|
Blender
V2.59
|
00001 /* 00002 * $Id: mathutils.h 38674 2011-07-25 01:44:19Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * This is a new part of Blender. 00024 * 00025 * Contributor(s): Joseph Gilbert 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 //Include this file for access to vector, quat, matrix, euler, etc... 00035 00036 #ifndef MATHUTILS_H 00037 #define MATHUTILS_H 00038 00039 /* Can cast different mathutils types to this, use for generic funcs */ 00040 00041 extern char BaseMathObject_Wrapped_doc[]; 00042 extern char BaseMathObject_Owner_doc[]; 00043 00044 #define BASE_MATH_MEMBERS(_data) \ 00045 PyObject_VAR_HEAD \ 00046 float *_data; /* array of data (alias), wrapped status depends on wrapped status */ \ 00047 PyObject *cb_user; /* if this vector references another object, otherwise NULL, *Note* this owns its reference */ \ 00048 unsigned char cb_type; /* which user funcs do we adhere to, RNA, GameObject, etc */ \ 00049 unsigned char cb_subtype; /* subtype: location, rotation... to avoid defining many new functions for every attribute of the same type */ \ 00050 unsigned char wrapped; /* wrapped data type? */ \ 00051 00052 typedef struct { 00053 BASE_MATH_MEMBERS(data) 00054 } BaseMathObject; 00055 00056 #include "mathutils_Vector.h" 00057 #include "mathutils_Matrix.h" 00058 #include "mathutils_Quaternion.h" 00059 #include "mathutils_Euler.h" 00060 #include "mathutils_Color.h" 00061 #include "mathutils_geometry.h" 00062 00063 PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); 00064 PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); 00065 00066 int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg); 00067 int BaseMathObject_clear(BaseMathObject *self); 00068 void BaseMathObject_dealloc(BaseMathObject * self); 00069 00070 PyMODINIT_FUNC PyInit_mathutils(void); 00071 00072 int EXPP_FloatsAreEqual(float A, float B, int floatSteps); 00073 int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps); 00074 00075 #define Py_NEW 1 00076 #define Py_WRAP 2 00077 00078 typedef struct Mathutils_Callback Mathutils_Callback; 00079 00080 typedef int (*BaseMathCheckFunc)(BaseMathObject *); /* checks the user is still valid */ 00081 typedef int (*BaseMathGetFunc)(BaseMathObject *, int); /* gets the vector from the user */ 00082 typedef int (*BaseMathSetFunc)(BaseMathObject *, int); /* sets the users vector values once the vector is modified */ 00083 typedef int (*BaseMathGetIndexFunc)(BaseMathObject *, int, int); /* same as above but only for an index */ 00084 typedef int (*BaseMathSetIndexFunc)(BaseMathObject *, int, int); /* same as above but only for an index */ 00085 00086 struct Mathutils_Callback { 00087 BaseMathCheckFunc check; 00088 BaseMathGetFunc get; 00089 BaseMathSetFunc set; 00090 BaseMathGetIndexFunc get_index; 00091 BaseMathSetIndexFunc set_index; 00092 }; 00093 00094 int Mathutils_RegisterCallback(Mathutils_Callback *cb); 00095 00096 int _BaseMathObject_ReadCallback(BaseMathObject *self); 00097 int _BaseMathObject_WriteCallback(BaseMathObject *self); 00098 int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index); 00099 int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index); 00100 00101 /* since this is called so often avoid where possible */ 00102 #define BaseMath_ReadCallback(_self) (((_self)->cb_user ? _BaseMathObject_ReadCallback((BaseMathObject *)_self):0)) 00103 #define BaseMath_WriteCallback(_self) (((_self)->cb_user ?_BaseMathObject_WriteCallback((BaseMathObject *)_self):0)) 00104 #define BaseMath_ReadIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index):0)) 00105 #define BaseMath_WriteIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index):0)) 00106 00107 /* utility func */ 00108 int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix); 00109 int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix); 00110 00111 int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject *mat); 00112 00113 #endif /* MATHUTILS_H */