Scene.c - world could not be set to None, added "cursor" attribute.

Scene.py - added docs for new scen attributes.
meshtools.c - typo
This commit is contained in:
2007-03-01 13:22:26 +00:00
parent e966aa549e
commit 69eb4eefb5
3 changed files with 52 additions and 4 deletions

View File

@@ -78,6 +78,8 @@ struct View3D;
#include "sceneRadio.h" #include "sceneRadio.h"
#include "sceneTimeLine.h" #include "sceneTimeLine.h"
#include "BKE_utildefines.h" /* vec copy */
#include "vector.h"
PyObject *M_Object_Get( PyObject * self, PyObject * args ); /* from Object.c */ PyObject *M_Object_Get( PyObject * self, PyObject * args ); /* from Object.c */
@@ -367,15 +369,21 @@ static int Scene_setWorld( BPy_Scene * self, PyObject * value )
SCENE_DEL_CHECK_INT(self); SCENE_DEL_CHECK_INT(self);
if (!BPy_World_Check(value)) /* accepts a World or None */
if (BPy_World_Check(value)) {
world = World_FromPyObject(value);
} else if (value != Py_None) {
return ( EXPP_ReturnIntError( PyExc_TypeError, return ( EXPP_ReturnIntError( PyExc_TypeError,
"expected a world object" ) ); "expected a world object" ) );
}
world = World_FromPyObject(value);
/* If there is a world then it now has one less user */ /* If there is a world then it now has one less user */
if( self->scene->world ) if( self->scene->world )
self->scene->world->id.us--; self->scene->world->id.us--;
world->id.us++;
if (world)
world->id.us++;
G.scene->world = world; G.scene->world = world;
return 0; return 0;
} }
@@ -387,6 +395,32 @@ static PyObject *Scene_getObjects( BPy_Scene *self)
return SceneObSeq_CreatePyObject(self, NULL, 0); return SceneObSeq_CreatePyObject(self, NULL, 0);
} }
static PyObject *Scene_getCursor( BPy_Scene * self )
{
SCENE_DEL_CHECK_PY(self);
return newVectorObject( self->scene->cursor, 3, Py_WRAP );
}
static int Scene_setCursor( BPy_Scene * self, PyObject * value )
{
VectorObject *bpy_vec;
SCENE_DEL_CHECK_INT(self);
if (!VectorObject_Check(value))
return ( EXPP_ReturnIntError( PyExc_TypeError,
"expected a vector" ) );
bpy_vec = (VectorObject *)value;
if (bpy_vec->size != 3)
return ( EXPP_ReturnIntError( PyExc_ValueError,
"can only assign a 3D vector" ) );
VECCOPY(self->scene->cursor, bpy_vec->vec);
return 0;
}
/*****************************************************************************/ /*****************************************************************************/
/* Python attributes get/set structure: */ /* Python attributes get/set structure: */
/*****************************************************************************/ /*****************************************************************************/
@@ -404,6 +438,10 @@ static PyGetSetDef BPy_Scene_getseters[] = {
(getter)Scene_getWorld, (setter)Scene_setWorld, (getter)Scene_getWorld, (setter)Scene_setWorld,
"Scene layer bitmask", "Scene layer bitmask",
NULL}, NULL},
{"cursor",
(getter)Scene_getCursor, (setter)Scene_setCursor,
"Scene layer bitmask",
NULL},
{"timeline", {"timeline",
(getter)Scene_getTimeLine, (setter)NULL, (getter)Scene_getTimeLine, (setter)NULL,
"Scenes timeline (read only)", "Scenes timeline (read only)",

View File

@@ -105,6 +105,16 @@ class Scene:
print scene.layers # will print: [1, 3] print scene.layers # will print: [1, 3]
@type objects: sequence of objects @type objects: sequence of objects
@ivar objects: The scene's objects. The sequence supports the methods .link(ob), .unlink(ob), and .new(obdata), and can be iterated over. @ivar objects: The scene's objects. The sequence supports the methods .link(ob), .unlink(ob), and .new(obdata), and can be iterated over.
@type cursor: Vector (wrapped)
@ivar cursor: the 3d cursor location for this scene.
@type world: World or None
@ivar world: The world that this scene uses (if any)
@type timeline: Timeline
@ivar timeline: The L{timeline<TimeLine.TimeLine>} for this scene, named markers are stored here. (read only)
@type render: RenderData
@ivar render: The scenes L{render<Render>} settings. (read only)
@type radiosity: RenderData
@ivar radiosity: The scenes L{radiosity<Radio>} settings. (read only)
""" """
def getName(): def getName():

View File

@@ -497,7 +497,7 @@ void sort_faces(void)
if(G.obedit) return; if(G.obedit) return;
if(ob->type!=OB_MESH) return; if(ob->type!=OB_MESH) return;
event = pupmenu("Soft Faces by%t|View Axis (back to front)%x1|View Axis (front to back)%x2|Cursor Distance (near to far)%x3|Cursor Distance (far to near)%x4|Z Axis%x5"); event = pupmenu("Sort Faces by%t|View Axis (back to front)%x1|View Axis (front to back)%x2|Cursor Distance (near to far)%x3|Cursor Distance (far to near)%x4|Z Axis%x5");
if (event==-1) return; if (event==-1) return;
me= ob->data; me= ob->data;