From c4b8a431bcb4b02c9da4e14485e97f6e4cbfa3a3 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Thu, 29 Sep 2005 07:05:00 +0000 Subject: [PATCH] fix Curve.update() method to use new DAG features. --- source/blender/python/api2_2x/Curve.c | 8 ++++---- source/blender/python/api2_2x/Object.c | 24 ++++++++++++++++++++---- source/blender/python/api2_2x/Object.h | 2 ++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index 1a65031f1a7..a79f1e63c4c 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -440,7 +440,8 @@ PyObject *Curve_Init( void ) { PyObject *submodule; - Curve_Type.ob_type = &PyType_Type; + if( PyType_Ready( &Curve_Type) < 0) /* set exception. -1 is failure */ + return NULL; submodule = Py_InitModule3( "Blender.Curve", M_Curve_methods, @@ -1280,10 +1281,9 @@ static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args ) PyObject *Curve_update( BPy_Curve * self ) { - freedisplist( &self->curve->disp ); + Object_updateDag( (void*) self->curve ); - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; } /* diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 25c21c4a587..db0584bcefd 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -116,10 +116,6 @@ static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args ); /* HELPER FUNCTION FOR PARENTING */ static PyObject *internal_makeParent(Object *parent, PyObject *py_child, int partype, int noninverse, int fast, int v1, int v2, int v3); -extern int Text3d_CheckPyObject( PyObject * py_obj ); -extern struct Text3d *Text3d_FromPyObject( PyObject * py_obj ); - - /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ /* In Python these will be written to the console when doing a */ @@ -4077,3 +4073,23 @@ int setupPI(Object* ob){ return 0; } } + +/* + * scan list of Objects looking for matching obdata. + * if found, set OB_RECALC_DATA flag. + * call this from a bpy type update() method. + */ + +void Object_updateDag( void *data ) +{ + Object *ob; + + if( !data) + return; + + for( ob= G.main->object.first; ob; ob= ob->id.next){ + if( ob->data == data){ + ob->recalc |= OB_RECALC_DATA; + } + } +} diff --git a/source/blender/python/api2_2x/Object.h b/source/blender/python/api2_2x/Object.h index c97e2346c07..79783db619f 100644 --- a/source/blender/python/api2_2x/Object.h +++ b/source/blender/python/api2_2x/Object.h @@ -57,6 +57,8 @@ Object *Object_FromPyObject( PyObject * py_obj ); int Object_CheckPyObject( PyObject * py_obj ); Object *GetObjectByName( char *name ); +void Object_updateDag( void *data ); + int EXPP_add_obdata( struct Object *object ); #endif /* EXPP_OBJECT_H */