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>2019-09-29 11:00:38 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-29 17:48:56 +0300
commit6bb8ab3ad7b8131ffa9ed3261b6da8627903f3b1 (patch)
treee9df96fbef4073c43ee1a316763c632b9392a387 /rigify/utils/misc.py
parent73784e78de99cb647870cbd93ef497f3e437a1a6 (diff)
Rigify: various additions to bone, mechanism and widget utilities.
Support easier setting of bone orientation via matrix, inherit_scale, invert_x/y/z constraint properties, computing a matrix from two axis vectors, adjusting widget positions, and add a pivot widget.
Diffstat (limited to 'rigify/utils/misc.py')
-rw-r--r--rigify/utils/misc.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/rigify/utils/misc.py b/rigify/utils/misc.py
index b0f79ea7..4d0fbad3 100644
--- a/rigify/utils/misc.py
+++ b/rigify/utils/misc.py
@@ -18,6 +18,7 @@
# <pep8 compliant>
+import bpy
import math
import collections
@@ -56,6 +57,28 @@ def angle_on_plane(plane, vec1, vec2):
return angle * sign
+
+# Convert between a matrix and axis+roll representations.
+# Re-export the C implementation internally used by bones.
+matrix_from_axis_roll = bpy.types.Bone.MatrixFromAxisRoll
+axis_roll_from_matrix = bpy.types.Bone.AxisRollFromMatrix
+
+
+def matrix_from_axis_pair(y_axis, other_axis, axis_name):
+ assert axis_name in 'xz'
+
+ y_axis = Vector(y_axis).normalized()
+
+ if axis_name == 'x':
+ z_axis = Vector(other_axis).cross(y_axis).normalized()
+ x_axis = y_axis.cross(z_axis)
+ else:
+ x_axis = y_axis.cross(other_axis).normalized()
+ z_axis = x_axis.cross(y_axis)
+
+ return Matrix((x_axis, y_axis, z_axis)).transposed()
+
+
#=============================================
# Color correction functions
#=============================================