Pydrivers: Ipo Drivers controlled by Python expressions

wiki with info: http://mediawiki.blender.org/index.php/BlenderDev/PyDrivers

(there are two sample .blends in the patch tracker entry, last link in
the wiki page)

Notes:

In usiblender.c I just made Python exit before the main library gets
freed. I found a situation with pydrivers where py's gc tried to del
objects on exit and their ID's were not valid anymore (so sigsegv).

Ton needs to check the depsgraph part.

For now pydrivers can reference their own object, something normal
ipodrivers can't. This seems to work fine and is quite useful, but if
tests prove the restriction is necessary, we just need to uncomment a
piece of code in EXPP_interface.c, marked with "XXX".

Thanks Ton for the ipodrivers code and adding the hooks for the py part
and Martin for the "Button Python Evaluation" patch from which I started
this one.

Anyone interested, please check the wiki, the .blends (they have
README's) and tell me about any issue.
This commit is contained in:
Willian Padovani Germano
2006-04-30 16:22:31 +00:00
parent 3b84767824
commit 89dab4397d
12 changed files with 437 additions and 22 deletions

View File

@@ -110,6 +110,7 @@ struct rctf;
#include "Group.h"
#include "Modifier.h"
#include "gen_utils.h"
#include "EXPP_interface.h"
#include "BIF_editkey.h"
/* Defines for insertIpoKey */
@@ -787,6 +788,10 @@ PyObject *M_Object_Get( PyObject * self, PyObject * args )
buffer );
}
/* objects used in pydriver expressions need this */
if (bpy_during_pydriver())
bpy_pydriver_appendToList(object);
return Object_CreatePyObject( object );
} else {
/* No argument has been given. Return a list of all objects. */
@@ -794,11 +799,17 @@ PyObject *M_Object_Get( PyObject * self, PyObject * args )
Link *link;
int index;
/* do not allow Get() (w/o arguments) inside pydriver, otherwise
* we'd have to update all objects in the DAG */
if (bpy_during_pydriver())
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"Object.Get requires an argument when used in pydrivers" );
obj_list = PyList_New( BLI_countlist( &( G.main->object ) ) );
if( !obj_list )
return EXPP_ReturnPyObjError( PyExc_SystemError,
"List creation failed." );
"List creation failed." );
link = G.main->object.first;
index = 0;