[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44938] trunk/blender/source: minor mathutils code cleanup - use mathutils callbacks as unsigned chars everywhere .
Campbell Barton
ideasman42 at gmail.com
Sat Mar 17 11:46:18 CET 2012
Revision: 44938
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44938
Author: campbellbarton
Date: 2012-03-17 10:46:02 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
minor mathutils code cleanup - use mathutils callbacks as unsigned chars everywhere.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/mathutils/mathutils.c
trunk/blender/source/blender/python/mathutils/mathutils.h
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.h
trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
trunk/blender/source/blender/python/mathutils/mathutils_Vector.h
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2012-03-17 10:46:02 UTC (rev 44938)
@@ -372,7 +372,7 @@
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback);
/* bpyrna vector/euler/quat callbacks */
-static int mathutils_rna_array_cb_index = -1; /* index for our callbacks */
+static unsigned char mathutils_rna_array_cb_index = -1; /* index for our callbacks */
/* subtype not used much yet */
#define MATHUTILS_CB_SUBTYPE_EUL 0
@@ -517,7 +517,7 @@
/* bpyrna matrix callbacks */
-static int mathutils_rna_matrix_cb_index = -1; /* index for our callbacks */
+static unsigned char mathutils_rna_matrix_cb_index = -1; /* index for our callbacks */
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
{
Modified: trunk/blender/source/blender/python/mathutils/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.c 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils.c 2012-03-17 10:46:02 UTC (rev 44938)
@@ -284,18 +284,21 @@
/* Mathutils Callbacks */
/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
-static Mathutils_Callback *mathutils_callbacks[8] = {NULL};
+#define MATHUTILS_TOT_CB 8
+static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
-int Mathutils_RegisterCallback(Mathutils_Callback *cb)
+unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb)
{
- int i;
+ unsigned char i;
/* find the first free slot */
for (i = 0; mathutils_callbacks[i]; i++) {
if (mathutils_callbacks[i] == cb) /* already registered? */
return i;
}
-
+
+ BLI_assert(i < MATHUTILS_TOT_CB);
+
mathutils_callbacks[i] = cb;
return i;
}
Modified: trunk/blender/source/blender/python/mathutils/mathutils.h
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.h 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils.h 2012-03-17 10:46:02 UTC (rev 44938)
@@ -98,7 +98,7 @@
BaseMathSetIndexFunc set_index;
};
-int Mathutils_RegisterCallback(Mathutils_Callback *cb);
+unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb);
int _BaseMathObject_ReadCallback(BaseMathObject *self);
int _BaseMathObject_WriteCallback(BaseMathObject *self);
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c 2012-03-17 10:46:02 UTC (rev 44938)
@@ -78,7 +78,7 @@
* matrix row callbacks
* this is so you can do matrix[i][j] = val OR matrix.row[i][j] = val */
-int mathutils_matrix_row_cb_index = -1;
+unsigned char mathutils_matrix_row_cb_index = -1;
static int mathutils_matrix_row_check(BaseMathObject *bmo)
{
@@ -162,7 +162,7 @@
* matrix row callbacks
* this is so you can do matrix.col[i][j] = val */
-int mathutils_matrix_col_cb_index = -1;
+unsigned char mathutils_matrix_col_cb_index = -1;
static int mathutils_matrix_col_check(BaseMathObject *bmo)
{
@@ -255,7 +255,7 @@
* this is so you can do matrix.translation = val
* note, this is _exactly like matrix.col except the 4th component is always omitted */
-int mathutils_matrix_translation_cb_index = -1;
+unsigned char mathutils_matrix_translation_cb_index = -1;
static int mathutils_matrix_translation_check(BaseMathObject *bmo)
{
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.h
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.h 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.h 2012-03-17 10:46:02 UTC (rev 44938)
@@ -73,9 +73,9 @@
const unsigned short num_col, const unsigned short num_row,
int cb_type, int cb_subtype);
-extern int mathutils_matrix_row_cb_index; /* default */
-extern int mathutils_matrix_col_cb_index;
-extern int mathutils_matrix_translation_cb_index;
+extern unsigned char mathutils_matrix_row_cb_index; /* default */
+extern unsigned char mathutils_matrix_col_cb_index;
+extern unsigned char mathutils_matrix_translation_cb_index;
extern struct Mathutils_Callback mathutils_matrix_row_cb; /* default */
extern struct Mathutils_Callback mathutils_matrix_col_cb;
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Vector.c 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Vector.c 2012-03-17 10:46:02 UTC (rev 44938)
@@ -2913,15 +2913,15 @@
return (PyObject *) self;
}
-PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype)
+PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, unsigned char cb_type, unsigned char cb_subtype)
{
float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */
VectorObject *self = (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL);
if (self) {
Py_INCREF(cb_user);
- self->cb_user = cb_user;
- self->cb_type = (unsigned char)cb_type;
- self->cb_subtype = (unsigned char)cb_subtype;
+ self->cb_user = cb_user;
+ self->cb_type = cb_type;
+ self->cb_subtype = cb_subtype;
PyObject_GC_Track(self);
}
Modified: trunk/blender/source/blender/python/mathutils/mathutils_Vector.h
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Vector.h 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Vector.h 2012-03-17 10:46:02 UTC (rev 44938)
@@ -46,7 +46,7 @@
/*prototypes*/
PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type);
-PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, int callback_type, int subtype);
+PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, unsigned char callback_type, unsigned char subtype);
PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type);
#endif /* __MATHUTILS_VECTOR_H__ */
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2012-03-17 10:46:02 UTC (rev 44938)
@@ -1374,7 +1374,7 @@
#define MATHUTILS_VEC_CB_ANGVEL_LOCAL 9
#define MATHUTILS_VEC_CB_ANGVEL_GLOBAL 10
-static int mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
+static unsigned char mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
static int mathutils_kxgameob_generic_check(BaseMathObject *bmo)
{
@@ -1514,7 +1514,7 @@
#define MATHUTILS_MAT_CB_ORI_LOCAL 1
#define MATHUTILS_MAT_CB_ORI_GLOBAL 2
-static int mathutils_kxgameob_matrix_cb_index= -1; /* index for our callbacks */
+static unsigned char mathutils_kxgameob_matrix_cb_index= -1; /* index for our callbacks */
static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
{
Modified: trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp 2012-03-17 10:23:44 UTC (rev 44937)
+++ trunk/blender/source/gameengine/Ketsji/KX_ObjectActuator.cpp 2012-03-17 10:46:02 UTC (rev 44938)
@@ -385,7 +385,7 @@
#define MATHUTILS_VEC_CB_LINV 1
#define MATHUTILS_VEC_CB_ANGV 2
-static int mathutils_kxobactu_vector_cb_index= -1; /* index for our callbacks */
+static unsigned char mathutils_kxobactu_vector_cb_index = -1; /* index for our callbacks */
static int mathutils_obactu_generic_check(BaseMathObject *bmo)
{
@@ -496,7 +496,7 @@
void KX_ObjectActuator_Mathutils_Callback_Init(void)
{
// register mathutils callbacks, ok to run more then once.
- mathutils_kxobactu_vector_cb_index= Mathutils_RegisterCallback(&mathutils_obactu_vector_cb);
+ mathutils_kxobactu_vector_cb_index = Mathutils_RegisterCallback(&mathutils_obactu_vector_cb);
}
#endif // USE_MATHUTILS
More information about the Bf-blender-cvs
mailing list