style cleanup: python api

This commit is contained in:
2012-03-26 06:55:09 +00:00
parent 7c8c1a0718
commit 11d12d945e
12 changed files with 1092 additions and 1092 deletions

View File

@@ -85,7 +85,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
}
if (size > array_max || size < array_min) {
if (array_max == array_min) {
if (array_max == array_min) {
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d",
error_prefix, size, array_max);
@@ -115,15 +115,15 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
size = PySequence_Fast_GET_SIZE(value_fast);
if (size > array_max || size < array_min) {
if (array_max == array_min) {
if (array_max == array_min) {
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected %d",
error_prefix, size, array_max);
"%.200s: sequence size is %d, expected %d",
error_prefix, size, array_max);
}
else {
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected [%d - %d]",
error_prefix, size, array_min, array_max);
"%.200s: sequence size is %d, expected [%d - %d]",
error_prefix, size, array_min, array_max);
}
Py_DECREF(value_fast);
return -1;
@@ -239,21 +239,22 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
/* Utility functions */
// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
#define SIGNMASK(i) (-(int)(((unsigned int)(i))>>31))
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
{ // solid, fast routine across all platforms
// with constant time behavior
{
/* solid, fast routine across all platforms
* with constant time behavior */
int ai = *(int *)(&af);
int bi = *(int *)(&bf);
int test = SIGNMASK(ai^bi);
int test = SIGNMASK(ai ^ bi);
int diff, v1, v2;
assert((0 == test) || (0xFFFFFFFF == test));
diff = (ai ^ (test & 0x7fffffff)) - bi;
v1 = maxDiff + diff;
v2 = maxDiff - diff;
return (v1|v2) >= 0;
return (v1 | v2) >= 0;
}
/*---------------------- EXPP_VectorsAreEqual -------------------------
@@ -376,7 +377,7 @@ PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (read-only).\n\n:type: boolean";
PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure))
{
return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1:0);
return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1 : 0);
}
int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg)
@@ -445,14 +446,14 @@ PyMODINIT_FUNC PyInit_mathutils(void)
submodule = PyModule_Create(&M_Mathutils_module_def);
/* each type has its own new() function */
PyModule_AddObject(submodule, "Vector", (PyObject *)&vector_Type);
PyModule_AddObject(submodule, "Matrix", (PyObject *)&matrix_Type);
PyModule_AddObject(submodule, "Euler", (PyObject *)&euler_Type);
PyModule_AddObject(submodule, "Quaternion", (PyObject *)&quaternion_Type);
PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type);
PyModule_AddObject(submodule, "Vector", (PyObject *)&vector_Type);
PyModule_AddObject(submodule, "Matrix", (PyObject *)&matrix_Type);
PyModule_AddObject(submodule, "Euler", (PyObject *)&euler_Type);
PyModule_AddObject(submodule, "Quaternion", (PyObject *)&quaternion_Type);
PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type);
/* submodule */
PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry()));
PyModule_AddObject(submodule, "geometry", (item = PyInit_mathutils_geometry()));
/* XXX, python doesnt do imports with this usefully yet
* 'from mathutils.geometry import PolyFill'
* ...fails without this. */
@@ -460,7 +461,7 @@ PyMODINIT_FUNC PyInit_mathutils(void)
Py_INCREF(item);
/* Noise submodule */
PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise()));
PyModule_AddObject(submodule, "noise", (item = PyInit_mathutils_noise()));
PyDict_SetItemString(sys_modules, "mathutils.noise", item);
Py_INCREF(item);

View File

