glb_skinning: accept extra inverse bind matrices #1753

Merged
kirigayakazima merged 2 commits from upstream-pr/1753 into main 2026-11-28 14:57:09 +00:00
kirigayakazima commented 2026-11-25 11:14:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T11:14:39Z.


Claimed in the coordination issue as: GLB-SKINNING-SURPLUS-BIND-MATRICES

What and why

The validator rejected every difference between the joint count and the accessor count. glTF permits an accessor to contain more matrices than a skin uses. The validator now rejects an undersized accessor, reports the actual count and retains its affine checks for the matrices used by joints. The synthetic case shares one accessor between two skins. glTF 2.0 skin specification

Tested

With one three-matrix accessor shared by skins of two joints and one joint, the baseline CLI exited 1 with two count errors. The branch exits 0 and its JSON retains both joint counts and the accessor count. The short-accessor and non-affine joint regressions also pass.

  • python -I tests/test_glb_skinning.py passed all 27 tests on this branch (Windows, Python 3.14.7).
  • git diff --check and the repository game-data scan of all changed paths passed.
  • The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at bcaa13da passed 6,287 semantic tests across 488 files.

GPUs tested: N/A (CPU-only asset tooling).
AI-assisted: Yes.

Checklist

  • Based on current upstream main.
  • One topic.
  • Only synthetic test fixtures. No game data, keys or decryption.
  • Translator contract table: N/A.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490255041 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1753). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-25T11:14:39Z. --- Claimed in the coordination issue as: [GLB-SKINNING-SURPLUS-BIND-MATRICES](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7160621714) ### What and why The validator rejected every difference between the joint count and the accessor count. glTF permits an accessor to contain more matrices than a skin uses. The validator now rejects an undersized accessor, reports the actual count and retains its affine checks for the matrices used by joints. The synthetic case shares one accessor between two skins. [glTF 2.0 skin specification](https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/Specification.adoc#skins) ### Tested With one three-matrix accessor shared by skins of two joints and one joint, the baseline CLI exited 1 with two count errors. The branch exits 0 and its JSON retains both joint counts and the accessor count. The short-accessor and non-affine joint regressions also pass. - `python -I tests/test_glb_skinning.py` passed all 27 tests on this branch (Windows, Python 3.14.7). - `git diff --check` and the repository game-data scan of all changed paths passed. - The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at `bcaa13da` passed 6,287 semantic tests across 488 files. GPUs tested: N/A (CPU-only asset tooling). AI-assisted: Yes. ### Checklist - [x] Based on current upstream main. - [x] One topic. - [x] Only synthetic test fixtures. No game data, keys or decryption. - Translator contract table: N/A.
lixonik commented 2026-11-25 11:20:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:20:01Z.

Review: COMMENTED


Independent check at "cdf5bce4". Windows: all 27 skinning tests passed. The relaxed count is correct for valid surplus matrices. A separate CLI check found that it also accepts a surplus matrix with an invalid fourth row. Details inline.

AI-assisted review and CPU-only testing with synthetic inputs.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6056673280 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1753#pullrequestreview-6056673280). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T11:20:01Z. **Review:** COMMENTED --- Independent check at "cdf5bce4". Windows: all 27 skinning tests passed. The relaxed count is correct for valid surplus matrices. A separate CLI check found that it also accepts a surplus matrix with an invalid fourth row. Details inline. AI-assisted review and CPU-only testing with synthetic inputs.
lixonik commented 2026-11-25 11:20:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:20:02Z.

Code review location: tools/glb_skinning.py; line 491

@@ -488,10 +488,10 @@ def _validate_skins(gltf, reader, warnings, errors):
                 "component_type": meta["component_type"],
                 "normalized": meta["normalized"],
             })
-            if meta["count"] != len(joints):
+            if meta["count"] < len(joints):

Accepting surplus matrices is correct, but the affine check below only covers indices below the joint count. With a two-joint synthetic model and a three-matrix accessor, I changed the third matrix's fourth row to [0.5, 0, 0, 1]. The CLI exited 0 and reported no errors. Now that excess entries are accepted, could the fourth-row check cover the entire referenced accessor? glTF requires the affine fourth row on each matrix. glTF 2.0 skin specification

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4694123506 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1753#discussion_r4694123506). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T11:20:02Z. **Code review location:** `tools/glb_skinning.py`; line 491 ~~~~diff @@ -488,10 +488,10 @@ def _validate_skins(gltf, reader, warnings, errors): "component_type": meta["component_type"], "normalized": meta["normalized"], }) - if meta["count"] != len(joints): + if meta["count"] < len(joints): ~~~~ --- Accepting surplus matrices is correct, but the affine check below only covers indices below the joint count. With a two-joint synthetic model and a three-matrix accessor, I changed the third matrix's fourth row to [0.5, 0, 0, 1]. The CLI exited 0 and reported no errors. Now that excess entries are accepted, could the fourth-row check cover the entire referenced accessor? glTF requires the affine fourth row on each matrix. [glTF 2.0 skin specification](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#skins)
kirigayakazima commented 2026-11-27 12:09:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:09:50Z.

