Where do matrix changes get stored before view_layer.update()?

consider the following snippet:

b = bpy.context.active_pose_bone
print(b.matrix.translation)
b.matrix = b.matrix @ Matrix.Translation((0,0,1))
print(b.matrix.translation)

both print statements will generate the same output, despite the second one happening after a matrix transformation has been performed on b.matrix.

i know inserting bpy.context.view_layer.update() before the second print statement will force b.matrix to update with its new value. but i’m curious, where does the actual data for the updated b.matrix exist before the view layer update? is it accessible anywhere, or should I be responsible for creating my own variable to store b.matrix @ Matrix.Translation((0,0,1)) if i need to reference it again before script end?

just trying to learn best practices!

With bones there’s a caveat where updates are deferred due to the potentially long evaluation chain (f-curves, drivers, expressions, constraints, etc.).

So, we instead need to explicitly call for updates if we want things to happen during a solid segment of script execution. In such cases it’s best to first copy the matrix or vector, do your thing, then assign it back at the end. This avoids unnecessary setter and update callbacks on the rna side of things.

1 Like