Skip to content

Commit 190ab26

Browse files
committed
Revert "remove keytangents test"
This reverts commit c027e2d.
1 parent bf5dd69 commit 190ab26

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Assets/com.unity.formats.fbx/EditorTests/FbxAnimationTest.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,33 @@ public virtual int Compare(Keyframe a, Keyframe b)
303303
}
304304
}
305305

306+
public class KeyTangentComparer : IComparer<Keyframe>
307+
{
308+
public int CompareKeyTangents(Keyframe a, Keyframe b)
309+
{
310+
bool result = true;
311+
312+
result &= a.time.Equals(b.time);
313+
#if DEBUG_UNITTEST
314+
Debug.Log(string.Format("{2} a.time: {0}, b.time: {1}", a.time, b.time,result));
315+
#endif
316+
// TODO : use AnimationUtility.GetLeftTangentMode
317+
// requires reference to AnimationCurve and keyindex
318+
result &= (a.tangentMode == b.tangentMode);
319+
#if DEBUG_UNITTEST
320+
Debug.Log(string.Format("{2} a.tangentMode={0} b.tangentMode={1}",
321+
((AnimationUtility.TangentMode)a.tangentMode).ToString(),
322+
((AnimationUtility.TangentMode)b.tangentMode).ToString(),result));
323+
#endif
324+
return result ? 0 : 1;
325+
}
326+
327+
public int Compare(Keyframe a, Keyframe b)
328+
{
329+
return CompareKeyTangents(a,b);
330+
}
331+
}
332+
306333
public class AnimTester
307334
{
308335
public FbxAnimationTest.KeyData keyData;
@@ -725,6 +752,30 @@ public int ContinuousRotationAnimTest (RotationCurveType rotCurveType, float []
725752
return tester.DoIt();
726753
}
727754

755+
[Description("Uni-35935 key tangents")]
756+
[Test, TestCaseSource (typeof (AnimationTestDataClass), "KeyTangentsTestCases")]
757+
public int KeyTangentsAnimTest (float [] keyTimesInSeconds, Vector3 [] keyPosValues, Vector3 [] keyRotValues)
758+
{
759+
System.Type componentType = typeof(Transform);
760+
761+
if (keyRotValues == null)
762+
{
763+
keyRotValues = new Vector3[keyPosValues.Length];
764+
}
765+
766+
string[] propertyNames = null;
767+
string testName = componentType.ToString () + "_KeyTangents";
768+
RotationCurveType rotCurveType = RotationCurveType.kEuler;
769+
770+
testName += "_Euler";
771+
propertyNames = AnimationTestDataClass.m_rotationEulerNames.Concat(AnimationTestDataClass.m_translationNames).ToArray();
772+
773+
KeyData keyData = new TransformKeyData { RotationType = rotCurveType, propertyNames = propertyNames, componentType = componentType, keyTimes = keyTimesInSeconds, keyPosValues = keyPosValues, keyEulerValues = keyRotValues };
774+
775+
var tester = new AnimTester {keyData=keyData, testName=testName, path=GetRandomFbxFilePath (), keyComparer=new KeyTangentComparer()};
776+
return tester.DoIt();
777+
}
778+
728779
[Test, TestCaseSource (typeof (AnimationTestDataClass), "ComponentTestCases")]
729780
public int ComponentAnimTest (System.Type componentType)
730781
{

0 commit comments

Comments
 (0)