minor changes to the python api.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 28 Nov 2010 06:03:30 +0000 (06:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 28 Nov 2010 06:03:30 +0000 (06:03 +0000)
- pep8 script was giving an error on non utf8 scons source files.
- use PyList_SET_ITEM macro when list type is ensured.
- all mathutils types use subtypes to create new types when available.
- use defines MAT3_UNITY, MAT4_UNITY to initialize unit matrices.

23 files changed:
release/test/pep8.py
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/particle.c
source/blender/blenlib/intern/math_geom.c
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/editcurve.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_manipulator.c
source/blender/modifiers/intern/MOD_screw.c
source/blender/python/generic/bgl.c
source/blender/python/generic/mathutils_color.c
source/blender/python/generic/mathutils_euler.c
source/blender/python/generic/mathutils_geometry.c
source/blender/python/generic/mathutils_matrix.c
source/blender/python/generic/mathutils_quat.c
source/blender/python/generic/mathutils_vector.c
source/blender/python/intern/bpy_rna.c
source/blender/render/intern/source/zbuf.c

index 7909036a5f1ff4b69397fbd0f582fe4386378618..12cdf5c3b60da398bb56952fbe2412d605d60db0 100644 (file)
@@ -47,6 +47,7 @@ def file_list_py(path):
 
 
 def is_pep8(path):
+    print(path)
     f = open(path, 'r')
     for i in range(PEP8_SEEK_COMMENT):
         line = f.readline()
@@ -63,14 +64,16 @@ def main():
     files = []
     files_skip = []
     for f in file_list_py("."):
+        if [None for prefix in SKIP_PREFIX if f.startswith(prefix)]:
+            continue
+
         pep8_type = is_pep8(f)
 
         if pep8_type:
             # so we can batch them for each tool.
             files.append((os.path.abspath(f), pep8_type))
         else:
-            if not [None for prefix in SKIP_PREFIX if f.startswith(prefix)]:
-                files_skip.append(f)
+            files_skip.append(f)
 
     print("\nSkipping...")
     for f in files_skip:
index d2861a8942c1ebf1eeaebc30a23ef630cecb8225..b4bdb516ab3d23524203e97f1fb336fc2d4ed495 100644 (file)
@@ -590,7 +590,7 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
        Mat4 *b_bone_rest= b_bone_spline_setup(pchan, 1);
        Mat4 *b_bone_mats;
        DualQuat *b_bone_dual_quats= NULL;
-       float tmat[4][4];
+       float tmat[4][4]= MAT4_UNITY;
        int a;
        
        /* allocate b_bone matrices and dual quats */
@@ -611,7 +611,6 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info
                - translate over the curve to the bbone mat space
                - transform with b_bone matrix
                - transform back into global space */
-       unit_m4(tmat);
 
        for(a=0; a<bone->segments; a++) {
                invert_m4_m4(tmat, b_bone_rest[a].mat);
@@ -1104,11 +1103,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
  */
 void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) 
 {
-       float xLocMat[4][4];
+       float xLocMat[4][4]= MAT4_UNITY;
        float nLocMat[4][4];
        
        /* build matrix for location */
-       unit_m4(xLocMat);
        VECCOPY(xLocMat[3], inloc);
 
        /* get bone-space cursor matrix and extract location */
@@ -1184,11 +1182,10 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
  */
 void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) 
 {
-       float xLocMat[4][4];
+       float xLocMat[4][4]= MAT4_UNITY;
        float nLocMat[4][4];
        
        /* build matrix for location */
-       unit_m4(xLocMat);
        VECCOPY(xLocMat[3], inloc);
 
        /* get bone-space cursor matrix and extract location */
index 076dae41e6aa4ef4cda18a710079aa9e3b2da165..f15e0bc31446f981b068e9d49dcdfe92c897f91e 100644 (file)
@@ -1202,12 +1202,11 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
        if (VALID_CONS_TARGET(ct)) {
                Curve *cu= ct->tar->data;
                float vec[4], dir[3], radius;
-               float totmat[4][4];
+               float totmat[4][4]= MAT4_UNITY;
                float curvetime;
-               
-               unit_m4(totmat);
+
                unit_m4(ct->matrix);
-               
+
                /* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
                 *              currently for paths to work it needs to go through the bevlist/displist system (ton) 
                 */
@@ -3106,11 +3105,11 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
        /* only evaluate if there is a target and it is a curve */
        if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) {
                Curve *cu= data->tar->data;
-               float obmat[4][4], targetMatrix[4][4], ownLoc[3];
+               float obmat[4][4], ownLoc[3];
                float curveMin[3], curveMax[3];
+               float targetMatrix[4][4]= MAT4_UNITY;
                
                copy_m4_m4(obmat, cob->matrix);
-               unit_m4(targetMatrix);
                copy_v3_v3(ownLoc, obmat[3]);
                
                INIT_MINMAX(curveMin, curveMax)
index 2eff81b96a6674e6eff251d07528f8913bf062c3..9c2efe395dc384347cbf59cfeb86255c87097137 100644 (file)
@@ -4359,7 +4359,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
                normalize_v3(side);
                cross_v3_v3v3(nor, vec, side);
 
-                unit_m4(mat);
+               unit_m4(mat);
                VECCOPY(mat[0], vec);
                VECCOPY(mat[1], side);
                VECCOPY(mat[2], nor);
index 88ca739a39e9b55749f4f31dba8e126932c3cb76..bab48c722dc4ee3ecb2a1ef70843c9d8874c5866 100644 (file)
@@ -1704,10 +1704,9 @@ void polarview_m4(float Vm[][4],float dist, float azimuth, float incidence, floa
 void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py, float pz, float twist)
 {
        float sine, cosine, hyp, hyp1, dx, dy, dz;
-       float mat1[4][4];
+       float mat1[4][4]= MAT4_UNITY;
        
        unit_m4(mat);
-       unit_m4(mat1);
 
        rotate_m4(mat, 'Z', -twist);
 
index fc9324d174207d0bf4fe889053a797f9e71bcc81..3bb0124bf0312579beb9436d684e3532871b609d 100644 (file)
@@ -5779,13 +5779,8 @@ EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *ar
 
        if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION)
        {
-               float invmat[4][4] = {  {1, 0, 0, 0},
-                                                               {0, 1, 0, 0},
-                                                               {0, 0, 1, 0},
-                                                               {0, 0, 0, 1}};
-               float tmat[3][3] = {    {1, 0, 0},
-                                                               {0, 1, 0},
-                                                               {0, 0, 1}};
+               float invmat[4][4]= MAT4_UNITY;
+               float tmat[3][3]= MAT3_UNITY;
                ReebArcIterator arc_iter;
                BArcIterator *iter = (BArcIterator*)&arc_iter;
                bArmature *arm= obedit->data;
@@ -5831,13 +5826,8 @@ EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, Re
        if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) &&
                arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
        {
-               float invmat[4][4] = {  {1, 0, 0, 0},
-                                                               {0, 1, 0, 0},
-                                                               {0, 0, 1, 0},
-                                                               {0, 0, 0, 1}};
-               float tmat[3][3] = {    {1, 0, 0},
-                                                               {0, 1, 0},
-                                                               {0, 0, 1}};
+               float invmat[4][4]= MAT4_UNITY;
+               float tmat[3][3]= MAT3_UNITY;
                ReebArcIterator arc_iter;
                BArcIterator *iter = (BArcIterator*)&arc_iter;
                bArmature *arm= obedit->data;
index b35657cb26697da9f17a00e1118eff81819f5f12..5349cc0e421c2638b2d7d26227ac6f947266ca01 100644 (file)
@@ -5754,8 +5754,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
        int a, b, cutype, stype;
        int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */
 
-       float umat[4][4];
-       unit_m4(umat);
+       float umat[4][4]= MAT4_UNITY;
 
        cutype= type & CU_TYPE; // poly, bezier, nurbs, etc
        stype= type & CU_PRIMITIVE;
index 1e818289d1e3a9145211d6bf0574d95512b8a354..0f298f5cbef81e0e925590b29ba2cb224249ef2a 100644 (file)
@@ -808,7 +808,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
        int i, c;
        float w, w3, h, alpha, yofs;
        GLint scissor[4];
-       float colors[3][3] = {{1,0,0},{0,1,0},{0,0,1}};
+       float colors[3][3]= MAT3_UNITY;
        float colorsycc[3][3] = {{1,0,1},{1,1,0},{0,1,1}};
        float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors  pre multiplied by alpha for speed up */
        float min, max;
index 1fd9e91095f805c9868bbf553bfbe24b97b125a7..12370e5b1ac6324ccd208e94f483bd5d540c68cf 100644 (file)
@@ -593,7 +593,7 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
        ParticleSystemModifierData *psmd = NULL;
        ParticleEditSettings *pset= PE_settings(data->scene);
        POINT_P; KEY_K;
-       float mat[4][4], imat[4][4];
+       float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY;
 
        if(edit->psys)
                psmd= psys_get_modifier(data->ob, edit->psys);
@@ -602,9 +602,6 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected
        if(pset->selectmode==SCE_SELECT_PATH)
                selected= 0;
 
-       unit_m4(imat);
-       unit_m4(mat);
-
        LOOP_VISIBLE_POINTS {
                if(pset->selectmode==SCE_SELECT_END) {
                        /* only do end keys */
@@ -1605,7 +1602,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s
        ParticleSystem *psys = edit->psys;
        ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
        POINT_P; KEY_K;
-       float co[3], mat[4][4];
+       float co[3], mat[4][4]= MAT4_UNITY;
        short vertco[2];
 
        PEData data;
@@ -1619,8 +1616,6 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s
        /* only for depths */
        PE_set_view3d_data(C, &data);
 
-       unit_m4(mat);
-
        LOOP_VISIBLE_POINTS {
                if(edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR))
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + p, mat);
index 0d07583c28c7d203ba3a4f89b4a8d096d71a88a5..73ca3bad5c2e30e16c1d155b89d6aa13e15704a1 100644 (file)
@@ -516,8 +516,7 @@ float calc_overlap(StrokeCache *cache, const char symm, const char axis, const f
        flip_coord(mirror, cache->true_location, symm);
 
        if(axis != 0) {
-               float mat[4][4];
-               unit_m4(mat);
+               float mat[4][4]= MAT4_UNITY;
                rotate_m4(mat, axis, angle);
                mul_m4_v3(mat, mirror);
        }
index 34c0e17f7d23ed5d96bd4d1c0c379a002a913864..f18839836c005ce1195802dd8c3a52ab8552f801 100644 (file)
@@ -560,7 +560,7 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
 
 int transformEvent(TransInfo *t, wmEvent *event)
 {
-       float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
+       float mati[3][3]= MAT3_UNITY;
        char cmode = constraintModeToChar(t);
        int handled = 1;
 
index f002bf9aeb90f70ce340ee8e38c64b2b35c634ac..60df20998e255b54e90baf31d0d3e6de3a276212 100644 (file)
@@ -560,9 +560,8 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
        switch(orientation) {
        case V3D_MANIP_GLOBAL:
                {
-                       float mtx[3][3];
+                       float mtx[3][3]= MAT3_UNITY;
                        sprintf(text, ftext, "global");
-                       unit_m3(mtx);
                        setConstraint(t, mtx, mode, text);
                }
                break;
index b03c5ef539570294e3537e64240635d1dbd49071..25d19f18d34320e711794130ff34a0afc4307b31 100644 (file)
@@ -1316,8 +1316,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
 
        /* Screen aligned view rot circle */
        if(drawflags & MAN_ROT_V) {
-               float unitmat[4][4];
-               unit_m4(unitmat);
+               float unitmat[4][4]= MAT4_UNITY;
 
                if(G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
                UI_ThemeColor(TH_TRANSFORM);
index 668f0a086d10a3b1906ceb13f9db9b7c108658d9..f7d4744134fc0ce6cdc7f4889e1260381d51e5f7 100644 (file)
@@ -168,11 +168,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 
        ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL;
 
-       float mat[4][4] =       {{0.0f, 0.0f, 0.0f, 0.0f},
-                                                {0.0f, 0.0f, 0.0f, 0.0f},
-                                                {0.0f, 0.0f, 0.0f, 0.0f},
-                                                {0.0f, 0.0f, 0.0f, 1.0f}};
-
        /* dont do anything? */
        if (!totvert)
                return CDDM_from_template(dm, 0, 0, 0);
@@ -674,6 +669,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                const int varray_stride= totvert * step;
                float step_angle;
                float nor_tx[3];
+               float mat[4][4];
                /* Rotation Matrix */
                step_angle= (angle / (step_tot - (!close))) * step;
 
index 321152ab581c64aee6ca19864eb177c6278367ff..f1c2451dace1b382f7901a773b980f4b3100b673 100644 (file)
@@ -297,9 +297,9 @@ static PyObject *Buffer_slice(PyObject *self, int begin, int end)
          
        list= PyList_New(end-begin);
 
-       for (count= begin; count<end; count++)
-               PyList_SetItem(list, count-begin, Buffer_item(self, count));
-       
+       for (count= begin; count<end; count++) {
+               PyList_SET_ITEM(list, count-begin, Buffer_item(self, count));
+       }
        return list;
 }
 
@@ -391,11 +391,11 @@ static PyObject *Buffer_tolist(PyObject *self)
 {
        int i, len= ((Buffer *)self)->dimensions[0];
        PyObject *list= PyList_New(len);
-       
+
        for (i=0; i<len; i++) {
-         PyList_SetItem(list, i, Buffer_item(self, i));
+               PyList_SET_ITEM(list, i, Buffer_item(self, i));
        }
-       
+
        return list;
 }
 
@@ -404,11 +404,11 @@ static PyObject *Buffer_dimensions(PyObject *self)
        Buffer *buffer= (Buffer *) self;
        PyObject *list= PyList_New(buffer->ndimensions);
        int i;
-         
+  
        for (i= 0; i<buffer->ndimensions; i++) {
-         PyList_SetItem(list, i, PyLong_FromLong(buffer->dimensions[i]));
+               PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i]));
        }
-       
+
        return list;
 }
 
index f1bb6b79f0f4ec73eced5995545f336e2f1de702..9b4daf8ea6691e3c252645e1c56ea7cc0b413bce 100644 (file)
@@ -225,9 +225,8 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
        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]));
+       for(count= begin; count < end; count++) {
+               PyList_SET_ITEM(list, count - begin, PyFloat_FromDouble(self->col[count]));
        }
 
        return list;
@@ -290,9 +289,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "color indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return NULL;
        }
 }
