diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-03-07 12:53:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-03-07 12:53:40 +0300 |
commit | d79f21eba7cd5f72b551911ccc34d3b2cd12eef0 (patch) | |
tree | 185ae9fb960ef7de3e9ae8a1f430a1787bb399f1 | |
parent | 37c7d4d385f4fcebaff03af91bd54dc6a0cfa523 (diff) |
DNA_meta_types.h - had a max element type defined that wasnt used anywhere, and some metaballs alredy use more then 1024 elements.
Metaball - added metaball.update attribute and constants Mataball.Update.ALWAYS, NEVER, HALFRES and NEVER
-rw-r--r-- | source/blender/makesdna/DNA_meta_types.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Metaball.c | 88 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Metaball.py | 10 |
3 files changed, 75 insertions, 25 deletions
diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index c96681e2223..e14782cf5ca 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -93,8 +93,6 @@ typedef struct MetaBall { /* **************** METABALL ********************* */ -#define MB_MAXELEM 1024 - /* texflag */ #define MB_AUTOSPACE 1 diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index 3ed3750abff..6cef3227943 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -102,6 +102,21 @@ static PyObject *M_MetaElem_TypesDict( void ) return Types; } +static PyObject *M_MetaElem_UpdateDict( void ) +{ + PyObject *Update = PyConstant_New( ); + + if( Update ) { + BPy_constant *d = ( BPy_constant * ) Update; + PyConstant_Insert( d, "ALWAYS", PyInt_FromLong( MB_UPDATE_ALWAYS ) ); + PyConstant_Insert( d, "HALFRES",PyInt_FromLong( MB_UPDATE_HALFRES ) ); + PyConstant_Insert( d, "FAST", PyInt_FromLong( MB_UPDATE_FAST ) ); + PyConstant_Insert( d, "NEVER", PyInt_FromLong( MB_UPDATE_NEVER ) ); + } + + return Update; +} + /*****************************************************************************/ /* Python BPy_Metaball methods declarations: */ /*****************************************************************************/ @@ -114,6 +129,8 @@ static PyObject *Metaball_getRendersize( BPy_Metaball * self ); static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value); static PyObject *Metaball_getThresh( BPy_Metaball * self ); static int Metaball_setThresh( BPy_Metaball * self, PyObject * args ); +static PyObject *Metaball_getUpdate( BPy_Metaball * self ); +static int Metaball_setUpdate( BPy_Metaball * self, PyObject * args ); static PyObject *Metaball_copy( BPy_Metaball * self ); /*****************************************************************************/ @@ -188,6 +205,10 @@ static PyGetSetDef BPy_Metaball_getseters[] = { (getter)Metaball_getThresh, (setter)Metaball_setThresh, "The density to render wire", NULL}, + {"update", + (getter)Metaball_getUpdate, (setter)Metaball_setUpdate, + "The setting for updating this metaball data", + NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -413,7 +434,7 @@ static PyObject *M_Metaball_New( PyObject * self, PyObject * args ) if( !PyArg_ParseTuple( args, "|s", &name ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, - "expected string argument (or nothing)" ) ); + "Metaball.New() - expected string argument (or nothing)" ) ); blmball = add_mball( ); /* first create the MetaBall Data in Blender */ @@ -426,7 +447,7 @@ static PyObject *M_Metaball_New( PyObject * self, PyObject * args ) &Metaball_Type ); } else return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, - "couldn't create MetaBall Data in Blender" ) ); + "Metaball.New() - couldn't create data in Blender" ) ); if( pymball == NULL ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, @@ -456,15 +477,15 @@ static PyObject *M_Metaball_Get( PyObject * self, PyObject * args ) if( !PyArg_ParseTuple( args, "|s", &name ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, - "expected string argument (or nothing)" ) ); + "Metaball.Get() - expected string argument (or nothing)" ) ); if( name ) { /* (name) - Search mball by name */ mball_iter = ( MetaBall * ) GetIdFromList( &( G.main->mball ), name ); if (!mball_iter) { - char error_msg[64]; + char error_msg[128]; PyOS_snprintf( error_msg, sizeof( error_msg ), - "MetaBall \"%s\" not found", name ); + "Metaball.Get(\"%s\") - not found", name ); return ( EXPP_ReturnPyObjError ( PyExc_NameError, error_msg ) ); } @@ -477,7 +498,7 @@ static PyObject *M_Metaball_Get( PyObject * self, PyObject * args ) if( mballlist == NULL ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, - "couldn't create PyList" ) ); + "MetaBall.Get() - couldn't create PyList" ) ); mball_iter = G.main->mball.first; while( mball_iter ) { @@ -497,7 +518,8 @@ static PyObject *M_Metaball_Get( PyObject * self, PyObject * args ) PyObject *Metaball_Init( void ) { PyObject *submodule; - PyObject *Types= M_MetaElem_TypesDict( ); + PyObject *Types= M_MetaElem_TypesDict( ); + PyObject *Update= M_MetaElem_UpdateDict( ); if( PyType_Ready( &Metaball_Type ) < 0 ) return NULL; @@ -510,6 +532,7 @@ PyObject *Metaball_Init( void ) if( Types ) PyModule_AddObject( submodule, "Types", Types ); + PyModule_AddObject( submodule, "Update", Update ); /*Add SUBMODULES to the module*/ /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/ @@ -542,12 +565,12 @@ static int Metaball_setMaterials( BPy_Metaball *self, PyObject * value ) if( !PySequence_Check( value ) || !EXPP_check_sequence_consistency( value, &Material_Type ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "list should only contain materials or None)" ); + "metaball.materials - list should only contain materials or None)" ); len = PyList_Size( value ); if( len > 16 ) return EXPP_ReturnIntError( PyExc_TypeError, - "list can't have more than 16 materials" ); + "metaball.materials - list can't have more than 16 materials" ); /* free old material list (if it exists) and adjust user counts */ if( self->metaball->mat ) { @@ -587,7 +610,7 @@ static int Metaball_setWiresize( BPy_Metaball * self, PyObject * value ) float param; if( !PyNumber_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected float argument" ); + "metaball.wiresize - expected float argument" ); param = (float)PyFloat_AsDouble( value ); @@ -606,7 +629,7 @@ static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value ) float param; if( !PyNumber_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected float argument" ); + "metaball.rendersize - expected float argument" ); param = (float)PyFloat_AsDouble( value ); @@ -625,7 +648,7 @@ static int Metaball_setThresh( BPy_Metaball * self, PyObject * value ) float param; if( !PyNumber_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected float argument" ); + "metaball.thresh - expected float argument" ); param = (float)PyFloat_AsDouble( value ); @@ -633,6 +656,25 @@ static int Metaball_setThresh( BPy_Metaball * self, PyObject * value ) return 0; } +static PyObject *Metaball_getUpdate( BPy_Metaball * self ) +{ + return PyInt_FromLong( (long)self->metaball->flag ); +} + +static int Metaball_setUpdate( BPy_Metaball * self, PyObject * value ) +{ + + int param; + if( !PyInt_CheckExact( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "metaball.update - expected an int argument" ); + + param = (int)PyInt_AS_LONG( value ); + + self->metaball->flag = EXPP_ClampInt( param, 0, 3 ); + return 0; +} + static PyObject *Metaball_copy( BPy_Metaball * self ) { BPy_Metaball *pymball; /* for Data object wrapper in Python */ @@ -649,11 +691,11 @@ static PyObject *Metaball_copy( BPy_Metaball * self ) &Metaball_Type ); } else return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, - "couldn't create MetaBall Data in Blender" ) ); + "metaball.__copy__() - couldn't create data in Blender" ) ); if( pymball == NULL ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, - "couldn't create MetaBall Data object" ) ); + "metaball.__copy__() - couldn't create data in Blender" ) ); pymball->metaball = blmball; @@ -725,7 +767,7 @@ static PyObject *Metaelem_getType( BPy_Metaelem *self ) return attr; return EXPP_ReturnPyObjError( PyExc_MemoryError, - "PyInt_FromLong() failed!" ); + "metaelem.type - PyInt_FromLong() failed!" ); } static int Metaelem_setType( BPy_Metaelem * self, PyObject * value ) { @@ -733,7 +775,7 @@ static int Metaelem_setType( BPy_Metaelem * self, PyObject * value ) int type; if( !PyInt_CheckExact( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected an integer (bitmask) as argument" ); + "metaelem.type - expected an integer (bitmask) as argument" ); METAELEM_DEL_CHECK_INT(self); @@ -741,7 +783,7 @@ static int Metaelem_setType( BPy_Metaelem * self, PyObject * value ) if( (type < 0) || ( type > ( MB_BALL | MB_TUBEX | MB_TUBEY | MB_TUBEZ | MB_TUBE | MB_PLANE | MB_ELIPSOID | MB_CUBE ) )) return EXPP_ReturnIntError( PyExc_ValueError, - "value out of range" ); + "metaelem.type - value out of range" ); self->metaelem->type= type; return 0; @@ -767,7 +809,7 @@ static int Metaelem_setCoord( BPy_Metaelem * self, VectorObject * value ) if( !VectorObject_Check( value ) || value->size != 3 ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected vector argument of size 3" ); + "metaelem.co - expected vector argument of size 3" ); METAELEM_DEL_CHECK_INT(self); @@ -795,7 +837,7 @@ static int Metaelem_setDims( BPy_Metaelem * self, VectorObject * value ) { if( !VectorObject_Check( value ) || value->size != 3 ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected vector argument of size 3" ); + "metaelem.dims - expected vector argument of size 3" ); METAELEM_DEL_CHECK_INT(self); @@ -819,7 +861,7 @@ static int Metaelem_setQuat( BPy_Metaelem * self, QuaternionObject * value ) int i; if( !QuaternionObject_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected quat argument" ); + "metaelem.quat - expected quat argument" ); METAELEM_DEL_CHECK_INT(self); @@ -860,7 +902,7 @@ static int Metaelem_setStiffness( BPy_Metaelem *self, PyObject *value) { if( !PyNumber_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected float argument" ); + "metaelem.stiffness - expected float argument" ); self->metaelem->s = EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 10.0); return 0; @@ -878,7 +920,7 @@ static int Metaelem_setRadius( BPy_Metaelem *self, PyObject *value) { if( !PyNumber_Check( value ) ) return EXPP_ReturnIntError( PyExc_TypeError, - "expected float argument" ); + "metaelem.radius - expected float argument" ); self->metaelem->rad = /* is 5000 too small? */ EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 5000.0); @@ -1043,7 +1085,7 @@ static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, PyObject *args ) if( !PyArg_ParseTuple( args, "O!", &Metaelem_Type, &elem) ) return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a Metaball element" ); + "elements.remove(metaelem) - expected a Metaball element" ); METAELEM_DEL_CHECK_PY(elem); diff --git a/source/blender/python/api2_2x/doc/Metaball.py b/source/blender/python/api2_2x/doc/Metaball.py index 704638ea742..69bcbedafae 100644 --- a/source/blender/python/api2_2x/doc/Metaball.py +++ b/source/blender/python/api2_2x/doc/Metaball.py @@ -95,6 +95,14 @@ Example:: - PLANE - ELIPSOID - CUBE + +@type Update: readonly dictionary +@var Update: MeteElement types. + - ALWAYS + - HALFRES + - FAST + - NEVER + """ @@ -141,6 +149,8 @@ class Metaball: @ivar materials: List of up to 16 Materials or None types Only the first material of the mother-ball used at the moment. @type materials: list + @ivar update: The update method to use for this metaball. + @type update: int """ def __copy__(): |