Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2022-01-18 11:42:58 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-01-18 11:45:27 +0300
commitd7822981b1fed42e7f9c0a6aed568014892e8af5 (patch)
tree5e3eedb47f7172d2be3dda64cc6490692c3b411f /doc
parent542d15b1cd7efe85c0f64c48dbd52b47f35950f8 (diff)
Python API Docs: add non-invert `Bone.convert_local_to_pose` example.
This updates the example function to support assigning a subset of bone matrices. The code was tested to work in real use by @gaiaclary.
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/examples/bpy.types.Bone.convert_local_to_pose.py51
1 files changed, 33 insertions, 18 deletions
diff --git a/doc/python_api/examples/bpy.types.Bone.convert_local_to_pose.py b/doc/python_api/examples/bpy.types.Bone.convert_local_to_pose.py
index f3cc95dec61..4a88096cf6f 100644
--- a/doc/python_api/examples/bpy.types.Bone.convert_local_to_pose.py
+++ b/doc/python_api/examples/bpy.types.Bone.convert_local_to_pose.py
@@ -8,27 +8,42 @@ def set_pose_matrices(obj, matrix_map):
"Assign pose space matrices of all bones at once, ignoring constraints."
def rec(pbone, parent_matrix):
- matrix = matrix_map[pbone.name]
+ if pbone.name in matrix_map:
+ matrix = matrix_map[pbone.name]
- ## Instead of:
- # pbone.matrix = matrix
- # bpy.context.view_layer.update()
+ ## Instead of:
+ # pbone.matrix = matrix
+ # bpy.context.view_layer.update()
- # Compute and assign local matrix, using the new parent matrix
- if pbone.parent:
- pbone.matrix_basis = pbone.bone.convert_local_to_pose(
- matrix,
- pbone.bone.matrix_local,
- parent_matrix=parent_matrix,
- parent_matrix_local=pbone.parent.bone.matrix_local,
- invert=True
- )
+ # Compute and assign local matrix, using the new parent matrix
+ if pbone.parent:
+ pbone.matrix_basis = pbone.bone.convert_local_to_pose(
+ matrix,
+ pbone.bone.matrix_local,
+ parent_matrix=parent_matrix,
+ parent_matrix_local=pbone.parent.bone.matrix_local,
+ invert=True
+ )
+ else:
+ pbone.matrix_basis = pbone.bone.convert_local_to_pose(
+ matrix,
+ pbone.bone.matrix_local,
+ invert=True
+ )
else:
- pbone.matrix_basis = pbone.bone.convert_local_to_pose(
- matrix,
- pbone.bone.matrix_local,
- invert=True
- )
+ # Compute the updated pose matrix from local and new parent matrix
+ if pbone.parent:
+ matrix = pbone.bone.convert_local_to_pose(
+ pbone.matrix_basis,
+ pbone.bone.matrix_local,
+ parent_matrix=parent_matrix,
+ parent_matrix_local=pbone.parent.bone.matrix_local,
+ )
+ else:
+ matrix = pbone.bone.convert_local_to_pose(
+ pbone.matrix_basis,
+ pbone.bone.matrix_local,
+ )
# Recursively process children, passing the new matrix through
for child in pbone.children: