Skip to content

Preserve skinning in model GLB exports - #148

Draft
kibradev wants to merge 1 commit into
Two-Play:developfrom
kibradev:glb-skinning
Draft

kibradev wants to merge 1 commit into
Two-Play:developfrom
kibradev:glb-skinning

Conversation

@kibradev

Copy link
Copy Markdown

Summary

  • Export joint indices, normalized weights, the bone hierarchy, and inverse bind matrices for skinned GLB meshes.
  • Resolve the shared GTA VI ped skeleton when the archive is exposed through recovery paths.
  • Report how many vertices have decoded weights and are ready to export.

Verification

  • cargo test --locked -p rage-formats --lib (147 passed)
  • Windows release build for the CLI and GUI
  • Blender 4.2 import and pose-driven mesh deformation with a synthetic rig. Also verified armature and weight import with a GTA VI drawable.

@Two-Play Two-Play self-assigned this Nov 26, 2026
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 minor

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Complexity 2 minor

View in Codacy

🟢 Metrics 407 complexity · 49 duplication

Metric Results
Complexity 407
Duplication 49

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Two-Play

Copy link
Copy Markdown
Owner

Hi @kibradev, thanks a lot for this.

I went through the diff and ran the checks locally on the current develop (it merges cleanly):

  • cargo fmt --check ✅, cargo clippy -D warnings for rage-formats, openrage-app and openrage-cli ✅
  • all tests pass, including your new one (rage-formats: 147) ✅

What I really like

  • Data from game files is handled defensively: joint indices are checked against the bone count, parents must come before children, weights must be finite and non-negative with a positive sum – and anything that doesn't qualify falls back to a rigid mesh instead of failing.
  • Rigid and skinned primitives of one drawable are split into separate meshes, and duplicate joints from palette remapping are merged before normalising. 👍
  • The joint hierarchy uses the same "parent before child" guard as Skeleton::world_transforms, so nodes and inverse bind matrices stay consistent.
  • write_glb_scene stays as a wrapper, so nothing else has to change.

Before merging

  1. Sign-off: we've just introduced the Developer Certificate of Origin – every commit needs a Signed-off-by line (git commit --amend -s --no-edit, then git push --force-with-lease). The DCO check will run on your next push.
  2. Other games: to_glb is used by the GUI, CLI and plugin exports for every game, so GTA V, RDR2 and GTA IV models now get skins too whenever their meshes qualify. Could you (or I, if you prefer) try exporting a GTA V ped and a GTA V vehicle and check them in Blender, to make sure nothing changed for the worse there?
  3. recovered_base_archive: the comment mentions the recovery view, but as far as I can see is_archive/open_child only work when the table of contents was read with the executable – in the recovery view the search can't find anything. So it seems to help when the TOC is read but the nested archive's name is unknown. Could you adjust the comment accordingly? Also, _ => recovered_base_archive(game)? falls back on any error from resolve (including I/O errors); falling back only when the path isn't found would keep the real cause visible. Moving "ambient_femalebody.#ft" into a named constant with a short note on why this file identifies the archive would help future readers (and note that find_map_any picks an arbitrary match if there are several).

Optional, only if you feel like it

  • The inverse bind matrices are written without finite(), unlike all other floats – NaN in a bone's data would end up in the file.
  • The CLI line skin weights: … now shows for every model, including props and vehicles with 0 decoded; printing it only when there are weights might be less noisy.
  • scene_to_glb keeps exporting without skins – fine for map objects, maybe worth a short comment so it doesn't look forgotten.
  • The test checks fixed byte offsets in the binary chunk (bin[84..92], get_f32(280)), which will break if the buffer layout changes; that's acceptable, just mentioning it.

When you're happy with it, please mark the PR as ready for review. Thanks again!

This branch has not been deployed

No deployments
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