BPython:
- applied Campbell Barton's patch for access to Oops location and selection of materials, mesh data and objects, slightly modified. Thanks, Campbell; - got rid of warnings in many files, hopefully not introducing any other during the process. Mostly this was done: 1) new EXPP_incr_ret_True/False functions were added and used instead of "Py_INCREF(Py_True/False); return Py_True/False;". Currently at least the functions use the fact that PyTrue/False == 1/0 and use 1 and 0 to avoid the warnings. 2) Filling of certain types structs got 0's added for all not defined data and methods. This is surely Python version specific, since these structs can change size and content at each major version number Python update.
This commit is contained in:
@@ -511,18 +511,16 @@ void M_Blender_Init( void )
|
||||
|
||||
g_blenderdict = NULL;
|
||||
|
||||
/* TODO: create a docstring for the Blender module */
|
||||
module = Py_InitModule3( "Blender", Blender_methods, NULL );
|
||||
module = Py_InitModule3( "Blender", Blender_methods,
|
||||
"The main Blender module" );
|
||||
|
||||
types_InitAll( ); /* set all our pytypes to &PyType_Type */
|
||||
|
||||
dict = PyModule_GetDict( module );
|
||||
g_blenderdict = dict;
|
||||
|
||||
Py_INCREF( Py_False );
|
||||
PyDict_SetItemString( dict, "bylink", Py_False );
|
||||
Py_INCREF( Py_None );
|
||||
PyDict_SetItemString( dict, "link", Py_None );
|
||||
PyDict_SetItemString( dict, "bylink", EXPP_incr_ret_False() );
|
||||
PyDict_SetItemString( dict, "link", EXPP_incr_ret ( Py_None ) );
|
||||
PyDict_SetItemString( dict, "event", PyString_FromString( "" ) );
|
||||
|
||||
PyDict_SetItemString( dict, "Types", Types_Init( ) );
|
||||
|
||||
@@ -195,6 +195,7 @@ PyTypeObject Bone_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Bone_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
//--------------- Bone Module Init-----------------------------
|
||||
@@ -901,20 +902,16 @@ static PyObject *Bone_hasParent( BPy_Bone * self )
|
||||
if( !self->bone ) { //test to see if linked to armature
|
||||
//use python vars
|
||||
if( BLI_streq( self->parent, parent_str ) ) {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
} else {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
} else {
|
||||
//use bone datastruct
|
||||
if( self->bone->parent ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1653,20 +1650,16 @@ static PyObject *Bone_hasIK( BPy_Bone * self )
|
||||
if( !self->bone ) { //test to see if linked to armature
|
||||
//use python vars
|
||||
if( self->flag & BONE_IK_TOPARENT ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
} else {
|
||||
//use bone datastruct
|
||||
if( self->bone->flag & BONE_IK_TOPARENT ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
|
||||
@@ -213,6 +213,7 @@ PyTypeObject Camera_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Camera_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
static PyObject *M_Camera_New( PyObject * self, PyObject * args,
|
||||
@@ -555,12 +556,10 @@ static PyObject *Camera_clearIpo( BPy_Camera * self )
|
||||
id->us--;
|
||||
cam->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
static PyObject *Camera_setName( BPy_Camera * self, PyObject * args )
|
||||
|
||||
@@ -194,7 +194,7 @@ static PyObject *CurNurb_repr( BPy_CurNurb * self )
|
||||
return PyString_FromFormat( "[CurNurb \"%d\"]", self->nurb->type );
|
||||
}
|
||||
|
||||
|
||||
/* XXX Can't this be simply removed? */
|
||||
static PyObject *M_CurNurb_New( PyObject * self, PyObject * args )
|
||||
{
|
||||
return ( PyObject * ) 0;
|
||||
@@ -419,11 +419,9 @@ static PyObject *CurNurb_isNurb( BPy_CurNurb * self )
|
||||
*/
|
||||
|
||||
if( self->nurb->bp ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return ( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,11 +435,9 @@ static PyObject *CurNurb_isCyclic( BPy_CurNurb * self )
|
||||
/* supposing that the flagu is always set */
|
||||
|
||||
if( self->nurb->flagu & CU_CYCLIC ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return ( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1067,9 +1067,10 @@ static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args )
|
||||
static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args )
|
||||
{
|
||||
int curve_num = 0; /* default value */
|
||||
int is_cyclic;
|
||||
/* unused:*/
|
||||
/* int is_cyclic;
|
||||
* PyObject *ret_val;*/
|
||||
Nurb *ptrnurb;
|
||||
PyObject *ret_val;
|
||||
int i;
|
||||
|
||||
/* parse and check input args */
|
||||
@@ -1096,11 +1097,9 @@ static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args )
|
||||
}
|
||||
|
||||
if( ptrnurb->flagu & CU_CYCLIC ){
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <BKE_image.h>
|
||||
#include <BIF_drawimage.h>
|
||||
#include <BLI_blenlib.h>
|
||||
#include <DNA_space_types.h> /* FILE_MAXDIR = 160 */
|
||||
#include <IMB_imbuf_types.h> /* for the IB_rect define */
|
||||
#include <BIF_gl.h>
|
||||
#include "gen_utils.h"
|
||||
@@ -62,8 +63,8 @@
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Image module. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Image_New( PyObject * self, PyObject * args,
|
||||
PyObject * keywords );
|
||||
/*static PyObject *M_Image_New( PyObject * self, PyObject * args,
|
||||
PyObject * keywords );*/
|
||||
static PyObject *M_Image_Get( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Image_Load( PyObject * self, PyObject * args );
|
||||
|
||||
@@ -74,8 +75,8 @@ static PyObject *M_Image_Load( PyObject * self, PyObject * args );
|
||||
/*****************************************************************************/
|
||||
static char M_Image_doc[] = "The Blender Image module\n\n";
|
||||
|
||||
static char M_Image_New_doc[] =
|
||||
"() - return a new Image object -- unimplemented";
|
||||
/*static char M_Image_New_doc[] =
|
||||
"() - return a new Image object -- unimplemented";*/
|
||||
|
||||
static char M_Image_Get_doc[] =
|
||||
"(name) - return the image with the name 'name', \
|
||||
@@ -90,8 +91,8 @@ returns None if not found.\n";
|
||||
/* Python method structure definition for Blender.Image module: */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef M_Image_methods[] = {
|
||||
{"New", ( PyCFunction ) M_Image_New, METH_VARARGS | METH_KEYWORDS,
|
||||
M_Image_New_doc},
|
||||
/*{"New", ( PyCFunction ) M_Image_New, METH_VARARGS | METH_KEYWORDS,
|
||||
M_Image_New_doc},*/
|
||||
{"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
|
||||
{"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
|
||||
{"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc},
|
||||
@@ -99,18 +100,16 @@ struct PyMethodDef M_Image_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Image_New */
|
||||
/* Function: M_Image_New (unimplemented) */
|
||||
/* Python equivalent: Blender.Image.New */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Image_New( PyObject * self, PyObject * args,
|
||||
PyObject * keywords )
|
||||
/*static PyObject *M_Image_New( PyObject * self, PyObject * args,
|
||||
PyObject * keywords )
|
||||
{
|
||||
printf( "In Image_New() - unimplemented in 2.25\n" );
|
||||
|
||||
Py_INCREF( Py_None );
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Image_Get */
|
||||
/* Python equivalent: Blender.Image.Get */
|
||||
@@ -326,6 +325,7 @@ PyTypeObject Image_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Image_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del, to avoid a warning */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -552,15 +552,19 @@ static PyObject *Image_setName( BPy_Image * self, PyObject * args )
|
||||
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args )
|
||||
{
|
||||
char *name;
|
||||
char buf[160];
|
||||
int namelen = 0;
|
||||
|
||||
if( !PyArg_ParseTuple( args, "s", &name ) )
|
||||
/* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */
|
||||
|
||||
if( !PyArg_ParseTuple( args, "s#", &name, &namelen ) )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected string argument" ) );
|
||||
"expected a string argument" ) );
|
||||
|
||||
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
|
||||
if( namelen >= 160)
|
||||
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"string argument is limited to 160 chars at most" ) );
|
||||
|
||||
strcpy(self->image->name, buf);
|
||||
PyOS_snprintf( self->image->name, FILE_MAXDIR * sizeof( char ), "%s", name );
|
||||
|
||||
Py_INCREF( Py_None );
|
||||
return Py_None;
|
||||
|
||||
@@ -341,6 +341,7 @@ PyTypeObject Lamp_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Lamp_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1527,10 +1528,8 @@ static PyObject *Lamp_clearIpo( BPy_Lamp * self )
|
||||
id->us--;
|
||||
lamp->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* This is a new part of Blender.
|
||||
*
|
||||
* Contributor(s): Willian P. Germano, Michel Selten, Alex Mole,
|
||||
* Alexander Szakaly
|
||||
* Alexander Szakaly, Campbell Barton
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
@@ -47,6 +47,10 @@
|
||||
#include "Material.h"
|
||||
#include "Ipo.h"
|
||||
|
||||
/* only used for .oopsLoc at the moment */
|
||||
#include "DNA_oops_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Material defaults: */
|
||||
/*****************************************************************************/
|
||||
@@ -670,6 +674,7 @@ PyTypeObject Material_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Material_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1217,12 +1222,10 @@ static PyObject *Material_clearIpo( BPy_Material * self )
|
||||
id->us--;
|
||||
mat->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
static PyObject *Material_setName( BPy_Material * self, PyObject * args )
|
||||
@@ -1998,10 +2001,44 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name )
|
||||
else if( strcmp( name, "users" ) == 0 )
|
||||
attr = PyInt_FromLong( ( double ) self->material->
|
||||
id.us );
|
||||
else if (strcmp(name, "oopsLoc") == 0) {
|
||||
if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_MA) {
|
||||
if ((Material *)oops->id == self->material) {
|
||||
return (Py_BuildValue ("ff", oops->x, oops->y));
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
}
|
||||
Py_INCREF (Py_None);
|
||||
return (Py_None);
|
||||
}
|
||||
/* Select in the oops view only since its a mesh */
|
||||
else if (strcmp(name, "oopsSel") == 0) {
|
||||
if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_MA) {
|
||||
if ((Material *)oops->id == self->material) {
|
||||
if (oops->flag & SELECT)
|
||||
return EXPP_incr_ret_True();
|
||||
else
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
}
|
||||
Py_INCREF (Py_None);
|
||||
return (Py_None);
|
||||
}
|
||||
else if( strcmp( name, "__members__" ) == 0 ) {
|
||||
attr = /* 28 items */
|
||||
attr = /* 30 items */
|
||||
Py_BuildValue
|
||||
( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
|
||||
( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
|
||||
"name", "mode", "rgbCol", "specCol", "mirCol", "R",
|
||||
"G", "B", "alpha", "amb", "emit", "ref", "spec",
|
||||
"specTransp", "add", "zOffset", "haloSize",
|
||||
@@ -2009,7 +2046,7 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name )
|
||||
"subSize", "hard", "nFlares", "nStars", "nLines",
|
||||
"nRings", "rayMirr", "rayMirrDepth", "fresnelDepth",
|
||||
"fresnelDepthFac", "IOR", "transDepth",
|
||||
"fresnelTrans", "fresnelTransFac", "users" );
|
||||
"fresnelTrans", "fresnelTransFac", "users", "oopsLoc", "oopsSel" );
|
||||
}
|
||||
|
||||
if( !attr )
|
||||
@@ -2129,7 +2166,46 @@ static int Material_setAttr( BPy_Material * self, char *name,
|
||||
error = Material_setFresnelTrans( self, valtuple );
|
||||
else if( strcmp( name, "fresnelTransFac" ) == 0 )
|
||||
error = Material_setFresnelTransFac( self, valtuple );
|
||||
|
||||
else if (strcmp (name, "oopsLoc") == 0) {
|
||||
if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_MA) {
|
||||
if ((Material *)oops->id == self->material) {
|
||||
if (!PyArg_ParseTuple (value, "ff", &(oops->x),&(oops->y)))
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"expected two floats as arguments");
|
||||
break;
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
if (!oops)
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"couldn't find oopsLoc data for this material!");
|
||||
else error = EXPP_incr_ret (Py_None);
|
||||
}
|
||||
}
|
||||
/* Select in the oops view only since its a mesh */
|
||||
else if (strcmp (name, "oopsSel") == 0) {
|
||||
int sel;
|
||||
if (!PyArg_Parse (value, "i", &sel))
|
||||
PyErr_SetString (PyExc_TypeError, "expected an integer, 0 or 1");
|
||||
else if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_MA) {
|
||||
if ((Material *)oops->id == self->material) {
|
||||
if(sel == 0) oops->flag &= ~SELECT;
|
||||
else oops->flag |= SELECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
error = EXPP_incr_ret (Py_None);
|
||||
}
|
||||
}
|
||||
else { /* Error */
|
||||
Py_DECREF( valtuple );
|
||||
return ( EXPP_ReturnIntError( PyExc_AttributeError, name ) );
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* This is a new part of Blender.
|
||||
*
|
||||
* Contributor(s): Willian P. Germano, Jordi Rovira i Bonet, Joseph Gilbert,
|
||||
* Bala Gi, Alexander Szakaly, Stephane Soppera
|
||||
* Bala Gi, Alexander Szakaly, Stephane Soppera, Campbell Barton
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
@@ -66,6 +66,9 @@
|
||||
#include "constant.h"
|
||||
#include "gen_utils.h"
|
||||
|
||||
/* only used for ob.oopsloc at the moment */
|
||||
#include "DNA_oops_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
/* EXPP Mesh defines */
|
||||
|
||||
@@ -402,6 +405,8 @@ PyTypeObject NMCol_Type = {
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */
|
||||
};
|
||||
|
||||
/*****************************/
|
||||
@@ -691,6 +696,7 @@ static PySequenceMethods NMFace_SeqMethods = {
|
||||
( intintargfunc ) NMFace_slice, /* sq_slice */
|
||||
( intobjargproc ) 0, /* sq_ass_item */
|
||||
( intintobjargproc ) 0, /* sq_ass_slice */
|
||||
0,0,0,
|
||||
};
|
||||
|
||||
PyTypeObject NMFace_Type = {
|
||||
@@ -709,6 +715,8 @@ PyTypeObject NMFace_Type = {
|
||||
&NMFace_SeqMethods, /*tp_as_sequence */
|
||||
0, /*tp_as_mapping */
|
||||
0, /*tp_hash */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */
|
||||
};
|
||||
|
||||
static BPy_NMVert *newvert( float *co )
|
||||
@@ -883,6 +891,7 @@ static PySequenceMethods NMVert_SeqMethods = {
|
||||
( intintargfunc ) NMVert_slice, /* sq_slice */
|
||||
( intobjargproc ) NMVert_ass_item, /* sq_ass_item */
|
||||
( intintobjargproc ) NMVert_ass_slice, /* sq_ass_slice */
|
||||
0,0,0,
|
||||
};
|
||||
|
||||
PyTypeObject NMVert_Type = {
|
||||
@@ -900,6 +909,8 @@ PyTypeObject NMVert_Type = {
|
||||
( reprfunc ) 0, /*tp_repr */
|
||||
0, /*tp_as_number */
|
||||
&NMVert_SeqMethods, /*tp_as_sequence */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_del */
|
||||
};
|
||||
|
||||
|
||||
@@ -998,13 +1009,11 @@ PyTypeObject NMEdge_Type = {
|
||||
( printfunc ) 0, /*tp_print */
|
||||
( getattrfunc ) NMEdge_getattr, /*tp_getattr */
|
||||
( setattrfunc ) NMEdge_setattr, /*tp_setattr */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void NMesh_dealloc( PyObject * self )
|
||||
{
|
||||
BPy_NMesh *me = ( BPy_NMesh * ) self;
|
||||
@@ -1104,12 +1113,12 @@ static PyObject *NMesh_removeAllKeys( PyObject * self, PyObject * args )
|
||||
"this function expects no arguments" );
|
||||
|
||||
if( !me || !me->key )
|
||||
return EXPP_incr_ret( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
|
||||
me->key->id.us--;
|
||||
me->key = 0;
|
||||
|
||||
return EXPP_incr_ret( Py_True );
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
static PyObject *NMesh_insertKey( PyObject * self, PyObject * args )
|
||||
@@ -1215,9 +1224,9 @@ static PyObject *NMesh_hasVertexUV( PyObject * self, PyObject * args )
|
||||
}
|
||||
|
||||
if( me->flags & NMESH_HASVERTUV )
|
||||
return EXPP_incr_ret( Py_True );
|
||||
return EXPP_incr_ret_True();
|
||||
else
|
||||
return EXPP_incr_ret( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
|
||||
static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args )
|
||||
@@ -1241,9 +1250,9 @@ static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args )
|
||||
}
|
||||
|
||||
if( me->flags & NMESH_HASFACEUV )
|
||||
return EXPP_incr_ret( Py_True );
|
||||
return EXPP_incr_ret_True();
|
||||
else
|
||||
return EXPP_incr_ret( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
|
||||
static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args )
|
||||
@@ -1267,9 +1276,9 @@ static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args )
|
||||
}
|
||||
|
||||
if( me->flags & NMESH_HASMCOL )
|
||||
return EXPP_incr_ret( Py_True );
|
||||
return EXPP_incr_ret_True();
|
||||
else
|
||||
return EXPP_incr_ret( Py_False );
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
|
||||
static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd )
|
||||
@@ -1626,11 +1635,45 @@ static PyObject *NMesh_getattr( PyObject * self, char *name )
|
||||
else
|
||||
return EXPP_incr_ret( Py_None );
|
||||
}
|
||||
else if (strcmp(name, "oopsLoc") == 0) {
|
||||
if (G.soops) {
|
||||
Oops *oops = G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_ME) {
|
||||
if ((Mesh *)oops->id == me->mesh) {
|
||||
return (Py_BuildValue ("ff", oops->x, oops->y));
|
||||
}
|
||||
}
|
||||
oops = oops->next;
|
||||
}
|
||||
}
|
||||
Py_INCREF (Py_None);
|
||||
return (Py_None);
|
||||
}
|
||||
/* Select in the oops view only since it's a mesh */
|
||||
else if (strcmp(name, "oopsSel") == 0) {
|
||||
if (G.soops) {
|
||||
Oops *oops = G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_ME) {
|
||||
if ((Mesh *)oops->id == me->mesh) {
|
||||
if (oops->flag & SELECT) {
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
}
|
||||
oops = oops->next;
|
||||
}
|
||||
}
|
||||
return EXPP_incr_ret(Py_None);
|
||||
}
|
||||
else if( strcmp( name, "__members__" ) == 0 )
|
||||
return Py_BuildValue( "[s,s,s,s,s,s,s,s]",
|
||||
return Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s]",
|
||||
"name", "materials", "verts", "users",
|
||||
"faces", "maxSmoothAngle",
|
||||
"subdivLevels", "edges" );
|
||||
"subdivLevels", "edges", "oopsLoc", "oopsSel" );
|
||||
|
||||
return Py_FindMethod( NMesh_methods, ( PyObject * ) self, name );
|
||||
}
|
||||
@@ -1743,6 +1786,41 @@ static int NMesh_setattr( PyObject * self, char *name, PyObject * v )
|
||||
else
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"mesh has no edge information" );
|
||||
}
|
||||
else if (!strcmp(name, "oopsLoc")) {
|
||||
if (G.soops) {
|
||||
Oops *oops = G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_ME) {
|
||||
if ((Mesh *)oops->id == me->mesh) {
|
||||
return (!PyArg_ParseTuple (v, "ff", &(oops->x),&(oops->y)));
|
||||
}
|
||||
}
|
||||
oops = oops->next;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* Select in the oops view only since its a mesh */
|
||||
else if (!strcmp(name, "oopsSel")) {
|
||||
int sel;
|
||||
if (!PyArg_Parse (v, "i", &sel))
|
||||
return EXPP_ReturnIntError
|
||||
(PyExc_TypeError, "expected an integer, 0 or 1");
|
||||
if (G.soops) {
|
||||
Oops *oops = G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_ME) {
|
||||
if ((Mesh *)oops->id == me->mesh) {
|
||||
if(sel == 0) oops->flag &= ~SELECT;
|
||||
else oops->flag |= SELECT;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
oops = oops->next;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return EXPP_ReturnIntError( PyExc_AttributeError, name );
|
||||
@@ -1760,11 +1838,12 @@ PyTypeObject NMesh_Type = {
|
||||
( printfunc ) 0, /*tp_print */
|
||||
( getattrfunc ) NMesh_getattr, /*tp_getattr */
|
||||
( setattrfunc ) NMesh_setattr, /*tp_setattr */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4],
|
||||
char mat_nr, char flag, TFace * tface,
|
||||
MCol * col )
|
||||
char mat_nr, char flag, TFace * tface, MCol * col )
|
||||
{
|
||||
BPy_NMFace *newf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
|
||||
int i, len;
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
#include "Lattice.h"
|
||||
#include "modules.h"
|
||||
|
||||
/* only used for oops location get/set at the moment */
|
||||
#include "DNA_oops_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Blender module. */
|
||||
@@ -340,6 +343,7 @@ PyTypeObject Object_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Object_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -608,12 +612,10 @@ static PyObject *Object_clearIpo( BPy_Object * self )
|
||||
id->us--;
|
||||
ob->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
|
||||
@@ -856,11 +858,9 @@ static PyObject *Object_isSelected( BPy_Object * self )
|
||||
while( base ) {
|
||||
if( base->object == self->object ) {
|
||||
if( base->flag & SELECT ) {
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
} else {
|
||||
Py_INCREF( Py_False );
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False();
|
||||
}
|
||||
}
|
||||
base = base->next;
|
||||
@@ -2221,6 +2221,20 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
|
||||
return ( Py_BuildValue( "s", object->id.name + 2 ) );
|
||||
if( StringEqual( name, "sel" ) )
|
||||
return ( Object_isSelected( obj ) );
|
||||
if (StringEqual (name, "oopsLoc")) {
|
||||
if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_OB) {
|
||||
if ((Object *)oops->id == object) {
|
||||
return (Py_BuildValue ("ff", oops->x, oops->y));
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
}
|
||||
return EXPP_incr_ret( Py_None );
|
||||
}
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
|
||||
@@ -2422,16 +2436,28 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
|
||||
else
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
if( StringEqual( name, "sel" ) ) {
|
||||
if( Object_Select( obj, valtuple ) != Py_None )
|
||||
return ( -1 );
|
||||
else
|
||||
return ( 0 );
|
||||
}
|
||||
if (StringEqual (name, "oopsLoc")) {
|
||||
if (G.soops) {
|
||||
Oops *oops= G.soops->oops.first;
|
||||
while(oops) {
|
||||
if(oops->type==ID_OB) {
|
||||
if ((Object *)oops->id == object) {
|
||||
return (!PyArg_ParseTuple (value, "ff", &(oops->x),&(oops->y)));
|
||||
}
|
||||
}
|
||||
oops= oops->next;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf( "Unknown variable.\n" );
|
||||
return ( 0 );
|
||||
return EXPP_ReturnIntError( PyExc_KeyError, "attribute not found" );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -500,6 +500,7 @@ PyTypeObject Texture_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Texture_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
static PyObject *M_Texture_New( PyObject * self, PyObject * args,
|
||||
@@ -2015,10 +2016,8 @@ static PyObject *Texture_clearIpo( BPy_Texture * self )
|
||||
id->us--;
|
||||
tex->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ PyTypeObject World_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_World_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -480,12 +481,10 @@ static PyObject *World_clearIpo( BPy_World * self )
|
||||
id->us--;
|
||||
world->ipo = NULL;
|
||||
|
||||
Py_INCREF( Py_True );
|
||||
return Py_True;
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
|
||||
Py_INCREF( Py_False ); /* no ipo found */
|
||||
return Py_False;
|
||||
return EXPP_incr_ret_False(); /* no ipo found */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -126,6 +126,20 @@ PyObject *EXPP_incr_ret( PyObject * object )
|
||||
return ( object );
|
||||
}
|
||||
|
||||
/* return Py_False - to avoid warnings, we use the fact that
|
||||
* 0 == False in Python: */
|
||||
PyObject *EXPP_incr_ret_False()
|
||||
{
|
||||
return Py_BuildValue("i", 0);
|
||||
}
|
||||
|
||||
/* return Py_True - to avoid warnings, we use the fact that
|
||||
* 1 == True in Python: */
|
||||
PyObject *EXPP_incr_ret_True()
|
||||
{
|
||||
return Py_BuildValue("i", 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: This function maps the event identifier to a string. */
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -64,6 +64,8 @@ float EXPP_ClampFloat( float value, float min, float max );
|
||||
int EXPP_ClampInt( int value, int min, int max );
|
||||
|
||||
PyObject *EXPP_incr_ret( PyObject * object );
|
||||
PyObject *EXPP_incr_ret_True(void);
|
||||
PyObject *EXPP_incr_ret_False(void);
|
||||
PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg );
|
||||
int EXPP_ReturnIntError( PyObject * type, char *error_msg );
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ PyTypeObject property_Type = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
BPy_Property_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
//--------------- Property module internal callbacks-------------------
|
||||
|
||||
@@ -98,9 +99,9 @@ int updatePyProperty( BPy_Property * self )
|
||||
self->type = self->property->type;
|
||||
if( self->property->type == PROP_BOOL ) {
|
||||
if( *( ( int * ) &self->property->poin ) ) {
|
||||
self->data = EXPP_incr_ret( Py_True );
|
||||
self->data = EXPP_incr_ret_True();
|
||||
} else {
|
||||
self->data = EXPP_incr_ret( Py_False );
|
||||
self->data = EXPP_incr_ret_False();
|
||||
}
|
||||
} else if( self->property->type == PROP_INT ) {
|
||||
self->data = PyInt_FromLong( self->property->data );
|
||||
@@ -430,9 +431,9 @@ static PyObject *Property_getData( BPy_Property * self )
|
||||
} else {
|
||||
if( self->property->type == PROP_BOOL ) {
|
||||
if( self->property->data )
|
||||
attr = EXPP_incr_ret( Py_True );
|
||||
attr = EXPP_incr_ret_True();
|
||||
else
|
||||
attr = EXPP_incr_ret( Py_False );
|
||||
attr = EXPP_incr_ret_False();
|
||||
} else if( self->property->type == PROP_INT ) {
|
||||
attr = PyInt_FromLong( self->property->data );
|
||||
} else if( self->property->type == PROP_FLOAT ||
|
||||
|
||||
Reference in New Issue
Block a user