Fix #2592: avoid export recursion when an ancestor is bone-parented to the skinning armature#2712
Open
Builder106 wants to merge 1 commit into
Conversation
…e-parented to the skinning armature gather_skin already drops the skin (keeping the bone parenting) when a skinned mesh is itself bone-parented to a bone of its own armature, to avoid a cyclic exported node graph. But that check only looked at the mesh's direct parent, so the cycle still formed when the bone-parented node was an ANCESTOR rather than the mesh itself (e.g. a mesh object-parented to an empty that is bone-parented to the armature). The exporter's node traversal then followed skin -> joint -> children -> ... -> mesh -> skin endlessly and raised RecursionError. Walk the whole ancestor chain instead of just the direct parent.
Author
|
Hey @julienduroure, since you filed #2592 yourself, figured this one might be worth a look. It's been about three weeks. The existing cycle-guard in |
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.
Fixes #2592.
Problem
Exporting a scene where a skinned mesh has an ancestor that is bone-parented to the same armature raises
RecursionError, and the export fails.Minimal repro:
Armature(boneBone) →Emptybone-parented toBone→Cubeobject-parented to theEmpty, with a vertex groupBone+ an Armature modifier targetingArmature. Exporting to glTF raisesRecursionError: maximum recursion depth exceeded.Cause
gather_skin(exp/nodes.py) already guards the direct case: a mesh bone-parented to a bone of its own skinning armature would make the skin's joint an ancestor of the mesh node, forming a cycle, so the skin is dropped. But the guard only checkedblender_object.parent. When the bone-parented node is an ancestor (theEmpty) rather than the mesh itself, the guard misses it, the skin is created, and the exported node graph contains a cycle:The exporter's node traversal follows
.skinand.children, so it recurses untilRecursionError.Fix
Walk the whole ancestor chain instead of only the direct parent; if any ancestor is bone-parented to the skinning armature, drop the skin (and keep the bone parenting) — identical behavior to the existing guard, just generalized past the direct parent.
Verification
Headless Blender 5.1.1 (the reported version),
export_format='GLTF_SEPARATE':RecursionError, no file writtenFINISHED·skins: []· Cube node hasmesh, noskinskinslength 1, Cube skinnedskinslength 1, Cube skinned (unchanged)So the cycle is broken (skin dropped, mesh + bone parenting preserved) and normal skinning is unaffected.
Two points for your call: I kept the existing name-based armature comparison for a minimal diff — happy to switch it to identity (
ancestor.parent == modifiers["ARMATURE"].object) to harden against same-named linked/duplicated armatures if you'd prefer. I can also add atests/fixture for this topology if that's useful.