@@ -321,9 +318,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "color indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return -1;
        }
 }
@@ -468,7 +463,7 @@ static char color_doc[] =
 
 PyTypeObject color_Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
-       "color",                                                //tp_name
+       "mathutils.Color",                                              //tp_name
        sizeof(ColorObject),                    //tp_basicsize
        0,                                                              //tp_itemsize
        (destructor)BaseMathObject_dealloc,             //tp_dealloc
index 9dc7cc2cc01ee610d0a848c8e821d05e0cc1eb0a..64d1b08b9e3f7c4f92a2b20cf3f26590e8dab327 100644 (file)
@@ -39,7 +39,7 @@
 
 //----------------------------------mathutils.Euler() -------------------
 //makes a new euler for you to play with
-static PyObject *Euler_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
        PyObject *seq= NULL;
        char *order_str= NULL;
@@ -67,7 +67,7 @@ static PyObject *Euler_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
                        return NULL;
                break;
        }
-       return newEulerObject(eul, order, Py_NEW, NULL);
+       return newEulerObject(eul, order, Py_NEW, type);
 }
 
 short euler_order_from_string(const char *str, const char *error_prefix)
@@ -456,8 +456,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
 
        list = PyList_New(end - begin);
        for(count = begin; count < end; count++) {
-               PyList_SetItem(list, count - begin,
-                               PyFloat_FromDouble(self->eul[count]));
+               PyList_SET_ITEM(list, count - begin, PyFloat_FromDouble(self->eul[count]));
        }
 
        return list;
