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:
authorCampbell Barton <ideasman42@gmail.com>2009-06-23 17:34:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-06-23 17:34:45 +0400
commiteb22a7b2102cceb432e3545cd342956e92873a49 (patch)
treec87ad1de81cc216403568b44f289ff9af3a2ae9e /source/blender/python/generic/Mathutils.h
parentbf74f105bc5ec98980fa087347203244750fb669 (diff)
PyRNA API support for matrix types as Mathutils matrix (with callbacks) rather then a generic rna sequence of floats.
Any 3x3 or 4x4 rna matrix will automatically be returned as a Mathutils matrix. This makes useful stuff like multiplying a vector location by an object matrix possible. ob = bpy.data.scenes[0].objects[0] print (ob.data.verts[0].co * ob.matrix) Also added mathutils matrix types to the BGE GameObject.localOrientation, worldOrientation * MT_Matrix3x3 added getValue3x3 and setValue3x3, assumed a 4x3 float array. * KX_GameObject.cpp convenience functions NodeSetGlobalOrientation, NodeGetLocalOrientation, NodeGetLocalScaling, NodeGetLocalPosition. * 2.5 python api now initializes modules BGL, Mathutils and Geometry * modules py3 PyModuleDef's use PyModuleDef_HEAD_INIT, rather then {}, was making msvc fail to build. * added macros for Vector_ReadCallback, Vector_WriteCallback etc. to check if the callback pointer is set before calling the function.
Diffstat (limited to 'source/blender/python/generic/Mathutils.h')
-rw-r--r--source/blender/python/generic/Mathutils.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h
index 6c769c7729b..a89b779ecbb 100644
--- a/source/blender/python/generic/Mathutils.h
+++ b/source/blender/python/generic/Mathutils.h
@@ -67,17 +67,30 @@ int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
typedef struct Mathutils_Callback Mathutils_Callback;
struct Mathutils_Callback {
int (*check)(PyObject *user); /* checks the user is still valid */
- int (*get)(PyObject *user, int subtype, float *vec_from); /* gets the vector from the user */
- int (*set)(PyObject *user, int subtype, float *vec_to); /* sets the users vector values once the vector is modified */
- int (*get_index)(PyObject *user, int subtype, float *vec_from, int index); /* same as above but only for an index */
- int (*set_index)(PyObject *user, int subtype, float *vec_to, int index); /* same as above but only for an index */
+ int (*get)(PyObject *user, int subtype, float *from); /* gets the vector from the user */
+ int (*set)(PyObject *user, int subtype, float *to); /* sets the users vector values once the vector is modified */
+ int (*get_index)(PyObject *user, int subtype, float *from,int index); /* same as above but only for an index */
+ int (*set_index)(PyObject *user, int subtype, float *to, int index); /* same as above but only for an index */
};
int Mathutils_RegisterCallback(Mathutils_Callback *cb);
-int Vector_ReadCallback(VectorObject *self);
-int Vector_WriteCallback(VectorObject *self);
-int Vector_ReadIndexCallback(VectorObject *self, int index);
-int Vector_WriteIndexCallback(VectorObject *self, int index);
+int _Vector_ReadCallback(VectorObject *self);
+int _Vector_WriteCallback(VectorObject *self);
+int _Vector_ReadIndexCallback(VectorObject *self, int index);
+int _Vector_WriteIndexCallback(VectorObject *self, int index);
+
+/* since this is called so often avoid where possible */
+#define Vector_ReadCallback(_self) (((_self)->cb_user ? _Vector_ReadCallback(_self):1))
+#define Vector_WriteCallback(_self) (((_self)->cb_user ?_Vector_WriteCallback(_self):1))
+#define Vector_ReadIndexCallback(_self, _index) (((_self)->cb_user ? _Vector_ReadIndexCallback(_self, _index):1))
+#define Vector_WriteIndexCallback(_self, _index) (((_self)->cb_user ? _Vector_WriteIndexCallback(_self, _index):1))
+
+
+int _Matrix_ReadCallback(MatrixObject *self);
+int _Matrix_WriteCallback(MatrixObject *self);
+
+#define Matrix_ReadCallback(_self) (((_self)->cb_user ?_Matrix_ReadCallback(_self):1))
+#define Matrix_WriteCallback(_self) (((_self)->cb_user ?_Matrix_WriteCallback(_self):1))
#endif /* EXPP_Mathutils_H */