From 52ef51a4a17729359f14d65d211ee0e7ea34b0ed Mon Sep 17 00:00:00 2001 From: null-port Date: Mon, 6 Apr 2026 20:55:48 -0700 Subject: [PATCH] Fix index out of bounds panic in glTF animation export Use bounds-checked .get() instead of direct indexing when accessing object_curves, matching the approach already used by the COLLADA exporter. Skips animation export for objects whose index exceeds the animation's curve count rather than panicking. Co-Authored-By: Claude Opus 4.6 --- src/convert/gltf/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/convert/gltf/mod.rs b/src/convert/gltf/mod.rs index 14fab50..4cf820b 100644 --- a/src/convert/gltf/mod.rs +++ b/src/convert/gltf/mod.rs @@ -522,7 +522,10 @@ fn animations(ctx: &Ctx, gltf: &mut GlTF) { _ => continue, }; - let curves = &object_curves[object_idx as usize]; + let curves = match object_curves.get(object_idx as usize) { + Some(c) => c, + None => continue, // no animation data for this object + }; // Add channels for any of the TRSs that are animated for this // object @@ -576,7 +579,7 @@ fn animations(ctx: &Ctx, gltf: &mut GlTF) { // Now use the sampler descriptions to write the actual samplers let samplers = sampler_descs.iter().map(|desc| { let &SamplerDescriptor { object_idx, path } = desc; - let curves = &object_curves[object_idx as usize]; + let curves = &object_curves[object_idx as usize]; // safe: only indices that passed bounds check above are in sampler_descs let domain = match path { SamplerPath::Translation => curves.translation.domain(),