@@ -303,6 +303,33 @@ public virtual int Compare(Keyframe a, Keyframe b)
303
303
}
304
304
}
305
305
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
+
306
333
public class AnimTester
307
334
{
308
335
public FbxAnimationTest . KeyData keyData ;
@@ -725,6 +752,30 @@ public int ContinuousRotationAnimTest (RotationCurveType rotCurveType, float []
725
752
return tester . DoIt ( ) ;
726
753
}
727
754
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
+
728
779
[ Test , TestCaseSource ( typeof ( AnimationTestDataClass ) , "ComponentTestCases" ) ]
729
780
public int ComponentAnimTest ( System . Type componentType )
730
781
{
0 commit comments