Skip to content

Commit ba4b192

Browse files
committed
code review fixes
1 parent b626c1e commit ba4b192

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,13 +1922,13 @@ private void TransferMotion(Transform source, Transform dest, float sampleRate,
19221922
var rotKeyFrames = new Keyframe[3][];
19231923
var scaleKeyFrames = new Keyframe[3][];
19241924

1925-
for (int t = 0; t < posKeyFrames.Length; t++) {
1926-
posKeyFrames [t] = new Keyframe[sampleTimes.Count];
1927-
rotKeyFrames[t] = new Keyframe[sampleTimes.Count];
1928-
scaleKeyFrames[t] = new Keyframe[sampleTimes.Count];
1925+
for (int k = 0; k < posKeyFrames.Length; k++) {
1926+
posKeyFrames [k] = new Keyframe[sampleTimes.Count];
1927+
rotKeyFrames[k] = new Keyframe[sampleTimes.Count];
1928+
scaleKeyFrames[k] = new Keyframe[sampleTimes.Count];
19291929
}
19301930

1931-
int i = 0;
1931+
int keyIndex = 0;
19321932
foreach (var currSampleTime in sampleTimes)
19331933
{
19341934
var sourceLocalMatrix = GetTransformMatrix (currSampleTime, source, sourceUnityCurves);
@@ -1955,27 +1955,27 @@ private void TransferMotion(Transform source, Transform dest, float sampleRate,
19551955
var rot = newLocalMatrix.rotation.eulerAngles;
19561956

19571957
for (int k = 0; k < 3; k++) {
1958-
posKeyFrames [k][i] = new Keyframe(currSampleTime, (float)translation [k]);
1959-
rotKeyFrames [k][i] = new Keyframe(currSampleTime, (float)rot [k]);
1960-
scaleKeyFrames [k][i] = new Keyframe(currSampleTime, (float)scale [k]);
1958+
posKeyFrames [k][keyIndex] = new Keyframe(currSampleTime, (float)translation [k]);
1959+
rotKeyFrames [k][keyIndex] = new Keyframe(currSampleTime, (float)rot [k]);
1960+
scaleKeyFrames [k][keyIndex] = new Keyframe(currSampleTime, (float)scale [k]);
19611961
}
1962-
i++;
1962+
keyIndex++;
19631963
}
19641964

19651965
// create the new list of unity curves, and add it to dest's curves
19661966
var newUnityCurves = new List<UnityCurve>();
19671967
string posPropName = "m_LocalPosition.";
19681968
string rotPropName = "localEulerAnglesRaw.";
19691969
string scalePropName = "m_LocalScale.";
1970-
var xyz = new string[]{ "x", "y", "z" };
1971-
for (int j = 0; j < 3; j++) {
1972-
var posUniCurve = new UnityCurve ( posPropName + xyz[j], new AnimationCurve(posKeyFrames[j]));
1970+
var xyz = "xyz";
1971+
for (int k = 0; k < 3; k++) {
1972+
var posUniCurve = new UnityCurve ( posPropName + xyz[k], new AnimationCurve(posKeyFrames[k]));
19731973
newUnityCurves.Add (posUniCurve);
19741974

1975-
var rotUniCurve = new UnityCurve ( rotPropName + xyz[j], new AnimationCurve(rotKeyFrames[j]));
1975+
var rotUniCurve = new UnityCurve ( rotPropName + xyz[k], new AnimationCurve(rotKeyFrames[k]));
19761976
newUnityCurves.Add (rotUniCurve);
19771977

1978-
var scaleUniCurve = new UnityCurve ( scalePropName + xyz[j], new AnimationCurve(scaleKeyFrames[j]));
1978+
var scaleUniCurve = new UnityCurve ( scalePropName + xyz[k], new AnimationCurve(scaleKeyFrames[k]));
19791979
newUnityCurves.Add (scaleUniCurve);
19801980
}
19811981

@@ -2031,9 +2031,9 @@ public UnityCurve(string propertyName, AnimationCurve uniAnimCurve){
20312031

20322032
private int GetPositionIndex(string uniPropertyName){
20332033
System.StringComparison ct = System.StringComparison.CurrentCulture;
2034-
bool isEulerComponent = uniPropertyName.StartsWith ("m_LocalPosition.", ct);
2034+
bool isPositionComponent = uniPropertyName.StartsWith ("m_LocalPosition.", ct);
20352035

2036-
if (!isEulerComponent) { return -1; }
2036+
if (!isPositionComponent) { return -1; }
20372037

20382038
switch (uniPropertyName [uniPropertyName.Length - 1]) {
20392039
case 'x':
@@ -2049,9 +2049,9 @@ private int GetPositionIndex(string uniPropertyName){
20492049

20502050
private int GetScaleIndex(string uniPropertyName){
20512051
System.StringComparison ct = System.StringComparison.CurrentCulture;
2052-
bool isEulerComponent = uniPropertyName.StartsWith ("m_LocalScale.", ct);
2052+
bool isScaleComponent = uniPropertyName.StartsWith ("m_LocalScale.", ct);
20532053

2054-
if (!isEulerComponent) { return -1; }
2054+
if (!isScaleComponent) { return -1; }
20552055

20562056
switch (uniPropertyName [uniPropertyName.Length - 1]) {
20572057
case 'x':
@@ -2257,7 +2257,13 @@ protected int ExportTransformHierarchy(
22572257
return numObjectsExported;
22582258
}
22592259

2260-
2260+
/// <summary>
2261+
/// Checks if the transform should be reset.
2262+
/// Transform should be reset if animation is being transferred, and this transform
2263+
/// is either the animation source, destination, or between these nodes.
2264+
/// </summary>
2265+
/// <returns><c>true</c>, if transform should be reset, <c>false</c> otherwise.</returns>
2266+
/// <param name="t">Transform.</param>
22612267
private bool ResetTransform(Transform t){
22622268
var source = ExportOptions.AnimationSource;
22632269
var dest = ExportOptions.AnimationDest;

0 commit comments

Comments
 (0)