Blender 5.x support (multi-version) + fix skeleton export bone-flag bug#31
Open
JeanxPereira wants to merge 17 commits into
Open
Blender 5.x support (multi-version) + fix skeleton export bone-flag bug#31JeanxPereira wants to merge 17 commits into
JeanxPereira wants to merge 17 commits into
Conversation
Clean-break port of the whole add-on to Blender 5.x: bgl->gpu so it registers, a thin anim_compat layer over slotted actions to keep the animation import/export logic behavior-preserving, material socket / dead-branch cleanup, and a headless round-trip harness over the 4 RW4 test files. Animation bug fixes are explicitly out of scope.
Seven TDD tasks: bgl->gpu registration, anim_compat slotted-action layer, importer/exporter migration, material/dead-branch cleanup, and a headless round-trip harness over the 4 RW4 test files.
Also fix rw4_animation_config.py id_root read and bone.select Blender 5.x regression.
The skeleton is exported as a flat depth-first list and the importer rebuilds the hierarchy with a flag-driven stack (BRANCH pushes, LEAF pops, ROOT replaces, BRANCH_LEAF is a no-op). process_bone keyed the flag on whether the parent had multiple children, which marked the last child of a multi-child parent as BRANCH instead of ROOT. That unbalanced the stack and reparented later siblings on re-import, so bones sharing a parent glitched. Key the flag on whether the bone is the last child instead, matching how Spore's own files are encoded. Add a regression test that replays the importer stack over the exported skeleton and asserts zero desync.
The add-on now runs from a single codebase across Blender 2.8 through 5.x by gating every version-specific surface instead of targeting 5.x only: - anim_compat: dual-path Action API behind one interface - legacy fcurves/groups/id_root for < 4.4, slotted channelbags/action_slot for >= 4.4. - geo_nodes, addon_updater_ops, gmdl_importer: restore the pre-existing bpy.app.version branches for the older node and texture APIs. - rw4_animation_config: gate bgl vs gpu.state and the builtin shader name. - static_model: gate the Principled BSDF specular socket name (renamed in 4.0). - bl_info: lower the minimum supported version to 2.80. PoseBone.select already works on all versions, so no gate is needed there.
Drop docs/superpowers/ (migration plans/specs that don't belong in a public addon repo) and delete untracked diagnostic/scratch files from _test/ that accumulated during development.
a2889e9 to
1b12f03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This branch gets the add-on running on Blender 5.x while keeping it working on
older versions from a single codebase, and fixes a long-standing skeleton
export bug that corrupted bones sharing a parent.
Bone-flag export fix
The skeleton is exported as a flat depth-first list, and the importer rebuilds
the hierarchy with a flag-driven stack (BRANCH pushes the parent context, LEAF
pops it, ROOT replaces it, BRANCH_LEAF is a no-op).
process_bonedecided each bone's flag based on whether its parent had multiplechildren. That marked the last child of a multi-child parent as
BRANCHinstead of
ROOT, which left the stack unbalanced and reparented the siblingsthat came after it on re-import — so bones sharing a parent glitched out (and it
was always the ones "after" the first child).
The fix keys the flag on whether the bone is the last child instead, which
matches how Spore's own files are encoded (reverse-engineered from a clean
original: ROOT/LEAF/BRANCH counts and zero stack desync). The importer needed no
changes.
There's a new regression test (
_test/test_bone_flags.py) that exports eachtest model, replays the importer's stack over the exported skeleton, and asserts
zero desync. It catches the two "export broken" models and passes after the fix.
Multi-version compatibility
Rather than targeting 5.x only, every version-specific surface is gated so the
add-on runs from 2.8 through 5.x:
fcurves/groups/id_rootfor Blender < 4.4, slotted channelbags /action_slotfor >= 4.4. Call sites are unchanged.bpy.app.versionbranches for the older node and texture APIs.bglvsgpu.stateand the builtin shadername (
3D_UNIFORM_COLOR→UNIFORM_COLORin 3.4)."Specular IOR Level" in 4.0).
PoseBone.selectalready works everywhere, so no gate was needed there.Testing
Verified on Blender 5.1: the add-on registers, the new bone-flag test passes
on all test models, and import → export → re-import round-trips with bone
positions back to ~0 error.
The legacy (2.8–4.x) code paths were restored from known-good history and
gated carefully, but I could only test on 5.1 — they'd appreciate a sanity check
on an older build before relying on them.