@@ -520,9 +519,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "euler indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return NULL;
        }
 }
@@ -552,9 +549,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "euler indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return -1;
        }
 }
@@ -650,7 +645,7 @@ static char euler_doc[] =
 
 PyTypeObject euler_Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
-       "euler",                                                //tp_name
+       "mathutils.Euler",                                              //tp_name
        sizeof(EulerObject),                    //tp_basicsize
        0,                                                              //tp_itemsize
        (destructor)BaseMathObject_dealloc,             //tp_dealloc
index d41c05abb71e21df6edf4a05b48008f3655b3437..4a98a42165058a7e3325e39f99fb240c185d4bce 100644 (file)
@@ -435,7 +435,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine
                index= 0;
                dl_face= dl->index;
                while(index < dl->parts) {
-                       PyList_SetItem(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]) );
+                       PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]) );
                        dl_face+= 3;
                        index++;
                }
index 671e2568d398282bafe0d6252775304e6a67c372..695ecad8417f11b51fe0b7a5667073460a3db21d 100644 (file)
@@ -105,7 +105,7 @@ Mathutils_Callback mathutils_matrix_vector_cb = {
 //----------------------------------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 *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
        PyObject *argObject, *m, *s;
        MatrixObject *mat;
@@ -124,7 +124,7 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
                PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size");
                return NULL;
        } else if (argSize == 0) { //return empty 4D matrix
-               return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, NULL);
+               return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, type);
        }else if (argSize == 1){
                //copy constructor for matrix objects
                argObject = PyTuple_GET_ITEM(args, 0);
@@ -180,7 +180,7 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
                        }
                }
        }
