PyAPI
authorCampbell Barton <ideasman42@gmail.com>
Sun, 11 Apr 2010 14:22:27 +0000 (14:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 11 Apr 2010 14:22:27 +0000 (14:22 +0000)
 - added new mathutils.Color() type, use with rna so we can do for eg:
 material.diffuse_color.r = 1.0
 # also has hsv access
 material.diffuse_color.s = 0.6

 - made Mathutils and Geometry module names lowercase.

62 files changed:
release/scripts/io/export_fbx.py
release/scripts/io/export_mdd.py
release/scripts/io/export_obj.py
release/scripts/io/export_x3d.py
release/scripts/io/import_anim_bvh.py
release/scripts/io/import_scene_3ds.py
release/scripts/io/import_scene_obj.py
release/scripts/modules/bpy_types.py
release/scripts/modules/rigify/__init__.py
release/scripts/modules/rigify/arm_biped.py
release/scripts/modules/rigify/eye_balls.py
release/scripts/modules/rigify/eye_lid.py
release/scripts/modules/rigify/leg_biped.py
release/scripts/modules/rigify/leg_quadruped.py
release/scripts/modules/rigify/mouth.py
release/scripts/modules/rigify/neck.py
release/scripts/modules/rigify/neck_flex.py
release/scripts/modules/rigify/palm_curl.py
release/scripts/modules/rigify/spine_pivot_flex.py
release/scripts/modules/rigify/tail_control.py
release/scripts/modules/rigify/tongue.py
release/scripts/modules/rigify_utils.py
release/scripts/op/add_armature_human.py
release/scripts/op/add_mesh_torus.py
release/scripts/op/console_python.py
release/scripts/op/fcurve_euler_filter.py
release/scripts/op/mesh.py
release/scripts/op/nla.py
release/scripts/op/object.py
release/scripts/op/object_align.py
release/scripts/op/object_randomize_transform.py
release/scripts/op/uvcalc_smart_project.py
release/scripts/op/vertexpaint_dirt.py
release/scripts/templates/gamelogic.py
source/blender/python/doc/epy/Geometry.py
source/blender/python/doc/epy/Mathutils.py
source/blender/python/doc/examples/Mathutils.Euler.py [deleted file]
source/blender/python/doc/examples/Mathutils.Matrix.py [deleted file]
source/blender/python/doc/examples/Mathutils.Quaternion.py [deleted file]
source/blender/python/doc/examples/Mathutils.py [deleted file]
source/blender/python/doc/examples/mathutils.Euler.py [new file with mode: 0644]
source/blender/python/doc/examples/mathutils.Matrix.py [new file with mode: 0644]
source/blender/python/doc/examples/mathutils.Quaternion.py [new file with mode: 0644]
source/blender/python/doc/examples/mathutils.Vector.py [moved from source/blender/python/doc/examples/Mathutils.Vector.py with 80% similarity]
source/blender/python/doc/examples/mathutils.py [new file with mode: 0644]
source/blender/python/doc/sphinx_doc_gen.py
source/blender/python/generic/geometry.c
source/blender/python/generic/mathutils.c
source/blender/python/generic/mathutils.h
source/blender/python/generic/mathutils_color.c [new file with mode: 0644]
source/blender/python/generic/mathutils_color.h [new file with mode: 0644]
source/blender/python/generic/mathutils_euler.c
source/blender/python/generic/mathutils_matrix.c
source/blender/python/generic/mathutils_matrix.h
source/blender/python/generic/mathutils_quat.c
source/blender/python/generic/mathutils_quat.h
source/blender/python/generic/mathutils_vector.c
source/blender/python/generic/mathutils_vector.h
source/blender/python/intern/bpy_rna.c
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/PyDoc/API_intro.py
source/gameengine/PyDoc/GameTypes.py

index 08d142d80e8fcf77a32dda6b3eeb079cfeb927a0..3aed242289de6160797065691ab081a1c0abc913 100644 (file)
@@ -77,7 +77,7 @@ import shutil # for file copying
 
 # import Blender
 import bpy
-import Mathutils
+import mathutils
 
 
 
@@ -135,7 +135,7 @@ def copy_images(dest_dir, textures):
 # I guess FBX uses degrees instead of radians (Arystan).
 # Call this function just before writing to FBX.
 def eulerRadToDeg(eul):
-    ret = Mathutils.Euler()
+    ret = mathutils.Euler()
 
     ret.x = 180 / math.pi * eul[0]
     ret.y = 180 / math.pi * eul[1]
@@ -143,10 +143,10 @@ def eulerRadToDeg(eul):
 
     return ret
 
-mtx4_identity = Mathutils.Matrix()
+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]
@@ -333,7 +333,7 @@ def write(filename, batch_objects = None, \
         EXP_CAMERA =                           True,
         EXP_EMPTY =                                    True,
         EXP_IMAGE_COPY =                       False,
-        GLOBAL_MATRIX =                                Mathutils.Matrix(),
+        GLOBAL_MATRIX =                                mathutils.Matrix(),
         ANIM_ENABLE =                          True,
         ANIM_OPTIMIZE =                                True,
         ANIM_OPTIMIZE_PRECISSION =     6,
@@ -600,8 +600,8 @@ def write(filename, batch_objects = None, \
                 matrix_rot = matrix_rot * mtx_x90
             elif type =='CAMERA':
 #                      elif ob and type =='Camera':
-                y = matrix_rot * Mathutils.Vector(0,1,0)
-                matrix_rot = Mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
+                y = matrix_rot * mathutils.Vector(0,1,0)
+                matrix_rot = mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
 
             return matrix_rot
 
@@ -702,8 +702,8 @@ def write(filename, batch_objects = None, \
                     matrix_rot = matrix_rot * mtx_x90
                     rot = tuple(matrix_rot.to_euler())
                 elif ob and ob.type =='Camera':
-                    y = matrix_rot * Mathutils.Vector(0,1,0)
-                    matrix_rot = Mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
+                    y = matrix_rot * mathutils.Vector(0,1,0)
+                    matrix_rot = mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
                     rot = tuple(matrix_rot.to_euler())
                 else:
                     rot = tuple(matrix_rot.to_euler())
@@ -1088,8 +1088,8 @@ def write(filename, batch_objects = None, \
         file.write('\n\t\tTypeFlags: "Camera"')
         file.write('\n\t\tGeometryVersion: 124')
         file.write('\n\t\tPosition: %.6f,%.6f,%.6f' % loc)
-        file.write('\n\t\tUp: %.6f,%.6f,%.6f' % tuple(matrix_rot * Mathutils.Vector(0,1,0)) )
-        file.write('\n\t\tLookAt: %.6f,%.6f,%.6f' % tuple(matrix_rot * Mathutils.Vector(0,0,-1)) )
+        file.write('\n\t\tUp: %.6f,%.6f,%.6f' % tuple(matrix_rot * mathutils.Vector(0,1,0)) )
+        file.write('\n\t\tLookAt: %.6f,%.6f,%.6f' % tuple(matrix_rot * mathutils.Vector(0,0,-1)) )
 
         #file.write('\n\t\tUp: 0,0,0' )
         #file.write('\n\t\tLookAt: 0,0,0' )
index 6523ce8b46688668a5cd42d394be3f9e6bb34673..578813db2c62535f9d9339af584df5f48c1fd929 100644 (file)
@@ -48,7 +48,7 @@ Be sure not to use modifiers that change the number or order of verts in the mes
 # ***** END GPL LICENCE BLOCK *****
 
 import bpy
-import Mathutils
+import mathutils
 from struct import pack
 
 
@@ -87,7 +87,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
     me = ob.create_mesh(sce, True, 'PREVIEW')
 
     #Flip y and z
-    mat_flip = Mathutils.Matrix(\
+    mat_flip = mathutils.Matrix(\
     [1.0, 0.0, 0.0, 0.0],\
     [0.0, 0.0, 1.0, 0.0],\
     [0.0, 1.0, 0.0, 0.0],\
index c87a2af67c60cf4f5cd7c80672fb22bdb7018715..2d09844e5928cac6f07c0cadda31d25ba70719d4 100644 (file)
@@ -47,7 +47,7 @@ import time
 import shutil
 
 import bpy
-import Mathutils
+import mathutils
 
 
 # Returns a tuple - path,extension.
@@ -221,7 +221,7 @@ def write_nurb(file, ob, ob_mat):
     cu = ob.data
 
     # use negative indices
-    Vector = Blender.Mathutils.Vector
+    Vector = Blender.mathutils.Vector
     for nu in cu:
 
         if nu.type==0:         DEG_ORDER_U = 1
@@ -370,7 +370,7 @@ def write(filename, objects, scene,
         file.write('mtllib %s\n' % ( mtlfilename.split('\\')[-1].split('/')[-1] ))
 
     if EXPORT_ROTX90:
-        mat_xrot90= Mathutils.RotationMatrix(-math.pi/2, 4, 'X')
+        mat_xrot90= mathutils.RotationMatrix(-math.pi/2, 4, 'X')
 
     # Initialize totals, these are updated each object
     totverts = totuvco = totno = 1
index e5c3213ee94edf11f97fb4e2a28597cde3a1e279..619c0b3d373530708bf61984339f1d08b0f3f251 100644 (file)
@@ -69,7 +69,7 @@ import math
 import os
 
 import bpy
-import Mathutils
+import mathutils
 
 from export_3ds import create_derived_objects, free_derived_objects
 
@@ -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
index e6142a2db8a3655e4cd32b9d5e4a44e2dc29ef4f..b1020d14b127753d5dbf35d5255808ddae1851e8 100644 (file)
@@ -22,8 +22,8 @@ import math
 from math import radians
 
 import bpy
-import Mathutils
-from Mathutils import Vector, Euler, Matrix, RotationMatrix, TranslationMatrix
+import mathutils
+from mathutils import Vector, Euler, Matrix, RotationMatrix, TranslationMatrix
 
 
 class bvh_node_class(object):
index 19bb734028b9cebd5012d5d7f23f29845270c20e..ca7ef774a7240bd769a41f0268bd7433a38790c0 100644 (file)
@@ -144,7 +144,7 @@ import struct
 from import_scene_obj import unpack_face_list, load_image
 
 import bpy
-import Mathutils
+import mathutils
 
 BOUNDS_3DS = []
 
@@ -310,8 +310,8 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
     contextObName = None
     contextLamp = [None, None] # object, Data
     contextMaterial = None
-    contextMatrix_rot = None # Blender.Mathutils.Matrix(); contextMatrix.identity()
-    #contextMatrix_tx = None # Blender.Mathutils.Matrix(); contextMatrix.identity()
+    contextMatrix_rot = None # Blender.mathutils.Matrix(); contextMatrix.identity()
+    #contextMatrix_tx = None # Blender.mathutils.Matrix(); contextMatrix.identity()
     contextMesh_vertls = None
     contextMesh_facels = None
     contextMeshMaterials = {} # matname:[face_idxs]
@@ -722,7 +722,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
             def getuv():
                 temp_data = file.read(STRUCT_SIZE_2FLOAT)
                 new_chunk.bytes_read += STRUCT_SIZE_2FLOAT #2 float x 4 bytes each
-                return Mathutils.Vector( struct.unpack('<2f', temp_data) )
+                return mathutils.Vector( struct.unpack('<2f', temp_data) )
 
             contextMeshUV = [ getuv() for i in range(num_uv) ]
 
@@ -732,7 +732,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
             data = list( struct.unpack('<ffffffffffff', temp_data)  )
             new_chunk.bytes_read += STRUCT_SIZE_4x3MAT
 
-            contextMatrix_rot = Mathutils.Matrix(\
+            contextMatrix_rot = mathutils.Matrix(\
              data[:3] + [0],\
              data[3:6] + [0],\
              data[6:9] + [0],\
@@ -740,7 +740,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
 
 
             '''
-            contextMatrix_rot = Blender.Mathutils.Matrix(\
+            contextMatrix_rot = Blender.mathutils.Matrix(\
              data[:3] + [0],\
              data[3:6] + [0],\
              data[6:9] + [0],\
@@ -748,14 +748,14 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
             '''
 
             '''
-            contextMatrix_rot = Blender.Mathutils.Matrix(\
+            contextMatrix_rot = Blender.mathutils.Matrix(\
              data[:3] ,\
              data[3:6],\
              data[6:9])
             '''
 
             '''
-            contextMatrix_rot = Blender.Mathutils.Matrix()
+            contextMatrix_rot = Blender.mathutils.Matrix()
             m = 0
             for j in xrange(4):
                 for i in xrange(3):
@@ -773,7 +773,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
             #print contextMatrix_rot
             contextMatrix_rot.invert()
             #print contextMatrix_rot
-            #contextMatrix_tx = Blender.Mathutils.TranslationMatrix(0.5 * Blender.Mathutils.Vector(data[9:]))
+            #contextMatrix_tx = Blender.mathutils.TranslationMatrix(0.5 * Blender.mathutils.Vector(data[9:]))
             #contextMatrix_tx.invert()
 
             #tx.invert()
@@ -946,8 +946,8 @@ def load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
                 SCALE/=10
 
             # SCALE Matrix
-            SCALE_MAT = Mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
-#                      SCALE_MAT = Blender.Mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
+            SCALE_MAT = mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
+#                      SCALE_MAT = Blender.mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
 
             for ob in importedObjects:
                 ob.setMatrix(ob.matrixWorld * SCALE_MAT)
index 9a147b06b07eac015ad2bcaa9fc546423040e27f..736c8fa91c1bfc762e02bc5c12f57ae53728d899 100644 (file)
@@ -54,8 +54,8 @@ Note, This loads mesh objects and materials only, nurbs and curves are not suppo
 import os
 import time
 import bpy
-import Mathutils
-import Geometry
+import mathutils
+from geometry import PolyFill
 
 # from Blender import Mesh, Draw, Window, Texture, Material, sys
 # # import BPyMesh
@@ -127,7 +127,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
     if not set: # Need sets for this, otherwise do a normal fill.
         PREF_FIX_LOOPS= False
 
-    Vector= Mathutils.Vector
+    Vector= mathutils.Vector
     if not indices:
         return []
 
@@ -158,7 +158,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
             if verts[i][1]==verts[i-1][0]:
                 verts.pop(i-1)
 
-        fill= Geometry.PolyFill([verts])
+        fill= PolyFill([verts])
 
     else:
         '''
@@ -266,7 +266,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
                     vert_map[i+ii]= vert[2]
                 ii+=len(verts)
 
-        fill= Geometry.PolyFill([ [v[0] for v in loop] for loop in loop_list ])
+        fill= PolyFill([ [v[0] for v in loop] for loop in loop_list ])
         #draw_loops(loop_list)
         #raise 'done loop'
         # map to original indicies
index 16fac74b9d0f47d52193ed3028c80da0f56c776b..9f066677e5d76c25156e58b23536f8d799e7a5f1 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 from _bpy import types as bpy_types
-from Mathutils import Vector
+from mathutils import Vector
 
 StructRNA = bpy_types.Struct.__bases__[0]
 # StructRNA = bpy_types.Struct
@@ -236,7 +236,7 @@ class EditBone(StructRNA, _GenericBone):
         Transform the the bones head, tail, roll and envalope (when the matrix has a scale component).
         Expects a 4x4 or 3x3 matrix.
         """
-        from Mathutils import Vector
+        from mathutils import Vector
         z_vec = self.matrix.rotation_part() * Vector(0.0, 0.0, 1.0)
         self.tail = matrix * self.tail
         self.head = matrix * self.head
index ee6cc934c1b2aa4863196ec4c3d68a9724b48d39..8a9894c43800ca369372cbe130d71b0a4e420342 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from Mathutils import Vector
+from mathutils import Vector
 
 # TODO, have these in a more general module
 from rna_prop_ui import rna_idprop_ui_prop_get
index 8568db66e5aeee01fb5936b70d1d0579f8c440f1..b75b26b5f2f79f02ac6d88ed0b3e8c2869bf4d6c 100644 (file)
@@ -23,7 +23,7 @@ from math import radians, pi
 from rigify import RigifyError, ORG_PREFIX
 from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, add_stretch_to, blend_bone_list, get_side_name, get_base_name
 from rna_prop_ui import rna_idprop_ui_prop_get
-from Mathutils import Vector
+from mathutils import Vector
 
 METARIG_NAMES = "shoulder", "arm", "forearm", "hand"
 
index 90e309bbc387e6514cb113007054abe9098aa7a9..20bb08f39a89d91e654ac86dce6f34cd5a14aa6b 100644 (file)
@@ -20,7 +20,7 @@
 
 import bpy
 from rna_prop_ui import rna_idprop_ui_prop_get
-from Mathutils import Vector
+from mathutils import Vector
 from rigify import RigifyError
 from rigify_utils import copy_bone_simple
 
index dd9c953e97d90507fce194191d30b14d5f46aae6..30492e4e138cdc1aefbcd1c1eb769484b2c078d2 100644 (file)
@@ -21,7 +21,7 @@
 import bpy
 from rna_prop_ui import rna_idprop_ui_prop_get
 from math import acos
-from Mathutils import Vector
+from mathutils import Vector
 from rigify import RigifyError
 from rigify_utils import copy_bone_simple
 
index 862d44b653fd458999f0794b729185417945ef8d..2ea217847d7a35200f78b83184800989d7a54684 100644 (file)
@@ -279,7 +279,7 @@ def ik(obj, bone_definition, base_names, options):
 
 
 def fk(obj, bone_definition, base_names, options):
-    from Mathutils import Vector
+    from mathutils import Vector
     arm = obj.data
 
     # these account for all bones in METARIG_NAMES
index 701fe295aac95a05b04db50c759538917c560f27..3ee9065af6136fd80dfbfc826b56ce7356c37c8b 100644 (file)
@@ -23,7 +23,7 @@ from rna_prop_ui import rna_idprop_ui_prop_get
 from math import pi
 from rigify import RigifyError
 from rigify_utils import bone_class_instance, copy_bone_simple, get_side_name, get_base_name
-from Mathutils import Vector
+from mathutils import Vector
 
 METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe"
 
index da03eb94b23738afe07e9d7c6e39c6e694f60995..9d36c60eede362c6fcabfbfd28885238ecccbc1a 100644 (file)
@@ -21,7 +21,7 @@
 import bpy
 from rna_prop_ui import rna_idprop_ui_prop_get
 from math import acos, pi
-from Mathutils import Vector
+from mathutils import Vector
 from rigify import RigifyError
 from rigify_utils import copy_bone_simple
 
index 747e8397710b45d5436e4aeb439e60191aa453c7..7d220663256a5f9bf76b6c91dc11f20423ea0d52 100644 (file)
@@ -119,7 +119,7 @@ def deform(obj, definitions, base_names, options):
 
 
 def main(obj, bone_definition, base_names, options):
-    from Mathutils import Vector
+    from mathutils import Vector
 
     arm = obj.data
     eb = obj.data.edit_bones
index 555645ecd2ae016e787be14c8cb29285a3e6f6b6..514d443a1f92e5fa48cce2ac83c91fb2e668fdd3 100644 (file)
@@ -125,7 +125,7 @@ def deform(obj, definitions, base_names, options):
 
 
 def main(obj, bone_definition, base_names, options):
-    from Mathutils import Vector
+    from mathutils import Vector
 
     arm = obj.data
 
index 165bffad950c878cbcd2e23852cff76a1b7f0a5e..ed656cf224341cad5d30301a96457ce8a2592005 100644 (file)
@@ -248,7 +248,7 @@ 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
+        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
index d67c066cdd5b3fb30dca1050b62fc88d7331acf1..025074490cb3cf9f77912bf08f3fe4509bad137d 100644 (file)
@@ -147,7 +147,7 @@ def deform(obj, definitions, base_names, options):
 
 
 def main(obj, bone_definition, base_names, options):
-    from Mathutils import Vector, RotationMatrix
+    from mathutils import Vector, RotationMatrix
     from math import radians, pi
 
     arm = obj.data
index 65d5c1d34dccacd313894955d64bc5c55555f285..76eaf6dd4d9b1f24084d3da21e37a81297720215 100644 (file)
@@ -22,7 +22,7 @@ import bpy
 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, RotationMatrix
 from math import radians, pi
 
 # not used, defined for completeness
index 5e2193095034abfb60cf20804d13053365d1f3f4..43a8c2125ce61545e8b109c61c2c42f92e8b75df 100644 (file)
@@ -128,7 +128,7 @@ def deform(obj, definitions, base_names, options):
 
 # TODO: rename all of the head/neck references to tongue
 def main(obj, bone_definition, base_names, options):
-    from Mathutils import Vector
+    from mathutils import Vector
 
     arm = obj.data
 
index 6ed97ce0bf06a54f66ca34b1f57025b596574551..1d5768e7f22bc219eed7cfdc4bd71db4f13dfc5c 100644 (file)
@@ -26,7 +26,7 @@
 # that a generic function would need to check for.
 
 import bpy
-from Mathutils import Vector
+from mathutils import Vector
 from rna_prop_ui import rna_idprop_ui_prop_get
 
 DELIMITER = '-._'
index b00b735d16d7784b44336b677e863e83b84f6df6..164bbfb100bea7252226bc246a48c3984ea5ba9e 100644 (file)
@@ -18,7 +18,7 @@
 
 # <pep8-80 compliant>
 import bpy
-import Mathutils
+import mathutils
 from math import cos, sin, pi
 
 # could this be stored elsewhere?
index 601cc712dda9e62218de87d77e2ed219b1b1123e..183a122f513870e8926f9fa9213d5f3eedb89193 100644 (file)
 
 # <pep8 compliant>
 import bpy
-import Mathutils
+import mathutils
 from math import cos, sin, pi
 
 
 def add_torus(major_rad, minor_rad, major_seg, minor_seg):
-    Vector = Mathutils.Vector
-    Quaternion = Mathutils.Quaternion
+    Vector = mathutils.Vector
+    Quaternion = mathutils.Quaternion
 
     PI_2 = pi * 2
     z_axis = (0, 0, 1)
index a9fa90ee6fa87d94e956e9155ddee5c7e160b819..6a235e118ce196510882e503034966c1609acb70 100644 (file)
@@ -190,7 +190,7 @@ def banner(context):
     add_scrollback("Execute:          Enter", 'OUTPUT')
     add_scrollback("Autocomplete:     Ctrl+Space", 'OUTPUT')
     add_scrollback("Ctrl +/-  Wheel:  Zoom", 'OUTPUT')
-    add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, Mathutils, Geometry", 'OUTPUT')
+    add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, mathutils, Geometry", 'OUTPUT')
     add_scrollback("", 'OUTPUT')
     add_scrollback("  WARNING!!! Blender 2.5 API is subject to change, see API reference for more info.", 'ERROR')
     add_scrollback("", 'OUTPUT')
index 1c9e9a7331243d76a828f22ca2aa86213d468681..bba4576ef7312538bc20963a4263d95e170d973a 100644 (file)
@@ -1,6 +1,6 @@
 from math import *
 import bpy
-from Mathutils import *
+from mathutils import *
 
 def main(context):
     def cleanupEulCurve(fcv):
index 3989e51b6ca3ff1d21ecbeb83877b3b8bf443d58..78ca9a18cdcc99d6244989155acc36ded9ef089b 100644 (file)
@@ -76,7 +76,7 @@ class MeshMirrorUV(bpy.types.Operator):
     def execute(self, context):
         DIR = 1 # TODO, make an option
 
-        from Mathutils import Vector
+        from mathutils import Vector
 
         ob = context.active_object
         is_editmode = (ob.mode == 'EDIT')
index 062d699ab887cc52d5c0021d19154a0cd305cee1..8f775c6040a7c22636730579315dfaf951242f35 100644 (file)
@@ -22,7 +22,7 @@ import bpy
 
 
 def pose_info():
-    from Mathutils import Matrix
+    from mathutils import Matrix
 
     info = {}
 
index 026d4409272d7e478cb1e6b0b365eca865a06848..0b8970ce7989f0e3fa8ca76eca5a43d00152eeb4 100644 (file)
@@ -235,8 +235,8 @@ class ShapeTransfer(bpy.types.Operator):
             ob.active_shape_key_index = len(me.shape_keys.keys) - 1
             ob.shape_key_lock = True
 
-        from Geometry import BarycentricTransform
-        from Mathutils import Vector
+        from geometry import BarycentricTransform
+        from mathutils import Vector
 
         if use_clamp and mode == 'OFFSET':
             use_clamp = False
@@ -452,7 +452,7 @@ class MakeDupliFace(bpy.types.Operator):
         return (obj and obj.type == 'MESH')
 
     def _main(self, context):
-        from Mathutils import Vector
+        from mathutils import Vector
         from math import sqrt
 
         SCALE_FAC = 0.01
index c5fcc3d2a324a5adda451602ab83e8f5d32af92c..8c0933b25181fd00db7e54337e2dc1e766c3f9ed 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from Mathutils import Vector
+from mathutils import Vector
 
 
 def align_objects(align_x, align_y, align_z, align_mode, relative_to):
index 3d3feb6642425623b931df50f6f00c9377547d21..857f6d6c620271cf6bcf8b3a8459526049ebd69b 100644 (file)
@@ -25,7 +25,7 @@ def randomize_selected(seed, loc, rot, scale, scale_even, scale_min):
 
     import random
     from random import uniform
-    from Mathutils import Vector
+    from mathutils import Vector
 
     random.seed(seed)
 
index c88faae2818572cfbb9a61be7fd9fb641e07be7a..230f2863a7ff362879314b0bc20add4caa580685 100644 (file)
 
 # <pep8 compliant>
 
-#from Blender import Object, Draw, Window, sys, Mesh, Geometry
-from Mathutils import Matrix, Vector, RotationMatrix
+from mathutils import Matrix, Vector, RotationMatrix
 import time
-import Geometry
+import geometry
 import bpy
 from math import cos, radians
 
@@ -227,7 +226,7 @@ def islandIntersectUvIsland(source, target, SourceOffset):
     # Edge intersect test
     for ed in edgeLoopsSource:
         for seg in edgeLoopsTarget:
-            i = Geometry.LineIntersect2D(\
+            i = geometry.LineIntersect2D(\
             seg[0], seg[1], SourceOffset+ed[0], SourceOffset+ed[1])
             if i:
                 return 1 # LINE INTERSECTION
@@ -741,7 +740,7 @@ def packIslands(islandList):
 #XXX   Window.DrawProgressBar(0.7, 'Packing %i UV Islands...' % len(packBoxes) )
 
     time1 = time.time()
-    packWidth, packHeight = Geometry.BoxPack2D(packBoxes)
+    packWidth, packHeight = geometry.BoxPack2D(packBoxes)
 
     # print 'Box Packing Time:', time.time() - time1
 
@@ -1056,7 +1055,7 @@ def main(context, island_margin, projection_limit):
             for f in faceProjectionGroupList[i]:
                 f_uv = f.uv
                 for j, v in enumerate(f.v):
-                    # XXX - note, between Mathutils in 2.4 and 2.5 the order changed.
+                    # XXX - note, between mathutils in 2.4 and 2.5 the order changed.
                     f_uv[j][:] = (v.co * MatProj)[:2]
 
 
index f2c2d5bd864057ea3fe00a2e8707293616f1c1f3..0b0d70c5e560155a0f6f01b6441bbd3ae7167aca 100644 (file)
@@ -34,7 +34,7 @@ import bpy
 import math
 import time
 
-from Mathutils import Vector
+from mathutils import Vector
 from bpy.props import *
 
 
index b4eac81b4925355d2d4a00732087115042ba6fef..b31d5d95987f2996b73fc3d63d507c0ceb72a4ac 100644 (file)
@@ -7,7 +7,7 @@
 # import GameKeys
 
 # support for Vector(), Matrix() types and advanced functions like ScaleMatrix(...) and RotationMatrix(...)
-# import Mathutils
+# import mathutils
 
 # for functions like getWindowWidth(), getWindowHeight()
 # import Rasterizer
index 237cd8c3443d877061cdf72c78c6f68bc8afc3ce..717c147b215ed80ddb0187bae58e35346f929cef 100644 (file)
@@ -101,7 +101,7 @@ def PolyFill(polylines):
 
        The example below creates 2 polylines and fills them in with faces, then makes a mesh in the current scene::
                import Blender
-               Vector= Blender.Mathutils.Vector
+               Vector= Blender.mathutils.Vector
 
                # Outline of 5 points
                polyline1= [Vector(-2.0, 1.0, 1.0), Vector(-1.0, 2.0, 1.0), Vector(1.0, 2.0, 1.0), Vector(1.0, -1.0, 1.0), Vector(-1.0, -1.0, 1.0)]
index b1bb039debe06db0fbcd199ff748f89aaf7e6d5d..17a227f729a6dd1697ee139157db2a4eb02c1249 100644 (file)
@@ -1,4 +1,4 @@
-# Blender.Mathutils module and its subtypes
+# Blender.mathutils module and its subtypes
 
 
 
diff --git a/source/blender/python/doc/examples/Mathutils.Euler.py b/source/blender/python/doc/examples/Mathutils.Euler.py
deleted file mode 100644 (file)
index 0e7a621..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-import Mathutils
-
-# todo
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/Mathutils.Matrix.py b/source/blender/python/doc/examples/Mathutils.Matrix.py
deleted file mode 100644 (file)
index 0e7a621..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-import Mathutils
-
-# todo
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/Mathutils.Quaternion.py b/source/blender/python/doc/examples/Mathutils.Quaternion.py
deleted file mode 100644 (file)
index 0e7a621..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-import Mathutils
-
-# todo
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/Mathutils.py b/source/blender/python/doc/examples/Mathutils.py
deleted file mode 100644 (file)
index a00ca3d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-import Mathutils
-
-vec = Mathutils.Vector(1.0, 2.0, 3.0)
-
-mat_rot = Mathutils.RotationMatrix(90, 4, 'X')
-mat_trans = Mathutils.TranslationMatrix(vec)
-
-mat = mat_trans * mat_rot
-mat.invert()
-
-mat3 = mat.rotation_part()
-quat1 = mat.to_quat()
-quat2 = mat3.to_quat()
-
-angle = quat1.difference(quat2)
-
-print(angle)
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/mathutils.Euler.py b/source/blender/python/doc/examples/mathutils.Euler.py
new file mode 100644 (file)
index 0000000..f8294ce
--- /dev/null
@@ -0,0 +1,3 @@
+import mathutils
+
+# todo
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/mathutils.Matrix.py b/source/blender/python/doc/examples/mathutils.Matrix.py
new file mode 100644 (file)
index 0000000..f8294ce
--- /dev/null
@@ -0,0 +1,3 @@
+import mathutils
+
+# todo
\ No newline at end of file
diff --git a/source/blender/python/doc/examples/mathutils.Quaternion.py b/source/blender/python/doc/examples/mathutils.Quaternion.py
new file mode 100644 (file)
index 0000000..f8294ce
--- /dev/null
@@ -0,0 +1,3 @@
+import mathutils
+
+# todo
\ No newline at end of file
similarity index 80%
rename from source/blender/python/doc/examples/Mathutils.Vector.py
rename to source/blender/python/doc/examples/mathutils.Vector.py
index 8b3dbfa5ee87776155c34be0e47a10bea564d666..143ad234416b0b8ed61af97ce8f62449bc207865 100644 (file)
@@ -1,20 +1,20 @@
-import Mathutils
+import mathutils
 
 # zero length vector
-vec = Mathutils.Vector(0, 0, 1)
+vec = mathutils.Vector(0, 0, 1)
 
 # unit length vector
 vec_a = vec.copy().normalize()
 
-vec_b = Mathutils.Vector(0, 1, 2)
+vec_b = mathutils.Vector(0, 1, 2)
 
-vec2d = Mathutils.Vector(1, 2)
-vec3d = Mathutils.Vector([1, 0, 0])
+vec2d = mathutils.Vector(1, 2)
+vec3d = mathutils.Vector([1, 0, 0])
 vec4d = vec_a.copy().resize4D()
 
 # other mathutuls types
-quat = Mathutils.Quaternion()
-matrix = Mathutils.Matrix()
+quat = mathutils.Quaternion()
+matrix = mathutils.Matrix()
 
 # Comparison operators can be done on Vector classes:
 
diff --git a/source/blender/python/doc/examples/mathutils.py b/source/blender/python/doc/examples/mathutils.py
new file mode 100644 (file)
index 0000000..dee8fa4
--- /dev/null
@@ -0,0 +1,17 @@
+import mathutils
+
+vec = mathutils.Vector(1.0, 2.0, 3.0)
+
+mat_rot = mathutils.RotationMatrix(90, 4, 'X')
+mat_trans = mathutils.TranslationMatrix(vec)
+
+mat = mat_trans * mat_rot
+mat.invert()
+
+mat3 = mat.rotation_part()
+quat1 = mat.to_quat()
+quat2 = mat3.to_quat()
+
+angle = quat1.difference(quat2)
+
+print(angle)
\ No newline at end of file
index 7a55a488c92276c8197f60003216fea4d097d0d3..67cd462b3c1f0b17cfb6e6d94aa96cd332d3bdab 100644 (file)
@@ -318,7 +318,7 @@ def rna2sphinx(BASEPATH):
     fw("   These parts of the API are relatively stable and are unlikely to change significantly\n")
     fw("      * data API, access to attributes of blender data such as mesh verts, material color, timeline frames and scene objects\n")
     fw("      * user interface functions for defining buttons, creation of menus, headers, panels\n")
-    fw("      * modules: bgl, Mathutils and Geometry\n")
+    fw("      * modules: bgl, mathutils and geometry\n")
     fw("\n")
     fw(".. toctree::\n")
     fw("   :maxdepth: 1\n\n")
@@ -332,7 +332,7 @@ def rna2sphinx(BASEPATH):
     # C modules
     fw("   bpy.props.rst\n\n")
     
-    fw("   Mathutils.rst\n\n")
+    fw("   mathutils.rst\n\n")
     fw("   blf.rst\n\n")
     file.close()
 
@@ -371,8 +371,8 @@ def rna2sphinx(BASEPATH):
     from bpy import props as module
     pymodule2sphinx(BASEPATH, "bpy.props", module, "Property Definitions (bpy.props)")
     
-    import Mathutils as module
-    pymodule2sphinx(BASEPATH, "Mathutils", module, "Math Types & Utilities (Mathutils)")
+    import mathutils as module
+    pymodule2sphinx(BASEPATH, "mathutils", module, "Math Types & Utilities (mathutils)")
     del module
 
     import blf as module
index 5ba2d7f7a7429f1cb1e3321bf6807102d5765a21..18907bb3012478ee3745eef3185c96503f1ea26b 100644 (file)
@@ -44,7 +44,7 @@
 
 
 /*-------------------------DOC STRINGS ---------------------------*/
-static char M_Geometry_doc[] = "The Blender Geometry module\n\n";
+static char M_Geometry_doc[] = "The Blender geometry module\n\n";
 static char M_Geometry_Intersect_doc[] = "(v1, v2, v3, ray, orig, clip=1) - returns the intersection between a ray and a triangle, if possible, returns None otherwise";
 static char M_Geometry_TriangleArea_doc[] = "(v1, v2, v3) - returns the area size of the 2D or 3D triangle defined";
 static char M_Geometry_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
@@ -59,7 +59,7 @@ static char M_Geometry_BoxPack2D_doc[] = "";
 static char M_Geometry_BezierInterp_doc[] = "";
 
 //---------------------------------INTERSECTION FUNCTIONS--------------------
-//----------------------------------Mathutils.Intersect() -------------------
+//----------------------------------geometry.Intersect() -------------------
 static PyObject *M_Geometry_Intersect( PyObject * self, PyObject * args )
 {
        VectorObject *ray, *ray_off, *vec1, *vec2, *vec3;
@@ -131,7 +131,7 @@ static PyObject *M_Geometry_Intersect( PyObject * self, PyObject * args )
 
        return newVectorObject(pvec, 3, Py_NEW, NULL);
 }
-//----------------------------------Mathutils.LineIntersect() -------------------
+//----------------------------------geometry.LineIntersect() -------------------
 /* Line-Line intersection using algorithm from mathworld.wolfram.com */
 static PyObject *M_Geometry_LineIntersect( PyObject * self, PyObject * args )
 {
@@ -200,7 +200,7 @@ static PyObject *M_Geometry_LineIntersect( PyObject * self, PyObject * args )
 
 
 //---------------------------------NORMALS FUNCTIONS--------------------
-//----------------------------------Mathutils.QuadNormal() -------------------
+//----------------------------------geometry.QuadNormal() -------------------
 static PyObject *M_Geometry_QuadNormal( PyObject * self, PyObject * args )
 {
        VectorObject *vec1;
@@ -251,7 +251,7 @@ static PyObject *M_Geometry_QuadNormal( PyObject * self, PyObject * args )
        return newVectorObject(n1, 3, Py_NEW, NULL);
 }
 
-//----------------------------Mathutils.TriangleNormal() -------------------
+//----------------------------geometry.TriangleNormal() -------------------
 static PyObject *M_Geometry_TriangleNormal( PyObject * self, PyObject * args )
 {
        VectorObject *vec1, *vec2, *vec3;
@@ -288,7 +288,7 @@ static PyObject *M_Geometry_TriangleNormal( PyObject * self, PyObject * args )
 }
 
 //--------------------------------- AREA FUNCTIONS--------------------
-//----------------------------------Mathutils.TriangleArea() -------------------
+//----------------------------------geometry.TriangleArea() -------------------
 static PyObject *M_Geometry_TriangleArea( PyObject * self, PyObject * args )
 {
        VectorObject *vec1, *vec2, *vec3;
@@ -333,7 +333,7 @@ static PyObject *M_Geometry_TriangleArea( PyObject * self, PyObject * args )
        }
 }
 
-/*----------------------------------Geometry.PolyFill() -------------------*/
+/*----------------------------------geometry.PolyFill() -------------------*/
 /* PolyFill function, uses Blenders scanfill to fill multiple poly lines */
 static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
 {
@@ -363,7 +363,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
                if (!PySequence_Check(polyLine)) {
                        freedisplist(&dispbase);
                        Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/
-                       PyErr_SetString( PyExc_TypeError, "One or more of the polylines is not a sequence of Mathutils.Vector's" );
+                       PyErr_SetString( PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's" );
                        return NULL;
                }
                
@@ -373,7 +373,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
                        if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) {
                                freedisplist(&dispbase);
                                Py_DECREF(polyLine);
-                               PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a Mathutils.Vector type" );
+                               PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" );
                                return NULL;
                        }
 #endif
@@ -414,7 +414,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
        
        if(ls_error) {
                freedisplist(&dispbase); /* possible some dl was allocated */
-               PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a Mathutils.Vector type" );
+               PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" );
                return NULL;
        }
        else if (totpoints) {
@@ -428,7 +428,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq )
                tri_list= PyList_New(dl->parts);
                if( !tri_list ) {
                        freedisplist(&dispbase);
-                       PyErr_SetString( PyExc_RuntimeError, "Geometry.PolyFill failed to make a new list" );
+                       PyErr_SetString( PyExc_RuntimeError, "geometry.PolyFill failed to make a new list" );
                        return NULL;
                }
                
@@ -819,7 +819,7 @@ struct PyMethodDef M_Geometry_methods[] = {
 
 static struct PyModuleDef M_Geometry_module_def = {
        PyModuleDef_HEAD_INIT,
-       "Geometry",  /* m_name */
+       "geometry",  /* m_name */
        M_Geometry_doc,  /* m_doc */
        0,  /* m_size */
        M_Geometry_methods,  /* m_methods */
index 2a3912c1787409910ee1b66174ac8574d8755334..e1e1cd2ae69cb2b7ec8299ff60435e2102686324 100644 (file)
@@ -124,7 +124,7 @@ PyObject *quat_rotation(PyObject *arg1, PyObject *arg2)
 }
 
 //----------------------------------MATRIX FUNCTIONS--------------------
-//----------------------------------Mathutils.RotationMatrix() ----------
+//----------------------------------mathutils.RotationMatrix() ----------
 //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
 static char M_Mathutils_RotationMatrix_doc[] =
 ".. function:: RotationMatrix(angle, size, axis)\n"
@@ -150,14 +150,14 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
 
        if(!PyArg_ParseTuple(args, "fi|O", &angle, &matSize, &vec)) {
-               PyErr_SetString(PyExc_TypeError, "Mathutils.RotationMatrix(angle, size, axis): expected float int and a string or vector\n");
+               PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(angle, size, axis): expected float int and a string or vector\n");
                return NULL;
        }
 
        if(vec && !VectorObject_Check(vec)) {
                axis= _PyUnicode_AsString((PyObject *)vec);
                if(axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') {
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.RotationMatrix(): 3rd argument axis value must be a 3D vector or a string in 'X', 'Y', 'Z'\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(): 3rd argument axis value must be a 3D vector or a string in 'X', 'Y', 'Z'\n");
                        return NULL;
                }
                else {
@@ -172,20 +172,20 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
                angle-=(Py_PI*2);
        
        if(matSize != 2 && matSize != 3 && matSize != 4) {
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
                return NULL;
        }
        if(matSize == 2 && (vec != NULL)) {
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis\n");
                return NULL;
        }
        if((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) {
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices\n");
                return NULL;
        }
        if(vec) {
                if(vec->size != 3) {
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): the vector axis must be a 3D vector\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): the vector axis must be a 3D vector\n");
                        return NULL;
                }
                
@@ -228,7 +228,7 @@ static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args)
        }
        else {
                /* should never get here */
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): unknown error\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): unknown error\n");
                return NULL;
        }
 
@@ -263,11 +263,11 @@ static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * v
                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
        
        if(!VectorObject_Check(vec)) {
-               PyErr_SetString(PyExc_TypeError, "Mathutils.TranslationMatrix(): expected vector\n");
+               PyErr_SetString(PyExc_TypeError, "mathutils.TranslationMatrix(): expected vector\n");
                return NULL;
        }
        if(vec->size != 3 && vec->size != 4) {
-               PyErr_SetString(PyExc_TypeError, "Mathutils.TranslationMatrix(): vector must be 3D or 4D\n");
+               PyErr_SetString(PyExc_TypeError, "mathutils.TranslationMatrix(): vector must be 3D or 4D\n");
                return NULL;
        }
        
@@ -282,7 +282,7 @@ static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * v
 
        return newMatrixObject(mat, 4, 4, Py_NEW, NULL);
 }
-//----------------------------------Mathutils.ScaleMatrix() -------------
+//----------------------------------mathutils.ScaleMatrix() -------------
 //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
 static char M_Mathutils_ScaleMatrix_doc[] =
 ".. function:: ScaleMatrix(factor, size, axis)\n"
@@ -307,16 +307,16 @@ static PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args)
                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
 
        if(!PyArg_ParseTuple(args, "fi|O!", &factor, &matSize, &vector_Type, &vec)) {
-               PyErr_SetString(PyExc_TypeError, "Mathutils.ScaleMatrix(): expected float int and optional vector\n");
+               PyErr_SetString(PyExc_TypeError, "mathutils.ScaleMatrix(): expected float int and optional vector\n");
                return NULL;
        }
        if(matSize != 2 && matSize != 3 && matSize != 4) {
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.ScaleMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.ScaleMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
                return NULL;
        }
        if(vec) {
                if(vec->size > 2 && matSize == 2) {
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.ScaleMatrix(): please use 2D vectors when scaling in 2D\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.ScaleMatrix(): please use 2D vectors when scaling in 2D\n");
                        return NULL;
                }
                
@@ -373,7 +373,7 @@ static PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args)
        //pass to matrix creation
        return newMatrixObject(mat, matSize, matSize, Py_NEW, NULL);
 }
-//----------------------------------Mathutils.OrthoProjectionMatrix() ---
+//----------------------------------mathutils.OrthoProjectionMatrix() ---
 //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
 static char M_Mathutils_OrthoProjectionMatrix_doc[] =
 ".. function:: OrthoProjectionMatrix(plane, size, axis)\n"
@@ -398,16 +398,16 @@ static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * a
                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
        
        if(!PyArg_ParseTuple(args, "si|O!", &plane, &matSize, &vector_Type, &vec)) {
-               PyErr_SetString(PyExc_TypeError, "Mathutils.OrthoProjectionMatrix(): expected string and int and optional vector\n");
+               PyErr_SetString(PyExc_TypeError, "mathutils.OrthoProjectionMatrix(): expected string and int and optional vector\n");
                return NULL;
        }
        if(matSize != 2 && matSize != 3 && matSize != 4) {
-               PyErr_SetString(PyExc_AttributeError,"Mathutils.OrthoProjectionMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
+               PyErr_SetString(PyExc_AttributeError,"mathutils.OrthoProjectionMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
                return NULL;
        }
        if(vec) {
                if(vec->size > 2 && matSize == 2) {
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): please use 2D vectors when scaling in 2D\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): please use 2D vectors when scaling in 2D\n");
                        return NULL;
                }
                
@@ -430,7 +430,7 @@ static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * a
                        mat[4] = 1.0f;
                        mat[8] = 1.0f;
                } else {
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: X, Y, XY, XZ, YZ\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): unknown plane - expected: X, Y, XY, XZ, YZ\n");
                        return NULL;
                }
        } else { //arbitrary plane
@@ -458,7 +458,7 @@ static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * a
                        mat[7] = -(vec->vec[1] * vec->vec[2]);
                        mat[8] = 1 - (vec->vec[2] * vec->vec[2]);
                } else {
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: 'r' expected for axis designation\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): unknown plane - expected: 'r' expected for axis designation\n");
                        return NULL;
                }
        }
@@ -500,11 +500,11 @@ static PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args)
                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
 
        if(!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)) {
-               PyErr_SetString(PyExc_TypeError,"Mathutils.ShearMatrix(): expected string float and int\n");
+               PyErr_SetString(PyExc_TypeError,"mathutils.ShearMatrix(): expected string float and int\n");
                return NULL;
        }
        if(matSize != 2 && matSize != 3 && matSize != 4) {
-               PyErr_SetString(PyExc_AttributeError,"Mathutils.ShearMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
+               PyErr_SetString(PyExc_AttributeError,"mathutils.ShearMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n");
                return NULL;
        }
 
@@ -535,7 +535,7 @@ static PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args)
                mat[4] = 1.0f;
                mat[8] = 1.0f;
        } else {
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.ShearMatrix(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.ShearMatrix(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n");
                return NULL;
        }
        if(matSize == 4) {
@@ -683,7 +683,7 @@ struct PyMethodDef M_Mathutils_methods[] = {
 
 static struct PyModuleDef M_Mathutils_module_def = {
        PyModuleDef_HEAD_INIT,
-       "Mathutils",  /* m_name */
+       "mathutils",  /* m_name */
        M_Mathutils_doc,  /* m_doc */
        0,  /* m_size */
        M_Mathutils_methods,  /* m_methods */
@@ -705,7 +705,9 @@ PyObject *Mathutils_Init(void)
                return NULL;
        if( PyType_Ready( &quaternion_Type ) < 0 )
                return NULL;
-       
+       if( PyType_Ready( &color_Type ) < 0 )
+               return NULL;
+
        submodule = PyModule_Create(&M_Mathutils_module_def);
        PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule);
        
@@ -714,6 +716,7 @@ PyObject *Mathutils_Init(void)
        PyModule_AddObject( submodule, "Matrix",                (PyObject *)&matrix_Type );
        PyModule_AddObject( submodule, "Euler",                 (PyObject *)&euler_Type );
        PyModule_AddObject( submodule, "Quaternion",    (PyObject *)&quaternion_Type );
+       PyModule_AddObject( submodule, "Color",                 (PyObject *)&color_Type );
        
        mathutils_matrix_vector_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_vector_cb);
 
index 9457c254113a983fbe41c738e042514e6d3f1090..0e87f49e30c8834782dfb5c6c2ec7dcaf1bc4c68 100644 (file)
@@ -37,6 +37,7 @@
 #include "mathutils_matrix.h"
 #include "mathutils_quat.h"
 #include "mathutils_euler.h"
+#include "mathutils_color.h"
 
 /* Can cast different mathutils types to this, use for generic funcs */
 
diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c
new file mode 100644 (file)
index 0000000..f715ff5
--- /dev/null
@@ -0,0 +1,467 @@
+/*
+ * $Id: mathutils_color.c 28124 2010-04-11 12:05:27Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "mathutils.h"
+
+#include "BLI_math.h"
+#include "BKE_utildefines.h"
+
+//----------------------------------mathutils.Color() -------------------
+//makes a new color for you to play with
+static PyObject *Color_new(PyTypeObject * type, PyObject * args, PyObject * kwargs)
+{
+       PyObject *listObject = NULL;
+       int size, i;
+       float col[3];
+       PyObject *e;
+
+
+       size = PyTuple_GET_SIZE(args);
+       if (size == 1) {
+               listObject = PyTuple_GET_ITEM(args, 0);
+               if (PySequence_Check(listObject)) {
+                       size = PySequence_Length(listObject);
+               } else { // Single argument was not a sequence
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Color(): 3d numeric sequence expected\n");
+                       return NULL;
+               }
+       } else if (size == 0) {
+               //returns a new empty 3d color
+               return newColorObject(NULL, Py_NEW, NULL);
+       } else {
+               listObject = args;
+       }
+
+       if (size != 3) { // Invalid color size
+               PyErr_SetString(PyExc_AttributeError, "mathutils.Color(): 3d numeric sequence expected\n");
+               return NULL;
+       }
+
+       for (i=0; i<size; i++) {
+               e = PySequence_GetItem(listObject, i);
+               if (e == NULL) { // Failed to read sequence
+                       Py_DECREF(listObject);
+                       PyErr_SetString(PyExc_RuntimeError, "mathutils.Color(): 3d numeric sequence expected\n");
+                       return NULL;
+               }
+
+               col[i]= (float)PyFloat_AsDouble(e);
+               Py_DECREF(e);
+
+               if(col[i]==-1 && PyErr_Occurred()) { // parsed item is not a number
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Color(): 3d numeric sequence expected\n");
+                       return NULL;
+               }
+       }
+       return newColorObject(col, Py_NEW, NULL);
+}
+
+//-----------------------------METHODS----------------------------
+
+//----------------------------Color.rotate()-----------------------
+// return a copy of the color
+
+static char Color_copy_doc[] =
+".. function:: copy()\n"
+"\n"
+"   Returns a copy of this color.\n"
+"\n"
+"   :return: A copy of the color.\n"
+"   :rtype: :class:`Color`\n"
+"\n"
+"   .. note:: use this to get a copy of a wrapped color with no reference to the original data.\n";
+
+static PyObject *Color_copy(ColorObject * self, PyObject *args)
+{
+       if(!BaseMath_ReadCallback(self))
+               return NULL;
+
+       return newColorObject(self->col, Py_NEW, Py_TYPE(self));
+}
+
+//----------------------------print object (internal)--------------
+//print the object to screen
+static PyObject *Color_repr(ColorObject * self)
+{
+       char str[64];
+
+       if(!BaseMath_ReadCallback(self))
+               return NULL;
+
+       sprintf(str, "[%.6f, %.6f, %.6f](color)", self->col[0], self->col[1], self->col[2]);
+       return PyUnicode_FromString(str);
+}
+//------------------------tp_richcmpr
+//returns -1 execption, 0 false, 1 true
+static PyObject* Color_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
+{
+       ColorObject *colA = NULL, *colB = NULL;
+       int result = 0;
+
+       if(ColorObject_Check(objectA)) {
+               colA = (ColorObject*)objectA;
+               if(!BaseMath_ReadCallback(colA))
+                       return NULL;
+       }
+       if(ColorObject_Check(objectB)) {
+               colB = (ColorObject*)objectB;
+               if(!BaseMath_ReadCallback(colB))
+                       return NULL;
+       }
+
+       if (!colA || !colB){
+               if (comparison_type == Py_NE){
+                       Py_RETURN_TRUE;
+               }else{
+                       Py_RETURN_FALSE;
+               }
+       }
+       colA = (ColorObject*)objectA;
+       colB = (ColorObject*)objectB;
+
+       switch (comparison_type){
+               case Py_EQ:
+                       result = EXPP_VectorsAreEqual(colA->col, colB->col, 3, 1);
+                       break;
+               case Py_NE:
+                       result = !EXPP_VectorsAreEqual(colA->col, colB->col, 3, 1);
+                       break;
+               default:
+                       printf("The result of the comparison could not be evaluated");
+                       break;
+       }
+       if (result == 1){
+               Py_RETURN_TRUE;
+       }else{
+               Py_RETURN_FALSE;
+       }
+}
+
+//---------------------SEQUENCE PROTOCOLS------------------------
+//----------------------------len(object)------------------------
+//sequence length
+static int Color_len(ColorObject * self)
+{
+       return 3;
+}
+//----------------------------object[]---------------------------
+//sequence accessor (get)
+static PyObject *Color_item(ColorObject * self, int i)
+{
+       if(i<0) i= 3-i;
+
+       if(i < 0 || i >= 3) {
+               PyErr_SetString(PyExc_IndexError, "color[attribute]: array index out of range");
+               return NULL;
+       }
+
+       if(!BaseMath_ReadIndexCallback(self, i))
+               return NULL;
+
+       return PyFloat_FromDouble(self->col[i]);
+
+}
+//----------------------------object[]-------------------------
+//sequence accessor (set)
+static int Color_ass_item(ColorObject * self, int i, PyObject * value)
+{
+       float f = PyFloat_AsDouble(value);
+
+       if(f == -1 && PyErr_Occurred()) { // parsed item not a number
+               PyErr_SetString(PyExc_TypeError, "color[attribute] = x: argument not a number");
+               return -1;
+       }
+
+       if(i<0) i= 3-i;
+
+       if(i < 0 || i >= 3){
+               PyErr_SetString(PyExc_IndexError, "color[attribute] = x: array assignment index out of range\n");
+               return -1;
+       }
+
+       self->col[i] = f;
+
+       if(!BaseMath_WriteIndexCallback(self, i))
+               return -1;
+
+       return 0;
+}
+//----------------------------object[z:y]------------------------
+//sequence slice (get)
+static PyObject *Color_slice(ColorObject * self, int begin, int end)
+{
+       PyObject *list = NULL;
+       int count;
+
+       if(!BaseMath_ReadCallback(self))
+               return NULL;
+
+       CLAMP(begin, 0, 3);
+       if (end<0) end= 4+end;
+       CLAMP(end, 0, 3);
+       begin = MIN2(begin,end);
+
+       list = PyList_New(end - begin);
+       for(count = begin; count < end; count++) {
+               PyList_SetItem(list, count - begin,
+                               PyFloat_FromDouble(self->col[count]));
+       }
+
+       return list;
+}
+//----------------------------object[z:y]------------------------
+//sequence slice (set)
+static int Color_ass_slice(ColorObject * self, int begin, int end,
+                                PyObject * seq)
+{
+       int i, y, size = 0;
+       float col[3];
+       PyObject *e;
+
+       if(!BaseMath_ReadCallback(self))
+               return -1;
+
+       CLAMP(begin, 0, 3);
+       if (end<0) end= 4+end;
+       CLAMP(end, 0, 3);
+       begin = MIN2(begin,end);
+
+       size = PySequence_Length(seq);
+       if(size != (end - begin)){
+               PyErr_SetString(PyExc_TypeError, "color[begin:end] = []: size mismatch in slice assignment");
+               return -1;
+       }
+
+       for (i = 0; i < size; i++) {
+               e = PySequence_GetItem(seq, i);
+               if (e == NULL) { // Failed to read sequence
+                       PyErr_SetString(PyExc_RuntimeError, "color[begin:end] = []: unable to read sequence");
+                       return -1;
+               }
+
+               col[i] = (float)PyFloat_AsDouble(e);
+               Py_DECREF(e);
+
+               if(col[i]==-1 && PyErr_Occurred()) { // parsed item not a number
+                       PyErr_SetString(PyExc_TypeError, "color[begin:end] = []: sequence argument not a number");
+                       return -1;
+               }
+       }
+       //parsed well - now set in vector
+       for(y = 0; y < 3; y++){
+               self->col[begin + y] = col[y];
+       }
+
+       BaseMath_WriteCallback(self);
+       return 0;
+}
+//-----------------PROTCOL DECLARATIONS--------------------------
+static PySequenceMethods Color_SeqMethods = {
+       (lenfunc) Color_len,                                            /* sq_length */
+       (binaryfunc) 0,                                                         /* sq_concat */
+       (ssizeargfunc) 0,                                                               /* sq_repeat */
+       (ssizeargfunc) Color_item,                                      /* sq_item */
+       (ssizessizeargfunc) Color_slice,                                /* sq_slice */
+       (ssizeobjargproc) Color_ass_item,                               /* sq_ass_item */
+       (ssizessizeobjargproc) Color_ass_slice,                 /* sq_ass_slice */
+};
+
+
+/* color channel, vector.r/g/b */
+static PyObject *Color_getChannel( ColorObject * self, void *type )
+{
+       return Color_item(self, GET_INT_FROM_POINTER(type));
+}
+
+static int Color_setChannel(ColorObject * self, PyObject * value, void * type)
+{
+       return Color_ass_item(self, GET_INT_FROM_POINTER(type), value);
+}
+
+/* color channel (HSV), color.h/s/v */
+static PyObject *Color_getChannelHSV( ColorObject * self, void *type )
+{
+       float hsv[3];
+       int i= GET_INT_FROM_POINTER(type);
+
+       if(!BaseMath_ReadCallback(self))
+               return NULL;
+
+       rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
+
+       return PyFloat_FromDouble(hsv[i]);
+}
+
+static int Color_setChannelHSV(ColorObject * self, PyObject * value, void * type)
+{
+       float hsv[3];
+       int i= GET_INT_FROM_POINTER(type);
+       float f = PyFloat_AsDouble(value);
+
+       if(f == -1 && PyErr_Occurred()) {
+               PyErr_SetString(PyExc_TypeError, "color.h/s/v = value: argument not a number");
+               return -1;
+       }
+
+       if(!BaseMath_ReadCallback(self))
+               return -1;
+
+       rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
+       CLAMP(f, 0.0f, 1.0f);
+       hsv[i] = f;
+       hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
+
+       if(!BaseMath_WriteCallback(self))
+               return -1;
+
+       return 0;
+}
+
+/*****************************************************************************/
+/* Python attributes get/set structure:                                      */
+/*****************************************************************************/
+static PyGetSetDef Color_getseters[] = {
+       {"r", (getter)Color_getChannel, (setter)Color_setChannel, "Red color channel. **type** float", (void *)0},
+       {"g", (getter)Color_getChannel, (setter)Color_setChannel, "Green color channel. **type** float", (void *)1},
+       {"b", (getter)Color_getChannel, (setter)Color_setChannel, "Blue color channel. **type** float", (void *)2},
+
+       {"h", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, "HSV Hue component in [0, 1]. **type** float", (void *)0},
+       {"s", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, "HSV Saturation component in [0, 1]. **type** float", (void *)1},
+       {"v", (getter)Color_getChannelHSV, (setter)Color_setChannelHSV, "HSV Value component in [0, 1]. **type** float", (void *)2},
+
+       {"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
+       {"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
+       {NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
+};
+
+
+//-----------------------METHOD DEFINITIONS ----------------------
+static struct PyMethodDef Color_methods[] = {
+       {"__copy__", (PyCFunction) Color_copy, METH_VARARGS, Color_copy_doc},
+       {"copy", (PyCFunction) Color_copy, METH_VARARGS, Color_copy_doc},
+       {NULL, NULL, 0, NULL}
+};
+
+//------------------PY_OBECT DEFINITION--------------------------
+static char color_doc[] =
+"This object gives access to Colors in Blender.";
+
+PyTypeObject color_Type = {
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "color",                                                //tp_name
+       sizeof(ColorObject),                    //tp_basicsize
+       0,                                                              //tp_itemsize
+       (destructor)BaseMathObject_dealloc,             //tp_dealloc
+       0,                                                              //tp_print
+       0,                                                              //tp_getattr
+       0,                                                              //tp_setattr
+       0,                                                              //tp_compare
+       (reprfunc) Color_repr,                  //tp_repr
+       0,                              //tp_as_number
+       &Color_SeqMethods,                              //tp_as_sequence
+       0,                                                              //tp_as_mapping
+       0,                                                              //tp_hash
+       0,                                                              //tp_call
+       0,                                                              //tp_str
+       0,                                                              //tp_getattro
+       0,                                                              //tp_setattro
+       0,                                                              //tp_as_buffer
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, //tp_flags
+       color_doc, //tp_doc
+       0,                                                              //tp_traverse
+       0,                                                              //tp_clear
+       (richcmpfunc)Color_richcmpr,    //tp_richcompare
+       0,                                                              //tp_weaklistoffset
+       0,                                                              //tp_iter
+       0,                                                              //tp_iternext
+       Color_methods,                                  //tp_methods
+       0,                                                              //tp_members
+       Color_getseters,                                //tp_getset
+       0,                                                              //tp_base
+       0,                                                              //tp_dict
+       0,                                                              //tp_descr_get
+       0,                                                              //tp_descr_set
+       0,                                                              //tp_dictoffset
+       0,                                                              //tp_init
+       0,                                                              //tp_alloc
+       Color_new,                                              //tp_new
+       0,                                                              //tp_free
+       0,                                                              //tp_is_gc
+       0,                                                              //tp_bases
+       0,                                                              //tp_mro
+       0,                                                              //tp_cache
+       0,                                                              //tp_subclasses
+       0,                                                              //tp_weaklist
+       0                                                               //tp_del
+};
+//------------------------newColorObject (internal)-------------
+//creates a new color object
+/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
+ (i.e. it was allocated elsewhere by MEM_mallocN())
+  pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
+ (i.e. it must be created here with PyMEM_malloc())*/
+PyObject *newColorObject(float *col, int type, PyTypeObject *base_type)
+{
+       ColorObject *self;
+       int x;
+
+       if(base_type)   self = (ColorObject *)base_type->tp_alloc(base_type, 0);
+       else                    self = PyObject_NEW(ColorObject, &color_Type);
+
+       /* init callbacks as NULL */
+       self->cb_user= NULL;
+       self->cb_type= self->cb_subtype= 0;
+
+       if(type == Py_WRAP){
+               self->col = col;
+               self->wrapped = Py_WRAP;
+       }else if (type == Py_NEW){
+               self->col = PyMem_Malloc(3 * sizeof(float));
+               if(!col) { //new empty
+                       for(x = 0; x < 3; x++) {
+                               self->col[x] = 0.0f;
+                       }
+               }else{
+                       VECCOPY(self->col, col);
+               }
+               self->wrapped = Py_NEW;
+       }else{ //bad type
+               return NULL;
+       }
+
+       return (PyObject *)self;
+}
+
+PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
+{
+       ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL);
+       if(self) {
+               Py_INCREF(cb_user);
+               self->cb_user=                  cb_user;
+               self->cb_type=                  (unsigned char)cb_type;
+               self->cb_subtype=               (unsigned char)cb_subtype;
+       }
+
+       return (PyObject *)self;
+}
diff --git a/source/blender/python/generic/mathutils_color.h b/source/blender/python/generic/mathutils_color.h
new file mode 100644 (file)
index 0000000..bae08af
--- /dev/null
@@ -0,0 +1,59 @@
+/* 
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joseph Gilbert
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#ifndef EXPP_color_h
+#define EXPP_color_h
+
+#include <Python.h>
+
+extern PyTypeObject color_Type;
+#define ColorObject_Check(_v) PyObject_TypeCheck((_v), &color_Type)
+
+typedef struct {
+       PyObject_VAR_HEAD
+       float *col;                                     /*1D array of data */
+       PyObject *cb_user;                      /* if this vector references another object, otherwise NULL, *Note* this owns its reference */
+       unsigned char cb_type;          /* which user funcs do we adhere to, RNA, GameObject, etc */
+       unsigned char cb_subtype;       /* subtype: location, rotation... to avoid defining many new functions for every attribute of the same type */
+       unsigned char wrapped;          /* wrapped data type? */
+       /* end BaseMathObject */
+
+} ColorObject;
+
+/*struct data contains a pointer to the actual data that the
+object uses. It can use either PyMem allocated data (which will
+be stored in py_data) or be a wrapper for data allocated through
+blender (stored in blend_data). This is an either/or struct not both*/
+
+//prototypes
+PyObject *newColorObject( float *col, int type, PyTypeObject *base_type);
+PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype);
+
+#endif                         /* EXPP_color_h */
index e4759a57d22ece3ecfe099ec24e7473680f85f1c..04f80dd41160a6375315ede44988abb42f1560d2 100644 (file)
@@ -35,7 +35,7 @@
 #include "BLO_sys_types.h"
 #endif
 
-//----------------------------------Mathutils.Euler() -------------------
+//----------------------------------mathutils.Euler() -------------------
 //makes a new euler for you to play with
 static PyObject *Euler_new(PyTypeObject * type, PyObject * args, PyObject * kwargs)
 {
@@ -51,7 +51,7 @@ static PyObject *Euler_new(PyTypeObject * type, PyObject * args, PyObject * kwar
                if (PySequence_Check(listObject)) {
                        size = PySequence_Length(listObject);
                } else { // Single argument was not a sequence
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Euler(): 3d numeric sequence expected\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Euler(): 3d numeric sequence expected\n");
                        return NULL;
                }
        } else if (size == 0) {
@@ -62,7 +62,7 @@ static PyObject *Euler_new(PyTypeObject * type, PyObject * args, PyObject * kwar
        }
 
        if (size != 3) { // Invalid euler size
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.Euler(): 3d numeric sequence expected\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.Euler(): 3d numeric sequence expected\n");
                return NULL;
        }
 
@@ -70,7 +70,7 @@ static PyObject *Euler_new(PyTypeObject * type, PyObject * args, PyObject * kwar
                e = PySequence_GetItem(listObject, i);
                if (e == NULL) { // Failed to read sequence
                        Py_DECREF(listObject);
-                       PyErr_SetString(PyExc_RuntimeError, "Mathutils.Euler(): 3d numeric sequence expected\n");
+                       PyErr_SetString(PyExc_RuntimeError, "mathutils.Euler(): 3d numeric sequence expected\n");
                        return NULL;
                }
 
@@ -78,7 +78,7 @@ static PyObject *Euler_new(PyTypeObject * type, PyObject * args, PyObject * kwar
                Py_DECREF(e);
                
                if(eul[i]==-1 && PyErr_Occurred()) { // parsed item is not a number
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Euler(): 3d numeric sequence expected\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Euler(): 3d numeric sequence expected\n");
                        return NULL;
                }
        }
@@ -499,7 +499,7 @@ static PySequenceMethods Euler_SeqMethods = {
 
 
 /*
- * vector axis, vector.x/y/z/w
+ * euler axis, euler.x/y/z
  */
 static PyObject *Euler_getAxis( EulerObject * self, void *type )
 {
index 67f91d19d1fcea387a1fd7c2caf7c5a0b15950d1..0c363df88376aae3aa6261367b5f6a491791e612 100644 (file)
@@ -105,7 +105,7 @@ Mathutils_Callback mathutils_matrix_vector_cb = {
 };
 /* matrix vector callbacks, this is so you can do matrix[i][j] = val  */
 
-//----------------------------------Mathutils.Matrix() -----------------
+//----------------------------------mathutils.Matrix() -----------------
 //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
 //create a new matrix type
 static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -119,7 +119,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
        argSize = PyTuple_GET_SIZE(args);
        if(argSize > 4){        //bad arg nums
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
                return NULL;
        } else if (argSize == 0) { //return empty 4D matrix
                return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, NULL);
@@ -141,13 +141,13 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                        if (PySequence_Check(argObject)) { //seq?
                                if(seqSize){ //0 at first
                                        if(PySequence_Length(argObject) != seqSize){ //seq size not same
-                                               PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
+                                               PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
                                                return NULL;
                                        }
                                }
                                seqSize = PySequence_Length(argObject);
                        }else{ //arg not a sequence
-                               PyErr_SetString(PyExc_TypeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
+                               PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
                                return NULL;
                        }
                }
@@ -155,14 +155,14 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                for (i = 0; i < argSize; i++){
                        m = PyTuple_GET_ITEM(args, i);
                        if (m == NULL) { // Failed to read sequence
-                               PyErr_SetString(PyExc_RuntimeError, "Mathutils.Matrix(): failed to parse arguments...\n");
+                               PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments...\n");
                                return NULL;
                        }
 
                        for (j = 0; j < seqSize; j++) {
                                s = PySequence_GetItem(m, j);
                                if (s == NULL) { // Failed to read sequence
-                                       PyErr_SetString(PyExc_RuntimeError, "Mathutils.Matrix(): failed to parse arguments...\n");
+                                       PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments...\n");
                                        return NULL;
                                }
                                
@@ -170,7 +170,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                                Py_DECREF(s);
                                
                                if(scalar==-1 && PyErr_Occurred()) { // parsed item is not a number
-                                       PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
+                                       PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
                                        return NULL;
                                }
 
index b18a3e8e6fe2f6318a898baf8ecb2b2f5d439e1e..421cde6c20def1ad748937d92614ba1be3e01189 100644 (file)
@@ -36,7 +36,7 @@ extern PyTypeObject matrix_Type;
 #define MatrixObject_Check(_v) PyObject_TypeCheck((_v), &matrix_Type)
 
 typedef float **ptRow;
-typedef struct _Matrix { /* keep aligned with BaseMathObject in Mathutils.h */
+typedef struct _Matrix { /* keep aligned with BaseMathObject in mathutils.h */
        PyObject_VAR_HEAD
        float *contigPtr;       /*1D array of data (alias)*/
        PyObject *cb_user;      /* if this vector references another object, otherwise NULL, *Note* this owns its reference */
index 2e51c5ae0ece606aa4b9f8eea76fc80bde278313..38fb2ae49039ffdee34517a0453b1032c9ab9af2 100644 (file)
@@ -712,7 +712,7 @@ static PyObject *Quaternion_getAxisVec( QuaternionObject * self, void *type )
        return (PyObject *) newVectorObject(vec, 3, Py_NEW, NULL);
 }
 
-//----------------------------------Mathutils.Quaternion() --------------
+//----------------------------------mathutils.Quaternion() --------------
 static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
        PyObject *listObject = NULL, *n, *q;
@@ -728,13 +728,13 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
                        if ((size == 4 && PySequence_Length(args) !=1) ||
                                (size == 3 && PySequence_Length(args) !=2) || (size >4 || size < 3)) {
                                // invalid args/size
-                               PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                               PyErr_SetString(PyExc_AttributeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                return NULL;
                        }
                           if(size == 3){ //get angle in axis/angle
                                n = PySequence_GetItem(args, 1);
                                if(n == NULL) { // parsed item not a number or getItem fail
-                                       PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                                       PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                        return NULL;
                                }
 
@@ -742,7 +742,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
                                Py_DECREF(n);
 
                                if (angle==-1 && PyErr_Occurred()) {
-                                       PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                                       PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                        return NULL;
                                }
                        }
@@ -752,17 +752,17 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
                                size = PySequence_Length(listObject);
                                if (size != 3) {
                                        // invalid args/size
-                                       PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                                       PyErr_SetString(PyExc_AttributeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                        return NULL;
                                }
                                angle = PyFloat_AsDouble(PyTuple_GET_ITEM(args, 0));
 
                                if (angle==-1 && PyErr_Occurred()) {
-                                       PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                                       PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                        return NULL;
                                }
                        } else { // argument was not a sequence
-                               PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                               PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                                return NULL;
                        }
                }
@@ -774,12 +774,12 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
 
        if (size == 3) { // invalid quat size
                if(PySequence_Length(args) != 2){
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                        return NULL;
                }
        }else{
                if(size != 4){
-                       PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                       PyErr_SetString(PyExc_AttributeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                        return NULL;
                }
        }
@@ -787,7 +787,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
        for (i=0; i<size; i++) { //parse
                q = PySequence_GetItem(listObject, i);
                if (q == NULL) { // Failed to read sequence
-                       PyErr_SetString(PyExc_RuntimeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                       PyErr_SetString(PyExc_RuntimeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                        return NULL;
                }
 
@@ -795,7 +795,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
                Py_DECREF(q);
 
                if (quat[i]==-1 && PyErr_Occurred()) {
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n");
                        return NULL;
                }
        }
index 6e0c9d6dd1f534654d91e90b53ab52124cd18412..0416bbe6042f16a81a310dd1fda2d40e6bf1908a 100644 (file)
@@ -36,7 +36,7 @@
 extern PyTypeObject quaternion_Type;
 #define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type)
 
-typedef struct { /* keep aligned with BaseMathObject in Mathutils.h */
+typedef struct { /* keep aligned with BaseMathObject in mathutils.h */
        PyObject_VAR_HEAD 
        float *quat;                            /* 1D array of data (alias) */
        PyObject *cb_user;                      /* if this vector references another object, otherwise NULL, *Note* this owns its reference */
index e4364865d257abb52ac893675074cfd7d4341e0a..e013a3583930f4c3646bcb90d25e506b7e8277ff 100644 (file)
@@ -41,7 +41,7 @@
 
 static PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat); /* utility func */
 
-//----------------------------------Mathutils.Vector() ------------------
+//----------------------------------mathutils.Vector() ------------------
 // Supports 2D, 3D, and 4D vector objects both int and float values
 // accepted. Mixed float and int values accepted. Ints are parsed to float 
 static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -57,7 +57,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                if (PySequence_Check(listObject)) {
                        size = PySequence_Length(listObject);
                } else { // Single argument was not a sequence
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
                        return NULL;
                }
        } else if (size == 0) {
@@ -68,21 +68,21 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
        }
 
        if (size<2 || size>4) { // Invalid vector size
-               PyErr_SetString(PyExc_AttributeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
+               PyErr_SetString(PyExc_AttributeError, "mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
                return NULL;
        }
 
        for (i=0; i<size; i++) {
                v=PySequence_GetItem(listObject, i);
                if (v==NULL) { // Failed to read sequence
-                       PyErr_SetString(PyExc_RuntimeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
+                       PyErr_SetString(PyExc_RuntimeError, "mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
                        return NULL;
                }
 
                f= PyFloat_AsDouble(v);
                if(f==-1 && PyErr_Occurred()) { // parsed item not a number
                        Py_DECREF(v);
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
+                       PyErr_SetString(PyExc_TypeError, "mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n");
                        return NULL;
                }
 
@@ -643,7 +643,6 @@ static PyObject *Vector_Project(VectorObject * self, VectorObject * value)
        return newVectorObject(vec, size, Py_NEW, NULL);
 }
 
-//----------------------------------Mathutils.MidpointVecs() -------------
 static char Vector_Lerp_doc[] =
 ".. function:: lerp(other, factor)\n"
 "\n"
index fd95f5a6750eafbe0e132f58820fd2c3570199e7..f6cd0ef65e778e4703b53de415c3a350d84e208b 100644 (file)
@@ -35,7 +35,7 @@
 extern PyTypeObject vector_Type;
 #define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type)
 
-typedef struct { /* keep aligned with BaseMathObject in Mathutils.h */
+typedef struct { /* keep aligned with BaseMathObject in mathutils.h */
        PyObject_VAR_HEAD 
        float *vec;                                     /*1D array of data (alias), wrapped status depends on wrapped status */
        PyObject *cb_user;                                      /* if this vector references another object, otherwise NULL, *Note* this owns its reference */
index 860c1e32875ee86db9976acfab80cdb14eac1711..89782978c856af56e98ff978b239e90d4f03fa05 100644 (file)
@@ -66,6 +66,7 @@ static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
 #define MATHUTILS_CB_SUBTYPE_EUL 0
 #define MATHUTILS_CB_SUBTYPE_VEC 1
 #define MATHUTILS_CB_SUBTYPE_QUAT 2
+#define MATHUTILS_CB_SUBTYPE_COLOR 0
 
 static int mathutils_rna_generic_check(BPy_PropertyRNA *self)
 {
@@ -246,8 +247,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                                }
                                else {
                                        PyObject *eul_cb= newEulerObject_cb(ret, 0, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA
-                                       Py_DECREF(ret); /* the matrix owns now */
-                                       ret= eul_cb; /* return the matrix instead */
+                                       Py_DECREF(ret); /* the euler owns now */
+                                       ret= eul_cb; /* return the euler instead */
                                }
                        }
                        else if (len==4) {
@@ -257,11 +258,23 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                                }
                                else {
                                        PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT);
-                                       Py_DECREF(ret); /* the matrix owns now */
-                                       ret= quat_cb; /* return the matrix instead */
+                                       Py_DECREF(ret); /* the quat owns now */
+                                       ret= quat_cb; /* return the quat instead */
                                }
                        }
                        break;
+               case PROP_COLOR:
+                       if(len==3) { /* color */
+                               if(is_thick) {
+                                       ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA
+                                       RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
+                               }
+                               else {
+                                       PyObject *col_cb= newColorObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR);
+                                       Py_DECREF(ret); /* the color owns now */
+                                       ret= col_cb; /* return the color instead */
+                               }
+                       }
                default:
                        break;
                }
index 8d4a6d3f8971d8eb6daeb40641d7cc7afcc5cd59..082f802010df7ff3028cd4e43eb244746f82be34 100644 (file)
@@ -1622,7 +1622,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
        /* quick hack for GamePython modules 
                TODO: register builtin modules properly by ExtendInittab */
        if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") ||
-               !strcmp(name, "Rasterizer") || !strcmp(name, "Mathutils") || !strcmp(name, "bgl") || !strcmp(name, "Geometry")) {
+               !strcmp(name, "Rasterizer") || !strcmp(name, "mathutils") || !strcmp(name, "bgl") || !strcmp(name, "geometry")) {
                return PyImport_ImportModuleEx(name, globals, locals, fromlist);
        }
        
index abc8c83855bb3c49d19994e92f30dcb15695ae45..097abbfbf1ae99eeb3eb90ef6dd826995a2cc988 100644 (file)
@@ -26,7 +26,7 @@ The Blender Game Engine Python API Reference
        
                These modules have no GameEngine specific functionality but are useful in many cases.
                
-                       - L{Mathutils}
+                       - L{mathutils}
                        - L{Geometry}
                        - L{BGL}
 
index 7045e6cb88e9d24e04f8c03444b29fbd50dde39f..839f228c3d5a4bcbdb1309eca14a415e2d3896c7 100644 (file)
@@ -1670,7 +1670,7 @@ class KX_GameObject(SCA_IObject):
                @deprecated: use L{localOrientation}
                @type orn: 3x3 rotation matrix, or Quaternion.
                @param orn: a rotation matrix specifying the new rotation.
-               @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
+               @note: When using this matrix with Blender.mathutils.Matrix() types, it will need to be transposed.
                """
        def alignAxisToVect(vect, axis, factor):
                """
@@ -1704,7 +1704,7 @@ class KX_GameObject(SCA_IObject):
                @deprecated: use L{worldOrientation}
                @rtype: 3x3 rotation matrix
                @return: The game object's rotation matrix
-               @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
+               @note: When using this matrix with Blender.mathutils.Matrix() types, it will need to be transposed.
                """
        def applyMovement(movement, local = 0):
                """