Skip to content

Commit

Permalink
use the cache that also respects clip speed for GetAnimationId
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Nov 8, 2023
1 parent 72c1720 commit a2f831d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Runtime/Scripts/GLTFSceneExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ private struct ImageInfo
private List<ImageInfo> _imageInfos;
private List<UniqueTexture> _textures;
private Dictionary<int, int> _exportedMaterials;
#if ANIMATION_SUPPORTED
private List<(Transform tr, AnimationClip clip)> _animationClips;
#endif
private bool _shouldUseInternalBufferForImages;
private Dictionary<int, int> _exportedTransforms;
private List<Transform> _animatedNodes;
Expand Down Expand Up @@ -514,9 +511,6 @@ public GLTFSceneExporter(Transform[] rootTransforms, ExportOptions options)
_imageInfos = new List<ImageInfo>();
_exportedMaterials = new Dictionary<int, int>();
_textures = new List<UniqueTexture>();
#if ANIMATION_SUPPORTED
_animationClips = new List<(Transform, AnimationClip)>();
#endif

_buffer = new GLTFBuffer();
_bufferId = new BufferId
Expand Down Expand Up @@ -1084,12 +1078,11 @@ private void ExportAnimation()
#region Public API
#if ANIMATION_SUPPORTED

public int GetAnimationId(AnimationClip clip, Transform transform)
public int GetAnimationId(AnimationClip clip, Transform transform, float speed = 1)
{
for (var i = 0; i < _animationClips.Count; i++)
if (_clipAndSpeedAndNodeToAnimation.TryGetValue((clip, speed, transform), out var id))
{
var entry = _animationClips[i];
if (entry.tr == transform && entry.clip == clip) return i;
return _root.Animations.IndexOf(id);
}
return -1;
}
Expand Down

0 comments on commit a2f831d

Please sign in to comment.