Skip to content

Commit e28208c

Browse files
authored
Merge pull request #285 from Unity-Technologies/Uni-35752-animation-unroll-filter
Uni 35752 animation unroll filter
2 parents fe3ccee + 6e512c7 commit e28208c

File tree

8 files changed

+67
-39
lines changed

8 files changed

+67
-39
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,12 @@ public void Animate(Transform unityTransform, FbxNode fbxNode, FbxAnimLayer fbxA
17931793
fbxAnimCurveY.KeyModifyEnd();
17941794
fbxAnimCurveX.KeyModifyEnd();
17951795

1796+
// Uni-35616 unroll curves to preserve continuous rotations
1797+
var fbxCurveNode = fbxNode.LclRotation.GetCurveNode(fbxAnimLayer, false /*should already exist*/);
1798+
1799+
FbxAnimCurveFilterUnroll fbxAnimUnrollFilter = new FbxAnimCurveFilterUnroll();
1800+
fbxAnimUnrollFilter.Apply(fbxCurveNode);
1801+
17961802
if (Verbose) {
17971803
Debug.Log("Exported rotation animation for " + fbxNode.GetName());
17981804
}

Assets/FbxExporters/Editor/UnitTests/FbxAnimationTest.cs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// NOTE: uncomment the next line to leave temporary FBX files on disk
2+
// and create a imported object in the scene.
3+
// #define DEBUG_UNITTEST
4+
15
using UnityEngine;
26
using UnityEditor;
37
using NUnit.Framework;
@@ -77,11 +81,11 @@ public static IEnumerable TestCases4 {
7781
// specify continuous rotations
7882
public static IEnumerable TestCases5 {
7983
get {
80-
yield return new TestCaseData (RotationInterpolation.kEuler /*use euler values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
84+
yield return new TestCaseData (RotationInterpolation.kEuler /*use euler values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (6);
8185
// Uni-35616 can't programmatically define a Euler (Quaternion) mix.
8286
// yield return new TestCaseData (RotationInterpolation.kMixed /*use euler+quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
8387
// Uni-35616 doesn't work with quaternions; rotations don't exceed 180
84-
// yield return new TestCaseData (RotationInterpolation.kQuaternion /*use quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
88+
yield return new TestCaseData (RotationInterpolation.kQuaternion /*use quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (6);
8589
}
8690
}
8791

@@ -112,8 +116,9 @@ public class FbxAnimationTest : ExporterTestBase
112116
[TearDown]
113117
public override void Term ()
114118
{
115-
// NOTE: comment out the next line to leave temporary FBX files on disk
119+
#if (!DEBUG_UNITTEST)
116120
base.Term ();
121+
#endif
117122
}
118123

119124
protected void AnimClipPropertyTest (AnimationClip animClipExpected, AnimationClip animClipActual)
@@ -384,6 +389,13 @@ public int AnimTest (KeyData keyData, string testName)
384389
AssetDatabase.ImportAsset (path);
385390
}
386391

392+
// create a scene GO so we can compare.
393+
#if DEBUG_UNITTEST
394+
GameObject prefabGO = AssetDatabase.LoadMainAssetAtPath (path) as GameObject;
395+
GameObject sceneGO = Object.Instantiate(prefabGO, keyData.targetObject.transform.localPosition, keyData.targetObject.transform.localRotation);
396+
sceneGO.name = "Imported_" + testName;
397+
#endif
398+
387399
//acquire imported object from exported file
388400
AnimationClip animClipImported = GetClipFromFbx (path);
389401

@@ -392,23 +404,31 @@ public int AnimTest (KeyData keyData, string testName)
392404
// check animCurve & keys
393405
int result = 0;
394406

407+
// keyed localEulerAnglesRaw.z m_LocalRotation.z -1
395408
foreach (EditorCurveBinding curveBinding in AnimationUtility.GetCurveBindings (animClipImported)) {
396409
AnimationCurve animCurveImported = AnimationUtility.GetEditorCurve (animClipImported, curveBinding);
397410
Assert.That (animCurveImported, Is.Not.Null);
398411

399-
string altPropertyName;
412+
string altBinding;
413+
414+
MapAltPropertyName.TryGetValue (curveBinding.propertyName, out altBinding);
400415

401-
MapAltPropertyName.TryGetValue (curveBinding.propertyName, out altPropertyName);
416+
bool hasAltBinding = !string.IsNullOrEmpty (altBinding);
402417

403-
bool hasAltPropertyName = !string.IsNullOrEmpty (altPropertyName);
418+
if (!hasAltBinding)
419+
altBinding = curveBinding.propertyName;
404420

405-
if (!hasAltPropertyName)
406-
altPropertyName = curveBinding.propertyName;
421+
int id = keyData.GetIndexOf (curveBinding.propertyName);
407422

408-
int id = keyData.GetIndexOf (altPropertyName);
423+
if (id == -1)
424+
id = keyData.GetIndexOf (altBinding);
425+
426+
#if DEBUG_UNITTEST
427+
Debug.Log(string.Format("animtest binding={0} altBinding={1} id={2}", curveBinding.propertyName, altBinding, id));
428+
#endif
409429

410430
if (id != -1) {
411-
AnimCurveTest (keyData.keyTimesInSeconds, hasAltPropertyName ? keyData.GetAltKeyValues (id) : keyData.GetKeyValues (id), animCurveImported, curveBinding.propertyName);
431+
AnimCurveTest (keyData.keyTimesInSeconds, hasAltBinding ? keyData.GetAltKeyValues (id) : keyData.GetKeyValues (id), animCurveImported, curveBinding.propertyName);
412432
result++;
413433
}
414434
}
@@ -491,6 +511,8 @@ public void LegacySkinnedMeshAnimTest (string fbxPath)
491511
AnimCurveTest(animCurveImported, animCurveOrig, curveBinding.propertyName);
492512
}
493513
}
514+
515+
494516
}
495517

496518
[Test, TestCaseSource (typeof (AnimationTestDataClass), "TestCases1")]

Assets/FbxSdk/LICENSE.txt

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Autodesk FBX SDK. Copyright (c) 2016 Autodesk, Inc. All rights reserved.
2-
Use of the FBX SDK requires agreeing to and complying with the FBX SDK License and Service Agreement terms
1+
Autodesk FBX SDK. Copyright (c) 2016 Autodesk, Inc. All rights reserved.
2+
Use of the FBX SDK requires agreeing to and complying with the FBX SDK License and Service Agreement terms
33
accessed at https://damassets.autodesk.net/content/dam/autodesk/www/Company/docs/pdf/legal-notices-&-trademarks/Autodesk_FBX_SDK_2015_License_and_Services_Agreement.pdf"

Assets/FbxSdk/Plugins/UnityFbxSdk.dll

100755100644
7.5 KB
Binary file not shown.

Assets/FbxSdk/Plugins/x64/MacOS/UnityFbxSdkNative.bundle/Contents/Info.plist

100755100644
File mode changed.

Assets/FbxSdk/README.txt

100755100644
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
FBX SDK C# Bindings
2-
===================
3-
4-
Autodesk FBX SDK. Copyright (c) 2016 Autodesk, Inc. All rights reserved.<br/>
5-
Use of the FBX SDK requires agreeing to and complying with the FBX SDK License and Service Agreement terms
6-
accessed at https://damassets.autodesk.net/content/dam/autodesk/www/Company/docs/pdf/legal-notices-&-trademarks/Autodesk_FBX_SDK_2015_License_and_Services_Agreement.pdf"
7-
8-
**Version**: 1.2.0b1
9-
10-
This package contains only a subset of the FbxSdk, and is designed to work in the Unity Editor only.
11-
12-
How to Access Bindings in Code
13-
-------------------------------
14-
All the bindings are located under the FbxSdk namespace,
15-
and are accessed almost the same way as in C++.
16-
e.g. FbxManager::Create() in C++ becomes FbxSdk.FbxManager.Create() in C#
17-
18-
19-
How to Access Global Variables and Functions
20-
--------------------------------------------
21-
All global variables and functions are in Globals.cs, in the Globals class under the FbxSdk namespace.
22-
e.g. if we want to access the IOSROOT variable, we would do FbxSdk.Globals.IOSROOT
23-
24-
25-
How to Access Documentation for Bindings
26-
----------------------------------------
27-
1. Unzip docs.zip outside of the Assets folder
1+
FBX SDK C# Bindings
2+
===================
3+
4+
Autodesk FBX SDK. Copyright (c) 2016 Autodesk, Inc. All rights reserved.<br/>
5+
Use of the FBX SDK requires agreeing to and complying with the FBX SDK License and Service Agreement terms
6+
accessed at https://damassets.autodesk.net/content/dam/autodesk/www/Company/docs/pdf/legal-notices-&-trademarks/Autodesk_FBX_SDK_2015_License_and_Services_Agreement.pdf"
7+
8+
**Version**: sprint42
9+
10+
This package contains only a subset of the FbxSdk, and is designed to work in the Unity Editor only.
11+
12+
How to Access Bindings in Code
13+
-------------------------------
14+
All the bindings are located under the FbxSdk namespace,
15+
and are accessed almost the same way as in C++.
16+
e.g. FbxManager::Create() in C++ becomes FbxSdk.FbxManager.Create() in C#
17+
18+
19+
How to Access Global Variables and Functions
20+
--------------------------------------------
21+
All global variables and functions are in Globals.cs, in the Globals class under the FbxSdk namespace.
22+
e.g. if we want to access the IOSROOT variable, we would do FbxSdk.Globals.IOSROOT
23+
24+
25+
How to Access Documentation for Bindings
26+
----------------------------------------
27+
1. Unzip docs.zip outside of the Assets folder
2828
2. Open docs/html/index.html

Assets/FbxSdk/docs.zip

100755100644
1.45 KB
Binary file not shown.

0 commit comments

Comments
 (0)