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-14 09:15:14 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-14 09:30:00 +0300
commit9b693a6be0aa2b0b4825d30ac5034655dce9c0dd (patch)
tree2875d325828db8e5f447419dcacfdeab1951af63 /rigify/utils/widgets.py
parent3423174b37a0784dc12035ff3f2fb536835099e1 (diff)
Rigify: update super_chain from the latest 2.79 version by MAD.
Differential Revision: https://developer.blender.org/D4624
Diffstat (limited to 'rigify/utils/widgets.py')
-rw-r--r--rigify/utils/widgets.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/rigify/utils/widgets.py b/rigify/utils/widgets.py
index fad1065a..6d83264a 100644
--- a/rigify/utils/widgets.py
+++ b/rigify/utils/widgets.py
@@ -21,6 +21,8 @@
import bpy
import math
+from mathutils import Matrix
+
from .errors import MetarigError
from .collections import ensure_widget_collection
@@ -132,13 +134,39 @@ def create_circle_polygon(number_verts, axis, radius=1.0, head_tail=0.0):
return verts, edges
+def adjust_widget_axis(obj, axis='y', offset=0.0):
+ mesh = obj.data
+
+ if axis[0] == '-':
+ s = -1.0
+ axis = axis[1]
+ else:
+ s = 1.0
+
+ trans_matrix = Matrix.Translation((0.0, offset, 0.0))
+ rot_matrix = Matrix.Diagonal((1.0, s, 1.0, 1.0))
+
+ if axis == "x":
+ rot_matrix = Matrix.Rotation(-s*math.pi/2, 4, 'Z')
+ trans_matrix = Matrix.Translation((offset, 0.0, 0.0))
+
+ elif axis == "z":
+ rot_matrix = Matrix.Rotation(s*math.pi/2, 4, 'X')
+ trans_matrix = Matrix.Translation((0.0, 0.0, offset))
+
+ matrix = trans_matrix @ rot_matrix
+
+ for vert in mesh.vertices:
+ vert.co = matrix @ vert.co
+
+
def write_widget(obj):
""" Write a mesh object as a python script for widget use.
"""
script = ""
script += "def create_thing_widget(rig, bone_name, size=1.0, bone_transform_name=None):\n"
script += " obj = create_widget(rig, bone_name, bone_transform_name)\n"
- script += " if obj != None:\n"
+ script += " if obj is not None:\n"
# Vertices
script += " verts = ["
@@ -168,7 +196,6 @@ def write_widget(obj):
script += "\n mesh = obj.data\n"
script += " mesh.from_pydata(verts, edges, faces)\n"
script += " mesh.update()\n"
- script += " mesh.update()\n"
script += " return obj\n"
script += " else:\n"
script += " return None\n"