Skip to content

Commit d143933

Browse files
committed
code review fix
1 parent 2cecb18 commit d143933

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

com.unity.formats.fbx/Editor/FbxExporter.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,18 +947,20 @@ SkinnedMeshRenderer unitySkin
947947
var fbxBone = MapUnityObjectToFbxNode[bone.gameObject];
948948
ExportTransform(bone, fbxBone, newCenter: Vector3.zero, TransformExportType.Local);
949949

950-
// cancel out the pre-rotation from the exported rotation
950+
// Cancel out the pre-rotation from the exported rotation
951+
952+
// Get prerotation
951953
var fbxPreRotationEuler = fbxBone.GetPreRotation(FbxNode.EPivotSet.eSourcePivot);
952-
// Get the inverse of the prerotation
954+
// Convert the prerotation to a Quaternion (so that it can be inverted)
953955
var fbxPreRotationInverse = ModelExporter.EulerToQuaternion(fbxPreRotationEuler);
956+
// Get the inverse of the prerotation
954957
fbxPreRotationInverse.Inverse();
955958

959+
// Multiply LclRotation by pre-rotation inverse to get the LclRotation without pre-rotation applied
956960
var fbxFinalQuat = fbxPreRotationInverse * EulerToQuaternion(new FbxVector4(fbxBone.LclRotation.Get()));
957961

958-
var finalUnityQuat = new FbxQuaternion((float)fbxFinalQuat.X, (float)fbxFinalQuat.Y, (float)fbxFinalQuat.Z, (float)fbxFinalQuat.W);
959-
960962
var quatToEulerMatrix = new FbxAMatrix();
961-
quatToEulerMatrix.SetQ(finalUnityQuat);
963+
quatToEulerMatrix.SetQ(fbxFinalQuat);
962964
fbxBone.LclRotation.Set(ToFbxDouble3(quatToEulerMatrix.GetR()));
963965
}
964966
}

0 commit comments

Comments
 (0)