From 3b9b6051d93122a27da57908c987670e9f831e7f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Nov 2011 04:45:36 +0000 Subject: rename mathutils constructors to match other parts of the bpy/api (no functional changes) --- source/blender/python/intern/bpy_rna.c | 30 +++++------ source/blender/python/mathutils/mathutils_Color.c | 20 ++++---- source/blender/python/mathutils/mathutils_Color.h | 4 +- source/blender/python/mathutils/mathutils_Euler.c | 16 +++--- source/blender/python/mathutils/mathutils_Euler.h | 4 +- source/blender/python/mathutils/mathutils_Matrix.c | 60 +++++++++++----------- source/blender/python/mathutils/mathutils_Matrix.h | 4 +- .../python/mathutils/mathutils_Quaternion.c | 38 +++++++------- .../python/mathutils/mathutils_Quaternion.h | 4 +- source/blender/python/mathutils/mathutils_Vector.c | 46 ++++++++--------- source/blender/python/mathutils/mathutils_Vector.h | 4 +- .../blender/python/mathutils/mathutils_geometry.c | 30 +++++------ source/gameengine/Converter/BL_ArmatureChannel.cpp | 2 +- source/gameengine/Expressions/PyObjectPlus.cpp | 6 +-- source/gameengine/Ketsji/KX_GameObject.cpp | 24 ++++----- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 4 +- source/gameengine/Ketsji/KX_PyMath.cpp | 12 ++--- 17 files changed, 154 insertions(+), 154 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 3bde38d1445..eb7362ff8c7 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -619,11 +619,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_ALL_VECTOR_SUBTYPES: if (len>=2 && len <= 4) { if (is_thick) { - ret= newVectorObject(NULL, len, Py_NEW, NULL); + ret= Vector_CreatePyObject(NULL, len, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec); } else { - PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC); + PyObject *vec_cb= Vector_CreatePyObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC); Py_DECREF(ret); /* the vector owns now */ ret= vec_cb; /* return the vector instead */ } @@ -632,22 +632,22 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_MATRIX: if (len==16) { if (is_thick) { - ret= newMatrixObject(NULL, 4, 4, Py_NEW, NULL); + ret= Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr); } else { - PyObject *mat_cb= newMatrixObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE); + PyObject *mat_cb= Matrix_CreatePyObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ ret= mat_cb; /* return the matrix instead */ } } else if (len==9) { if (is_thick) { - ret= newMatrixObject(NULL, 3, 3, Py_NEW, NULL); + ret= Matrix_CreatePyObject(NULL, 3, 3, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr); } else { - PyObject *mat_cb= newMatrixObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE); + PyObject *mat_cb= Matrix_CreatePyObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ ret= mat_cb; /* return the matrix instead */ } @@ -661,23 +661,23 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) PropertyRNA *prop_eul_order= NULL; short order= pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ); - ret= newEulerObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA + ret= Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul); } else { /* order will be updated from callback on use */ - PyObject *eul_cb= newEulerObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA + PyObject *eul_cb= Euler_CreatePyObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA Py_DECREF(ret); /* the euler owns now */ ret= eul_cb; /* return the euler instead */ } } else if (len==4) { if (is_thick) { - ret= newQuaternionObject(NULL, Py_NEW, NULL); + ret= Quaternion_CreatePyObject(NULL, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat); } else { - PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT); + PyObject *quat_cb= Quaternion_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT); Py_DECREF(ret); /* the quat owns now */ ret= quat_cb; /* return the quat instead */ } @@ -687,11 +687,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_COLOR_GAMMA: if (len==3) { /* color */ if (is_thick) { - ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA + ret= Color_CreatePyObject(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); + PyObject *col_cb= Color_CreatePyObject_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 */ } @@ -4543,15 +4543,15 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat switch(RNA_property_subtype(prop)) { #ifdef USE_MATHUTILS case PROP_ALL_VECTOR_SUBTYPES: - ret= newVectorObject(data, len, Py_NEW, NULL); + ret= Vector_CreatePyObject(data, len, Py_NEW, NULL); break; case PROP_MATRIX: if (len==16) { - ret= newMatrixObject(data, 4, 4, Py_NEW, NULL); + ret= Matrix_CreatePyObject(data, 4, 4, Py_NEW, NULL); break; } else if (len==9) { - ret= newMatrixObject(data, 3, 3, Py_NEW, NULL); + ret= Matrix_CreatePyObject(data, 3, 3, Py_NEW, NULL); break; } /* pass through */ diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 79628cf5ae9..8409344a9fe 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -61,7 +61,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) "more then a single arg given"); return NULL; } - return newColorObject(col, Py_NEW, type); + return Color_CreatePyObject(col, Py_NEW, type); } //-----------------------------METHODS---------------------------- @@ -104,7 +104,7 @@ static PyObject *Color_copy(ColorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newColorObject(self->col, Py_NEW, Py_TYPE(self)); + return Color_CreatePyObject(self->col, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -384,7 +384,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); - return newColorObject(col, Py_NEW, Py_TYPE(v1)); + return Color_CreatePyObject(col, Py_NEW, Py_TYPE(v1)); } /* addition in-place: obj += obj */ @@ -433,7 +433,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); - return newColorObject(col, Py_NEW, Py_TYPE(v1)); + return Color_CreatePyObject(col, Py_NEW, Py_TYPE(v1)); } /* subtraction in-place: obj -= obj */ @@ -465,7 +465,7 @@ static PyObject *color_mul_float(ColorObject *color, const float scalar) { float tcol[COLOR_SIZE]; mul_vn_vn_fl(tcol, color->col, COLOR_SIZE, scalar); - return newColorObject(tcol, Py_NEW, Py_TYPE(color)); + return Color_CreatePyObject(tcol, Py_NEW, Py_TYPE(color)); } @@ -612,7 +612,7 @@ static PyObject *Color_neg(ColorObject *self) return NULL; negate_vn_vn(tcol, self->col, COLOR_SIZE); - return newColorObject(tcol, Py_NEW, Py_TYPE(self)); + return Color_CreatePyObject(tcol, Py_NEW, Py_TYPE(self)); } @@ -821,13 +821,13 @@ PyTypeObject color_Type = { NULL, //tp_weaklist NULL //tp_del }; -//------------------------newColorObject (internal)------------- +//------------------------Color_CreatePyObject (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) +PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) { ColorObject *self; @@ -860,9 +860,9 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) return (PyObject *)self; } -PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) +PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL); + ColorObject *self= (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index 6c84b5f596d..f218d653ec9 100644 --- a/source/blender/python/mathutils/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -48,7 +48,7 @@ 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); +PyObject *Color_CreatePyObject( float *col, int type, PyTypeObject *base_type); +PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); #endif /* MATHUTILS_COLOR_H */ diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index ce9ac5fbbb5..a1e18432b4b 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -71,7 +71,7 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; break; } - return newEulerObject(eul, order, Py_NEW, type); + return Euler_CreatePyObject(eul, order, Py_NEW, type); } /* internal use, assume read callback is done */ @@ -142,7 +142,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self) eulO_to_quat(quat, self->eul, self->order); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } //return a matrix representation of the euler @@ -163,7 +163,7 @@ static PyObject *Euler_to_matrix(EulerObject * self) eulO_to_mat3((float (*)[3])mat, self->eul, self->order); - return newMatrixObject(mat, 3, 3 , Py_NEW, NULL); + return Matrix_CreatePyObject(mat, 3, 3 , Py_NEW, NULL); } PyDoc_STRVAR(Euler_zero_doc, @@ -293,7 +293,7 @@ static PyObject *Euler_copy(EulerObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self)); + return Euler_CreatePyObject(self->eul, self->order, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -664,13 +664,13 @@ PyTypeObject euler_Type = { NULL, //tp_weaklist NULL //tp_del }; -//------------------------newEulerObject (internal)------------- +//------------------------Euler_CreatePyObject (internal)------------- //creates a new euler 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 *newEulerObject(float *eul, short order, int type, PyTypeObject *base_type) +PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type) { EulerObject *self; @@ -707,9 +707,9 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t return (PyObject *)self; } -PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) { - EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL); + EulerObject *self= (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 46f5910f31f..5760d08e1f6 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -50,8 +50,8 @@ 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 *newEulerObject( float *eul, short order, int type, PyTypeObject *base_type); -PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype); +PyObject *Euler_CreatePyObject( float *eul, short order, int type, PyTypeObject *base_type); +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype); short euler_order_from_string(const char *str, const char *error_prefix); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 409acdd5d5e..f5e1218aaa3 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -125,7 +125,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) switch(PyTuple_GET_SIZE(args)) { case 0: - return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, type); + return (PyObject *) Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type); case 1: { PyObject *arg= PyTuple_GET_ITEM(args, 0); @@ -140,7 +140,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (col_size >= 2 && col_size <= 4) { /* sane row & col size, new matrix and assign as slice */ - PyObject *matrix= newMatrixObject(NULL, row_size, col_size, Py_NEW, type); + PyObject *matrix= Matrix_CreatePyObject(NULL, row_size, col_size, Py_NEW, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { return matrix; } @@ -284,7 +284,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } @@ -308,7 +308,7 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) /* create a identity matrix and add translation */ unit_m4((float(*)[4]) mat); copy_v3_v3(mat + 12, tvec); /* 12, 13, 14 */ - return newMatrixObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.Scale() ------------- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -395,7 +395,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.OrthoProjection() --- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -512,7 +512,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } PyDoc_STRVAR(C_Matrix_Shear_doc, @@ -613,7 +613,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } void matrix_as_3x3(float mat[3][3], MatrixObject *self) @@ -673,7 +673,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) mat4_to_quat(quat, (float (*)[4])self->contigPtr); } - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } /*---------------------------matrix.toEuler() --------------------*/ @@ -747,7 +747,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) else mat3_to_eulO(eul, order, mat); } - return newEulerObject(eul, order, Py_NEW, NULL); + return Euler_CreatePyObject(eul, order, Py_NEW, NULL); } PyDoc_STRVAR(Matrix_resize_4x4_doc, @@ -827,12 +827,12 @@ static PyObject *Matrix_to_4x4(MatrixObject *self) return NULL; if (self->col_size==4 && self->row_size==4) { - return (PyObject *)newMatrixObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self)); + return (PyObject *)Matrix_CreatePyObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self)); } else if (self->col_size==3 && self->row_size==3) { float mat[4][4]; copy_m4_m3(mat, (float (*)[3])self->contigPtr); - return (PyObject *)newMatrixObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); + return (PyObject *)Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); } /* TODO, 2x2 matrix */ @@ -865,7 +865,7 @@ static PyObject *Matrix_to_3x3(MatrixObject *self) matrix_as_3x3(mat, self); - return newMatrixObject((float *)mat, 3, 3, Py_NEW, Py_TYPE(self)); + return Matrix_CreatePyObject((float *)mat, 3, 3, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Matrix_to_translation_doc, @@ -888,7 +888,7 @@ static PyObject *Matrix_to_translation(MatrixObject *self) return NULL; } - return newVectorObject(self->matrix[3], 3, Py_NEW, NULL); + return Vector_CreatePyObject(self->matrix[3], 3, Py_NEW, NULL); } PyDoc_STRVAR(Matrix_to_scale_doc, @@ -923,7 +923,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) /* compatible mat4_to_loc_rot_size */ mat3_to_rot_size(rot, size, mat); - return newVectorObject(size, 3, Py_NEW, NULL); + return Vector_CreatePyObject(size, 3, Py_NEW, NULL); } /*---------------------------matrix.invert() ---------------------*/ @@ -1080,9 +1080,9 @@ static PyObject *Matrix_decompose(MatrixObject *self) mat3_to_quat(quat, rot); ret= PyTuple_New(3); - PyTuple_SET_ITEM(ret, 0, newVectorObject(loc, 3, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 1, newQuaternionObject(quat, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 2, newVectorObject(size, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(loc, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 1, Quaternion_CreatePyObject(quat, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 2, Vector_CreatePyObject(size, 3, Py_NEW, NULL)); return ret; } @@ -1133,7 +1133,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) return NULL; } - return (PyObject*)newMatrixObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); + return (PyObject*)Matrix_CreatePyObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); } /*---------------------------matrix.determinant() ----------------*/ @@ -1286,7 +1286,7 @@ static PyObject *Matrix_copy(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return (PyObject*)newMatrixObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); + return (PyObject*)Matrix_CreatePyObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); } /*----------------------------print object (internal)-------------*/ @@ -1383,7 +1383,7 @@ static PyObject *Matrix_item(MatrixObject *self, int i) "array index out of range"); return NULL; } - return newVectorObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, i); + return Vector_CreatePyObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, i); } /*----------------------------object[]------------------------- sequence accessor (set) */ @@ -1428,7 +1428,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) tuple= PyTuple_New(end - begin); for (count= begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, - newVectorObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, count)); + Vector_CreatePyObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, count)); } @@ -1514,7 +1514,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) add_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->row_size * mat1->col_size); - return newMatrixObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj - obj------------------------------ subtraction*/ @@ -1547,7 +1547,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) sub_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->row_size * mat1->col_size); - return newMatrixObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj * obj------------------------------ mulplication*/ @@ -1555,7 +1555,7 @@ static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar) { float tmat[16]; mul_vn_vn_fl(tmat, mat->contigPtr, mat->row_size * mat->col_size, scalar); - return newMatrixObject(tmat, mat->row_size, mat->col_size, Py_NEW, Py_TYPE(mat)); + return Matrix_CreatePyObject(tmat, mat->row_size, mat->col_size, Py_NEW, Py_TYPE(mat)); } static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) @@ -1594,7 +1594,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } } - return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } else if (mat2) { /*FLOAT/INT * MATRIX */ @@ -1613,7 +1613,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) return NULL; } - return newVectorObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); + return Vector_CreatePyObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); } /*FLOAT/INT * MATRIX */ else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { @@ -1940,7 +1940,7 @@ PyTypeObject matrix_Type = { NULL /*tp_del*/ }; -/*------------------------newMatrixObject (internal)------------- +/*------------------------Matrix_CreatePyObject (internal)------------- creates a new matrix object self->matrix self->contiguous_ptr (reference to data.xxx) [0]------------->[0] @@ -1956,7 +1956,7 @@ self->matrix[1][1] = self->contigPtr[4] */ (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 *newMatrixObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type) +PyObject *Matrix_CreatePyObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type) { MatrixObject *self; int x, row, col; @@ -2022,9 +2022,9 @@ PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsign return (PyObject *) self; } -PyObject *newMatrixObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) +PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)newMatrixObject(NULL, rowSize, colSize, Py_NEW, NULL); + MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, rowSize, colSize, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 275f4270787..d1984d7299d 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -51,8 +51,8 @@ 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 *newMatrixObject(float *mat, const unsigned short row_size, const unsigned short col_size, int type, PyTypeObject *base_type); -PyObject *newMatrixObject_cb(PyObject *user, int row_size, int col_size, int cb_type, int cb_subtype); +PyObject *Matrix_CreatePyObject(float *mat, const unsigned short row_size, const unsigned short col_size, int type, PyTypeObject *base_type); +PyObject *Matrix_CreatePyObject_cb(PyObject *user, int row_size, int col_size, int cb_type, int cb_subtype); extern int mathutils_matrix_vector_cb_index; extern struct Mathutils_Callback mathutils_matrix_vector_cb; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 8a6c4909e94..0b24db708e2 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -120,7 +120,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) else quat_to_eulO(eul, order, tquat); } - return newEulerObject(eul, order, Py_NEW, NULL); + return Euler_CreatePyObject(eul, order, Py_NEW, NULL); } //----------------------------Quaternion.toMatrix()------------------ PyDoc_STRVAR(Quaternion_to_matrix_doc, @@ -139,7 +139,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self) return NULL; quat_to_mat3((float (*)[3])mat, self->quat); - return newMatrixObject(mat, 3, 3, Py_NEW, NULL); + return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL); } //----------------------------Quaternion.toMatrix()------------------ @@ -169,7 +169,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) quat__axis_angle_sanitize(axis, &angle); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(axis, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(axis, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(angle)); return ret; } @@ -197,7 +197,7 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value) return NULL; mul_qt_qtqt(quat, self->quat, tquat); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } //----------------------------Quaternion.dot(other)------------------ @@ -246,7 +246,7 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject rotation_between_quats_to_quat(quat, self->quat, tquat); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Quaternion_slerp_doc, @@ -288,7 +288,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args) interp_qt_qtqt(quat, self->quat, tquat, fac); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Quaternion_rotate_doc, @@ -464,7 +464,7 @@ static PyObject *Quaternion_copy(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(self->quat, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -721,7 +721,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, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } //------------------------obj - obj------------------------------ //subtraction @@ -749,7 +749,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) quat[x] = quat1->quat[x] - quat2->quat[x]; } - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) @@ -757,7 +757,7 @@ static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) float tquat[4]; copy_qt_qt(tquat, quat->quat); mul_qt_fl(tquat, scalar); - return newQuaternionObject(tquat, Py_NEW, Py_TYPE(quat)); + return Quaternion_CreatePyObject(tquat, Py_NEW, Py_TYPE(quat)); } //------------------------obj * obj------------------------------ @@ -780,7 +780,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, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } /* the only case this can happen (for a supported type is "FLOAT*QUAT") */ else if (quat2) { /* FLOAT*QUAT */ @@ -808,7 +808,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) copy_v3_v3(tvec, vec2->vec); mul_qt_v3(quat1->quat, tvec); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); } /* QUAT * FLOAT */ else if ((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { @@ -836,7 +836,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self) return NULL; negate_v4_v4(tquat, self->quat); - return newQuaternionObject(tquat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(tquat, Py_NEW, Py_TYPE(self)); } @@ -982,7 +982,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos quat__axis_angle_sanitize(axis, NULL); - return (PyObject *) newVectorObject(axis, 3, Py_NEW, NULL); + return (PyObject *) Vector_CreatePyObject(axis, 3, Py_NEW, NULL); } static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) @@ -1045,7 +1045,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw break; /* PyArg_ParseTuple assures no more then 2 */ } - return newQuaternionObject(quat, Py_NEW, type); + return Quaternion_CreatePyObject(quat, Py_NEW, type); } static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self) @@ -1190,13 +1190,13 @@ PyTypeObject quaternion_Type = { NULL, //tp_weaklist NULL, //tp_del }; -//------------------------newQuaternionObject (internal)------------- +//------------------------Quaternion_CreatePyObject (internal)------------- //creates a new quaternion 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 *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) +PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_type) { QuaternionObject *self; @@ -1229,9 +1229,9 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) return (PyObject *) self; } -PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) +PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - QuaternionObject *self= (QuaternionObject *)newQuaternionObject(NULL, Py_NEW, NULL); + QuaternionObject *self= (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index 13060ed9ff9..a34720769fa 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -48,7 +48,7 @@ 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 *newQuaternionObject( float *quat, int type, PyTypeObject *base_type); -PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); +PyObject *Quaternion_CreatePyObject( float *quat, int type, PyTypeObject *base_type); +PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); #endif /* MATHUTILS_QUAT_H */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index d9b86658bd9..1dff33887e3 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -70,7 +70,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED "more then a single arg given"); return NULL; } - return newVectorObject(vec, size, Py_NEW, type); + return Vector_CreatePyObject(vec, size, Py_NEW, type); } static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) @@ -264,7 +264,7 @@ static PyObject *Vector_to_2d(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(self->vec, 2, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_3d_doc, ".. method:: to_3d()\n" @@ -282,7 +282,7 @@ static PyObject *Vector_to_3d(VectorObject *self) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3)); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_4d_doc, ".. method:: to_4d()\n" @@ -300,7 +300,7 @@ static PyObject *Vector_to_4d(VectorObject *self) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4)); - return newVectorObject(tvec, 4, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, 4, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_tuple_doc, @@ -475,7 +475,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) vec_to_quat(quat, vec, track, up); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } /* @@ -518,7 +518,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) normalize_v3(mirror); reflect_v3_v3v3(reflect, vec, mirror); - return newVectorObject(reflect, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(reflect, self->size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_cross_doc, @@ -544,7 +544,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) return NULL; - ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self)); + ret= (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); cross_v3_v3v3(ret->vec, self->vec, tvec); return (PyObject *)ret; } @@ -667,7 +667,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) rotation_between_vecs_to_quat(quat, vec_a, vec_b); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } PyDoc_STRVAR(Vector_project_doc, @@ -707,7 +707,7 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) for (x = 0; x < size; x++) { vec[x] = (float)dot * tvec[x]; } - return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_lerp_doc, @@ -744,7 +744,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) for (x = 0; x < size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]); } - return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_rotate_doc, @@ -793,7 +793,7 @@ static PyObject *Vector_copy(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); } static PyObject *Vector_repr(VectorObject *self) @@ -960,7 +960,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) add_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size); - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* addition in-place: obj += obj */ @@ -1023,7 +1023,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) sub_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size); - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* subtraction in-place: obj -= obj */ @@ -1108,7 +1108,7 @@ static PyObject *vector_mul_float(VectorObject *vec, const float scalar) { float tvec[MAX_DIMENSIONS]; mul_vn_vn_fl(tvec, vec->vec, vec->size, scalar); - return newVectorObject(tvec, vec->size, Py_NEW, Py_TYPE(vec)); + return Vector_CreatePyObject(tvec, vec->size, Py_NEW, Py_TYPE(vec)); } static PyObject *Vector_mul(PyObject *v1, PyObject *v2) @@ -1151,7 +1151,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) return NULL; } - return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ @@ -1177,7 +1177,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) copy_v3_v3(tvec, vec1->vec); mul_qt_v3(quat2->quat, tvec); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); #endif /* ------ to be removed ------*/ } @@ -1311,7 +1311,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) for (i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] / scalar; } - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* divide in-place: obj /= obj */ @@ -1357,7 +1357,7 @@ static PyObject *Vector_neg(VectorObject *self) return NULL; negate_vn_vn(tvec, self->vec, self->size); - return newVectorObject(tvec, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, self->size, Py_NEW, Py_TYPE(self)); } /*------------------------vec_magnitude_nosqrt (internal) - for comparing only */ @@ -1702,7 +1702,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) axis_to++; } - return newVectorObject(vec, axis_to, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, axis_to, Py_NEW, Py_TYPE(self)); } /* Set the items of this vector using a swizzle. @@ -2364,13 +2364,13 @@ PyTypeObject vector_Type = { NULL }; -/*------------------------newVectorObject (internal)------------- +/*------------------------Vector_CreatePyObject (internal)------------- creates a new vector 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 *newVectorObject(float *vec, const int size, const int type, PyTypeObject *base_type) +PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type) { VectorObject *self; @@ -2414,10 +2414,10 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje return (PyObject *) self; } -PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) +PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ - VectorObject *self= (VectorObject *)newVectorObject(dummy, size, Py_NEW, NULL); + VectorObject *self= (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h index 610805fcee0..c1550aabb25 100644 --- a/source/blender/python/mathutils/mathutils_Vector.h +++ b/source/blender/python/mathutils/mathutils_Vector.h @@ -45,7 +45,7 @@ typedef struct { } VectorObject; /*prototypes*/ -PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObject *base_type); -PyObject *newVectorObject_cb(PyObject *user, int size, int callback_type, int subtype); +PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type); +PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, int callback_type, int subtype); #endif /* MATHUTILS_VECTOR_H */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 2f79dfd9914..c5e0d2ab95d 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -158,7 +158,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* mul_v3_fl(dir, t); add_v3_v3v3(pvec, orig, dir); - return newVectorObject(pvec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(pvec, 3, Py_NEW, NULL); } /* Line-Line intersection using algorithm from mathworld.wolfram.com */ @@ -242,8 +242,8 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject } else { tuple= PyTuple_New(2); - PyTuple_SET_ITEM(tuple, 0, newVectorObject(i1, vec1->size, Py_NEW, NULL)); - PyTuple_SET_ITEM(tuple, 1, newVectorObject(i2, vec1->size, Py_NEW, NULL)); + PyTuple_SET_ITEM(tuple, 0, Vector_CreatePyObject(i1, vec1->size, Py_NEW, NULL)); + PyTuple_SET_ITEM(tuple, 1, Vector_CreatePyObject(i2, vec1->size, Py_NEW, NULL)); return tuple; } } @@ -338,7 +338,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec); } - return newVectorObject(n, 3, Py_NEW, NULL); + return Vector_CreatePyObject(n, 3, Py_NEW, NULL); } //--------------------------------- AREA FUNCTIONS-------------------- @@ -433,7 +433,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj } if (isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) { - return newVectorObject(vi, 2, Py_NEW, NULL); + return Vector_CreatePyObject(vi, 2, Py_NEW, NULL); } else { Py_RETURN_NONE; @@ -490,7 +490,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec } if (isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) { - return newVectorObject(isect, 3, Py_NEW, NULL); + return Vector_CreatePyObject(isect, 3, Py_NEW, NULL); } else { Py_RETURN_NONE; @@ -552,8 +552,8 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje normalize_v3(isect_no); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_co, 3, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_no, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_co, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_no, 3, Py_NEW, NULL)); return ret; } @@ -626,10 +626,10 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje use_b= FALSE; } - if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); } + if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } - if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); } + if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 3, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } return ret; @@ -699,10 +699,10 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO use_b= FALSE; } - if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); } + if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } - if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); } + if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 2, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } return ret; @@ -758,7 +758,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec lambda= closest_to_line_v3(pt_out, pt_in, l1, l2); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(pt_out, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda)); return ret; } @@ -939,7 +939,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); - return newVectorObject(vec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); } #ifndef MATH_STANDALONE @@ -1015,7 +1015,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* list= PyList_New(resolu); fp= coord_array; for (i=0; im_imax, Py_NEW, NULL); + return Vector_CreatePyObject(val, attrdef->m_imax, Py_NEW, NULL); #else PyObject* resultlist = PyList_New(attrdef->m_imax); for (unsigned int i=0; im_imax; i++) @@ -435,7 +435,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * return NULL; } #ifdef USE_MATHUTILS - return newMatrixObject(val, attrdef->m_imin, attrdef->m_imax, Py_WRAP, NULL); + return Matrix_CreatePyObject(val, attrdef->m_imin, attrdef->m_imax, Py_WRAP, NULL); #else PyObject* collist = PyList_New(attrdef->m_imin); for (unsigned int i=0; im_imin; i++) @@ -457,7 +457,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * MT_Vector3 *val = reinterpret_cast(ptr); #ifdef USE_MATHUTILS float fval[3]= {(*val)[0], (*val)[1], (*val)[2]}; - return newVectorObject(fval, 3, Py_NEW, NULL); + return Vector_CreatePyObject(fval, 3, Py_NEW, NULL); #else PyObject* resultlist = PyList_New(3); for (unsigned int i=0; i<3; i++) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c240a7fcf84..18b8c0d533d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -2000,7 +2000,7 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetWorldPosition()); @@ -2022,7 +2022,7 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetLocalPosition()); @@ -2044,7 +2044,7 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); #else KX_GameObject* self= static_cast(self_v); if (self->GetPhysicsController()) @@ -2056,7 +2056,7 @@ PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); + return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetWorldOrientation()); @@ -2081,7 +2081,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); + return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetLocalOrientation()); @@ -2105,7 +2105,7 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetWorldScaling()); @@ -2115,7 +2115,7 @@ PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->NodeGetLocalScaling()); @@ -2138,7 +2138,7 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(GetLinearVelocity(false)); @@ -2160,7 +2160,7 @@ int KX_GameObject::pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(GetLinearVelocity(true)); @@ -2182,7 +2182,7 @@ int KX_GameObject::pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(GetAngularVelocity(false)); @@ -2204,7 +2204,7 @@ int KX_GameObject::pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTR PyObject* KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(GetAngularVelocity(true)); @@ -2297,7 +2297,7 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE PyObject* KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); #else KX_GameObject* self= static_cast(self_v); return PyObjectFrom(self->GetObjectColor()); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index b7420b3c3f0..aed9ff2b81d 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -462,7 +462,7 @@ Mathutils_Callback mathutils_obactu_vector_cb = { PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); } int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -478,7 +478,7 @@ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); } int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index a221020c1ef..dd32284a807 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -100,7 +100,7 @@ PyObject* PyObjectFrom(const MT_Matrix4x4 &mat) #ifdef USE_MATHUTILS float fmat[16]; mat.getValue(fmat); - return newMatrixObject(fmat, 4, 4, Py_NEW, NULL); + return Matrix_CreatePyObject(fmat, 4, 4, Py_NEW, NULL); #else PyObject *collist = PyList_New(4); PyObject *col; @@ -124,7 +124,7 @@ PyObject* PyObjectFrom(const MT_Matrix3x3 &mat) #ifdef USE_MATHUTILS float fmat[9]; mat.getValue3x3(fmat); - return newMatrixObject(fmat, 3, 3, Py_NEW, NULL); + return Matrix_CreatePyObject(fmat, 3, 3, Py_NEW, NULL); #else PyObject *collist = PyList_New(3); PyObject *col; @@ -147,7 +147,7 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot) { /* NOTE, were re-ordering here for Mathutils compat */ float fvec[4]= {qrot[3], qrot[0], qrot[1], qrot[2]}; - return newQuaternionObject(fvec, Py_NEW, NULL); + return Quaternion_CreatePyObject(fvec, Py_NEW, NULL); } #endif @@ -155,7 +155,7 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec) { #ifdef USE_MATHUTILS float fvec[4]= {vec[0], vec[1], vec[2], vec[3]}; - return newVectorObject(fvec, 4, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 4, Py_NEW, NULL); #else PyObject *list = PyList_New(4); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -170,7 +170,7 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec) { #ifdef USE_MATHUTILS float fvec[3]= {vec[0], vec[1], vec[2]}; - return newVectorObject(fvec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 3, Py_NEW, NULL); #else PyObject *list = PyList_New(3); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -184,7 +184,7 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec) { #ifdef USE_MATHUTILS float fvec[2]= {vec[0], vec[1]}; - return newVectorObject(fvec, 2, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 2, Py_NEW, NULL); #else PyObject *list = PyList_New(2); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); -- cgit v1.2.3