Skip to content

Commit 6f448ce

Browse files
committed
UNI-37183 fix not exporting last frame of animation
- issue was due to rounding errors when incrementing the key time causing the last frame to be missed
1 parent 6d21ad8 commit 6f448ce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ public static HashSet<float> GetSampleTimes(AnimationCurve[] animCurves, double
14521452
var keyTimes = new HashSet<float>();
14531453
double fs = 1.0/sampleRate;
14541454

1455-
double currSample = double.MaxValue, firstTime = double.MaxValue, lastTime = double.MinValue;
1455+
double firstTime = double.MaxValue, lastTime = double.MinValue;
14561456

14571457
foreach (var ac in animCurves)
14581458
{
@@ -1462,9 +1462,10 @@ public static HashSet<float> GetSampleTimes(AnimationCurve[] animCurves, double
14621462
lastTime = System.Math.Max(lastTime, ac[ac.length-1].time);
14631463
}
14641464

1465-
for (currSample = firstTime; currSample < lastTime; currSample += fs)
1466-
{
1467-
keyTimes.Add((float)currSample);
1465+
int firstframe = (int)(firstTime * sampleRate);
1466+
int lastframe = (int)(lastTime * sampleRate);
1467+
for (int i = firstframe; i <= lastframe; i++) {
1468+
keyTimes.Add ((float)(i * fs));
14681469
}
14691470

14701471
return keyTimes;

0 commit comments

Comments
 (0)