| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  | /* 
 | 
					
						
							| 
									
										
										
										
											2009-06-23 00:09:26 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is a new part of Blender. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Joseph Gilbert | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | //Include this file for access to vector, quat, matrix, euler, etc...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 16:14:57 +00:00
										 |  |  | #ifndef MATHUTILS_H
 | 
					
						
							|  |  |  | #define MATHUTILS_H
 | 
					
						
							| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | /* Can cast different mathutils types to this, use for generic funcs */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 21:33:39 +00:00
										 |  |  | extern char BaseMathObject_Wrapped_doc[]; | 
					
						
							|  |  |  | extern char BaseMathObject_Owner_doc[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-16 08:17:13 +00:00
										 |  |  | #define BASE_MATH_MEMBERS(_data) \
 | 
					
						
							|  |  |  | 	PyObject_VAR_HEAD \ | 
					
						
							|  |  |  | 	float *_data;				/* array of data (alias), wrapped status depends on wrapped status */ \ | 
					
						
							|  |  |  | 	PyObject *cb_user;			/* if this vector references another object, otherwise NULL, *Note* this owns its reference */ \ | 
					
						
							|  |  |  | 	unsigned char cb_type;		/* which user funcs do we adhere to, RNA, GameObject, etc */ \ | 
					
						
							|  |  |  | 	unsigned char cb_subtype;	/* subtype: location, rotation... to avoid defining many new functions for every attribute of the same type */ \ | 
					
						
							|  |  |  | 	unsigned char wrapped;		/* wrapped data type? */ \ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2010-04-16 08:17:13 +00:00
										 |  |  | 	BASE_MATH_MEMBERS(data) | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | } BaseMathObject; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-14 04:15:25 +00:00
										 |  |  | #include "mathutils_Vector.h"
 | 
					
						
							|  |  |  | #include "mathutils_Matrix.h"
 | 
					
						
							|  |  |  | #include "mathutils_Quaternion.h"
 | 
					
						
							|  |  |  | #include "mathutils_Euler.h"
 | 
					
						
							|  |  |  | #include "mathutils_Color.h"
 | 
					
						
							| 
									
										
										
										
											2010-10-25 22:44:01 +00:00
										 |  |  | #include "mathutils_geometry.h"
 | 
					
						
							| 
									
										
										
										
											2010-04-16 08:17:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * ); | 
					
						
							|  |  |  | PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * ); | 
					
						
							|  |  |  | void BaseMathObject_dealloc(BaseMathObject * self); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-29 22:59:39 +00:00
										 |  |  | PyMODINIT_FUNC BPyInit_mathutils(void); | 
					
						
							| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | int EXPP_FloatsAreEqual(float A, float B, int floatSteps); | 
					
						
							|  |  |  | int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 04:26:48 +00:00
										 |  |  | #define Py_NEW  1
 | 
					
						
							|  |  |  | #define Py_WRAP 2
 | 
					
						
							| 
									
										
										
										
											2009-06-17 20:33:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 04:26:48 +00:00
										 |  |  | typedef struct Mathutils_Callback Mathutils_Callback; | 
					
						
							| 
									
										
										
										
											2009-07-10 18:09:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-26 21:04:42 +00:00
										 |  |  | typedef int (*BaseMathCheckFunc)(BaseMathObject *);							/* checks the user is still valid */ | 
					
						
							| 
									
										
										
										
											2010-04-27 19:21:36 +00:00
										 |  |  | typedef int (*BaseMathGetFunc)(BaseMathObject *, int);				/* gets the vector from the user */ | 
					
						
							|  |  |  | typedef int (*BaseMathSetFunc)(BaseMathObject *, int);				/* sets the users vector values once the vector is modified */ | 
					
						
							|  |  |  | typedef int (*BaseMathGetIndexFunc)(BaseMathObject *, int, int);	/* same as above but only for an index */ | 
					
						
							|  |  |  | typedef int (*BaseMathSetIndexFunc)(BaseMathObject *, int, int);	/* same as above but only for an index */ | 
					
						
							| 
									
										
										
										
											2009-07-10 18:09:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-22 04:26:48 +00:00
										 |  |  | struct Mathutils_Callback { | 
					
						
							| 
									
										
										
										
											2010-04-26 21:04:42 +00:00
										 |  |  | 	BaseMathCheckFunc		check; | 
					
						
							|  |  |  | 	BaseMathGetFunc			get; | 
					
						
							|  |  |  | 	BaseMathSetFunc			set; | 
					
						
							|  |  |  | 	BaseMathGetIndexFunc	get_index; | 
					
						
							|  |  |  | 	BaseMathSetIndexFunc	set_index; | 
					
						
							| 
									
										
										
										
											2009-06-22 04:26:48 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int Mathutils_RegisterCallback(Mathutils_Callback *cb); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | int _BaseMathObject_ReadCallback(BaseMathObject *self); | 
					
						
							|  |  |  | int _BaseMathObject_WriteCallback(BaseMathObject *self); | 
					
						
							|  |  |  | int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index); | 
					
						
							|  |  |  | int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index); | 
					
						
							| 
									
										
										
										
											2009-06-23 13:34:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* since this is called so often avoid where possible */ | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | #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))
 | 
					
						
							| 
									
										
										
										
											2009-06-22 04:26:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-25 19:27:59 +00:00
										 |  |  | /* utility func */ | 
					
						
							|  |  |  | int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix); | 
					
						
							| 
									
										
										
										
											2011-02-05 09:57:02 +00:00
										 |  |  | int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix); | 
					
						
							| 
									
										
										
										
											2010-04-25 19:27:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 16:14:57 +00:00
										 |  |  | #endif /* MATHUTILS_H */
 |