-1 indexed bones on Imported assets with a skeleton?

Whoda what now? Why? I get that we add some extra transform nodes for like flipping the coordinate systems to the correct handiness. But but but what are all these -1 indexed bones prior to the root bone?

Its madness I tell you! ummm naw there is prolly a reason for it but I dont understand why. Can someone please explain what is going on here?

pinging @bghgary (as I’m on my phone now)

Also how does that index come into play? Is that what the matrices are indexed to? I thought it was the index position of the bone in the skeleton array, but this is making me thing otherwise.

That is what they are. Looks like an initialization. issue of the exporter (which one?). Blender provides bones in an order such that child bones are ALWAYS listed after the parent.

BJS absolute relies on this being the case as well. skeleton._computeTransformMatrices() they are processed in order. That loop relies on the fact that the parent’s has already been updated.

I know this is not really helping, but I recently re-read Skeleton & thought I would share what I determined in this area.

There is also a sortBones(), on skeleton but then the animation would almost surely be trash.

Ive seen files come in with like 6 or 7, -1 indexed bones before the root though and that seems like chaos.

Ok I figured out that its the bone._index that you set as the matrices ID. Now that raises secondary questions. But Ill leave that for another thread.

Sorry for all the trouble. This is because of glTF as doing it this way makes the loading faster. The _index makes it such that the code doesn’t have to reorder the matrices at load time. The -1 values are for bones that don’t have a corresponding bone matrix.

2 Likes

Kinda figured all that, but wanted to validate.