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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2022-02-11 23:27:26 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-02-11 23:40:22 +0300
commit7120e9c9e08720c20833a334fee197ed9a11dc64 (patch)
tree1900e8544142f3ac4bcc91059fb94a8fae9eb840 /rigify/utils/bones.py
parent01c94f43a6ddc174c3f90aa9fa9c247ea79b4b76 (diff)
Rigify: allow aligning IK control location channels to world space.
For IK controls that move freely in space without being tied to a parent it makes sense to align the location channels to world (or root), while keeping rotation channels aligned to the limb end orientation. Blender already has a Local Location parenting option for this very use case, but Rigify wasn't using it. This adjusts the switchable parent mechanism so that the option works as intended, and provides a Rigify option that controls its value for IK controls. Note that now it is possible to enable the Local Location option directly on the control bones after generation and it will work correctly - it is not required to enable IK Local Location.
Diffstat (limited to 'rigify/utils/bones.py')
-rw-r--r--rigify/utils/bones.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/rigify/utils/bones.py b/rigify/utils/bones.py
index 16cf62de..10a8926d 100644
--- a/rigify/utils/bones.py
+++ b/rigify/utils/bones.py
@@ -482,6 +482,20 @@ def align_bone_orientation(obj, bone_name, target_bone_name):
bone1_e.roll = bone2_e.roll
+def set_bone_orientation(obj, bone_name, orientation):
+ """ Aligns the orientation of bone to target bone or matrix. """
+ if isinstance(orientation, str):
+ align_bone_orientation(obj, bone_name, orientation)
+
+ else:
+ bone_e = obj.data.edit_bones[bone_name]
+
+ matrix = Matrix(orientation).to_4x4()
+ matrix.translation = bone_e.head
+
+ bone_e.matrix = matrix
+
+
def align_bone_roll(obj, bone1, bone2):
""" Aligns the roll of two bones.
"""