Code review location: tools/glb_skinning.py; line 491

@@ -488,10 +488,10 @@ def _validate_skins(gltf, reader, warnings, errors):
                 "component_type": meta["component_type"],
                 "normalized": meta["normalized"],
             })
-            if meta["count"] != len(joints):
+            if meta["count"] < len(joints):

Fixed: removed and index < len(joints) in tools/glb_skinning.py so every entry in inverseBindMatrices (including surplus entries) is checked for an affine fourth row [0, 0, 0, 1]. Updated tests/test_glb_skinning.py to test affine-valid shared surplus matrices plus rejecting an invalid surplus fourth row (inverseBindMatrices[2]).

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4719193459 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1753#discussion_r4719193459). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-27T12:09:50Z. **Code review location:** `tools/glb_skinning.py`; line 491 ~~~~diff @@ -488,10 +488,10 @@ def _validate_skins(gltf, reader, warnings, errors): "component_type": meta["component_type"], "normalized": meta["normalized"], }) - if meta["count"] != len(joints): + if meta["count"] < len(joints): ~~~~ --- Fixed: removed `and index < len(joints)` in `tools/glb_skinning.py` so every entry in `inverseBindMatrices` (including surplus entries) is checked for an affine fourth row `[0, 0, 0, 1]`. Updated `tests/test_glb_skinning.py` to test affine-valid shared surplus matrices plus rejecting an invalid surplus fourth row (`inverseBindMatrices[2]`).
lixonik commented 2026-11-27 15:50:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:50:27Z.

Review: COMMENTED


Re-verified at 783d1e61e (merged cleanly onto main ec91d695c).

  • Confirmed the prior finding is resolved: _validate_skins() now validates the affine fourth row [0, 0, 0, 1] across all entries of inverseBindMatrices, including surplus matrices beyond len(joints), with regression coverage for both valid shared surplus matrices and a non-affine surplus entry.
  • Windows 11, Python 3.12: python -I -B tests/test_glb_skinning.py -v passed (28/28); scripts/check_no_game_data.py and git diff --check clean.
  • No remaining findings.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6090597883 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1753#pullrequestreview-6090597883). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T15:50:27Z. **Review:** COMMENTED --- Re-verified at `783d1e61e` (merged cleanly onto `main` `ec91d695c`). - Confirmed the prior finding is resolved: `_validate_skins()` now validates the affine fourth row `[0, 0, 0, 1]` across all entries of `inverseBindMatrices`, including surplus matrices beyond `len(joints)`, with regression coverage for both valid shared surplus matrices and a non-affine surplus entry. - Windows 11, Python 3.12: `python -I -B tests/test_glb_skinning.py -v` passed (28/28); `scripts/check_no_game_data.py` and `git diff --check` clean. - No remaining findings. AI-assisted.
zmasi commented 2026-11-28 11:53:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:53:12Z.


#1753 | head 783d1e61e5 (merged cleanly with main 24549bdb1) | python -I tests/test_glb_skinning.py | red on main: FAILED (failures=3) (inverseBindMatrices count 3 != joint count 2 rejected shared surplus matrices) | green on PR+main: 34 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _validate_skins in tools/glb_skinning.py and docs/character_skeleton.md (accepting inverseBindMatrices accessors with count >= len(joints) while still validating finite elements and the affine [0, 0, 0, 1] fourth row across every matrix in the accessor, including surplus entries). Also verified clean merge (0 conflicts) and combined execution with #1754 (36 tests OK), plus tests/test_docs_encoding.py (1 OK), tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238847431 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1753#issuecomment-7238847431). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:53:12Z. --- #1753 | head 783d1e61e52de26334a8dc97f1cf953fe590964a (merged cleanly with main 24549bdb1) | `python -I tests/test_glb_skinning.py` | red on main: `FAILED (failures=3)` (`inverseBindMatrices count 3 != joint count 2` rejected shared surplus matrices) | green on PR+main: `34 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_validate_skins` in `tools/glb_skinning.py` and `docs/character_skeleton.md` (accepting `inverseBindMatrices` accessors with `count >= len(joints)` while still validating finite elements and the affine `[0, 0, 0, 1]` fourth row across every matrix in the accessor, including surplus entries). Also verified clean merge (`0` conflicts) and combined execution with #1754 (`36 tests OK`), plus `tests/test_docs_encoding.py` (`1 OK`), `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:57:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:57:06Z.


Red/green: pytest tests/test_glb_skinning.py fails on main (1 failed, 5 passed, 4 subtests passed) and passes on head 783d1e61e5 merged with main (28 passed, 23 subtests passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241064363 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1753#issuecomment-7241064363). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:57:06Z. --- Red/green: `pytest tests/test_glb_skinning.py` fails on main (1 failed, 5 passed, 4 subtests passed) and passes on head 783d1e61e52d merged with main (28 passed, 23 subtests passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1753
No description provided.