Collada importer removes all bones after internally setting their length to zero #101177
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#101177
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Simplified Report
fix_leaf_bone_hierarchy
setting the length of all bones to a value close to zero.blender sample broken armature (7 bones) base.dae
Original Report
System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94
Blender Version
Broken: At least as far back as 2.78, and up to 3.3.0 (branch: master, commit date: 2022-09-06 15:39, hash:
0759f671ce
)Worked: N/A
Short description of error
Collada import of a mesh with skeleton may destructively import "successfully" (no console errors) if there's a child bone with "length 0" which has it's own child bones but is not weighted to anything. The mesh imports just fine but the skeleton does not, in my test case this causes most of the bones (238) to disappear and only about 10 bones survive.
Exact steps for others to reproduce the error
Import a Collada mesh with a skeleton that has a child bone with length 0, which has it's own child bones and is not referenced by the skin controller, such as the sample file below (bone "Bip01_Neck01"):
pew_00_nude_0001_noalpha_mesh00_lod0 broken.dae
The go-to workaround for the problematic file above for years has been to use "Find Bone Chains" (and usually also "Fix Leaf Bones") during import, this does recover most bones, however there are still a few missing (including the "Bip01" root bone), and they're no longer aligned with the skeleton in use by the game, resulting clipping issues, twisted wrists, etc.
New workarounds as of yesterday include adjusting the bone values so that the length won't be "0", in the file below I've copied values from "Bip01_Neck" (parent) to "Bip01_Neck01" (child):
pew_00_nude_0001_noalpha_mesh00_lod0 broken workaround.dae
Another workaround is to include the bone in the skin controller, where the other files only listed the bones in use by the mesh, this one lists all of them, which seems to prevent the bone from being destructively removed during import:
pew_00_nude_0001_noalpha_mesh00_lod0 refAllBones.dae
Added subscriber: @Perv
Added subscriber: @mano-wii
Changed status from 'Needs Triage' to: 'Archived'
Blender does not allow zero-sized bones. See {https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/armature/armature_utils.c$675-688}.
This is an old behavior (before 2.5) and not easy to change. So it's not surprising the bones with length 0 disappear when imported into Blender.
Thanks for the report, but the issue reported here is a request for modified/improved behavior and not a bug in current behavior. Closing as this bug tracker is only for bugs and errors.
For user requests and feedback, please use other channels: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests
For more information on why this isn't considered a bug, visit: https://wiki.blender.org/wiki/Reference/Not_a_bug
Again, the bones do NOT get removed if the bones are "referenced" (no weights) in the joints array, so the behavior to preserve "zero-sized" bones already exists as it can be achieved by referencing all the bones, it could use some tweaking to also apply to all bones that have their own child bones.
Regardless of whether you think zero-sized bones should exist or not, this IS a bug, because again, the entire armature is destroyed, including unrelated bones, that should NOT be intended behavior, in the sample files I posted you can compare the final armature that is imported between the "broken" and "refAllBones" files, it'd be fine if it simply removed all the "zero-sized" bones while leaving a functional armature (child bones being moved one node up, where the parent "zero" bone was) and otherwise unchanged, but it doesn't, it makes the armature unusable.
Changed status from 'Archived' to: 'Needs Triage'
The sample files are very complex. It would be preferable to simplify to just the armature with as few bones as possible.
To demonstrate the bug in Collada, it is recommended to use a simplified .blend file that can be exported and re-imported.
I'm not familiar with how zero-sized bones are preserved if they are referenced.
In my opinion this report falls into the category Too complex file report, where user could not simplify enough on the Triaging_Playbook .
The issue is on import, the Collada file is typically generated by another tool, not Blender, so I don't know how (or if) there's a way to generate a broken armature via Blender, importing with a mesh that references a "zero" bone and then exporting just the armature does not seem to result a skeleton that breaks on import.
I have however simplified the sample, the issue is reproducible with just 7 bones (6 parent nodes to the problematic bone and the problematic bone itself), in that scenario no bones survive the import, an empty armature is added to the scene, I've first also tried with 24 bones, keeping some child bones of the problematic bones and other child bones to the different parent bones, only one bone survives, the other child of the root bone, I've then also tried 8 bones, the same 7 I explained above and the second child of the root bone, it was the only bone to survive again.
I've created "non-zero" variations of the samples above where the values of the parent to the problematic bone were copied, and another variation where the problematic bone is removed, in both cases all bones get imported correctly.
blender sample broken armature (7 bones) base.dae
blender sample broken armature (7 bones) non-zero.dae
blender sample broken armature (7 bones) removed.dae
blender sample broken armature (8 bones) base.dae
blender sample broken armature (8 bones) non-zero.dae
blender sample broken armature (8 bones) removed.dae
blender sample broken armature (24 bones) base.dae
blender sample broken armature (24 bones) non-zero.dae
blender sample broken armature (24 bones) removed.dae
Added subscriber: @scurest
Looking at the first file (7 bones), the matrix for the leaf bone is
Some observations:
I think I can combine these into a tentative theory about what happens:
As you know floats have more precision around the origin and less as you move away from the origin. Near y=170.795 the gap between floats is 1/2^16 or about 0.000_0153. Adding something less than half of this to y is the same as adding zero, since it gets rounded back down to y. The halfway point is 0.000_00763, which notably lies in the range noted above to contain the crossover from "broken" to "working".
So if the code does something like this, where the length is checked before calculating the tail
it won't work, since the "mathematical" assumption that (tail-head).length = bone_length > min_length doesn't hold for floats.
Added subscriber: @OmarEmaraDev
Changed status from 'Needs Triage' to: 'Confirmed'
This seems like a bug indeed. But I am not really sure if it is related to your investigation on float precision.
The issues seems to be caused by the
fix_leaf_bone_hierarchy
function, which seems to consider all bones to be leaf bones inbc_is_leaf_bone
and then it adjust the length of the bones to be close to zero which is then removed in the next call toED_armature_from_edit
. This seems to be the unexpected part.Collada mesh import is potentially destructive to the included skeletonto Collada importer removes all bones after internally setting their length to zeroWith the original report I've stated that there's a workaround, where referencing the problematic bone in the joints array of the mesh (even without assigning any weights to it) causes it to import correctly, could it be that one of the leaf bone checks fails due to that reference?
Also it might be worth mentioning that similar behavior was experienced with 3ds Max (skeleton does not import correctly unless the "zero sized" bone is referenced in the joints array of a mesh), I thought the issue might be with OpenCollada code that both Blender and 3ds share.