@@ -156,7 +156,7 @@ public enum FbxNodeRelationType
156
156
/// keep a map between the constrained FbxNode (in Unity this is the GameObject with constraint component)
157
157
/// and its FbxConstraints for quick lookup when exporting constraint animations.
158
158
/// </summary>
159
- Dictionary < FbxNode , List < FbxConstraint > > MapConstrainedObjectToConstraints = new Dictionary < FbxNode , List < FbxConstraint > > ( ) ;
159
+ Dictionary < FbxNode , Dictionary < FbxConstraint , System . Type > > MapConstrainedObjectToConstraints = new Dictionary < FbxNode , Dictionary < FbxConstraint , System . Type > > ( ) ;
160
160
161
161
/// <summary>
162
162
/// Map Unity material name to FBX material object
@@ -1425,7 +1425,7 @@ protected bool ExportCommonConstraintProperties<T,U>(T uniConstraint, U fbxConst
1425
1425
fbxConstraint . Lock . Set ( uniConstraint . locked ) ;
1426
1426
fbxConstraint . Weight . Set ( uniConstraint . weight * UnitScaleFactor ) ;
1427
1427
1428
- AddFbxNodeToConstraintsMapping ( fbxNode , fbxConstraint ) ;
1428
+ AddFbxNodeToConstraintsMapping ( fbxNode , fbxConstraint , typeof ( T ) ) ;
1429
1429
return true ;
1430
1430
}
1431
1431
@@ -1459,13 +1459,13 @@ protected List<FbxConstraintSource> GetConstraintSources(IConstraint unityConstr
1459
1459
return fbxSources ;
1460
1460
}
1461
1461
1462
- protected void AddFbxNodeToConstraintsMapping < T > ( FbxNode fbxNode , T fbxConstraint ) where T : FbxConstraint
1462
+ protected void AddFbxNodeToConstraintsMapping < T > ( FbxNode fbxNode , T fbxConstraint , System . Type uniConstraintType ) where T : FbxConstraint
1463
1463
{
1464
1464
if ( ! MapConstrainedObjectToConstraints . ContainsKey ( fbxNode ) )
1465
1465
{
1466
- MapConstrainedObjectToConstraints . Add ( fbxNode , new List < FbxConstraint > ( ) ) ;
1466
+ MapConstrainedObjectToConstraints . Add ( fbxNode , new Dictionary < FbxConstraint , System . Type > ( ) ) ;
1467
1467
}
1468
- MapConstrainedObjectToConstraints [ fbxNode ] . Add ( fbxConstraint ) ;
1468
+ MapConstrainedObjectToConstraints [ fbxNode ] . Add ( fbxConstraint , uniConstraintType ) ;
1469
1469
}
1470
1470
1471
1471
protected bool ExportPositionConstraint ( PositionConstraint uniPosConstraint , FbxScene fbxScene , FbxNode fbxNode )
@@ -1846,26 +1846,6 @@ protected void ExportAnimationSamples (AnimationCurve uniAnimCurve, FbxAnimCurve
1846
1846
}
1847
1847
}
1848
1848
1849
-
1850
- protected System . Type FbxToUnityConstraintType ( FbxConstraint . EType fbxConstraintType )
1851
- {
1852
- switch ( fbxConstraintType )
1853
- {
1854
- case FbxConstraint . EType . eAim :
1855
- return typeof ( AimConstraint ) ;
1856
- case FbxConstraint . EType . eParent :
1857
- return typeof ( ParentConstraint ) ;
1858
- case FbxConstraint . EType . ePosition :
1859
- return typeof ( PositionConstraint ) ;
1860
- case FbxConstraint . EType . eRotation :
1861
- return typeof ( RotationConstraint ) ;
1862
- case FbxConstraint . EType . eScale :
1863
- return typeof ( ScaleConstraint ) ;
1864
- default :
1865
- throw new System . NotImplementedException ( fbxConstraintType . ToString ( ) ) ;
1866
- }
1867
- }
1868
-
1869
1849
/// <summary>
1870
1850
/// Get the FbxConstraint associated with the constrained node.
1871
1851
/// </summary>
@@ -1880,21 +1860,20 @@ protected FbxConstraint GetFbxConstraint(FbxNode constrainedNode, System.Type un
1880
1860
return null ;
1881
1861
}
1882
1862
1883
- List < FbxConstraint > constraints ;
1863
+ Dictionary < FbxConstraint , System . Type > constraints ;
1884
1864
if ( ! MapConstrainedObjectToConstraints . TryGetValue ( constrainedNode , out constraints ) )
1885
1865
{
1886
1866
return null ;
1887
1867
}
1888
-
1889
-
1868
+
1890
1869
foreach ( var constraint in constraints )
1891
1870
{
1892
- if ( uniConstraintType != FbxToUnityConstraintType ( constraint . GetConstraintType ( ) ) )
1871
+ if ( uniConstraintType != constraint . Value )
1893
1872
{
1894
1873
continue ;
1895
1874
}
1896
1875
1897
- return constraint ;
1876
+ return constraint . Key ;
1898
1877
}
1899
1878
1900
1879
return null ;
0 commit comments