Revision: 21020
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21020
Author:   campbellbarton
Date:     2009-06-20 04:44:57 +0200 (Sat, 20 Jun 2009)

Log Message:
-----------
ObColor wasnt converted into an RNA string.

Updated Mathutils.Vector/Euler/Quaternion/Matrix so these are types rather then 
module methods, each type now has a tp_new function, matching python builtins 
float/int/str.
Also cleaned up float conversion and arg passing.

Changed buttons_objects.py...
 if ob in groups.objects: # no longer works
 if ob.name in groups.objects: # is the new syntax
...its more dict like and a lot faster (avoids python iterating over each item 
and comparing each, use a single rna lookup instead).

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_objects.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c
    branches/blender2.5/blender/source/blender/python/generic/Mathutils.c
    branches/blender2.5/blender/source/blender/python/generic/Mathutils.h
    branches/blender2.5/blender/source/blender/python/generic/euler.c
    branches/blender2.5/blender/source/blender/python/generic/euler.h
    branches/blender2.5/blender/source/blender/python/generic/matrix.c
    branches/blender2.5/blender/source/blender/python/generic/matrix.h
    branches/blender2.5/blender/source/blender/python/generic/quat.c
    branches/blender2.5/blender/source/blender/python/generic/quat.h
    branches/blender2.5/blender/source/blender/python/generic/vector.c
    branches/blender2.5/blender/source/blender/python/generic/vector.h
    branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c

Modified: branches/blender2.5/blender/release/ui/buttons_objects.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_objects.py   2009-06-19 
23:11:41 UTC (rev 21019)
+++ branches/blender2.5/blender/release/ui/buttons_objects.py   2009-06-20 
02:44:57 UTC (rev 21020)
@@ -35,7 +35,7 @@
                # layout.itemO("OBJECT_OT_add_group");
 
                for group in bpy.data.groups:
-                       if ob in group.objects:
+                       if ob.name in group.objects:
                                col = layout.column(align=True)
 
                                row = col.box().row()

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c  
2009-06-19 23:11:41 UTC (rev 21019)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c  
2009-06-20 02:44:57 UTC (rev 21020)
@@ -235,17 +235,15 @@
                        *array_index= 1; return "delta_scale";
                case OB_DSIZE_Z:
                        *array_index= 2; return "delta_scale";
-       
-#if 0  
-               case OB_COL_R:  
-                       poin= &(ob->col[0]); break;
+               case OB_COL_R:
+                       *array_index= 0; return "color";
                case OB_COL_G:
-                       poin= &(ob->col[1]); break;
+                       *array_index= 1; return "color";
                case OB_COL_B:
-                       poin= &(ob->col[2]); break;
+                       *array_index= 2; return "color";
                case OB_COL_A:
-                       poin= &(ob->col[3]); break;
-                       
+                       *array_index= 3; return "color";
+#if 0
                case OB_PD_FSTR:
                        if (ob->pd) poin= &(ob->pd->f_strength);
                        break;

Modified: branches/blender2.5/blender/source/blender/python/generic/Mathutils.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/Mathutils.c       
2009-06-19 23:11:41 UTC (rev 21019)
+++ branches/blender2.5/blender/source/blender/python/generic/Mathutils.c       
2009-06-20 02:44:57 UTC (rev 21020)
@@ -36,10 +36,6 @@
 
 //-------------------------DOC STRINGS ---------------------------
 static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n";
-static char M_Mathutils_Vector_doc[] = "() - create a new vector object from a 
list of floats";
-static char M_Mathutils_Matrix_doc[] = "() - create a new matrix object from a 
list of floats";
-static char M_Mathutils_Quaternion_doc[] = "() - create a quaternion from a 
list or an axis of rotation and an angle";
-static char M_Mathutils_Euler_doc[] = "() - create and return a new euler 
object";
 static char M_Mathutils_Rand_doc[] = "() - return a random number";
 static char M_Mathutils_AngleBetweenVecs_doc[] = "() - returns the angle 
between two vectors in degrees";
 static char M_Mathutils_MidpointVecs_doc[] = "() - return the vector to the 
midpoint between two vectors";
@@ -57,22 +53,36 @@
 static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the 
normal of the 3D quad defined";
 static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a 
tuple with the points on each line respectively closest to the other";
 //-----------------------METHOD DEFINITIONS ----------------------