-       return newMatrixObject(matrix, argSize, seqSize, Py_NEW, NULL);
+       return newMatrixObject(matrix, argSize, seqSize, Py_NEW, type);
 }
 
 /*-----------------------CLASS-METHODS----------------------------*/
@@ -1410,7 +1410,7 @@ static PyObject *Matrix_slice(MatrixObject * self, int begin, int end)
 
        list = PyList_New(end - begin);
        for(count = begin; count < end; count++) {
-               PyList_SetItem(list, count - begin,
+               PyList_SET_ITEM(list, count - begin,
                                newVectorObject_cb((PyObject *)self, self->colSize, mathutils_matrix_vector_cb_index, count));
 
        }
@@ -1597,7 +1597,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
                        }
                }
                
-               return newMatrixObject(mat, mat2->rowSize, mat1->colSize, Py_NEW, NULL);
+               return newMatrixObject(mat, mat2->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1));
        }
        
        if(mat1==NULL){
@@ -1608,7 +1608,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
                                        mat[((x * mat2->colSize) + y)] = scalar * mat2->matrix[x][y];
                                }
                        }
-                       return newMatrixObject(mat, mat2->rowSize, mat2->colSize, Py_NEW, NULL);
+                       return newMatrixObject(mat, mat2->rowSize, mat2->colSize, Py_NEW, Py_TYPE(mat2));
                }
                
                PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation");
