@@ -1922,13 +1922,13 @@ private void TransferMotion(Transform source, Transform dest, float sampleRate,
1922
1922
var rotKeyFrames = new Keyframe [ 3 ] [ ] ;
1923
1923
var scaleKeyFrames = new Keyframe [ 3 ] [ ] ;
1924
1924
1925
- for ( int t = 0 ; t < posKeyFrames . Length ; t ++ ) {
1926
- posKeyFrames [ t ] = new Keyframe [ sampleTimes . Count ] ;
1927
- rotKeyFrames [ t ] = new Keyframe [ sampleTimes . Count ] ;
1928
- scaleKeyFrames [ t ] = new Keyframe [ sampleTimes . Count ] ;
1925
+ for ( int k = 0 ; k < posKeyFrames . Length ; k ++ ) {
1926
+ posKeyFrames [ k ] = new Keyframe [ sampleTimes . Count ] ;
1927
+ rotKeyFrames [ k ] = new Keyframe [ sampleTimes . Count ] ;
1928
+ scaleKeyFrames [ k ] = new Keyframe [ sampleTimes . Count ] ;
1929
1929
}
1930
1930
1931
- int i = 0 ;
1931
+ int keyIndex = 0 ;
1932
1932
foreach ( var currSampleTime in sampleTimes )
1933
1933
{
1934
1934
var sourceLocalMatrix = GetTransformMatrix ( currSampleTime , source , sourceUnityCurves ) ;
@@ -1955,27 +1955,27 @@ private void TransferMotion(Transform source, Transform dest, float sampleRate,
1955
1955
var rot = newLocalMatrix . rotation . eulerAngles ;
1956
1956
1957
1957
for ( int k = 0 ; k < 3 ; k ++ ) {
1958
- posKeyFrames [ k ] [ i ] = new Keyframe ( currSampleTime , ( float ) translation [ k ] ) ;
1959
- rotKeyFrames [ k ] [ i ] = new Keyframe ( currSampleTime , ( float ) rot [ k ] ) ;
1960
- scaleKeyFrames [ k ] [ i ] = new Keyframe ( currSampleTime , ( float ) scale [ k ] ) ;
1958
+ posKeyFrames [ k ] [ keyIndex ] = new Keyframe ( currSampleTime , ( float ) translation [ k ] ) ;
1959
+ rotKeyFrames [ k ] [ keyIndex ] = new Keyframe ( currSampleTime , ( float ) rot [ k ] ) ;
1960
+ scaleKeyFrames [ k ] [ keyIndex ] = new Keyframe ( currSampleTime , ( float ) scale [ k ] ) ;
1961
1961
}
1962
- i ++ ;
1962
+ keyIndex ++ ;
1963
1963
}
1964
1964
1965
1965
// create the new list of unity curves, and add it to dest's curves
1966
1966
var newUnityCurves = new List < UnityCurve > ( ) ;
1967
1967
string posPropName = "m_LocalPosition." ;
1968
1968
string rotPropName = "localEulerAnglesRaw." ;
1969
1969
string scalePropName = "m_LocalScale." ;
1970
- var xyz = new string [ ] { "x" , "y" , "z" } ;
1971
- for ( int j = 0 ; j < 3 ; j ++ ) {
1972
- var posUniCurve = new UnityCurve ( posPropName + xyz [ j ] , new AnimationCurve ( posKeyFrames [ j ] ) ) ;
1970
+ var xyz = "xyz" ;
1971
+ for ( int k = 0 ; k < 3 ; k ++ ) {
1972
+ var posUniCurve = new UnityCurve ( posPropName + xyz [ k ] , new AnimationCurve ( posKeyFrames [ k ] ) ) ;
1973
1973
newUnityCurves . Add ( posUniCurve ) ;
1974
1974
1975
- var rotUniCurve = new UnityCurve ( rotPropName + xyz [ j ] , new AnimationCurve ( rotKeyFrames [ j ] ) ) ;
1975
+ var rotUniCurve = new UnityCurve ( rotPropName + xyz [ k ] , new AnimationCurve ( rotKeyFrames [ k ] ) ) ;
1976
1976
newUnityCurves . Add ( rotUniCurve ) ;
1977
1977
1978
- var scaleUniCurve = new UnityCurve ( scalePropName + xyz [ j ] , new AnimationCurve ( scaleKeyFrames [ j ] ) ) ;
1978
+ var scaleUniCurve = new UnityCurve ( scalePropName + xyz [ k ] , new AnimationCurve ( scaleKeyFrames [ k ] ) ) ;
1979
1979
newUnityCurves . Add ( scaleUniCurve ) ;
1980
1980
}
1981
1981
@@ -2031,9 +2031,9 @@ public UnityCurve(string propertyName, AnimationCurve uniAnimCurve){
2031
2031
2032
2032
private int GetPositionIndex ( string uniPropertyName ) {
2033
2033
System . StringComparison ct = System . StringComparison . CurrentCulture ;
2034
- bool isEulerComponent = uniPropertyName . StartsWith ( "m_LocalPosition." , ct ) ;
2034
+ bool isPositionComponent = uniPropertyName . StartsWith ( "m_LocalPosition." , ct ) ;
2035
2035
2036
- if ( ! isEulerComponent ) { return - 1 ; }
2036
+ if ( ! isPositionComponent ) { return - 1 ; }
2037
2037
2038
2038
switch ( uniPropertyName [ uniPropertyName . Length - 1 ] ) {
2039
2039
case 'x' :
@@ -2049,9 +2049,9 @@ private int GetPositionIndex(string uniPropertyName){
2049
2049
2050
2050
private int GetScaleIndex ( string uniPropertyName ) {
2051
2051
System . StringComparison ct = System . StringComparison . CurrentCulture ;
2052
- bool isEulerComponent = uniPropertyName . StartsWith ( "m_LocalScale." , ct ) ;
2052
+ bool isScaleComponent = uniPropertyName . StartsWith ( "m_LocalScale." , ct ) ;
2053
2053
2054
- if ( ! isEulerComponent ) { return - 1 ; }
2054
+ if ( ! isScaleComponent ) { return - 1 ; }
2055
2055
2056
2056
switch ( uniPropertyName [ uniPropertyName . Length - 1 ] ) {
2057
2057
case 'x' :
@@ -2257,7 +2257,13 @@ protected int ExportTransformHierarchy(
2257
2257
return numObjectsExported ;
2258
2258
}
2259
2259
2260
-
2260
+ /// <summary>
2261
+ /// Checks if the transform should be reset.
2262
+ /// Transform should be reset if animation is being transferred, and this transform
2263
+ /// is either the animation source, destination, or between these nodes.
2264
+ /// </summary>
2265
+ /// <returns><c>true</c>, if transform should be reset, <c>false</c> otherwise.</returns>
2266
+ /// <param name="t">Transform.</param>
2261
2267
private bool ResetTransform ( Transform t ) {
2262
2268
var source = ExportOptions . AnimationSource ;
2263
2269
var dest = ExportOptions . AnimationDest ;
0 commit comments