replaced id->us++ with id_us_plus(id); so any indirect libdata isnt lost on reload.

added camera.dofDist to the python camera module
This commit is contained in:
2006-12-24 03:25:53 +00:00
parent 1c6f41a27a
commit b72bfbd923
10 changed files with 75 additions and 38 deletions

View File

@@ -104,6 +104,7 @@ static PyObject *Camera_getMode( BPy_Camera * self );
static PyObject *Camera_getLens( BPy_Camera * self );
static PyObject *Camera_getClipStart( BPy_Camera * self );
static PyObject *Camera_getClipEnd( BPy_Camera * self );
static PyObject *Camera_getDofDist( BPy_Camera * self );
static PyObject *Camera_getDrawSize( BPy_Camera * self );
static PyObject *Camera_getScale( BPy_Camera * self );
static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args );
@@ -116,6 +117,7 @@ static PyObject *Camera_setIntMode( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setDofDist( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args );
static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args );
static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args );
@@ -149,6 +151,8 @@ static PyMethodDef BPy_Camera_methods[] = {
"() - Return Camera clip start value"},
{"getClipEnd", ( PyCFunction ) Camera_getClipEnd, METH_NOARGS,
"() - Return Camera clip end value"},
{"getDofDist", ( PyCFunction ) Camera_getDofDist, METH_NOARGS,
"() - Return Camera dof distance value"},
{"getDrawSize", ( PyCFunction ) Camera_getDrawSize, METH_NOARGS,
"() - Return Camera draw size value"},
{"setIpo", ( PyCFunction ) Camera_setIpo, METH_VARARGS,
@@ -171,6 +175,8 @@ static PyMethodDef BPy_Camera_methods[] = {
"(f) - Set Camera clip start value"},
{"setClipEnd", ( PyCFunction ) Camera_setClipEnd, METH_VARARGS,
"(f) - Set Camera clip end value"},
{"setDifDist", ( PyCFunction ) Camera_setDofDist, METH_VARARGS,
"(f) - Set Camera DOF Distance"},
{"setDrawSize", ( PyCFunction ) Camera_setDrawSize, METH_VARARGS,
"(f) - Set Camera draw size value"},
{"getScriptLinks", ( PyCFunction ) Camera_getScriptLinks, METH_VARARGS,
@@ -421,10 +427,8 @@ static PyObject *Camera_getIpo( BPy_Camera * self )
{
struct Ipo *ipo = self->camera->ipo;
if( !ipo ) {
Py_INCREF( Py_None );
return Py_None;
}
if( !ipo )
Py_RETURN_NONE;
return Ipo_CreatePyObject( ipo );
}
@@ -512,6 +516,17 @@ static PyObject *Camera_getClipEnd( BPy_Camera * self )
"couldn't get Camera.clipEnd attribute" );
}
static PyObject *Camera_getDofDist( BPy_Camera * self )
{
PyObject *attr = PyFloat_FromDouble( self->camera->YF_dofdist );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Camera.dofDist attribute" );
}
static PyObject *Camera_getDrawSize( BPy_Camera * self )
{
PyObject *attr = PyFloat_FromDouble( self->camera->drawsize );
@@ -552,12 +567,11 @@ static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args )
id->us--;
}
( ( ID * ) & ipo->id )->us++;
id_us_plus(&ipo->id); //( ( ID * ) & ipo->id )->us++;
self->camera->ipo = ipo;
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_clearIpo( BPy_Camera * self )
@@ -590,8 +604,7 @@ static PyObject *Camera_setName( BPy_Camera * self, PyObject * args )
rename_id( &self->camera->id, buf );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setType( BPy_Camera * self, PyObject * args )
@@ -610,8 +623,7 @@ static PyObject *Camera_setType( BPy_Camera * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"unknown camera type" );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
/* This one is 'private'. It is not really a method, just a helper function for
@@ -634,8 +646,7 @@ static PyObject *Camera_setIntType( BPy_Camera * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"expected int argument: 0 or 1" );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setMode( BPy_Camera * self, PyObject * args )
@@ -670,8 +681,7 @@ static PyObject *Camera_setMode( BPy_Camera * self, PyObject * args )
self->camera->flag = flag;
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
/* Another helper function, for the same reason.
@@ -691,8 +701,7 @@ static PyObject *Camera_setIntMode( BPy_Camera * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"expected int argument in [0,3]" );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args )
@@ -707,8 +716,7 @@ static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args )
EXPP_CAM_LENS_MIN,
EXPP_CAM_LENS_MAX );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args )
@@ -723,8 +731,7 @@ static PyObject *Camera_setScale( BPy_Camera * self, PyObject * args )
EXPP_CAM_SCALE_MIN,
EXPP_CAM_SCALE_MAX );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args )
@@ -739,8 +746,7 @@ static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args )
EXPP_CAM_CLIPSTART_MIN,
EXPP_CAM_CLIPSTART_MAX );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args )
@@ -755,8 +761,22 @@ static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args )
EXPP_CAM_CLIPEND_MIN,
EXPP_CAM_CLIPEND_MAX );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
static PyObject *Camera_setDofDist( BPy_Camera * self, PyObject * args )
{
float value;
if( !PyArg_ParseTuple( args, "f", &value ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected float argument" );
self->camera->YF_dofdist = EXPP_ClampFloat( value,
0.0,
5000.0 );
Py_RETURN_NONE;
}
static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args )
@@ -771,8 +791,7 @@ static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args )
EXPP_CAM_DRAWSIZE_MIN,
EXPP_CAM_DRAWSIZE_MAX );
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
/* cam.addScriptLink */
@@ -862,6 +881,8 @@ static PyObject *Camera_getAttr( BPy_Camera * self, char *name )
attr = PyFloat_FromDouble( self->camera->clipsta );
else if( strcmp( name, "clipEnd" ) == 0 )
attr = PyFloat_FromDouble( self->camera->clipend );
else if( strcmp( name, "dofDist" ) == 0 )
attr = PyFloat_FromDouble( self->camera->YF_dofdist );
else if( strcmp( name, "drawSize" ) == 0 )
attr = PyFloat_FromDouble( self->camera->drawsize );
else if( strcmp( name, "users" ) == 0 )
@@ -932,6 +953,8 @@ static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * value )
error = Camera_setClipStart( self, valtuple );
else if( strcmp( name, "clipEnd" ) == 0 )
error = Camera_setClipEnd( self, valtuple );
else if( strcmp( name, "dofDist" ) == 0 )
error = Camera_setDofDist( self, valtuple );
else if( strcmp( name, "drawSize" ) == 0 )
error = Camera_setDrawSize( self, valtuple );
@@ -1000,5 +1023,5 @@ static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args )
EXPP_allqueue(REDRAWACTION, 0);
EXPP_allqueue(REDRAWNLA, 0);
return EXPP_incr_ret( Py_None );
Py_RETURN_NONE;
}

