BPython API
added a function - GenericLib_assignData for assigning blender data, to assign an ipo to a camera or world to a scene for instance. Using this function removed ~300 lines of code. also fixes user count error in some places that didnt check. also made it possible to clear the colorband by setting it to []
This commit is contained in:
parent
51c16edabc
commit
5eaf9f90c1
@ -109,7 +109,6 @@ struct PyMethodDef M_Camera_methods[] = {
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Camera methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Camera_oldgetIpo( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetType( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetMode( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetLens( BPy_Camera * self );
|
||||
@ -117,6 +116,8 @@ static PyObject *Camera_oldgetClipStart( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetClipEnd( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetDrawSize( BPy_Camera * self );
|
||||
static PyObject *Camera_oldgetScale( BPy_Camera * self );
|
||||
static PyObject *Camera_getIpo( BPy_Camera * self );
|
||||
static int Camera_setIpo( BPy_Camera * self, PyObject * value );
|
||||
static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args );
|
||||
static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args );
|
||||
static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args );
|
||||
@ -138,7 +139,7 @@ static PyObject *Camera_copy( BPy_Camera * self );
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef BPy_Camera_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getIpo", ( PyCFunction ) Camera_oldgetIpo, METH_NOARGS,
|
||||
{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
|
||||
"() - Return Camera Data Ipo"},
|
||||
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
|
||||
"() - Return Camera Data name"},
|
||||
@ -459,36 +460,7 @@ static PyObject *Camera_oldgetDrawSize( BPy_Camera * self )
|
||||
|
||||
static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args )
|
||||
{
|
||||
PyObject *pyipo = 0;
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo;
|
||||
|
||||
if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected Ipo as argument" );
|
||||
|
||||
ipo = Ipo_FromPyObject( pyipo );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_CA )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"this ipo is not a camera data ipo" );
|
||||
|
||||
oldipo = self->camera->ipo;
|
||||
if( oldipo ) {
|
||||
ID *id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
id_us_plus(&ipo->id);
|
||||
|
||||
self->camera->ipo = ipo;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
return EXPP_setterWrapper( (void *)self, args, (setter)Camera_setIpo );
|
||||
}
|
||||
|
||||
static PyObject *Camera_oldclearIpo( BPy_Camera * self )
|
||||
@ -767,43 +739,7 @@ static PyObject *Camera_getIpo( BPy_Camera * self )
|
||||
|
||||
static int Camera_setIpo( BPy_Camera * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo = self->camera->ipo;
|
||||
ID *id;
|
||||
|
||||
/* if parameter is not None, check for valid Ipo */
|
||||
|
||||
if ( value != Py_None ) {
|
||||
if ( !Ipo_CheckPyObject( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected an Ipo object" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_CA )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo is not a camera data Ipo" );
|
||||
}
|
||||
|
||||
/* if already linked to Ipo, delete link */
|
||||
|
||||
if ( oldipo ) {
|
||||
id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
/* assign new Ipo and increment user count, or set to NULL if deleting */
|
||||
|
||||
self->camera->ipo = ipo;
|
||||
if ( ipo )
|
||||
id_us_plus(&ipo->id);
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->camera->ipo, 0, 1, ID_IP, ID_CA);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1037,22 +1037,12 @@ static PyObject *Curve_getBevOb( BPy_Curve * self)
|
||||
/*****************************************************************************/
|
||||
static int Curve_newsetBevOb( BPy_Curve * self, PyObject * args )
|
||||
{
|
||||
BPy_Object *pybevobj = (BPy_Object *) args;
|
||||
|
||||
if( args == Py_None ) { /* Accept None */
|
||||
self->curve->bevobj = (Object *)NULL;
|
||||
} else { /* Accept Object with type 'Curve' */
|
||||
if( !Object_CheckPyObject( args ) ||
|
||||
pybevobj->object->type != OB_CURVE )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected Curve object type or None argument" );
|
||||
if( pybevobj->object->data == self->curve )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Can't bevel an object to itself" );
|
||||
self->curve->bevobj = Object_FromPyObject( args );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
if (Object_CheckPyObject( args ) && ((BPy_Object *)args)->object->data == self->curve )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Can't bevel an object to itself" );
|
||||
|
||||
return GenericLib_assignData(args, (void **) &self->curve->bevobj, 0, 0, ID_OB, OB_CURVE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -1075,22 +1065,11 @@ static PyObject *Curve_getTaperOb( BPy_Curve * self)
|
||||
|
||||
static int Curve_newsetTaperOb( BPy_Curve * self, PyObject * args )
|
||||
{
|
||||
BPy_Object *pytaperobj = (BPy_Object *) args;
|
||||
|
||||
if( args == Py_None ) { /* Accept None */
|
||||
self->curve->taperobj = (Object *)NULL;
|
||||
} else { /* Accept Object with type 'Curve' */
|
||||
if( !Object_CheckPyObject( args ) ||
|
||||
pytaperobj->object->type != OB_CURVE )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected Curve object type or None argument" );
|
||||
if( pytaperobj->object->data == self->curve )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Can't bevel an object to itself" );
|
||||
self->curve->taperobj = Object_FromPyObject( args );
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (Object_CheckPyObject( args ) && ((BPy_Object *)args)->object->data == self->curve )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Can't taper an object to itself" );
|
||||
|
||||
return GenericLib_assignData(args, (void **) &self->curve->taperobj, 0, 0, ID_OB, OB_CURVE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -65,12 +65,12 @@ static void KeyBlock_dealloc( PyObject * self );
|
||||
static int Key_compare( BPy_Key * a, BPy_Key * b );
|
||||
static PyObject *Key_repr( BPy_Key * self );
|
||||
|
||||
static PyObject *Key_getBlocks( PyObject * self );
|
||||
static PyObject *Key_getBlocks( BPy_Key * self );
|
||||
static PyObject *Key_getType( BPy_Key * self );
|
||||
static PyObject *Key_getRelative( BPy_Key * self );
|
||||
static PyObject *Key_getIpo( PyObject * self );
|
||||
static int Key_setIpo( PyObject * self, PyObject * args );
|
||||
static PyObject *Key_getValue( PyObject * self );
|
||||
static PyObject *Key_getIpo( BPy_Key * self );
|
||||
static int Key_setIpo( BPy_Key * self, PyObject * args );
|
||||
static PyObject *Key_getValue( BPy_Key * self );
|
||||
static int Key_setRelative( BPy_Key * self, PyObject * value );
|
||||
|
||||
static struct PyMethodDef Key_methods[] = {
|
||||
@ -319,69 +319,30 @@ static PyObject *Key_repr( BPy_Key * self )
|
||||
return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 );
|
||||
}
|
||||
|
||||
static PyObject *Key_getIpo( PyObject * self )
|
||||
static PyObject *Key_getIpo( BPy_Key * self )
|
||||
{
|
||||
BPy_Key *k = ( BPy_Key * ) self;
|
||||
BPy_Ipo *new_ipo;
|
||||
|
||||
if (k->key->ipo) {
|
||||
if (self->key->ipo) {
|
||||
new_ipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
|
||||
new_ipo->ipo = k->key->ipo;
|
||||
new_ipo->ipo = self->key->ipo;
|
||||
return (PyObject *) new_ipo;
|
||||
} else {
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static int Key_setIpo( PyObject * self, PyObject * value )
|
||||
static int Key_setIpo( BPy_Key * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo = (( BPy_Key * )self)->key->ipo;
|
||||
ID *id;
|
||||
|
||||
/* if parameter is not None, check for valid Ipo */
|
||||
|
||||
if ( value != Py_None ) {
|
||||
if ( !Ipo_CheckPyObject( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"expected an Ipo object" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_KE )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo is not a key data Ipo" );
|
||||
}
|
||||
|
||||
/* if already linked to Ipo, delete link */
|
||||
|
||||
if ( oldipo ) {
|
||||
id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
/* assign new Ipo and increment user count, or set to NULL if deleting */
|
||||
|
||||
(( BPy_Key * )self)->key->ipo = ipo;
|
||||
if ( ipo ) {
|
||||
id = &ipo->id;
|
||||
id_us_plus(id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->key->ipo, 0, 1, ID_IP, ID_KE);
|
||||
}
|
||||
|
||||
static PyObject *Key_getRelative( BPy_Key * self )
|
||||
{
|
||||
if( self->key->type == KEY_RELATIVE )
|
||||
return EXPP_incr_ret(Py_True);
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
return EXPP_incr_ret(Py_False);
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static int Key_setRelative( BPy_Key * self, PyObject * value )
|
||||
@ -418,16 +379,14 @@ static PyObject *Key_getType( BPy_Key * self )
|
||||
return PyInt_FromLong( type );
|
||||
}
|
||||
|
||||
static PyObject *Key_getBlocks( PyObject * self )
|
||||
static PyObject *Key_getBlocks( BPy_Key * self )
|
||||
{
|
||||
BPy_Key *k = ( BPy_Key * ) self;
|
||||
Key *key = k->key;
|
||||
Key *key = self->key;
|
||||
KeyBlock *kb;
|
||||
PyObject *keyblock_object;
|
||||
PyObject *l = PyList_New( 0 );
|
||||
|
||||
for (kb = key->block.first; kb; kb = kb->next) {
|
||||
|
||||
keyblock_object = KeyBlock_CreatePyObject( kb, key );
|
||||
PyList_Append( l, keyblock_object );
|
||||
}
|
||||
@ -435,7 +394,7 @@ static PyObject *Key_getBlocks( PyObject * self )
|
||||
return l;
|
||||
}
|
||||
|
||||
static PyObject *Key_getValue( PyObject * self )
|
||||
static PyObject *Key_getValue( BPy_Key * self )
|
||||
{
|
||||
BPy_Key *k = ( BPy_Key * ) self;
|
||||
|
||||
|
@ -1394,45 +1394,7 @@ static PyObject *Lamp_getIpo( BPy_Lamp * self )
|
||||
|
||||
static int Lamp_setIpo( BPy_Lamp * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo = self->lamp->ipo;
|
||||
ID *id;
|
||||
|
||||
/* if parameter is not None, check for valid Ipo */
|
||||
|
||||
if ( value != Py_None ) {
|
||||
if ( !Ipo_CheckPyObject( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"expected an Ipo object" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_LA )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo is not a lamp data Ipo" );
|
||||
}
|
||||
|
||||
/* if already linked to Ipo, delete link */
|
||||
|
||||
if ( oldipo ) {
|
||||
id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
/* assign new Ipo and increment user count, or set to NULL if deleting */
|
||||
|
||||
self->lamp->ipo = ipo;
|
||||
if ( ipo ) {
|
||||
id = &ipo->id;
|
||||
id_us_plus(id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->lamp->ipo, 0, 1, ID_IP, ID_LA);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -283,27 +283,7 @@ int MTex_CheckPyObject( PyObject * pyobj )
|
||||
|
||||
static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args )
|
||||
{
|
||||
Tex *tex;
|
||||
|
||||
if( args == Py_None )
|
||||
{
|
||||
tex = NULL;
|
||||
} else if( Texture_CheckPyObject( args ) ) {
|
||||
tex = Texture_FromPyObject( args );
|
||||
} else {
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected Texture argument" );
|
||||
}
|
||||
|
||||
if( self->mtex->tex )
|
||||
self->mtex->tex->id.us--;
|
||||
|
||||
self->mtex->tex = tex;
|
||||
|
||||
if( self->mtex->tex )
|
||||
self->mtex->tex->id.us++;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
return EXPP_setterWrapper( (void *)self, args, (setter)MTex_setTex );
|
||||
}
|
||||
|
||||
static void MTex_dealloc( BPy_MTex * self )
|
||||
@ -336,27 +316,7 @@ static PyObject *MTex_getTex( BPy_MTex *self, void *closure )
|
||||
|
||||
static int MTex_setTex( BPy_MTex *self, PyObject *value, void *closure)
|
||||
{
|
||||
Tex *tex;
|
||||
|
||||
if( value == Py_None )
|
||||
{
|
||||
tex = NULL;
|
||||
} else if( Texture_CheckPyObject( value ) ) {
|
||||
tex = Texture_FromPyObject( value );
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected Texture argument" );
|
||||
}
|
||||
|
||||
if( self->mtex->tex )
|
||||
self->mtex->tex->id.us--;
|
||||
|
||||
self->mtex->tex = tex;
|
||||
|
||||
if( self->mtex->tex )
|
||||
self->mtex->tex->id.us++;
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->mtex->tex, 0, 1, ID_TE, 0);
|
||||
}
|
||||
|
||||
static PyObject *MTex_getTexCo( BPy_MTex *self, void *closure )
|
||||
@ -397,27 +357,7 @@ static PyObject *MTex_getObject( BPy_MTex *self, void *closure )
|
||||
|
||||
static int MTex_setObject( BPy_MTex *self, PyObject *value, void *closure)
|
||||
{
|
||||
Object *obj;
|
||||
|
||||
if( value == Py_None )
|
||||
{
|
||||
obj = NULL;
|
||||
} else if( Object_CheckPyObject( value ) ) {
|
||||
obj = Object_FromPyObject( value );
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected Object argument" );
|
||||
}
|
||||
|
||||
if( self->mtex->object )
|
||||
self->mtex->object->id.us--;
|
||||
|
||||
self->mtex->object = obj;
|
||||
|
||||
if( self->mtex->object )
|
||||
self->mtex->object->id.us++;
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->mtex->object, 0, 1, ID_OB, 0);
|
||||
}
|
||||
|
||||
static PyObject *MTex_getUVLayer( BPy_MTex *self, void *closure )
|
||||
|
@ -1818,49 +1818,10 @@ static PyObject *Material_getTextures( BPy_Material * self )
|
||||
|
||||
static int Material_setIpo( BPy_Material * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo = self->material->ipo;
|
||||
ID *id;
|
||||
|
||||
/* if parameter is not None, check for valid Ipo */
|
||||
|
||||
if ( value != Py_None ) {
|
||||
if ( !Ipo_CheckPyObject( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"expected an Ipo object" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_MA )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo is not a material data Ipo" );
|
||||
}
|
||||
|
||||
/* if already linked to Ipo, delete link */
|
||||
|
||||
if ( oldipo ) {
|
||||
id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
/* assign new Ipo and increment user count, or set to NULL if deleting */
|
||||
|
||||
self->material->ipo = ipo;
|
||||
if ( ipo ) {
|
||||
id = &ipo->id;
|
||||
id_us_plus(id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->material->ipo, 0, 1, ID_IP, ID_MA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Material_insertIpoKey( key )
|
||||
* inserts Material IPO key at current frame
|
||||
@ -2084,18 +2045,9 @@ static int Material_setZOffset( BPy_Material * self, PyObject * value )
|
||||
EXPP_MAT_ZOFFS_MAX );
|
||||
}
|
||||
|
||||
static int Material_setLightGroup( BPy_Material * self, PyObject * value ) {
|
||||
BPy_Group *pygrp=NULL;
|
||||
if ( PyObject_TypeCheck(value, &Group_Type) ) {
|
||||
pygrp= (BPy_Group *)value;
|
||||
self->material->group= pygrp->group;
|
||||
} else if (value==Py_None) {
|
||||
self->material->group= NULL;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected a group or None" );
|
||||
}
|
||||
return 0;
|
||||
static int Material_setLightGroup( BPy_Material * self, PyObject * value )
|
||||
{
|
||||
return GenericLib_assignData(value, (void **) &self->material->group, NULL, 1, ID_GR, 0);
|
||||
}
|
||||
|
||||
static int Material_setAdd( BPy_Material * self, PyObject * value )
|
||||
@ -2505,22 +2457,31 @@ PyObject *EXPP_PyList_fromColorband( ColorBand *coba )
|
||||
}
|
||||
|
||||
/* make sure you coba is not none before calling this */
|
||||
int EXPP_Colorband_fromPyList( ColorBand *coba, PyObject * value )
|
||||
int EXPP_Colorband_fromPyList( ColorBand **coba, PyObject * value )
|
||||
{
|
||||
short totcol, i;
|
||||
PyObject *colseq;
|
||||
PyObject *pyflt;
|
||||
float f;
|
||||
|
||||
if ( !PySequence_Check( value ) )
|
||||
if ( !PySequence_Check( value ) )
|
||||
return ( EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Colorband must be a sequence" ) );
|
||||
|
||||
totcol = PySequence_Size(value);
|
||||
if (totcol < 1 || totcol > 31)
|
||||
if ( totcol > 31)
|
||||
return ( EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Colorband must be between 1 and 31 in length" ) );
|
||||
|
||||
if (totcol==0) {
|
||||
MEM_freeN(*coba);
|
||||
*coba = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!*coba)
|
||||
*coba = MEM_callocN( sizeof(ColorBand), "colorband");
|
||||
|
||||
for (i=0; i<totcol; i++) {
|
||||
colseq = PySequence_GetItem( value, i );
|
||||
if ( !PySequence_Check( colseq ) || PySequence_Size( colseq ) != 5) {
|
||||
@ -2542,38 +2503,38 @@ int EXPP_Colorband_fromPyList( ColorBand *coba, PyObject * value )
|
||||
}
|
||||
|
||||
/* ok, continue - should check for 5 floats, will ignore non floats for now */
|
||||
coba->tot = totcol;
|
||||
(*coba)->tot = totcol;
|
||||
for (i=0; i<totcol; i++) {
|
||||
colseq = PySequence_GetItem( value, i );
|
||||
|
||||
pyflt = PySequence_GetItem( colseq, 0 );
|
||||
f = (float)PyFloat_AsDouble( pyflt );
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
coba->data[i].r = f;
|
||||
(*coba)->data[i].r = f;
|
||||
Py_DECREF ( pyflt );
|
||||
|
||||
pyflt = PySequence_GetItem( colseq, 1 );
|
||||
f = (float)PyFloat_AsDouble( pyflt );
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
coba->data[i].g = f;
|
||||
(*coba)->data[i].g = f;
|
||||
Py_DECREF ( pyflt );
|
||||
|
||||
pyflt = PySequence_GetItem( colseq, 2 );
|
||||
f = (float)PyFloat_AsDouble( pyflt );
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
coba->data[i].b = f;
|
||||
(*coba)->data[i].b = f;
|
||||
Py_DECREF ( pyflt );
|
||||
|
||||
pyflt = PySequence_GetItem( colseq, 3 );
|
||||
f = (float)PyFloat_AsDouble( pyflt );
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
coba->data[i].a = f;
|
||||
(*coba)->data[i].a = f;
|
||||
Py_DECREF ( pyflt );
|
||||
|
||||
pyflt = PySequence_GetItem( colseq, 4 );
|
||||
f = (float)PyFloat_AsDouble( pyflt );
|
||||
CLAMP(f, 0.0, 1.0);
|
||||
coba->data[i].pos = f;
|
||||
(*coba)->data[i].pos = f;
|
||||
Py_DECREF ( pyflt );
|
||||
|
||||
Py_DECREF ( colseq );
|
||||
@ -2814,13 +2775,9 @@ int Material_setColorband( BPy_Material * self, PyObject * value, void * type)
|
||||
{
|
||||
switch( (long)type ) {
|
||||
case 0: /* these are backwards, but that how it works */
|
||||
if (!self->material->ramp_col)
|
||||
self->material->ramp_col = MEM_callocN( sizeof(ColorBand), "colorband");
|
||||
return EXPP_Colorband_fromPyList( self->material->ramp_col, value );
|
||||
return EXPP_Colorband_fromPyList( &self->material->ramp_col, value );
|
||||
case 1:
|
||||
if (!self->material->ramp_spec)
|
||||
self->material->ramp_spec = MEM_callocN( sizeof(ColorBand), "colorband");
|
||||
return EXPP_Colorband_fromPyList( self->material->ramp_spec, value );
|
||||
return EXPP_Colorband_fromPyList( &self->material->ramp_spec, value );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ int Material_CheckPyObject( PyObject * pyobj );
|
||||
|
||||
/* colorband tp_getseters */
|
||||
PyObject *EXPP_PyList_fromColorband( ColorBand *coba );
|
||||
int EXPP_Colorband_fromPyList( ColorBand *coba, PyObject * value );
|
||||
int EXPP_Colorband_fromPyList( ColorBand **coba, PyObject * value );
|
||||
|
||||
/* Some functions needed by NMesh, Curve and friends */
|
||||
PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
|
||||
|
@ -7508,27 +7508,13 @@ static PyObject *Mesh_getTexMesh( BPy_Mesh * self )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int Mesh_setTexMesh( BPy_Mesh * self, PyObject * arg )
|
||||
{
|
||||
static int Mesh_setTexMesh( BPy_Mesh * self, PyObject * value )
|
||||
{
|
||||
int ret = GenericLib_assignData(value, (void **) &self->mesh->texcomesh, 0, 1, ID_ME, 0);
|
||||
|
||||
/*None or Mesh*/
|
||||
if ( arg != Py_None && !Mesh_CheckPyObject(arg) )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"texmesh must be a Mesh or None type" );
|
||||
if (ret==0 && value!=Py_None) /*This must be a mesh type*/
|
||||
(( BPy_Mesh * ) value)->new= 0;
|
||||
|
||||
/*remove existing texmesh*/
|
||||
if (self->mesh->texcomesh) {
|
||||
self->mesh->texcomesh->id.us--;
|
||||
self->mesh->texcomesh= NULL;
|
||||
}
|
||||
|
||||
if (arg != Py_None) { /* its a mesh */
|
||||
BPy_Mesh *blen_obj = ( BPy_Mesh * ) arg;
|
||||
/*This is a mesh so it needs to be added */
|
||||
self->mesh->texcomesh= blen_obj->mesh;
|
||||
self->mesh->texcomesh->id.us++;
|
||||
blen_obj->new= 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -398,27 +398,8 @@ static int armature_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
ArmatureModifierData *md = (ArmatureModifierData *)(self->md);
|
||||
|
||||
switch( type ) {
|
||||
case EXPP_MOD_OBJECT: {
|
||||
Object *ob_new=NULL;
|
||||
if (value == Py_None) {
|
||||
md->object = NULL;
|
||||
} else if (BPy_Object_Check( value )) {
|
||||
ob_new = ((( BPy_Object * )value)->object);
|
||||
if( ob_new->type != OB_ARMATURE) {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"this object is not a supported type" );
|
||||
}
|
||||
|
||||
if( ob_new == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot assign the object to its self" );
|
||||
md->object = ob_new;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Expected an Object or None value" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case EXPP_MOD_OBJECT:
|
||||
return GenericLib_assignData(value, (void **) &md->object, 0, 0, ID_OB, OB_ARMATURE);
|
||||
case EXPP_MOD_VERTGROUP:
|
||||
return EXPP_setBitfield( value, &md->deformflag, 1, 'h' );
|
||||
case EXPP_MOD_ENVELOPES:
|
||||
@ -447,27 +428,8 @@ static int lattice_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
LatticeModifierData *md = (LatticeModifierData *)(self->md);
|
||||
|
||||
switch( type ) {
|
||||
case EXPP_MOD_OBJECT: {
|
||||
Object *ob_new=NULL;
|
||||
if (value == Py_None) {
|
||||
md->object = NULL;
|
||||
} else if (BPy_Object_Check( value )) {
|
||||
ob_new = ((( BPy_Object * )value)->object);
|
||||
if( ob_new->type != OB_LATTICE) {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"this object is not a supported type" );
|
||||
}
|
||||
|
||||
if( ob_new == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot assign the object to its self" );
|
||||
md->object = ob_new;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Expected an Object or None value" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case EXPP_MOD_OBJECT:
|
||||
return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_LATTICE);
|
||||
case EXPP_MOD_VERTGROUP: {
|
||||
char *name = PyString_AsString( value );
|
||||
if( !name )
|
||||
@ -501,26 +463,8 @@ static int curve_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
CurveModifierData *md = (CurveModifierData *)(self->md);
|
||||
|
||||
switch( type ) {
|
||||
case EXPP_MOD_OBJECT: {
|
||||
Object *ob_new=NULL;
|
||||
if (value == Py_None) {
|
||||
md->object = NULL;
|
||||
} else if (BPy_Object_Check( value )) {
|
||||
ob_new = ((( BPy_Object * )value)->object);
|
||||
if( ob_new->type != OB_CURVE) {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"this object is not a supported type" );
|
||||
}
|
||||
if( ob_new == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot assign the object to its self" );
|
||||
md->object = ob_new;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Expected an Object or None value" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case EXPP_MOD_OBJECT:
|
||||
return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_CURVE);
|
||||
case EXPP_MOD_VERTGROUP: {
|
||||
char *name = PyString_AsString( value );
|
||||
if( !name )
|
||||
@ -715,40 +659,10 @@ static int array_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
{
|
||||
ArrayModifierData *md = (ArrayModifierData *)(self->md);
|
||||
switch( type ) {
|
||||
case EXPP_MOD_OBJECT_OFFSET: {
|
||||
Object *ob_new=NULL;
|
||||
if (value == Py_None) {
|
||||
md->offset_ob = NULL;
|
||||
} else if (BPy_Object_Check( value )) {
|
||||
ob_new = ((( BPy_Object * )value)->object);
|
||||
|
||||
if( ob_new == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot assign the object to its self" );
|
||||
md->offset_ob = ob_new;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Expected an Object or None value" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case EXPP_MOD_OBJECT_CURVE: {
|
||||
Object *ob_new=NULL;
|
||||
if (value == Py_None) {
|
||||
md->curve_ob = NULL;
|
||||
} else if (BPy_Object_Check( value )) {
|
||||
ob_new = ((( BPy_Object * )value)->object);
|
||||
|
||||
if( ob_new == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot assign the object to its self" );
|
||||
md->curve_ob = ob_new;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Expected an Object or None value" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case EXPP_MOD_OBJECT_OFFSET:
|
||||
return GenericLib_assignData(value, (void **) &md->offset_ob, (void **) &self->object, 0, ID_OB, 0);
|
||||
case EXPP_MOD_OBJECT_CURVE:
|
||||
return GenericLib_assignData(value, (void **) &md->curve_ob, 0, 0, ID_OB, OB_CURVE);
|
||||
case EXPP_MOD_COUNT:
|
||||
return EXPP_setIValueClamped( value, &md->count, 1, 1000, 'i' );
|
||||
case EXPP_MOD_LENGTH:
|
||||
@ -780,17 +694,9 @@ static int boolean_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
{
|
||||
BooleanModifierData *md = (BooleanModifierData *)(self->md);
|
||||
|
||||
if( type == EXPP_MOD_OBJECT ) {
|
||||
Object *ob = (( BPy_Object * )value)->object;
|
||||
if( !BPy_Object_Check( value ) || ob->type != OB_MESH )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected BPy mesh object argument" );
|
||||
if(ob == self->object )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot boolean an object with its self" );
|
||||
md->object = ob;
|
||||
return 0;
|
||||
} else if( type == EXPP_MOD_OPERATION )
|
||||
if( type == EXPP_MOD_OBJECT )
|
||||
return GenericLib_assignData(value, (void **) &md->object, (void **) &self->object, 0, ID_OB, OB_MESH);
|
||||
else if( type == EXPP_MOD_OPERATION )
|
||||
return EXPP_setIValueRange( value, &md->operation,
|
||||
eBooleanModifierOp_Intersect, eBooleanModifierOp_Difference,
|
||||
'h' );
|
||||
@ -870,23 +776,7 @@ static int displace_setter( BPy_Modifier *self, int type, PyObject *value )
|
||||
|
||||
switch( type ) {
|
||||
case EXPP_MOD_TEXTURE:
|
||||
if (md->texture)
|
||||
md->texture->id.us--;
|
||||
|
||||
if (value == Py_None) {
|
||||
md->texture = NULL;
|
||||
} else if (Texture_CheckPyObject(value)) {
|
||||
BPy_Texture *bpytex = (BPy_Texture *)value;
|
||||
md->texture = bpytex->texture;
|
||||
md->texture->id.us--;
|
||||
|
||||
} else {
|
||||
if (md->texture)
|
||||
md->texture->id.us++;
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Texture must be of Texture or None type" );
|
||||
}
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &md->texture, 0, 1, ID_TE, 0);
|
||||
case EXPP_MOD_STRENGTH:
|
||||
return EXPP_setFloatClamped( value, &md->strength, -1000.0, 1000.0 );
|
||||
|
||||
|
@ -2982,26 +2982,9 @@ static PyObject *Object_getDupliGroup( BPy_Object * self )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int Object_setDupliGroup( BPy_Object * self, BPy_Group * args )
|
||||
static int Object_setDupliGroup( BPy_Object * self, PyObject * value )
|
||||
{
|
||||
Object *ob= self->object;
|
||||
|
||||
if( (PyObject *)args == Py_None ) {
|
||||
if (ob->dup_group)
|
||||
ob->dup_group->id.us--;
|
||||
|
||||
ob->dup_group = NULL;
|
||||
} else if( BPy_Group_Check( args ) ) {
|
||||
if (ob->dup_group)
|
||||
ob->dup_group->id.us--;
|
||||
|
||||
ob->dup_group = args->group;
|
||||
id_us_plus(&ob->dup_group->id);
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected a group or None" );
|
||||
}
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->object->dup_group, 0, 1, ID_GR, 0);
|
||||
}
|
||||
|
||||
static PyObject *Object_getEffects( BPy_Object * self )
|
||||
@ -4307,43 +4290,7 @@ static int Object_setLayersMask( BPy_Object *self, PyObject *value )
|
||||
|
||||
static int Object_setIpo( BPy_Object * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo = self->object->ipo;
|
||||
ID *id;
|
||||
|
||||
/* if parameter is not None, check for valid Ipo */
|
||||
|
||||
if ( value != Py_None ) {
|
||||
if ( !Ipo_CheckPyObject( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected an Ipo object" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_OB )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo is not a object data Ipo" );
|
||||
}
|
||||
|
||||
/* if already linked to Ipo, delete link */
|
||||
|
||||
if ( oldipo ) {
|
||||
id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
/* assign new Ipo and increment user count, or set to NULL if deleting */
|
||||
|
||||
self->object->ipo = ipo;
|
||||
if ( ipo )
|
||||
id_us_plus(&ipo->id);
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->object->ipo, 0, 1, ID_IP, ID_OB);
|
||||
}
|
||||
|
||||
static PyObject *Object_getOopsLoc( BPy_Object * self )
|
||||
@ -4434,20 +4381,13 @@ static int Object_setOopsSel( BPy_Object * self, PyObject * value )
|
||||
|
||||
static int Object_setTracked( BPy_Object * self, PyObject * value )
|
||||
{
|
||||
Object *ob = self->object;
|
||||
|
||||
if( value != Py_None && !BPy_Object_Check( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected an object argument" );
|
||||
|
||||
if( value != Py_None )
|
||||
ob->track = ((BPy_Object *)value)->object;
|
||||
else
|
||||
ob->track = ((BPy_Object *)value)->object;
|
||||
self->object->recalc |= OB_RECALC_OB;
|
||||
DAG_scene_sort( G.scene );
|
||||
|
||||
return 0;
|
||||
int ret;
|
||||
ret = GenericLib_assignData(value, (void **) &self->object->track, 0, 0, ID_OB, 0);
|
||||
if (ret==0) {
|
||||
self->object->recalc |= OB_RECALC_OB;
|
||||
DAG_scene_sort( G.scene );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Localspace matrix */
|
||||
|
@ -962,14 +962,7 @@ static PyObject *PoseBone_getDisplayObject(BPy_PoseBone *self, void *closure)
|
||||
//Sets the pose bones object used for display
|
||||
static int PoseBone_setDisplayObject(BPy_PoseBone *self, PyObject *value, void *closure)
|
||||
{
|
||||
if (value == Py_None) {
|
||||
self->posechannel->custom = NULL;
|
||||
} else if (BPy_Object_Check(value)) {
|
||||
self->posechannel->custom = Object_FromPyObject(value);
|
||||
} else {
|
||||
return EXPP_ReturnIntError(PyExc_AttributeError, "can only assign a Blender Object or None");
|
||||
}
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->posechannel->custom, 0, 0, ID_OB, 0);
|
||||
}
|
||||
|
||||
//------------------------PoseBone.hasIK (getter)
|
||||
|
@ -368,27 +368,8 @@ static PyObject *Scene_getWorld( BPy_Scene * self )
|
||||
|
||||
static int Scene_setWorld( BPy_Scene * self, PyObject * value )
|
||||
{
|
||||
World *world=NULL;
|
||||
|
||||
SCENE_DEL_CHECK_INT(self);
|
||||
|
||||
/* accepts a World or None */
|
||||
if (BPy_World_Check(value)) {
|
||||
world = World_FromPyObject(value);
|
||||
} else if (value != Py_None) {
|
||||
return ( EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected a world object" ) );
|
||||
}
|
||||
|
||||
/* If there is a world then it now has one less user */
|
||||
if( self->scene->world )
|
||||
self->scene->world->id.us--;
|
||||
|
||||
if (world)
|
||||
world->id.us++;
|
||||
|
||||
G.scene->world = world;
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->scene->world, NULL, 1, ID_WO, 0);
|
||||
}
|
||||
|
||||
/* accessed from scn.objects */
|
||||
@ -398,8 +379,6 @@ static PyObject *Scene_getObjects( BPy_Scene *self)
|
||||
return SceneObSeq_CreatePyObject(self, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyObject *Scene_getCursor( BPy_Scene * self )
|
||||
{
|
||||
SCENE_DEL_CHECK_PY(self);
|
||||
@ -1685,30 +1664,21 @@ PyObject *SceneObSeq_getCamera(BPy_SceneObSeq *self)
|
||||
static int SceneObSeq_setCamera(BPy_SceneObSeq *self, PyObject *value)
|
||||
{
|
||||
SCENE_DEL_CHECK_INT(self->bpyscene);
|
||||
|
||||
int ret;
|
||||
if (self->mode!=EXPP_OBSEQ_NORMAL)
|
||||
return (EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"cannot set camera from objects.selected or objects.context" ));
|
||||
|
||||
if (value==Py_None) {
|
||||
self->bpyscene->scene->camera= NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!BPy_Object_Check(value))
|
||||
return (EXPP_ReturnIntError( PyExc_ValueError,
|
||||
"Object or None types can only be assigned to camera!" ));
|
||||
|
||||
self->bpyscene->scene->camera= ((BPy_Object *)value)->object;
|
||||
ret = GenericLib_assignData(value, (void **) &self->bpyscene->scene->camera, 0, 0, ID_OB, 0);
|
||||
|
||||
/* if this is the current scene, update its window now */
|
||||
if( !G.background && self->bpyscene->scene == G.scene ) /* Traced a crash to redrawing while in background mode -Campbell */
|
||||
if( ret == 0 && !G.background && self->bpyscene->scene == G.scene ) /* Traced a crash to redrawing while in background mode -Campbell */
|
||||
copy_view3d_lock( REDRAW );
|
||||
|
||||
/* XXX copy_view3d_lock(REDRAW) prints "bad call to addqueue: 0 (18, 1)".
|
||||
* The same happens in bpython. */
|
||||
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2662,9 +2662,7 @@ static PyObject *Texture_getColorband( BPy_Texture * self)
|
||||
|
||||
int Texture_setColorband( BPy_Texture * self, PyObject * value)
|
||||
{
|
||||
if (!self->texture->coba)
|
||||
self->texture->coba = MEM_callocN( sizeof(ColorBand), "colorband");
|
||||
return EXPP_Colorband_fromPyList( self->texture->coba, value );
|
||||
return EXPP_Colorband_fromPyList( &self->texture->coba, value );
|
||||
}
|
||||
|
||||
static PyObject *Texture_evaluate( BPy_Texture * self, PyObject * args )
|
||||
|
@ -522,35 +522,7 @@ static PyObject *World_getIpo( BPy_World * self )
|
||||
|
||||
static int World_setIpo( BPy_World * self, PyObject * value )
|
||||
{
|
||||
Ipo *ipo = NULL;
|
||||
Ipo *oldipo;
|
||||
|
||||
if( !BPy_Ipo_Check(value) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected Ipo as argument" );
|
||||
|
||||
ipo = Ipo_FromPyObject( value );
|
||||
|
||||
if( !ipo )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"null ipo!" );
|
||||
|
||||
if( ipo->blocktype != ID_WO )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"this ipo is not a World type ipo" );
|
||||
|
||||
oldipo = self->world->ipo;
|
||||
if( oldipo ) {
|
||||
ID *id = &oldipo->id;
|
||||
if( id->us > 0 )
|
||||
id->us--;
|
||||
}
|
||||
|
||||
id_us_plus(&ipo->id);
|
||||
|
||||
self->world->ipo = ipo;
|
||||
|
||||
return 0;
|
||||
return GenericLib_assignData(value, (void **) &self->world->ipo, 0, 1, ID_IP, ID_WO);
|
||||
}
|
||||
|
||||
static PyObject *World_oldsetIpo( BPy_World * self, PyObject * args )
|
||||
|
@ -49,6 +49,14 @@
|
||||
|
||||
#include "constant.h"
|
||||
|
||||
/* GenericLib */
|
||||
#include "World.h"
|
||||
#include "Object.h"
|
||||
#include "Texture.h"
|
||||
#include "Ipo.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_ipo_types.h"
|
||||
|
||||
/*---------------------- EXPP_FloatsAreEqual -------------------------
|
||||
Floating point comparisons
|
||||
floatStep = number of representable floats allowable in between
|
||||
@ -1039,3 +1047,78 @@ PyObject * GenericLib_setName_with_method( void *self, PyObject *args )
|
||||
return EXPP_setterWrapper( (void *)self, args, (setter)GenericLib_setName );
|
||||
}
|
||||
|
||||
|
||||
/* returns the Blender lib type code from a PyObject
|
||||
-1 for no match, only give this function libdata */
|
||||
short GenericLib_getType(PyObject * pydata)
|
||||
{
|
||||
//~ if (BPy_Scene_Check(pydata)) return ID_SCE;
|
||||
if (BPy_Object_Check(pydata)) return ID_OB;
|
||||
//~ if (BPy_Mesh_Check(pydata)) return ID_ME;
|
||||
//~ if (BPy_Curve_Check(pydata)) return ID_CU;
|
||||
//~ if (BPy_Metaball_Check(pydata)) return ID_MB;
|
||||
//~ if (BPy_Material_Check(pydata)) return ID_MA;
|
||||
if (BPy_Texture_Check(pydata)) return ID_TE;
|
||||
//~ if (BPy_Image_Check(pydata)) return ID_IM;
|
||||
//~ //if (BPy_Lattice_Check(pydata)) return ID_LT;
|
||||
//~ if (BPy_Lamp_Check(pydata)) return ID_LA;
|
||||
//~ if (BPy_Camera_Check(pydata)) return ID_CA;
|
||||
if (BPy_Ipo_Check(pydata)) return ID_IP;
|
||||
if (BPy_World_Check(pydata)) return ID_WO;
|
||||
//~ //if (BPy_Font_Check(pydata)) return ID_VF;
|
||||
//~ if (BPy_Text_Check(pydata)) return ID_TXT;
|
||||
//~ if (BPy_Sound_Check(pydata)) return ID_SO;
|
||||
//~ if (BPy_Group_Check(pydata)) return ID_GR;
|
||||
//~ if (BPy_Armature_Check(pydata)) return ID_AR;
|
||||
//~ if (BPy_Action_Check(pydata)) return ID_AC;
|
||||
|
||||
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int GenericLib_assignData(PyObject *value, void **data, void **ndata, short refcount, short type, short subtype)
|
||||
{
|
||||
ID *id=NULL;
|
||||
|
||||
if (*data && ndata && *data == *ndata) {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Cannot set this data to its self" );
|
||||
|
||||
id = ((ID*)*data);
|
||||
}
|
||||
if (value == Py_None) {
|
||||
*data = NULL;
|
||||
if (refcount && id) id->us--;
|
||||
} else if (GenericLib_getType(value) == type) {
|
||||
|
||||
/* object subtypes */
|
||||
if (subtype != 0) {
|
||||
if (type == ID_OB) {
|
||||
Object *ob= ((BPy_GenericLib *)value)->id;
|
||||
if (ob->type != subtype)
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Object type not supported" );
|
||||
}
|
||||
|
||||
if (type == ID_IP) {
|
||||
Ipo *ipo = ((BPy_GenericLib *)value)->id;
|
||||
if (ipo->blocktype != subtype)
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Ipo type does is not compatible" );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (refcount && id) id->us--;
|
||||
id = ((BPy_GenericLib *)value)->id;
|
||||
id->us++;
|
||||
*data = id;
|
||||
} else {
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"Could not assign Python Type - None or Library Object" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -169,7 +169,6 @@ typedef struct {
|
||||
} BPy_GenericLib;
|
||||
|
||||
|
||||
|
||||
/* ID functions for all libdata */
|
||||
#define GENERIC_LIB_GETSETATTR \
|
||||
{"name",\
|
||||
@ -194,8 +193,6 @@ typedef struct {
|
||||
NULL}
|
||||
|
||||
|
||||
|
||||
|
||||
int GenericLib_setName( void *self, PyObject *value );
|
||||
PyObject *GenericLib_getName( void *self );
|
||||
PyObject *GenericLib_getFakeUser( void *self );
|
||||
@ -207,4 +204,7 @@ PyObject *GenericLib_getProperties( void *self );
|
||||
/* use this for oldstyle somedata.getName("name") */
|
||||
PyObject * GenericLib_setName_with_method( void *self, PyObject *value );
|
||||
|
||||
int GenericLib_assignData(PyObject *value, void **data, void **ndata, short refcount, short type, short subtype);
|
||||
short GenericLib_getType(PyObject * pydata);
|
||||
|
||||
#endif /* EXPP_gen_utils_h */
|
||||
|
Loading…
Reference in New Issue
Block a user