Skip to content

Commit cad7556

Browse files
committed
tidy commit
1 parent fcb7d6c commit cad7556

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxAnimationTest.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public static IEnumerable TestCases4 {
7171
// specify continuous rotations
7272
public static IEnumerable TestCases5 {
7373
get {
74-
yield return new TestCaseData (m_keytimes5, m_keyRotValues5.Concat(m_keyPosValues5).ToArray(), typeof (Transform), m_eulerRotationNames.Concat(m_translationNames).ToArray() ).Returns (3);
74+
yield return new TestCaseData (false /*use quaternion values*/, m_keytimes5, m_keyRotValues5.Concat(m_keyPosValues5).ToArray()).Returns (3);
75+
// Uni-35616 continuous rotations doesn't work with quaternions
76+
// yield return new TestCaseData (true /*use quaternion values*/, m_keytimes5, m_keyRotValues5.Concat(m_keyPosValues5).ToArray()).Returns (3);
7577
}
7678
}
7779
}
@@ -90,7 +92,7 @@ public class FbxAnimationTest : ExporterTestBase
9092
public override void Term ()
9193
{
9294
// NOTE: comment out the next line to leave temporary FBX files on disk
93-
//base.Term ();
95+
base.Term ();
9496
}
9597

9698
protected void AnimClipTest (AnimationClip animClipExpected, AnimationClip animClipActual)
@@ -117,8 +119,10 @@ protected void AnimCurveTest (float [] keyTimesExpected, float [] keyValuesExpec
117119
Assert.That (animCurveActual.length, Is.EqualTo(numKeysExpected), "animcurve number of keys doesn't match");
118120

119121
//check imported animation against original
120-
Assert.That(List.Map(animCurveActual.keys).Property ("time"), Is.EqualTo(keyTimesExpected), string.Format("{0} key time doesn't match",message));
121-
Assert.That(List.Map(animCurveActual.keys).Property ("value"), Is.EqualTo(keyValuesExpected).Within(0.000005f), string.Format("{0} key value doesn't match", message));
122+
// NOTE: if I check the key values explicitly they match but when I compare using this ListMapper the float values
123+
// are off by 0.000005f; not sure why that happens.
124+
Assert.That(new ListMapper(animCurveActual.keys).Property ("time"), Is.EqualTo(keyTimesExpected), string.Format("{0} key time doesn't match",message));
125+
Assert.That(new ListMapper(animCurveActual.keys).Property ("value"), Is.EqualTo(keyValuesExpected).Within(0.000005f), string.Format("{0} key value doesn't match", message));
122126

123127
return ;
124128
}
@@ -189,9 +193,9 @@ public class TransformKeyData : KeyData
189193
{
190194
public const int kNumQuatRotFields = 4;
191195
public const int kNumEulerRotFields = 3;
192-
public bool useQuaternion = false;
196+
public bool useQuaternionValues = false;
193197

194-
public int NumRotationFields { get { return ((useQuaternion) ? kNumQuatRotFields : kNumEulerRotFields); } }
198+
public int NumRotationFields { get { return ((useQuaternionValues) ? kNumQuatRotFields : kNumEulerRotFields); } }
195199

196200
public string[] propertyNames;
197201
public Vector3 [] keyValues; // NOTE: first half is Euler Rotation and second half is Translation
@@ -203,7 +207,7 @@ public class TransformKeyData : KeyData
203207
public override int NumComponents { get { return propertyNames.Length; } }
204208
public override float [] GetKeyValues (int id)
205209
{
206-
if (!useQuaternion) return GetAltKeyValues(id);
210+
if (!useQuaternionValues) return GetAltKeyValues(id);
207211

208212
// compute continous rotations
209213
if (keyQuatValues==null)
@@ -224,10 +228,6 @@ public override float [] GetKeyValues (int id)
224228
currQuat *= Quaternion.Euler(deltaRot);
225229
keyQuatValues[idx] = currQuat;
226230
}
227-
Debug.Log(string.Format("{0} rot[{1},{2},{3}] quat[{4},{5},{6},{7}]", idx,
228-
keyValues[idx][0], keyValues[idx][1], keyValues[idx][2],
229-
keyQuatValues[idx][0], keyQuatValues[idx][1], keyQuatValues[idx][2], keyQuatValues[idx][3]
230-
));
231231
}
232232
}
233233

@@ -394,9 +394,15 @@ public int GimbalConditionsAnimTest (float [] keyTimesInSeconds, Vector3 [] keyV
394394

395395
[Description("Uni-35616 continuous rotations")]
396396
[Test, TestCaseSource (typeof (AnimationTestDataClass), "TestCases5")]
397-
public int ContinuousRotationAnimTest (float [] keyTimesInSeconds, Vector3 [] keyValues, System.Type componentType, string [] propertyNames)
397+
public int ContinuousRotationAnimTest (bool useQuaternionValues, float [] keyTimesInSeconds, Vector3 [] keyValues)
398398
{
399-
KeyData keyData = new TransformKeyData { propertyNames = propertyNames, componentType = componentType, keyTimesInSeconds = keyTimesInSeconds, keyValues = keyValues };
399+
System.Type componentType = typeof(Transform);
400+
401+
string[] propertyNames = useQuaternionValues ?
402+
AnimationTestDataClass.m_quaternionRotationNames.Concat(AnimationTestDataClass.m_translationNames).ToArray() :
403+
AnimationTestDataClass.m_eulerRotationNames.Concat(AnimationTestDataClass.m_translationNames).ToArray();
404+
405+
KeyData keyData = new TransformKeyData { useQuaternionValues = useQuaternionValues, propertyNames = propertyNames, componentType = componentType, keyTimesInSeconds = keyTimesInSeconds, keyValues = keyValues };
400406

401407
return AnimTest (keyData, componentType.ToString () + "_ContinuousRotations");
402408
}

0 commit comments

Comments
 (0)