@@ -1627,7 +1627,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
                                                mat[((x * mat1->colSize) + y)] = scalar * mat1->matrix[x][y];
                                        }
                                }
-                               return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, NULL);
+                               return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1));
                        }
                }
                PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation");
@@ -1688,9 +1688,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "vector indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return NULL;
        }
 }
@@ -1719,9 +1717,7 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "matrix indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return -1;
        }
 }
@@ -1865,7 +1861,7 @@ static char matrix_doc[] =
 
 PyTypeObject matrix_Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
-       "matrix",                                               /*tp_name*/
+       "mathutils.Matrix",                                             /*tp_name*/
        sizeof(MatrixObject),                   /*tp_basicsize*/
        0,                                                              /*tp_itemsize*/
        (destructor)BaseMathObject_dealloc,             /*tp_dealloc*/
index dec156101331b00d51314592bc7eca20ea00f5b1..b787d778277cd5ef76317d1db7ab8199028fbee8 100644 (file)
@@ -151,7 +151,7 @@ static PyObject *Quaternion_Cross(QuaternionObject *self, QuaternionObject *valu
                return NULL;
 
        mul_qt_qtqt(quat, self->quat, value->quat);
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
 }
 
 //----------------------------Quaternion.dot(other)------------------
@@ -202,7 +202,7 @@ static PyObject *Quaternion_Difference(QuaternionObject * self, QuaternionObject
 
        rotation_between_quats_to_quat(quat, self->quat, value->quat);
 
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
 }
 
 static char Quaternion_Slerp_doc[] =
