Skip to content

Commit e6c4fda

Browse files
author
David Lassonde
committed
Removed the KeyTangentComparer
1 parent 8934722 commit e6c4fda

File tree

1 file changed

+1
-74
lines changed

1 file changed

+1
-74
lines changed

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

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -303,72 +303,6 @@ public virtual int Compare(Keyframe a, Keyframe b)
303303
}
304304
}
305305

306-
public class KeyTangentComparer : IComparer<Keyframe>
307-
{
308-
AnimationCurve curveA = null;
309-
AnimationCurve curveB = null;
310-
Dictionary<Keyframe,int> keyFrameToIndexA;
311-
Dictionary<Keyframe,int> keyFrameToIndexB;
312-
313-
public int CompareKeyTangents(Keyframe a, Keyframe b)
314-
{
315-
bool result = true;
316-
317-
result &= a.time.Equals(b.time);
318-
#if DEBUG_UNITTEST
319-
Debug.Log(string.Format("{2} a.time: {0}, b.time: {1}", a.time, b.time,result));
320-
#endif
321-
322-
result &= (AnimationUtility.GetKeyLeftTangentMode(curveA,keyFrameToIndexA[a]) == AnimationUtility.GetKeyLeftTangentMode(curveB,keyFrameToIndexB[b]));
323-
result &= (AnimationUtility.GetKeyRightTangentMode(curveA,keyFrameToIndexA[a]) == AnimationUtility.GetKeyRightTangentMode(curveB,keyFrameToIndexB[b]));
324-
#if DEBUG_UNITTEST
325-
Debug.Log(string.Format("comparison result = {0}\n" +
326-
"keyframe a left tangent mode = {1}\n" +
327-
"keyframe b left tangent mode = {2}\n" +
328-
"keyframe a right tangent mode = {3}\n" +
329-
"keyframe b right tangent mode = {4}\n",
330-
result,
331-
((AnimationUtility.TangentMode) AnimationUtility.GetKeyLeftTangentMode(curveA,keyFrameToIndexA[a])).ToString(),
332-
((AnimationUtility.TangentMode) AnimationUtility.GetKeyLeftTangentMode(curveB,keyFrameToIndexB[b])).ToString(),
333-
((AnimationUtility.TangentMode) AnimationUtility.GetKeyRightTangentMode(curveA,keyFrameToIndexA[a])).ToString(),
334-
((AnimationUtility.TangentMode) AnimationUtility.GetKeyRightTangentMode(curveB,keyFrameToIndexB[b])).ToString()));
335-
#endif
336-
return result ? 0 : 1;
337-
}
338-
339-
public int Compare(Keyframe a, Keyframe b)
340-
{
341-
if (curveA == null || curveB == null)
342-
{
343-
#if DEBUG_UNITTEST
344-
Debug.Log(string.Format("The animation curves were not set for this KeyTangentComparer});
345-
#endif
346-
347-
return 1;
348-
}
349-
return CompareKeyTangents(a,b);
350-
}
351-
352-
public void SetAnimationCurves(AnimationCurve a, AnimationCurve b)
353-
{
354-
curveA = a;
355-
curveB = b;
356-
357-
// Keep a dictionary of Keyframe->index for both curves
358-
keyFrameToIndexA = new Dictionary<Keyframe,int>();
359-
foreach (int index in Enumerable.Range(0,a.keys.Length))
360-
{
361-
keyFrameToIndexA[a.keys[index]] = index;
362-
}
363-
364-
keyFrameToIndexB = new Dictionary<Keyframe,int>();
365-
foreach (int index in Enumerable.Range(0,b.keys.Length))
366-
{
367-
keyFrameToIndexB[b.keys[index]] = index;
368-
}
369-
}
370-
}
371-
372306
public class AnimTester
373307
{
374308
public FbxAnimationTest.KeyData keyData;
@@ -591,13 +525,6 @@ public static void KeysTest (AnimationCurve expectedAnimCurve, AnimationCurve ac
591525
Assert.That (actualAnimCurve.length, Is.EqualTo(expectedAnimCurve.length), string.Format("{0} number of keys doesn't match", message));
592526

593527
Assert.That(actualAnimCurve.keys, Is.EqualTo(expectedAnimCurve.keys).Using<Keyframe>(keyComparer), string.Format("{0} key doesn't match", message));
594-
595-
// Setup our tangent comparer if it is the one we are using
596-
var tangentComparer = keyComparer as KeyTangentComparer;
597-
if (tangentComparer != null)
598-
{
599-
tangentComparer.SetAnimationCurves(actualAnimCurve, expectedAnimCurve);
600-
}
601528
}
602529

603530
public static void KeysTest (float [] expectedKeyTimes, float [] expectedKeyValues, AnimationCurve actualAnimCurve, string message, IComparer<Keyframe> keyComparer=null)
@@ -820,7 +747,7 @@ public int KeyTangentsAnimTest (float [] keyTimesInSeconds, Vector3 [] keyPosVal
820747

821748
KeyData keyData = new TransformKeyData { RotationType = rotCurveType, propertyNames = propertyNames, componentType = componentType, keyTimes = keyTimesInSeconds, keyPosValues = keyPosValues, keyEulerValues = keyRotValues };
822749

823-
var tester = new AnimTester {keyData=keyData, testName=testName, path=GetRandomFbxFilePath (), keyComparer=new KeyTangentComparer()};
750+
var tester = new AnimTester {keyData=keyData, testName=testName, path=GetRandomFbxFilePath ()};
824751
return tester.DoIt();
825752
}
826753

0 commit comments

Comments
 (0)