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 | |
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')
-rw-r--r-- | release/scripts/io/engine_render_pov.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_3ds.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_fbx.py | 50 | ||||
-rw-r--r-- | release/scripts/io/export_x3d.py | 26 | ||||
-rw-r--r-- | release/scripts/io/import_anim_bvh.py | 50 | ||||
-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 | ||||
-rw-r--r-- | release/scripts/op/mesh.py | 2 | ||||
-rw-r--r-- | release/scripts/op/mesh_skin.py | 7 | ||||
-rw-r--r-- | release/scripts/op/uvcalc_smart_project.py | 2 | ||||
-rw-r--r-- | release/scripts/templates/gamelogic.py | 2 |
17 files changed, 100 insertions, 104 deletions
diff --git a/release/scripts/io/engine_render_pov.py b/release/scripts/io/engine_render_pov.py index 5275574d903..7abb0c19cd7 100644 --- a/release/scripts/io/engine_render_pov.py +++ b/release/scripts/io/engine_render_pov.py @@ -146,7 +146,7 @@ def write_pov(filename, scene=None, info_callback=None): file.write('\tup <0, 1, 0>\n') file.write('\tangle %f \n' % (360.0 * atan(16.0 / camera.data.lens) / pi)) - file.write('\trotate <%.6f, %.6f, %.6f>\n' % tuple([degrees(e) for e in matrix.rotationPart().toEuler()])) + file.write('\trotate <%.6f, %.6f, %.6f>\n' % tuple([degrees(e) for e in matrix.rotation_part().to_euler()])) file.write('\ttranslate <%.6f, %.6f, %.6f>\n' % (matrix[3][0], matrix[3][1], matrix[3][2])) file.write('}\n') diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 979c53c581d..f898a4b5f9e 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -839,7 +839,7 @@ def make_track_chunk(ID, obj): track_chunk.add_variable("position", _3ds_point_3d(obj.getLocation())) elif ID==ROT_TRACK_TAG: # rotation (quaternion, angle first, followed by axis): - q = obj.getEuler().toQuat() + q = obj.getEuler().to_quat() track_chunk.add_variable("rotation", _3ds_point_4d((q.angle, q.axis[0], q.axis[1], q.axis[2]))) elif ID==SCL_TRACK_TAG: # scale vector: diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 7a69659d164..dcf109e24e1 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -146,7 +146,7 @@ def eulerRadToDeg(eul): mtx4_identity = Mathutils.Matrix() # testing -mtx_x90 = Mathutils.RotationMatrix( math.pi/2, 3, 'x') # used +mtx_x90 = Mathutils.RotationMatrix( math.pi/2, 3, 'X') # used #mtx_x90n = RotationMatrix(-90, 3, 'x') #mtx_y90 = RotationMatrix( 90, 3, 'y') #mtx_y90n = RotationMatrix(-90, 3, 'y') @@ -154,11 +154,11 @@ mtx_x90 = Mathutils.RotationMatrix( math.pi/2, 3, 'x') # used #mtx_z90n = RotationMatrix(-90, 3, 'z') #mtx4_x90 = RotationMatrix( 90, 4, 'x') -mtx4_x90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'x') # used +mtx4_x90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'X') # used #mtx4_y90 = RotationMatrix( 90, 4, 'y') -mtx4_y90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'y') # used -mtx4_z90 = Mathutils.RotationMatrix( math.pi/2, 4, 'z') # used -mtx4_z90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'z') # used +mtx4_y90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'Y') # used +mtx4_z90 = Mathutils.RotationMatrix( math.pi/2, 4, 'Z') # used +mtx4_z90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'Z') # used # def strip_path(p): # return p.split('\\')[-1].split('/')[-1] @@ -590,9 +590,9 @@ def write(filename, batch_objects = None, \ def getAnimParRelMatrixRot(self, frame): type = self.blenObject.type if self.fbxParent: - matrix_rot = (((self.__anim_poselist[frame] * GLOBAL_MATRIX) * (self.fbxParent.__anim_poselist[frame] * GLOBAL_MATRIX).invert())).rotationPart() + matrix_rot = (((self.__anim_poselist[frame] * GLOBAL_MATRIX) * (self.fbxParent.__anim_poselist[frame] * GLOBAL_MATRIX).invert())).rotation_part() else: - matrix_rot = (self.__anim_poselist[frame] * GLOBAL_MATRIX).rotationPart() + matrix_rot = (self.__anim_poselist[frame] * GLOBAL_MATRIX).rotation_part() # Lamps need to be rotated if type =='LAMP': @@ -600,7 +600,7 @@ def write(filename, batch_objects = None, \ elif type =='CAMERA': # elif ob and type =='Camera': y = Mathutils.Vector(0,1,0) * matrix_rot - matrix_rot = matrix_rot * Mathutils.RotationMatrix(math.pi/2, 3, 'r', y) + matrix_rot = matrix_rot * Mathutils.RotationMatrix(math.pi/2, 3, y) return matrix_rot @@ -676,11 +676,11 @@ def write(filename, batch_objects = None, \ # par_matrix = mtx4_z90 * parent.matrix['ARMATURESPACE'] # dont apply armature matrix anymore matrix = matrix * par_matrix.copy().invert() - matrix_rot = matrix.rotationPart() + matrix_rot = matrix.rotation_part() - loc = tuple(matrix.translationPart()) - scale = tuple(matrix.scalePart()) - rot = tuple(matrix_rot.toEuler()) + loc = tuple(matrix.translation_part()) + scale = tuple(matrix.scale_part()) + rot = tuple(matrix_rot.to_euler()) else: # This is bad because we need the parent relative matrix from the fbx parent (if we have one), dont use anymore @@ -692,20 +692,20 @@ def write(filename, batch_objects = None, \ # matrix = matrix_scale * matrix if matrix: - loc = tuple(matrix.translationPart()) - scale = tuple(matrix.scalePart()) + loc = tuple(matrix.translation_part()) + scale = tuple(matrix.scale_part()) - matrix_rot = matrix.rotationPart() + matrix_rot = matrix.rotation_part() # Lamps need to be rotated if ob and ob.type =='Lamp': matrix_rot = mtx_x90 * matrix_rot - rot = tuple(matrix_rot.toEuler()) + rot = tuple(matrix_rot.to_euler()) elif ob and ob.type =='Camera': y = Mathutils.Vector(0,1,0) * matrix_rot - matrix_rot = matrix_rot * Mathutils.RotationMatrix(math.pi/2, 3, 'r', y) - rot = tuple(matrix_rot.toEuler()) + matrix_rot = matrix_rot * Mathutils.RotationMatrix(math.pi/2, 3, y) + rot = tuple(matrix_rot.to_euler()) else: - rot = tuple(matrix_rot.toEuler()) + rot = tuple(matrix_rot.to_euler()) else: if not loc: loc = 0,0,0 @@ -1131,7 +1131,7 @@ def write(filename, batch_objects = None, \ else: do_light = 1 - scale = abs(GLOBAL_MATRIX.scalePart()[0]) # scale is always uniform in this case + scale = abs(GLOBAL_MATRIX.scale_part()[0]) # scale is always uniform in this case file.write('\n\t\t\tProperty: "LightType", "enum", "",%i' % light_type) file.write('\n\t\t\tProperty: "CastLightOnObject", "bool", "",1') @@ -2866,18 +2866,18 @@ Takes: {''') # ---------------- for TX_LAYER, TX_CHAN in enumerate('TRS'): # transform, rotate, scale - if TX_CHAN=='T': context_bone_anim_vecs = [mtx[0].translationPart() for mtx in context_bone_anim_mats] - elif TX_CHAN=='S': context_bone_anim_vecs = [mtx[0].scalePart() for mtx in context_bone_anim_mats] + if TX_CHAN=='T': context_bone_anim_vecs = [mtx[0].translation_part() for mtx in context_bone_anim_mats] + elif TX_CHAN=='S': context_bone_anim_vecs = [mtx[0].scale_part() for mtx in context_bone_anim_mats] elif TX_CHAN=='R': # Was.... - # elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].toEuler() for mtx in context_bone_anim_mats] + # elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].to_euler() for mtx in context_bone_anim_mats] # # ...but we need to use the previous euler for compatible conversion. context_bone_anim_vecs = [] prev_eul = None for mtx in context_bone_anim_mats: - if prev_eul: prev_eul = mtx[1].toEuler(prev_eul) - else: prev_eul = mtx[1].toEuler() + if prev_eul: prev_eul = mtx[1].to_euler(prev_eul) + else: prev_eul = mtx[1].to_euler() context_bone_anim_vecs.append(eulerRadToDeg(prev_eul)) # context_bone_anim_vecs.append(prev_eul) diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 44032a0c733..0875abf1de1 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -81,7 +81,7 @@ from export_3ds import create_derived_objects, free_derived_objects # DEG2RAD=0.017453292519943295 -MATWORLD= Mathutils.RotationMatrix(-90, 4, 'x') +MATWORLD= Mathutils.RotationMatrix(-90, 4, 'X') #################################### # Global Variables @@ -239,8 +239,8 @@ class x3d_class: # get the camera location, subtract 90 degress from X to orient like X3D does # mat = ob.matrixWorld - mat is now passed! - loc = self.rotatePointForVRML(mat.translationPart()) - rot = mat.toEuler() + loc = self.rotatePointForVRML(mat.translation_part()) + rot = mat.to_euler() rot = (((rot[0]-90)), rot[1], rot[2]) # rot = (((rot[0]-90)*DEG2RAD), rot[1]*DEG2RAD, rot[2]*DEG2RAD) nRot = self.rotatePointForVRML( rot ) @@ -300,8 +300,8 @@ class x3d_class: # note -dz seems to equal om[3][1] # note dy seems to equal om[3][2] - #location=(ob.matrixWorld*MATWORLD).translationPart() # now passed - location=(mtx*MATWORLD).translationPart() + #location=(ob.matrixWorld*MATWORLD).translation_part() # now passed + location=(mtx*MATWORLD).translation_part() radius = lamp.distance*math.cos(beamWidth) # radius = lamp.dist*math.cos(beamWidth) @@ -346,8 +346,8 @@ class x3d_class: ambi = 0 ambientIntensity = 0 - # location=(ob.matrixWorld*MATWORLD).translationPart() # now passed - location= (mtx*MATWORLD).translationPart() + # location=(ob.matrixWorld*MATWORLD).translation_part() # now passed + location= (mtx*MATWORLD).translation_part() self.file.write("<PointLight DEF=\"%s\" " % safeName) self.file.write("ambientIntensity=\"%s\" " % (round(ambientIntensity,self.cp))) @@ -364,8 +364,8 @@ class x3d_class: return else: dx,dy,dz = self.computeDirection(mtx) - # location=(ob.matrixWorld*MATWORLD).translationPart() - location=(mtx*MATWORLD).translationPart() + # location=(ob.matrixWorld*MATWORLD).translation_part() + location=(mtx*MATWORLD).translation_part() self.writeIndented("<%s\n" % obname,1) self.writeIndented("direction=\"%s %s %s\"\n" % (round(dx,3),round(dy,3),round(dz,3))) self.writeIndented("location=\"%s %s %s\"\n" % (round(location[0],3), round(location[1],3), round(location[2],3))) @@ -448,9 +448,9 @@ class x3d_class: # mtx = ob.matrixWorld * MATWORLD # mtx is now passed mtx = mtx * MATWORLD - loc= mtx.translationPart() - sca= mtx.scalePart() - quat = mtx.toQuat() + loc= mtx.translation_part() + sca= mtx.scale_part() + quat = mtx.to_quat() rot= quat.axis self.writeIndented('<Transform DEF="%s" translation="%.6f %.6f %.6f" scale="%.6f %.6f %.6f" rotation="%.6f %.6f %.6f %.6f">\n' % \ @@ -1048,7 +1048,7 @@ class x3d_class: def computeDirection(self, mtx): x,y,z=(0,-1.0,0) # point down - ax,ay,az = (mtx*MATWORLD).toEuler() + ax,ay,az = (mtx*MATWORLD).to_euler() # ax *= DEG2RAD # ay *= DEG2RAD diff --git a/release/scripts/io/import_anim_bvh.py b/release/scripts/io/import_anim_bvh.py index 2afd2db3cb2..f6626e8fb1e 100644 --- a/release/scripts/io/import_anim_bvh.py +++ b/release/scripts/io/import_anim_bvh.py @@ -89,13 +89,13 @@ MATRIX_IDENTITY_4x4 = Matrix([1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]) def eulerRotate(x,y,z, rot_order): # Clamp all values between 0 and 360, values outside this raise an error. - mats=[RotationMatrix(math.radians(x%360),3,'x'), RotationMatrix(math.radians(y%360),3,'y'), RotationMatrix(math.radians(z%360),3,'z')] + mats=[RotationMatrix(math.radians(x % 360), 3, 'X'), RotationMatrix(math.radians(y % 360),3,'Y'), RotationMatrix(math.radians(z % 360), 3, 'Z')] # print rot_order # Standard BVH multiplication order, apply the rotation in the order Z,X,Y #XXX, order changes??? - #eul = (mats[rot_order[2]]*(mats[rot_order[1]]* (mats[rot_order[0]]* MATRIX_IDENTITY_3x3))).toEuler() - eul = (MATRIX_IDENTITY_3x3*mats[rot_order[0]]*(mats[rot_order[1]]* (mats[rot_order[2]]))).toEuler() + #eul = (mats[rot_order[2]]*(mats[rot_order[1]]* (mats[rot_order[0]]* MATRIX_IDENTITY_3x3))).to_euler() + eul = (MATRIX_IDENTITY_3x3*mats[rot_order[0]]*(mats[rot_order[1]]* (mats[rot_order[2]]))).to_euler() eul = math.degrees(eul.x), math.degrees(eul.y), math.degrees(eul.z) @@ -534,8 +534,8 @@ def bvh_node_dict2armature(context, bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOO bone_name= bvh_node.temp # may not be the same name as the bvh_node, could have been shortened. pose_bone= pose_bones[bone_name] rest_bone= arm_data.bones[bone_name] -#XXX bone_rest_matrix = rest_bone.matrix['ARMATURESPACE'].rotationPart() - bone_rest_matrix = rest_bone.matrix.rotationPart() +#XXX bone_rest_matrix = rest_bone.matrix['ARMATURESPACE'].rotation_part() + bone_rest_matrix = rest_bone.matrix.rotation_part() bone_rest_matrix_inv= Matrix(bone_rest_matrix) @@ -575,31 +575,31 @@ def bvh_node_dict2armature(context, bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOO if ROT_STYLE=='QUAT': # Set the rotation, not so simple - bone_rotation_matrix= Euler(math.radians(rx), math.radians(ry), math.radians(rz)).toMatrix() + bone_rotation_matrix= Euler(math.radians(rx), math.radians(ry), math.radians(rz)).to_matrix() bone_rotation_matrix.resize4x4() #XXX ORDER CHANGE??? - #pose_bone.rotation_quaternion= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).toQuat() # ORIGINAL - # pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix).toQuat() - # pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix).toQuat() # BAD - # pose_bone.rotation_quaternion= bone_rotation_matrix.toQuat() # NOT GOOD - # pose_bone.rotation_quaternion= bone_rotation_matrix.toQuat() # NOT GOOD + #pose_bone.rotation_quaternion= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).to_quat() # ORIGINAL + # pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix).to_quat() + # pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix).to_quat() # BAD + # pose_bone.rotation_quaternion= bone_rotation_matrix.to_quat() # NOT GOOD + # pose_bone.rotation_quaternion= bone_rotation_matrix.to_quat() # NOT GOOD - #pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix_inv * bone_rest_matrix).toQuat() - #pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rest_matrix * bone_rotation_matrix).toQuat() - #pose_bone.rotation_quaternion= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).toQuat() + #pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix_inv * bone_rest_matrix).to_quat() + #pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rest_matrix * bone_rotation_matrix).to_quat() + #pose_bone.rotation_quaternion= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).to_quat() - #pose_bone.rotation_quaternion= ( bone_rest_matrix* bone_rest_matrix_inv * bone_rotation_matrix).toQuat() - #pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix * bone_rest_matrix_inv).toQuat() - #pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix ).toQuat() + #pose_bone.rotation_quaternion= ( bone_rest_matrix* bone_rest_matrix_inv * bone_rotation_matrix).to_quat() + #pose_bone.rotation_quaternion= (bone_rotation_matrix * bone_rest_matrix * bone_rest_matrix_inv).to_quat() + #pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix ).to_quat() - pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix).toQuat() + pose_bone.rotation_quaternion= (bone_rest_matrix_inv * bone_rotation_matrix * bone_rest_matrix).to_quat() else: - bone_rotation_matrix= Euler(math.radians(rx), math.radians(ry), math.radians(rz)).toMatrix() + bone_rotation_matrix= Euler(math.radians(rx), math.radians(ry), math.radians(rz)).to_matrix() bone_rotation_matrix.resize4x4() - eul= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).toEuler() + eul= (bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).to_euler() #pose_bone.rotation_euler = math.radians(rx), math.radians(ry), math.radians(rz) pose_bone.rotation_euler = eul @@ -610,8 +610,8 @@ def bvh_node_dict2armature(context, bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOO # Set the Location, simple too #XXX ORDER CHANGE - # pose_bone.location= (TranslationMatrix(Vector(lx, ly, lz) - bvh_node.rest_head_local ) * bone_rest_matrix_inv).translationPart() # WHY * 10? - just how pose works - # pose_bone.location= (bone_rest_matrix_inv * TranslationMatrix(Vector(lx, ly, lz) - bvh_node.rest_head_local )).translationPart() + # pose_bone.location= (TranslationMatrix(Vector(lx, ly, lz) - bvh_node.rest_head_local ) * bone_rest_matrix_inv).translation_part() # WHY * 10? - just how pose works + # pose_bone.location= (bone_rest_matrix_inv * TranslationMatrix(Vector(lx, ly, lz) - bvh_node.rest_head_local )).translation_part() # pose_bone.location= lx, ly, lz pose_bone.location= Vector(lx, ly, lz) - bvh_node.rest_head_local @@ -714,12 +714,12 @@ def bvh_node_dict2armature(context, bvh_nodes, IMPORT_START_FRAME= 1, IMPORT_LOO def pose_rot(anim_data): - bone_rotation_matrix= Euler(anim_data[3], anim_data[4], anim_data[5]).toMatrix() + bone_rotation_matrix= Euler(anim_data[3], anim_data[4], anim_data[5]).to_matrix() bone_rotation_matrix.resize4x4() - return tuple((bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).toQuat()) # qw,qx,qy,qz + return tuple((bone_rest_matrix * bone_rotation_matrix * bone_rest_matrix_inv).to_quat()) # qw,qx,qy,qz def pose_loc(anim_data): - return tuple((TranslationMatrix(Vector(anim_data[0], anim_data[1], anim_data[2])) * bone_rest_matrix_inv).translationPart()) + return tuple((TranslationMatrix(Vector(anim_data[0], anim_data[1], anim_data[2])) * bone_rest_matrix_inv).translation_part()) last_frame= len(bvh_node.anim_data)+IMPORT_START_FRAME-1 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: diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index f9b0b4d75b8..88b70509dee 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -90,7 +90,7 @@ class MeshMirrorUV(bpy.types.Operator): mirror_gt = {} mirror_lt = {} - vcos = [v.co.toTuple(5) for v in mesh.verts] + vcos = [v.co.to_tuple(5) for v in mesh.verts] for i, co in enumerate(vcos): if co[0] > 0.0: diff --git a/release/scripts/op/mesh_skin.py b/release/scripts/op/mesh_skin.py index 6f62924ec02..15bf22d38b9 100644 --- a/release/scripts/op/mesh_skin.py +++ b/release/scripts/op/mesh_skin.py @@ -22,8 +22,7 @@ import time, functools import bpy # from Blender import Window -from Mathutils import MidpointVecs, Vector -from Mathutils import AngleBetweenVecs as _AngleBetweenVecs_ +from Mathutils import Vector # import BPyMessages # from Blender.Draw import PupMenu @@ -36,7 +35,7 @@ CULL_METHOD = 0 def AngleBetweenVecs(a1,a2): import math try: - return math.degrees(_AngleBetweenVecs_(a1,a2)) + return math.degrees(a1.angle(a2)) except: return 180.0 @@ -54,7 +53,7 @@ class edge(object): self.removed = 0 # Have we been culled from the eloop self.match = None # The other edge were making a face with - self.cent= MidpointVecs(co1, co2) + self.cent= co1.lerp(co2, 0.5) self.angle= 0.0 self.fake= False diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 0cf2a650973..5efbbf25c32 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -936,7 +936,7 @@ def main(context, island_margin, projection_limit): # Initialize projectVecs if USER_VIEW_INIT: # Generate Projection - projectVecs = [Vector(Window.GetViewVector()) * ob.matrixWorld.copy().invert().rotationPart()] # We add to this allong the way + projectVecs = [Vector(Window.GetViewVector()) * ob.matrixWorld.copy().invert().rotation_part()] # We add to this allong the way else: projectVecs = [] diff --git a/release/scripts/templates/gamelogic.py b/release/scripts/templates/gamelogic.py index 0d1bc7fa29d..b4eac81b492 100644 --- a/release/scripts/templates/gamelogic.py +++ b/release/scripts/templates/gamelogic.py @@ -6,7 +6,7 @@ # for keyboard event comparison # import GameKeys -# support for Vector(), Matrix() types and advanced functions like AngleBetweenVecs(v1,v2) and RotationMatrix(...) +# support for Vector(), Matrix() types and advanced functions like ScaleMatrix(...) and RotationMatrix(...) # import Mathutils # for functions like getWindowWidth(), getWindowHeight() |