diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-28 09:03:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-28 09:03:30 +0300 |
commit | 34ea1cf0b23977ab76b23b06f6ceb1fda5631f88 (patch) | |
tree | fe8ed20a86405a088270ba5e8fef53ae1cb68972 | |
parent | 9d3a17922cad62f1f73ba60eef669a091a2b8687 (diff) |
minor changes to the python api.
- 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, 81 insertions, 132 deletions
diff --git a/release/test/pep8.py b/release/test/pep8.py index 7909036a5f1..12cdf5c3b60 100644 --- a/release/test/pep8.py +++ b/release/test/pep8.py @@ -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: diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d2861a8942c..b4bdb516ab3 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -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 */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 076dae41e6a..f15e0bc3144 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -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) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2eff81b96a6..9c2efe395dc 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -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); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 88ca739a39e..bab48c722dc 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -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); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index fc9324d1742..3bb0124bf03 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -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; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index b35657cb266..5349cc0e421 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -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; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 1e818289d1e..0f298f5cbef 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -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; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 1fd9e91095f..12370e5b1ac 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -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); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 0d07583c28c..73ca3bad5c2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 34c0e17f7d2..f18839836c0 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -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; diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index f002bf9aeb9..60df20998e2 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -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; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b03c5ef5395..25d19f18d34 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -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); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 668f0a086d1..f7d4744134f 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -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; diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 321152ab581..f1c2451dace 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -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; } diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c index f1bb6b79f0f..9b4daf8ea66 100644 --- a/source/blender/python/generic/mathutils_color.c +++ b/source/blender/python/generic/mathutils_color.c @@ -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 diff --git a/source/blender/python/generic/mathutils_euler.c b/source/blender/python/generic/mathutils_euler.c index 9dc7cc2cc01..64d1b08b9e3 100644 --- a/source/blender/python/generic/mathutils_euler.c +++ b/source/blender/python/generic/mathutils_euler.c @@ -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 diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index d41c05abb71..4a98a421650 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -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++; } diff --git a/source/blender/python/generic/mathutils_matrix.c b/source/blender/python/generic/mathutils_matrix.c index 671e2568d39..695ecad8417 100644 --- a/source/blender/python/generic/mathutils_matrix.c +++ b/source/blender/python/generic/mathutils_matrix.c @@ -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*/ diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index dec15610133..b787d778277 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -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 diff --git a/source/blender/python/generic/mathutils_vector.c b/source/blender/python/generic/mathutils_vector.c index ee4cd154894..60381e914f6 100644 --- a/source/blender/python/generic/mathutils_vector.c +++ b/source/blender/python/generic/mathutils_vector.c @@ -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; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ab1d0d1ab94..20b8599a651 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -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); diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 4f872a238cd..1a52bc36482 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -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; |