+
+static PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * 
args);
+static PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * 
value);
+static PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * 
args);
+static PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args);
+static PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args 
);
+static PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args );
+
 struct PyMethodDef M_Mathutils_methods[] = {
        {"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, 
M_Mathutils_Rand_doc},
-       {"Vector", (PyCFunction) M_Mathutils_Vector, METH_VARARGS, 
M_Mathutils_Vector_doc},
        {"AngleBetweenVecs", (PyCFunction) M_Mathutils_AngleBetweenVecs, 
METH_VARARGS, M_Mathutils_AngleBetweenVecs_doc},
        {"MidpointVecs", (PyCFunction) M_Mathutils_MidpointVecs, METH_VARARGS, 
M_Mathutils_MidpointVecs_doc},
        {"ProjectVecs", (PyCFunction) M_Mathutils_ProjectVecs, METH_VARARGS, 
M_Mathutils_ProjectVecs_doc},
-       {"Matrix", (PyCFunction) M_Mathutils_Matrix, METH_VARARGS, 
M_Mathutils_Matrix_doc},
        {"RotationMatrix", (PyCFunction) M_Mathutils_RotationMatrix, 
METH_VARARGS, M_Mathutils_RotationMatrix_doc},
        {"ScaleMatrix", (PyCFunction) M_Mathutils_ScaleMatrix, METH_VARARGS, 
M_Mathutils_ScaleMatrix_doc},
        {"ShearMatrix", (PyCFunction) M_Mathutils_ShearMatrix, METH_VARARGS, 
M_Mathutils_ShearMatrix_doc},
        {"TranslationMatrix", (PyCFunction) M_Mathutils_TranslationMatrix, 
METH_O, M_Mathutils_TranslationMatrix_doc},
        {"OrthoProjectionMatrix", (PyCFunction) 
M_Mathutils_OrthoProjectionMatrix,  METH_VARARGS, 
M_Mathutils_OrthoProjectionMatrix_doc},
-       {"Quaternion", (PyCFunction) M_Mathutils_Quaternion, METH_VARARGS, 
M_Mathutils_Quaternion_doc},
        {"DifferenceQuats", (PyCFunction) M_Mathutils_DifferenceQuats, 
METH_VARARGS,M_Mathutils_DifferenceQuats_doc},
        {"Slerp", (PyCFunction) M_Mathutils_Slerp, METH_VARARGS, 
M_Mathutils_Slerp_doc},
-       {"Euler", (PyCFunction) M_Mathutils_Euler, METH_VARARGS, 
M_Mathutils_Euler_doc},
        {"Intersect", ( PyCFunction ) M_Mathutils_Intersect, METH_VARARGS, 
M_Mathutils_Intersect_doc},
        {"TriangleArea", ( PyCFunction ) M_Mathutils_TriangleArea, 
METH_VARARGS, M_Mathutils_TriangleArea_doc},
        {"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, 
METH_VARARGS, M_Mathutils_TriangleNormal_doc},
@@ -80,6 +90,7 @@
        {"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, 
METH_VARARGS, M_Mathutils_LineIntersect_doc},
        {NULL, NULL, 0, NULL}
 };
+
 /*----------------------------MODULE INIT-------------------------*/
 /* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */
 
@@ -120,6 +131,12 @@
        submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc);
 #endif
        
+       /* each type has its own new() function */
+       PyModule_AddObject( submodule, "Vector",                (PyObject 
*)&vector_Type );
+       PyModule_AddObject( submodule, "Matrix",                (PyObject 
*)&matrix_Type );
+       PyModule_AddObject( submodule, "Euler",                 (PyObject 
*)&euler_Type );
+       PyModule_AddObject( submodule, "Quaternion",    (PyObject 
*)&quaternion_Type );
+       
        return (submodule);
 }
 
@@ -250,7 +267,7 @@
 
 //----------------------------------Mathutils.Rand() --------------------
 //returns a random number between a high and low value
-PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args)
+static PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args)
 {
        float high, low, range;
        double drand;
@@ -278,65 +295,9 @@
        return PyFloat_FromDouble(drand);
 }
 //----------------------------------VECTOR FUNCTIONS---------------------
-//----------------------------------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 
-PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args)
-{
-       PyObject *listObject = NULL;
-       int size, i;
-       float vec[4], f;
-       PyObject *v;
-
-       size = PySequence_Length(args);
-       if (size == 1) {
-               listObject = PySequence_GetItem(args, 0);
-               if (PySequence_Check(listObject)) {
-                       size = PySequence_Length(listObject);
-               } else { // Single argument was not a sequence
-                       Py_XDECREF(listObject);
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 
2-4 floats or ints expected (optionally in a sequence)\n");
-                       return NULL;
-               }
-       } else if (size == 0) {
-               //returns a new empty 3d vector
-               return newVectorObject(NULL, 3, Py_NEW); 
-       } else {
-               Py_INCREF(args);
-               listObject = args;
-       }
-
-       if (size<2 || size>4) { // Invalid vector size
-               Py_XDECREF(listObject);
-               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
-                       Py_XDECREF(listObject);
-                       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);
-                       Py_XDECREF(listObject);
-                       PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 
2-4 floats or ints expected (optionally in a sequence)\n");
-                       return NULL;
-               }
-
-               vec[i]= f;
-               Py_DECREF(v);
-       }
-       Py_DECREF(listObject);
-       return newVectorObject(vec, size, Py_NEW);
-}
 //----------------------------------Mathutils.AngleBetweenVecs() ---------
 //calculates the angle between 2 vectors
-PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args)
+static PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args)
 {
        VectorObject *vec1 = NULL, *vec2 = NULL;
        double dot = 0.0f, angleRads, test_v1 = 0.0f, test_v2 = 0.0f;
@@ -378,7 +339,7 @@
 }
 //----------------------------------Mathutils.MidpointVecs() -------------
 //calculates the midpoint between 2 vectors
-PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args)
+static PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args)
 {
        VectorObject *vec1 = NULL, *vec2 = NULL;
        float vec[4];
@@ -400,7 +361,7 @@
 }
 //----------------------------------Mathutils.ProjectVecs() -------------
 //projects vector 1 onto vector 2
-PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args)
+static PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args)
 {
        VectorObject *vec1 = NULL, *vec2 = NULL;
        float vec[4]; 
@@ -432,94 +393,10 @@
        return newVectorObject(vec, size, Py_NEW);
 }

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to