| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2004-09-18 18:47:03 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL/BL DUAL 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. The Blender | 
					
						
							|  |  |  |  * Foundation also sells licenses for use in proprietary software under | 
					
						
							|  |  |  |  * the Blender License.  See http://www.blender.org/BL/ for information
 | 
					
						
							|  |  |  |  * about this. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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, | 
					
						
							|  |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is a new part of Blender. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  |  * Contributor(s): Jacques Guignot, Jean-Michel Soler | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "Effect.h" /*This must come first */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_object_types.h"
 | 
					
						
							|  |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | #include "BKE_effect.h"
 | 
					
						
							|  |  |  | #include "BKE_object.h"
 | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | #include "Particle.h"
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "gen_utils.h"
 | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | PyObject *M_Particle_New( PyObject * self, PyObject * args ); | 
					
						
							|  |  |  | int ParticleSetAttr( BPy_Particle * msh, char *name, PyObject * v ); | 
					
						
							|  |  |  | PyObject *ParticleGetAttr( BPy_Particle * msh, char *name ); | 
					
						
							|  |  |  | PyObject *M_Effect_GetParticlesLoc( PyObject * self, PyObject * args ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-23 13:11:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | /* Python BPy_Effect methods table:                                          */ | 
					
						
							| 
									
										
										
										
											2004-04-23 13:11:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyMethodDef BPy_Effect_methods[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2004-04-23 13:11:48 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Effect_Type structure definition:                                  */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyTypeObject Effect_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT( NULL ) | 
					
						
							|  |  |  | 		0,		/* ob_size */ | 
					
						
							|  |  |  | 	"Effect",		/* tp_name */ | 
					
						
							|  |  |  | 	sizeof( BPy_Effect ),	/* tp_basicsize */ | 
					
						
							|  |  |  | 	0,			/* tp_itemsize */ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	( destructor ) EffectDeAlloc,	/* tp_dealloc */ | 
					
						
							|  |  |  | 	0,			/* tp_print */ | 
					
						
							|  |  |  | 	( getattrfunc ) EffectGetAttr,	/* tp_getattr */ | 
					
						
							|  |  |  | 	( setattrfunc ) EffectSetAttr,	/* tp_setattr */ | 
					
						
							|  |  |  | 	0,			/* tp_compare */ | 
					
						
							|  |  |  | 	( reprfunc ) EffectRepr,	/* tp_repr */ | 
					
						
							|  |  |  | 	0,			/* tp_as_number */ | 
					
						
							|  |  |  | 	0,			/* tp_as_sequence */ | 
					
						
							|  |  |  | 	0,			/* tp_as_mapping */ | 
					
						
							|  |  |  | 	0,			/* tp_as_hash */ | 
					
						
							|  |  |  | 	0, 0, 0, 0, 0, 0, | 
					
						
							|  |  |  | 	0,			/* tp_doc */ | 
					
						
							|  |  |  | 	0, 0, 0, 0, 0, 0, | 
					
						
							|  |  |  | 	BPy_Effect_methods,	/* tp_methods */ | 
					
						
							|  |  |  | 	0,			/* tp_members */ | 
					
						
							| 
									
										
										
										
											2004-04-23 13:11:48 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | static char M_Effect_GetParticlesLoc_doc[] = "GetParticlesLoc(name,effect num, curframe) : current particles locations"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python method structure definition for Blender.Effect module:             */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct PyMethodDef M_Effect_methods[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"New", ( PyCFunction ) M_Effect_New, METH_VARARGS, NULL}, | 
					
						
							|  |  |  | 	{"Get", M_Effect_Get, METH_VARARGS, NULL}, | 
					
						
							|  |  |  | 	{"get", M_Effect_Get, METH_VARARGS, NULL}, | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | 	{"GetParticlesLoc", M_Effect_GetParticlesLoc, METH_VARARGS, M_Effect_GetParticlesLoc_doc}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Effect_New                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Effect.New                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *M_Effect_New( PyObject * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | 	return M_Particle_New( self, args ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Effect_Get                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Effect.Get                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *M_Effect_Get( PyObject * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	/*arguments : string object name
 | 
					
						
							|  |  |  | 	   int : position of effect in the obj's effect list  */ | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 	char *name = NULL; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Object *object_iter; | 
					
						
							|  |  |  | 	Effect *eff; | 
					
						
							|  |  |  | 	BPy_Effect *wanted_eff; | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 	int num = -1, i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "|si", &name, &num ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						"expected string int argument" ) ); | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	object_iter = G.main->object.first; | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !object_iter ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						"Scene contains no object" ) ); | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if( name ) { /* (name, num = -1) - try to find the given object */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		while( object_iter ) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 			if( !strcmp( name, object_iter->id.name + 2 ) ) { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 				eff = object_iter->effect.first; /*can be NULL: None will be returned*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (num >= 0) { /* return effect in given num position if available */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					for( i = 0; i < num; i++ ) { | 
					
						
							|  |  |  | 						if (!eff) break; | 
					
						
							|  |  |  | 						eff = eff->next; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					if (eff) { | 
					
						
							|  |  |  | 						wanted_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type); | 
					
						
							|  |  |  | 						wanted_eff->effect = eff; | 
					
						
							|  |  |  | 						return ( PyObject * ) wanted_eff; | 
					
						
							|  |  |  | 					} else { /* didn't find any effect in the given position */ | 
					
						
							|  |  |  | 						Py_INCREF(Py_None); | 
					
						
							|  |  |  | 						return Py_None; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				else {/*return a list with all effects linked to the given object*/ | 
					
						
							|  |  |  | 							/* this was pointed by Stephen Swaney */ | 
					
						
							|  |  |  | 					PyObject *effectlist = PyList_New( 0 ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					while (eff) { | 
					
						
							|  |  |  | 						BPy_Effect *found_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, | 
					
						
							|  |  |  | 							&Effect_Type); | 
					
						
							|  |  |  | 						found_eff->effect = eff; | 
					
						
							|  |  |  | 						PyList_Append( effectlist, ( PyObject * ) found_eff ); | 
					
						
							|  |  |  | 						Py_DECREF((PyObject *)found_eff); /* PyList_Append incref'ed it */ | 
					
						
							|  |  |  | 						eff = eff->next; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					return effectlist; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 			 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			object_iter = object_iter->id.next; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (!object_iter) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 				"no such object"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	else { /* () - return a list with all effects currently in Blender */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		PyObject *effectlist = PyList_New( 0 ); | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		while( object_iter ) { | 
					
						
							|  |  |  | 			if( object_iter->effect.first != NULL ) { | 
					
						
							|  |  |  | 				eff = object_iter->effect.first; | 
					
						
							|  |  |  | 				while( eff ) { | 
					
						
							|  |  |  | 					BPy_Effect *found_eff = | 
					
						
							|  |  |  | 						( BPy_Effect * ) | 
					
						
							|  |  |  | 						PyObject_NEW( BPy_Effect, | 
					
						
							|  |  |  | 							      &Effect_Type ); | 
					
						
							|  |  |  | 					found_eff->effect = eff; | 
					
						
							|  |  |  | 					PyList_Append( effectlist, | 
					
						
							|  |  |  | 						       ( PyObject * ) | 
					
						
							|  |  |  | 						       found_eff ); | 
					
						
							| 
									
										
											  
											
												BPython -- a few fixes:
-- fixed bug #1689:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1689&group_id=9
Reported by Tom Musgrove (thanks), the problem was that Window.QHandle was not passing events to windows that had id's below the current active window.  It was a stupid mistake (mine), the code was iterating from curarea instead of from the first area in the areabase list.
-- fixed bug #1568:
http://projects.blender.org/tracker/index.php?func=detail&aid=1568&group_id=9&atid=125
Stephen investigated the problem, reported by Gabriel Beloin, and left hints in the bug report, thanks :).  I also implemented what he suggested, now Effect.Get('objname') returns a list with all objname's effects and as before, Get('objname, position') returns the effect at position 'position'.  Ref doc already updated.
-- Allowed menu registration lines to appear commented out -- Python comments: '#', of course -- (suggested by Michael Reimpell) in scripts:
Some Python doc tools need the doc strings between triple double-quotes, so to avoid conflicts scripts writers can now comment out the registration code, it should work anyway.  Michael also provided a patch for this a few days ago, too (thanks), but to keep changes at a minimum because of proximity to a release I didn't use it.
											
										 
											2004-10-31 04:09:19 +00:00
										 |  |  | 					Py_DECREF((PyObject *)found_eff); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 					eff = eff->next; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			object_iter = object_iter->id.next; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 		return effectlist; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:            GetParticlesLoc                                      */ | 
					
						
							|  |  |  | /* Python equivalent:   Blender.Effect.GetParticlesLoc                       */ | 
					
						
							|  |  |  | /* Description:         Get the current location of each  particle           */ | 
					
						
							|  |  |  | /*                      and return a list of 3D coords                       */ | 
					
						
							|  |  |  | /* Data:                String object name, int particle effect number,      */ | 
					
						
							|  |  |  | /*                      float currentframe                                   */ | 
					
						
							|  |  |  | /* Return:              One python list of python lists of 3D coords         */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyObject *M_Effect_GetParticlesLoc( PyObject * self, PyObject * args  ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *name; | 
					
						
							|  |  |  | 	Object *ob; | 
					
						
							|  |  |  | 	Effect *eff; | 
					
						
							|  |  |  | 	PartEff *paf; | 
					
						
							|  |  |  | 	Particle *pa=0; | 
					
						
							|  |  |  | 	int num, i, a; | 
					
						
							|  |  |  | 	PyObject  *list; | 
					
						
							|  |  |  | 	float p_time, c_time, vec[3],cfra; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "sif", &name, &num , &cfra) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 						"expected string, int, float arguments" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for( ob = G.main->object.first; ob; ob = ob->id.next ) | 
					
						
							|  |  |  | 		if( !strcmp( name, ob->id.name + 2 ) ) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !ob ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError,  | 
					
						
							|  |  |  | 				"object does not exist" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( ob->type != OB_MESH ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError,  | 
					
						
							|  |  |  | 				"object is not a mesh" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	eff = ob->effect.first; | 
					
						
							|  |  |  | 	for( i = 0; i < num && eff; i++ ) | 
					
						
							|  |  |  | 		eff = eff->next; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( num < 0 || !eff ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_IndexError,  | 
					
						
							|  |  |  | 				"effect index out of range" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( eff->type != EFF_PARTICLE ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 				"unknown effect type" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	paf = (PartEff *)eff; | 
					
						
							|  |  |  | 	pa = paf->keys; | 
					
						
							|  |  |  | 	if( !pa ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 				"Particles location: no keys" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if( ob->ipoflag & OB_OFFS_PARTICLE ) | 
					
						
							|  |  |  | 		p_time= ob->sf; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		p_time= 0.0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	c_time= bsystem_time( ob, 0, cfra, p_time ); | 
					
						
							|  |  |  | 	list = PyList_New( 0 ); | 
					
						
							|  |  |  | 	if( !list ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, "PyList() failed" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for( a=0; a<paf->totpart; a++, pa += paf->totkey ) { | 
					
						
							|  |  |  | 		if( c_time > pa->time && c_time < pa->time+pa->lifetime ) { | 
					
						
							|  |  |  | 			where_is_particle(paf, pa, c_time, vec); | 
					
						
							|  |  |  | 			if( PyList_Append( list, Py_BuildValue("[fff]",  | 
					
						
							|  |  |  | 							vec[0], vec[1], vec[2]) ) < 0 ) { | 
					
						
							|  |  |  | 				Py_DECREF( list ); | 
					
						
							|  |  |  | 				return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 						  "Couldn't add item to list" ); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return list;	 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | /* Function:              Effect_Init                                        */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Particle_Init( void ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Effect_Init( void ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *submodule, *dict; | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Effect_Type.ob_type = &PyType_Type; | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	submodule = Py_InitModule3( "Blender.Effect", M_Effect_methods, 0 ); | 
					
						
							|  |  |  | 	dict = PyModule_GetDict( submodule ); | 
					
						
							|  |  |  | 	PyDict_SetItemString( dict, "Particle", Particle_Init(  ) ); | 
					
						
							|  |  |  | 	return ( submodule ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Python BPy_Effect methods:                                       */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Effect_getType( BPy_Effect * self ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyInt_FromLong( ( long ) self->effect->type ); | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 					"couldn't get mode attribute" ) ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-04 20:34:38 +00:00
										 |  |  | /* does nothing since there is only one type of effect */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *Effect_setType( BPy_Effect * self ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Effect_getFlag( BPy_Effect * self ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject *attr = PyInt_FromLong( ( long ) self->effect->flag ); | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 					"couldn't get mode attribute" ) ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	int value; | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "i", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 						"expected an int as argument" ) ); | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | 	self->effect->flag = (short)value; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    EffectDeAlloc                                                */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Effect type. It is   */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*              the destructor function.                                     */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | void EffectDeAlloc( BPy_Effect * self ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	PyObject_DEL( self ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    EffectGetAttr                                                */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Effect type. It is   */ | 
					
						
							|  |  |  | /*              the function that accesses BPy_Effect "member variables" and */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*              methods.                                                     */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *EffectGetAttr( BPy_Effect * self, char *name ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	switch ( self->effect->type ) { | 
					
						
							|  |  |  | 	case EFF_PARTICLE: | 
					
						
							|  |  |  | 		return ParticleGetAttr( ( BPy_Particle * ) self, name ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return Py_FindMethod( BPy_Effect_methods, ( PyObject * ) self, name ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    EffectSetAttr                                                */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Effect type. It   */ | 
					
						
							|  |  |  | /*              sets Effect Data attributes (member variables). */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	switch ( self->effect->type ) { | 
					
						
							|  |  |  | 	case EFF_PARTICLE: | 
					
						
							|  |  |  | 		return ParticleSetAttr( ( BPy_Particle * ) self, name, value ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 0;		/* normal exit */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    EffectPrint                                                  */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Effect type. It      */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*              builds a meaninful string to 'print' effcte objects.         */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-04 16:06:39 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:46:29 +00:00
										 |  |  | int EffectPrint(BPy_Effect *self, FILE *fp, int flags)  | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | {  | 
					
						
							|  |  |  | if (self->effect->type == EFF_PARTICLE)puts("Effect Particle"); | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-07-04 16:06:39 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    EffectRepr                                                   */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Effect type. It      */ | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | /*              builds a meaninful string to represent effcte objects.       */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-04 16:06:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *EffectRepr( BPy_Effect * self ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *str = ""; | 
					
						
							|  |  |  | 	if( self->effect->type == EFF_PARTICLE ) | 
					
						
							|  |  |  | 		str = "Effect Particle"; | 
					
						
							|  |  |  | 	return PyString_FromString( str ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | PyObject *EffectCreatePyObject( struct Effect * effect ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	BPy_Effect *blen_object; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	blen_object = | 
					
						
							|  |  |  | 		( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( blen_object == NULL ) { | 
					
						
							|  |  |  | 		return ( NULL ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	blen_object->effect = effect; | 
					
						
							|  |  |  | 	return ( ( PyObject * ) blen_object ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | int EffectCheckPyObject( PyObject * py_obj ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return ( py_obj->ob_type == &Effect_Type ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | struct Effect *EffectFromPyObject( PyObject * py_obj ) | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	BPy_Effect *blen_obj; | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	blen_obj = ( BPy_Effect * ) py_obj; | 
					
						
							|  |  |  | 	return ( ( Effect * ) blen_obj->effect ); | 
					
						
							| 
									
										
										
										
											2003-06-21 11:44:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |