Skip to content

Commit 4e04736

Browse files
authored
Merge pull request #552 from BabylonJS/drigax/fix_549
Make baked animations get excluded in export if they aren't relevant within group frame range.
2 parents 15f442f + 6e93189 commit 4e04736

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Maya/Exporter/BabylonExporter.GLTFExporter.Animation.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,20 @@ private void ExportNodeAnimation(GLTFAnimation gltfAnimation, int startFrame, in
161161

162162
// Optimization process always keeps first and last frames
163163
OptimizeAnimations(keysInRangeFull, true);
164+
bool keysInRangeAreRelevant = IsAnimationKeysRelevant(keysInRangeFull, babylonAnimation.property);
165+
166+
// if we are baking the animation frames, then do a less efficient check against all frames in the scene for this animation channel if the first check fails.
167+
if (!keysInRangeAreRelevant && _bakeAnimationFrames)
168+
{
169+
List<BabylonAnimationKey> optimizedKeysFull = new List<BabylonAnimationKey>(babylonAnimation.keysFull);
170+
OptimizeAnimations(optimizedKeysFull, true);
171+
keysInRangeAreRelevant = IsAnimationKeysRelevant(optimizedKeysFull, babylonAnimation.property);
172+
}
164173

165-
if (IsAnimationKeysRelevant(keysInRangeFull, babylonAnimation.property))
174+
// If we have any significant animation keys in this channel
175+
// (or if we are baking the animation track and have any relevant (non-identity) animation keys in the whole track)
176+
// then add the optimized keys in range to the animation track
177+
if (keysInRangeAreRelevant)
166178
{
167179
// Override animation keys
168180
babylonAnimation.keys = keysInRangeFull.ToArray();

0 commit comments

Comments
 (0)