@@ -431,47 +431,41 @@ public int Main (KeyData keyData, string testName, string path)
431
431
AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( animClipImported , curveBinding ) ;
432
432
Assert . That ( animCurveImported , Is . Not . Null ) ;
433
433
434
- string propertyBinding ;
434
+ string propertyBinding = curveBinding . propertyName ;
435
+ int id = keyData . GetIndexOf ( propertyBinding ) ;
435
436
436
- MapEulerToQuaternionPropertyName . TryGetValue ( curveBinding . propertyName , out propertyBinding ) ;
437
+ bool hasQuatBinding =
438
+ MapEulerToQuaternionPropertyName . TryGetValue ( propertyBinding , out propertyBinding ) ;
437
439
438
- bool hasQuatBinding = ! string . IsNullOrEmpty ( propertyBinding ) ;
439
-
440
- if ( ! hasQuatBinding )
441
- propertyBinding = curveBinding . propertyName ;
442
-
443
- int id = keyData . GetIndexOf ( curveBinding . propertyName ) ;
444
-
445
- if ( id == - 1 )
440
+ if ( id == - 1 )
446
441
id = keyData . GetIndexOf ( propertyBinding ) ;
447
442
448
443
#if DEBUG_UNITTEST
449
- Debug . Log ( string . Format ( "animtest binding ={0} quatBinding ={1} id={2}" , curveBinding . propertyName , propertyBinding , id ) ) ;
444
+ Debug . Log ( string . Format ( "propertyBinding ={0} mappedBinding ={1} id={2}" , curveBinding . propertyName , propertyBinding , id ) ) ;
450
445
#endif
451
446
452
447
if ( id != - 1 )
453
448
{
454
449
if ( keyData . compareOriginalKeys )
455
450
{
456
- // NOTE: we cannot test the keys on curves that go out as quaternion
457
- // return as euler.
451
+ // NOTE: we cannot compare the keys that exported quaternion but are imported as euler.
458
452
if ( ! hasQuatBinding )
459
453
{
460
- // test against original data
454
+ // compare against original keydata
461
455
KeysTest ( keyData . keyTimes , keyData . GetKeyValues ( id ) , animCurveImported , curveBinding . propertyName ) ;
462
456
463
- // test against origin curve keys
457
+ // compare against original animCurve
464
458
KeysTest ( animCurvesOriginal [ id ] , animCurveImported , curveBinding . propertyName , keyComparer ) ;
465
459
}
466
460
else
467
461
{
468
- // test against original data
469
- KeysTest ( keyData . keyTimes , keyData . GetAltKeyValues ( id ) , animCurveImported , curveBinding . propertyName ) ;
462
+ // compare by sampled keyvalues against original keydata
463
+ KeyValuesTest ( keyData . keyTimes , keyData . GetAltKeyValues ( id ) , animCurveImported , curveBinding . propertyName ) ;
470
464
}
471
465
}
472
466
else
473
467
{
474
- // test against original data
468
+ // compare by sampled keyvalues against original animCurve
475
469
KeyValuesTest ( animCurvesOriginal [ id ] , animCurveImported , curveBinding . propertyName ) ;
476
470
}
477
471
result ++ ;
@@ -503,45 +497,61 @@ public static void KeysTest (AnimationCurve expectedAnimCurve, AnimationCurve ac
503
497
Assert . That ( actualAnimCurve . keys , Is . EqualTo ( expectedAnimCurve . keys ) . Using < Keyframe > ( keyComparer ) , string . Format ( "{0} key doesn't match" , message ) ) ;
504
498
}
505
499
506
- public static void KeyValuesTest ( AnimationCurve expectedAnimCurve , AnimationCurve actualAnimCurve , string message )
507
- {
508
- foreach ( var key in expectedAnimCurve . keys )
509
- {
510
- float actualKeyValue = actualAnimCurve . Evaluate ( key . time ) ;
511
-
512
- #if DEBUG_UNITTEST
513
- Debug . Log ( string . Format ( "key time={0} actual={1} expected={2} delta={3}" , key . time . ToString ( ) , key . value . ToString ( ) , actualKeyValue . ToString ( ) , Mathf . Abs ( key . value - actualKeyValue ) . ToString ( ) ) ) ;
514
- #endif
515
- Assert . That ( key . value , Is . EqualTo ( actualKeyValue ) . Within ( 0.000001 ) , string . Format ( "{0} key ({1}) doesn't match" , message , key . time ) ) ;
516
- }
517
- }
518
-
519
- public static void KeysTest ( float [ ] keyTimesExpected , float [ ] keyValuesExpected , AnimationCurve actualAnimCurve , string message , IComparer < Keyframe > keyComparer = null )
500
+ public static void KeysTest ( float [ ] expectedKeyTimes , float [ ] expectedKeyValues , AnimationCurve actualAnimCurve , string message , IComparer < Keyframe > keyComparer = null )
520
501
{
521
502
if ( keyComparer == null )
522
503
keyComparer = new BasicKeyComparer ( ) ;
523
504
524
- int numKeysExpected = keyTimesExpected . Length ;
505
+ int numKeysExpected = expectedKeyTimes . Length ;
525
506
526
507
// NOTE : Uni-34492 number of keys don't match
527
508
Assert . That ( actualAnimCurve . length , Is . EqualTo ( numKeysExpected ) , string . Format ( "{0} number of keys doesn't match" , message ) ) ;
528
509
529
- //check imported animation against original
510
+ // check actual animation against expected
530
511
// NOTE: if I check the key values explicitly they match but when I compare using this ListMapper the float values
531
512
// are off by 0.000005f; not sure why that happens.
532
513
var keysExpected = new Keyframe [ numKeysExpected ] ;
533
514
534
515
for ( int idx = 0 ; idx < numKeysExpected ; idx ++ )
535
516
{
536
- keysExpected [ idx ] . time = keyTimesExpected [ idx ] ;
537
- keysExpected [ idx ] . value = keyValuesExpected [ idx ] ;
517
+ keysExpected [ idx ] . time = expectedKeyTimes [ idx ] ;
518
+ keysExpected [ idx ] . value = expectedKeyValues [ idx ] ;
538
519
}
539
520
540
521
Assert . That ( actualAnimCurve . keys , Is . EqualTo ( keysExpected ) . Using < Keyframe > ( keyComparer ) , string . Format ( "{0} key doesn't match" , message ) ) ;
541
522
542
523
return ;
543
524
}
544
525
526
+ public static void KeyValuesTest ( float [ ] expectedKeyTimes , float [ ] expectedKeyValues , AnimationCurve actualAnimCurve , string message )
527
+ {
528
+ for ( var i = 0 ; i < expectedKeyTimes . Length ; ++ i )
529
+ {
530
+ float expectedKeyTime = expectedKeyTimes [ i ] ;
531
+ float expectedKeyValue = expectedKeyValues [ i ] ;
532
+
533
+ float actualKeyValue = actualAnimCurve . Evaluate ( expectedKeyTime ) ;
534
+
535
+ #if DEBUG_UNITTEST
536
+ Debug . Log ( string . Format ( "key time={0} expected={1} actual={2} delta={3}" , expectedKeyTime . ToString ( ) , expectedKeyValue . ToString ( ) , actualKeyValue . ToString ( ) , Mathf . Abs ( expectedKeyValue - actualKeyValue ) . ToString ( ) ) ) ;
537
+ #endif
538
+ Assert . That ( expectedKeyValue , Is . EqualTo ( actualKeyValue ) . Within ( 0.000001 ) , string . Format ( "{0} key ({1}) doesn't match" , message , expectedKeyTime ) ) ;
539
+ }
540
+ }
541
+
542
+ public static void KeyValuesTest ( AnimationCurve expectedAnimCurve , AnimationCurve actualAnimCurve , string message )
543
+ {
544
+ foreach ( var key in expectedAnimCurve . keys )
545
+ {
546
+ float actualKeyValue = actualAnimCurve . Evaluate ( key . time ) ;
547
+
548
+ #if DEBUG_UNITTEST
549
+ Debug . Log ( string . Format ( "key time={0} actual={1} expected={2} delta={3}" , key . time . ToString ( ) , key . value . ToString ( ) , actualKeyValue . ToString ( ) , Mathf . Abs ( key . value - actualKeyValue ) . ToString ( ) ) ) ;
550
+ #endif
551
+ Assert . That ( key . value , Is . EqualTo ( actualKeyValue ) . Within ( 0.000001 ) , string . Format ( "{0} key ({1}) doesn't match" , message , key . time ) ) ;
552
+ }
553
+ }
554
+
545
555
public static void CurveTest ( AnimationCurve animCurveImported , AnimationCurve animCurveActual , string message )
546
556
{
547
557
// TODO : Uni-34492 number of keys don't match
0 commit comments