Skip to content

Blender 5.x support (multi-version) + fix skeleton export bone-flag bug#31

Open
JeanxPereira wants to merge 17 commits into
Spore-Community:masterfrom
JeanxPereira:blender-5x-migration
Open

Blender 5.x support (multi-version) + fix skeleton export bone-flag bug#31
JeanxPereira wants to merge 17 commits into
Spore-Community:masterfrom
JeanxPereira:blender-5x-migration

Conversation

@JeanxPereira

Copy link
Copy Markdown

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_bone decided each bone's flag based on whether its parent had multiple
children. That marked the last child of a multi-child parent as BRANCH
instead of ROOT, which left the stack unbalanced and reparented the siblings
that 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 each
test 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:

  • anim_compat: dual-path Action API behind one interface — legacy
    fcurves/groups/id_root for Blender < 4.4, slotted channelbags /
    action_slot for >= 4.4. Call sites are unchanged.
  • geo_nodes, addon_updater_ops, gmdl_importer: restored the
    bpy.app.version branches for the older node and texture APIs.
  • rw4_animation_config: gated bgl vs gpu.state and the builtin shader
    name (3D_UNIFORM_COLORUNIFORM_COLOR in 3.4).
  • static_model: gated the Principled BSDF specular socket name (renamed to
    "Specular IOR Level" in 4.0).
  • bl_info: minimum supported version lowered to 2.80.
  • PoseBone.select already 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.

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.
@JeanxPereira JeanxPereira force-pushed the blender-5x-migration branch from a2889e9 to 1b12f03 Compare June 18, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant