@@ -26,12 +26,19 @@ public class AnimationTestDataClass
26
26
Where ( t => typeof ( Component ) . IsAssignableFrom ( t ) &&
27
27
ModelExporter . MapsToFbxObject . ContainsKey ( t ) ) . Except ( m_exceptionTypes ) ;
28
28
29
+ public static string [ ] m_localRotationNames = new string [ 4 ] { "m_LocalRotation.x" , "m_LocalRotation.y" , "m_LocalRotation.z" , "m_LocalRotation.w" } ;
30
+ public static string [ ] m_localTranslationNames = new string [ 3 ] { "m_LocalPosition.x" , "m_LocalPosition.y" , "m_LocalPosition.z" } ;
31
+
29
32
public static float [ ] m_keytimes1 = new float [ 3 ] { 1f , 2f , 3f } ;
30
33
public static float [ ] m_keyFloatValues1 = new float [ 3 ] { 0f , 100f , 0f } ;
31
34
public static float [ ] m_keyvalues2 = new float [ 3 ] { 1f , 100f , 1f } ;
32
35
public static Vector3 [ ] m_keyEulerValues3 = new Vector3 [ 3 ] { new Vector3 ( 0f , 80f , 0f ) , new Vector3 ( 80f , 0f , 0f ) , new Vector3 ( 0f , 0f , 80f ) } ;
33
36
public static Vector3 [ ] m_keyEulerValues4 = new Vector3 [ 3 ] { new Vector3 ( 0f , 270f , 0f ) , new Vector3 ( 270f , 0f , 0f ) , new Vector3 ( 0f , 0f , 270f ) } ;
34
37
38
+ public static float [ ] m_keytimes5 = new float [ 5 ] { 0f , 30f , 60f , 90f , 120f } ;
39
+ public static Vector3 [ ] m_keyPosValues5 = new Vector3 [ 5 ] { new Vector3 ( 5.078195f , 0.000915527f , 4.29761f ) , new Vector3 ( 0.81f , 0.000915527f , 10.59f ) , new Vector3 ( - 3.65f , 0.000915527f , 4.29761f ) , new Vector3 ( 0.81f , 0.000915527f , - 3.37f ) , new Vector3 ( 5.078195f , 0.000915527f , 4.29761f ) } ;
40
+ public static Vector3 [ ] m_keyRotValues5 = new Vector3 [ 5 ] { new Vector3 ( 0f , 0f , 0f ) , new Vector3 ( 0f , - 90f , 0f ) , new Vector3 ( 0f , - 180f , 0f ) , new Vector3 ( 0f , - 270f , 0f ) , new Vector3 ( 0f , - 360f , 0f ) } ;
41
+
35
42
public static IEnumerable TestCases1 {
36
43
get {
37
44
yield return new TestCaseData ( m_keytimes1 , m_keyvalues2 , typeof ( Transform ) , "m_LocalScale.x" ) . Returns ( 1 ) ;
@@ -44,13 +51,13 @@ public static IEnumerable TestCases1 {
44
51
}
45
52
public static IEnumerable TestCases2 {
46
53
get {
47
- yield return new TestCaseData ( m_keytimes1 , m_keyEulerValues3 , typeof ( Transform ) , new string [ 4 ] { "m_LocalRotation.x" , "m_LocalRotation.y" , "m_LocalRotation.z" , "m_LocalRotation.w" } ) . Returns ( 3 ) ;
54
+ yield return new TestCaseData ( m_keytimes1 , m_keyEulerValues3 , typeof ( Transform ) , m_localRotationNames ) . Returns ( 3 ) ;
48
55
}
49
56
}
50
57
// specify gimbal conditions for rotation
51
58
public static IEnumerable TestCases3 {
52
59
get {
53
- yield return new TestCaseData ( m_keytimes1 , m_keyEulerValues4 , typeof ( Transform ) , new string [ 4 ] { "m_LocalRotation.x" , "m_LocalRotation.y" , "m_LocalRotation.z" , "m_LocalRotation.w" } ) . Returns ( 3 ) ;
60
+ yield return new TestCaseData ( m_keytimes1 , m_keyEulerValues4 , typeof ( Transform ) , m_localRotationNames ) . Returns ( 3 ) ;
54
61
}
55
62
}
56
63
// specify one of each component type
@@ -60,6 +67,12 @@ public static IEnumerable TestCases4 {
60
67
yield return new TestCaseData ( cType ) . Returns ( 1 ) ;
61
68
}
62
69
}
70
+ // specify continuous rotations
71
+ public static IEnumerable TestCases5 {
72
+ get {
73
+ yield return new TestCaseData ( m_keytimes5 , m_keyRotValues5 . Concat ( m_keyPosValues5 ) . ToArray ( ) , typeof ( Transform ) , m_localRotationNames . Concat ( m_localTranslationNames ) . ToArray ( ) ) . Returns ( 3 ) ;
74
+ }
75
+ }
63
76
}
64
77
65
78
[ TestFixture ]
@@ -171,6 +184,46 @@ public override int FindComponent (string name)
171
184
}
172
185
}
173
186
187
+ public class TransformKeyData : KeyData
188
+ {
189
+ public string [ ] propertyNames ;
190
+ public Vector3 [ ] keyValues ; // NOTE: first half is Quaternions and second half is Translation
191
+ public bool IsRotation ( int id ) { return id < 4 ; }
192
+
193
+ public override int NumKeys { get { return Mathf . Min ( keyTimesInSeconds . Length , keyValues . Length / 2 ) ; } }
194
+ public override int NumComponents { get { return propertyNames . Length ; } }
195
+ public override float [ ] GetKeyValues ( int id )
196
+ {
197
+ float [ ] result = new float [ NumKeys ] ;
198
+ bool isRot = IsRotation ( id ) ;
199
+
200
+ for ( int idx = 0 ; idx < NumKeys ; idx ++ )
201
+ {
202
+ result [ idx ] = ( isRot ) ? Quaternion . Euler ( keyValues [ idx ] ) [ id ] : keyValues [ NumKeys + idx ] [ id - 4 ] ;
203
+ }
204
+
205
+ return result ;
206
+ }
207
+ public override float [ ] GetAltKeyValues ( int id )
208
+ {
209
+ float [ ] result = new float [ NumKeys ] ;
210
+ bool isRot = IsRotation ( id ) ;
211
+
212
+ for ( int idx = 0 ; idx < NumKeys ; idx ++ )
213
+ {
214
+ result [ idx ] = ( isRot ) ? keyValues [ idx ] [ id ] : keyValues [ NumKeys + idx ] [ id - 4 ] ;
215
+ }
216
+
217
+ return result ;
218
+ }
219
+
220
+ public override string GetComponentName ( int id ) { return propertyNames [ id ] ; }
221
+ public override int FindComponent ( string name )
222
+ {
223
+ return System . Array . IndexOf ( propertyNames , name ) ;
224
+ }
225
+ }
226
+
174
227
GameObject CreateTargetObject ( string name , System . Type componentType )
175
228
{
176
229
GameObject goModel = new GameObject ( ) ;
@@ -301,7 +354,16 @@ public int GimbalConditionsAnimTest (float [] keyTimesInSeconds, Vector3 [] keyV
301
354
{
302
355
KeyData keyData = new QuaternionKeyData { propertyNames = componentNames , componentType = componentType , keyTimesInSeconds = keyTimesInSeconds , keyEulerValues = keyValues } ;
303
356
304
- return AnimTest ( keyData , componentType . ToString ( ) + "_Quaternion" ) ;
357
+ return AnimTest ( keyData , componentType . ToString ( ) + "_Gimbal" ) ;
358
+ }
359
+
360
+ [ Description ( "Uni-35616 continuous rotations" ) ]
361
+ [ Test , TestCaseSource ( typeof ( AnimationTestDataClass ) , "TestCases5" ) ]
362
+ public int ContinuousRotationAnimTest ( float [ ] keyTimesInSeconds , Vector3 [ ] keyValues , System . Type componentType , string [ ] propertyNames )
363
+ {
364
+ KeyData keyData = new TransformKeyData { propertyNames = propertyNames , componentType = componentType , keyTimesInSeconds = keyTimesInSeconds , keyValues = keyValues } ;
365
+
366
+ return AnimTest ( keyData , componentType . ToString ( ) + "_ContinuousRotations" ) ;
305
367
}
306
368
307
369
[ Test , TestCaseSource ( typeof ( AnimationTestDataClass ) , "TestCases4" ) ]
0 commit comments