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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-28 21:42:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-28 21:42:41 +0300
commit7348a50d7917252a49ef26afd2e7bbfb26c49dbe (patch)
tree36817186e338f5d2b9292ef74d24bab29e9278ba /source
parent506e8aa43786f80c60979fb53ba38288cfe193ad (diff)
change return values from mathutils callbacks to match pythons (-1 is error), so error macro's can be used in both.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/generic/mathutils.c32
-rw-r--r--source/blender/python/generic/mathutils.h8
-rw-r--r--source/blender/python/generic/mathutils_Color.c24
-rw-r--r--source/blender/python/generic/mathutils_Euler.c30
-rw-r--r--source/blender/python/generic/mathutils_Matrix.c84
-rw-r--r--source/blender/python/generic/mathutils_Quaternion.c64
-rw-r--r--source/blender/python/generic/mathutils_Vector.c92
-rw-r--r--source/blender/python/generic/mathutils_geometry.c22
-rw-r--r--source/blender/python/intern/bpy_rna.c26
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp38
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp18
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h6
12 files changed, 224 insertions, 220 deletions
diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c
index 3380f9aea62..39ca9f4f8d9 100644
--- a/source/blender/python/generic/mathutils.c
+++ b/source/blender/python/generic/mathutils.c
@@ -152,7 +152,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
(QuaternionObject_Check(value) && (size= 4)) ||
(ColorObject_Check(value) && (size= 3))
) {
- if(!BaseMath_ReadCallback((BaseMathObject *)value)) {
+ if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
@@ -175,7 +175,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
{
if(EulerObject_Check(value)) {
- if(!BaseMath_ReadCallback((BaseMathObject *)value)) {
+ if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else {
@@ -184,7 +184,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
}
else if (QuaternionObject_Check(value)) {
- if(!BaseMath_ReadCallback((BaseMathObject *)value)) {
+ if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else {
@@ -195,7 +195,7 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
}
}
else if (MatrixObject_Check(value)) {
- if(!BaseMath_ReadCallback((BaseMathObject *)value)) {
+ if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
return -1;
}
else if(((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
@@ -274,45 +274,45 @@ int Mathutils_RegisterCallback(Mathutils_Callback *cb)
int _BaseMathObject_ReadCallback(BaseMathObject *self)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->get(self, self->cb_subtype))
- return 1;
+ if(cb->get(self, self->cb_subtype) != -1)
+ return 0;
if(!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name);
- return 0;
+ return -1;
}
int _BaseMathObject_WriteCallback(BaseMathObject *self)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->set(self, self->cb_subtype))
- return 1;
+ if(cb->set(self, self->cb_subtype) != -1)
+ return 0;
if(!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name);
- return 0;
+ return -1;
}
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->get_index(self, self->cb_subtype, index))
- return 1;
+ if(cb->get_index(self, self->cb_subtype, index) != -1)
+ return 0;
if(!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name);
- return 0;
+ return -1;
}
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
{
Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->set_index(self, self->cb_subtype, index))
- return 1;
+ if(cb->set_index(self, self->cb_subtype, index) != -1)
+ return 0;
if(!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name);
- return 0;
+ return -1;
}
/* BaseMathObject generic functions for all mathutils types */
diff --git a/source/blender/python/generic/mathutils.h b/source/blender/python/generic/mathutils.h
index 674aefa3705..449708d1ac1 100644
--- a/source/blender/python/generic/mathutils.h
+++ b/source/blender/python/generic/mathutils.h
@@ -99,10 +99,10 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index);
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index);
/* since this is called so often avoid where possible */
-#define BaseMath_ReadCallback(_self) (((_self)->cb_user ? _BaseMathObject_ReadCallback((BaseMathObject *)_self):1))
-#define BaseMath_WriteCallback(_self) (((_self)->cb_user ?_BaseMathObject_WriteCallback((BaseMathObject *)_self):1))
-#define BaseMath_ReadIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index):1))
-#define BaseMath_WriteIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index):1))
+#define BaseMath_ReadCallback(_self) (((_self)->cb_user ? _BaseMathObject_ReadCallback((BaseMathObject *)_self):0))
+#define BaseMath_WriteCallback(_self) (((_self)->cb_user ?_BaseMathObject_WriteCallback((BaseMathObject *)_self):0))
+#define BaseMath_ReadIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index):0))
+#define BaseMath_WriteIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index):0))
/* utility func */
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix);
diff --git a/source/blender/python/generic/mathutils_Color.c b/source/blender/python/generic/mathutils_Color.c
index 50dd6592ca4..6e699429feb 100644
--- a/source/blender/python/generic/mathutils_Color.c
+++ b/source/blender/python/generic/mathutils_Color.c
@@ -97,7 +97,7 @@ static char Color_copy_doc[] =
;
static PyObject *Color_copy(ColorObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newColorObject(self->col, Py_NEW, Py_TYPE(self));
@@ -110,7 +110,7 @@ static PyObject *Color_repr(ColorObject * self)
{
PyObject *ret, *tuple;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Color_ToTupleExt(self, -1);
@@ -132,7 +132,7 @@ static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op)
ColorObject *colA= (ColorObject*)a;
ColorObject *colB= (ColorObject*)b;
- if(!BaseMath_ReadCallback(colA) || !BaseMath_ReadCallback(colB))
+ if(BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
return NULL;
ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
@@ -177,7 +177,7 @@ static PyObject *Color_item(ColorObject * self, int i)
return NULL;
}
- if(!BaseMath_ReadIndexCallback(self, i))
+ if(BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->col[i]);
@@ -203,7 +203,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject * value)
self->col[i] = f;
- if(!BaseMath_WriteIndexCallback(self, i))
+ if(BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -215,7 +215,7 @@ static PyObject *Color_slice(ColorObject * self, int begin, int end)
PyObject *tuple;
int count;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, COLOR_SIZE);
@@ -237,7 +237,7 @@ static int Color_ass_slice(ColorObject * self, int begin, int end, PyObject * se
int i, size;
float col[COLOR_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, COLOR_SIZE);
@@ -359,7 +359,7 @@ static PyObject *Color_getChannelHSV( ColorObject * self, void *type )
float hsv[3];
int i= GET_INT_FROM_POINTER(type);
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -378,7 +378,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject * value, void * type
return -1;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -386,7 +386,7 @@ static int Color_setChannelHSV(ColorObject * self, PyObject * value, void * type
hsv[i] = f;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -398,7 +398,7 @@ static PyObject *Color_getHSV(ColorObject * self, void *UNUSED(closure))
float hsv[3];
PyObject *ret;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -423,7 +423,7 @@ static int Color_setHSV(ColorObject * self, PyObject * value, void *UNUSED(closu
hsv_to_rgb(hsv[0], hsv[1], hsv[2], &(self->col[0]), &(self->col[1]), &(self->col[2]));
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
diff --git a/source/blender/python/generic/mathutils_Euler.c b/source/blender/python/generic/mathutils_Euler.c
index c685f49842c..03d94f77269 100644
--- a/source/blender/python/generic/mathutils_Euler.c
+++ b/source/blender/python/generic/mathutils_Euler.c
@@ -138,7 +138,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self)
{
float quat[4];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
eulO_to_quat(quat, self->eul, self->order);
@@ -159,7 +159,7 @@ static PyObject *Euler_to_matrix(EulerObject * self)
{
float mat[9];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
@@ -177,7 +177,9 @@ static PyObject *Euler_zero(EulerObject * self)
{
zero_v3(self->eul);
- (void)BaseMath_WriteCallback(self);
+ if(BaseMath_WriteCallback(self) == -1)
+ return NULL;
+
Py_RETURN_NONE;
}
@@ -205,7 +207,7 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
return NULL;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
@@ -228,7 +230,7 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
{
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
@@ -254,7 +256,7 @@ static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
{
float teul[EULER_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
@@ -282,7 +284,7 @@ static char Euler_copy_doc[] =
;
static PyObject *Euler_copy(EulerObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self));
@@ -295,7 +297,7 @@ static PyObject *Euler_repr(EulerObject * self)
{
PyObject *ret, *tuple;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Euler_ToTupleExt(self, -1);
@@ -315,7 +317,7 @@ static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op)
EulerObject *eulA= (EulerObject*)a;
EulerObject *eulB= (EulerObject*)b;
- if(!BaseMath_ReadCallback(eulA) || !BaseMath_ReadCallback(eulB))
+ if(BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
return NULL;
ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
@@ -360,7 +362,7 @@ static PyObject *Euler_item(EulerObject * self, int i)
return NULL;
}
- if(!BaseMath_ReadIndexCallback(self, i))
+ if(BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->eul[i]);
@@ -386,7 +388,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value)
self->eul[i] = f;
- if(!BaseMath_WriteIndexCallback(self, i))
+ if(BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
@@ -398,7 +400,7 @@ static PyObject *Euler_slice(EulerObject * self, int begin, int end)
PyObject *tuple;
int count;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, EULER_SIZE);
@@ -420,7 +422,7 @@ static int Euler_ass_slice(EulerObject * self, int begin, int end, PyObject * se
int i, size;
float eul[EULER_SIZE];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, EULER_SIZE);
@@ -542,7 +544,7 @@ static int Euler_setAxis(EulerObject *self, PyObject *value, void *type)
/* rotation order */
static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure))
{
- if(!BaseMath_ReadCallback(self)) /* can read order too */
+ if(BaseMath_ReadCallback(self) == -1) /* can read order too */
return NULL;
return PyUnicode_FromString(euler_order_str(self));
diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c
index ea0b04cfba1..aeefd420a0b 100644
--- a/source/blender/python/generic/mathutils_Matrix.c
+++ b/source/blender/python/generic/mathutils_Matrix.c
@@ -56,13 +56,13 @@ static int mathutils_matrix_vector_get(BaseMathObject *bmo, int subtype)
MatrixObject *self= (MatrixObject *)bmo->cb_user;
int i;
- if(!BaseMath_ReadCallback(self))
- return 0;
+ if(BaseMath_ReadCallback(self) == -1)
+ return -1;
for(i=0; i < self->col_size; i++)
bmo->data[i]= self->matrix[subtype][i];
- return 1;
+ return 0;
}
static int mathutils_matrix_vector_set(BaseMathObject *bmo, int subtype)
@@ -70,38 +70,38 @@ static int mathutils_matrix_vector_set(BaseMathObject *bmo, int subtype)
MatrixObject *self= (MatrixObject *)bmo->cb_user;
int i;
- if(!BaseMath_ReadCallback(self))
- return 0;
+ if(BaseMath_ReadCallback(self) == -1)
+ return -1;
for(i=0; i < self->col_size; i++)
self->matrix[subtype][i]= bmo->data[i];
(void)BaseMath_WriteCallback(self);
- return 1;
+ return 0;
}
static int mathutils_matrix_vector_get_index(BaseMathObject *bmo, int subtype, int index)
{
MatrixObject *self= (MatrixObject *)bmo->cb_user;
- if(!BaseMath_ReadCallback(self))
- return 0;
+ if(BaseMath_ReadCallback(self) == -1)
+ return -1;
bmo->data[index]= self->matrix[subtype][index];
- return 1;
+ return 0;
}
static int mathutils_matrix_vector_set_index(BaseMathObject *bmo, int subtype, int index)
{
MatrixObject *self= (MatrixObject *)bmo->cb_user;
- if(!BaseMath_ReadCallback(self))
- return 0;
+ if(BaseMath_ReadCallback(self) == -1)
+ return -1;
self->matrix[subtype][index]= bmo->data[index];
(void)BaseMath_WriteCallback(self);
- return 1;
+ return 0;
}
Mathutils_Callback mathutils_matrix_vector_cb = {
@@ -635,7 +635,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
{
float quat[4];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
/*must be 3-4 cols, 3-4 rows, square matrix*/
@@ -675,14 +675,14 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
float tmat[3][3];
float (*mat)[3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
return NULL;
if(eul_compat) {
- if(!BaseMath_ReadCallback(eul_compat))
+ if(BaseMath_ReadCallback(eul_compat) == -1)
return NULL;
copy_v3_v3(eul_compatf, eul_compat->eul);
@@ -784,7 +784,7 @@ static char Matrix_to_4x4_doc[] =
;
static PyObject *Matrix_to_4x4(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(self->col_size==4 && self->row_size==4) {
@@ -813,7 +813,7 @@ static PyObject *Matrix_to_3x3(MatrixObject *self)
{
float mat[3][3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if((self->col_size < 3) || (self->row_size < 3)) {
@@ -836,7 +836,7 @@ static char Matrix_to_translation_doc[] =
;
static PyObject *Matrix_to_translation(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if((self->col_size < 3) || self->row_size < 4){
@@ -863,7 +863,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self)
float mat[3][3];
float size[3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
/*must be 3-4 cols, 3-4 rows, square matrix*/
@@ -898,7 +898,7 @@ static PyObject *Matrix_invert(MatrixObject *self)
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};
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(self->row_size != self->col_size){
@@ -972,7 +972,7 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value)
{
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "matrix.rotate(value)") == -1)
@@ -1014,7 +1014,7 @@ static PyObject *Matrix_decompose(MatrixObject *self)
return NULL;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
mat4_to_loc_rot_size(loc, rot, size, (float (*)[4])self->contigPtr);
@@ -1055,7 +1055,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
return NULL;
}
- if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(mat2))
+ if(BaseMath_ReadCallback(self) == -1 || BaseMath_ReadCallback(mat2) == -1)
return NULL;
/* TODO, different sized matrix */
@@ -1086,7 +1086,7 @@ static char Matrix_determinant_doc[] =
;
static PyObject *Matrix_determinant(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(self->row_size != self->col_size){
@@ -1108,7 +1108,7 @@ static PyObject *Matrix_transpose(MatrixObject *self)
{
float t = 0.0f;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(self->row_size != self->col_size){
@@ -1156,7 +1156,7 @@ static PyObject *Matrix_zero(MatrixObject *self)
{
fill_vn(self->contigPtr, self->row_size * self->col_size, 0.0f);
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return NULL;
Py_RETURN_NONE;
@@ -1173,7 +1173,7 @@ static char Matrix_identity_doc[] =
;
static PyObject *Matrix_identity(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(self->row_size != self->col_size){
@@ -1192,7 +1192,7 @@ static PyObject *Matrix_identity(MatrixObject *self)
unit_m4((float (*)[4])self->contigPtr);
}
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return NULL;
Py_RETURN_NONE;
@@ -1209,7 +1209,7 @@ static char Matrix_copy_doc[] =
;
static PyObject *Matrix_copy(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(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));
@@ -1222,7 +1222,7 @@ static PyObject *Matrix_repr(MatrixObject *self)
int x, y;
PyObject *rows[MATRIX_MAX_DIM]= {NULL};
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(x = 0; x < self->row_size; x++){
@@ -1258,7 +1258,7 @@ static PyObject* Matrix_richcmpr(PyObject *a, PyObject *b, int op)
MatrixObject *matA= (MatrixObject*)a;
MatrixObject *matB= (MatrixObject*)b;
- if(!BaseMath_ReadCallback(matA) || !BaseMath_ReadCallback(matB))
+ if(BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1)
return NULL;
ok= ( (matA->col_size == matB->col_size) &&
@@ -1300,7 +1300,7 @@ static int Matrix_len(MatrixObject *self)
the wrapped vector gives direct access to the matrix data*/
static PyObject *Matrix_item(MatrixObject *self, int i)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(i < 0 || i >= self->row_size) {
@@ -1315,7 +1315,7 @@ static PyObject *Matrix_item(MatrixObject *self, int i)
static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value)
{
float vec[4];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
if(i >= self->row_size || i < 0){
@@ -1341,7 +1341,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
PyObject *tuple;
int count;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, self->row_size);
@@ -1363,7 +1363,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
{
PyObject *value_fast= NULL;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, self->row_size);
@@ -1420,7 +1420,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
return NULL;
}
- if(!BaseMath_ReadCallback(mat1) || !BaseMath_ReadCallback(mat2))
+ if(BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1)
return NULL;
if(mat1->row_size != mat2->row_size || mat1->col_size != mat2->col_size){
@@ -1447,7 +1447,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
return NULL;
}
- if(!BaseMath_ReadCallback(mat1) || !BaseMath_ReadCallback(mat2))
+ if(BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1)
return NULL;
if(mat1->row_size != mat2->row_size || mat1->col_size != mat2->col_size){
@@ -1476,12 +1476,12 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
if(MatrixObject_Check(m1)) {
mat1 = (MatrixObject*)m1;
- if(!BaseMath_ReadCallback(mat1))
+ if(BaseMath_ReadCallback(mat1) == -1)
return NULL;
}
if(MatrixObject_Check(m2)) {
mat2 = (MatrixObject*)m2;
- if(!BaseMath_ReadCallback(mat2))
+ if(BaseMath_ReadCallback(mat2) == -1)
return NULL;
}
@@ -1530,7 +1530,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2)
}
static PyObject* Matrix_inv(MatrixObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return Matrix_invert(self);
@@ -1671,7 +1671,7 @@ static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure)
{
float mat[3][3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
/*must be 3-4 cols, 3-4 rows, square matrix*/
@@ -1687,7 +1687,7 @@ static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure)
static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure))
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
/*must be 3-4 cols, 3-4 rows, square matrix*/
diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c
index ca342e72637..7e9191004cc 100644
--- a/source/blender/python/generic/mathutils_Quaternion.c
+++ b/source/blender/python/generic/mathutils_Quaternion.c
@@ -90,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) {
@@ -105,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);
@@ -133,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);
@@ -155,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)
@@ -180,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)
@@ -203,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)
@@ -236,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)
@@ -265,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)
@@ -291,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);
@@ -320,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);
@@ -352,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);
@@ -371,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);
@@ -387,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);
@@ -421,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));
@@ -433,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);
@@ -453,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;
@@ -498,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]);
@@ -522,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;
@@ -534,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);
@@ -556,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);
@@ -659,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);
@@ -681,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++) {
@@ -708,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;
}
@@ -746,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);
@@ -823,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)));
@@ -833,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);
@@ -848,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);
@@ -874,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;
@@ -887,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);
@@ -912,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);
@@ -924,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;
diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/generic/mathutils_Vector.c
index 950a2c43e13..f9eabd28bfb 100644
--- a/source/blender/python/generic/mathutils_Vector.c
+++ b/source/blender/python/generic/mathutils_Vector.c
@@ -96,7 +96,9 @@ static PyObject *Vector_zero(VectorObject *self)
{
fill_vn(self->vec, self->size, 0.0f);
- (void)BaseMath_WriteCallback(self);
+ if(BaseMath_WriteCallback(self) == -1)
+ return NULL;
+
Py_RETURN_NONE;
}
@@ -114,7 +116,7 @@ static PyObject *Vector_normalize(VectorObject *self)
int i;
float norm = 0.0f;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++) {
@@ -245,7 +247,7 @@ static char Vector_to_2d_doc[] =
;
static PyObject *Vector_to_2d(VectorObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self));
@@ -262,7 +264,7 @@ static PyObject *Vector_to_3d(VectorObject *self)
{
float tvec[3]= {0.0f};
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3));
@@ -280,7 +282,7 @@ static PyObject *Vector_to_4d(VectorObject *self)
{
float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f};
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4));
@@ -334,7 +336,7 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
if(PyTuple_GET_SIZE(args)==0)
ndigits= -1;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return Vector_to_tuple_ext(self, ndigits);
@@ -366,7 +368,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args )
return NULL;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if (strack) {
@@ -475,7 +477,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
float reflect[3] = {0.0f};
float tvec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if((value_size= mathutils_array_parse(tvec, 2, 4, value, "vector.reflect(other), invalid 'other' arg")) == -1)
@@ -514,7 +516,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
VectorObject *ret;
float tvec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.cross(other), invalid 'other' arg") == -1)
@@ -541,7 +543,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
double dot = 0.0;
int x;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.dot(other), invalid 'other' arg") == -1)
@@ -580,7 +582,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
if(!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback))
return NULL;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, size, size, value, "vector.angle(other), invalid 'other' arg") == -1)
@@ -632,7 +634,7 @@ static PyObject *Vector_difference(VectorObject *self, PyObject *value)
return NULL;
}
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "vector.difference(other), invalid 'other' arg") == -1)
@@ -664,13 +666,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
double dot = 0.0f, dot2 = 0.0f;
int x;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_array_parse(tvec, size, size, value, "vector.project(other), invalid 'other' arg") == -1)
return NULL;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
//get dot products
@@ -712,7 +714,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
if(mathutils_array_parse(tvec, size, size, value, "vector.lerp(other), invalid 'other' arg") == -1)
return NULL;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
ifac= 1.0 - fac;
@@ -735,7 +737,7 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
{
float other_rmat[3][3];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
if(mathutils_any_to_rotmat(other_rmat, value, "vector.rotate(value)") == -1)
@@ -764,7 +766,7 @@ static char Vector_copy_doc[] =
;
static PyObject *Vector_copy(VectorObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self));
@@ -774,7 +776,7 @@ static PyObject *Vector_repr(VectorObject *self)
{
PyObject *ret, *tuple;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
tuple= Vector_to_tuple_ext(self, -1);
@@ -799,7 +801,7 @@ static PyObject *Vector_item(VectorObject *self, int i)
return NULL;
}
- if(!BaseMath_ReadIndexCallback(self, i))
+ if(BaseMath_ReadIndexCallback(self, i) == -1)
return NULL;
return PyFloat_FromDouble(self->vec[i]);
@@ -821,7 +823,7 @@ static int Vector_ass_item(VectorObject *self, int i, PyObject * ob)
}
self->vec[i] = scalar;
- if(!BaseMath_WriteIndexCallback(self, i))
+ if(BaseMath_WriteIndexCallback(self, i) == -1)
return -1;
return 0;
}
@@ -832,7 +834,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
PyObject *tuple;
int count;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
CLAMP(begin, 0, self->size);
@@ -854,7 +856,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end,
int y, size = 0;
float vec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
CLAMP(begin, 0, self->size);
@@ -870,7 +872,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end,
self->vec[begin + y] = vec[y];
}
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
return 0;
@@ -890,7 +892,7 @@ static PyObject *Vector_add(PyObject * v1, PyObject * v2)
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
/*VECTOR + VECTOR*/
@@ -921,7 +923,7 @@ static PyObject *Vector_iadd(PyObject * v1, PyObject * v2)
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
add_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -944,7 +946,7 @@ static PyObject *Vector_sub(PyObject * v1, PyObject * v2)
vec1 = (VectorObject*)v1;
vec2 = (VectorObject*)v2;
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
if(vec1->size != vec2->size) {
@@ -974,7 +976,7 @@ static PyObject *Vector_isub(PyObject * v1, PyObject * v2)
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
return NULL;
sub_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -1041,12 +1043,12 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
if VectorObject_Check(v1) {
vec1= (VectorObject *)v1;
- if(!BaseMath_ReadCallback(vec1))
+ if(BaseMath_ReadCallback(vec1) == -1)
return NULL;
}
if VectorObject_Check(v2) {
vec2= (VectorObject *)v2;
- if(!BaseMath_ReadCallback(vec2))
+ if(BaseMath_ReadCallback(vec2) == -1)
return NULL;
}
@@ -1071,7 +1073,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
if (MatrixObject_Check(v2)) {
/* VEC * MATRIX */
float tvec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback((MatrixObject *)v2))
+ if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
if(column_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) {
return NULL;
@@ -1088,7 +1090,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported");
return NULL;
}
- if(!BaseMath_ReadCallback(quat2)) {
+ if(BaseMath_ReadCallback(quat2) == -1) {
return NULL;
}
copy_v3_v3(tvec, vec1->vec);
@@ -1118,14 +1120,14 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
VectorObject *vec = (VectorObject *)v1;
float scalar;
- if(!BaseMath_ReadCallback(vec))
+ if(BaseMath_ReadCallback(vec) == -1)
return NULL;
/* only support vec*=float and vec*=mat
vec*=vec result is a float so that wont work */
if (MatrixObject_Check(v2)) {
float rvec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback((MatrixObject *)v2))
+ if(BaseMath_ReadCallback((MatrixObject *)v2) == -1)
return NULL;
if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1)
@@ -1142,7 +1144,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2)
return NULL;
}
- if(!BaseMath_ReadCallback(quat2)) {
+ if(BaseMath_ReadCallback(quat2) == -1) {
return NULL;
}
mul_qt_v3(quat2->quat, vec->vec);
@@ -1173,7 +1175,7 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2)
}
vec1 = (VectorObject*)v1; /* vector */
- if(!BaseMath_ReadCallback(vec1))
+ if(BaseMath_ReadCallback(vec1) == -1)
return NULL;
if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
@@ -1199,7 +1201,7 @@ static PyObject *Vector_idiv(PyObject * v1, PyObject * v2)
float scalar;
VectorObject *vec1 = (VectorObject*)v1;
- if(!BaseMath_ReadCallback(vec1))
+ if(BaseMath_ReadCallback(vec1) == -1)
return NULL;
if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
@@ -1227,7 +1229,7 @@ static PyObject *Vector_neg(VectorObject *self)
{
float tvec[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
negate_vn_vn(tvec, self->vec, self->size);
@@ -1270,7 +1272,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
vecA = (VectorObject*)objectA;
vecB = (VectorObject*)objectB;
- if(!BaseMath_ReadCallback(vecA) || !BaseMath_ReadCallback(vecB))
+ if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
return NULL;
if (vecA->size != vecB->size){
@@ -1473,7 +1475,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
double dot = 0.0f;
int i;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
for(i = 0; i < self->size; i++){
@@ -1487,7 +1489,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
double dot = 0.0f, param;
int i;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
if((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
@@ -1537,7 +1539,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure)
float vec[MAX_DIMENSIONS];
unsigned int swizzleClosure;
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
/* Unpack the axes from the closure into an array. */
@@ -1582,7 +1584,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject * value, void *closure
float tvec[MAX_DIMENSIONS];
float vec_assign[MAX_DIMENSIONS];
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return -1;
/* Check that the closure can be used with this vector: even 2D vectors have
@@ -1631,7 +1633,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject * value, void *closure
memcpy(self->vec, tvec, axis_from * sizeof(float));
/* continue with BaseMathObject_WriteCallback at the end */
- if(!BaseMath_WriteCallback(self))
+ if(BaseMath_WriteCallback(self) == -1)
return -1;
else
return 0;
@@ -2052,7 +2054,7 @@ static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObj
}
}
- if(!BaseMath_ReadCallback(vec) || !BaseMath_ReadCallback(mat))
+ if(BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1)
return -1;
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
@@ -2081,7 +2083,7 @@ static char Vector_negate_doc[] =
;
static PyObject *Vector_negate(VectorObject *self)
{
- if(!BaseMath_ReadCallback(self))
+ if(BaseMath_ReadCallback(self) == -1)
return NULL;
negate_vn(self->vec, self->size);
diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c
index e4c02fec1d6..03501ae817d 100644
--- a/source/blender/python/generic/mathutils_geometry.c
+++ b/source/blender/python/generic/mathutils_geometry.c
@@ -92,7 +92,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject*
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3) || !BaseMath_ReadCallback(ray) || !BaseMath_ReadCallback(ray_off))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(ray) == -1 || BaseMath_ReadCallback(ray_off) == -1)
return NULL;
VECCOPY(v1, vec1->vec);
@@ -179,7 +179,7 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3) || !BaseMath_ReadCallback(vec4))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
return NULL;
if(vec1->size == 3 || vec1->size == 2) {
@@ -265,7 +265,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
return NULL;
normal_tri_v3(n, vec1->vec, vec2->vec, vec3->vec);
@@ -283,7 +283,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3) || !BaseMath_ReadCallback(vec4))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1 || BaseMath_ReadCallback(vec4) == -1)
return NULL;
normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec);
@@ -320,7 +320,7 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args)
return NULL;
}
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3))
+ if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1 || BaseMath_ReadCallback(vec3) == -1)
return NULL;
if (vec1->size == 3) {
@@ -397,7 +397,7 @@ static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *
polyVec= PySequence_GetItem(polyLine, index);
if(VectorObject_Check(polyVec)) {
- if(!BaseMath_ReadCallback((VectorObject *)polyVec))
+ if(BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
ls_error= 1;
fp[0]= ((VectorObject *)polyVec)->vec[0];
@@ -484,7 +484,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
- if(!BaseMath_ReadCallback(line_a1) || !BaseMath_ReadCallback(line_a2) || !BaseMath_ReadCallback(line_b1) || !BaseMath_ReadCallback(line_b2))
+ if(BaseMath_ReadCallback(line_a1) == -1 || BaseMath_ReadCallback(line_a2) == -1 || BaseMath_ReadCallback(line_b1) == -1 || BaseMath_ReadCallback(line_b2) == -1)
return NULL;
if(isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) {
@@ -523,7 +523,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec
return NULL;
}
- if(!BaseMath_ReadCallback(pt) || !BaseMath_ReadCallback(line_1) || !BaseMath_ReadCallback(line_2))
+ if(BaseMath_ReadCallback(pt) == -1 || BaseMath_ReadCallback(line_1) == -1 || BaseMath_ReadCallback(line_2) == -1)
return NULL;
/* accept 2d verts */
@@ -573,7 +573,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj
return NULL;
}
- if(!BaseMath_ReadCallback(pt_vec) || !BaseMath_ReadCallback(tri_p1) || !BaseMath_ReadCallback(tri_p2) || !BaseMath_ReadCallback(tri_p3))
+ if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(tri_p1) == -1 || BaseMath_ReadCallback(tri_p2) == -1 || BaseMath_ReadCallback(tri_p3) == -1)
return NULL;
return PyLong_FromLong(isect_point_tri_v2(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec));
@@ -610,7 +610,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb
return NULL;
}
- if(!BaseMath_ReadCallback(pt_vec) || !BaseMath_ReadCallback(quad_p1) || !BaseMath_ReadCallback(quad_p2) || !BaseMath_ReadCallback(quad_p3) || !BaseMath_ReadCallback(quad_p4))
+ if(BaseMath_ReadCallback(pt_vec) == -1 || BaseMath_ReadCallback(quad_p1) == -1 || BaseMath_ReadCallback(quad_p2) == -1 || BaseMath_ReadCallback(quad_p3) == -1 || BaseMath_ReadCallback(quad_p4) == -1)
return NULL;
return PyLong_FromLong(isect_point_quad_v2(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec));
@@ -767,7 +767,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject*
return NULL;
}
- if(!BaseMath_ReadCallback(vec_k1) || !BaseMath_ReadCallback(vec_h1) || !BaseMath_ReadCallback(vec_k2) || !BaseMath_ReadCallback(vec_h2))
+ if(BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1)
return NULL;
dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size);
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index c8ec97420da..92feb75fd44 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -130,14 +130,14 @@ static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
static int mathutils_rna_generic_check(BaseMathObject *bmo)
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
- return self->prop ? 1:0;
+ return self->prop ? 0 : -1;
}
static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
{
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
if(self->prop==NULL)
- return 0;
+ return -1;
RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
@@ -148,7 +148,7 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
eul->order= pyrna_rotation_euler_order_get(&self->ptr, &prop_eul_order, eul->order);
}
- return 1;
+ return 0;
}
static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
@@ -156,17 +156,17 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
float min, max;
if(self->prop==NULL)
- return 0;
+ return -1;
#ifdef USE_PEDANTIC_WRITE
if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
- return 0;
+ return -1;
}
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
- return 0;
+ return -1;
}
RNA_property_float_range(&self->ptr, self->prop, &min, &max);
@@ -195,7 +195,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
}
}
}
- return 1;
+ return 0;
}
static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtype), int index)
@@ -203,10 +203,10 @@ static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtyp
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
if(self->prop==NULL)
- return 0;
+ return -1;
bmo->data[index]= RNA_property_float_get_index(&self->ptr, self->prop, index);
- return 1;
+ return 0;
}
static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtype), int index)
@@ -214,17 +214,17 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
BPy_PropertyRNA *self= (BPy_PropertyRNA *)bmo->cb_user;
if(self->prop==NULL)
- return 0;
+ return -1;
#ifdef USE_PEDANTIC_WRITE
if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
- return 0;
+ return -1;
}
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
- return 0;
+ return -1;
}
RNA_property_float_clamp(&self->ptr, self->prop, &bmo->data[index]);
@@ -234,7 +234,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
- return 1;
+ return 0;
}
static Mathutils_Callback mathutils_rna_array_cb = {
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 93d67e92dd5..bd59949475a 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1263,16 +1263,16 @@ static int mathutils_kxgameob_generic_check(BaseMathObject *bmo)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
#define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller")
@@ -1290,26 +1290,26 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
self->NodeGetWorldScaling().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_INERTIA_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localInertia"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localInertia"), -1;
self->GetPhysicsController()->GetLocalInertia().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_OBJECT_COLOR:
self->GetObjectColor().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_LINVEL_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
self->GetLinearVelocity(true).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_LINVEL_GLOBAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
self->GetLinearVelocity(false).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_ANGVEL_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
self->GetAngularVelocity(true).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_ANGVEL_GLOBAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
self->GetAngularVelocity(false).getValue(bmo->data);
break;
@@ -1317,14 +1317,14 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
#undef PHYS_ERR
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_VEC_CB_POS_LOCAL:
@@ -1341,7 +1341,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
break;
case MATHUTILS_VEC_CB_SCALE_GLOBAL:
PyErr_SetString(PyExc_AttributeError, "KX_GameObject.worldScale is read-only");
- return 0;
+ return -1;
case MATHUTILS_VEC_CB_INERTIA_LOCAL:
/* read only */
break;
@@ -1362,15 +1362,15 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index)
{
/* lazy, avoid repeteing the case statement */
if(!mathutils_kxgameob_vector_get(bmo, subtype))
- return 0;
- return 1;
+ return -1;
+ return 0;
}
static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, int index)
@@ -1379,7 +1379,7 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype,
/* lazy, avoid repeteing the case statement */
if(!mathutils_kxgameob_vector_get(bmo, subtype))
- return 0;
+ return -1;
bmo->data[index]= f;
return mathutils_kxgameob_vector_set(bmo, subtype);
@@ -1403,7 +1403,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_MAT_CB_ORI_LOCAL:
@@ -1414,7 +1414,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
@@ -1422,7 +1422,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
MT_Matrix3x3 mat3x3;
switch(subtype) {
@@ -1438,7 +1438,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
Mathutils_Callback mathutils_kxgameob_matrix_cb = {
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index 83d8f4b883b..977e32a4c7f 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -392,16 +392,16 @@ static int mathutils_obactu_generic_check(BaseMathObject *bmo)
{
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
- return 1;
+ return 0;
}
static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype)
{
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_VEC_CB_LINV:
@@ -412,14 +412,14 @@ static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype)
{
KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_VEC_CB_LINV:
@@ -430,15 +430,15 @@ static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
static int mathutils_obactu_vector_get_index(BaseMathObject *bmo, int subtype, int index)
{
/* lazy, avoid repeteing the case statement */
if(!mathutils_obactu_vector_get(bmo, subtype))
- return 0;
- return 1;
+ return -1;
+ return 0;
}
static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, int index)
@@ -447,7 +447,7 @@ static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, i
/* lazy, avoid repeteing the case statement */
if(!mathutils_obactu_vector_get(bmo, subtype))
- return 0;
+ return -1;
bmo->data[index]= f;
return mathutils_obactu_vector_set(bmo, subtype);
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index d7ea63c9880..9b198f85664 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -114,7 +114,7 @@ bool PyVecTo(PyObject* pyval, T& vec)
if(VectorObject_Check(pyval)) {
VectorObject *pyvec= (VectorObject *)pyval;
- if(!BaseMath_ReadCallback(pyvec)) {
+ if(BaseMath_ReadCallback(pyvec) == -1) {
return false; /* exception raised */
}
if (pyvec->size != Size(vec)) {
@@ -126,7 +126,7 @@ bool PyVecTo(PyObject* pyval, T& vec)
}
else if(QuaternionObject_Check(pyval)) {
QuaternionObject *pyquat= (QuaternionObject *)pyval;
- if(!BaseMath_ReadCallback(pyquat)) {
+ if(BaseMath_ReadCallback(pyquat) == -1) {
return false; /* exception raised */
}
if (4 != Size(vec)) {
@@ -139,7 +139,7 @@ bool PyVecTo(PyObject* pyval, T& vec)
}
else if(EulerObject_Check(pyval)) {
EulerObject *pyeul= (EulerObject *)pyval;
- if(!BaseMath_ReadCallback(pyeul)) {
+ if(BaseMath_ReadCallback(pyeul) == -1) {
return false; /* exception raised */
}
if (3 != Size(vec)) {