Page MenuHome

Complex armature with bone constraints - setting PoseBone matrix_basis may not influence another bone's matrix as expected as not calculated yet (possible bug, definite FBX export bug!)
Closed, ResolvedPublic

Description

Not sure if this is a bug - the only way to get the correct PoseBone's matrix after setting another PoseBone's matrix_basis (which in some way influences the former bone) is to call scene.update() after applying matrix_basis to one or many PoseBones.
At the very least, this should be noted in the Gotchas section on docs.blender.

Taking this into account - I have spotted a definite bug in the FBX export addon.
Looking through the FBX export addon file export_fbx_bin.py, I noticed the coder had tripped up with this same misconception.
After both instances of:

if pbones_matrices is not ...:
	for pbo, mat in zip(ob.pose.bones, pbones_matrices):
		pbo.matrix_basis = mat.copy()

scene.update() needs to be called immediately afterwards.
Assuming bake_anim_force_startend_keying = False and there are multiple actions being exported, the last frame of the previous action will influence the following action if one of the keying bones was not keyframed on the first frame.
This is very noticable when exporting a rigify rig for example, and creates bad exports.

Please see attached blend file for simple example (with code).

Related Objects

Event Timeline

Bastien Montagne (mont29) claimed this task.
Bastien Montagne (mont29) triaged this task as Normal priority.

Having to call scene.update in such cases is expected (you have same issues when e.g. manipulating meshes from bpy API, if you need actual resulting data of those manipulations, you'll have to enforce an update yourself, as the one triggered by regular scene refreshing from UI will likely not happen soon enough).

So this totally sounds like an FBX exporter bug, thanks for reporting, will check asap.