[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31258] trunk/blender: mathutils module methods only contained matrix constructors, move these to matrix class methods since this is acceptable in python.

Campbell Barton ideasman42 at gmail.com
Wed Aug 11 18:40:36 CEST 2010


Revision: 31258
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31258
Author:   campbellbarton
Date:     2010-08-11 18:40:36 +0200 (Wed, 11 Aug 2010)

Log Message:
-----------
mathutils module methods only contained matrix constructors, move these to matrix class methods since this is acceptable in python. eg: dict.fromkeys() and groups them more logically.
 mathutils.RotationMatrix -> mathutils.Matrix.Rotation
 mathutils.ScaleMatrix -> mathutils.Matrix.Scale
 mathutils.ShearMatrix -> mathutils.Matrix.Shear
 mathutils.TranslationMatrix -> mathutils.Matrix.Translation
 mathutils.OrthoProjectionMatrix -> mathutils.Matrix.OrthoProjection

Modified Paths:
--------------
    trunk/blender/release/scripts/io/export_fbx.py
    trunk/blender/release/scripts/io/export_obj.py
    trunk/blender/release/scripts/io/export_x3d.py
    trunk/blender/release/scripts/io/import_anim_bvh.py
    trunk/blender/release/scripts/io/import_scene_3ds.py
    trunk/blender/release/scripts/modules/add_object_utils.py
    trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py
    trunk/blender/release/scripts/modules/rigify/tail_control.py
    trunk/blender/release/scripts/op/uvcalc_smart_project.py
    trunk/blender/release/scripts/templates/gamelogic.py
    trunk/blender/source/blender/python/generic/mathutils.c
    trunk/blender/source/blender/python/generic/mathutils_matrix.c

Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/io/export_fbx.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -55,7 +55,7 @@
 import shutil # for file copying
 
 import bpy
-from mathutils import Vector, Euler, Matrix, RotationMatrix
+from mathutils import Vector, Euler, Matrix
 
 def copy_file(source, dest):
     # XXX - remove, can use shutil
@@ -107,19 +107,19 @@
 mtx4_identity = Matrix()
 
 # testing
-mtx_x90		= 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')
-#mtx_z90	= RotationMatrix( 90, 3, 'z')
-#mtx_z90n	= RotationMatrix(-90, 3, 'z')
+mtx_x90		= Matrix.Rotation( math.pi/2, 3, 'X') # used
+#mtx_x90n	= Matrix.Rotation(-90, 3, 'x')
+#mtx_y90	= Matrix.Rotation( 90, 3, 'y')
+#mtx_y90n	= Matrix.Rotation(-90, 3, 'y')
+#mtx_z90	= Matrix.Rotation( 90, 3, 'z')
+#mtx_z90n	= Matrix.Rotation(-90, 3, 'z')
 
-#mtx4_x90	= RotationMatrix( 90, 4, 'x')
-mtx4_x90n	= RotationMatrix(-math.pi/2, 4, 'X') # used
-#mtx4_y90	= RotationMatrix( 90, 4, 'y')
-mtx4_y90n	= RotationMatrix(-math.pi/2, 4, 'Y') # used
-mtx4_z90	= RotationMatrix( math.pi/2, 4, 'Z') # used
-mtx4_z90n	= RotationMatrix(-math.pi/2, 4, 'Z') # used
+#mtx4_x90	= Matrix.Rotation( 90, 4, 'x')
+mtx4_x90n	= Matrix.Rotation(-math.pi/2, 4, 'X') # used
+#mtx4_y90	= Matrix.Rotation( 90, 4, 'y')
+mtx4_y90n	= Matrix.Rotation(-math.pi/2, 4, 'Y') # used
+mtx4_z90	= Matrix.Rotation( math.pi/2, 4, 'Z') # used
+mtx4_z90n	= Matrix.Rotation(-math.pi/2, 4, 'Z') # used
 
 # def strip_path(p):
 # 	return p.split('\\')[-1].split('/')[-1]