View File

@@ -369,7 +369,7 @@ static int Key_setIpo( PyObject * self, PyObject * value )
(( BPy_Key * )self)->key->ipo = ipo;
if ( ipo ) {
id = &ipo->id;
id->us++;
id_us_plus(id);
}
return 0;

View File

@@ -48,8 +48,8 @@ extern PyTypeObject KeyBlock_Type;
typedef struct {
PyObject_HEAD /* required python macro */
Key * key;
// Object *object; /* for vertex grouping info, since it's stored on the object */
//PyObject *keyBlock;
/* Object *object;/* /* for vertex grouping info, since it's stored on the object */
/*PyObject *keyBlock;*/
PyObject *ipo;
} BPy_Key;
@@ -57,7 +57,7 @@ typedef struct {
PyObject_HEAD /* required python macro */
Key *key;
KeyBlock * keyblock;
// Object *object; /* for vertex grouping info, since it's stored on the object */
/* Object *object;*/ /* for vertex grouping info, since it's stored on the object */
} BPy_KeyBlock;
PyObject *Key_CreatePyObject( Key * k );

View File

@@ -1498,7 +1498,7 @@ static int Lamp_setIpo( BPy_Lamp * self, PyObject * value )
self->lamp->ipo = ipo;
if ( ipo ) {
id = &ipo->id;
id->us++;
id_us_plus(id);
}
return 0;

View File

@@ -1920,7 +1920,7 @@ static int Material_setIpo( BPy_Material * self, PyObject * value )
self->material->ipo = ipo;
if ( ipo ) {
id = &ipo->id;
id->us++;
id_us_plus(id);
}
return 0;

View File

@@ -3111,7 +3111,7 @@ static int Object_setDupliGroup( BPy_Object * self, BPy_Group * args )
ob->dup_group->id.us--;
ob->dup_group = args->group;
ob->dup_group->id.us++;
id_us_plus(&ob->dup_group->id);
} else {
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a group or None" );

View File

@@ -1375,7 +1375,7 @@ typeError:
object = alloc_libblock( &( G.main->object ), ID_OB, name );
if( data ) {
object->data = data;
((ID *)data)->us++;
id_us_plus((ID *)data);
}
object->flag = SELECT;

View File

@@ -1996,7 +1996,7 @@ static int Texture_setIpo( BPy_Texture * self, PyObject * value )
self->texture->ipo = ipo;
if ( ipo ) {
id = &ipo->id;
id->us++;
id_us_plus(id); //id->us++;
}
return 0;

View File

@@ -480,7 +480,7 @@ static PyObject *World_setIpo( BPy_World * self, PyObject * args )
id->us--;
}
( ( ID * ) & ipo->id )->us++;
id_us_plus(&ipo->id);
self->world->ipo = ipo;

View File

@@ -58,6 +58,7 @@ class Camera:
cameras.
@ivar clipStart: The clip start value in [0.0, 100.0].
@ivar clipEnd: The clip end value in [1.0, 5000.0].
@ivar dofDist: The dofDist value in [0.0, 5000.0].
@ivar drawSize: The draw size value in [0.1, 10.0].
@type ipo: Blender Ipo
@ivar ipo: The "camera data" ipo linked to this camera data object.
@@ -188,6 +189,19 @@ class Camera:
@param clipend: The new clip end value.
"""
def getDofDist():
"""
Get the dofDist value.
@rtype: float
"""
def setDofDist(dist):
"""
Set the dofDist value.
@type dist: float
@param dist: The new dof distance value.
"""
def getDrawSize():
"""
Get the draw size value.