===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.
This commit is contained in:
Ken Hughes
2006-07-04 00:08:40 +00:00
parent c4b4e2922f
commit e6f4bd6baf
2 changed files with 53 additions and 0 deletions

View File

@@ -268,6 +268,10 @@ class RenderData:
@ivar mapNew: New mapping value (in frames).
Values are clamped to the range [1,900].
@type mapNew: int
@ivar set: The scene linked as a set to this scene. Values are an existing
scene or None (setting to None clears the set). The scene argument cannot
cause a circular link.
@type set: BPy_Scene or None
"""
def currentFrame(frame = None):

View File

@@ -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}
};