added Window.Get/SetActiveLayer() and changed how scn.objects.new() works, if scn is the active scene it uses the 3d views active layer to create the object in.
This commit is contained in:
@@ -1522,7 +1522,18 @@ typeError:
|
|||||||
"couldn't allocate new Base for object" );
|
"couldn't allocate new Base for object" );
|
||||||
|
|
||||||
base->object = object; /* link object to the new base */
|
base->object = object; /* link object to the new base */
|
||||||
|
|
||||||
|
if (scene == G.scene && G.vd) {
|
||||||
|
if (G.vd->localview) {
|
||||||
|
object->lay= G.vd->layact + G.vd->lay;
|
||||||
|
} else {
|
||||||
|
object->lay= G.vd->layact;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
base->lay= object->lay = scene->lay & ((1<<20)-1); /* Layer, by default visible*/
|
base->lay= object->lay = scene->lay & ((1<<20)-1); /* Layer, by default visible*/
|
||||||
|
}
|
||||||
|
|
||||||
|
base->lay= object->lay;
|
||||||
|
|
||||||
base->flag = SELECT;
|
base->flag = SELECT;
|
||||||
object->id.us = 1; /* we will exist once in this scene */
|
object->id.us = 1; /* we will exist once in this scene */
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ static PyObject *M_Window_GetCursorPos( PyObject * self );
|
|||||||
static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args );
|
static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args );
|
||||||
static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args );
|
static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args );
|
||||||
static PyObject *M_Window_GetViewVector( PyObject * self );
|
static PyObject *M_Window_GetViewVector( PyObject * self );
|
||||||
|
static PyObject *M_Window_GetActiveLayer( PyObject * self );
|
||||||
|
static PyObject *M_Window_SetActiveLayer( PyObject * self, PyObject * args );
|
||||||
static PyObject *M_Window_GetViewQuat( PyObject * self );
|
static PyObject *M_Window_GetViewQuat( PyObject * self );
|
||||||
static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args );
|
static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args );
|
||||||
static PyObject *M_Window_GetViewOffset( PyObject * self );
|
static PyObject *M_Window_GetViewOffset( PyObject * self );
|
||||||
@@ -158,6 +160,12 @@ static char M_Window_WaitCursor_doc[] =
|
|||||||
static char M_Window_GetViewVector_doc[] =
|
static char M_Window_GetViewVector_doc[] =
|
||||||
"() - Get the current 3d view vector as a list of three floats [x,y,z].";
|
"() - Get the current 3d view vector as a list of three floats [x,y,z].";
|
||||||
|
|
||||||
|
static char M_Window_GetActiveLayer_doc[] =
|
||||||
|
"() - Get the current 3d views active layer where new objects are created.";
|
||||||
|
|
||||||
|
static char M_Window_SetActiveLayer_doc[] =
|
||||||
|
"(int) - Set the current 3d views active layer where new objects are created.";
|
||||||
|
|
||||||
static char M_Window_GetViewMatrix_doc[] =
|
static char M_Window_GetViewMatrix_doc[] =
|
||||||
"() - Get the current 3d view matrix.";
|
"() - Get the current 3d view matrix.";
|
||||||
|
|
||||||
@@ -296,6 +304,10 @@ struct PyMethodDef M_Window_methods[] = {
|
|||||||
M_Window_WaitCursor_doc},
|
M_Window_WaitCursor_doc},
|
||||||
{"GetViewVector", ( PyCFunction ) M_Window_GetViewVector, METH_NOARGS,
|
{"GetViewVector", ( PyCFunction ) M_Window_GetViewVector, METH_NOARGS,
|
||||||
M_Window_GetViewVector_doc},
|
M_Window_GetViewVector_doc},
|
||||||
|
{"GetActiveLayer", ( PyCFunction ) M_Window_GetActiveLayer, METH_NOARGS,
|
||||||
|
M_Window_GetActiveLayer_doc},
|
||||||
|
{"SetActiveLayer", ( PyCFunction ) M_Window_SetActiveLayer, METH_VARARGS,
|
||||||
|
M_Window_SetActiveLayer_doc},
|
||||||
{"GetViewQuat", ( PyCFunction ) M_Window_GetViewQuat, METH_NOARGS,
|
{"GetViewQuat", ( PyCFunction ) M_Window_GetViewQuat, METH_NOARGS,
|
||||||
M_Window_GetViewQuat_doc},
|
M_Window_GetViewQuat_doc},
|
||||||
{"SetViewQuat", ( PyCFunction ) M_Window_SetViewQuat, METH_VARARGS,
|
{"SetViewQuat", ( PyCFunction ) M_Window_SetViewQuat, METH_VARARGS,
|
||||||
@@ -402,8 +414,7 @@ PyObject *M_Window_Redraw( PyObject * self, PyObject * args )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -422,9 +433,7 @@ static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args )
|
|||||||
static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args )
|
static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args )
|
||||||
{
|
{
|
||||||
EXPP_allqueue( REDRAWALL, 0 );
|
EXPP_allqueue( REDRAWALL, 0 );
|
||||||
|
Py_RETURN_NONE;
|
||||||
Py_INCREF( Py_None );
|
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -539,8 +548,7 @@ static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
activate_fileselect( FILE_BLENDER, title, filename, getSelectedFile );
|
activate_fileselect( FILE_BLENDER, title, filename, getSelectedFile );
|
||||||
|
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args )
|
static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args )
|
||||||
@@ -604,8 +612,7 @@ static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
activate_imageselect( FILE_BLENDER, title, filename, getSelectedFile );
|
activate_imageselect( FILE_BLENDER, title, filename, getSelectedFile );
|
||||||
|
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -687,8 +694,7 @@ static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args )
|
|||||||
G.scene->cursor[2] = val[2];
|
G.scene->cursor[2] = val[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
|
static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
|
||||||
@@ -701,7 +707,7 @@ static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
waitcursor( bool ); /* nonzero bool sets, zero unsets */
|
waitcursor( bool ); /* nonzero bool sets, zero unsets */
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -713,10 +719,8 @@ static PyObject *M_Window_GetViewVector( PyObject * self )
|
|||||||
float *vec = NULL;
|
float *vec = NULL;
|
||||||
PyObject *pylist;
|
PyObject *pylist;
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec = G.vd->viewinv[2];
|
vec = G.vd->viewinv[2];
|
||||||
|
|
||||||
@@ -729,15 +733,58 @@ static PyObject *M_Window_GetViewVector( PyObject * self )
|
|||||||
return pylist;
|
return pylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Function: M_Window_GetActiveLayer */
|
||||||
|
/* Python equivalent: Blender.Window.GetActiveLayer */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static PyObject *M_Window_GetActiveLayer( PyObject * self )
|
||||||
|
{
|
||||||
|
if (!G.vd) {
|
||||||
|
return PyInt_FromLong(0);
|
||||||
|
} else {
|
||||||
|
return PyInt_FromLong( G.vd->layact );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *M_Window_SetActiveLayer( PyObject * self, PyObject * args )
|
||||||
|
{
|
||||||
|
int layer, bit=1;
|
||||||
|
if( !PyArg_ParseTuple( args, "i", &layer ) )
|
||||||
|
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||||
|
"expected an int" ) );
|
||||||
|
|
||||||
|
if (!G.vd)
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
|
||||||
|
bit= 0;
|
||||||
|
while(bit<32) {
|
||||||
|
if(layer & (1<<bit)) {
|
||||||
|
G.vd->layact= 1<<bit;
|
||||||
|
G.vd->lay |= G.vd->layact;
|
||||||
|
|
||||||
|
if (G.vd->scenelock) {
|
||||||
|
G.scene->lay |= G.vd->layact;
|
||||||
|
}
|
||||||
|
bit = -1; /* no error */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bit++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bit != -1)
|
||||||
|
return ( EXPP_ReturnPyObjError( PyExc_ValueError,
|
||||||
|
"The flag could not be used for the active layer" ) );
|
||||||
|
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_GetViewQuat( PyObject * self )
|
static PyObject *M_Window_GetViewQuat( PyObject * self )
|
||||||
{
|
{
|
||||||
float *vec = NULL;
|
float *vec = NULL;
|
||||||
PyObject *pylist;
|
PyObject *pylist;
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec = G.vd->viewquat;
|
vec = G.vd->viewquat;
|
||||||
|
|
||||||
@@ -755,10 +802,8 @@ static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
|
|||||||
int ok = 0;
|
int ok = 0;
|
||||||
float val[4];
|
float val[4];
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( PyObject_Length( args ) == 4 )
|
if( PyObject_Length( args ) == 4 )
|
||||||
ok = PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2],
|
ok = PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2],
|
||||||
@@ -776,7 +821,7 @@ static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
|
|||||||
G.vd->viewquat[2] = val[2];
|
G.vd->viewquat[2] = val[2];
|
||||||
G.vd->viewquat[3] = val[3];
|
G.vd->viewquat[3] = val[3];
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_GetViewOffset( PyObject * self )
|
static PyObject *M_Window_GetViewOffset( PyObject * self )
|
||||||
@@ -784,10 +829,8 @@ static PyObject *M_Window_GetViewOffset( PyObject * self )
|
|||||||
float *vec = NULL;
|
float *vec = NULL;
|
||||||
PyObject *pylist;
|
PyObject *pylist;
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec = G.vd->ofs;
|
vec = G.vd->ofs;
|
||||||
|
|
||||||
@@ -805,10 +848,8 @@ static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
|
|||||||
int ok = 0;
|
int ok = 0;
|
||||||
float val[3];
|
float val[3];
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( PyObject_Length( args ) == 3 )
|
if( PyObject_Length( args ) == 3 )
|
||||||
ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
|
ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
|
||||||
@@ -825,7 +866,7 @@ static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
|
|||||||
G.vd->ofs[1] = val[1];
|
G.vd->ofs[1] = val[1];
|
||||||
G.vd->ofs[2] = val[2];
|
G.vd->ofs[2] = val[2];
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -837,10 +878,8 @@ static PyObject *M_Window_GetViewMatrix( PyObject * self )
|
|||||||
{
|
{
|
||||||
PyObject *viewmat;
|
PyObject *viewmat;
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
viewmat =
|
viewmat =
|
||||||
( PyObject * ) newMatrixObject( ( float * ) G.vd->viewmat, 4,
|
( PyObject * ) newMatrixObject( ( float * ) G.vd->viewmat, 4,
|
||||||
@@ -861,10 +900,8 @@ static PyObject *M_Window_GetPerspMatrix( PyObject * self )
|
|||||||
{
|
{
|
||||||
PyObject *perspmat;
|
PyObject *perspmat;
|
||||||
|
|
||||||
if( !G.vd ) {
|
if( !G.vd )
|
||||||
Py_INCREF( Py_None );
|
Py_RETURN_NONE;
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
perspmat =
|
perspmat =
|
||||||
( PyObject * ) newMatrixObject( ( float * ) G.vd->persmat, 4,
|
( PyObject * ) newMatrixObject( ( float * ) G.vd->persmat, 4,
|
||||||
@@ -1051,7 +1088,7 @@ static PyObject *M_Window_CameraView( PyObject * self, PyObject * args )
|
|||||||
if( camtov3d )
|
if( camtov3d )
|
||||||
setcameratoview3d( );
|
setcameratoview3d( );
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_QTest( PyObject * self )
|
static PyObject *M_Window_QTest( PyObject * self )
|
||||||
@@ -1097,7 +1134,7 @@ static PyObject *M_Window_QAdd( PyObject * self, PyObject * args )
|
|||||||
else
|
else
|
||||||
addqueue( win, evt, val );
|
addqueue( win, evt, val );
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_QHandle( PyObject * self, PyObject * args )
|
static PyObject *M_Window_QHandle( PyObject * self, PyObject * args )
|
||||||
@@ -1147,7 +1184,7 @@ static PyObject *M_Window_QHandle( PyObject * self, PyObject * args )
|
|||||||
set_g_activearea( oldsa );
|
set_g_activearea( oldsa );
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_GetMouseCoords( PyObject * self )
|
static PyObject *M_Window_GetMouseCoords( PyObject * self )
|
||||||
@@ -1181,7 +1218,7 @@ static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args )
|
|||||||
|
|
||||||
warp_pointer( x, y );
|
warp_pointer( x, y );
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_GetMouseButtons( PyObject * self )
|
static PyObject *M_Window_GetMouseButtons( PyObject * self )
|
||||||
@@ -1220,7 +1257,7 @@ static PyObject *M_Window_GetAreaSize( PyObject * self )
|
|||||||
ScrArea *sa = curarea;
|
ScrArea *sa = curarea;
|
||||||
|
|
||||||
if( !sa )
|
if( !sa )
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
return Py_BuildValue( "hh", sa->winx, sa->winy );
|
return Py_BuildValue( "hh", sa->winx, sa->winy );
|
||||||
}
|
}
|
||||||
@@ -1230,7 +1267,7 @@ static PyObject *M_Window_GetAreaID( PyObject * self )
|
|||||||
ScrArea *sa = curarea;
|
ScrArea *sa = curarea;
|
||||||
|
|
||||||
if( !sa )
|
if( !sa )
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
return Py_BuildValue( "h", sa->win );
|
return Py_BuildValue( "h", sa->win );
|
||||||
}
|
}
|
||||||
@@ -1240,7 +1277,7 @@ static PyObject *M_Window_GetScreenSize( PyObject * self )
|
|||||||
bScreen *scr = G.curscreen;
|
bScreen *scr = G.curscreen;
|
||||||
|
|
||||||
if( !scr )
|
if( !scr )
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
return Py_BuildValue( "hh", scr->sizex, scr->sizey );
|
return Py_BuildValue( "hh", scr->sizex, scr->sizey );
|
||||||
}
|
}
|
||||||
@@ -1267,7 +1304,7 @@ static PyObject *M_Window_SetScreen( PyObject * self, PyObject * args )
|
|||||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||||
"no such screen, check Window.GetScreens() for valid names" );
|
"no such screen, check Window.GetScreens() for valid names" );
|
||||||
|
|
||||||
return EXPP_incr_ret( Py_None );
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *M_Window_GetScreens( PyObject * self )
|
static PyObject *M_Window_GetScreens( PyObject * self )
|
||||||
|
|||||||
@@ -186,6 +186,21 @@ def GetCursorPos ():
|
|||||||
@return: the current position: [x, y, z].
|
@return: the current position: [x, y, z].
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def GetActiveLayer ():
|
||||||
|
"""
|
||||||
|
Get the bitmask for the active layer.
|
||||||
|
@note: if there is no 3d view it will return zero.
|
||||||
|
@rtype: int
|
||||||
|
@return: layer bitmask
|
||||||
|
"""
|
||||||
|
|
||||||
|
def SetActiveLayer(layermask):
|
||||||
|
"""
|
||||||
|
Set the bitmask for the active layer.
|
||||||
|
@type layermask: int
|
||||||
|
@param layermask: An integer bitmask, to use humanly readable values do (1<<0) for the first layer, (1<<19) for the last layer.
|
||||||
|
"""
|
||||||
|
|
||||||
def SetCursorPos (coords):
|
def SetCursorPos (coords):
|
||||||
"""
|
"""
|
||||||
Change the 3d cursor position.
|
Change the 3d cursor position.
|
||||||
|
|||||||
Reference in New Issue
Block a user