@@ -50,17 +50,17 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 1:
if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
case 0:
break;
case 1:
if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError,
"mathutils.Color(): "
"more then a single arg given");
return NULL;
break;
default:
PyErr_SetString(PyExc_TypeError,
"mathutils.Color(): "
"more then a single arg given");
return NULL;
}
return Color_CreatePyObject(col, Py_NEW, type);
}
@@ -358,16 +358,16 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
//-----------------PROTCOL DECLARATIONS--------------------------
static PySequenceMethods Color_SeqMethods = {
(lenfunc) Color_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Color_item, /* sq_item */
NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Color_ass_item, /* sq_ass_item */
NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
(lenfunc) Color_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Color_item, /* sq_item */
NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Color_ass_item, /* sq_ass_item */
NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PyMappingMethods Color_AsMapping = {
@@ -490,12 +490,12 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2)
ColorObject *color1 = NULL, *color2 = NULL;
float scalar;
if ColorObject_Check(v1) {
if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1;
if (BaseMath_ReadCallback(color1) == -1)
return NULL;
}
if ColorObject_Check(v2) {
if (ColorObject_Check(v2)) {
color2 = (ColorObject *)v2;
if (BaseMath_ReadCallback(color2) == -1)
return NULL;
@@ -532,7 +532,7 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
ColorObject *color1 = NULL;
float scalar;
if ColorObject_Check(v1) {
if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1;
if (BaseMath_ReadCallback(color1) == -1)
return NULL;
@@ -633,40 +633,40 @@ static PyObject *Color_neg(ColorObject *self)
static PyNumberMethods Color_NumMethods = {
(binaryfunc) Color_add, /*nb_add*/
(binaryfunc) Color_sub, /*nb_subtract*/
(binaryfunc) Color_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(binaryfunc) Color_add, /*nb_add*/
(binaryfunc) Color_sub, /*nb_subtract*/
(binaryfunc) Color_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(unaryfunc) Color_neg, /*nb_negative*/
(unaryfunc) NULL, /*tp_positive*/
(unaryfunc) NULL, /*tp_absolute*/
(inquiry) NULL, /*tp_bool*/
(unaryfunc) NULL, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)NULL, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
Color_iadd, /* nb_inplace_add */
Color_isub, /* nb_inplace_subtract */
Color_imul, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
Color_div, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
Color_idiv, /* nb_inplace_true_divide */
NULL, /* nb_index */
(unaryfunc) NULL, /*tp_positive*/
(unaryfunc) NULL, /*tp_absolute*/
(inquiry) NULL, /*tp_bool*/
(unaryfunc) NULL, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)NULL, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
Color_iadd, /* nb_inplace_add */
Color_isub, /* nb_inplace_subtract */
Color_imul, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
Color_div, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
Color_idiv, /* nb_inplace_true_divide */
NULL, /* nb_index */
};
/* color channel, vector.r/g/b */
@@ -679,7 +679,7 @@ static PyObject *Color_channel_get(ColorObject *self, void *type)
return Color_item(self, GET_INT_FROM_POINTER(type));
}
static int Color_channel_set(ColorObject *self, PyObject *value, void * type)
static int Color_channel_set(ColorObject *self, PyObject *value, void *type)
{
return Color_ass_item(self, GET_INT_FROM_POINTER(type), value);
}
@@ -702,7 +702,7 @@ static PyObject *Color_channel_hsv_get(ColorObject *self, void *type)
return PyFloat_FromDouble(hsv[i]);
}
static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void * type)
static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void *type)
{
float hsv[3];
int i = GET_INT_FROM_POINTER(type);
@@ -800,51 +800,51 @@ PyDoc_STRVAR(color_doc,
);
PyTypeObject color_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Color", //tp_name
sizeof(ColorObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Color_repr, //tp_repr
&Color_NumMethods, //tp_as_number
&Color_SeqMethods, //tp_as_sequence
&Color_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Color_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
"mathutils.Color", //tp_name
sizeof(ColorObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Color_repr, //tp_repr
&Color_NumMethods, //tp_as_number
&Color_SeqMethods, //tp_as_sequence
&Color_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Color_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
color_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Color_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Color_methods, //tp_methods
NULL, //tp_members
Color_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Color_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL //tp_del
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Color_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Color_methods, //tp_methods
NULL, //tp_members
Color_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Color_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL //tp_del
};
//------------------------Color_CreatePyObject (internal)-------------
//creates a new color object
@@ -856,8 +856,8 @@ PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type)
{
ColorObject *self;
self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) :
(ColorObject *)PyObject_GC_New(ColorObject, &color_Type);
self = base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) :
(ColorObject *)PyObject_GC_New(ColorObject, &color_Type);
if (self) {
/* init callbacks as NULL */

View File

@@ -61,16 +61,16 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 2:
if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
return NULL;
case 0:
break;
case 2:
if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
return NULL;
/* intentionally pass through */
case 1:
if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1)
return NULL;
break;
case 1:
if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1)
return NULL;
break;
}
return Euler_CreatePyObject(eul, order, Py_NEW, type);
}
@@ -86,12 +86,12 @@ short euler_order_from_string(const char *str, const char *error_prefix)
{
if ((str[0] && str[1] && str[2] && str[3] == '\0')) {
switch (*((PY_INT32_T *)str)) {
case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ;
case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY;
case 'Y'|'X'<<8|'Z'<<16: return EULER_ORDER_YXZ;
case 'Y'|'Z'<<8|'X'<<16: return EULER_ORDER_YZX;
case 'Z'|'X'<<8|'Y'<<16: return EULER_ORDER_ZXY;
case 'Z'|'Y'<<8|'X'<<16: return EULER_ORDER_ZYX;
case 'X' | 'Y' << 8 | 'Z' << 16: return EULER_ORDER_XYZ;
case 'X' | 'Z' << 8 | 'Y' << 16: return EULER_ORDER_XZY;
case 'Y' | 'X' << 8 | 'Z' << 16: return EULER_ORDER_YXZ;
case 'Y' | 'Z' << 8 | 'X' << 16: return EULER_ORDER_YZX;
case 'Z' | 'X' << 8 | 'Y' << 16: return EULER_ORDER_ZXY;
case 'Z' | 'Y' << 8 | 'X' << 16: return EULER_ORDER_ZYX;
}
}
@@ -164,7 +164,7 @@ static PyObject *Euler_to_matrix(EulerObject *self)
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
return Matrix_CreatePyObject(mat, 3, 3 , Py_NEW, NULL);
return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL);
}
PyDoc_STRVAR(Euler_zero_doc,
@@ -550,16 +550,16 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
//-----------------PROTCOL DECLARATIONS--------------------------
static PySequenceMethods Euler_SeqMethods = {
(lenfunc) Euler_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Euler_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Euler_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
(lenfunc) Euler_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Euler_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Euler_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PyMappingMethods Euler_AsMapping = {
@@ -643,51 +643,51 @@ PyDoc_STRVAR(euler_doc,
);
PyTypeObject euler_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Euler", //tp_name
sizeof(EulerObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Euler_repr, //tp_repr
NULL, //tp_as_number
&Euler_SeqMethods, //tp_as_sequence
&Euler_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Euler_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
"mathutils.Euler", //tp_name
sizeof(EulerObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Euler_repr, //tp_repr
NULL, //tp_as_number
&Euler_SeqMethods, //tp_as_sequence
&Euler_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Euler_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
euler_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Euler_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Euler_methods, //tp_methods
NULL, //tp_members
Euler_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Euler_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL //tp_del
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Euler_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Euler_methods, //tp_methods
NULL, //tp_members
Euler_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Euler_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL //tp_del
};
//------------------------Euler_CreatePyObject (internal)-------------
//creates a new euler object
@@ -699,8 +699,8 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *
{
EulerObject *self;
self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
self = base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
if (self) {
/* init callbacks as NULL */

View File

@@ -431,8 +431,8 @@ static PyObject *C_Matrix_Identity(PyObject *cls, PyObject *args)
if (matSize < 2 || matSize > 4) {
PyErr_SetString(PyExc_RuntimeError,
"Matrix.Identity(): "
"size must be between 2 and 4");
"Matrix.Identity(): "
"size must be between 2 and 4");
return NULL;
}
@@ -461,9 +461,9 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
int matSize;
double angle; /* use double because of precision problems at high values */
float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) {
return NULL;
@@ -549,7 +549,7 @@ PyDoc_STRVAR(C_Matrix_Translation_doc,
);
static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
{
float mat[4][4]= MAT4_UNITY;
float mat[4][4] = MAT4_UNITY;
if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1)
return NULL;
@@ -601,7 +601,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
return NULL;
}
}
if (vec == NULL) { //scaling along axis
if (vec == NULL) { //scaling along axis
if (matSize == 2) {
mat[0] = factor;
mat[3] = factor;
@@ -612,8 +612,9 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
mat[8] = factor;
}
}
else { //scaling in arbitrary direction
//normalize arbitrary axis
else {
/* scaling in arbitrary direction
* normalize arbitrary axis */
float norm = 0.0f;
int x;
for (x = 0; x < vec_size; x++) {
@@ -624,21 +625,21 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
tvec[x] /= norm;
}
if (matSize == 2) {
mat[0] = 1 + ((factor - 1) *(tvec[0] * tvec[0]));
mat[1] = ((factor - 1) *(tvec[0] * tvec[1]));
mat[2] = ((factor - 1) *(tvec[0] * tvec[1]));
mat[3] = 1 + ((factor - 1) *(tvec[1] * tvec[1]));
mat[0] = 1 + ((factor - 1) * (tvec[0] * tvec[0]));
mat[1] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[2] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[3] = 1 + ((factor - 1) * (tvec[1] * tvec[1]));
}
else {
mat[0] = 1 + ((factor - 1) *(tvec[0] * tvec[0]));
mat[1] = ((factor - 1) *(tvec[0] * tvec[1]));
mat[2] = ((factor - 1) *(tvec[0] * tvec[2]));
mat[3] = ((factor - 1) *(tvec[0] * tvec[1]));
mat[4] = 1 + ((factor - 1) *(tvec[1] * tvec[1]));
mat[5] = ((factor - 1) *(tvec[1] * tvec[2]));
mat[6] = ((factor - 1) *(tvec[0] * tvec[2]));
mat[7] = ((factor - 1) *(tvec[1] * tvec[2]));
mat[8] = 1 + ((factor - 1) *(tvec[2] * tvec[2]));
mat[0] = 1 + ((factor - 1) * (tvec[0] * tvec[0]));
mat[1] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[2] = ((factor - 1) * (tvec[0] * tvec[2]));
mat[3] = ((factor - 1) * (tvec[0] * tvec[1]));
mat[4] = 1 + ((factor - 1) * (tvec[1] * tvec[1]));
mat[5] = ((factor - 1) * (tvec[1] * tvec[2]));
mat[6] = ((factor - 1) * (tvec[0] * tvec[2]));
mat[7] = ((factor - 1) * (tvec[1] * tvec[2]));
mat[8] = 1 + ((factor - 1) * (tvec[2] * tvec[2]));
}
}
if (matSize == 4) {
@@ -684,7 +685,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
return NULL;
}
if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane
if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane
Py_ssize_t plane_len;
const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len);
if (matSize == 2) {
@@ -971,10 +972,10 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
}
/*must be 3-4 cols, 3-4 rows, square matrix */
if (self->num_row ==3 && self->num_col ==3) {
if (self->num_row == 3 && self->num_col == 3) {
mat = (float (*)[3])self->matrix;
}
else if (self->num_row ==4 && self->num_col ==4) {
else if (self->num_row == 4 && self->num_col == 4) {
copy_m3_m4(tmat, (float (*)[4])self->matrix);
mat = tmat;
}
@@ -993,12 +994,12 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
}
if (eul_compat) {
if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat);
else mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat);
else mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
}
else {
if (order == 1) mat3_to_eul(eul, mat);
else mat3_to_eulO(eul, order, mat);
if (order == 1) mat3_to_eul(eul, mat);
else mat3_to_eulO(eul, order, mat);
}
return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
@@ -1202,10 +1203,10 @@ static PyObject *Matrix_invert(MatrixObject *self)
mat[3] = MATRIX_ITEM(self, 0, 0);
}
else if (self->num_col == 3) {
adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->matrix);
adjoint_m3_m3((float (*)[3])mat, (float (*)[3])self->matrix);
}
else if (self->num_col == 4) {
adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->matrix);
adjoint_m4_m4((float (*)[4])mat, (float (*)[4])self->matrix);
}
/* divide by determinate */
for (x = 0; x < (self->num_col * self->num_row); x++) {
@@ -1536,17 +1537,17 @@ static PyObject *Matrix_repr(MatrixObject *self)
}
}
switch (self->num_row) {
case 2: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R))", rows[0], rows[1]);
case 2: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R))", rows[0], rows[1]);
case 3: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n"
" %R))", rows[0], rows[1], rows[2]);
case 3: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n"
" %R))", rows[0], rows[1], rows[2]);
case 4: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n"
" %R,\n"
" %R))", rows[0], rows[1], rows[2], rows[3]);
case 4: return PyUnicode_FromFormat("Matrix((%R,\n"
" %R,\n"
" %R,\n"
" %R))", rows[0], rows[1], rows[2], rows[3]);
}
Py_FatalError("Matrix(): invalid row size!");
@@ -1905,8 +1906,8 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
if (mat1->num_col != mat2->num_row) {
PyErr_SetString(PyExc_ValueError,
"matrix1 * matrix2: matrix1 number of columns "
"and the matrix2 number of rows must be the same");
"matrix1 * matrix2: matrix1 number of columns "
"and the matrix2 number of rows must be the same");
return NULL;
}
@@ -1966,16 +1967,16 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
/*-----------------PROTOCOL DECLARATIONS--------------------------*/
static PySequenceMethods Matrix_SeqMethods = {
(lenfunc) Matrix_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Matrix_item_row, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Matrix_ass_item_row, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
(lenfunc) Matrix_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Matrix_item_row, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Matrix_ass_item_row, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
@@ -2056,40 +2057,40 @@ static PyMappingMethods Matrix_AsMapping = {
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/
(binaryfunc) Matrix_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(unaryfunc) 0, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) Matrix_inverted, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */
(binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/
(binaryfunc) Matrix_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(unaryfunc) 0, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) Matrix_inverted, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */
};
PyDoc_STRVAR(Matrix_translation_doc,
@@ -2233,7 +2234,7 @@ static PyGetSetDef Matrix_getseters[] = {
{(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL},
{(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL},
{(char *)"owner",(getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
@@ -2285,51 +2286,51 @@ PyDoc_STRVAR(matrix_doc,
);
PyTypeObject matrix_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Matrix", /*tp_name*/
sizeof(MatrixObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)BaseMathObject_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
(reprfunc) Matrix_repr, /*tp_repr*/
&Matrix_NumMethods, /*tp_as_number*/
&Matrix_SeqMethods, /*tp_as_sequence*/
&Matrix_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/
NULL, /*tp_call*/
(reprfunc) Matrix_str, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
"mathutils.Matrix", /*tp_name*/
sizeof(MatrixObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)BaseMathObject_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
(reprfunc) Matrix_repr, /*tp_repr*/
&Matrix_NumMethods, /*tp_as_number*/
&Matrix_SeqMethods, /*tp_as_sequence*/
&Matrix_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/
NULL, /*tp_call*/
(reprfunc) Matrix_str, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
matrix_doc, /*tp_doc*/
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
NULL, /*tp_iter*/
NULL, /*tp_iternext*/
Matrix_methods, /*tp_methods*/
NULL, /*tp_members*/
Matrix_getseters, /*tp_getset*/
NULL, /*tp_base*/
NULL, /*tp_dict*/
NULL, /*tp_descr_get*/
NULL, /*tp_descr_set*/
0, /*tp_dictoffset*/
NULL, /*tp_init*/
NULL, /*tp_alloc*/
Matrix_new, /*tp_new*/
NULL, /*tp_free*/
NULL, /*tp_is_gc*/
NULL, /*tp_bases*/
NULL, /*tp_mro*/
NULL, /*tp_cache*/
NULL, /*tp_subclasses*/
NULL, /*tp_weaklist*/
NULL /*tp_del*/
matrix_doc, /*tp_doc*/
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
NULL, /*tp_iter*/
NULL, /*tp_iternext*/
Matrix_methods, /*tp_methods*/
NULL, /*tp_members*/
Matrix_getseters, /*tp_getset*/
NULL, /*tp_base*/
NULL, /*tp_dict*/
NULL, /*tp_descr_get*/
NULL, /*tp_descr_set*/
0, /*tp_dictoffset*/
NULL, /*tp_init*/
NULL, /*tp_alloc*/
Matrix_new, /*tp_new*/
NULL, /*tp_free*/
NULL, /*tp_is_gc*/
NULL, /*tp_bases*/
NULL, /*tp_mro*/
NULL, /*tp_cache*/
NULL, /*tp_subclasses*/
NULL, /*tp_weaklist*/
NULL /*tp_del*/
};
/* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER
@@ -2374,7 +2375,7 @@ PyObject *Matrix_CreatePyObject(float *mat,
return NULL;
}
if (mat) { /*if a float array passed*/
if (mat) { /*if a float array passed*/
memcpy(self->matrix, mat, num_col * num_row * sizeof(float));
}
else if (num_col == num_row) {
@@ -2448,8 +2449,8 @@ static void MatrixAccess_dealloc(MatrixAccessObject *self)
static int MatrixAccess_len(MatrixAccessObject *self)
{
return (self->type == MAT_ACCESS_ROW) ?
self->matrix_user->num_row :
self->matrix_user->num_col;
self->matrix_user->num_row :
self->matrix_user->num_col;
}
static PyObject *MatrixAccess_slice(MatrixAccessObject *self, int begin, int end)
@@ -2585,30 +2586,30 @@ static PyMappingMethods MatrixAccess_AsMapping = {
PyTypeObject matrix_access_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"MatrixAccess", /*tp_name*/
sizeof(MatrixAccessObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)MatrixAccess_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
NULL, /*tp_repr*/
NULL, /*tp_as_number*/
NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/
&MatrixAccess_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/
NULL, /*tp_call*/
NULL, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
"MatrixAccess", /*tp_name*/
sizeof(MatrixAccessObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)MatrixAccess_dealloc, /*tp_dealloc*/
NULL, /*tp_print*/
NULL, /*tp_getattr*/
NULL, /*tp_setattr*/
NULL, /*tp_compare*/
NULL, /*tp_repr*/
NULL, /*tp_as_number*/
NULL /*&MatrixAccess_SeqMethods*/ /* TODO */, /*tp_as_sequence*/
&MatrixAccess_AsMapping, /*tp_as_mapping*/
NULL, /*tp_hash*/
NULL, /*tp_call*/
NULL, /*tp_str*/
NULL, /*tp_getattro*/
NULL, /*tp_setattro*/
NULL, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
NULL, /*tp_doc*/
(traverseproc)MatrixAccess_traverse, //tp_traverse
(inquiry)MatrixAccess_clear, //tp_clear
NULL, /*tp_doc*/
(traverseproc)MatrixAccess_traverse, //tp_traverse
(inquiry)MatrixAccess_clear, //tp_clear
NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_weaklistoffset*/
(getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */
};

View File

@@ -113,12 +113,12 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
quat_to_mat3(mat, tquat);
if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat);
if (order == EULER_ORDER_XYZ) mat3_to_compatible_eul(eul, eul_compat->eul, mat);
else mat3_to_compatible_eulO(eul, eul_compat->eul, order, mat);
}
else {
if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
else quat_to_eulO(eul, order, tquat);
if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
else quat_to_eulO(eul, order, tquat);
}
return Euler_CreatePyObject(eul, order, Py_NEW, NULL);
@@ -741,8 +741,8 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name);
return NULL;
}
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
@@ -766,8 +766,8 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
return NULL;
}
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
@@ -795,12 +795,12 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
QuaternionObject *quat1 = NULL, *quat2 = NULL;
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject*)q1;
quat1 = (QuaternionObject *)q1;
if (BaseMath_ReadCallback(quat1) == -1)
return NULL;
}
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject*)q2;
quat2 = (QuaternionObject *)q2;
if (BaseMath_ReadCallback(quat2) == -1)
return NULL;
}
@@ -823,8 +823,8 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
if (vec2->size != 3) {
PyErr_SetString(PyExc_ValueError,
"Vector multiplication: "
"only 3D vector rotations (with quats) "
"Vector multiplication: "
"only 3D vector rotations (with quats) "
"currently supported");
return NULL;
}
@@ -869,16 +869,16 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
//-----------------PROTOCOL DECLARATIONS--------------------------
static PySequenceMethods Quaternion_SeqMethods = {
(lenfunc) Quaternion_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Quaternion_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
(lenfunc) Quaternion_len, /* sq_length */
(binaryfunc) NULL, /* sq_concat */
(ssizeargfunc) NULL, /* sq_repeat */
(ssizeargfunc) Quaternion_item, /* sq_item */
(ssizessizeargfunc) NULL, /* sq_slice, deprecated */
(ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */
(ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */
(objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */
(ssizeargfunc) NULL, /* sq_inplace_repeat */
};
static PyMappingMethods Quaternion_AsMapping = {
@@ -888,40 +888,40 @@ static PyMappingMethods Quaternion_AsMapping = {
};
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/
(binaryfunc) Quaternion_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(unaryfunc) Quaternion_neg, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) 0, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */
(binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/
(binaryfunc) Quaternion_mul, /*nb_multiply*/
NULL, /*nb_remainder*/
NULL, /*nb_divmod*/
NULL, /*nb_power*/
(unaryfunc) Quaternion_neg, /*nb_negative*/
(unaryfunc) 0, /*tp_positive*/
(unaryfunc) 0, /*tp_absolute*/
(inquiry) 0, /*tp_bool*/
(unaryfunc) 0, /*nb_invert*/
NULL, /*nb_lshift*/
(binaryfunc)0, /*nb_rshift*/
NULL, /*nb_and*/
NULL, /*nb_xor*/
NULL, /*nb_or*/
NULL, /*nb_int*/
NULL, /*nb_reserved*/
NULL, /*nb_float*/
NULL, /* nb_inplace_add */
NULL, /* nb_inplace_subtract */
NULL, /* nb_inplace_multiply */
NULL, /* nb_inplace_remainder */
NULL, /* nb_inplace_power */
NULL, /* nb_inplace_lshift */
NULL, /* nb_inplace_rshift */
NULL, /* nb_inplace_and */
NULL, /* nb_inplace_xor */
NULL, /* nb_inplace_or */
NULL, /* nb_floor_divide */
NULL, /* nb_true_divide */
NULL, /* nb_inplace_floor_divide */
NULL, /* nb_inplace_true_divide */
NULL, /* nb_index */
};
PyDoc_STRVAR(Quaternion_axis_doc,
@@ -1070,19 +1070,19 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
return NULL;
switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 1:
if (mathutils_array_parse(quat, QUAT_SIZE, QUAT_SIZE, seq, "mathutils.Quaternion()") == -1)
return NULL;
break;
case 2:
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
return NULL;
angle = angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, quat, angle);
break;
/* PyArg_ParseTuple assures no more then 2 */
case 0:
break;
case 1:
if (mathutils_array_parse(quat, QUAT_SIZE, QUAT_SIZE, seq, "mathutils.Quaternion()") == -1)
return NULL;
break;
case 2:
if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1)
return NULL;
angle = angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, quat, angle);
break;
/* PyArg_ParseTuple assures no more then 2 */
}
return Quaternion_CreatePyObject(quat, Py_NEW, type);
}
@@ -1172,7 +1172,7 @@ static PyGetSetDef Quaternion_getseters[] = {
{(char *)"z", (getter)Quaternion_axis_get, (setter)Quaternion_axis_set, Quaternion_axis_doc, (void *)3},
{(char *)"magnitude", (getter)Quaternion_magnitude_get, (setter)NULL, Quaternion_magnitude_doc, NULL},
{(char *)"angle", (getter)Quaternion_angle_get, (setter)Quaternion_angle_set, Quaternion_angle_doc, NULL},
{(char *)"axis",(getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, NULL},
{(char *)"axis", (getter)Quaternion_axis_vector_get, (setter)Quaternion_axis_vector_set, Quaternion_axis_vector_doc, NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL},
{(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
@@ -1184,51 +1184,51 @@ PyDoc_STRVAR(quaternion_doc,
);
PyTypeObject quaternion_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"mathutils.Quaternion", //tp_name
sizeof(QuaternionObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Quaternion_repr, //tp_repr
&Quaternion_NumMethods, //tp_as_number
&Quaternion_SeqMethods, //tp_as_sequence
&Quaternion_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Quaternion_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
"mathutils.Quaternion", //tp_name
sizeof(QuaternionObject), //tp_basicsize
0, //tp_itemsize
(destructor)BaseMathObject_dealloc, //tp_dealloc
NULL, //tp_print
NULL, //tp_getattr
NULL, //tp_setattr
NULL, //tp_compare
(reprfunc) Quaternion_repr, //tp_repr
&Quaternion_NumMethods, //tp_as_number
&Quaternion_SeqMethods, //tp_as_sequence
&Quaternion_AsMapping, //tp_as_mapping
NULL, //tp_hash
NULL, //tp_call
(reprfunc) Quaternion_str, //tp_str
NULL, //tp_getattro
NULL, //tp_setattro
NULL, //tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags
quaternion_doc, //tp_doc
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Quaternion_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Quaternion_methods, //tp_methods
NULL, //tp_members
Quaternion_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Quaternion_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL, //tp_del
(traverseproc)BaseMathObject_traverse, //tp_traverse
(inquiry)BaseMathObject_clear, //tp_clear
(richcmpfunc)Quaternion_richcmpr, //tp_richcompare
0, //tp_weaklistoffset
NULL, //tp_iter
NULL, //tp_iternext
Quaternion_methods, //tp_methods
NULL, //tp_members
Quaternion_getseters, //tp_getset
NULL, //tp_base
NULL, //tp_dict
NULL, //tp_descr_get
NULL, //tp_descr_set
0, //tp_dictoffset
NULL, //tp_init
NULL, //tp_alloc
Quaternion_new, //tp_new
NULL, //tp_free
NULL, //tp_is_gc
NULL, //tp_bases
NULL, //tp_mro
NULL, //tp_cache
NULL, //tp_subclasses
NULL, //tp_weaklist
NULL, //tp_del
};
//------------------------Quaternion_CreatePyObject (internal)-------------
//creates a new quaternion object

File diff suppressed because it is too large Load Diff

View File

@@ -627,10 +627,10 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
}
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); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
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); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret;
}
@@ -700,10 +700,10 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
}
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); }
else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); }
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); }
else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); }
return ret;
}
@@ -745,13 +745,13 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
}
/* accept 2d verts */
if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec);}
if (pt->size == 3) { copy_v3_v3(pt_in, pt->vec); }
else { pt_in[2] = 0.0f; copy_v2_v2(pt_in, pt->vec); }
if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec);}
if (line_1->size == 3) { copy_v3_v3(l1, line_1->vec); }
else { l1[2] = 0.0f; copy_v2_v2(l1, line_1->vec); }
if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec);}
if (line_2->size == 3) { copy_v3_v3(l2, line_2->vec); }
else { l2[2] = 0.0f; copy_v2_v2(l2, line_2->vec); }
/* do the calculation */
@@ -937,8 +937,8 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
}
barycentric_transform(vec, vec_pt->vec,
vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec,
vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec);
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 Vector_CreatePyObject(vec, 3, Py_NEW, NULL);
}
@@ -1010,7 +1010,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject
coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier");
for (i = 0; i < dims; i++) {
forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float)*dims);
forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array + i, resolu - 1, sizeof(float) * dims);
}
list = PyList_New(resolu);
@@ -1095,7 +1095,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
if (((VectorObject *)polyVec)->size > 2)
fp[2] = ((VectorObject *)polyVec)->vec[2];
else
fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
}
else {
ls_error = 1;

View File

@@ -112,13 +112,13 @@
/* Period parameters */
#define N 624
#define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define UMASK 0x80000000UL /* most significant w-r bits */
#define LMASK 0x7fffffffUL /* least significant r bits */
#define MIXBITS(u,v) (((u) & UMASK) | ((v) & LMASK))
#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define UMASK 0x80000000UL /* most significant w-r bits */
#define LMASK 0x7fffffffUL /* least significant r bits */
#define MIXBITS(u, v) (((u) & UMASK) | ((v) & LMASK))
#define TWIST(u, v) ((MIXBITS(u, v) >> 1) ^ ((v) & 1UL ? MATRIX_A : 0UL))
static unsigned long state[N]; /* the array for the state vector */
static unsigned long state[N]; /* the array for the state vector */
static int left = 1;
static int initf = 0;
static unsigned long *next;
@@ -130,13 +130,13 @@ static void init_genrand(unsigned long s)
state[0] = s & 0xffffffffUL;
for (j = 1; j < N; j++) {
state[j] =
(1812433253UL *
(state[j - 1] ^ (state[j - 1] >> 30)) + j);
(1812433253UL *
(state[j - 1] ^ (state[j - 1] >> 30)) + j);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array state[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
state[j] &= 0xffffffffUL; /* for >32 bit machines */
state[j] &= 0xffffffffUL; /* for >32 bit machines */
}
left = 1;
initf = 1;
@@ -215,7 +215,7 @@ static void noise_vector(float x, float y, float z, int nb, float v[3])
/* Returns a turbulence value for a given position (x, y, z) */
static float turb(float x, float y, float z, int oct, int hard, int nb,
float ampscale, float freqscale)
float ampscale, float freqscale)
{
float amp, out, t;
int i;
@@ -334,7 +334,7 @@ PyDoc_STRVAR(M_Noise_random_vector_doc,
);
static PyObject *M_Noise_random_vector(PyObject *UNUSED(self), PyObject *args)
{
float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f};
float vec[4] = {0.0f, 0.0f, 0.0f, 0.0f};
int size = 3;
if (!PyArg_ParseTuple(args, "|i:random_vector", &size))
@@ -729,7 +729,7 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args)
float vec[3];
float da[4], pa[12];
int dtype = 0;
float me = 2.5f; /* default minkovsky exponent */
float me = 2.5f; /* default minkovsky exponent */
int i;