Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/generic/mathutils_Quaternion.c')
-rw-r--r--source/blender/python/generic/mathutils_Quaternion.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c
index 42c295c0d7e..c5fb7e61e6d 100644
--- a/source/blender/python/generic/mathutils_Quaternion.c
+++ b/source/blender/python/generic/mathutils_Quaternion.c
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/python/generic/mathutils_Quaternion.c
+ * \ingroup pygen
+ */
+
+
#include <Python.h>
#include "mathutils.h"
@@ -85,7 +90,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
return NULL;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(order_str) {
@@ -100,7 +105,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
if(eul_compat) {
float mat[3][3];
- if(!BaseMath_ReadCallback(eul_compat))
+ if(BaseMath_ReadCallback(eul_compat) == -1)
return NULL;
quat_to_mat3(mat, tquat);
@@ -128,7 +133,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
{
float mat[9]; /* all values are set */
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
quat_to_mat3( (float (*)[3]) mat,self->quat);
@@ -150,7 +155,7 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
{
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.cross(other), invalid 'other' arg") == -1)
@@ -175,7 +180,7 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
{
float tquat[QUAT_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.dot(other), invalid 'other' arg") == -1)
@@ -198,7 +203,7 @@ static PyObject *Quaternion_difference(QuaternionObject *self, PyObject *value)
{
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.difference(other), invalid 'other' arg") == -1)
@@ -231,7 +236,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
return NULL;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.slerp(other), invalid 'other' arg") == -1)
@@ -260,7 +265,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
float tquat[4], length;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "quaternion.rotate(value)") == -1)
@@ -286,7 +291,7 @@ static char Quaternion_normalize_doc[] =
;
static PyObject *Quaternion_normalize(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt(self->quat);
@@ -315,7 +320,7 @@ static char Quaternion_invert_doc[] =
;
static PyObject *Quaternion_invert(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
invert_qt(self->quat);
@@ -347,7 +352,7 @@ static char Quaternion_identity_doc[] =
;
static PyObject *Quaternion_identity(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
unit_qt(self->quat);
@@ -366,7 +371,7 @@ static char Quaternion_negate_doc[] =
;
static PyObject *Quaternion_negate(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
mul_qt_fl(self->quat, -1.0f);
@@ -382,7 +387,7 @@ static char Quaternion_conjugate_doc[] =
;
static PyObject *Quaternion_conjugate(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
conjugate_qt(self->quat);
@@ -416,7 +421,7 @@ static char Quaternion_copy_doc[] =
;
static PyObject *Quaternion_copy(QuaternionObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self));
@@ -428,7 +433,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self)
{
PyObject *ret, *tuple;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Quaternion_to_tuple_ext(self, -1);
@@ -448,7 +453,7 @@ static PyObject* Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
QuaternionObject *quatA= (QuaternionObject *)a;
QuaternionObject *quatB= (QuaternionObject *)b;
- if(!BaseMath_ReadCallback(quatA) || !BaseMath_ReadCallback(quatB))
+ if(BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
return NULL;
ok= (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1;
@@ -493,7 +498,7 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
return NULL;
}
- if(!BaseMath_ReadIndexCallback(self, i))
+ if(BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->quat[i]);
@@ -517,7 +522,7 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
}
self->quat[i] = scalar;
- if(!BaseMath_WriteIndexCallback(self, i))
+ if(BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -529,7 +534,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
PyObject *tuple;
int count;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, QUAT_SIZE);
@@ -551,7 +556,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
int i, size;
float quat[QUAT_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, QUAT_SIZE);
@@ -654,7 +659,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
- if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
+ if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
@@ -676,7 +681,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject*)q1;
quat2 = (QuaternionObject*)q2;
- if(!BaseMath_ReadCallback(quat1) || !BaseMath_ReadCallback(quat2))
+ if(BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
return NULL;
for(x = 0; x < QUAT_SIZE; x++) {
@@ -703,12 +708,12 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
if(QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject*)q1;
- if(!BaseMath_ReadCallback(quat1))
+ if(BaseMath_ReadCallback(quat1) == -1)
return NULL;
}
if(QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject*)q2;
- if(!BaseMath_ReadCallback(quat2))
+ if(BaseMath_ReadCallback(quat2) == -1)
return NULL;
}
@@ -741,7 +746,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
{
float tquat[QUAT_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
negate_v4_v4(tquat, self->quat);
@@ -818,7 +823,7 @@ static int Quaternion_setAxis( QuaternionObject *self, PyObject *value, void *ty
static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(closure))
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return PyFloat_FromDouble(sqrt(dot_qtqt(self->quat, self->quat)));
@@ -828,7 +833,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur
{
float tquat[4];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt_qt(tquat, self->quat);
@@ -843,7 +848,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
float axis[3], angle_dummy;
double angle;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
len= normalize_qt_qt(tquat, self->quat);
@@ -869,7 +874,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN
axis_angle_to_quat(self->quat, axis, angle);
mul_qt_fl(self->quat, len);
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -882,7 +887,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos
float axis[3];
float angle;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
normalize_qt_qt(tquat, self->quat);
@@ -907,7 +912,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
float axis[3];
float angle;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
len= normalize_qt_qt(tquat, self->quat);
@@ -919,7 +924,7 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *
axis_angle_to_quat(self->quat, axis, angle);
mul_qt_fl(self->quat, len);
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -1119,6 +1124,7 @@ PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype)
self->cb_user= cb_user;
self->cb_type= (unsigned char)cb_type;
self->cb_subtype= (unsigned char)cb_subtype;
+ PyObject_GC_Track(self);
}
return (PyObject *)self;