@@ -237,7 +237,7 @@ static PyObject *Quaternion_Slerp(QuaternionObject *self, PyObject *args)
 
        interp_qt_qtqt(quat, self->quat, value->quat, fac);
 
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, Py_TYPE(self));
 }
 
 //----------------------------Quaternion.normalize()----------------
@@ -490,8 +490,7 @@ static PyObject *Quaternion_slice(QuaternionObject * self, int begin, int end)
 
        list = PyList_New(end - begin);
        for(count = begin; count < end; count++) {
-               PyList_SetItem(list, count - begin,
-                               PyFloat_FromDouble(self->quat[count]));
+               PyList_SET_ITEM(list, count - begin, PyFloat_FromDouble(self->quat[count]));
        }
 
        return list;
@@ -556,9 +555,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "quaternion indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return NULL;
        }
 }
@@ -588,9 +585,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "quaternion indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "quaternion indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return -1;
        }
 }
@@ -614,7 +609,7 @@ static PyObject *Quaternion_add(PyObject * q1, PyObject * q2)
                return NULL;
 
        add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
 }
 //------------------------obj - obj------------------------------
 //subtraction
@@ -639,7 +634,7 @@ static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2)
                quat[x] = quat1->quat[x] - quat2->quat[x];
        }
 
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
 }
 //------------------------obj * obj------------------------------
 //mulplication
@@ -661,7 +656,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
 
        if(quat1 && quat2) { /* QUAT*QUAT (cross product) */
                mul_qt_qtqt(quat, quat1->quat, quat2->quat);
-               return newQuaternionObject(quat, Py_NEW, NULL);
+               return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
        }
        
        /* the only case this can happen (for a supported type is "FLOAT*QUAT" ) */
@@ -670,7 +665,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
                if ((scalar == -1.0 && PyErr_Occurred())==0) { /* FLOAT*QUAT */
                        QUATCOPY(quat, quat2->quat);
                        mul_qt_fl(quat, scalar);
-                       return newQuaternionObject(quat, Py_NEW, NULL);
+                       return newQuaternionObject(quat, Py_NEW, Py_TYPE(q2));
                }
                PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: val * quat, val is not an acceptable type");
                return NULL;
@@ -685,7 +680,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2)
                if ((scalar == -1.0 && PyErr_Occurred())==0) { /* QUAT*FLOAT */
                        QUATCOPY(quat, quat1->quat);
                        mul_qt_fl(quat, scalar);
-                       return newQuaternionObject(quat, Py_NEW, NULL);
+                       return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1));
                }
        }
        
@@ -860,7 +855,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
 }
 
 //----------------------------------mathutils.Quaternion() --------------