@@ -562,7 +562,7 @@
             elif type =='CAMERA':
 # 			elif ob and type =='Camera':
                 y = matrix_rot * Vector((0.0, 1.0, 0.0))
-                matrix_rot = RotationMatrix(math.pi/2, 3, y) * matrix_rot
+                matrix_rot = Matrix.Rotation(math.pi/2, 3, y) * matrix_rot
 
             return matrix_rot
 
@@ -664,7 +664,7 @@
                     rot = tuple(matrix_rot.to_euler())
                 elif ob and ob.type =='Camera':
                     y = matrix_rot * Vector((0.0, 1.0, 0.0))
-                    matrix_rot = RotationMatrix(math.pi/2, 3, y) * matrix_rot
+                    matrix_rot = Matrix.Rotation(math.pi/2, 3, y) * matrix_rot
                     rot = tuple(matrix_rot.to_euler())
                 else:
                     rot = tuple(matrix_rot.to_euler())

Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/io/export_obj.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -363,7 +363,7 @@
         file.write('mtllib %s\n' % ( mtlfilepath.split('\\')[-1].split('/')[-1] ))
 
     if EXPORT_ROTX90:
-        mat_xrot90= mathutils.RotationMatrix(-math.pi/2, 4, 'X')
+        mat_xrot90= mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')
 
     # Initialize totals, these are updated each object
     totverts = totuvco = totno = 1

Modified: trunk/blender/release/scripts/io/export_x3d.py
===================================================================
--- trunk/blender/release/scripts/io/export_x3d.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/io/export_x3d.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -81,7 +81,7 @@
 
 #
 DEG2RAD=0.017453292519943295
-MATWORLD= mathutils.RotationMatrix(-90, 4, 'X')
+MATWORLD= mathutils.Matrix.Rotation(-90, 4, 'X')
 
 ####################################
 # Global Variables

Modified: trunk/blender/release/scripts/io/import_anim_bvh.py
===================================================================
--- trunk/blender/release/scripts/io/import_anim_bvh.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/io/import_anim_bvh.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -23,7 +23,7 @@
 
 import bpy
 import mathutils
-from mathutils import Vector, Euler, Matrix, RotationMatrix, TranslationMatrix
+from mathutils import Vector, Euler, Matrix
 
 
 class bvh_node_class(object):
@@ -78,7 +78,7 @@
 
 def eulerRotate(x, y, z, rot_order):
     # Clamp all values between 0 and 360, values outside this raise an error.
-    mats = [RotationMatrix(x, 3, 'X'), RotationMatrix(y, 3, 'Y'), RotationMatrix(z, 3, 'Z')]
+    mats = [Matrix.Rotation(x, 3, 'X'), Matrix.Rotation(y, 3, 'Y'), Matrix.Rotation(z, 3, 'Z')]
     return (MATRIX_IDENTITY_3x3 * mats[rot_order[0]] * (mats[rot_order[1]] * (mats[rot_order[2]]))).to_euler()
 
     # Should work but doesnt!
@@ -529,7 +529,7 @@
                     prev_euler[i] = euler
 
             if bvh_node.has_loc:
-                pose_bone.location = (bone_rest_matrix_inv * TranslationMatrix(Vector((lx, ly, lz)) - bvh_node.rest_head_local)).translation_part()
+                pose_bone.location = (bone_rest_matrix_inv * Matrix.Translation(Vector((lx, ly, lz)) - bvh_node.rest_head_local)).translation_part()
 
             if bvh_node.has_loc:
                 pose_bone.keyframe_insert("location")

Modified: trunk/blender/release/scripts/io/import_scene_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/import_scene_3ds.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/io/import_scene_3ds.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -771,7 +771,7 @@
             #print contextMatrix_rot
             contextMatrix_rot.invert()
             #print contextMatrix_rot
-            #contextMatrix_tx = Blender.mathutils.TranslationMatrix(0.5 * Blender.mathutils.Vector(data[9:]))
+            #contextMatrix_tx = mathutils.Matrix.Translation(0.5 * Blender.mathutils.Vector(data[9:]))
             #contextMatrix_tx.invert()
 
             #tx.invert()

