diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-25 12:44:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-25 12:44:04 +0300 |
commit | 0a0f4c9d81cfa2a4b4a9999e1dc976bc417d7d54 (patch) | |
tree | 367f259b695955a514530d125ab495344724eafb /release/scripts/modules | |
parent | eed13d859b67185996569178ede9241a5695f215 (diff) |
Mathutils refactor & include in sphinx generated docs, (TODO, include getset'ers in docs)
- Mathutils.MidpointVecs --> vector.lerp(other, fac)
- Mathutils.AngleBetweenVecs --> vector.angle(other)
- Mathutils.ProjectVecs --> vector.project(other)
- Mathutils.DifferenceQuats --> quat.difference(other)
- Mathutils.Slerp --> quat.slerp(other, fac)
- Mathutils.Rand: removed, use pythons random module
- Mathutils.RotationMatrix(angle, size, axis_flag, axis) --> Mathutils.RotationMatrix(angle, size, axis); merge axis & axis_flag args
- Matrix.scalePart --> Matrix.scale_part
- Matrix.translationPart --> Matrix.translation_part
- Matrix.rotationPart --> Matrix.rotation_part
- toMatrix --> to_matrix
- toEuler --> to_euler
- toQuat --> to_quat
- Vector.toTrackQuat --> Vector.to_track_quat
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 12 | ||||
-rw-r--r-- | release/scripts/modules/retopo.py | 21 | ||||
-rw-r--r-- | release/scripts/modules/rigify/delta.py | 6 | ||||
-rw-r--r-- | release/scripts/modules/rigify/leg_quadruped.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/mouth.py | 4 | ||||
-rw-r--r-- | release/scripts/modules/rigify/palm_curl.py | 6 | ||||
-rw-r--r-- | release/scripts/modules/rigify/shape_key_rotdiff.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify_utils.py | 8 |
8 files changed, 29 insertions, 32 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index a1278f4f7cd..668951980e8 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -94,19 +94,19 @@ class _GenericBone: def x_axis(self): """ Vector pointing down the x-axis of the bone. """ - return self.matrix.rotationPart() * Vector(1,0,0) + return self.matrix.rotation_part() * Vector(1,0,0) @property def y_axis(self): """ Vector pointing down the x-axis of the bone. """ - return self.matrix.rotationPart() * Vector(0,1,0) + return self.matrix.rotation_part() * Vector(0,1,0) @property def z_axis(self): """ Vector pointing down the x-axis of the bone. """ - return self.matrix.rotationPart() * Vector(0,0,1) + return self.matrix.rotation_part() * Vector(0,0,1) @property def basename(self): @@ -236,7 +236,7 @@ class EditBone(StructRNA, _GenericBone): Expects a 4x4 or 3x3 matrix. """ from Mathutils import Vector - z_vec = self.matrix.rotationPart() * Vector(0.0, 0.0, 1.0) + z_vec = self.matrix.rotation_part() * Vector(0.0, 0.0, 1.0) self.tail = matrix * self.tail self.head = matrix * self.head scalar = matrix.median_scale @@ -421,8 +421,8 @@ class OrderedMeta(type): # Only defined so operators members can be used by accessing self.order -class Operator(StructRNA, metaclass=OrderedMeta): - __slots__ = () +#class Operator(StructRNA, metaclass=OrderedMeta): +# __slots__ = () class Macro(StructRNA, metaclass=OrderedMeta): diff --git a/release/scripts/modules/retopo.py b/release/scripts/modules/retopo.py index 6fba34b7b58..e10589d17d0 100644 --- a/release/scripts/modules/retopo.py +++ b/release/scripts/modules/retopo.py @@ -30,14 +30,14 @@ def get_hub(co, _hubs, EPS_SPLINE): if (hub.co - co).length < EPS_SPLINE: return hub - key = co.toTuple(3) + key = co.to_tuple(3) hub = _hubs[key] = Hub(co, key, len(_hubs)) return hub else: pass ''' - key = co.toTuple(3) + key = co.to_tuple(3) try: return _hubs[key] except: @@ -274,9 +274,7 @@ def get_splines(gp): def xsect_spline(sp_a, sp_b, _hubs): - from Mathutils import LineIntersect - from Mathutils import MidpointVecs - from Geometry import ClosestPointOnLine + from Geometry import ClosestPointOnLine, LineIntersect pt_a_prev = pt_b_prev = None EPS_SPLINE = (sp_a.length + sp_b.length) / (EPS_SPLINE_DIV * 2) pt_a_prev = sp_a.points[0] @@ -296,7 +294,7 @@ def xsect_spline(sp_a, sp_b, _hubs): # if f >= 0.0-EPS_SPLINE and f <= 1.0+EPS_SPLINE: if f >= 0.0 and f <= 1.0: # This wont happen often - co = MidpointVecs(xsect[0], xsect[1]) + co = xsect[0].lerp(xsect[1], 0.5) hub = get_hub(co, _hubs, EPS_SPLINE) sp_a.hubs.append((a, hub)) @@ -309,7 +307,6 @@ def xsect_spline(sp_a, sp_b, _hubs): def connect_splines(splines): HASH_PREC = 8 - from Mathutils import AngleBetweenVecs from math import radians ANG_LIMIT = radians(ANGLE_JOIN_LIMIT) def sort_pair(a, b): @@ -341,7 +338,7 @@ def connect_splines(splines): v1 = p1a - p1b v2 = p2b - p2a - if AngleBetweenVecs(v1, v2) > ANG_LIMIT: + if v1.angle(v2) > ANG_LIMIT: return False # print("joining!") @@ -354,8 +351,8 @@ def connect_splines(splines): while do_join: do_join = False for i, s1 in enumerate(splines): - key1a = s1.points[0].toTuple(HASH_PREC) - key1b = s1.points[-1].toTuple(HASH_PREC) + key1a = s1.points[0].to_tuple(HASH_PREC) + key1b = s1.points[-1].to_tuple(HASH_PREC) for j, s2 in enumerate(splines): if s1 is s2: @@ -363,8 +360,8 @@ def connect_splines(splines): length_average = min(s1.length, s2.length) - key2a = s2.points[0].toTuple(HASH_PREC) - key2b = s2.points[-1].toTuple(HASH_PREC) + key2a = s2.points[0].to_tuple(HASH_PREC) + key2b = s2.points[-1].to_tuple(HASH_PREC) # there are 4 ways this may be joined key_pair = sort_pair(key1a, key2a) diff --git a/release/scripts/modules/rigify/delta.py b/release/scripts/modules/rigify/delta.py index 475c64ab317..3376348c0af 100644 --- a/release/scripts/modules/rigify/delta.py +++ b/release/scripts/modules/rigify/delta.py @@ -127,8 +127,8 @@ def main(obj, bone_definition, base_names, options): delta_pbone.rotation_mode = 'XYZ' - rot = delta_pmatrix.invert().rotationPart() * child_pmatrix.rotationPart() - rot = rot.invert().toEuler() + rot = delta_pmatrix.invert().rotation_part() * child_pmatrix.rotation_part() + rot = rot.invert().to_euler() fcurve_drivers = delta_pbone.driver_add("rotation_euler", -1) for i, fcurve_driver in enumerate(fcurve_drivers): @@ -141,7 +141,7 @@ def main(obj, bone_definition, base_names, options): mod.coefficients[1] = 0.0 # tricky, find the transform to drive the bone to this location. - delta_head_offset = child_pmatrix.rotationPart() * (delta_phead - child_phead) + delta_head_offset = child_pmatrix.rotation_part() * (delta_phead - child_phead) fcurve_drivers = delta_pbone.driver_add("location", -1) for i, fcurve_driver in enumerate(fcurve_drivers): diff --git a/release/scripts/modules/rigify/leg_quadruped.py b/release/scripts/modules/rigify/leg_quadruped.py index d1f74ca28bf..524450d0d24 100644 --- a/release/scripts/modules/rigify/leg_quadruped.py +++ b/release/scripts/modules/rigify/leg_quadruped.py @@ -157,7 +157,7 @@ def ik(obj, bone_definition, base_names, options): ik.foot_roll_e.parent = ik_chain.foot_e ik.foot_roll_e.head -= mt_chain.toe_e.vector.normalize() * mt_chain.foot_e.length ik.foot_roll_e.tail = ik.foot_roll_e.head - (mt_chain.foot_e.vector.normalize() * mt_chain.toe_e.length) - ik.foot_roll_e.align_roll(mt_chain.foot_e.matrix.rotationPart() * Vector(0.0, 0.0, -1.0)) + ik.foot_roll_e.align_roll(mt_chain.foot_e.matrix.rotation_part() * Vector(0.0, 0.0, -1.0)) # MCH-foot ik.foot_roll_01_e = copy_bone_simple(arm, mt_chain.foot, "MCH-" + base_names[mt_chain.foot]) diff --git a/release/scripts/modules/rigify/mouth.py b/release/scripts/modules/rigify/mouth.py index e2ca1ab4d0c..77545bc09fd 100644 --- a/release/scripts/modules/rigify/mouth.py +++ b/release/scripts/modules/rigify/mouth.py @@ -255,8 +255,8 @@ def deform(obj, definitions, base_names, options): bpy.ops.object.mode_set(mode='EDIT') # Calculate the rotation difference between the bones - rotdiff_r = acos(eb[lip1].matrix.toQuat() * eb[lip8].matrix.toQuat()) * 2 - rotdiff_l = acos(eb[lip4].matrix.toQuat() * eb[lip5].matrix.toQuat()) * 2 + rotdiff_r = acos(eb[lip1].matrix.to_quat() * eb[lip8].matrix.to_quat()) * 2 + rotdiff_l = acos(eb[lip4].matrix.to_quat() * eb[lip5].matrix.to_quat()) * 2 print (rotdiff_l) diff --git a/release/scripts/modules/rigify/palm_curl.py b/release/scripts/modules/rigify/palm_curl.py index b231919823b..82010552ea7 100644 --- a/release/scripts/modules/rigify/palm_curl.py +++ b/release/scripts/modules/rigify/palm_curl.py @@ -249,15 +249,15 @@ def main(obj, bone_definition, base_names, options): # NOTE: the direction of the Z rotation depends on which side the palm is on. # we could do a simple side-of-x test but better to work out the direction # the hand is facing. - from Mathutils import Vector, AngleBetweenVecs + from Mathutils import Vector from math import degrees child_pbone_01 = obj.pose.bones[children[0]].bone child_pbone_02 = obj.pose.bones[children[1]].bone rel_vec = child_pbone_01.head - child_pbone_02.head - x_vec = child_pbone_01.matrix.rotationPart() * Vector(1.0, 0.0, 0.0) + x_vec = child_pbone_01.matrix.rotation_part() * Vector(1.0, 0.0, 0.0) - return degrees(AngleBetweenVecs(rel_vec, x_vec)) > 90.0 + return degrees(rel_vec.angle(x_vec)) > 90.0 if x_direction(): # flip driver.expression = "-(%s)" % driver.expression diff --git a/release/scripts/modules/rigify/shape_key_rotdiff.py b/release/scripts/modules/rigify/shape_key_rotdiff.py index 98ab1bd16b7..265a2fe368a 100644 --- a/release/scripts/modules/rigify/shape_key_rotdiff.py +++ b/release/scripts/modules/rigify/shape_key_rotdiff.py @@ -111,7 +111,7 @@ def deform(obj, definitions, base_names, options): # Calculate the rotation difference between the bones - rotdiff = (eb[bone_from].matrix.toQuat() * eb[bone_to].matrix.toQuat()) * 2 + rotdiff = (eb[bone_from].matrix.to_quat() * eb[bone_to].matrix.to_quat()) * 2 bpy.ops.object.mode_set(mode='OBJECT') diff --git a/release/scripts/modules/rigify_utils.py b/release/scripts/modules/rigify_utils.py index e45f0dbc63a..289489686ec 100644 --- a/release/scripts/modules/rigify_utils.py +++ b/release/scripts/modules/rigify_utils.py @@ -205,8 +205,8 @@ def add_pole_target_bone(obj, base_bone_name, name, mode='CROSS'): offset.length = distance elif mode == 'ZAVERAGE': # between both bones Z axis - z_axis_a = base_ebone.matrix.copy().rotationPart() * Vector(0.0, 0.0, -1.0) - z_axis_b = parent_ebone.matrix.copy().rotationPart() * Vector(0.0, 0.0, -1.0) + z_axis_a = base_ebone.matrix.copy().rotation_part() * Vector(0.0, 0.0, -1.0) + z_axis_b = parent_ebone.matrix.copy().rotation_part() * Vector(0.0, 0.0, -1.0) offset = (z_axis_a + z_axis_b).normalize() * distance else: # preset axis @@ -274,8 +274,8 @@ def write_meta_rig(obj, func_name="metarig_template"): for bone_name in bones: bone = arm.edit_bones[bone_name] code.append(" bone = arm.edit_bones.new('%s')" % bone.name) - code.append(" bone.head[:] = %.4f, %.4f, %.4f" % bone.head.toTuple(4)) - code.append(" bone.tail[:] = %.4f, %.4f, %.4f" % bone.tail.toTuple(4)) + code.append(" bone.head[:] = %.4f, %.4f, %.4f" % bone.head.to_tuple(4)) + code.append(" bone.tail[:] = %.4f, %.4f, %.4f" % bone.tail.to_tuple(4)) code.append(" bone.roll = %.4f" % bone.roll) code.append(" bone.connected = %s" % str(bone.connected)) if bone.parent: |