Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-03-08 17:37:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-03-08 17:37:34 +0300
commit5eaf9f90c1acc1b337a3fee38887f5db2a46ac81 (patch)
tree6c2608c7d77487761dfeefc0caf15be68dd64b0b /source/blender/python/api2_2x/Scene.c
parent51c16edabc18a13e91bee1a35cbe39eb1e911ea3 (diff)
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 []
Diffstat (limited to 'source/blender/python/api2_2x/Scene.c')
-rw-r--r--source/blender/python/api2_2x/Scene.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index ffe6ca7510e..8c8c2bda89c 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -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;
}