-static PyObject *Quaternion_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
        PyObject *seq= NULL;
        float angle = 0.0f;
@@ -889,7 +884,7 @@ static PyObject *Quaternion_new(PyTypeObject *UNUSED(type), PyObject *args, PyOb
                break;
        /* PyArg_ParseTuple assures no more then 2 */
        }
-       return newQuaternionObject(quat, Py_NEW, NULL);
+       return newQuaternionObject(quat, Py_NEW, type);
 }
 
 
@@ -933,7 +928,7 @@ static char quaternion_doc[] =
 
 PyTypeObject quaternion_Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
-       "quaternion",                                           //tp_name
+       "mathutils.Quaternion",                                         //tp_name
        sizeof(QuaternionObject),                       //tp_basicsize
        0,                                                              //tp_itemsize
        (destructor)BaseMathObject_dealloc,             //tp_dealloc
index ee4cd154894a92e166db7c21692483007e4ccc8f..60381e914f67fc9f74b98acd9f503a5df0900949 100644 (file)
@@ -379,9 +379,7 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args )
                flip vector around, since vectoquat expect a vector from target to tracking object 
                and the python function expects the inverse (a vector to the target).
        */
-       vec[0] = -self->vec[0];
-       vec[1] = -self->vec[1];
-       vec[2] = -self->vec[2];
+       negate_v3_v3(vec, self->vec);
 
        vec_to_quat( quat,vec, track, up);
 
@@ -1400,9 +1398,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item)
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "vector indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return NULL;
        }
 }
@@ -1431,9 +1427,7 @@ static int Vector_ass_subscript(VectorObject* self, PyObject* item, PyObject* va
                }
        }
        else {
-               PyErr_Format(PyExc_TypeError,
-                                "vector indices must be integers, not %.200s",
-                                item->ob_type->tp_name);
+               PyErr_Format(PyExc_TypeError, "vector indices must be integers, not %.200s", Py_TYPE(item)->tp_name);
                return -1;
        }
 }
@@ -2163,7 +2157,7 @@ static char vector_doc[] =
 PyTypeObject vector_Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
        /*  For printing, in format "<module>.<name>" */
-       "vector",             /* char *tp_name; */
+       "mathutils.Vector",             /* char *tp_name; */
        sizeof(VectorObject),         /* int tp_basicsize; */
        0,                          /* tp_itemsize;  For allocation */
 
@@ -2296,6 +2290,6 @@ PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_su
                self->cb_type=                  (unsigned char)cb_type;
                self->cb_subtype=               (unsigned char)cb_subtype;
        }
-       
+
        return (PyObject *)self;
 }
index ab1d0d1ab944bd6b79e9d338e19fd21de6569f6f..20b8599a6517e5bd1dd595d7a8e85cc5af47a34d 100644 (file)
@@ -305,7 +305,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
                case PROP_QUATERNION:
                        if(len==3) { /* euler */
                                if(is_thick) {
-                                       /* attempt to get order, only needed for thixk types since wrapped with update via callbacks */
+                                       /* attempt to get order, only needed for thick types since wrapped with update via callbacks */
                                        PropertyRNA *prop_eul_order= NULL;
                                        short order= pyrna_rotation_euler_order_get(ptr, &prop_eul_order, ROT_MODE_XYZ);
 
index 4f872a238cd6c3733f6f2bf112143c599eba9f5e..1a52bc3648249921c78e06bc4c14426c46a15199 100644 (file)
@@ -1805,10 +1805,9 @@ void zbuf_render_project(float winmat[][4], float *co, float *ho)
 
 void zbuf_make_winmat(Render *re, float winmat[][4])
 {
-       float panomat[4][4];
-
        if(re->r.mode & R_PANORAMA) {
-               unit_m4(panomat);
+               float panomat[4][4]= MAT4_UNITY;
+
                panomat[0][0]= re->panoco;
                panomat[0][2]= re->panosi;
                panomat[2][0]= -re->panosi;