Merged changes in the trunk up to revision 42116.
This commit is contained in:
@@ -385,8 +385,12 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
if (PyBytes_Check(py_str)) {
|
||||
return PyBytes_AS_STRING(py_str);
|
||||
}
|
||||
else if ((*coerce= PyUnicode_EncodeFSDefault(py_str))) {
|
||||
return PyBytes_AS_STRING(*coerce);
|
||||
}
|
||||
else {
|
||||
return PyBytes_AS_STRING((*coerce= PyUnicode_EncodeFSDefault(py_str)));
|
||||
/* leave error raised from EncodeFS */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ void BPY_python_start(int argc, const char **argv)
|
||||
PyThreadState *py_tstate= NULL;
|
||||
|
||||
/* not essential but nice to set our name */
|
||||
static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
|
||||
static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
|
||||
BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
|
||||
Py_SetProgramName(program_path_wchar);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
@@ -6376,10 +6376,14 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
|
||||
if ((order= PyDict_GetItem(class_dict, bpy_intern_str_order)) && PyList_CheckExact(order)) {
|
||||
for (pos= 0; pos<PyList_GET_SIZE(order); pos++) {
|
||||
key= PyList_GET_ITEM(order, pos);
|
||||
item= PyDict_GetItem(class_dict, key);
|
||||
ret= deferred_register_prop(srna, key, item);
|
||||
if (ret != 0)
|
||||
break;
|
||||
/* however unlikely its possible
|
||||
* fails in py 3.3 beta with __qualname__ */
|
||||
if ((item= PyDict_GetItem(class_dict, key))) {
|
||||
ret= deferred_register_prop(srna, key, item);
|
||||
if (ret != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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,
|
||||
@@ -241,7 +241,7 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
|
||||
return NULL;
|
||||
|
||||
eulO_to_mat3(self_rmat, self->eul, self->order);
|
||||
mul_m3_m3m3(rmat, self_rmat, other_rmat);
|
||||
mul_m3_m3m3(rmat, other_rmat, self_rmat);
|
||||
|
||||
mat3_to_compatible_eulO(self->eul, self->eul, self->order, rmat);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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() ---------------------*/
|
||||
@@ -1041,7 +1041,7 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value)
|
||||
}
|
||||
|
||||
matrix_as_3x3(self_rmat, self);
|
||||
mul_m3_m3m3(rmat, self_rmat, other_rmat);
|
||||
mul_m3_m3m3(rmat, other_rmat, self_rmat);
|
||||
|
||||
copy_m3_m3((float (*)[3])(self->contigPtr), rmat);
|
||||
|
||||
@@ -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() ----------------*/
|
||||
@@ -1223,7 +1223,7 @@ PyDoc_STRVAR(Matrix_zero_doc,
|
||||
);
|
||||
static PyObject *Matrix_zero(MatrixObject *self)
|
||||
{
|
||||
fill_vn(self->contigPtr, self->row_size * self->col_size, 0.0f);
|
||||
fill_vn_fl(self->contigPtr, self->row_size * self->col_size, 0.0f);
|
||||
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return NULL;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
@@ -312,7 +312,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
|
||||
|
||||
length= normalize_qt_qt(tquat, self->quat);
|
||||
quat_to_mat3(self_rmat, tquat);
|
||||
mul_m3_m3m3(rmat, self_rmat, other_rmat);
|
||||
mul_m3_m3m3(rmat, other_rmat, self_rmat);
|
||||
|
||||
mat3_to_quat(self->quat, rmat);
|
||||
mul_qt_fl(self->quat, length); /* maintain length after rotating */
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
@@ -95,7 +95,7 @@ PyDoc_STRVAR(Vector_zero_doc,
|
||||
);
|
||||
static PyObject *Vector_zero(VectorObject *self)
|
||||
{
|
||||
fill_vn(self->vec, self->size, 0.0f);
|
||||
fill_vn_fl(self->vec, self->size, 0.0f);
|
||||
|
||||
if (BaseMath_WriteCallback(self) == -1)
|
||||
return NULL;
|
||||
@@ -116,19 +116,10 @@ PyDoc_STRVAR(Vector_normalize_doc,
|
||||
);
|
||||
static PyObject *Vector_normalize(VectorObject *self)
|
||||
{
|
||||
int i;
|
||||
float norm = 0.0f;
|
||||
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < self->size; i++) {
|
||||
norm += self->vec[i] * self->vec[i];
|
||||
}
|
||||
norm = (float) sqrt(norm);
|
||||
for (i = 0; i < self->size; i++) {
|
||||
self->vec[i] /= norm;
|
||||
}
|
||||
normalize_vn(self->vec, self->size);
|
||||
|
||||
(void)BaseMath_WriteCallback(self);
|
||||
Py_RETURN_NONE;
|
||||
@@ -273,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"
|
||||
@@ -291,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"
|
||||
@@ -309,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,
|
||||
@@ -484,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -527,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,
|
||||
@@ -553,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;
|
||||
}
|
||||
@@ -571,8 +562,6 @@ PyDoc_STRVAR(Vector_dot_doc,
|
||||
static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
{
|
||||
float tvec[MAX_DIMENSIONS];
|
||||
double dot = 0.0;
|
||||
int x;
|
||||
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
@@ -580,11 +569,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
|
||||
return NULL;
|
||||
|
||||
for (x = 0; x < self->size; x++) {
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(dot);
|
||||
return PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(Vector_angle_doc,
|
||||
@@ -682,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,
|
||||
@@ -722,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,
|
||||
@@ -759,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,
|
||||
@@ -808,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)
|
||||
@@ -975,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 */
|
||||
@@ -1038,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 */
|
||||
@@ -1123,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)
|
||||
@@ -1145,9 +1130,6 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
|
||||
|
||||
/* make sure v1 is always the vector */
|
||||
if (vec1 && vec2) {
|
||||
int i;
|
||||
double dot = 0.0f;
|
||||
|
||||
if (vec1->size != vec2->size) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Vector multiplication: "
|
||||
@@ -1156,10 +1138,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
|
||||
}
|
||||
|
||||
/*dot product*/
|
||||
for (i = 0; i < vec1->size; i++) {
|
||||
dot += (double)(vec1->vec[i] * vec2->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
return PyFloat_FromDouble(dot_vn_vn(vec1->vec, vec2->vec, vec1->size));
|
||||
}
|
||||
else if (vec1) {
|
||||
if (MatrixObject_Check(v2)) {
|
||||
@@ -1172,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 */
|
||||
@@ -1198,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 ------*/
|
||||
}
|
||||
@@ -1332,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 */
|
||||
@@ -1378,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 */
|
||||
@@ -1644,7 +1623,6 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
|
||||
static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
{
|
||||
double dot = 0.0f, param;
|
||||
int i;
|
||||
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
@@ -1661,13 +1639,11 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
return -1;
|
||||
}
|
||||
if (param == 0.0) {
|
||||
fill_vn(self->vec, self->size, 0.0f);
|
||||
fill_vn_fl(self->vec, self->size, 0.0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < self->size; i++) {
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
dot= dot_vn_vn(self->vec, self->vec, self->size);
|
||||
|
||||
if (!dot) /* cant sqrt zero */
|
||||
return 0;
|
||||
@@ -1679,9 +1655,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
|
||||
dot= dot/param;
|
||||
|
||||
for (i = 0; i < self->size; i++) {
|
||||
self->vec[i]= self->vec[i] / (float)dot;
|
||||
}
|
||||
mul_vn_fl(self->vec, self->size, 1.0/dot);
|
||||
|
||||
(void)BaseMath_WriteCallback(self); /* checked already */
|
||||
|
||||
@@ -1691,16 +1665,10 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
/* vector.length_squared */
|
||||
static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure))
|
||||
{
|
||||
double dot = 0.0f;
|
||||
int i;
|
||||
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < self->size; i++) {
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
return PyFloat_FromDouble(dot_vn_vn(self->vec, self->vec, self->size));
|
||||
}
|
||||
|
||||
/* Get a new Vector according to the provided swizzle. This function has little
|
||||
@@ -1734,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.
|
||||
@@ -2396,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;
|
||||
|
||||
@@ -2432,7 +2400,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje
|
||||
memcpy(self->vec, vec, size * sizeof(float));
|
||||
}
|
||||
else { /* new empty */
|
||||
fill_vn(self->vec, size, 0.0f);
|
||||
fill_vn_fl(self->vec, size, 0.0f);
|
||||
if (size == 4) { /* do the homogenous thing */
|
||||
self->vec[3] = 1.0f;
|
||||
}
|
||||
@@ -2446,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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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; i<resolu; i++, fp= fp+dims) {
|
||||
PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL));
|
||||
PyList_SET_ITEM(list, i, Vector_CreatePyObject(fp, dims, Py_NEW, NULL));
|
||||
}
|
||||
MEM_freeN(coord_array);
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user