Modified: trunk/blender/release/scripts/modules/add_object_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/add_object_utils.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/modules/add_object_utils.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -25,11 +25,11 @@
 def add_object_align_init(context, operator):
 
     if operator and operator.properties.is_property_set("location") and operator.properties.is_property_set("rotation"):
-        location = mathutils.TranslationMatrix(mathutils.Vector(operator.properties.location))
+        location = mathutils.Matrix.Translation(mathutils.Vector(operator.properties.location))
         rotation = mathutils.Euler(operator.properties.rotation).to_matrix().resize4x4()
     else:
         # TODO, local view cursor!
-        location = mathutils.TranslationMatrix(context.scene.cursor_location)
+        location = mathutils.Matrix.Translation(context.scene.cursor_location)
 
         if context.user_preferences.edit.object_align == 'VIEW' and context.space_data.type == 'VIEW_3D':
             rotation = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()

Modified: trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -147,7 +147,7 @@
 
 
 def main(obj, bone_definition, base_names, options):
-    from mathutils import Vector, RotationMatrix
+    from mathutils import Vector, Matrix
     from math import radians, pi
 
     arm = obj.data
@@ -264,7 +264,7 @@
 
     # Rotate the rev chain 180 about the by the first bones center point
     pivot = (rv_chain.spine_01_e.head + rv_chain.spine_01_e.tail) * 0.5
-    matrix = RotationMatrix(radians(180), 3, 'X')
+    matrix = Matrix.Rotation(radians(180), 3, 'X')
     for i, attr in enumerate(rv_chain.attr_names): # similar to neck
         spine_e = getattr(rv_chain, attr + "_e")
         # use the first bone as the pivot

Modified: trunk/blender/release/scripts/modules/rigify/tail_control.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify/tail_control.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/modules/rigify/tail_control.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -22,7 +22,7 @@
 from rigify import RigifyError
 from rigify_utils import bone_class_instance, copy_bone_simple
 from rna_prop_ui import rna_idprop_ui_prop_get
-from mathutils import Vector, RotationMatrix
+from mathutils import Vector, Matrix
 from math import radians, pi
 
 # not used, defined for completeness

Modified: trunk/blender/release/scripts/op/uvcalc_smart_project.py
===================================================================
--- trunk/blender/release/scripts/op/uvcalc_smart_project.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/op/uvcalc_smart_project.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -22,7 +22,7 @@
 
 # <pep8 compliant>
 
-from mathutils import Matrix, Vector, RotationMatrix
+from mathutils import Matrix, Vector
 import time
 import geometry
 import bpy
@@ -275,15 +275,15 @@
 
 # Takes a list of faces that make up a UV island and rotate
 # until they optimally fit inside a square.
-ROTMAT_2D_POS_90D = RotationMatrix( radians(90.0), 2)
-ROTMAT_2D_POS_45D = RotationMatrix( radians(45.0), 2)
+ROTMAT_2D_POS_90D = Matrix.Rotation( radians(90.0), 2)
+ROTMAT_2D_POS_45D = Matrix.Rotation( radians(45.0), 2)
 
 RotMatStepRotation = []
 rot_angle = 22.5 #45.0/2
 while rot_angle > 0.1:
     RotMatStepRotation.append([\
-     RotationMatrix( radians(rot_angle), 2),\
-     RotationMatrix( radians(-rot_angle), 2)])
+     Matrix.Rotation( radians(rot_angle), 2),\
+     Matrix.Rotation( radians(-rot_angle), 2)])
 
     rot_angle = rot_angle/2.0
 

Modified: trunk/blender/release/scripts/templates/gamelogic.py
===================================================================
--- trunk/blender/release/scripts/templates/gamelogic.py	2010-08-11 16:30:16 UTC (rev 31257)
+++ trunk/blender/release/scripts/templates/gamelogic.py	2010-08-11 16:40:36 UTC (rev 31258)
@@ -6,7 +6,7 @@
 # for keyboard event comparison

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list