diff options
author | Ken Hughes <khughes@pacific.edu> | 2006-07-04 04:08:40 +0400 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2006-07-04 04:08:40 +0400 |
commit | e6f4bd6bafd2dd93ea7d03cc9c5296df152195b6 (patch) | |
tree | 645ee0b98245ab5d0dff219b7b4ce68483704806 /source/blender/python/api2_2x/sceneRender.c | |
parent | c4b4e2922fb7a219decd9702cd2924e2bc4117d4 (diff) |
===Python API===
Plumiferos request: added sceneRender.set attribute, which give access
to the Render "Set" link for scenes. Always wondered what that button
was for.
Diffstat (limited to 'source/blender/python/api2_2x/sceneRender.c')
-rw-r--r-- | source/blender/python/api2_2x/sceneRender.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c index 22dea4fc60b..b35f81dca8a 100644 --- a/source/blender/python/api2_2x/sceneRender.c +++ b/source/blender/python/api2_2x/sceneRender.c @@ -38,6 +38,7 @@ struct View3D; /* keep me up here */ #include "BKE_image.h" #include "BKE_global.h" #include "BKE_screen.h" +#include "BKE_scene.h" #include "BIF_drawscene.h" #include "BIF_renderwin.h" @@ -51,6 +52,8 @@ struct View3D; /* keep me up here */ #include "blendef.h" #include "gen_utils.h" +#include "Scene.h" + /* local defines */ #define PY_NONE 0 #define PY_LOW 1 @@ -1502,6 +1505,7 @@ static int RenderData_setFloatAttrClamp( BPy_RenderData *self, PyObject *value, max = 5.0f; param = &self->renderContext->blurfac; break; + default: return EXPP_ReturnIntError( PyExc_RuntimeError, "undefined type constant in RenderData_setFloatAttrClamp" ); } @@ -1981,6 +1985,47 @@ static int RenderData_setMapNew( BPy_RenderData *self, PyObject *value ) return result; } +static PyObject *RenderData_getSet( BPy_RenderData *self ) +{ + if( self->scene->set ) + return Scene_CreatePyObject( self->scene->set ); + Py_RETURN_NONE; +} + +static int RenderData_setSet( BPy_RenderData *self, PyObject *value ) +{ + BPy_Scene *sc; + + /* if "None", delete the link to the scene */ + if( value == Py_None ) { + self->scene->set = NULL; + return 0; + } + + /* be sure argument is a Scene */ + if( !BPy_Scene_Check( value ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected Scene as argument" ); + + /* check for attempt to link to ourselves */ + sc = (BPy_Scene *)value; + if( self->scene == sc->scene ) + return EXPP_ReturnIntError( PyExc_ValueError, + "cannot link a scene to itself" ); + + /* + * Accept the set link, then check for a circular link. If circular link + * exists, scene_check_setscene() sets self->scene->set to NULL. + */ + + self->scene->set = sc->scene; + if( !scene_check_setscene( self->scene ) ) + return EXPP_ReturnIntError( PyExc_ValueError, + "linking scene would create a cycle" ); + + return 0; +} + /***************************************************************************/ /* BPy_RenderData attribute def */ /***************************************************************************/ @@ -2196,6 +2241,10 @@ static PyGetSetDef BPy_RenderData_getseters[] = { (getter)RenderData_getMapNew, (setter)RenderData_setMapNew, "New mapping value (in frames)", NULL}, + {"set", + (getter)RenderData_getSet, (setter)RenderData_setSet, + "Scene link 'set' value", + NULL}, {NULL,NULL,NULL,NULL,NULL} }; |