Skip to content

feat(skel): SkelAnimQuery + array interp#72

Open
bresilla wants to merge 1 commit into
mxpv:mainfrom
bresilla:feat/skel-anim-query
Open

feat(skel): SkelAnimQuery + array interp#72
bresilla wants to merge 1 commit into
mxpv:mainfrom
bresilla:feat/skel-anim-query

Conversation

@bresilla
Copy link
Copy Markdown
Contributor

Follow-up to #71. Adds the time-sampled animation evaluator the heads-up there mentioned. With this, the existing skel resolvers can be driven at a stage time.

src/schemas/skel/
└── anim_query.rs       # SkelAnimQuery
src/
└── interp.rs           # extended with array variants
tests/
└── skel_reader.rs      # 6 new tests for SkelAnimQuery

The query wraps a SkelAnimation prim and exposes translations, rotations, scales, and blend-shape weights at a given time. It delegates to Stage::value_at so values inherit the stage's interpolation mode, including per-joint slerp on rotations. A separate helper composes the T/R/S triples into per-joint 4×4 matrices ready to feed the SkeletonResolver.

For rotations to actually slerp frame to frame, the interp module needed to handle array values. It now covers every VtArray variant in C++'s USD_LINEAR_INTERPOLATION_TYPES — component-wise lerp for vector and matrix arrays, per-element slerp for quaternion arrays. Length mismatches fall back to held, same as C++.

14 unit + 21 integration tests, all green.

Copilot AI review requested due to automatic review settings May 25, 2026 19:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a time-sampled SkelAnimation query API and expands linear interpolation support to array-valued USD types, enabling per-frame animation evaluation and wiring results into existing skinning resolvers.

Changes:

  • Introduce SkelAnimQuery for sampling joint TRS components, composing joint-local matrices, and sampling blend-shape weights.
  • Extend interp::evaluate linear interpolation to support many Value::*Vec array variants (including per-element quat slerp).
  • Add integration tests validating animation sampling and resolver wiring.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/skel_reader.rs Adds end-to-end tests covering SkelAnimQuery outputs and integration with SkeletonResolver.
src/schemas/skel/mod.rs Hooks up the new anim_query module, re-exports its public API, and updates skel module docs.
src/schemas/skel/anim_query.rs Implements SkelAnimQuery (sampling, defaults, TRS composition) plus unit tests for matrix helpers.
src/interp.rs Adds linear interpolation support + tests for array (VtArray) Value variants, including quat array slerp and length-mismatch fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +158 to +168
Ok(match v {
Some(Value::Vec3fVec(a)) if a.len() == n => a,
Some(Value::Vec3dVec(a)) if a.len() == n => {
a.into_iter().map(|x| [x[0] as f32, x[1] as f32, x[2] as f32]).collect()
}
Some(Value::Vec3hVec(a)) if a.len() == n => a
.into_iter()
.map(|x| [x[0].to_f32(), x[1].to_f32(), x[2].to_f32()])
.collect(),
_ => vec![default; n],
})
Comment on lines +28 to +29
pub type JointTransformComponents = (Vec<[f32; 3]>, Vec<[f32; 4]>, Vec<[f32; 3]>);

Comment thread tests/skel_reader.rs
Comment on lines +306 to +310
// should be a ~22.5° rotation about +Z.
let w_expected = (std::f32::consts::PI / 8.0).cos();
let z_expected = (std::f32::consts::PI / 8.0).sin();
assert!((r[1][0] - w_expected).abs() < 1e-3, "w: {}", r[1][0]);
assert!((r[1][3] - z_expected).abs() < 1e-3, "z: {}", r[1][3]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants