Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKen Hughes <khughes@pacific.edu>2006-08-14 22:01:28 +0400
committerKen Hughes <khughes@pacific.edu>2006-08-14 22:01:28 +0400
commit0a3f16304fc55dc1d0ee510dff4ea2a85d1c7c3c (patch)
treeee9b8a59952f9f6a51a3202e9f03c025c3fd87f7 /source
parentd10797a23ec623631f10a6c4aa68b3defe85de46 (diff)
===Python API===
Long-awaited refactor of Object module. Should not break backward compatibility -- at least it didn't in my tests -- but I'm requesting users to put it through heavier testing and report problems through the bug tracker.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Object.c5538
-rw-r--r--source/blender/python/api2_2x/doc/Object.py590
2 files changed, 3530 insertions, 2598 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 8581288fe44..838e85fbdd3 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -134,6 +134,139 @@ struct rctf;
#define PFIELD_MAGNET 3
#define PFIELD_WIND 4
+enum obj_consts {
+ EXPP_OBJ_ATTR_LOC_X = 0,
+ EXPP_OBJ_ATTR_LOC_Y,
+ EXPP_OBJ_ATTR_LOC_Z,
+ EXPP_OBJ_ATTR_DLOC_X,
+ EXPP_OBJ_ATTR_DLOC_Y,
+ EXPP_OBJ_ATTR_DLOC_Z,
+ EXPP_OBJ_ATTR_ROT_X,
+ EXPP_OBJ_ATTR_ROT_Y,
+ EXPP_OBJ_ATTR_ROT_Z,
+ EXPP_OBJ_ATTR_DROT_X,
+ EXPP_OBJ_ATTR_DROT_Y,
+ EXPP_OBJ_ATTR_DROT_Z,
+ EXPP_OBJ_ATTR_SIZE_X,
+ EXPP_OBJ_ATTR_SIZE_Y,
+ EXPP_OBJ_ATTR_SIZE_Z,
+ EXPP_OBJ_ATTR_DSIZE_X,
+ EXPP_OBJ_ATTR_DSIZE_Y,
+ EXPP_OBJ_ATTR_DSIZE_Z,
+ EXPP_OBJ_ATTR_LOC,
+ EXPP_OBJ_ATTR_DLOC,
+ EXPP_OBJ_ATTR_DROT,
+ EXPP_OBJ_ATTR_SIZE,
+ EXPP_OBJ_ATTR_DSIZE,
+ EXPP_OBJ_ATTR_LAYERMASK,
+ EXPP_OBJ_ATTR_COLBITS,
+ EXPP_OBJ_ATTR_DRAWMODE,
+ EXPP_OBJ_ATTR_DRAWTYPE,
+ EXPP_OBJ_ATTR_DUPON,
+ EXPP_OBJ_ATTR_DUPOFF,
+ EXPP_OBJ_ATTR_DUPSTA,
+ EXPP_OBJ_ATTR_DUPEND,
+ EXPP_OBJ_ATTR_TIMEOFFSET,
+ EXPP_OBJ_ATTR_DRAWSIZE,
+
+ EXPP_OBJ_ATTR_PI_SURFACEDAMP, /* these need to stay together */
+ EXPP_OBJ_ATTR_PI_RANDOMDAMP, /* and in order */
+ EXPP_OBJ_ATTR_PI_PERM,
+ EXPP_OBJ_ATTR_PI_STRENGTH,
+ EXPP_OBJ_ATTR_PI_FALLOFF,
+ EXPP_OBJ_ATTR_PI_MAXDIST,
+ EXPP_OBJ_ATTR_PI_SBDAMP,
+ EXPP_OBJ_ATTR_PI_SBIFACETHICK,
+ EXPP_OBJ_ATTR_PI_SBOFACETHICK,
+
+ EXPP_OBJ_ATTR_SB_NODEMASS, /* these need to stay together */
+ EXPP_OBJ_ATTR_SB_GRAV, /* and in order */
+ EXPP_OBJ_ATTR_SB_MEDIAFRICT,
+ EXPP_OBJ_ATTR_SB_RKLIMIT,
+ EXPP_OBJ_ATTR_SB_PHYSICSSPEED,
+ EXPP_OBJ_ATTR_SB_GOALSPRING,
+ EXPP_OBJ_ATTR_SB_GOALFRICT,
+ EXPP_OBJ_ATTR_SB_MINGOAL,
+ EXPP_OBJ_ATTR_SB_MAXGOAL,
+ EXPP_OBJ_ATTR_SB_DEFGOAL,
+ EXPP_OBJ_ATTR_SB_INSPRING,
+ EXPP_OBJ_ATTR_SB_INFRICT,
+
+};
+
+#define EXPP_OBJECT_DRAWSIZEMIN 0.01f
+#define EXPP_OBJECT_DRAWSIZEMAX 10.0f
+
+/* clamping and range values for particle interaction settings */
+#define EXPP_OBJECT_PIDAMP_MIN 0.0f
+#define EXPP_OBJECT_PIDAMP_MAX 1.0f
+#define EXPP_OBJECT_PIRDAMP_MIN 0.0f
+#define EXPP_OBJECT_PIRDAMP_MAX 1.0f
+#define EXPP_OBJECT_PIPERM_MIN 0.0f
+#define EXPP_OBJECT_PIPERM_MAX 1.0f
+#define EXPP_OBJECT_PISTRENGTH_MIN 0.0f
+#define EXPP_OBJECT_PISTRENGTH_MAX 1000.0f
+#define EXPP_OBJECT_PIPOWER_MIN 0.0f
+#define EXPP_OBJECT_PIPOWER_MAX 10.0f
+#define EXPP_OBJECT_PIMAXDIST_MIN 0.0f
+#define EXPP_OBJECT_PIMAXDIST_MAX 1000.0f
+#define EXPP_OBJECT_PISBDAMP_MIN 0.0f
+#define EXPP_OBJECT_PISBDAMP_MAX 1.0f
+#define EXPP_OBJECT_PISBIFTMIN 0.001f
+#define EXPP_OBJECT_PISBIFTMAX 1.0f
+#define EXPP_OBJECT_PISBOFTMIN 0.001f
+#define EXPP_OBJECT_PISBOFTMAX 1.0f
+
+/* clamping and range values for softbody settings */
+#define EXPP_OBJECT_SBMASS_MIN 0.0f
+#define EXPP_OBJECT_SBMASS_MAX 50.0f
+#define EXPP_OBJECT_SBGRAVITY_MIN 0.0f
+#define EXPP_OBJECT_SBGRAVITY_MAX 10.0f
+#define EXPP_OBJECT_SBFRICTION_MIN 0.0f
+#define EXPP_OBJECT_SBFRICTION_MAX 10.0f
+#define EXPP_OBJECT_SBSPEED_MIN 0.01f
+#define EXPP_OBJECT_SBSPEED_MAX 100.0f
+#define EXPP_OBJECT_SBERRORLIMIT_MIN 0.01f
+#define EXPP_OBJECT_SBERRORLIMIT_MAX 1.0f
+#define EXPP_OBJECT_SBGOALSPRING_MIN 0.0f
+#define EXPP_OBJECT_SBGOALSPRING_MAX 0.999f
+#define EXPP_OBJECT_SBGOALFRICT_MIN 0.0f
+#define EXPP_OBJECT_SBGOALFRICT_MAX 10.0f
+#define EXPP_OBJECT_SBMINGOAL_MIN 0.0f
+#define EXPP_OBJECT_SBMINGOAL_MAX 1.0f
+#define EXPP_OBJECT_SBMAXGOAL_MIN 0.0f
+#define EXPP_OBJECT_SBMAXGOAL_MAX 1.0f
+#define EXPP_OBJECT_SBINSPRING_MIN 0.0f
+#define EXPP_OBJECT_SBINSPRING_MAX 0.999f
+#define EXPP_OBJECT_SBINFRICT_MIN 0.0f
+#define EXPP_OBJECT_SBINFRICT_MAX 10.0f
+#define EXPP_OBJECT_SBDEFGOAL_MIN 0.0f
+#define EXPP_OBJECT_SBDEFGOAL_MAX 1.0f
+#define EXPP_OBJECT_SBNODEMASSMIN 0.001f
+#define EXPP_OBJECT_SBNODEMASSMAX 50.0f
+#define EXPP_OBJECT_SBGRAVMIN 0.0f
+#define EXPP_OBJECT_SBGRAVMAX 10.0f
+#define EXPP_OBJECT_SBMEDIAFRICTMIN 0.0f
+#define EXPP_OBJECT_SBMEDIAFRICTMAX 10.0f
+#define EXPP_OBJECT_SBRKLIMITMIN 0.01f
+#define EXPP_OBJECT_SBRKLIMITMAX 1.0f
+#define EXPP_OBJECT_SBPHYSICSSPEEDMIN 0.01f
+#define EXPP_OBJECT_SBPHYSICSSPEEDMAX 100.0f
+#define EXPP_OBJECT_SBGOALSPRINGMIN 0.0f
+#define EXPP_OBJECT_SBGOALSPRINGMAX 0.999f
+#define EXPP_OBJECT_SBGOALFRICTMIN 0.0f
+#define EXPP_OBJECT_SBGOALFRICTMAX 10.0f
+#define EXPP_OBJECT_SBMINGOALMIN 0.0f
+#define EXPP_OBJECT_SBMINGOALMAX 1.0f
+#define EXPP_OBJECT_SBMAXGOALMIN 0.0f
+#define EXPP_OBJECT_SBMAXGOALMAX 1.0f
+#define EXPP_OBJECT_SBDEFGOALMIN 0.0f
+#define EXPP_OBJECT_SBDEFGOALMAX 1.0f
+#define EXPP_OBJECT_SBINSPRINGMIN 0.0f
+#define EXPP_OBJECT_SBINSPRINGMAX 0.999f
+#define EXPP_OBJECT_SBINFRICTMIN 0.0f
+#define EXPP_OBJECT_SBINFRICTMAX 10.0f
+
/*****************************************************************************/
/* Python API function prototypes for the Blender module. */
/*****************************************************************************/
@@ -189,8 +322,8 @@ struct PyMethodDef M_Object_methods[] = {
/*****************************************************************************/
/* Python BPy_Object methods declarations: */
/*****************************************************************************/
-int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
-int setupPI(Object* ob);
+static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
+static int setupPI(Object* ob);
static PyObject *Object_buildParts( BPy_Object * self );
static PyObject *Object_clearIpo( BPy_Object * self );
@@ -200,7 +333,7 @@ static PyObject *Object_getData(BPy_Object *self, PyObject *args, PyObject *kwd)
static PyObject *Object_getDeltaLocation( BPy_Object * self );
static PyObject *Object_getDrawMode( BPy_Object * self );
static PyObject *Object_getDrawType( BPy_Object * self );
-static PyObject *Object_getEuler( BPy_Object * self, PyObject * args );
+static PyObject *Object_GetEuler( BPy_Object * self, PyObject * args );
static PyObject *Object_getInverseMatrix( BPy_Object * self );
static PyObject *Object_getIpo( BPy_Object * self );
static PyObject *Object_getLocation( BPy_Object * self, PyObject * args );
@@ -217,7 +350,7 @@ static PyObject *Object_getBoundBox( BPy_Object * self );
static PyObject *Object_getAction( BPy_Object * self );
static PyObject *Object_getPose( BPy_Object * self );
static PyObject *Object_evaluatePose( BPy_Object * self, PyObject *args );
-static PyObject *Object_isSelected( BPy_Object * self );
+static PyObject *Object_getSelected( BPy_Object * self );
static PyObject *Object_makeDisplayList( BPy_Object * self );
static PyObject *Object_link( BPy_Object * self, PyObject * args );
static PyObject *Object_makeParent( BPy_Object * self, PyObject * args );
@@ -225,28 +358,23 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args );
static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args );
static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args );
static PyObject *Object_materialUsage( void );
-static PyObject *Object_getDupliVerts ( BPy_Object * self ); /* */
-static PyObject *Object_getDupliFrames ( BPy_Object * self );
-static PyObject *Object_getDupliGroup ( BPy_Object * self );
-static PyObject *Object_getDupliRot ( BPy_Object * self );
-static PyObject *Object_getDupliNoSpeed ( BPy_Object * self );
static PyObject *Object_getDupliObjects ( BPy_Object * self);
static PyObject *Object_getEffects( BPy_Object * self );
static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args );
-static PyObject *Object_setDrawMode( BPy_Object * self, PyObject * args );
-static PyObject *Object_setDrawType( BPy_Object * self, PyObject * args );
-static PyObject *Object_setEuler( BPy_Object * self, PyObject * args );
-static PyObject *Object_setMatrix( BPy_Object * self, PyObject * args );
-static PyObject *Object_setIpo( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetDrawMode( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetEuler( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetIpo( BPy_Object * self, PyObject * args );
static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args );
static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args );
static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args );
static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args );
-static PyObject *Object_bake_to_action( BPy_Object * self, PyObject * args );
+static PyObject *Object_bake_to_action( void );
static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self, PyObject * args );
static PyObject *Object_setLocation( BPy_Object * self, PyObject * args );
static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args );
-static PyObject *Object_setName( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetName( BPy_Object * self, PyObject * args );
static PyObject *Object_setSize( BPy_Object * self, PyObject * args );
static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args );
static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args );
@@ -262,11 +390,6 @@ static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * args );
static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args );
static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject *args );
-static PyObject *Object_setDupliVerts ( BPy_Object * self, PyObject * args ); /* removed from API, used by enableDupliVerts */
-static PyObject *Object_setDupliFrames ( BPy_Object * self, PyObject * args ); /* removed from API, used by enableDupliFrames */
-static PyObject *Object_setDupliGroup ( BPy_Object * self, PyObject * args ); /* removed from API, used by enableDupliGroups */
-static PyObject *Object_setDupliRot ( BPy_Object * self , PyObject * args); /* removed from API, used by enableDupliRot */
-static PyObject *Object_setDupliNoSpeed ( BPy_Object * self , PyObject * args); /* removed from API, used by enableDupliNoSpeed */
static PyObject *Object_getPIStrength( BPy_Object * self );
static PyObject *Object_setPIStrength( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIFalloff( BPy_Object * self );
@@ -274,24 +397,22 @@ static PyObject *Object_setPIFalloff( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIMaxDist( BPy_Object * self );
static PyObject *Object_setPIMaxDist( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIUseMaxDist( BPy_Object * self );
-static PyObject *Object_setPIUseMaxDist( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetPIUseMaxDist( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIType( BPy_Object * self );
-static PyObject *Object_setPIType( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetPIType( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIPerm( BPy_Object * self );
-static PyObject *Object_setPIPerm( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetPIPerm( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIRandomDamp( BPy_Object * self );
static PyObject *Object_setPIRandomDamp( BPy_Object * self, PyObject * args );
static PyObject *Object_getPISurfaceDamp( BPy_Object * self );
-static PyObject *Object_setPISurfaceDamp( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetPISurfaceDamp( BPy_Object * self, PyObject * args );
static PyObject *Object_getPIDeflection( BPy_Object * self );
-static PyObject *Object_setPIDeflection( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetPIDeflection( BPy_Object * self, PyObject * args );
static int Object_setRBMass( BPy_Object * self, PyObject * args );
-static int Object_setRBRadius( BPy_Object * self, PyObject * args );
static int Object_setRBFlags( BPy_Object * self, PyObject * args );
static int Object_setRBShapeBoundType( BPy_Object * self, PyObject * args );
-static PyObject *Object_isSB( BPy_Object * self );
static PyObject *Object_getSBMass( BPy_Object * self );
static PyObject *Object_setSBMass( BPy_Object * self, PyObject * args );
static PyObject *Object_getSBGravity( BPy_Object * self );
@@ -312,14 +433,16 @@ static PyObject *Object_getSBInnerSpring( BPy_Object * self );
static PyObject *Object_setSBInnerSpring( BPy_Object * self, PyObject * args );
static PyObject *Object_getSBInnerSpringFriction( BPy_Object * self );
static PyObject *Object_setSBInnerSpringFriction( BPy_Object * self, PyObject * args );
+
+static PyObject *Object_isSB( BPy_Object * self );
static PyObject *Object_getSBDefaultGoal( BPy_Object * self );
static PyObject *Object_setSBDefaultGoal( BPy_Object * self, PyObject * args );
static PyObject *Object_getSBUseGoal( BPy_Object * self );
-static PyObject *Object_setSBUseGoal( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetSBUseGoal( BPy_Object * self, PyObject * args );
static PyObject *Object_getSBUseEdges( BPy_Object * self );
-static PyObject *Object_setSBUseEdges( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetSBUseEdges( BPy_Object * self, PyObject * args );
static PyObject *Object_getSBStiffQuads( BPy_Object * self );
-static PyObject *Object_setSBStiffQuads( BPy_Object * self, PyObject * args );
+static PyObject *Object_SetSBStiffQuads( BPy_Object * self, PyObject * args );
static PyObject *Object_insertShapeKey(BPy_Object * self);
static PyObject *Object_copyNLA( BPy_Object * self, PyObject * args );
static PyObject *Object_convertActionToStrip( BPy_Object * self );
@@ -355,14 +478,14 @@ If 'name_only' is nonzero or True, only the name of the datablock is returned"},
"Returns the object draw type"},
{"getAction", ( PyCFunction ) Object_getAction, METH_NOARGS,
"Returns the active action for this object"},
- {"evaluatePose", ( PyCFunction ) Object_evaluatePose, METH_VARARGS,
+ {"evaluatePose", ( PyCFunction ) Object_evaluatePose, METH_VARARGS,
"(framenum) - Updates the pose to a certain frame number when the Object is\
bound to an Action"},
{"getPose", ( PyCFunction ) Object_getPose, METH_NOARGS,
"() - returns the pose from an object if it exists, else None"},
- {"isSelected", ( PyCFunction ) Object_isSelected, METH_NOARGS,
+ {"isSelected", ( PyCFunction ) Object_getSelected, METH_NOARGS,
"Return a 1 or 0 depending on whether the object is selected"},
- {"getEuler", ( PyCFunction ) Object_getEuler, METH_VARARGS,
+ {"getEuler", ( PyCFunction ) Object_GetEuler, METH_VARARGS,
"(space = 'localspace' / 'worldspace') - Returns the object's rotation as Euler rotation vector\n\
(rotX, rotY, rotZ)"},
{"getInverseMatrix", ( PyCFunction ) Object_getInverseMatrix,
@@ -413,19 +536,19 @@ automatic when the script finishes."},
"Sets Particle Interaction Max Distance"},
{"getPIUseMaxDist", ( PyCFunction ) Object_getPIUseMaxDist, METH_NOARGS,
"Returns bool for Use Max Distace in Particle Interaction "},
- {"setPIUseMaxDist", ( PyCFunction ) Object_setPIUseMaxDist, METH_VARARGS,
+ {"setPIUseMaxDist", ( PyCFunction ) Object_SetPIUseMaxDist, METH_VARARGS,
"Sets if Max Distance should be used in Particle Interaction"},
{"getPIType", ( PyCFunction ) Object_getPIType, METH_NOARGS,
"Returns Particle Interaction Type"},
- {"setPIType", ( PyCFunction ) Object_setPIType, METH_VARARGS,
+ {"setPIType", ( PyCFunction ) Object_SetPIType, METH_VARARGS,
"sets Particle Interaction Type"},
{"getPIPerm", ( PyCFunction ) Object_getPIPerm, METH_NOARGS,
"Returns Particle Interaction Permiability"},
- {"setPIPerm", ( PyCFunction ) Object_setPIPerm, METH_VARARGS,
- "Sets Particle Interaction Permiability"},
+ {"setPIPerm", ( PyCFunction ) Object_SetPIPerm, METH_VARARGS,
+ "Sets Particle Interaction Permiability"},
{"getPISurfaceDamp", ( PyCFunction ) Object_getPISurfaceDamp, METH_NOARGS,
"Returns Particle Interaction Surface Damping"},
- {"setPISurfaceDamp", ( PyCFunction ) Object_setPISurfaceDamp, METH_VARARGS,
+ {"setPISurfaceDamp", ( PyCFunction ) Object_SetPISurfaceDamp, METH_VARARGS,
"Sets Particle Interaction Surface Damping"},
{"getPIRandomDamp", ( PyCFunction ) Object_getPIRandomDamp, METH_NOARGS,
"Returns Particle Interaction Random Damping"},
@@ -433,29 +556,8 @@ automatic when the script finishes."},
"Sets Particle Interaction Random Damping"},
{"getPIDeflection", ( PyCFunction ) Object_getPIDeflection, METH_NOARGS,
"Returns Particle Interaction Deflection"},
- {"setPIDeflection", ( PyCFunction ) Object_setPIDeflection, METH_VARARGS,
+ {"setPIDeflection", ( PyCFunction ) Object_SetPIDeflection, METH_VARARGS,
"Sets Particle Interaction Deflection"},
-
-/* Rigidbody , mass, inertia, shape type (boundtype), friction, restitution */
-
-#if 0
- {"getRBMass", ( PyCFunction ) Object_getRBMass, METH_NOARGS,
- "Returns RB Mass"},
- {"setRBMass", ( PyCFunction ) Object_setRBMass, METH_VARARGS,
- "Sets RB Mass"},
-
- {"getRBFlags", ( PyCFunction ) Object_getRBFlags, METH_NOARGS,
- "Returns RB Flags"},
- {"setRBFlags", ( PyCFunction ) Object_setRBFlags, METH_VARARGS,
- "Sets RB Flags"},
-
- {"getRBShapeBoundType", ( PyCFunction ) Object_getRBShapeBoundType, METH_NOARGS,
- "Returns RB Shape Bound Type"},
- {"setRBShapeBoundType", ( PyCFunction ) Object_setRBShapeBoundType, METH_VARARGS,
- "Sets RB Shape Bound Type"},
-#endif
-
-
/* Softbody */
@@ -507,36 +609,32 @@ automatic when the script finishes."},
"Sets SB DefaultGoal"},
{"getSBUseGoal", ( PyCFunction ) Object_getSBUseGoal, METH_NOARGS,
"Returns SB UseGoal"},
- {"setSBUseGoal", ( PyCFunction ) Object_setSBUseGoal, METH_VARARGS,
+ {"setSBUseGoal", ( PyCFunction ) Object_SetSBUseGoal, METH_VARARGS,
"Sets SB UseGoal"},
{"getSBUseEdges", ( PyCFunction ) Object_getSBUseEdges, METH_NOARGS,
"Returns SB UseEdges"},
- {"setSBUseEdges", ( PyCFunction ) Object_setSBUseEdges, METH_VARARGS,
+ {"setSBUseEdges", ( PyCFunction ) Object_SetSBUseEdges, METH_VARARGS,
"Sets SB UseEdges"},
{"getSBStiffQuads", ( PyCFunction ) Object_getSBStiffQuads, METH_NOARGS,
"Returns SB StiffQuads"},
- {"setSBStiffQuads", ( PyCFunction ) Object_setSBStiffQuads, METH_VARARGS,
+ {"setSBStiffQuads", ( PyCFunction ) Object_SetSBStiffQuads, METH_VARARGS,
"Sets SB StiffQuads"},
{"getBoundBox", ( PyCFunction ) Object_getBoundBox, METH_NOARGS,
"Returns the object's bounding box"},
- /*{"getDupliObjects", ( PyCFunction ) Object_getDupliObjects,
- METH_NOARGS, "Returns of list of tuples for object duplicated (object, dupliMatrix)\n\
- by dupliframe or dupliverst state "},*/
- {"makeDisplayList", ( PyCFunction ) Object_makeDisplayList,
- METH_NOARGS,
- "Update this object's Display List. Some changes like turning \n\
-'SubSurf' on for a mesh need this method (followed by a Redraw) to \n\
+ {"makeDisplayList", ( PyCFunction ) Object_makeDisplayList, METH_NOARGS,
+ "Update this object's Display List. Some changes like turning\n\
+'SubSurf' on for a mesh need this method (followed by a Redraw) to\n\
show the changes on the 3d window."},
{"link", ( PyCFunction ) Object_link, METH_VARARGS,
- "Links Object with data provided in the argument. The data must \n\
+ "Links Object with data provided in the argument. The data must\n\
match the Object's type, so you cannot link a Lamp to a Mesh type object."},
{"makeParent", ( PyCFunction ) Object_makeParent, METH_VARARGS,
- "Makes the object the parent of the objects provided in the \n\
+ "Makes the object the parent of the objects provided in the\n\
argument which must be a list of valid Objects. Optional extra arguments:\n\
mode:\n\t0: make parent with inverse\n\t1: without inverse\n\
fast:\n\t0: update scene hierarchy automatically\n\t\
don't update scene hierarchy (faster). In this case, you must\n\t\
-explicitely update the Scene hierarchy."},
+explicitly update the Scene hierarchy."},
{"join", ( PyCFunction ) Object_join, METH_VARARGS,
"(object_list) - Joins the objects in object list of the same type, into this object."},
{"makeParentDeform", ( PyCFunction ) Object_makeParentDeform, METH_VARARGS,
@@ -564,16 +662,16 @@ Possible arguments (provide as strings):\n\
{"setDeltaLocation", ( PyCFunction ) Object_setDeltaLocation,
METH_VARARGS,
"Sets the object's delta location which must be a vector triple."},
- {"setDrawMode", ( PyCFunction ) Object_setDrawMode, METH_VARARGS,
+ {"setDrawMode", ( PyCFunction ) Object_SetDrawMode, METH_VARARGS,
"Sets the object's drawing mode. The argument can be a sum of:\n\
2: axis\n4: texspace\n8: drawname\n16: drawimage\n32: drawwire"},
- {"setDrawType", ( PyCFunction ) Object_setDrawType, METH_VARARGS,
+ {"setDrawType", ( PyCFunction ) Object_SetDrawType, METH_VARARGS,
"Sets the object's drawing type. The argument must be one of:\n\
1: Bounding box\n2: Wire\n3: Solid\n4: Shaded\n5: Textured"},
- {"setEuler", ( PyCFunction ) Object_setEuler, METH_VARARGS,
+ {"setEuler", ( PyCFunction ) Object_SetEuler, METH_VARARGS,
"Set the object's rotation according to the specified Euler\n\
angles. The argument must be a vector triple"},
- {"setMatrix", ( PyCFunction ) Object_setMatrix, METH_VARARGS,
+ {"setMatrix", ( PyCFunction ) Object_SetMatrix, METH_VARARGS,
"Set and apply a new matrix for the object"},
{"setLocation", ( PyCFunction ) Object_setLocation, METH_VARARGS,
"Set the object's location. The first argument must be a vector\n\
@@ -581,7 +679,7 @@ triple."},
{"setMaterials", ( PyCFunction ) Object_setMaterials, METH_VARARGS,
"Sets materials. The argument must be a list of valid material\n\
objects."},
- {"setName", ( PyCFunction ) Object_setName, METH_VARARGS,
+ {"setName", ( PyCFunction ) Object_SetName, METH_VARARGS,
"Sets the name of the object"},
{"setSize", ( PyCFunction ) Object_setSize, METH_VARARGS,
"Set the object's size. The first argument must be a vector\n\
@@ -600,10 +698,11 @@ works only if self and the object specified are of the same type."},
{"select", ( PyCFunction ) Object_Select, METH_VARARGS,
"( 1 or 0 ) - Set the selected state of the object.\n\
1 is selected, 0 not selected "},
- {"setIpo", ( PyCFunction ) Object_setIpo, METH_VARARGS,
+ {"setIpo", ( PyCFunction ) Object_SetIpo, METH_VARARGS,
"(Blender Ipo) - Sets the object's ipo"},
{"clearIpo", ( PyCFunction ) Object_clearIpo, METH_NOARGS,
"() - Unlink ipo from this object"},
+
{"insertIpoKey", ( PyCFunction ) Object_insertIpoKey, METH_VARARGS,
"( Object IPO type ) - Inserts a key into IPO"},
{"insertPoseKey", ( PyCFunction ) Object_insertPoseKey, METH_VARARGS,
@@ -612,7 +711,7 @@ works only if self and the object specified are of the same type."},
"( Object Pose type ) - Inserts a key into Action based on current pose"},
{"insertMatrixKey", ( PyCFunction ) Object_insertMatrixKey, METH_VARARGS,
"( ) - Inserts a key into Action based on current/giventime object matrix"},
- {"bake_to_action", ( PyCFunction ) Object_bake_to_action, METH_VARARGS,
+ {"bake_to_action", ( PyCFunction ) Object_bake_to_action, METH_NOARGS,
"( ) - creates a new action with the information from object animations"},
{"setConstraintInfluenceForBone", ( PyCFunction ) Object_setConstraintInfluenceForBone, METH_VARARGS,
"( ) - sets a constraint influence for a certain bone in this (armature)object."},
@@ -657,40 +756,10 @@ works only if self and the object specified are of the same type."},
/* PythonTypeObject callback function prototypes */
/*****************************************************************************/
static void Object_dealloc( BPy_Object * obj );
-static PyObject *Object_getAttr( BPy_Object * obj, char *name );
-static int Object_setAttr( BPy_Object * obj, char *name, PyObject * v );
static PyObject *Object_repr( BPy_Object * obj );
static int Object_compare( BPy_Object * a, BPy_Object * b );
/*****************************************************************************/
-/* Python TypeObject structure definition. */
-/*****************************************************************************/
-PyTypeObject Object_Type = {
- PyObject_HEAD_INIT( NULL ) /* requred macro */
- 0, /* ob_size */
- "Blender Object", /* tp_name */
- sizeof( BPy_Object ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) Object_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) Object_getAttr, /* tp_getattr */
- ( setattrfunc ) Object_setAttr, /* tp_setattr */
- ( cmpfunc ) Object_compare, /* tp_compare */
- ( reprfunc ) Object_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 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,
-};
-
-/*****************************************************************************/
/* Function: M_Object_New */
/* Python equivalent: Blender.Object.New */
/*****************************************************************************/
@@ -726,10 +795,9 @@ PyObject *M_Object_New( PyObject * self_unused, PyObject * args )
/* else if (strcmp (str_type, "Wave") == 0) type = OB_WAVE; */
else if( strcmp( str_type, "Empty" ) == 0 )
type = OB_EMPTY;
- else {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Unknown type specified" ) );
- }
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unknown type specified" );
/* Create a new object. */
if( name == NULL ) {
@@ -940,7 +1008,7 @@ static PyObject *M_Object_Duplicate( PyObject * self_unused,
if (!PyArg_ParseTupleAndKeywords(args, kwd, "|iiiiiiiiii", kwlist,
&mesh_dupe, &surface_dupe, &curve_dupe, &text_dupe, &metaball_dupe,
&armature_dupe, &lamp_dupe, &material_dupe, &texture_dupe, &ipo_dupe))
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected nothing or bool keywords 'mesh', 'surface', 'curve', 'text', 'metaball', 'armature', 'lamp' 'material', 'texture' and 'ipo' as arguments" );
/* USER_DUP_ACT for actions is not supported in the UI so dont support it here */
@@ -960,55 +1028,13 @@ static PyObject *M_Object_Duplicate( PyObject * self_unused,
/*****************************************************************************/
-/* Function: initObject */
-/*****************************************************************************/
-PyObject *Object_Init( void )
-{
- PyObject *module, *dict;
-
- Object_Type.ob_type = &PyType_Type;
-
- module = Py_InitModule3( "Blender.Object", M_Object_methods,
- M_Object_doc );
-
- PyModule_AddIntConstant( module, "LOC", IPOKEY_LOC );
- PyModule_AddIntConstant( module, "ROT", IPOKEY_ROT );
- PyModule_AddIntConstant( module, "SIZE", IPOKEY_SIZE );
- PyModule_AddIntConstant( module, "LOCROT", IPOKEY_LOCROT );
- PyModule_AddIntConstant( module, "LOCROTSIZE", IPOKEY_LOCROTSIZE );
-
- PyModule_AddIntConstant( module, "PI_STRENGTH", IPOKEY_PI_STRENGTH );
- PyModule_AddIntConstant( module, "PI_FALLOFF", IPOKEY_PI_FALLOFF );
- PyModule_AddIntConstant( module, "PI_SURFACEDAMP", IPOKEY_PI_SURFACEDAMP );
- PyModule_AddIntConstant( module, "PI_RANDOMDAMP", IPOKEY_PI_RANDOMDAMP );
- PyModule_AddIntConstant( module, "PI_PERM", IPOKEY_PI_PERM );
-
- PyModule_AddIntConstant( module, "NONE",0 );
- PyModule_AddIntConstant( module, "FORCE",PFIELD_FORCE );
- PyModule_AddIntConstant( module, "VORTEX",PFIELD_VORTEX );
- PyModule_AddIntConstant( module, "MAGNET",PFIELD_MAGNET );
- PyModule_AddIntConstant( module, "WIND",PFIELD_WIND );
-
- /*Add SUBMODULES to the module*/
- dict = PyModule_GetDict( module ); /*borrowed*/
- PyDict_SetItemString(dict, "Pose", Pose_Init()); /*creates a *new* module*/
- /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/
-
- return ( module );
-}
-
-/*****************************************************************************/
/* Python BPy_Object methods: */
/*****************************************************************************/
static PyObject *Object_buildParts( BPy_Object * self )
{
- struct Object *obj = self->object;
-
- build_particle_system( obj );
-
- Py_INCREF( Py_None );
- return ( Py_None );
+ build_particle_system( self->object );
+ Py_RETURN_NONE;
}
static PyObject *Object_clearIpo( BPy_Object * self )
@@ -1022,10 +1048,10 @@ static PyObject *Object_clearIpo( BPy_Object * self )
id->us--;
ob->ipo = NULL;
- return EXPP_incr_ret_True();
+ Py_RETURN_TRUE;
}
- return EXPP_incr_ret_False(); /* no ipo found */
+ Py_RETURN_FALSE; /* no ipo found */
}
static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
@@ -1033,10 +1059,9 @@ static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
int mode = 0;
int fast = 0;
- if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected one or two integers as arguments" ) );
- }
+ if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or two optional integers as arguments" );
/* Remove the link only, the object is still in the scene. */
self->object->parent = NULL;
@@ -1046,12 +1071,10 @@ static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
apply_obmat( self->object );
}
- if( !fast ) {
+ if( !fast )
DAG_scene_sort( G.scene );
- }
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
@@ -1059,10 +1082,9 @@ static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
int mode = 0;
int fast = 0;
- if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected one or two integers as arguments" ) );
- }
+ if( !PyArg_ParseTuple( args, "|ii", &mode, &fast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or two optional integers as arguments" );
/* Remove the link only, the object is still in the scene. */
self->object->track = NULL;
@@ -1072,12 +1094,10 @@ static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
apply_obmat( self->object );
}
- if( !fast ) {
+ if( !fast )
DAG_scene_sort( G.scene );
- }
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
/* adds object data to a Blender object, if object->data = NULL */
@@ -1138,158 +1158,32 @@ int EXPP_add_obdata( struct Object *object )
return 0;
}
-
-static PyObject *Object_getData( BPy_Object *self, PyObject *args, PyObject *kwd )
-{
- PyObject *data_object;
- Object *object = self->object;
- int name_only = 0;
- int mesh = 0; /* default mesh type = NMesh */
- static char *kwlist[] = {"name_only", "mesh", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwd, "|ii", kwlist, &name_only, &mesh))
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected nothing or bool keyword 'name_only' as argument" );
-
- /* if there's no obdata, try to create it */
- if( object->data == NULL ) {
- if( EXPP_add_obdata( object ) != 0 ) { /* couldn't create obdata */
- Py_INCREF( Py_None );
- return ( Py_None );
- }
- }
-
- /* user wants only the name of the data object */
- if (name_only) {
- ID *id = object->data;
- data_object = Py_BuildValue("s", id->name+2);
-
- if (data_object) return data_object;
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "could not create a string pyobject!");
- }
-
- /* user wants the data object wrapper */
- data_object = NULL;
-
- switch ( object->type ) {
- case OB_ARMATURE:
- data_object = PyArmature_FromArmature( object->data );
- break;
- case OB_CAMERA:
- data_object = Camera_CreatePyObject( object->data );
- break;
- case OB_CURVE:
- data_object = Curve_CreatePyObject( object->data );
- break;
- case ID_IM:
- data_object = Image_CreatePyObject( object->data );
- break;
- case ID_IP:
- data_object = Ipo_CreatePyObject( object->data );
- break;
- case OB_LAMP:
- data_object = Lamp_CreatePyObject( object->data );
- break;
- case OB_LATTICE:
- data_object = Lattice_CreatePyObject( object->data );
- break;
- case ID_MA:
- break;
- case OB_MESH:
- if( !mesh ) /* get as NMesh (default) */
- data_object = NMesh_CreatePyObject( object->data, object );
- else /* else get as Mesh */
- data_object = Mesh_CreatePyObject( object->data, object );
- break;
- case ID_OB:
- data_object = Object_CreatePyObject( object->data );
- break;
- case ID_SCE:
- break;
- case ID_TXT:
- data_object = Text_CreatePyObject( object->data );
- break;
- case OB_FONT:
- data_object = Text3d_CreatePyObject( object->data );
- break;
- case ID_WO:
- break;
- default:
- break;
- }
- if( data_object == NULL ) {
- Py_INCREF( Py_None );
- return ( Py_None );
- } else {
- return ( data_object );
- }
-}
-
static PyObject *Object_getDeltaLocation( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue( "fff",
- self->object->dloc[0],
- self->object->dloc[1],
- self->object->dloc[2] );
-
- if( attr )
- return ( attr );
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.dloc attributes" ) );
-}
-
-static PyObject *Object_getDrawMode( BPy_Object * self )
-{
- PyObject *attr = Py_BuildValue( "b", self->object->dtx );
-
- if( attr )
- return ( attr );
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.drawMode attribute" ) );
+ return Py_BuildValue( "fff", self->object->dloc[0],
+ self->object->dloc[1], self->object->dloc[2] );
}
static PyObject *Object_getAction( BPy_Object * self )
{
- /*BPy_Action *py_action = NULL; */
-
- if( !self->object->action ) {
- Py_INCREF( Py_None );
- return ( Py_None );
- } else {
+ if( self->object->action )
return Action_CreatePyObject( self->object->action );
- }
-}
-
-#if 0
-static PyObject *Object_getPose( BPy_Object * self )
-{
- /*BPy_Action *py_action = NULL; */
-
- if( !self->object->pose ) {
- Py_INCREF( Py_None );
- return ( Py_None );
- }
- else
- return Pose_CreatePyObject( self->object->pose );
+ Py_RETURN_NONE;
}
-#endif
-
static PyObject *Object_evaluatePose(BPy_Object *self, PyObject *args)
{
int frame = 1;
- if( !PyArg_ParseTuple( args, "i", &frame ))
- return EXPP_ReturnPyObjError( PyExc_AttributeError, "expected int argument" );
+ if( !PyArg_ParseTuple( args, "i", &frame ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
frame = EXPP_ClampInt(frame, MINFRAME, MAXFRAME);
G.scene->r.cfra = frame;
do_all_pose_actions(self->object);
where_is_pose (self->object);
- return EXPP_incr_ret(Py_None);
+ Py_RETURN_NONE;
}
static PyObject * Object_getPose(BPy_Object *self)
@@ -1298,7 +1192,7 @@ static PyObject * Object_getPose(BPy_Object *self)
return PyPose_FromPose(self->object->pose, self->object->id.name+2);
}
-static PyObject *Object_isSelected( BPy_Object * self )
+static PyObject *Object_getSelected( BPy_Object * self )
{
Base *base;
@@ -1306,37 +1200,53 @@ static PyObject *Object_isSelected( BPy_Object * self )
while( base ) {
if( base->object == self->object ) {
if( base->flag & SELECT ) {
- return EXPP_incr_ret_True();
+ Py_RETURN_TRUE;
} else {
- return EXPP_incr_ret_False();
+ Py_RETURN_FALSE;
}
}
base = base->next;
}
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Internal error: could not find objects selection state" ) );
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "could not find object's selection state" );
}
-static PyObject *Object_getDrawType( BPy_Object * self )
+static int Object_setSelect( BPy_Object * self, PyObject * value )
{
- PyObject *attr = Py_BuildValue( "b", self->object->dt );
+ Base *base;
+ int setting = PyObject_IsTrue( value );
- if( attr )
- return ( attr );
+ if( setting == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.drawType attribute" ) );
+ base = FIRSTBASE;
+ while( base ) {
+ if( base->object == self->object ) {
+ if( setting == 1 ) {
+ base->flag |= SELECT;
+ self->object->flag = (short)base->flag;
+ set_active_base( base );
+ } else {
+ base->flag &= ~SELECT;
+ self->object->flag = (short)base->flag;
+ }
+ break;
+ }
+ base = base->next;
+ }
+ countall( );
+ return 0;
}
-static PyObject *Object_getEuler( BPy_Object * self, PyObject * args )
+static PyObject *Object_GetEuler( BPy_Object * self, PyObject * args )
{
char *space = "localspace"; /* default to local */
float eul[3];
- if( !PyArg_ParseTuple( args, "|s", &space ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string or nothing" ) );
- }
+ if( !PyArg_ParseTuple( args, "|s", &space ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string or nothing" );
if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
float mat3[3][3];
@@ -1350,9 +1260,8 @@ static PyObject *Object_getEuler( BPy_Object * self, PyObject * args )
eul[1] = self->object->rot[1];
eul[2] = self->object->rot[2];
} else {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "wrong parameter, expected nothing or either 'localspace' (default),\n\
-'worldspace'" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected either nothing, 'localspace' (default) or 'worldspace'" );
}
return ( PyObject * ) newEulerObject( eul, Py_NEW );
@@ -1361,7 +1270,7 @@ static PyObject *Object_getEuler( BPy_Object * self, PyObject * args )
static PyObject *Object_getInverseMatrix( BPy_Object * self )
{
MatrixObject *inverse =
- ( MatrixObject * ) newMatrixObject( NULL, 4, 4, Py_NEW);
+ ( MatrixObject * ) newMatrixObject( NULL, 4, 4, Py_NEW );
Mat4Invert( (float ( * )[4])*inverse->matrix, self->object->obmat );
return ( ( PyObject * ) inverse );
@@ -1371,23 +1280,19 @@ static PyObject *Object_getIpo( BPy_Object * self )
{
struct Ipo *ipo = self->object->ipo;
- if( !ipo ) {
- Py_INCREF( Py_None );
- return Py_None;
- }
-
- return Ipo_CreatePyObject( ipo );
+ if( ipo )
+ return Ipo_CreatePyObject( ipo );
+ Py_RETURN_NONE;
}
static PyObject *Object_getLocation( BPy_Object * self, PyObject * args )
{
char *space = "localspace"; /* default to local */
PyObject *attr;
- if( !PyArg_ParseTuple( args, "|s", &space ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string or nothing" ) );
- }
-
+ if( !PyArg_ParseTuple( args, "|s", &space ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string or nothing" );
+
if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
disable_where_script( 1 );
where_is_object( self->object );
@@ -1398,127 +1303,48 @@ static PyObject *Object_getLocation( BPy_Object * self, PyObject * args )
self->object->obmat[3][2] );
disable_where_script( 0 );
-
} else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */
attr = Py_BuildValue( "fff",
self->object->loc[0],
self->object->loc[1],
self->object->loc[2] );
- } else {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "wrong parameter, expected nothing or either 'localspace' (default),\n\
-'worldspace'" ) );
- }
-
- if( attr )
- return ( attr );
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected either nothing, 'localspace' (default) or 'worldspace'" );
+ }
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.loc attributes" ) );
+ return attr;
}
static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args )
{
int all = 0;
- if( !PyArg_ParseTuple( args, "|i", &all ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an int or nothing" ) );
- }
-
- return ( EXPP_PyList_fromMaterialList( self->object->mat,
- self->object->totcol, all ) );
-}
-
-static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args )
-{
- Object *ob = self->object;
- char *space = "worldspace"; /* default to world */
-
- if( !PyArg_ParseTuple( args, "|s", &space ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string or nothing" ) );
- }
-
- if( BLI_streq( space, "worldspace" ) ) { /* world space matrix */
- disable_where_script( 1 );
- where_is_object( self->object );
- disable_where_script( 0 );
- }
-
- else if( BLI_streq( space, "localspace" )) {/* return local space matrix */
- if (ob->parent) {
- float matrix[4][4]; /* for the result */
- float invmat[4][4]; /* for inverse of parent's matrix */
-
- Mat4Invert(invmat, self->object->parent->obmat );
- Mat4MulMat4(matrix, self->object->obmat, invmat);
- return newMatrixObject((float*)matrix,4,4,Py_NEW);
- }
- else { /* no parent, so return world space matrix */
- disable_where_script( 1 );
- where_is_object( self->object );
- disable_where_script( 0 );
- }
- }
-
- else if( BLI_streq( space, "old_worldspace" ) ) {
- /* old behavior, prior to 2.34, check this method's doc string: */
- }
-
- else {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "wrong parameter, expected nothing or either\n\
- 'worldspace' (default), 'localspace' or 'old_worldspace'" ) );
- }
+ if( !PyArg_ParseTuple( args, "|i", &all ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int or nothing" );
- /* return world space matrix */
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
+ return EXPP_PyList_fromMaterialList( self->object->mat,
+ self->object->totcol, all );
}
static PyObject *Object_getName( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue( "s", self->object->id.name + 2 );
-
- if( attr )
- return ( attr );
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get the name of the Object" ) );
+ return PyString_FromString( self->object->id.name + 2 );
}
static PyObject *Object_getParent( BPy_Object * self )
{
- PyObject *attr;
-
- if( self->object->parent == NULL )
- return EXPP_incr_ret( Py_None );
-
- attr = Object_CreatePyObject( self->object->parent );
-
- if( attr ) {
- return ( attr );
- }
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.parent attribute" ) );
+ if( self->object->parent )
+ return Object_CreatePyObject( self->object->parent );
+ Py_RETURN_NONE;
}
static PyObject *Object_getParentBoneName( BPy_Object * self )
{
- PyObject *attr;
-
- if( self->object->parent == NULL )
- return EXPP_incr_ret( Py_None );
- if( self->object->parsubstr[0] == '\0' )
- return EXPP_incr_ret( Py_None );
-
- attr = Py_BuildValue( "s", self->object->parsubstr );
- if( attr )
- return attr;
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Failed to get parent bone name" ) );
+ if( self->object->parent && self->object->parsubstr[0] != '\0' )
+ return PyString_FromString( self->object->parsubstr );
+ Py_RETURN_NONE;
}
static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
@@ -1526,11 +1352,10 @@ static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
PyObject *attr;
char *space = "localspace"; /* default to local */
- if( !PyArg_ParseTuple( args, "|s", &space ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string or nothing" ) );
- }
-
+ if( !PyArg_ParseTuple( args, "|s", &space ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string or nothing" );
+
if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
float scale[3];
disable_where_script( 1 );
@@ -1547,75 +1372,67 @@ static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
self->object->size[1],
self->object->size[2] );
} else {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "wrong parameter, expected nothing or either 'localspace' (default),\n\
-'worldspace'" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected either nothing, 'localspace' (default) or 'worldspace'" );
}
- if( attr )
- return ( attr );
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.size attributes" ) );
+ return attr;
}
static PyObject *Object_getTimeOffset( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue( "f", self->object->sf );
-
- if( attr )
- return ( attr );
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.sf attributes" ) );
+ return PyFloat_FromDouble ( (double) self->object->sf );
}
-
static PyObject *Object_getTracked( BPy_Object * self )
{
- PyObject *attr;
-
- if( self->object->track == NULL )
- return EXPP_incr_ret( Py_None );
-
- attr = Object_CreatePyObject( self->object->track );
-
- if( attr ) {
- return ( attr );
- }
-
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object.track attribute" ) );
+ if( self->object->track )
+ return Object_CreatePyObject( self->object->track );
+ Py_RETURN_NONE;
}
static PyObject *Object_getType( BPy_Object * self )
{
+ char *str;
switch ( self->object->type ) {
case OB_ARMATURE:
- return ( Py_BuildValue( "s", "Armature" ) );
+ str = "Armature";
+ break;
case OB_CAMERA:
- return ( Py_BuildValue( "s", "Camera" ) );
+ str = "Camera";
+ break;
case OB_CURVE:
- return ( Py_BuildValue( "s", "Curve" ) );
+ str = "Curve";
+ break;
case OB_EMPTY:
- return ( Py_BuildValue( "s", "Empty" ) );
+ str = "Empty";
+ break;
case OB_FONT:
- return ( Py_BuildValue( "s", "Text" ) );
+ str = "Text";
+ break;
case OB_LAMP:
- return ( Py_BuildValue( "s", "Lamp" ) );
+ str = "Lamp";
+ break;
case OB_LATTICE:
- return ( Py_BuildValue( "s", "Lattice" ) );
+ str = "Lattice";
+ break;
case OB_MBALL:
- return ( Py_BuildValue( "s", "MBall" ) );
+ str = "MBall";
+ break;
case OB_MESH:
- return ( Py_BuildValue( "s", "Mesh" ) );
+ str = "Mesh";
+ break;
case OB_SURF:
- return ( Py_BuildValue( "s", "Surf" ) );
+ str = "Surf";
+ break;
case OB_WAVE:
- return ( Py_BuildValue( "s", "Wave" ) );
+ str = "Wave";
+ break;
default:
- return ( Py_BuildValue( "s", "unknown" ) );
+ str = "unknown";
+ break;
}
+ return PyString_FromString( str );
}
static PyObject *Object_getBoundBox( BPy_Object * self )
@@ -1626,7 +1443,7 @@ static PyObject *Object_getBoundBox( BPy_Object * self )
if( !self->object->data )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "This object isn't linked to any object data (mesh, curve, etc) yet" );
+ "This object isn't linked to any object data (mesh, curve, etc) yet" );
if( !self->object->bb ) { /* if no ob bbox, we look in obdata */
Mesh *me;
@@ -1645,8 +1462,7 @@ static PyObject *Object_getBoundBox( BPy_Object * self )
vec = ( float * ) curve->bb->vec;
break;
default:
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
{ /* transform our obdata bbox by the obmat.
@@ -1721,7 +1537,6 @@ static PyObject *Object_getBoundBox( BPy_Object * self )
return bbox;
}
-
static PyObject *Object_makeDisplayList( BPy_Object * self )
{
Object *ob = self->object;
@@ -1731,8 +1546,7 @@ static PyObject *Object_makeDisplayList( BPy_Object * self )
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *Object_link( BPy_Object * self, PyObject * args )
@@ -1742,11 +1556,12 @@ static PyObject *Object_link( BPy_Object * self, PyObject * args )
ID *oldid;
int obj_id;
void *data = NULL;
+ int ok;
+
+ if( !PyArg_ParseTuple( args, "O", &py_data ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an object as argument" );
- if( !PyArg_ParseTuple( args, "O", &py_data ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an object as argument" ) );
- }
if( ArmatureObject_Check( py_data ) )
data = ( void * ) PyArmature_AsArmature((BPy_Armature*)py_data);
else if( Camera_CheckPyObject( py_data ) )
@@ -1769,62 +1584,59 @@ static PyObject *Object_link( BPy_Object * self, PyObject * args )
data = ( void * ) Text3d_FromPyObject( py_data );
/* have we set data to something good? */
- if( !data ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "link argument type is not supported " ) );
- }
+ if( !data )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "link argument type is not supported " );
oldid = ( ID * ) self->object->data;
id = ( ID * ) data;
obj_id = MAKE_ID2( id->name[0], id->name[1] );
+ ok = 1;
switch ( obj_id ) {
case ID_AR:
if( self->object->type != OB_ARMATURE ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_CA:
if( self->object->type != OB_CAMERA ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_LA:
if( self->object->type != OB_LAMP ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_ME:
if( self->object->type != OB_MESH ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_CU:
if( self->object->type != OB_CURVE && self->object->type != OB_FONT ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_LT:
if( self->object->type != OB_LATTICE ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
case ID_MB:
if( self->object->type != OB_MBALL ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "The 'link' object is incompatible with the base object" ) );
+ ok = 0;
}
break;
default:
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Linking this object type is not supported" ) );
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Linking this object type is not supported" );
}
+
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" );
self->object->data = data;
/* creates the curve for the text object */
@@ -1844,7 +1656,7 @@ static PyObject *Object_link( BPy_Object * self, PyObject * args )
/* make sure data and object materials are consistent */
test_object_materials( id );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args )
@@ -1858,55 +1670,53 @@ static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args )
int fast = 0;
int partype;
int v1, v2=0, v3=0;
- int i, vlen;
+ int i;
/* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "OO|ii", &list, &vlist, &noninverse, &fast ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a list of objects, a tuple of integers and one or two integers as arguments" ) );
- }
- if( !PySequence_Check( list ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" ) );
- }
+ if( !PyArg_ParseTuple( args, "OO|ii", &list, &vlist, &noninverse, &fast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects, a tuple of integers and one or two integers as arguments" );
+
+ if( !PySequence_Check( list ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" );
if (!PyTuple_Check( vlist ))
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of integers" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a tuple of integers" );
- vlen = PyTuple_Size( vlist );
- switch (vlen) {
+ switch( PyTuple_Size( vlist ) ) {
case 1:
if( !PyArg_ParseTuple( vlist, "i", &v1 ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a tuple of 1 or 3 integers" );
if ( v1 < 0 )
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "indices must be strictly positive" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "indices must be strictly positive" );
partype = PARVERT1;
break;
case 3:
if( !PyArg_ParseTuple( vlist, "iii", &v1, &v2, &v3 ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a tuple of 1 or 3 integers" );
if ( v1 < 0 || v2 < 0 || v3 < 0)
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "indices must be strictly positive" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "indices must be strictly positive" );
partype = PARVERT3;
break;
default:
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a tuple of 1 or 3 integers" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a tuple of 1 or 3 integers" );
}
parent = ( Object * ) self->object;
if (!ELEM3(parent->type, OB_MESH, OB_CURVE, OB_SURF))
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Parent Vertex only applies to curve, mesh or surface objects" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Parent Vertex only applies to curve, mesh or surface objects" );
if (parent->id.us == 0)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
@@ -1922,7 +1732,7 @@ static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args )
if (ret_val)
Py_DECREF(ret_val);
else {
- if (!fast) /* need to sort when interupting in the middle of the list */
+ if (!fast) /* need to sort when interrupting in the middle of the list */
DAG_scene_sort( G.scene );
return NULL; /* error has been set already */
}
@@ -1931,7 +1741,7 @@ static PyObject *Object_makeParentVertex( BPy_Object * self, PyObject * args )
if (!fast) /* otherwise, only sort at the end */
DAG_scene_sort( G.scene );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args )
@@ -1945,20 +1755,19 @@ static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args )
int i;
/* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a list of objects and one or two integers as arguments" ) );
- }
- if( !PySequence_Check( list ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" ) );
- }
+ if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects and one or two integers as arguments" );
+
+ if( !PySequence_Check( list ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" );
parent = ( Object * ) self->object;
if (parent->type != OB_CURVE && parent->type != OB_ARMATURE)
- return ( EXPP_ReturnPyObjError( PyExc_ValueError,
- "Parent Deform only applies to curve or armature objects" ) );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Parent Deform only applies to curve or armature objects" );
if (parent->id.us == 0)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
@@ -1983,7 +1792,7 @@ static PyObject *Object_makeParentDeform( BPy_Object * self, PyObject * args )
if (!fast) /* otherwise, only sort at the end */
DAG_scene_sort( G.scene );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
@@ -1997,14 +1806,13 @@ static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
int i;
/* Check if the arguments passed to makeParent are valid. */
- if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a list of objects and one or two integers as arguments" ) );
- }
- if( !PySequence_Check( list ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" ) );
- }
+ if( !PyArg_ParseTuple( args, "O|ii", &list, &noninverse, &fast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects and one or two integers as arguments" );
+
+ if( !PySequence_Check( list ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" );
parent = ( Object * ) self->object;
@@ -2031,10 +1839,9 @@ static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
if (!fast) /* otherwise, only sort at the end */
DAG_scene_sort( G.scene );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-
static PyObject *Object_join( BPy_Object * self, PyObject * args )
{
PyObject *list;
@@ -2046,77 +1853,79 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args )
Base *temp_base;
short type;
int i, ok=0, ret_value=0, list_length=0;
-
- if( G.background==1 )
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "cannot join objects in background mode" ) );
-
+
+ /* joining in background causes segfaults */
+ if( G.background == 1 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "cannot join objects in background mode" );
+
/* Check if the arguments passed to makeParent are valid. */
if( !PyArg_ParseTuple( args, "O", &list ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" );
if( !PySequence_Check( list ) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" );
list_length = PySequence_Length( list ); /* if there are no objects to join then exit silently */
- if( !list_length )
- return EXPP_incr_ret( Py_None );
-
+ if( !list_length ) {
+ Py_RETURN_NONE;
+ }
parent = ( Object * ) self->object;
type = parent->type;
/* Only these object types are sypported */
- if (type==OB_MESH || type==OB_MESH || type==OB_CURVE || type==OB_SURF || type==OB_ARMATURE);
- else
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Base object is not a type blender can join" ) );
-
- if (object_in_scene( parent, G.scene )==NULL)
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "object must be in the current scene" ) );
+ if( type!=OB_MESH && type!=OB_CURVE && type!=OB_SURF && type!=OB_ARMATURE )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Base object is not a type Blender can join" );
+ if( !object_in_scene( parent, G.scene ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object must be in the current scene" );
+
/* exit editmode so join can be done */
if( G.obedit )
exit_editmode( 1 );
temp_scene = add_scene( "Scene" ); /* make the new scene */
- temp_scene->lay= 1; /* all layers on */
+ temp_scene->lay= 1; /* first layer on */
+ /* TODO: use EXPP_check_sequence_consistency here */
+
/* Check if the PyObject passed in list is a Blender object. */
for( i = 0; i < list_length; i++ ) {
- child = NULL;
py_child = PySequence_GetItem( list, i );
if( !Object_CheckPyObject( py_child ) ) {
/* Cleanup */
free_libblock( &G.main->scene, temp_scene );
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of objects, one or more of the list items is not a Blender Object." ) );
+ Py_DECREF( py_child );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects, one or more of the list items is not a Blender Object." );
} else {
/* List item is an object, is it the same type? */
child = ( Object * ) Object_FromPyObject( py_child );
- Py_DECREF (py_child);
- if (parent->type == child->type) {
-
- if (object_in_scene( child, G.scene )==NULL) {
+ Py_DECREF( py_child );
+ if( parent->type == child->type ) {
+ if( !object_in_scene( child, G.scene ) ) {
free_libblock( &G.main->scene, temp_scene );
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "object must be in the current scene" ) );
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object must be in the current scene" );
}
-
+
ok =1;
/* Add a new base, then link the base to the temp_scene */
temp_base = MEM_callocN( sizeof( Base ), "pynewbase" );
- /*we know these types are the same, link to the temp scene for joining*/
+ /* we know these types are the same, link to the temp scene
+ * for joining */
temp_base->object = child; /* link object to the new base */
temp_base->flag |= SELECT;
temp_base->lay = 1; /*1 layer on */
BLI_addhead( &temp_scene->base, temp_base ); /* finally, link new base to scene */
- /*child->id.us += 1;*/ /*Would useually increase user count but in this case its ok not to */
+ /*child->id.us += 1;*/ /*Would usually increase user count but in this case it's ok not to */
} else {
child->id.us -= 1; /* python object user oddness */
}
@@ -2158,46 +1967,43 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args )
base = base->next;
}
}*/
-
+
/* remove old scene */
set_scene( orig_scene );
free_libblock( &G.main->scene, temp_scene );
-
-
+
/* no objects were of the correct type, return None */
- if (!ok)
- return EXPP_incr_ret( Py_None );
-
+ if (!ok) {
+ Py_RETURN_NONE;
+ }
+
/* If the join failed then raise an error */
if (!ret_value)
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
-"Blender failed to join the objects, this is not a script error\n\
-Please add exception handeling to your script with a RuntimeError exception\n\
+"Blender failed to join the objects, this is not a script error.\n\
+Please add exception handling to your script with a RuntimeError exception\n\
letting the user know that their data could not be joined." ) );
-
- return EXPP_incr_ret( Py_None );
+
+ Py_RETURN_NONE;
}
static PyObject *internal_makeParent(Object *parent, PyObject *py_child,
- int partype, /* parenting type */
- int noninverse, int fast, /* parenting arguments */
- int v1, int v2, int v3 /* for vertex parent */
- )
+ int partype, /* parenting type */
+ int noninverse, int fast, /* parenting arguments */
+ int v1, int v2, int v3 ) /* for vertex parent */
{
Object *child = NULL;
if( Object_CheckPyObject( py_child ) )
child = ( Object * ) Object_FromPyObject( py_child );
- if( child == NULL ) {
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "Object Type expected" ) );
- }
+ if( child == NULL )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Object Type expected" );
- if( test_parent_loop( parent, child ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "parenting loop detected - parenting failed" ) );
- }
+ if( test_parent_loop( parent, child ) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "parenting loop detected - parenting failed" );
if (partype == PARSKEL && child->type != OB_MESH)
child->partype = PAROBJECT;
@@ -2227,11 +2033,10 @@ static PyObject *internal_makeParent(Object *parent, PyObject *py_child,
clear_workob();
}
- if( !fast ) {
+ if( !fast )
child->recalc |= OB_RECALC_OB;
- }
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_materialUsage( void )
@@ -2255,8 +2060,8 @@ static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args )
&dloc3 );
if( !status )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected list argument of 3 floats" );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected sequence argument of 3 floats" );
self->object->dloc[0] = dloc1;
self->object->dloc[1] = dloc2;
@@ -2265,86 +2070,73 @@ static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args )
/* since we have messed with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
-static PyObject *Object_setDrawMode( BPy_Object * self, PyObject * args )
+#define DTX_MASK ( OB_AXIS | OB_TEXSPACE | OB_DRAWNAME | \
+ OB_DRAWIMAGE | OB_DRAWWIRE | OB_DRAWXRAY | OB_DRAWTRANSP )
+
+static PyObject *Object_getDrawMode( BPy_Object * self )
{
- char dtx;
+ return PyInt_FromLong( (long)(self->object->dtx & DTX_MASK) );
+}
- if( !PyArg_ParseTuple( args, "b", &dtx ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an integer as argument" ) );
- }
- self->object->dtx = dtx;
+static int Object_setDrawMode( BPy_Object * self, PyObject * args )
+{
+ PyObject* integer = PyNumber_Int( args );
+ int value;
- /* since we have messed with object, we need to flag for DAG recalc */
+ if( !integer )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected integer argument" );
+
+ value = ( int )PyInt_AS_LONG( integer );
+ if( value & ~DTX_MASK )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "undefined bit(s) set in bitfield" );
+
+ self->object->dtx = value;
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ return 0;
}
-static PyObject *Object_setDrawType( BPy_Object * self, PyObject * args )
+static PyObject *Object_getDrawType( BPy_Object * self )
{
- char dt;
-
- if( !PyArg_ParseTuple( args, "b", &dt ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an integer as argument" ) );
- }
- self->object->dt = dt;
+ return PyInt_FromLong( (long)self->object->dt );
+}
- /* since we have messed with object, we need to flag for DAG recalc */
+static int Object_setDrawType( BPy_Object * self, PyObject * value )
+{
+ /* since we mess with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ return EXPP_setIValueRange( value, &self->object->dt,
+ OB_BOUNDBOX, OB_TEXTURE, 'b' );
}
-static PyObject *Object_setEuler( BPy_Object * self, PyObject * args )
+static int Object_setEuler( BPy_Object * self, PyObject * args )
{
- float rot1 = 0.0f;
- float rot2 = 0.0f;
- float rot3 = 0.0f;
+ float rot1, rot2, rot3;
int status = 0; /* failure */
- PyObject *ob;
-
- /*
- args is either a tuple/list of floats or an euler.
- for backward compatibility, we also accept 3 floats.
- */
- /* do we have 3 floats? */
- if( PyObject_Length( args ) == 3 ) {
+ if( EulerObject_Check( args ) ) {
+ rot1 = ( ( EulerObject * ) args )->eul[0];
+ rot2 = ( ( EulerObject * ) args )->eul[1];
+ rot3 = ( ( EulerObject * ) args )->eul[2];
+ status = 1;
+ } else if( PySequence_Check( args ) && PySequence_Size( args ) == 3 ) {
+ if( PyList_Check( args ) )
+ args = PySequence_Tuple( args );
+ else
+ Py_INCREF( args );
status = PyArg_ParseTuple( args, "fff", &rot1, &rot2, &rot3 );
- } else { /*test to see if it's a list or a euler*/
- if( PyArg_ParseTuple( args, "O", &ob ) ) {
- if( EulerObject_Check( ob ) ) {
- rot1 = ( ( EulerObject * ) ob )->eul[0];
- rot2 = ( ( EulerObject * ) ob )->eul[1];
- rot3 = ( ( EulerObject * ) ob )->eul[2];
- status = 1; /* success! */
- } else if( PySequence_Check( ob ) )
- status = PyArg_ParseTuple( args, "(fff)",
- &rot1, &rot2,
- &rot3 );
- else { /* not an euler or tuple */
-
- /* python C api doc says don't decref this */
- /*Py_DECREF (ob); */
-
- status = 0; /* false */
- }
- } else { /* arg parsing failed */
- status = 0;
- }
+ Py_DECREF( args );
}
- if( !status ) /* parsing args failed */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected euler or list/tuple of 3 floats " ) );
+ if( !status )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected euler or sequence of 3 floats" );
self->object->rot[0] = rot1;
self->object->rot[1] = rot2;
@@ -2353,20 +2145,16 @@ static PyObject *Object_setEuler( BPy_Object * self, PyObject * args )
/* since we have messed with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ return 0;
}
-
-static PyObject *Object_setMatrix( BPy_Object * self, PyObject * args )
+static int Object_setMatrix( BPy_Object * self, MatrixObject * mat )
{
- MatrixObject *mat;
int x, y;
- if( !PyArg_ParseTuple( args, "O!", &matrix_Type, &mat ) )
- return EXPP_ReturnPyObjError
- ( PyExc_TypeError,
- "expected matrix object as argument" );
+ if( !MatrixObject_Check( mat ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected matrix object as argument" );
if( mat->rowSize == 4 && mat->colSize == 4 ) {
for( x = 0; x < 4; x++ ) {
@@ -2385,57 +2173,18 @@ static PyObject *Object_setMatrix( BPy_Object * self, PyObject * args )
self->object->obmat[x][3] = self->object->obmat[3][x] = 0.0;
self->object->obmat[3][3] = 1.0;
} else
- return EXPP_ReturnPyObjError ( PyExc_ValueError,
- "expected 3x3 or 4x4 matrix" );
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "expected 3x3 or 4x4 matrix" );
apply_obmat( self->object );
/* since we have messed with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ return 0;
}
-static PyObject *Object_setIpo( BPy_Object * self, PyObject * args )
-{
- PyObject *pyipo = 0;
- Ipo *ipo = NULL;
- Ipo *oldipo;
-
- if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Ipo as argument" );
-
- ipo = Ipo_FromPyObject( pyipo );
-
- if( !ipo )
- return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "null ipo!" );
-
- if( ipo->blocktype != ID_OB )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "this ipo is not an object ipo" );
-
- oldipo = self->object->ipo;
- if( oldipo ) {
- ID *id = &oldipo->id;
- if( id->us > 0 )
- id->us--;
- }
-
- ( ( ID * ) & ipo->id )->us++;
-
- self->object->ipo = ipo;
-
- /* since we have messed with object, we need to flag for DAG recalc */
- self->object->recalc |= OB_RECALC_OB;
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
/*
* Object_insertIpoKey()
* inserts Object IPO key for LOC, ROT, SIZE, LOCROT, or LOCROTSIZE
@@ -2447,10 +2196,11 @@ static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
Object *ob= self->object;
int key = 0;
char *actname= NULL;
-
- if( !PyArg_ParseTuple( args, "i", &( key ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
+
+ if( !PyArg_ParseTuple( args, "i", &key ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
if(ob->ipoflag & OB_ACTION_OB)
actname= "Object";
@@ -2459,50 +2209,41 @@ static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z);
}
- if (key == IPOKEY_ROT || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
+ else if (key == IPOKEY_ROT || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z);
}
- if (key == IPOKEY_SIZE || key == IPOKEY_LOCROTSIZE ){
+ else if (key == IPOKEY_SIZE || key == IPOKEY_LOCROTSIZE ){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z);
}
-
- if (key == IPOKEY_PI_STRENGTH ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR);
- }
-
- if (key == IPOKEY_PI_FALLOFF ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL);
- }
-
- if (key == IPOKEY_PI_SURFACEDAMP ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP);
- }
-
- if (key == IPOKEY_PI_RANDOMDAMP ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP);
- }
-
- if (key == IPOKEY_PI_PERM ){
- insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM);
+ else if (key == IPOKEY_PI_STRENGTH ){
+ insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR);
+ } else if (key == IPOKEY_PI_FALLOFF ){
+ insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL);
+ } else if (key == IPOKEY_PI_SURFACEDAMP ){
+ insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP);
+ } else if (key == IPOKEY_PI_RANDOMDAMP ){
+ insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP);
+ } else if (key == IPOKEY_PI_PERM ){
+ insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM);
}
-
allspace(REMAKEIPO, 0);
EXPP_allqueue(REDRAWIPO, 0);
EXPP_allqueue(REDRAWVIEW3D, 0);
EXPP_allqueue(REDRAWACTION, 0);
EXPP_allqueue(REDRAWNLA, 0);
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
/*
* Object_insertPoseKey()
- * inserts a Action Pose key from a given pose (sourceaction, frame) to the active action to a given framenum
+ * inserts a Action Pose key from a given pose (sourceaction, frame) to the
+ * active action to a given framenum
*/
static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
@@ -2520,30 +2261,27 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
int oldframe;
int curframe;
- if( !PyArg_ParseTuple( args, "O!sii", &Action_Type, &sourceact, &chanName, &actframe, &curframe ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects an action to copy poses from, a string for chan/bone name, an int argument for frame-to-extract from the action and finally another int for the frame where to put the new key in the active object.action" ) );
+ if( !PyArg_ParseTuple( args, "O!sii", &Action_Type, &sourceact,
+ &chanName, &actframe, &curframe ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expects an action to copy poses from, a string for chan/bone name, an int argument for frame to extract from the action and finally another int for the frame where to put the new key in the active object.action" );
- printf("%s %s %d %d, ", sourceact->action->id.name, chanName, actframe, curframe);
- printf("%s\n", ob->action->id.name);
-
- /* */
extract_pose_from_action(ob->pose, sourceact->action, (float)actframe);
oldframe = G.scene->r.cfra;
G.scene->r.cfra = curframe;
-
+
/*debug*/
pchan = get_pose_channel(ob->pose, chanName);
printquat(pchan->name, pchan->quat);
achan = get_action_channel(sourceact->action, chanName);
- if(achan->ipo) {
- IpoCurve* icu;
- for (icu = achan->ipo->curve.first; icu; icu=icu->next){
- printvecf("bezt", icu->bezt->vec[1]);
- }
+ if( achan->ipo ) {
+ IpoCurve* icu;
+ for( icu = achan->ipo->curve.first; icu; icu=icu->next )
+ printvecf("bezt", icu->bezt->vec[1]);
}
-
+
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z);
@@ -2555,17 +2293,6 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
- /*
- for (achan = ob->action->chanbase.first; achan; achan=achan->next) {
- if(achan->ipo) {
- IpoCurve* icu;
- for (icu = achan->ipo->curve.first; icu; icu=icu->next){
- printf("result: %f %f %f %f", icu->bp->vec[0], icu->bp->vec[1], icu->bp->vec[2], icu->bp->vec[3]);
- }
- }
- }
- */
-
G.scene->r.cfra = oldframe;
allspace(REMAKEIPO, 0);
@@ -2578,53 +2305,54 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
/*extract_pose_from_action(ob->pose, ob->action, G.scene->r.cfra);
where_is_pose(ob);*/
- allqueue(REDRAWACTION, 1);
+ EXPP_allqueue(REDRAWACTION, 1);
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args )
+static PyObject *Object_insertCurrentPoseKey( BPy_Object * self,
+ PyObject * args )
{
- Object *ob= self->object;
- /*bPoseChannel *pchan;*/ /*for iterating over all channels in object->pose*/
- char *chanName;
+ Object *ob= self->object;
+ char *chanName;
/* for doing the time trick, similar to editaction bake_action_with_client() */
- int oldframe;
- int curframe;
-
- if( !PyArg_ParseTuple( args, "si", &chanName, &curframe ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected chan/bone name, and a time (int) argument" ) );
-
- oldframe = G.scene->r.cfra;
- G.scene->r.cfra = curframe;
-
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
- insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
-
- G.scene->r.cfra = oldframe;
-
- allspace(REMAKEIPO, 0);
- EXPP_allqueue(REDRAWIPO, 0);
- EXPP_allqueue(REDRAWVIEW3D, 0);
- EXPP_allqueue(REDRAWACTION, 0);
- EXPP_allqueue(REDRAWNLA, 0);
-
- /* restore */
- extract_pose_from_action(ob->pose, ob->action, (float)G.scene->r.cfra);
- where_is_pose(ob);
-
- allqueue(REDRAWACTION, 1);
+int oldframe;
+int curframe;
+
+ if( !PyArg_ParseTuple( args, "si", &chanName, &curframe ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected chan/bone name, and a time (int) argument" );
+
+ oldframe = G.scene->r.cfra;
+ G.scene->r.cfra = curframe;
+
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
+ insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
+
+ G.scene->r.cfra = oldframe;
+
+ allspace(REMAKEIPO, 0);
+ EXPP_allqueue(REDRAWIPO, 0);
+ EXPP_allqueue(REDRAWVIEW3D, 0);
+ EXPP_allqueue(REDRAWACTION, 0);
+ EXPP_allqueue(REDRAWNLA, 0);
- return EXPP_incr_ret( Py_None );
+ /* restore */
+ extract_pose_from_action(ob->pose, ob->action, (float)G.scene->r.cfra);
+ where_is_pose(ob);
+
+ EXPP_allqueue(REDRAWACTION, 1);
+
+ Py_RETURN_NONE;
}
static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
@@ -2632,7 +2360,10 @@ static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
Object *ob= self->object;
char *chanName;
- /* for doing the time trick, similar to editaction bake_action_with_client() */
+ /*
+ * for doing the time trick, similar to editaction
+ * bake_action_with_client()
+ */
int oldframe;
int curframe;
@@ -2645,16 +2376,20 @@ static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
Bone *bone;
if( !PyArg_ParseTuple( args, "si", &chanName, &curframe ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects a string for chan/bone name and an int for the frame where to put the new key" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expects a string for chan/bone name and an int for the frame where to put the new key" );
oldframe = G.scene->r.cfra;
G.scene->r.cfra = curframe;
/*just to get the armaturespace mat*/
arm = get_armature(ob);
- for (bone = arm->bonebase.first; bone; bone=bone->next)
- if (bone->name == chanName) break;
- /*XXX does not check for if-not-found*/
+ for( bone = arm->bonebase.first; bone; bone=bone->next )
+ if( bone->name == chanName ) break;
+
+ if( !bone )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bone not found for named channel" );
where_is_object(ob);
world2bonespace(tmat, ob->obmat, bone->arm_mat, startpos);
@@ -2667,11 +2402,7 @@ static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, localQuat[1]);
insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, localQuat[2]);
insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, localQuat[3]);
- /*
- insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, );
- insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y);
- insertmatrixkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z);
- */
+
allspace(REMAKEIPO, 0);
EXPP_allqueue(REDRAWIPO, 0);
EXPP_allqueue(REDRAWVIEW3D, 0);
@@ -2684,63 +2415,58 @@ static PyObject *Object_insertMatrixKey( BPy_Object * self, PyObject * args )
extract_pose_from_action(ob->pose, ob->action, (float)G.scene->r.cfra);
where_is_pose(ob);
- allqueue(REDRAWACTION, 1);
+ EXPP_allqueue(REDRAWACTION, 1);
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-static PyObject *Object_bake_to_action( BPy_Object * self, PyObject * args )
-{
-
- /* for doing the time trick, similar to editaction bake_action_with_client() */
- /*
- int oldframe;
- int curframe;
-
- if( !PyArg_ParseTuple( args, "i", &curframe ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects an int for the frame where to put the new key" ) );
-
- oldframe = G.scene->r.cfra;
- G.scene->r.cfra = curframe;
- */
- bake_all_to_action(); /*ob);*/
-
- /*G.scene->r.cfra = oldframe;*/
+/*
+ * since this doesn't depend on self, but on the active object, it should
+ * be moved to function Object.BakeToAction()
+ */
- return EXPP_incr_ret( Py_None );
+static PyObject *Object_bake_to_action( void )
+{
+ bake_all_to_action();
+ Py_RETURN_NONE;
}
-static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self, PyObject * args ) {
+static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self,
+ PyObject * args )
+{
char *boneName, *constName;
float influence;
-
IpoCurve *icu;
- if( !PyArg_ParseTuple( args, "ssf", &boneName, &constName, &influence ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expects: bonename, constraintname, influenceval" ) );
+ if( !PyArg_ParseTuple( args, "ssf", &boneName, &constName, &influence ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expects bonename, constraintname, influenceval" );
- icu = verify_ipocurve((ID *)self->object, ID_CO, boneName, constName, CO_ENFORCE);
+ icu = verify_ipocurve((ID *)self->object, ID_CO, boneName, constName,
+ CO_ENFORCE);
insert_vert_ipo(icu, (float)CFRA, influence);
+ self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_copyNLA( BPy_Object * self, PyObject * args ) {
BPy_Object *bpy_fromob;
if( !PyArg_ParseTuple( args, "O", &bpy_fromob ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "requires a Blender Object to copy NLA strips from." ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "requires a Blender Object to copy NLA strips from." );
copy_nlastrips(&self->object->nlastrips, &bpy_fromob->object->nlastrips);
+ self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
-static PyObject *Object_convertActionToStrip( BPy_Object * self ) {
- /*when BPY gets a Strip type, make this to return the created strip.*/
- convert_action_to_strip(self->object);
- return EXPP_incr_ret_True (); /*figured that True is closer to a Strip than None..*/
+/*Now that BPY has a Strip type, return the created strip.*/
+static PyObject *Object_convertActionToStrip( BPy_Object * self )
+{
+ bActionStrip *strip = convert_action_to_strip( self->object );
+ return ActionStrip_CreatePyObject( strip );
}
static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
@@ -2757,8 +2483,8 @@ static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
&loc3 );
if( !status )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected list argument of 3 floats" );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list argument of 3 floats" );
self->object->loc[0] = loc1;
self->object->loc[1] = loc2;
@@ -2768,8 +2494,7 @@ static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
self->object->recalc |= OB_RECALC_OB;
DAG_object_flush_update(G.scene, self->object, OB_RECALC_DATA);
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
@@ -2781,11 +2506,11 @@ static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
if (!self->object->data)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "object must be linked to object data (e.g. to a mesh) first" );
+ "object must be linked to object data (e.g. to a mesh) first" );
if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a list of materials (None's also accepted) as argument" );
+ "expected a list (of materials or None) as argument" );
len = PyList_Size(list);
@@ -2795,14 +2520,13 @@ static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
* In other words, list can be '[]' and so len can be zero. */
if (len > 0) {
if( len > MAXMAT )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "list must have from 1 up to 16 materials" );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "list must have from 1 up to 16 materials" );
matlist = EXPP_newMaterialList_fromPyList( list );
- if( !matlist ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "material list must be a list of valid materials!" ) );
- }
+ if( !matlist )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "material list must be a list of valid materials!" );
}
if( self->object->mat )
@@ -2832,25 +2556,23 @@ static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
/* since we have messed with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-static PyObject *Object_setName( BPy_Object * self, PyObject * args )
+static int Object_setName( BPy_Object * self, PyObject * args )
{
char *name;
char buf[21];
- if( !PyArg_ParseTuple( args, "s", &name ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a String as argument" ) );
- }
+ name = PyString_AsString ( args );
+ if( !name )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a string argument" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
-
rename_id( &self->object->id, buf );
- Py_INCREF( Py_None );
- return ( Py_None );
+ return 0;
}
static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
@@ -2868,8 +2590,8 @@ static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
&sizez );
if( !status )
- return EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected list argument of 3 floats" );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list argument of 3 floats" );
self->object->size[0] = sizex;
self->object->size[1] = sizey;
@@ -2878,23 +2600,7 @@ static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
/* since we have messed with object, we need to flag for DAG recalc */
self->object->recalc |= OB_RECALC_OB;
- Py_INCREF( Py_None );
- return ( Py_None );
-}
-
-static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args )
-{
- float newTimeOffset;
-
- if( !PyArg_ParseTuple( args, "f", &newTimeOffset ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a float as argument" ) );
- }
-
- self->object->sf = newTimeOffset;
-
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args )
@@ -2905,14 +2611,14 @@ static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args )
if( !PyArg_ParseTuple( args, "O!|i", &Object_Type, &tracked, &fast ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an object and optionally also an int as arguments." );
+ "expected an object and optionally also an int as arguments." );
ob->track = tracked->object;
if( !fast )
DAG_scene_sort( G.scene );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
@@ -2921,19 +2627,14 @@ static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
ID *id;
ID *oldid;
- if( !PyArg_ParseTuple( args, "O", &object ) ) {
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &object ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an object argument" );
- }
- if( !Object_CheckPyObject( ( PyObject * ) object ) ) {
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "first argument is not of type 'Object'" );
- }
- if( self->object->type != object->object->type ) {
+ if( self->object->type != object->object->type )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"objects are not of same data type" );
- }
+
switch ( self->object->type ) {
case OB_MESH:
case OB_LAMP:
@@ -2956,52 +2657,17 @@ static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
if( oldid->us > 0 ) {
oldid->us--;
} else {
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "old object reference count below 0" ) );
+ return EXPP_ReturnPyObjError ( PyExc_RuntimeError,
+ "old object reference count below 0" );
}
}
- Py_INCREF( Py_None );
- return ( Py_None );
+ Py_RETURN_NONE;
default:
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "type not supported" );
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "object type not supported" );
}
}
-
-
-static PyObject *Object_Select( BPy_Object * self, PyObject * args )
-{
- Base *base;
- int sel;
-
- base = FIRSTBASE;
- if( !PyArg_ParseTuple( args, "i", &sel ) )
- return EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected an integer, 0 or 1" );
-
- while( base ) {
- if( base->object == self->object ) {
- if( sel == 1 ) {
- base->flag |= SELECT;
- self->object->flag = (short)base->flag;
- set_active_base( base );
- } else {
- base->flag &= ~SELECT;
- self->object->flag = (short)base->flag;
- }
- break;
- }
- base = base->next;
- }
-
- countall( );
-
- Py_INCREF( Py_None );
- return ( Py_None );
-}
-
static PyObject *Object_getAllProperties( BPy_Object * self )
{
PyObject *prop_list;
@@ -3021,21 +2687,17 @@ static PyObject *Object_getProperty( BPy_Object * self, PyObject * args )
{
char *prop_name = NULL;
bProperty *prop = NULL;
- PyObject *py_prop = Py_None;
- if( !PyArg_ParseTuple( args, "s", &prop_name ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a string" ) );
- }
+ if( !PyArg_ParseTuple( args, "s", &prop_name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string" );
prop = get_property( self->object, prop_name );
- if( prop ) {
- py_prop = Property_CreatePyObject( prop );
- } else {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "couldn't find the property...." ) );
- }
- return py_prop;
+ if( prop )
+ return Property_CreatePyObject( prop );
+
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't find the property" );
}
static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
@@ -3049,24 +2711,22 @@ static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
int argslen = PyObject_Length( args );
if( argslen == 3 || argslen == 2 ) {
- if( !PyArg_ParseTuple
- ( args, "sO|s", &prop_name, &prop_data, &prop_type ) ) {
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "unable to get string, data, and optional string" ) );
+ if( !PyArg_ParseTuple( args, "sO|s", &prop_name, &prop_data,
+ &prop_type ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expecting string, data, and optional string" );
}
} else if( argslen == 1 ) {
- if( !PyArg_ParseTuple( args, "O!", &property_Type, &py_prop ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "unable to get Property" ) );
- }
- if( py_prop->property != NULL ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "Property is already added to an object" ) );
- }
+ if( !PyArg_ParseTuple( args, "O!", &property_Type, &py_prop ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expecting a Property" );
+
+ if( py_prop->property != NULL )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Property is already added to an object" );
} else {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected 1,2 or 3 arguments" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 1,2 or 3 arguments" );
}
/*parse property type*/
@@ -3083,9 +2743,8 @@ static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
else if( BLI_streq( prop_type, "STRING" ) )
type = PROP_STRING;
else
- return ( EXPP_ReturnPyObjError
- ( PyExc_RuntimeError,
- "BOOL, INT, FLOAT, TIME or STRING expected" ) );
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "BOOL, INT, FLOAT, TIME or STRING expected" );
} else {
/*use the default*/
if( PyInt_Check( prop_data ) )
@@ -3118,16 +2777,20 @@ static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
}
} else {
py_prop->property = prop;
+
+ /* this should never be able to happen is we just assigned a valid
+ * proper to py_prop->property */
+
if( !updateProperyData( py_prop ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "Could not update property data - error" ) );
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Could not update property data" );
}
}
/*add to property listbase for the object*/
BLI_addtail( &self->object->prop, prop );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
@@ -3136,13 +2799,18 @@ static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
BPy_Property *py_prop = NULL;
bProperty *prop = NULL;
- /* we have property and no optional arg*/
- if( !PyArg_ParseTuple( args, "O!", &property_Type, &py_prop ) ) {
- if( !PyArg_ParseTuple( args, "s", &prop_name ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a Property or a string" ) );
- }
+ /* we accept either a property stringname or actual object */
+ if( PyTuple_Size( args ) == 1 ) {
+ PyObject *prop = PyTuple_GET_ITEM( args, 0 );
+ if( Property_CheckPyObject( prop ) )
+ py_prop = (BPy_Property *)prop;
+ else
+ prop_name = PyString_AsString( prop );
}
+ if( !py_prop && !prop_name )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a Property or a string" );
+
/*remove the link, free the data, and update the py struct*/
if( py_prop ) {
BLI_remlink( &self->object->prop, py_prop->property );
@@ -3157,27 +2825,27 @@ static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
free_property( prop );
}
}
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_removeAllProperties( BPy_Object * self )
{
free_properties( &self->object->prop );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
PyObject * args )
{
- PyObject *dest = Py_None;
+ PyObject *dest;
bProperty *prop = NULL;
bProperty *propn = NULL;
- if( !PyArg_ParseTuple( args, "O!", &Object_Type, &dest ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected an Object" ) );
- }
- /*make a copy of all it's properties*/
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &dest ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an Object" );
+
+ /*make a copy of all its properties*/
prop = self->object->prop.first;
while( prop ) {
propn = copy_property( prop );
@@ -3185,165 +2853,33 @@ static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
prop = prop->next;
}
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-/* obj.addScriptLink */
static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args )
{
Object *obj = self->object;
- ScriptLink *slink = NULL;
-
- slink = &( obj )->scriptlink;
-
+ ScriptLink *slink = &obj->scriptlink;
return EXPP_addScriptLink( slink, args, 0 );
}
-/* obj.clearScriptLinks */
static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject * args )
{
Object *obj = self->object;
- ScriptLink *slink = NULL;
-
- slink = &( obj )->scriptlink;
-
+ ScriptLink *slink = &obj->scriptlink;
return EXPP_clearScriptLinks( slink, args );
}
-/* obj.getScriptLinks */
static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * args )
{
Object *obj = self->object;
- ScriptLink *slink = NULL;
- PyObject *ret = NULL;
-
- slink = &( obj )->scriptlink;
-
- ret = EXPP_getScriptLinks( slink, args, 0 );
-
- if( ret )
- return ret;
- else
- return NULL;
-}
-
-static PyObject *Object_getDupliVerts ( BPy_Object * self ) {
- if (self->object->transflag & OB_DUPLIVERTS)
- return EXPP_incr_ret_True ();
- else
- return EXPP_incr_ret_False();
+ ScriptLink *slink = &obj->scriptlink;
+ return EXPP_getScriptLinks( slink, args, 0 );
}
-static PyObject *Object_setDupliVerts ( BPy_Object * self, PyObject * args ) {
- int setting= 0;
- if( !PyArg_ParseTuple( args, "i", &setting ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a int, 0/1 for True/False") );
- }
- if (self && self->object) {
- if (setting)
- self->object->transflag |= OB_DUPLIVERTS;
- else
- self->object->transflag &= ~OB_DUPLIVERTS;
- }
- return Py_None;
-}
-
-static PyObject *Object_getDupliFrames ( BPy_Object * self ) {
- if (self->object->transflag & OB_DUPLIFRAMES)
- return EXPP_incr_ret_True ();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *Object_setDupliFrames ( BPy_Object * self, PyObject * args ) {
- int setting= 0;
- if( !PyArg_ParseTuple( args, "i", &setting ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a int, 0/1 for True/False") );
- }
- if (self && self->object) {
- if (setting)
- self->object->transflag |= OB_DUPLIFRAMES;
- else
- self->object->transflag &= ~OB_DUPLIFRAMES;
- }
- return Py_None;
-}
-
-static PyObject *Object_getDupliGroup ( BPy_Object * self ) {
- if (self->object->transflag & OB_DUPLIGROUP)
- return EXPP_incr_ret_True ();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *Object_setDupliGroup ( BPy_Object * self, PyObject * args ) {
- int setting= 0;
- if( !PyArg_ParseTuple( args, "i", &setting ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a int, 0/1 for True/False") );
- }
- if (self && self->object) {
- if (setting)
- self->object->transflag |= OB_DUPLIGROUP;
- else
- self->object->transflag &= ~OB_DUPLIGROUP;
- }
- return Py_None;
-}
-
-static PyObject *Object_getDupliRot ( BPy_Object * self ) {
- if (self->object->transflag & OB_DUPLIROT)
- return EXPP_incr_ret_True ();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *Object_setDupliRot ( BPy_Object * self, PyObject * args ) {
- int setting= 0;
- if( !PyArg_ParseTuple( args, "i", &setting ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a int, 0/1 for True/False") );
- }
- if (self && self->object) {
- if (setting)
- self->object->transflag |= OB_DUPLIROT;
- else
- self->object->transflag &= ~OB_DUPLIROT;
- }
- return Py_None;
-}
-
-static PyObject *Object_getDupliNoSpeed ( BPy_Object * self ) {
- if (self->object->transflag & OB_DUPLINOSPEED)
- return EXPP_incr_ret_True ();
- else
- return EXPP_incr_ret_False();
-}
-
-static PyObject *Object_setDupliNoSpeed ( BPy_Object * self, PyObject * args ) {
- int setting= 0;
- if( !PyArg_ParseTuple( args, "i", &setting ) ) {
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected a int, 0/1 for True/False") );
- }
- if (self && self->object) {
- if (setting)
- self->object->transflag |= OB_DUPLINOSPEED;
- else
- self->object->transflag &= ~OB_DUPLINOSPEED;
- }
- return Py_None;
-}
-
-static PyObject *Object_getDupliObjects ( BPy_Object * self )
- {
- PyObject *dupli_objects_list= PyList_New( 0 );
+static PyObject *Object_getDupliObjects( BPy_Object * self )
+{
Object *ob= self->object;
- DupliObject *dupob;
- ListBase *duplilist;
- int index;
if(ob->transflag & OB_DUPLI) {
/* before make duplis, update particle for current frame */
@@ -3354,26 +2890,51 @@ static PyObject *Object_getDupliObjects ( BPy_Object * self )
}
}
if(ob->type!=OB_MBALL) {
- duplilist= object_duplilist(G.scene, ob);
- dupli_objects_list= PyList_New( BLI_countlist(duplilist) );
- if( !dupli_objects_list )
+ PyObject *list;
+ DupliObject *dupob;
+ int index;
+ ListBase *duplilist = object_duplilist(G.scene, ob);
+
+ list = PyList_New( BLI_countlist(duplilist) );
+ if( !list )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyList_New() failed" );
-
+
for(dupob= duplilist->first, index=0; dupob; dupob= dupob->next, index++)
- PyList_SetItem( dupli_objects_list, index,
- Py_BuildValue( "(OO)",
- Object_CreatePyObject(dupob->ob),
- newMatrixObject((float*)dupob->mat,4,4,Py_NEW) )
- );
-
+ PyList_SetItem( list, index, Py_BuildValue( "(OO)",
+ Object_CreatePyObject(dupob->ob),
+ newMatrixObject((float*)dupob->mat,4,4,Py_NEW) ) );
+
free_object_duplilist(duplilist);
-
+ return list;
}
}
- return dupli_objects_list;
+ return PyList_New( 0 );
+}
+
+static PyObject *Object_getDupliGroup( BPy_Object * self )
+{
+ Object *ob= self->object;
+
+ if( ob->dup_group )
+ return Group_CreatePyObject( ob->dup_group );
+
+ Py_RETURN_NONE;
}
+static int Object_setDupliGroup( BPy_Object * self, BPy_Group * args )
+{
+ Object *ob= self->object;
+
+ if( (PyObject *)args == Py_None )
+ ob->dup_group = NULL;
+ else if( BPy_Group_Check( args ) )
+ ob->dup_group = args->group;
+ else
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a group or None" );
+ return 0;
+}
static PyObject *Object_getEffects( BPy_Object * self )
{
@@ -3394,10 +2955,25 @@ static PyObject *Object_getEffects( BPy_Object * self )
return effect_list;
}
-static PyObject *Object_insertShapeKey(BPy_Object * self)
+static PyObject *Object_getActionStrips( BPy_Object * self )
+{
+ return ActionStrips_CreatePyObject( self->object );
+}
+
+static PyObject *Object_getConstraints( BPy_Object * self )
+{
+ return ObConstraintSeq_CreatePyObject( self->object );
+}
+
+static PyObject *Object_getModifiers( BPy_Object * self )
+{
+ return ModSeq_CreatePyObject( self->object );
+}
+
+static PyObject *Object_insertShapeKey(BPy_Object * self)
{
insert_shapekey(self->object);
- return Py_None;
+ Py_RETURN_NONE;
}
/* __copy__() */
@@ -3409,13 +2985,8 @@ static PyObject *Object_copy(BPy_Object * self)
/* Create a Python object from it. */
return Object_CreatePyObject( object );
-
-
-
-
}
-
/*****************************************************************************/
/* Function: Object_CreatePyObject */
/* Description: This function will create a new BlenObject from an existing */
@@ -3425,8 +2996,9 @@ PyObject *Object_CreatePyObject( struct Object * obj )
{
BPy_Object *blen_object;
- if( !obj )
- return EXPP_incr_ret( Py_None );
+ if( !obj ) {
+ Py_RETURN_NONE;
+ }
blen_object =
( BPy_Object * ) PyObject_NEW( BPy_Object, &Object_Type );
@@ -3498,1647 +3070,2731 @@ static void Object_dealloc( BPy_Object * obj )
}
/*****************************************************************************/
-/* Function: Object_getAttr */
-/* Description: This is a callback function for the BlenObject type. It is */
-/* the function that retrieves any value from Blender and */
-/* passes it to Python. */
+/* Function: Object_compare */
+/* Description: This is a callback function for the BPy_Object type. It */
+/* compares two Object_Type objects. Only the "==" and "!=" */
+/* comparisons are meaninful. Returns 0 for equality and -1 if */
+/* they don't point to the same Blender Object struct. */
+/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static PyObject *Object_getAttr( BPy_Object * obj, char *name )
-{
- Object *object;
-
- object = obj->object;
- if( StringEqual( name, "LocX" ) )
- return ( PyFloat_FromDouble( object->loc[0] ) );
- if( StringEqual( name, "LocY" ) )
- return ( PyFloat_FromDouble( object->loc[1] ) );
- if( StringEqual( name, "LocZ" ) )
- return ( PyFloat_FromDouble( object->loc[2] ) );
- if( StringEqual( name, "loc" ) )
- return ( Py_BuildValue( "fff", object->loc[0], object->loc[1],
- object->loc[2] ) );
- if( StringEqual( name, "dLocX" ) )
- return ( PyFloat_FromDouble( object->dloc[0] ) );
- if( StringEqual( name, "dLocY" ) )
- return ( PyFloat_FromDouble( object->dloc[1] ) );
- if( StringEqual( name, "dLocZ" ) )
- return ( PyFloat_FromDouble( object->dloc[2] ) );
- if( StringEqual( name, "dloc" ) )
- return ( Py_BuildValue
- ( "fff", object->dloc[0], object->dloc[1],
- object->dloc[2] ) );
- if( StringEqual( name, "RotX" ) )
- return ( PyFloat_FromDouble( object->rot[0] ) );
- if( StringEqual( name, "RotY" ) )
- return ( PyFloat_FromDouble( object->rot[1] ) );
- if( StringEqual( name, "RotZ" ) )
- return ( PyFloat_FromDouble( object->rot[2] ) );
- if( StringEqual( name, "rot" ) )
- return ( Py_BuildValue( "fff", object->rot[0], object->rot[1],
- object->rot[2] ) );
- if( StringEqual( name, "dRotX" ) )
- return ( PyFloat_FromDouble( object->drot[0] ) );
- if( StringEqual( name, "dRotY" ) )
- return ( PyFloat_FromDouble( object->drot[1] ) );
- if( StringEqual( name, "dRotZ" ) )
- return ( PyFloat_FromDouble( object->drot[2] ) );
- if( StringEqual( name, "drot" ) )
- return ( Py_BuildValue
- ( "fff", object->drot[0], object->drot[1],
- object->drot[2] ) );
- if( StringEqual( name, "SizeX" ) )
- return ( PyFloat_FromDouble( object->size[0] ) );
- if( StringEqual( name, "SizeY" ) )
- return ( PyFloat_FromDouble( object->size[1] ) );
- if( StringEqual( name, "SizeZ" ) )
- return ( PyFloat_FromDouble( object->size[2] ) );
- if( StringEqual( name, "size" ) )
- return ( Py_BuildValue
- ( "fff", object->size[0], object->size[1],
- object->size[2] ) );
- if( StringEqual( name, "dSizeX" ) )
- return ( PyFloat_FromDouble( object->dsize[0] ) );
- if( StringEqual( name, "dSizeY" ) )
- return ( PyFloat_FromDouble( object->dsize[1] ) );
- if( StringEqual( name, "dSizeZ" ) )
- return ( PyFloat_FromDouble( object->dsize[2] ) );
- if( StringEqual( name, "dsize" ) )
- return ( Py_BuildValue
- ( "fff", object->dsize[0], object->dsize[1],
- object->dsize[2] ) );
-
- /* accept both Layer (old, for compatibility) and Layers */
- if( strncmp( name, "Layer", 5 ) == 0)
- return ( PyInt_FromLong( object->lay ) );
- /* Layers returns a bitmask, layers returns a list of integers */
- if( StringEqual( name, "layers" ) ) {
- int layers, bit = 0, val = 0;
- PyObject *item = NULL, *laylist = PyList_New( 0 );
-
- if( !laylist )
- return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create pylist!" ) );
-
- layers = object->lay;
-
- while( bit < 20 ) {
- val = 1 << bit;
- if( layers & val ) {
- item = Py_BuildValue( "i", bit + 1 );
- PyList_Append( laylist, item );
- Py_DECREF( item );
- }
- bit++;
- }
- return laylist;
- }
- if( StringEqual( name, "parent" ) ) {
- if( object->parent )
- return Object_CreatePyObject( object->parent );
- else {
- Py_RETURN_NONE;
- }
- }
- if( StringEqual( name, "parentbonename" ) ) {
- if( object->parent && object->parsubstr[0] )
- return ( Py_BuildValue("s", object->parsubstr) );
- else {
- Py_INCREF( Py_None );
- return ( Py_None );
- }
- }
-
- if( StringEqual( name, "track" ) )
- return Object_CreatePyObject( object->track );
- if( StringEqual( name, "type" ) )
- return Object_getType( obj );
- if( StringEqual( name, "data" ) ) {
- PyObject *getdata, *tuple = PyTuple_New(0);
+static int Object_compare( BPy_Object * a, BPy_Object * b )
+{
+ Object *pa = a->object, *pb = b->object;
+ return ( pa == pb ) ? 0 : -1;
+}
- if (!tuple)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create an empty tuple!");
+/*****************************************************************************/
+/* Function: Object_repr */
+/* Description: This is a callback function for the BPy_Object type. It */
+/* builds a meaninful string to represent object objects. */
+/*****************************************************************************/
+static PyObject *Object_repr( BPy_Object * self )
+{
+ return PyString_FromFormat( "[Object \"%s\"]",
+ self->object->id.name + 2 );
+}
- getdata = Object_getData( obj, tuple, NULL );
+/* Particle Deflection functions */
- Py_DECREF(tuple);
- return getdata;
- }
- if( StringEqual( name, "ipo" ) ) {
- if( object->ipo == NULL ) {
- /* There's no ipo linked to the object, return Py_None. */
- Py_INCREF( Py_None );
- return ( Py_None );
- }
- return ( Ipo_CreatePyObject( object->ipo ) );
- }
- if( StringEqual( name, "mat" ) || StringEqual( name, "matrix" ) )
- return ( Object_getMatrix
- ( obj, Py_BuildValue( "(s)", "worldspace" ) ) );
- if( StringEqual( name, "matrixWorld" ) )
- return ( Object_getMatrix
- ( obj, Py_BuildValue( "(s)", "worldspace" ) ) );
- if( StringEqual( name, "matrixLocal" ) )
- return ( Object_getMatrix
- ( obj, Py_BuildValue( "(s)", "localspace" ) ) );
- if( StringEqual( name, "colbits" ) )
- return ( Py_BuildValue( "h", object->colbits ) );
- if( StringEqual( name, "drawType" ) )
- return ( Py_BuildValue( "b", object->dt ) );
- if( StringEqual( name, "drawMode" ) )
- return ( Py_BuildValue( "b", object->dtx ) );
- if( StringEqual( name, "name" ) )
- return ( Py_BuildValue( "s", object->id.name + 2 ) );
- if( StringEqual( name, "sel" ) )
- return ( Object_isSelected( obj ) );
- if( StringEqual( name, "DupSta" ) )
- return PyInt_FromLong( obj->object->dupsta );
- if( StringEqual( name, "DupEnd" ) )
- return PyInt_FromLong( obj->object->dupend );
- if( StringEqual( name, "DupOn" ) )
- return PyInt_FromLong( obj->object->dupon );
- if( StringEqual( name, "DupOff" ) )
- return PyInt_FromLong( obj->object->dupoff );
- 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 );
- }
- if( StringEqual( name, "effects" ) )
- return Object_getEffects( obj );
- if( StringEqual( name, "users" ) )
- return PyInt_FromLong( obj->object->id.us );
- if( StringEqual( name, "protectFlags" ) )
- return PyInt_FromLong( obj->object->protectflag );
- if( StringEqual( name, "DupObjects" ) )
- return Object_getDupliObjects( obj );
- if( StringEqual( name, "DupGroup" ) )
- return Group_CreatePyObject( obj->object->dup_group );
- if( StringEqual( name, "enableDupVerts" ) )
- return Object_getDupliVerts( obj );
- if( StringEqual( name, "enableDupFrames" ) )
- return Object_getDupliFrames( obj );
- if( StringEqual( name, "enableDupGroup" ) )
- return Object_getDupliGroup( obj );
- if( StringEqual( name, "enableDupRot" ) )
- return Object_getDupliRot( obj );
- if( StringEqual( name, "enableDupNoSpeed" ) )
- return Object_getDupliNoSpeed( obj );
- if( StringEqual( name, "drawSize" ) )
- return ( PyFloat_FromDouble( object->empty_drawsize ) );
- if( StringEqual( name, "modifiers" ) )
- return ModSeq_CreatePyObject( object );
- if( StringEqual( name, "constraints" ) )
- return ObConstraintSeq_CreatePyObject( object );
- if( StringEqual( name, "actionStrips" ) )
- return ActionStrips_CreatePyObject( object );
- if( StringEqual( name, "rbMass" ) )
- return PyFloat_FromDouble( ( double ) object->mass );
- if( StringEqual( name, "rbFlags" ) )
- return PyInt_FromLong( ( long ) object->gameflag );
- if( StringEqual( name, "rbShapeBoundType" ) )
- return PyInt_FromLong( ( long ) object->boundtype );
- if( StringEqual( name, "rbHalfExtents" ) )
- {
- float center[3];
- float extents[3];
- get_local_bounds(object,center,extents);
- return (Py_BuildValue ("fff", extents[0],extents[1],extents[2]));
- }
- if( StringEqual( name, "rbRadius" ) )
- {
- //for historical reasons, inertia is used, instead of radius...
- return PyFloat_FromDouble( ( double ) object->inertia);
- }
-
+static PyObject *Object_getPIDeflection( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- /* not an attribute, search the methods table */
- return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
+ return PyBool_FromLong( ( long ) self->object->pd->deflect );
}
-/*****************************************************************************/
-/* Function: Object_setAttr */
-/* Description: This is a callback function for the BlenObject type. It is */
-/* the function that retrieves any value from Python and sets */
-/* it accordingly in Blender. */
-/*****************************************************************************/
-static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value )
+static int Object_setPIDeflection( BPy_Object * self, PyObject * args )
{
- PyObject *valtuple, *result=NULL;
- struct Object *object;
-
- object = obj->object;
-
- /* Handle all properties which are Read Only */
- if( StringEqual( name, "parent" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Setting the parent is not allowed." );
- if( StringEqual( name, "data" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Setting the data is not allowed." );
- if( StringEqual( name, "ipo" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Setting the ipo is not allowed." );
- if( StringEqual( name, "mat" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Not allowed. Please use .setMatrix(matrix)" );
- if( StringEqual( name, "matrix" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "Not allowed. Please use .setMatrix(matrix)" );
-
- /* FIRST, do attributes that are directly changed */
-
- /*
- All the methods below modify the object so we set the recalc
- flag here.
- When we move to tp_getset, the individual setters will need
- to set the flag.
- */
- object->recalc |= OB_RECALC_OB;
-
- if( StringEqual( name, "LocX" ) )
- return ( !PyArg_Parse( value, "f", &( object->loc[0] ) ) );
- if( StringEqual( name, "LocY" ) )
- return ( !PyArg_Parse( value, "f", &( object->loc[1] ) ) );
- if( StringEqual( name, "LocZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->loc[2] ) ) );
- if( StringEqual( name, "dLocX" ) )
- return ( !PyArg_Parse( value, "f", &( object->dloc[0] ) ) );
- if( StringEqual( name, "dLocY" ) )
- return ( !PyArg_Parse( value, "f", &( object->dloc[1] ) ) );
- if( StringEqual( name, "dLocZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->dloc[2] ) ) );
- if( StringEqual( name, "RotX" ) )
- return ( !PyArg_Parse( value, "f", &( object->rot[0] ) ) );
- if( StringEqual( name, "RotY" ) )
- return ( !PyArg_Parse( value, "f", &( object->rot[1] ) ) );
- if( StringEqual( name, "RotZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->rot[2] ) ) );
- if( StringEqual( name, "dRotX" ) )
- return ( !PyArg_Parse( value, "f", &( object->drot[0] ) ) );
- if( StringEqual( name, "dRotY" ) )
- return ( !PyArg_Parse( value, "f", &( object->drot[1] ) ) );
- if( StringEqual( name, "dRotZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->drot[2] ) ) );
- if( StringEqual( name, "drot" ) )
- return ( !PyArg_ParseTuple( value, "fff", &( object->drot[0] ),
- &( object->drot[1] ),
- &( object->drot[2] ) ) );
- if( StringEqual( name, "SizeX" ) )
- return ( !PyArg_Parse( value, "f", &( object->size[0] ) ) );
- if( StringEqual( name, "SizeY" ) )
- return ( !PyArg_Parse( value, "f", &( object->size[1] ) ) );
- if( StringEqual( name, "SizeZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->size[2] ) ) );
- if( StringEqual( name, "size" ) )
- return ( !PyArg_ParseTuple( value, "fff", &( object->size[0] ),
- &( object->size[1] ),
- &( object->size[2] ) ) );
- if( StringEqual( name, "dSizeX" ) )
- return ( !PyArg_Parse( value, "f", &( object->dsize[0] ) ) );
- if( StringEqual( name, "dSizeY" ) )
- return ( !PyArg_Parse( value, "f", &( object->dsize[1] ) ) );
- if( StringEqual( name, "dSizeZ" ) )
- return ( !PyArg_Parse( value, "f", &( object->dsize[2] ) ) );
- if( StringEqual( name, "dsize" ) )
- return ( !PyArg_ParseTuple
- ( value, "fff", &( object->dsize[0] ),
- &( object->dsize[1] ), &( object->dsize[2] ) ) );
-
- if( StringEqual( name, "DupSta" ) )
- return ( !PyArg_Parse( value, "h", &( object->dupsta ) ) );
+ int value;
- if( StringEqual( name, "DupEnd" ) )
- return ( !PyArg_Parse( value, "h", &( object->dupend ) ) );
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- if( StringEqual( name, "DupOn" ) )
- return ( !PyArg_Parse( value, "h", &( object->dupon ) ) );
+ value = PyObject_IsTrue( args );
+ if( value == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
- if( StringEqual( name, "DupOff" ) )
- return ( !PyArg_Parse( value, "h", &( object->dupoff ) ) );
- if( StringEqual( name, "colbits" ) )
- return ( !PyArg_Parse( value, "h", &( object->colbits ) ) );
+ self->object->pd->deflect = (short)value;
+ self->object->recalc |= OB_RECALC_OB;
- /* accept both Layer (for compatibility) and Layers */
- if( strncmp( name, "Layer", 5 ) == 0 ) {
- /* usage note: caller of this func needs to do a
- Blender.Redraw(-1) to update and redraw the interface */
+ return 0;
+}
- Base *base;
- int newLayer;
- int local;
+static PyObject *Object_getPIType( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- if( ! PyArg_Parse( value, "i", &newLayer ) ) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "expected int as bitmask" );
- }
+ return PyInt_FromLong( ( long )self->object->pd->forcefield );
+}
- /* uppper 2 nibbles are for local view */
- newLayer &= 0x00FFFFFF;
- if( newLayer == 0 ) {
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "bitmask must have from 1 up to 20 bits set");
- }
+static int Object_setPIType( BPy_Object * self, PyObject * value )
+{
+ int status;
+ int oldforcefield;
- /* update any bases pointing to our object */
- base = FIRSTBASE; /* first base in current scene */
- while( base ){
- if( base->object == obj->object ) {
- local = base->lay &= 0xFF000000;
- base->lay = local | newLayer;
- object->lay = base->lay;
- }
- base = base->next;
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+
+ oldforcefield = self->object->pd->forcefield;
+ status = EXPP_setIValueRange( value, &self->object->pd->forcefield,
+ PFIELD_FORCE, PFIELD_GUIDE, 'h' );
+
+ /*
+ * if value was set successfully but is PFIELD_MAGNET, restore the old
+ * value and throw exception
+ */
+ if( !status ) {
+ if ( self->object->pd->forcefield == PFIELD_MAGNET ) {
+ self->object->pd->forcefield = oldforcefield;
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "PFIELD_MAGNET not supported" );
}
- countall( );
-
- return ( 0 );
+ self->object->recalc |= OB_RECALC_OB;
}
- if( StringEqual( name, "layers" ) ) {
- /* usage note: caller of this func needs to do a
- Blender.Redraw(-1) to update and redraw the interface */
+ return status;
+}
- Base *base;
- int layers = 0, len_list = 0;
- int local, i, val;
- PyObject *list = NULL, *item = NULL;
+static PyObject *Object_getPIUseMaxDist( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- if( !PyArg_Parse( value, "O!", &PyList_Type, &list ) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a list of integers" );
+ return PyBool_FromLong( ( long )self->object->pd->flag );
+}
- len_list = PyList_Size(list);
+static int Object_setPIUseMaxDist( BPy_Object * self, PyObject * args )
+{
+ int value;
- if (len_list == 0)
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "list can't be empty, at least one layer must be set" );
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- for( i = 0; i < len_list; i++ ) {
- item = PyList_GetItem( list, i );
- if( !PyInt_Check( item ) )
- return EXPP_ReturnIntError
- ( PyExc_AttributeError,
- "list must contain only integer numbers" );
+ value = PyObject_IsTrue( args );
+ if( value == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
- val = ( int ) PyInt_AsLong( item );
- if( val < 1 || val > 20 )
- return EXPP_ReturnIntError
- ( PyExc_AttributeError,
- "layer values must be in the range [1, 20]" );
+ self->object->pd->flag = (short)value;
+ self->object->recalc |= OB_RECALC_OB;
- layers |= 1 << ( val - 1 );
- }
+ return 0;
+}
- /* update any bases pointing to our object */
- base = FIRSTBASE; /* first base in current scene */
- while( base ){
- if( base->object == obj->object ) {
- local = base->lay &= 0xFF000000;
- base->lay = local | layers;
- object->lay = base->lay;
- }
- base = base->next;
- }
- countall();
+/* RIGIDBODY FUNCTIONS */
- 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;
- }
- if( StringEqual( name, "protectFlags" ) ) {
- int flag=0;
- if( !PyArg_Parse( value, "i", &flag ) )
- return EXPP_ReturnIntError ( PyExc_AttributeError,
- "expected an integer" );
+static PyObject *Object_getRBMass( BPy_Object * self )
+{
+ return PyFloat_FromDouble( (double)self->object->mass );
+}
- flag &= OB_LOCK_LOCX | OB_LOCK_LOCY | OB_LOCK_LOCZ |
- OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ |
- OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ;
+static int Object_setRBMass( BPy_Object * self, PyObject * args )
+{
+ float value;
+ PyObject* flt = PyNumber_Float( args );
- object->protectflag = (short)flag;
- return 0;
- }
- if( StringEqual( name, "DupGroup" ) ) {
- PyObject *pyob=NULL;
- BPy_Group *pygrp=NULL;
- if( !PyArg_Parse( value, "O", &pyob) )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a group or None" );
-
- if ( PyObject_TypeCheck(pyob, &Group_Type) ) {
- pygrp= (BPy_Group *)pyob;
- object->dup_group= pygrp->group;
- } else if (pyob==Py_None) {
- object->dup_group= NULL;
- } else {
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected a group or None" );
- }
- return 0;
- }
- if( StringEqual( name, "rbMass" ) )
- return Object_setRBMass( obj, value );
- if( StringEqual( name, "rbFlags" ) )
- return Object_setRBFlags( obj, value );
- if( StringEqual( name, "rbShapeBoundType" ) )
- return Object_setRBShapeBoundType( obj, value );
- if( StringEqual( name, "rbRadius" ) )
- return Object_setRBRadius( obj, value );
-
- /* SECOND, handle all the attributes that passes the value as a tuple to another function */
-
- /* Put the value(s) in a tuple. For some variables, we want to */
- /* pass the values to a function, and these functions only accept */
- /* PyTuples. */
- valtuple = Py_BuildValue( "(O)", value );
- if( !valtuple ) {
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "Object_setAttr: couldn't create PyTuple" );
- }
- /* Call the setFunctions to handle it */
- if( StringEqual( name, "loc" ) )
- result = Object_setLocation( obj, valtuple );
- else if( StringEqual( name, "dloc" ) )
- result = Object_setDeltaLocation( obj, valtuple );
- else if( StringEqual( name, "rot" ) )
- result = Object_setEuler( obj, valtuple );
- else if( StringEqual( name, "track" ) )
- result = Object_makeTrack( obj, valtuple );
- else if( StringEqual( name, "drawType" ) )
- result = Object_setDrawType( obj, valtuple );
- else if( StringEqual( name, "drawMode" ) )
- result = Object_setDrawMode( obj, valtuple );
- else if( StringEqual( name, "name" ) )
- result = Object_setName( obj, valtuple );
- else if( StringEqual( name, "sel" ) )
- result = Object_Select( obj, valtuple );
- else if( StringEqual( name, "effects" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "effects is not writable" );
-
- else if( StringEqual( name, "enableDupVerts" ) )
- result = Object_setDupliVerts( obj, valtuple );
- else if( StringEqual( name, "enableDupFrames" ) )
- result = Object_setDupliFrames( obj, valtuple );
- else if( StringEqual( name, "enableDupGroup" ) )
- result = Object_setDupliGroup( obj, valtuple );
- else if( StringEqual( name, "enableDupRot" ) )
- result = Object_setDupliRot( obj, valtuple );
- else if( StringEqual( name, "enableDupNoSpeed" ) )
- result = Object_setDupliNoSpeed( obj, valtuple );
- else if( StringEqual( name, "DupObjects" ) )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "DupObjects is not writable" );
- else if( StringEqual( name, "drawSize" ) )
- return ( !PyArg_Parse( value, "f", &( object->empty_drawsize ) ) );
- else { /* if it turns out here, it's not an attribute*/
- Py_DECREF(valtuple);
- return EXPP_ReturnIntError( PyExc_KeyError, "attribute not found" );
- }
+ if( !flt )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected float argument" );
+ value = PyFloat_AS_DOUBLE( flt );
+ Py_DECREF( flt );
-/* valtuple won't be returned to the caller, so we need to DECREF it */
- Py_DECREF(valtuple);
+ if( value < 0.0f )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "acceptable values are non-negative, 0.0 or more" );
- if( result != Py_None )
- return -1; /* error return */
+ self->object->mass = value;
+ self->object->recalc |= OB_RECALC_OB;
-/* Py_None was incref'ed by the called Scene_set* function. We probably
- * don't need to decref Py_None (!), but since Python/C API manual tells us
- * to treat it like any other PyObject regarding ref counting ... */
- Py_DECREF( Py_None );
- return 0; /* normal return */
+ return 0;
}
-/*****************************************************************************/
-/* Function: Object_compare */
-/* Description: This is a callback function for the BPy_Object type. It */
-/* compares two Object_Type objects. Only the "==" and "!=" */
-/* comparisons are meaninful. Returns 0 for equality and -1 if */
-/* they don't point to the same Blender Object struct. */
-/* In Python it becomes 1 if they are equal, 0 otherwise. */
-/*****************************************************************************/
-static int Object_compare( BPy_Object * a, BPy_Object * b )
+/* this is too low level, possible to add helper methods */
+
+#define GAMEFLAG_MASK ( OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
+ OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | \
+ OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
+ OB_MAINACTOR )
+
+static PyObject *Object_getRBFlags( BPy_Object * self )
{
- Object *pa = a->object, *pb = b->object;
- return ( pa == pb ) ? 0 : -1;
+ return PyInt_FromLong( (long)( self->object->gameflag & GAMEFLAG_MASK ) );
}
-/*****************************************************************************/
-/* Function: Object_repr */
-/* Description: This is a callback function for the BPy_Object type. It */
-/* builds a meaninful string to represent object objects. */
-/*****************************************************************************/
-static PyObject *Object_repr( BPy_Object * self )
+static int Object_setRBFlags( BPy_Object * self, PyObject * args )
{
- return PyString_FromFormat( "[Object \"%s\"]",
- self->object->id.name + 2 );
+ PyObject* integer = PyNumber_Int( args );
+ int value;
+
+ if( !integer )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected integer argument" );
+
+ value = ( int )PyInt_AS_LONG( integer );
+ if( value & ~GAMEFLAG_MASK )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "undefined bit(s) set in bitfield" );
+
+ self->object->gameflag = value;
+ self->object->recalc |= OB_RECALC_OB;
+
+ return 0;
}
+static PyObject *Object_getRBShapeBoundType( BPy_Object * self )
+{
+ return PyInt_FromLong( (long)self->object->boundtype );
+}
-PyObject *Object_getPIStrength( BPy_Object * self )
+static int Object_setRBShapeBoundType( BPy_Object * self, PyObject * args )
{
- PyObject *attr;
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setIValueRange( args, &self->object->boundtype,
+ 0, OB_BOUND_POLYH, 'h' );
+}
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->pd->f_strength );
+/* SOFTBODY FUNCTIONS */
- if( attr )
- return attr;
+PyObject *Object_isSB(BPy_Object *self)
+{
+ if( self->object->soft )
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->f_strength attribute" ) );
+static PyObject *Object_getSBUseGoal( BPy_Object * self )
+{
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
+
+ if( self->object->softflag & OB_SB_GOAL )
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
}
-PyObject *Object_setPIStrength( BPy_Object * self, PyObject * args )
+
+static int Object_setSBUseGoal( BPy_Object * self, PyObject * args )
{
- float value;
+ int setting = PyObject_IsTrue( args );
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ if( setting == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
- if(value > 1000.0f || value < -1000.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1000.0 and -1000.0" ) );
- self->object->pd->f_strength = value;
+ if( setting )
+ self->object->softflag |= OB_SB_GOAL;
+ else
+ self->object->softflag &= ~OB_SB_GOAL;
- return EXPP_incr_ret( Py_None );
+ self->object->recalc |= OB_RECALC_OB;
+ return 0;
}
-PyObject *Object_getPIFalloff( BPy_Object * self )
+static PyObject *Object_getSBUseEdges( BPy_Object * self )
{
- PyObject *attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ if( self->object->softflag & OB_SB_EDGES )
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
+static int Object_setSBUseEdges( BPy_Object * self, PyObject * args )
+{
+ int setting = PyObject_IsTrue( args );
+
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
+
+ if( setting == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
+
+ if( setting )
+ self->object->softflag |= OB_SB_EDGES;
+ else
+ self->object->softflag &= ~OB_SB_EDGES;
+
+ self->object->recalc |= OB_RECALC_OB;
+ return 0;
+}
+
+static PyObject *Object_getSBStiffQuads( BPy_Object * self )
+{
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- attr = PyFloat_FromDouble( ( double ) self->object->pd->f_power );
+ if( self->object->softflag & OB_SB_QUADS )
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
- if( attr )
- return attr;
+static int Object_setSBStiffQuads( BPy_Object * self, PyObject * args )
+{
+ int setting = PyObject_IsTrue( args );
+
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->f_power attribute" ) );
+ if( setting == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
+
+ if( setting )
+ self->object->softflag |= OB_SB_QUADS;
+ else
+ self->object->softflag &= ~OB_SB_QUADS;
+
+ self->object->recalc |= OB_RECALC_OB;
+ return 0;
}
-PyObject *Object_setPIFalloff( BPy_Object * self, PyObject * args )
+
+static int setupSB( Object* ob )
{
- float value;
+ ob->soft= sbNew();
+ ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ if( !ob->soft )
+ return 0;
+ /* all this is initialized in sbNew() */
+#if 0
+ ob->soft->mediafrict = 0.5f;
+ ob->soft->nodemass = 1.0f;
+ ob->soft->grav = 0.0f;
+ ob->soft->rklimit = 0.1f;
+
+ ob->soft->goalspring = 0.5f;
+ ob->soft->goalfrict = 0.0f;
+ ob->soft->mingoal = 0.0f;
+ ob->soft->maxgoal = 1.0f;
+ ob->soft->defgoal = 0.7f;
+
+ ob->soft->inspring = 0.5f;
+ ob->soft->infrict = 0.5f;
+#endif
+ return 1;
+}
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+static int setupPI( Object* ob )
+{
+ if( ob->pd==NULL ) {
+ ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
+ /* and if needed, init here */
+ }
- if(value > 10.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 10.0 and 0.0" ) );
- self->object->pd->f_power = value;
+ if( !ob->pd )
+ return 0;
- return EXPP_incr_ret( Py_None );
+ ob->pd->deflect =0;
+ ob->pd->forcefield =0;
+ ob->pd->flag =0;
+ ob->pd->pdef_damp =0;
+ ob->pd->pdef_rdamp =0;
+ ob->pd->pdef_perm =0;
+ ob->pd->f_strength =0;
+ ob->pd->f_power =0;
+ ob->pd->maxdist =0;
+ return 1;
}
-PyObject *Object_getPIMaxDist( BPy_Object * self )
+/*
+ * scan list of Objects looking for matching obdata.
+ * if found, set OB_RECALC_DATA flag.
+ * call this from a bpy type update() method.
+ */
+
+void Object_updateDag( void *data )
{
- PyObject *attr;
+ Object *ob;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->pd->maxdist );
+ if( !data )
+ return;
+
+ for( ob = G.main->object.first; ob; ob= ob->id.next ){
+ if( ob->data == data ) {
+ ob->recalc |= OB_RECALC_DATA;
+ }
+ }
+}
+
+/*
+ * utilities routines for handling generic getters and setters
+ */
+
+/*
+ * get integer attributes
+ */
+static PyObject *getIntAttr( BPy_Object *self, void *type )
+{
+ PyObject *attr = NULL;
+ int param;
+ struct Object *object = self->object;
+
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_LAYERMASK:
+ param = object->lay;
+ break;
+ case EXPP_OBJ_ATTR_COLBITS:
+ param = object->colbits;
+ if( param < 0 ) param += 65536;
+ break;
+ case EXPP_OBJ_ATTR_DRAWMODE:
+ param = object->dtx;
+ break;
+ case EXPP_OBJ_ATTR_DRAWTYPE:
+ param = object->dt;
+ break;
+ case EXPP_OBJ_ATTR_DUPON:
+ param = object->dupon;
+ break;
+ case EXPP_OBJ_ATTR_DUPOFF:
+ param = object->dupoff;
+ break;
+ case EXPP_OBJ_ATTR_DUPSTA:
+ param = object->dupsta;
+ break;
+ case EXPP_OBJ_ATTR_DUPEND:
+ param = object->dupend;
+ break;
+ default:
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "undefined type in getIntAttr" );
+ }
+
+ attr = PyInt_FromLong( param );
+
if( attr )
return attr;
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->f_maxdist attribute" ) );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "PyInt_FromLong() failed!" );
}
-PyObject *Object_setPIMaxDist( BPy_Object * self, PyObject * args )
+
+/*
+ * set integer attributes which require clamping
+ */
+
+static int setIntAttrClamp( BPy_Object *self, PyObject *value, void *type )
{
- float value;
+ void *param;
+ struct Object *object = self->object;
+ int min, max, size;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_DUPON:
+ min = 1;
+ max = 1500;
+ size = 'H'; /* in case max is later made > 32767 */
+ param = (void *)&object->dupon;
+ break;
+ case EXPP_OBJ_ATTR_DUPOFF:
+ min = 0;
+ max = 1500;
+ size = 'H'; /* in case max is later made > 32767 */
+ param = (void *)&object->dupoff;
+ break;
+ case EXPP_OBJ_ATTR_DUPSTA:
+ min = 1;
+ max = 32767;
+ size = 'H'; /* in case max is later made > 32767 */
+ param = (void *)&object->dupsta;
+ break;
+ case EXPP_OBJ_ATTR_DUPEND:
+ min = 1;
+ max = 32767;
+ size = 'H'; /* in case max is later made > 32767 */
+ param = (void *)&object->dupend;
+ break;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "undefined type in setIntAttrClamp");
+ }
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setIValueClamped( value, param, min, max, size );
+}
- if(value > 1000.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1000.0 and 0.0" ) );
- self->object->pd->maxdist = value;
+/*
+ * set integer attributes which require range checking
+ */
+
+static int setIntAttrRange( BPy_Object *self, PyObject *value, void *type )
+{
+ void *param;
+ struct Object *object = self->object;
+ int min, max, size;
+
+ if( !PyInt_CheckExact( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected integer argument" );
+
+ /* these parameters require clamping */
+
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_COLBITS:
+ min = 0;
+ max = 0xffff;
+ size = 'H';
+ param = (void *)&object->colbits;
+ break;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "undefined type in setIntAttrRange" );
+ }
- return EXPP_incr_ret( Py_None );
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setIValueRange( value, param, min, max, size );
}
-PyObject *Object_getPIUseMaxDist( BPy_Object * self )
-{
- PyObject *attr;
-
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyInt_FromLong( ( long ) self->object->pd->flag );
+/*
+ * get floating point attributes
+ */
- if( attr )
- return attr;
+static PyObject *getFloatAttr( BPy_Object *self, void *type )
+{
+ float param;
+ struct Object *object = self->object;
+
+ if( (int)type >= EXPP_OBJ_ATTR_PI_SURFACEDAMP &&
+ (int)type <= EXPP_OBJ_ATTR_PI_SBOFACETHICK ) {
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+ }
+ else if( (int)type >= EXPP_OBJ_ATTR_SB_NODEMASS &&
+ (int)type <= EXPP_OBJ_ATTR_SB_INFRICT ) {
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
+ }
+
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_LOC_X:
+ param = object->loc[0];
+ break;
+ case EXPP_OBJ_ATTR_LOC_Y:
+ param = object->loc[1];
+ break;
+ case EXPP_OBJ_ATTR_LOC_Z:
+ param = object->loc[2];
+ break;
+ case EXPP_OBJ_ATTR_DLOC_X:
+ param = object->dloc[0];
+ break;
+ case EXPP_OBJ_ATTR_DLOC_Y:
+ param = object->dloc[1];
+ break;
+ case EXPP_OBJ_ATTR_DLOC_Z:
+ param = object->dloc[2];
+ break;
+ case EXPP_OBJ_ATTR_ROT_X:
+ param = object->rot[0];
+ break;
+ case EXPP_OBJ_ATTR_ROT_Y:
+ param = object->rot[1];
+ break;
+ case EXPP_OBJ_ATTR_ROT_Z:
+ param = object->rot[2];
+ break;
+ case EXPP_OBJ_ATTR_DROT_X:
+ param = object->drot[0];
+ break;
+ case EXPP_OBJ_ATTR_DROT_Y:
+ param = object->drot[1];
+ break;
+ case EXPP_OBJ_ATTR_DROT_Z:
+ param = object->drot[2];
+ break;
+ case EXPP_OBJ_ATTR_SIZE_X:
+ param = object->size[0];
+ break;
+ case EXPP_OBJ_ATTR_SIZE_Y:
+ param = object->size[1];
+ break;
+ case EXPP_OBJ_ATTR_SIZE_Z:
+ param = object->size[2];
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_X:
+ param = object->dsize[0];
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_Y:
+ param = object->dsize[1];
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_Z:
+ param = object->dsize[2];
+ break;
+ case EXPP_OBJ_ATTR_TIMEOFFSET:
+ param = object->sf;
+ break;
+ case EXPP_OBJ_ATTR_DRAWSIZE:
+ param = object->empty_drawsize;
+ break;
+ case EXPP_OBJ_ATTR_PI_SURFACEDAMP:
+ param = object->pd->pdef_perm;
+ break;
+ case EXPP_OBJ_ATTR_PI_RANDOMDAMP:
+ param = object->pd->pdef_rdamp;
+ break;
+ case EXPP_OBJ_ATTR_PI_PERM:
+ param = object->pd->pdef_perm;
+ break;
+ case EXPP_OBJ_ATTR_PI_STRENGTH:
+ param = object->pd->f_strength;
+ break;
+ case EXPP_OBJ_ATTR_PI_FALLOFF:
+ param = object->pd->f_power;
+ break;
+ case EXPP_OBJ_ATTR_PI_MAXDIST:
+ param = object->pd->maxdist;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBDAMP:
+ param = object->pd->pdef_sbdamp;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBIFACETHICK:
+ param = object->pd->pdef_sbift;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBOFACETHICK:
+ param = object->pd->pdef_sboft;
+ break;
+ case EXPP_OBJ_ATTR_SB_NODEMASS:
+ param = self->object->soft->nodemass;
+ break;
+ case EXPP_OBJ_ATTR_SB_GRAV:
+ param = self->object->soft->grav;
+ break;
+ case EXPP_OBJ_ATTR_SB_MEDIAFRICT:
+ param = self->object->soft->mediafrict;
+ break;
+ case EXPP_OBJ_ATTR_SB_RKLIMIT:
+ param = self->object->soft->rklimit;
+ break;
+ case EXPP_OBJ_ATTR_SB_PHYSICSSPEED:
+ param = self->object->soft->physics_speed;
+ break;
+ case EXPP_OBJ_ATTR_SB_GOALSPRING:
+ param = self->object->soft->goalspring;
+ break;
+ case EXPP_OBJ_ATTR_SB_GOALFRICT:
+ param = self->object->soft->goalfrict;
+ break;
+ case EXPP_OBJ_ATTR_SB_MINGOAL:
+ param = self->object->soft->mingoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_MAXGOAL:
+ param = self->object->soft->maxgoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_DEFGOAL:
+ param = self->object->soft->defgoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_INSPRING:
+ param = self->object->soft->inspring;
+ break;
+ case EXPP_OBJ_ATTR_SB_INFRICT:
+ param = self->object->soft->infrict;
+ break;
+ default:
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "undefined type in getFloatAttr" );
+ }
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->flag attribute" ) );
+ return PyFloat_FromDouble( param );
}
-PyObject *Object_setPIUseMaxDist( BPy_Object * self, PyObject * args )
+/*
+ * set floating point attributes which require clamping
+ */
+
+static int setFloatAttrClamp( BPy_Object *self, PyObject *value, void *type )
{
- int value;
+ float *param;
+ struct Object *object = self->object;
+ float min, max;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
+ if( (int)type >= EXPP_OBJ_ATTR_PI_SURFACEDAMP &&
+ (int)type <= EXPP_OBJ_ATTR_PI_SBOFACETHICK ) {
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+ }
+ else if( (int)type >= EXPP_OBJ_ATTR_SB_NODEMASS &&
+ (int)type <= EXPP_OBJ_ATTR_SB_INFRICT ) {
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
}
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_DRAWSIZE:
+ min = EXPP_OBJECT_DRAWSIZEMIN;
+ max = EXPP_OBJECT_DRAWSIZEMAX;
+ param = &object->empty_drawsize;
+ break;
+ case EXPP_OBJ_ATTR_TIMEOFFSET:
+ min = -MAXFRAMEF;
+ max = MAXFRAMEF;
+ param = &object->sf;
+ break;
+ case EXPP_OBJ_ATTR_PI_SURFACEDAMP:
+ min = EXPP_OBJECT_PIDAMP_MIN;
+ max = EXPP_OBJECT_PIDAMP_MAX;
+ param = &object->pd->pdef_perm;
+ break;
+ case EXPP_OBJ_ATTR_PI_RANDOMDAMP:
+ min = EXPP_OBJECT_PIRDAMP_MIN;
+ max = EXPP_OBJECT_PIRDAMP_MAX;
+ param = &object->pd->pdef_rdamp;
+ break;
+ case EXPP_OBJ_ATTR_PI_PERM:
+ min = EXPP_OBJECT_PIPERM_MIN;
+ max = EXPP_OBJECT_PIPERM_MAX;
+ param = &object->pd->pdef_perm;
+ break;
+ case EXPP_OBJ_ATTR_PI_STRENGTH:
+ min = EXPP_OBJECT_PISTRENGTH_MIN;
+ max = EXPP_OBJECT_PISTRENGTH_MAX;
+ param = &object->pd->f_strength;
+ break;
+ case EXPP_OBJ_ATTR_PI_FALLOFF:
+ min = EXPP_OBJECT_PIPOWER_MIN;
+ max = EXPP_OBJECT_PIPOWER_MAX;
+ param = &object->pd->f_power;
+ break;
+ case EXPP_OBJ_ATTR_PI_MAXDIST:
+ min = EXPP_OBJECT_PIMAXDIST_MIN;
+ max = EXPP_OBJECT_PIMAXDIST_MAX;
+ param = &object->pd->maxdist;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBDAMP:
+ min = EXPP_OBJECT_PISBDAMP_MIN;
+ max = EXPP_OBJECT_PISBDAMP_MAX;
+ param = &object->pd->pdef_sbdamp;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBIFACETHICK:
+ min = EXPP_OBJECT_PISBIFTMIN;
+ max = EXPP_OBJECT_PISBIFTMAX;
+ param = &object->pd->pdef_sbift;
+ break;
+ case EXPP_OBJ_ATTR_PI_SBOFACETHICK:
+ min = EXPP_OBJECT_PISBOFTMIN;
+ max = EXPP_OBJECT_PISBOFTMAX;
+ param = &object->pd->pdef_sboft;
+ break;
+ case EXPP_OBJ_ATTR_SB_NODEMASS:
+ min = EXPP_OBJECT_SBNODEMASSMIN;
+ max = EXPP_OBJECT_SBNODEMASSMAX;
+ param = &self->object->soft->nodemass;
+ break;
+ case EXPP_OBJ_ATTR_SB_GRAV:
+ min = EXPP_OBJECT_SBGRAVMIN;
+ max = EXPP_OBJECT_SBGRAVMAX;
+ param = &self->object->soft->grav;
+ break;
+ case EXPP_OBJ_ATTR_SB_MEDIAFRICT:
+ min = EXPP_OBJECT_SBMEDIAFRICTMIN;
+ max = EXPP_OBJECT_SBMEDIAFRICTMAX;
+ param = &self->object->soft->mediafrict;
+ break;
+ case EXPP_OBJ_ATTR_SB_RKLIMIT:
+ min = EXPP_OBJECT_SBRKLIMITMIN;
+ max = EXPP_OBJECT_SBRKLIMITMAX;
+ param = &self->object->soft->rklimit;
+ break;
+ case EXPP_OBJ_ATTR_SB_PHYSICSSPEED:
+ min = EXPP_OBJECT_SBPHYSICSSPEEDMIN;
+ max = EXPP_OBJECT_SBPHYSICSSPEEDMAX;
+ param = &self->object->soft->physics_speed;
+ break;
+ case EXPP_OBJ_ATTR_SB_GOALSPRING:
+ min = EXPP_OBJECT_SBGOALSPRINGMIN;
+ max = EXPP_OBJECT_SBGOALSPRINGMAX;
+ param = &self->object->soft->goalspring;
+ break;
+ case EXPP_OBJ_ATTR_SB_GOALFRICT:
+ min = EXPP_OBJECT_SBGOALFRICTMIN;
+ max = EXPP_OBJECT_SBGOALFRICTMAX;
+ param = &self->object->soft->goalfrict;
+ break;
+ case EXPP_OBJ_ATTR_SB_MINGOAL:
+ min = EXPP_OBJECT_SBMINGOALMIN;
+ max = EXPP_OBJECT_SBMINGOALMAX;
+ param = &self->object->soft->mingoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_MAXGOAL:
+ min = EXPP_OBJECT_SBMAXGOALMIN;
+ max = EXPP_OBJECT_SBMAXGOALMAX;
+ param = &self->object->soft->maxgoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_DEFGOAL:
+ min = EXPP_OBJECT_SBDEFGOALMIN;
+ max = EXPP_OBJECT_SBDEFGOALMAX;
+ param = &self->object->soft->defgoal;
+ break;
+ case EXPP_OBJ_ATTR_SB_INSPRING:
+ min = EXPP_OBJECT_SBINSPRINGMIN;
+ max = EXPP_OBJECT_SBINSPRINGMAX;
+ param = &self->object->soft->inspring;
+ break;
+ case EXPP_OBJ_ATTR_SB_INFRICT:
+ min = EXPP_OBJECT_SBINFRICTMIN;
+ max = EXPP_OBJECT_SBINFRICTMAX;
+ param = &self->object->soft->infrict;
+ break;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "undefined type in setFloatAttrClamp" );
+ }
- if( !PyArg_ParseTuple( args, "i", &( value ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setFloatClamped( value, param, min, max );
+}
- self->object->pd->flag = (short)value;
+/*
+ * set floating point attributes
+ */
- return EXPP_incr_ret( Py_None );
+static int setFloatAttr( BPy_Object *self, PyObject *value, void *type )
+{
+ float param;
+ struct Object *object = self->object;
+
+ if( !PyNumber_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected float argument" );
+
+ param = PyFloat_AsDouble( value );
+
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_LOC_X:
+ object->loc[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_LOC_Y:
+ object->loc[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_LOC_Z:
+ object->loc[2] = param;
+ break;
+ case EXPP_OBJ_ATTR_DLOC_X:
+ object->dloc[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_DLOC_Y:
+ object->dloc[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_DLOC_Z:
+ object->dloc[2] = param;
+ break;
+ case EXPP_OBJ_ATTR_ROT_X:
+ object->rot[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_ROT_Y:
+ object->rot[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_ROT_Z:
+ object->rot[2] = param;
+ break;
+ case EXPP_OBJ_ATTR_DROT_X:
+ object->drot[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_DROT_Y:
+ object->drot[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_DROT_Z:
+ object->drot[2] = param;
+ break;
+ case EXPP_OBJ_ATTR_SIZE_X:
+ object->size[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_SIZE_Y:
+ object->size[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_SIZE_Z:
+ object->size[2] = param;
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_X:
+ object->dsize[0] = param;
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_Y:
+ object->dsize[1] = param;
+ break;
+ case EXPP_OBJ_ATTR_DSIZE_Z:
+ object->dsize[2] = param;
+ break;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "undefined type in setFloatAttr " );
+ }
+ self->object->recalc |= OB_RECALC_OB;
+ return 0;
}
-PyObject *Object_getPIType( BPy_Object * self )
+/*
+ * get 3-tuple floating point attributes
+ */
+
+static PyObject *getFloat3Attr( BPy_Object *self, void *type )
{
- PyObject *attr;
+ PyObject *attr = NULL;
+ float *param;
+ struct Object *object = self->object;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyInt_FromLong( ( long ) self->object->pd->forcefield );
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_LOC:
+ param = object->loc;
+ break;
+ case EXPP_OBJ_ATTR_DLOC:
+ param = object->dloc;
+ break;
+ case EXPP_OBJ_ATTR_DROT:
+ param = object->drot;
+ break;
+ case EXPP_OBJ_ATTR_SIZE:
+ param = object->size;
+ break;
+ case EXPP_OBJ_ATTR_DSIZE:
+ param = object->dsize;
+ break;
+ default:
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "undefined type in getFloat3Attr" );
+ }
+ attr = Py_BuildValue( "(fff)", param[0], param[1], param[2] );
+
if( attr )
return attr;
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->forcefield attribute" ) );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "Py_BuildValue() failed!" );
+}
+
+/*
+ * set 3-tuple floating point attributes
+ */
+
+static int setFloat3Attr( BPy_Object *self, PyObject *value, void *type )
+{
+ int i;
+ float *dst, param[3];
+ struct Object *object = self->object;
+
+ if( !PyArg_ParseTuple( value, "fff", &param[0], &param[1], &param[2] ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a tuple of 3 floats" );
+
+ switch( (int)type ) {
+ case EXPP_OBJ_ATTR_LOC:
+ dst = object->loc;
+ break;
+ case EXPP_OBJ_ATTR_DLOC:
+ dst = object->dloc;
+ break;
+ case EXPP_OBJ_ATTR_DROT:
+ dst = object->drot;
+ break;
+ case EXPP_OBJ_ATTR_SIZE:
+ dst = object->size;
+ break;
+ case EXPP_OBJ_ATTR_DSIZE:
+ dst = object->dsize;
+ break;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "undefined type in setFloat3Attr" );
+ }
+
+ for( i = 0; i < 3; ++i )
+ dst[i] = param[i];
+ self->object->recalc |= OB_RECALC_OB;
+ return 0;
}
-PyObject *Object_setPIType( BPy_Object * self, PyObject * args )
+
+/*****************************************************************************/
+/* BPy_Object methods and attribute handlers */
+/*****************************************************************************/
+
+static PyObject *Object_getDrawModeBits( BPy_Object *self, void *type )
{
- int value;
+ return EXPP_getBitfield( (void *)&self->object->dtx, (int)type, 'b' );
+}
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+static int Object_setDrawModeBits( BPy_Object *self, PyObject *value,
+ void *type )
+{
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setBitfield( value, (void *)&self->object->dtx,
+ (int)type, 'b' );
+}
- if( !PyArg_ParseTuple( args, "i", &( value ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
+static PyObject *Object_getTransflagBits( BPy_Object *self, void *type )
+{
+ return EXPP_getBitfield( (void *)&self->object->transflag,
+ (int)type, 'b' );
+}
+
+static int Object_setTransflagBits( BPy_Object *self, PyObject *value,
+ void *type )
+{
+ self->object->recalc |= OB_RECALC_OB;
+ return EXPP_setBitfield( value, (void *)&self->object->transflag,
+ (int)type, 'b' );
+}
+
+static PyObject *Object_getLayers( BPy_Object * self )
+{
+ int layers, bit;
+ PyObject *laylist = PyList_New( 0 );
+
+ if( !laylist )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "PyList_New() failed" );
- self->object->pd->forcefield = (short)value;
+ layers = self->object->lay & 0xfffff; /* get layer bitmask */
- return EXPP_incr_ret( Py_None );
+ /*
+ * starting with the first layer, and until there are no more layers,
+ * find which layers are visible
+ */
+
+ for( bit = 1; layers; ++bit ) {
+ if( layers & 1 ) { /* if layer is visible, add to list */
+ PyObject *item = PyInt_FromLong( bit );
+ PyList_Append( laylist, item );
+ Py_DECREF( item );
+ }
+ layers >>= 1; /* go to the next layer */
+ }
+ return laylist;
}
+/*
+ * usage note: caller of this func needs to do a Blender.Redraw(-1)
+ * to update and redraw the interface
+ */
-PyObject *Object_getPIPerm( BPy_Object * self )
+static int Object_setLayers( BPy_Object * self, PyObject *value )
{
- PyObject *attr;
-
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->pd->pdef_perm );
+ int layers = 0, val, i, len_list, local;
+ Base *base;
- if( attr )
- return attr;
+ if( !PyList_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a list of integers in the range [1, 20]" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->pdef_perm attribute" ) );
+ len_list = PyList_Size( value );
+
+ /* build a bitmask, check for values outside of range */
+
+ for( i = 0; i < len_list; i++ ) {
+ PyObject* integer = PyNumber_Int( PyList_GetItem( value, i ) );
+ val = PyInt_AsLong( integer );
+ Py_XDECREF( integer );
+ if( !integer )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "list must contain only integer numbers" );
+ if( val < 1 || val > 20 )
+ return EXPP_ReturnIntError ( PyExc_ValueError,
+ "layer values must be in the range [1, 20]" );
+ layers |= 1 << ( val - 1 );
+ }
+
+ /* update any bases pointing to our object */
+
+ base = FIRSTBASE; /* first base in current scene */
+ while( base ) {
+ if( base->object == self->object ) {
+ base->lay &= 0xFFF00000;
+ local = base->lay;
+ base->lay = local | layers;
+ self->object->lay = base->lay;
+ }
+ base = base->next;
+ }
+ countall();
+ DAG_scene_sort( G.scene );
+ return 0;
}
-PyObject *Object_setPIPerm( BPy_Object * self, PyObject * args )
+
+static int Object_setLayersMask( BPy_Object *self, PyObject *value )
{
- float value;
+ int layers = 0, local;
+ Base *base;
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ if( !PyInt_CheckExact( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an integer (bitmask) as argument" );
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ layers = PyInt_AS_LONG( value );
+
+ /* make sure some bits are set, and only those bits are set */
+
+ if( !( layers & 0xFFFFF ) || ( layers & 0xFFF00000 ) )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "bitmask must have between 1 and 20 bits set" );
- if(value > 1.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1.0 and 0.0" ) );
- self->object->pd->pdef_perm = value;
+ /* update any bases pointing to our object */
- return EXPP_incr_ret( Py_None );
+ base = FIRSTBASE; /* first base in current scene */
+ while( base ) {
+ if( base->object == self->object ) {
+ base->lay &= 0xFFF00000;
+ local = base->lay;
+ base->lay = local | layers;
+ self->object->lay = base->lay;
+ }
+ base = base->next;
+ }
+ countall();
+ DAG_scene_sort( G.scene );
+ return 0;
}
-PyObject *Object_getPIRandomDamp( BPy_Object * self )
+/*
+ * this should accept a Py_None argument and just delete the Ipo link
+ * (as Object_clearIpo() does)
+ */
+
+static int Object_setIpo( BPy_Object * self, PyObject * value )
{
- PyObject *attr;
-
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->pd->pdef_rdamp );
+ Ipo *ipo = NULL;
+ Ipo *oldipo = self->object->ipo;
+ ID *id;
- if( attr )
- return attr;
+ /* if parameter is not None, check for valid Ipo */
+
+ if ( value != Py_None ) {
+ if ( !Ipo_CheckPyObject( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an Ipo object" );
+
+ ipo = Ipo_FromPyObject( value );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->pdef_rdamp attribute" ) );
+ if( !ipo )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "null ipo!" );
+
+ if( ipo->blocktype != ID_OB )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Ipo is not a object data Ipo" );
+ }
+
+ /* if already linked to Ipo, delete link */
+
+ if ( oldipo ) {
+ id = &oldipo->id;
+ if( id->us > 0 )
+ id->us--;
+ }
+
+ /* assign new Ipo and increment user count, or set to NULL if deleting */
+
+ self->object->ipo = ipo;
+ if ( ipo ) {
+ id = &ipo->id;
+ id->us++;
+ }
+
+ return 0;
}
-PyObject *Object_setPIRandomDamp( BPy_Object * self, PyObject * args )
+
+static PyObject *Object_getOopsLoc( BPy_Object * self )
{
- float value;
+ if( G.soops ) {
+ Oops *oops = G.soops->oops.first;
+ while( oops ) {
+ if( oops->type == ID_OB && (Object *)oops->id == self->object )
+ return Py_BuildValue( "ff", oops->x, oops->y );
+ oops = oops->next;
+ }
+ }
+ Py_RETURN_NONE;
+}
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+static PyObject *Object_getOopsSel ( BPy_Object * self )
+{
+ if( G.soops ) {
+ Oops *oops= G.soops->oops.first;
+ while( oops ) {
+ if( oops->type == ID_OB
+ && (Object *)oops->id == self->object ) {
+ if( oops->flag & SELECT )
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+ }
+ oops = oops->next;
+ }
+ }
+ Py_RETURN_NONE;
+}
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+static int Object_setOopsLoc( BPy_Object * self, PyObject * value )
+{
+ if( G.soops ) {
+ Oops *oops= G.soops->oops.first;
+ while( oops ) {
+ if( oops->type == ID_OB && (Object *)oops->id == self->object ) {
+ if( !PyArg_ParseTuple( value, "ff", &oops->x, &oops->y ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected two floats as arguments" );
+ return 0;
+ }
+ oops = oops->next;
+ }
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "couldn't find oopsLoc data for object" );
+ }
+ return 0;
+}
+
+static int Object_setOopsSel( BPy_Object * self, PyObject * value )
+{
+ int setting = PyObject_IsTrue( value );
- if(value > 1.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1.0 and 0.0" ) );
- self->object->pd->pdef_rdamp = value;
+ if( setting == -1 )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected true/false argument" );
- return EXPP_incr_ret( Py_None );
+ if( G.soops ) {
+ Oops *oops = G.soops->oops.first;
+ while( oops ) {
+ if( oops->type==ID_OB ) {
+ if( (Object *)oops->id == self->object ) {
+#if 0
+ /* this code is what other modules do; it doesn't seem to work */
+ if( !setting )
+ oops->flag &= ~SELECT;
+ else
+ oops->flag |= SELECT;
+#else
+ printf ("warning: Object.oopsSel setter may not be coded correctly\n");
+ /* this code seems to work, but may not be the correct thing to do */
+ if( !setting )
+ self->object->flag &= ~SELECT;
+ else
+ self->object->flag |= SELECT;
+#endif
+ return 0;
+ }
+ }
+ oops= oops->next;
+ }
+ }
+ return 0;
}
-PyObject *Object_getPISurfaceDamp( BPy_Object * self )
+static int Object_setTracked( BPy_Object * self, PyObject * value )
{
- PyObject *attr;
-
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->pd->pdef_damp );
+ Object *ob = self->object;
- if( attr )
- return attr;
+ if( value != Py_None && !BPy_Object_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an object argument" );
+
+ if( value != Py_None )
+ ob->track = ((BPy_Object *)value)->object;
+ else
+ ob->track = ((BPy_Object *)value)->object;
+ self->object->recalc |= OB_RECALC_OB;
+ DAG_scene_sort( G.scene );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->pdef_rdamp attribute" ) );
+ return 0;
}
-PyObject *Object_setPISurfaceDamp( BPy_Object * self, PyObject * args )
+
+static PyObject *Object_getUsers( BPy_Object * self )
{
- float value;
+ return PyInt_FromLong( self->object->id.us );
+}
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+/* Localspace matrix */
- if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+static PyObject *Object_getMatrixLocal( BPy_Object * self )
+{
+ if( self->object->parent ) {
+ float matrix[4][4]; /* for the result */
+ float invmat[4][4]; /* for inverse of parent's matrix */
+
+ Mat4Invert(invmat, self->object->parent->obmat );
+ Mat4MulMat4(matrix, invmat, self->object->obmat);
+ return newMatrixObject((float*)matrix,4,4,Py_NEW);
+ } else { /* no parent, so return world space matrix */
+ disable_where_script( 1 );
+ where_is_object( self->object );
+ disable_where_script( 0 );
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
+ }
+}
- if(value > 1.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 1.0 and 0.0" ) );
- self->object->pd->pdef_damp = value;
+/* Worldspace matrix */
- return EXPP_incr_ret( Py_None );
+static PyObject *Object_getMatrixWorld( BPy_Object * self )
+{
+ disable_where_script( 1 );
+ where_is_object( self->object );
+ disable_where_script( 0 );
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
}
-PyObject *Object_getPIDeflection( BPy_Object * self )
-{
- PyObject *attr;
-
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
-
- attr = PyInt_FromLong( ( long ) self->object->pd->deflect );
- if( attr )
- return attr;
+/*
+ * Old behavior, prior to Blender 2.34, where eventual changes made by the
+ * script itself were not taken into account until a redraw happened, either
+ * called by the script or upon its exit.
+ */
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->pd->deflect attribute" ) );
+static PyObject *Object_getMatrixOldWorld( BPy_Object * self )
+{
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
}
-PyObject *Object_setPIDeflection( BPy_Object * self, PyObject * args )
+/*
+ * get one of three different matrix representations
+ */
+
+static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args )
{
- int value;
+ char *space = "worldspace"; /* default to world */
+ char *errstr = "expected nothing, 'worldspace' (default), 'localspace' or 'old_worldspace'";
- if(!self->object->pd){
- if(!setupPI(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "particle deflection could not be accessed (null pointer)" ) );
- }
+ if( !PyArg_ParseTuple( args, "|s", &space ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError, errstr );
- if( !PyArg_ParseTuple( args, "i", &( value ) ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected int argument" ) );
+ if( BLI_streq( space, "worldspace" ) )
+ return Object_getMatrixWorld( self );
+ else if( BLI_streq( space, "localspace" ) )
+ return Object_getMatrixLocal( self );
+ else if( BLI_streq( space, "old_worldspace" ) )
+ return Object_getMatrixOldWorld( self );
+ else
+ return EXPP_ReturnPyObjError( PyExc_ValueError, errstr );
+}
- self->object->pd->deflect = (short)value;
+static PyObject *get_obj_data( BPy_Object *self, int mesh )
+{
+ Object *object = self->object;
+ PyObject *data_object = NULL;
- return EXPP_incr_ret( Py_None );
+ switch ( object->type ) {
+ case OB_ARMATURE:
+ data_object = PyArmature_FromArmature( object->data );
+ break;
+ case OB_CAMERA:
+ data_object = Camera_CreatePyObject( object->data );
+ break;
+ case OB_CURVE:
+ data_object = Curve_CreatePyObject( object->data );
+ break;
+ case ID_IM:
+ data_object = Image_CreatePyObject( object->data );
+ break;
+ case ID_IP:
+ data_object = Ipo_CreatePyObject( object->data );
+ break;
+ case OB_LAMP:
+ data_object = Lamp_CreatePyObject( object->data );
+ break;
+ case OB_LATTICE:
+ data_object = Lattice_CreatePyObject( object->data );
+ break;
+ case ID_MA:
+ break;
+ case OB_MESH:
+ if( !mesh ) /* get as NMesh (default) */
+ data_object = NMesh_CreatePyObject( object->data, object );
+ else /* else get as Mesh */
+ data_object = Mesh_CreatePyObject( object->data, object );
+ break;
+ case ID_OB:
+ data_object = Object_CreatePyObject( object->data );
+ break;
+ case ID_SCE:
+ break;
+ case ID_TXT:
+ data_object = Text_CreatePyObject( object->data );
+ break;
+ case OB_FONT:
+ data_object = Text3d_CreatePyObject( object->data );
+ break;
+ case ID_WO:
+ break;
+ default:
+ break;
+ }
+
+ if( data_object )
+ return data_object;
+
+ Py_RETURN_NONE;
}
-/* RIGIDBODY FUNCTIONS */
+static PyObject *Object_getData( BPy_Object *self, PyObject *args,
+ PyObject *kwd )
+{
+ Object *object = self->object;
+ int name_only = 0;
+ int mesh = 0; /* default mesh type = NMesh */
+ static char *kwlist[] = {"name_only", "mesh", NULL};
-static int Object_setRBMass( BPy_Object * self, PyObject * args )
+ if( !PyArg_ParseTupleAndKeywords(args, kwd, "|ii", kwlist,
+ &name_only, &mesh) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or bool keywords 'name_only' or 'mesh' as argument" );
+
+ /* if there's no obdata, try to create it */
+ if( object->data == NULL ) {
+ if( EXPP_add_obdata( object ) != 0 ) { /* couldn't create obdata */
+ Py_RETURN_NONE;
+ }
+ }
+
+ /* user wants only the name of the data object */
+ if( name_only ) {
+ ID *id = object->data;
+ return PyString_FromString( id->name+2 );
+ }
+
+ return get_obj_data( self, mesh );
+}
+
+static PyObject *Object_getEuler( BPy_Object * self )
{
- float value;
- PyObject* flt = PyNumber_Float( args );
+ return ( PyObject * ) newEulerObject( self->object->rot, Py_WRAP );
+}
- if( !flt )
+#define PROTFLAGS_MASK ( OB_LOCK_LOCX | OB_LOCK_LOCY | OB_LOCK_LOCZ | \
+ OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | \
+ OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ )
+
+static PyObject *Object_getProtectFlags( BPy_Object * self )
+{
+ return PyInt_FromLong( (long)(self->object->protectflag & PROTFLAGS_MASK) );
+}
+
+static int Object_setProtectFlags( BPy_Object * self, PyObject * args )
+{
+ PyObject* integer = PyNumber_Int( args );
+ short value;
+
+ if( !integer )
return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
-
- value = PyFloat_AS_DOUBLE( flt );
- Py_DECREF(flt);
-
- if( value < 0.0f )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "acceptable values are non-negative, 0.0 or more" );
+ "expected integer argument" );
- self->object->mass = value;
+ value = ( short )PyInt_AS_LONG( integer );
+ if( value & ~PROTFLAGS_MASK )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "undefined bit(s) set in bitfield" );
+ self->object->protectflag = value;
+ self->object->recalc |= OB_RECALC_OB;
return 0;
}
+static PyObject *Object_getRBRadius( BPy_Object * self )
+{
+ return PyFloat_FromDouble( (double) self->object->inertia );
+}
static int Object_setRBRadius( BPy_Object * self, PyObject * args )
{
float value;
- PyObject* flt = PyNumber_Float( args );
+ PyObject* flt = PyNumber_Float( args );
- if( !flt )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected float argument" );
- value = PyFloat_AS_DOUBLE( flt );
- Py_DECREF(flt);
+ if( !flt )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected float argument" );
+ value = PyFloat_AS_DOUBLE( flt );
+ Py_DECREF( flt );
+
+ if( value < 0.0f )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "acceptable values are non-negative, 0.0 or more" );
+
+ self->object->inertia = value;
+ self->object->recalc |= OB_RECALC_OB;
+
+ return 0;
+}
+
+static PyObject *Object_getRBHalfExtents( BPy_Object * self )
+{
+ float center[3], extents[3];
+
+ get_local_bounds( self->object, center, extents );
+ return Py_BuildValue( "[fff]", extents[0], extents[1], extents[2] );
+}
+
+static PyGetSetDef BPy_Object_getseters[] = {
+ {"LocX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The X location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_LOC_X},
+ {"LocY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Y location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_LOC_Y},
+ {"LocZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Z location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_LOC_Z},
+ {"dLocX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta X location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_DLOC_X},
+ {"dLocY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Y location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_DLOC_Y},
+ {"dLocZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Z location coordinate of the object",
+ (void *)EXPP_OBJ_ATTR_DLOC_Z},
+ {"RotX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The X rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_ROT_X},
+ {"RotY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Y rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_ROT_Y},
+ {"RotZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Z rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_ROT_Z},
+ {"dRotX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta X rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_DROT_X},
+ {"dRotY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Y rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_DROT_Y},
+ {"dRotZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Z rotation angle (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_DROT_Z},
+ {"SizeX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The X size of the object",
+ (void *)EXPP_OBJ_ATTR_SIZE_X},
+ {"SizeY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Y size of the object",
+ (void *)EXPP_OBJ_ATTR_SIZE_Y},
+ {"SizeZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The Z size of the object",
+ (void *)EXPP_OBJ_ATTR_SIZE_Z},
+ {"dSizeX",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta X size of the object",
+ (void *)EXPP_OBJ_ATTR_DSIZE_X},
+ {"dSizeY",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Y size of the object",
+ (void *)EXPP_OBJ_ATTR_DSIZE_Y},
+ {"dSizeZ",
+ (getter)getFloatAttr, (setter)setFloatAttr,
+ "The delta Z size of the object",
+ (void *)EXPP_OBJ_ATTR_DSIZE_Z},
+
+ {"loc",
+ (getter)getFloat3Attr, (setter)setFloat3Attr,
+ "The (X,Y,Z) location coordinates of the object",
+ (void *)EXPP_OBJ_ATTR_LOC},
+ {"dloc",
+ (getter)getFloat3Attr, (setter)setFloat3Attr,
+ "The delta (X,Y,Z) location coordinates of the object",
+ (void *)EXPP_OBJ_ATTR_DLOC},
+ {"rot",
+ (getter)Object_getEuler, (setter)Object_setEuler,
+ "The (X,Y,Z) rotation angles (in degrees) of the object",
+ NULL},
+ {"drot",
+ (getter)getFloat3Attr, (setter)setFloat3Attr,
+ "The delta (X,Y,Z) rotation angles (in radians) of the object",
+ (void *)EXPP_OBJ_ATTR_DROT},
+ {"size",
+ (getter)getFloat3Attr, (setter)setFloat3Attr,
+ "The (X,Y,Z) size of the object",
+ (void *)EXPP_OBJ_ATTR_SIZE},
+ {"dsize",
+ (getter)getFloat3Attr, (setter)setFloat3Attr,
+ "The delta (X,Y,Z) size of the object",
+ (void *)EXPP_OBJ_ATTR_DSIZE},
+ {"Layer",
+ (getter)getIntAttr, (setter)Object_setLayersMask,
+ "The object layers (bitfield)",
+ (void *)EXPP_OBJ_ATTR_LAYERMASK},
+ {"Layers",
+ (getter)getIntAttr, (setter)Object_setLayersMask,
+ "The object layers (bitfield)",
+ (void *)EXPP_OBJ_ATTR_LAYERMASK},
+ {"layers",
+ (getter)Object_getLayers, (setter)Object_setLayers,
+ "The object layers (list of ints)",
+ NULL},
+ {"ipo",
+ (getter)Object_getIpo, (setter)Object_setIpo,
+ "Object's Ipo data",
+ NULL},
+ {"colbits",
+ (getter)getIntAttr, (setter)setIntAttrRange,
+ "The Material usage bitfield",
+ (void *)EXPP_OBJ_ATTR_COLBITS},
+ {"drawMode",
+ (getter)getIntAttr, (setter)Object_setDrawMode,
+ "The object's drawing mode bitfield",
+ (void *)EXPP_OBJ_ATTR_DRAWMODE},
+ {"drawType",
+ (getter)getIntAttr, (setter)Object_setDrawType,
+ "The object's drawing type",
+ (void *)EXPP_OBJ_ATTR_DRAWTYPE},
+ {"DupOn",
+ (getter)getIntAttr, (setter)setIntAttrClamp,
+ "DupOn setting (for DupliFrames)",
+ (void *)EXPP_OBJ_ATTR_DUPON},
+ {"DupOff",
+ (getter)getIntAttr, (setter)setIntAttrClamp,
+ "DupOff setting (for DupliFrames)",
+ (void *)EXPP_OBJ_ATTR_DUPOFF},
+ {"DupSta",
+ (getter)getIntAttr, (setter)setIntAttrClamp,
+ "Starting frame (for DupliFrames)",
+ (void *)EXPP_OBJ_ATTR_DUPSTA},
+ {"DupEnd",
+ (getter)getIntAttr, (setter)setIntAttrClamp,
+ "Ending frame (for DupliFrames)",
+ (void *)EXPP_OBJ_ATTR_DUPEND},
+ {"mat",
+ (getter)Object_getMatrixWorld, (setter)Object_setMatrix,
+ "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
+ NULL},
+ {"matrix",
+ (getter)Object_getMatrixWorld, (setter)Object_setMatrix,
+ "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
+ NULL},
+ {"matrixWorld",
+ (getter)Object_getMatrixWorld, (setter)NULL,
+ "worldspace matrix: absolute, takes vertex parents, tracking and Ipos into account",
+ NULL},
+ {"matrixLocal",
+ (getter)Object_getMatrixLocal, (setter)NULL,
+ "localspace matrix: relative to the object's parent",
+ NULL},
+ {"matrixOldWorld",
+ (getter)Object_getMatrixOldWorld, (setter)NULL,
+ "old-type worldspace matrix (prior to Blender 2.34)",
+ NULL},
+ {"name",
+ (getter)Object_getName, (setter)Object_setName,
+ "Object data name",
+ NULL},
+ {"oopsLoc",
+ (getter)Object_getOopsLoc, (setter)Object_setOopsLoc,
+ "Object OOPs location",
+ NULL},
+ {"oopsSel",
+ (getter)Object_getOopsSel, (setter)Object_setOopsSel,
+ "Object OOPs selection flag",
+ NULL},
+ {"data",
+ (getter)get_obj_data, (setter)NULL,
+ "The Datablock object linked to this object",
+ NULL},
+ {"sel",
+ (getter)Object_getSelected, (setter)Object_setSelect,
+ "The object's selection state",
+ NULL},
+ {"parent",
+ (getter)Object_getParent, (setter)NULL,
+ "The object's parent object (if parented)",
+ NULL},
+ {"parentbonename",
+ (getter)Object_getParentBoneName, (setter)NULL,
+ "Returns the object's parent object's sub name",
+ NULL},
+ {"track",
+ (getter)Object_getTracked, (setter)Object_setTracked,
+ "The object's tracked object",
+ NULL},
+ {"timeOffset",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "The time offset of the object's animation",
+ (void *)EXPP_OBJ_ATTR_TIMEOFFSET},
+ {"type",
+ (getter)Object_getType, (setter)NULL,
+ "The object's type",
+ NULL},
+ {"boundingBox",
+ (getter)Object_getBoundBox, (setter)NULL,
+ "The bounding box of this object",
+ NULL},
+ {"action",
+ (getter)Object_getAction, (setter)NULL,
+ "The action associated with this object (if defined)",
+ NULL},
+ {"properties",
+ (getter)Object_getAllProperties, (setter)NULL,
+ "The object's properties",
+ NULL},
+ {"users",
+ (getter)Object_getUsers, (setter)NULL,
+ "The number of object users",
+ NULL},
+
+ {"piFalloff",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "The particle interaction falloff power",
+ (void *)EXPP_OBJ_ATTR_PI_FALLOFF},
+ {"piMaxDist",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Max distance for the particle interaction field to work",
+ (void *)EXPP_OBJ_ATTR_PI_MAXDIST},
+ {"piPermeability",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Probability that a particle will pass through the mesh",
+ (void *)EXPP_OBJ_ATTR_PI_PERM},
+ {"piRandomDamp",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Random variation of particle interaction damping",
+ (void *)EXPP_OBJ_ATTR_PI_RANDOMDAMP},
+ {"piStrength",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Particle interaction force field strength",
+ (void *)EXPP_OBJ_ATTR_PI_STRENGTH},
+ {"piSurfaceDamp",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Amount of damping during particle collision",
+ (void *)EXPP_OBJ_ATTR_PI_SURFACEDAMP},
+ {"piSoftbodyDamp",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Damping factor for softbody deflection",
+ (void *)EXPP_OBJ_ATTR_PI_SBDAMP},
+ {"piSoftbodyIThick",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Inner face thickness for softbody deflection",
+ (void *)EXPP_OBJ_ATTR_PI_SBIFACETHICK},
+ {"piSoftbodyOThick",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Outer face thickness for softbody deflection",
+ (void *)EXPP_OBJ_ATTR_PI_SBOFACETHICK},
+
+ {"piDeflection",
+ (getter)Object_getPIDeflection, (setter)Object_setPIDeflection,
+ "Deflects particles based on collision",
+ NULL},
+ {"piType",
+ (getter)Object_getPIType, (setter)Object_setPIType,
+ "Type of particle interaction (force field, wind, etc)",
+ NULL},
+ {"piUseMaxDist",
+ (getter)Object_getPIUseMaxDist, (setter)Object_setPIUseMaxDist,
+ "Use a maximum distance for the field to work",
+ NULL},
+
+ {"sbMass",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody point mass (heavier is slower)",
+ (void *)EXPP_OBJ_ATTR_SB_NODEMASS},
+ {"sbGrav",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Apply gravitation to softbody point movement",
+ (void *)EXPP_OBJ_ATTR_SB_GRAV},
+ {"sbFriction",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "General media friction for softbody point movements",
+ (void *)EXPP_OBJ_ATTR_SB_MEDIAFRICT},
+ {"sbSpeed",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Tweak timing for physics to control softbody frequency and speed",
+ (void *)EXPP_OBJ_ATTR_SB_MEDIAFRICT},
+ {"sbErrorLimit",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody Runge-Kutta ODE solver error limit (low values give more precision)",
+ (void *)EXPP_OBJ_ATTR_SB_RKLIMIT},
+ {"sbGoalSpring",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody goal (vertex target position) spring stiffness",
+ (void *)EXPP_OBJ_ATTR_SB_GOALSPRING},
+ {"sbGoalFriction",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody goal (vertex target position) friction",
+ (void *)EXPP_OBJ_ATTR_SB_GOALFRICT},
+ {"sbMinGoal",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody goal minimum (vertex group weights scaled to match this range)",
+ (void *)EXPP_OBJ_ATTR_SB_MINGOAL},
+ {"sbMaxGoal",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody goal maximum (vertex group weights scaled to match this range)",
+ (void *)EXPP_OBJ_ATTR_SB_MAXGOAL},
+ {"sbDefaultGoal",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Default softbody goal value, when no vertex group used",
+ (void *)EXPP_OBJ_ATTR_SB_DEFGOAL},
+ {"sbInnerSpring",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody edge spring stiffness",
+ (void *)EXPP_OBJ_ATTR_SB_INSPRING},
+ {"sbInnerSpringFrict",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "Softbody edge spring friction",
+ (void *)EXPP_OBJ_ATTR_SB_INFRICT},
+ {"isSoftBody",
+ (getter)Object_isSB, (setter)NULL,
+ "True if object is a soft body",
+ NULL},
+ {"sbUseGoal",
+ (getter)Object_getSBUseGoal, (setter)Object_setSBUseGoal,
+ "Softbody forces for vertices to stick to animated position enabled",
+ NULL},
+ {"sbUseEdges",
+ (getter)Object_getSBUseEdges, (setter)Object_setSBUseEdges,
+ "Softbody use edges as springs enabled",
+ NULL},
+ {"sbStiffQuads",
+ (getter)Object_getSBStiffQuads, (setter)Object_setSBStiffQuads,
+ "Softbody adds diagonal springs on 4-gons enabled",
+ NULL},
+
+ {"axis",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Display of active object's center and axis enabled",
+ (void *)OB_AXIS},
+ {"texSpace",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Display of active object's texture space enabled",
+ (void *)OB_TEXSPACE},
+ {"nameMode",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Display of active object's name enabled",
+ (void *)OB_DRAWNAME},
+ {"wireMode",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Add the active object's wireframe over solid drawing enabled",
+ (void *)OB_DRAWWIRE},
+ {"xRay",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Draw the active object in front of others enabled",
+ (void *)OB_DRAWXRAY},
+ {"transp",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Transparent materials for the active object (mesh only) enabled",
+ (void *)OB_DRAWTRANSP},
+
+ {"enableDupVerts",
+ (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
+ "Duplicate child objects on all vertices",
+ (void *)OB_DUPLIVERTS},
+ {"enableDupFrames",
+ (getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
+ "Make copy of object for every frame",
+ (void *)OB_DUPLIFRAMES},
+ {"enableDupGroup",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Enable group instancing",
+ (void *)OB_DUPLIGROUP},
+ {"enableDupRot",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Rotate dupli according to vertex normal",
+ (void *)OB_DUPLIROT},
+ {"enableDupNoSpeed",
+ (getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
+ "Set dupliframes to still, regardless of frame",
+ (void *)OB_DUPLINOSPEED},
+ {"DupObjects",
+ (getter)Object_getDupliObjects, (setter)NULL,
+ "Get a list of tuples for object duplicated by dupliframe",
+ NULL},
+ {"DupGroup",
+ (getter)Object_getDupliGroup, (setter)Object_setDupliGroup,
+ "Get a list of tuples for object duplicated by dupliframe",
+ NULL},
+
+ {"effects",
+ (getter)Object_getEffects, (setter)NULL,
+ "The list of particle effects associated with the object",
+ NULL},
+ {"actionStrips",
+ (getter)Object_getActionStrips, (setter)NULL,
+ "The action strips associated with the object",
+ NULL},
+ {"constraints",
+ (getter)Object_getConstraints, (setter)NULL,
+ "The constraints associated with the object",
+ NULL},
+ {"modifiers",
+ (getter)Object_getModifiers, (setter)NULL,
+ "The modifiers associated with the object",
+ NULL},
+ {"protectFlags",
+ (getter)Object_getProtectFlags, (setter)Object_setProtectFlags,
+ "The \"transform locking\" bitfield for the object",
+ NULL},
+ {"drawSize",
+ (getter)getFloatAttr, (setter)setFloatAttrClamp,
+ "The size to display the Empty",
+ (void *)EXPP_OBJ_ATTR_DRAWSIZE},
+
+ {"rbFlags",
+ (getter)Object_getRBFlags, (setter)Object_setRBFlags,
+ "Rigid body flags",
+ NULL},
+ {"rbMass",
+ (getter)Object_getRBMass, (setter)Object_setRBMass,
+ "Rigid body object mass",
+ NULL},
+ {"rbRadius",
+ (getter)Object_getRBRadius, (setter)Object_setRBRadius,
+ "Rigid body bounding sphere size",
+ NULL},
+ {"rbShapeBoundType",
+ (getter)Object_getRBShapeBoundType, (setter)Object_setRBShapeBoundType,
+ "Rigid body physics bounds object type",
+ NULL},
+ {"rbShapeBoundType",
+ (getter)Object_getRBHalfExtents, (setter)NULL,
+ "Rigid body physics bounds object type",
+ NULL},
+ {"type",
+ (getter)Object_getType, (setter)NULL,
+ "String describing Object type",
+ NULL},
+
+ {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
+};
+
+/*****************************************************************************/
+/* Python Object_Type structure definition: */
+/*****************************************************************************/
+PyTypeObject Object_Type = {
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+ /* For printing, in format "<module>.<name>" */
+ "Blender Object", /* char *tp_name; */
+ sizeof( BPy_Object ), /* int tp_basicsize; */
+ 0, /* tp_itemsize; For allocation */
+
+ /* Methods to implement standard operations */
+
+ ( destructor ) Object_dealloc,/* destructor tp_dealloc; */
+ NULL, /* printfunc tp_print; */
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ ( cmpfunc ) Object_compare, /* cmpfunc tp_compare; */
+ ( reprfunc ) Object_repr, /* reprfunc tp_repr; */
+
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ BPy_Object_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ BPy_Object_getseters, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+
+static PyObject *M_Object_DrawModesDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "AXIS", PyInt_FromLong( OB_AXIS ) );
+ PyConstant_Insert( d, "TEXSPACE", PyInt_FromLong( OB_TEXSPACE ) );
+ PyConstant_Insert( d, "NAME", PyInt_FromLong( OB_DRAWNAME ) );
+ PyConstant_Insert( d, "WIRE", PyInt_FromLong( OB_DRAWWIRE ) );
+ PyConstant_Insert( d, "XRAY", PyInt_FromLong( OB_DRAWXRAY ) );
+ PyConstant_Insert( d, "TRANSP", PyInt_FromLong( OB_DRAWTRANSP ) );
+ }
+ return M;
+}
+
+static PyObject *M_Object_DrawTypesDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "BOUNDBOX", PyInt_FromLong( OB_BOUNDBOX ) );
+ PyConstant_Insert( d, "WIRE", PyInt_FromLong( OB_WIRE ) );
+ PyConstant_Insert( d, "SOLID", PyInt_FromLong( OB_SOLID ) );
+ PyConstant_Insert( d, "SHADED", PyInt_FromLong( OB_SHADED ) );
+ }
+ return M;
+}
+
+static PyObject *M_Object_PITypesDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "NONE", PyInt_FromLong( 0 ) );
+ PyConstant_Insert( d, "FORCE", PyInt_FromLong( PFIELD_FORCE ) );
+ PyConstant_Insert( d, "VORTEX", PyInt_FromLong( PFIELD_VORTEX ) );
+ PyConstant_Insert( d, "WIND", PyInt_FromLong( PFIELD_WIND ) );
+ PyConstant_Insert( d, "GUIDE", PyInt_FromLong( PFIELD_GUIDE ) );
+ }
+ return M;
+}
+
+static PyObject *M_Object_ProtectDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "LOCX", PyInt_FromLong( OB_LOCK_LOCX ) );
+ PyConstant_Insert( d, "LOCY", PyInt_FromLong( OB_LOCK_LOCY ) );
+ PyConstant_Insert( d, "LOCZ", PyInt_FromLong( OB_LOCK_LOCZ ) );
+ PyConstant_Insert( d, "LOC", PyInt_FromLong( OB_LOCK_LOC ) );
+ PyConstant_Insert( d, "ROTX", PyInt_FromLong( OB_LOCK_ROTX ) );
+ PyConstant_Insert( d, "ROTY", PyInt_FromLong( OB_LOCK_ROTY ) );
+ PyConstant_Insert( d, "ROTZ", PyInt_FromLong( OB_LOCK_ROTZ ) );
+ PyConstant_Insert( d, "ROT",
+ PyInt_FromLong( OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ ) );
+ PyConstant_Insert( d, "SCALEX", PyInt_FromLong( OB_LOCK_SCALEX ) );
+ PyConstant_Insert( d, "SCALEY", PyInt_FromLong( OB_LOCK_SCALEY ) );
+ PyConstant_Insert( d, "SCALEZ", PyInt_FromLong( OB_LOCK_SCALEZ ) );
+ PyConstant_Insert( d, "SCALE",
+ PyInt_FromLong( OB_LOCK_SCALEX|OB_LOCK_SCALEY|OB_LOCK_SCALEZ ) );
+ }
+ return M;
+}
+
+static PyObject *M_Object_RBFlagsDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
+ PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
+ PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
+ PyConstant_Insert( d, "USEFH", PyInt_FromLong( OB_DO_FH ) );
+ PyConstant_Insert( d, "ROTFH", PyInt_FromLong( OB_ROT_FH ) );
+ PyConstant_Insert( d, "ANISOTROPIC",
+ PyInt_FromLong( OB_ANISOTROPIC_FRICTION ) );
+ PyConstant_Insert( d, "GHOST", PyInt_FromLong( OB_GHOST ) );
+ PyConstant_Insert( d, "RIGIDBODY", PyInt_FromLong( OB_RIGID_BODY ) );
+ PyConstant_Insert( d, "BOUNDS", PyInt_FromLong( OB_BOUNDS ) );
+ PyConstant_Insert( d, "COLLISION_RESPONSE",
+ PyInt_FromLong( OB_COLLISION_RESPONSE ) );
+ PyConstant_Insert( d, "SECTOR", PyInt_FromLong( OB_SECTOR ) );
+ PyConstant_Insert( d, "PROP", PyInt_FromLong( OB_PROP ) );
+ PyConstant_Insert( d, "MAINACTOR", PyInt_FromLong( OB_MAINACTOR ) );
+ }
+ return M;
+}
+
+static PyObject *M_Object_RBShapeBoundDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "BOX", PyInt_FromLong( OB_BOUND_BOX ) );
+ PyConstant_Insert( d, "SPHERE", PyInt_FromLong( OB_BOUND_SPHERE ) );
+ PyConstant_Insert( d, "CYLINDER", PyInt_FromLong( OB_BOUND_CYLINDER ) );
+ PyConstant_Insert( d, "CONE", PyInt_FromLong( OB_BOUND_CONE ) );
+ PyConstant_Insert( d, "POLYHEDERON", PyInt_FromLong( OB_BOUND_POLYH ) );
+ }
+ return M;
+}
+
+/*****************************************************************************/
+/* Function: initObject */
+/*****************************************************************************/
+PyObject *Object_Init( void )
+{
+ PyObject *module, *dict;
+ PyObject *DrawModesDict = M_Object_DrawModesDict( );
+ PyObject *DrawTypesDict = M_Object_DrawTypesDict( );
+ PyObject *ProtectDict = M_Object_ProtectDict( );
+ PyObject *PITypesDict = M_Object_PITypesDict( );
+ PyObject *RBFlagsDict = M_Object_RBFlagsDict( );
+ PyObject *RBShapesDict = M_Object_RBShapeBoundDict( );
+
+ PyType_Ready( &Object_Type ) ;
+
+ module = Py_InitModule3( "Blender.Object", M_Object_methods,
+ M_Object_doc );
+
+ PyModule_AddIntConstant( module, "LOC", IPOKEY_LOC );
+ PyModule_AddIntConstant( module, "ROT", IPOKEY_ROT );
+ PyModule_AddIntConstant( module, "SIZE", IPOKEY_SIZE );
+ PyModule_AddIntConstant( module, "LOCROT", IPOKEY_LOCROT );
+ PyModule_AddIntConstant( module, "LOCROTSIZE", IPOKEY_LOCROTSIZE );
+
+ PyModule_AddIntConstant( module, "PI_STRENGTH", IPOKEY_PI_STRENGTH );
+ PyModule_AddIntConstant( module, "PI_FALLOFF", IPOKEY_PI_FALLOFF );
+ PyModule_AddIntConstant( module, "PI_SURFACEDAMP", IPOKEY_PI_SURFACEDAMP );
+ PyModule_AddIntConstant( module, "PI_RANDOMDAMP", IPOKEY_PI_RANDOMDAMP );
+ PyModule_AddIntConstant( module, "PI_PERM", IPOKEY_PI_PERM );
+
+ PyModule_AddIntConstant( module, "NONE",0 );
+ PyModule_AddIntConstant( module, "FORCE",PFIELD_FORCE );
+ PyModule_AddIntConstant( module, "VORTEX",PFIELD_VORTEX );
+ PyModule_AddIntConstant( module, "MAGNET",PFIELD_MAGNET );
+ PyModule_AddIntConstant( module, "WIND",PFIELD_WIND );
+
+ if( DrawModesDict )
+ PyModule_AddObject( module, "DrawModes", DrawModesDict );
+ if( DrawTypesDict )
+ PyModule_AddObject( module, "DrawTypes", DrawTypesDict );
+ if( PITypesDict )
+ PyModule_AddObject( module, "PITypes", PITypesDict );
+ if( ProtectDict )
+ PyModule_AddObject( module, "ProtectFlags", ProtectDict );
+ if( RBFlagsDict )
+ PyModule_AddObject( module, "RBFlags", RBFlagsDict );
+ if( RBShapesDict )
+ PyModule_AddObject( module, "RBShapes", RBShapesDict );
- if( value < 0.0f )
- return EXPP_ReturnIntError( PyExc_AttributeError,
- "acceptable values are non-negative, 0.0 or more" );
- self->object->inertia = value;
+ /*Add SUBMODULES to the module*/
+ dict = PyModule_GetDict( module ); /*borrowed*/
+ PyDict_SetItemString(dict, "Pose", Pose_Init()); /*creates a *new* module*/
+ /*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/
- return 0;
+ return ( module );
}
-/* this is too low level, possible to add helper methods */
+/* #####DEPRECATED###### */
-static int Object_setRBFlags( BPy_Object * self, PyObject * args )
+static PyObject *Object_SetIpo( BPy_Object * self, PyObject * args )
{
- PyObject* integer = PyNumber_Int( args );
+ return EXPP_setterWrapper( (void *)self, args, (setter)Object_setIpo );
+}
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
+static PyObject *Object_Select( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args, (setter)Object_setSelect );
+}
- /* more input validation? */
+static PyObject *Object_SetDrawMode( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setDrawMode );
+}
- self->object->gameflag = ( int )PyInt_AS_LONG( integer );
+static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setDrawType );
+}
- return 0;
+static PyObject *Object_SetName( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setName );
}
-static int Object_setRBShapeBoundType( BPy_Object * self, PyObject * args )
+static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args )
{
- PyObject* integer = PyNumber_Int( args );
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setMatrix );
+}
- if( !integer )
- return EXPP_ReturnIntError( PyExc_TypeError,
- "expected integer argument" );
+static PyObject *Object_SetEuler( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setEuler );
+}
- /* more input validation? */
+static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args )
+{
+ float newTimeOffset;
- self->object->boundtype = ( int )PyInt_AS_LONG( integer );
+ if( !PyArg_ParseTuple( args, "f", &newTimeOffset ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float as argument" );
- return 0;
+ self->object->sf = newTimeOffset;
+ self->object->recalc |= OB_RECALC_OB;
+
+ Py_RETURN_NONE;
}
-/* SOFTBODY FUNCTIONS */
+/*************************************************************************/
+/* particle defection methods */
+/*************************************************************************/
-PyObject *Object_isSB(BPy_Object *self)
+static PyObject *Object_SetPIDeflection( BPy_Object * self, PyObject * args )
{
- if (self->object->soft)
- return EXPP_incr_ret_True();
- else return EXPP_incr_ret_False();
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setPIDeflection );
}
-PyObject *Object_getSBMass( BPy_Object * self )
+static PyObject *Object_SetPIType( BPy_Object * self, PyObject * args )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->nodemass );
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setPIType );
+}
- if( attr )
- return attr;
+static PyObject *Object_SetPIUseMaxDist( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setPIUseMaxDist );
+}
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->nodemass attribute" ) );
+static PyObject *Object_getPISurfaceDamp( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+
+ return PyFloat_FromDouble( ( double ) self->object->pd->pdef_damp );
}
-PyObject *Object_setSBMass( BPy_Object * self, PyObject * args )
+static PyObject *Object_SetPISurfaceDamp( BPy_Object * self, PyObject * args )
{
- float value;
+ float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return NULL;
- if(value > 50.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.0 and 50.0" ) );
- self->object->soft->nodemass = value;
+ self->object->pd->pdef_damp = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PIDAMP_MIN, EXPP_OBJECT_PIDAMP_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
+}
- return EXPP_incr_ret( Py_None );
+static PyObject *Object_getPIPerm( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+ return PyFloat_FromDouble ( (double) self->object->pd->pdef_perm );
}
-PyObject *Object_getSBGravity( BPy_Object * self )
+static PyObject *Object_SetPIPerm( BPy_Object * self, PyObject * args )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->grav );
+ float value;
- if( attr )
- return attr;
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return NULL;
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->grav attribute" ) );
+ self->object->pd->pdef_perm = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PIPERM_MIN, EXPP_OBJECT_PIPERM_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
}
-PyObject *Object_setSBGravity( BPy_Object * self, PyObject * args )
+static PyObject *Object_getPIStrength( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+
+ return PyFloat_FromDouble( ( double ) self->object->pd->f_strength );
+}
+
+static PyObject *Object_setPIStrength( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
+
+ self->object->pd->f_strength = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PISTRENGTH_MIN, EXPP_OBJECT_PISTRENGTH_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
+}
- if(value > 10.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.0 and 10.0" ) );
- self->object->soft->grav = value;
+static PyObject *Object_getPIFalloff( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- return EXPP_incr_ret( Py_None );
+ return PyFloat_FromDouble( ( double ) self->object->pd->f_power );
}
-PyObject *Object_getSBFriction( BPy_Object * self )
+static PyObject *Object_setPIFalloff( BPy_Object * self, PyObject * args )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->mediafrict );
+ float value;
- if( attr )
- return attr;
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->mediafrict attribute" ) );
+ self->object->pd->f_power = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PIPOWER_MIN, EXPP_OBJECT_PIPOWER_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
}
-PyObject *Object_setSBFriction( BPy_Object * self, PyObject * args )
+static PyObject *Object_getPIMaxDist( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
+
+ return PyFloat_FromDouble( ( double ) self->object->pd->maxdist );
+}
+
+static PyObject *Object_setPIMaxDist( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
+
+ self->object->pd->maxdist = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PIMAXDIST_MIN, EXPP_OBJECT_PIMAXDIST_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
+}
- if(value > 10.0f || value < 0.0f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.0 and 10.0" ) );
- self->object->soft->mediafrict = value;
+static PyObject *Object_getPIRandomDamp( BPy_Object * self )
+{
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- return EXPP_incr_ret( Py_None );
+ return PyFloat_FromDouble( ( double ) self->object->pd->pdef_rdamp );
}
-PyObject *Object_getSBErrorLimit( BPy_Object * self )
+static PyObject *Object_setPIRandomDamp( BPy_Object * self, PyObject * args )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->rklimit );
+ float value;
- if( attr )
- return attr;
+ if( !self->object->pd && !setupPI(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "particle deflection could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->rklimit attribute" ) );
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return NULL;
+
+ self->object->pd->pdef_rdamp = EXPP_ClampFloat( value,
+ EXPP_OBJECT_PIRDAMP_MIN, EXPP_OBJECT_PIRDAMP_MAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
}
-PyObject *Object_setSBErrorLimit( BPy_Object * self, PyObject * args )
+/*************************************************************************/
+/* softbody methods */
+/*************************************************************************/
+
+static PyObject *Object_getSBMass( BPy_Object * self )
+{
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
+
+ return PyFloat_FromDouble( ( double ) self->object->soft->nodemass );
+}
+
+static PyObject *Object_setSBMass( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 1.0f || value < 0.01f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.01 and 1.0" ) );
- self->object->soft->rklimit = value;
+ self->object->soft->nodemass = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBNODEMASSMIN, EXPP_OBJECT_SBNODEMASSMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBGoalSpring( BPy_Object * self )
+static PyObject *Object_getSBGravity( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->goalspring );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->goalspring attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->grav );
}
-PyObject *Object_setSBGoalSpring( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBGravity( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer) " ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 0.999f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 0.999" ) );
- self->object->soft->goalspring = value;
+ self->object->soft->grav = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBGRAVMIN, EXPP_OBJECT_SBGRAVMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBGoalFriction( BPy_Object * self )
+static PyObject *Object_getSBFriction( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->goalfrict );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->goalfrict attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->mediafrict );
}
-PyObject *Object_setSBGoalFriction( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBFriction( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
-
- if(value > 10.0f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 10.0" ) );
- self->object->soft->goalfrict = value;
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- return EXPP_incr_ret( Py_None );
+ self->object->soft->mediafrict = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBMEDIAFRICTMIN, EXPP_OBJECT_SBMEDIAFRICTMAX );
+ self->object->recalc |= OB_RECALC_OB;
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBMinGoal( BPy_Object * self )
+static PyObject *Object_getSBErrorLimit( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->mingoal );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->mingoal attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->rklimit );
}
-PyObject *Object_setSBMinGoal( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBErrorLimit( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 1.0f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 1.0" ) );
- self->object->soft->mingoal = value;
+ self->object->soft->rklimit = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBRKLIMITMIN, EXPP_OBJECT_SBRKLIMITMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBMaxGoal( BPy_Object * self )
+static PyObject *Object_getSBGoalSpring( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->maxgoal );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->maxgoal attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->goalspring );
}
-PyObject *Object_setSBMaxGoal( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBGoalSpring( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 1.0f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 1.0" ) );
- self->object->soft->maxgoal = value;
+ self->object->soft->goalspring = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBGOALSPRINGMIN, EXPP_OBJECT_SBGOALSPRINGMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBInnerSpring( BPy_Object * self )
+static PyObject *Object_getSBGoalFriction( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->inspring );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->inspring attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->goalfrict );
}
-PyObject *Object_setSBInnerSpring( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBGoalFriction( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 0.999f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 0.999" ) );
- self->object->soft->inspring = value;
+ self->object->soft->goalfrict = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBGOALFRICTMIN, EXPP_OBJECT_SBGOALFRICTMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBInnerSpringFriction( BPy_Object * self )
+static PyObject *Object_getSBMinGoal( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->infrict );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->infrict attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->mingoal );
}
-PyObject *Object_setSBInnerSpringFriction( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBMinGoal( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 10.0f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 10.0" ) );
- self->object->soft->infrict = value;
+ self->object->soft->mingoal = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBMINGOALMIN, EXPP_OBJECT_SBMINGOALMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBDefaultGoal( BPy_Object * self )
+static PyObject *Object_getSBMaxGoal( BPy_Object * self )
{
- PyObject *attr;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- attr = PyFloat_FromDouble( ( double ) self->object->soft->defgoal );
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->soft->defgoal attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->maxgoal );
}
-PyObject *Object_setSBDefaultGoal( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBMaxGoal( BPy_Object * self, PyObject * args )
{
float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
if( !PyArg_ParseTuple( args, "f", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected float argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(value > 1.0f || value < 0.00f)
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "acceptable values are between 0.00 and 1.0" ) );
- self->object->soft->defgoal = value;
+ self->object->soft->maxgoal = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBMAXGOALMIN, EXPP_OBJECT_SBMAXGOALMAX );
+ self->object->recalc |= OB_RECALC_OB;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBUseGoal( BPy_Object * self )
+static PyObject *Object_getSBDefaultGoal( BPy_Object * self )
{
- /*short flag = self->object->softflag;*/
- PyObject *attr = NULL;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- if(self->object->softflag & OB_SB_GOAL){
- attr = PyInt_FromLong(1);
- }
- else{ attr = PyInt_FromLong(0); }
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->softflag attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->defgoal );
}
-PyObject *Object_setSBUseGoal( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBDefaultGoal( BPy_Object * self, PyObject * args )
{
- short value;
+ float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected integer argument" ) );
-
- if(value){ self->object->softflag |= OB_SB_GOAL; }
- else{ self->object->softflag &= ~OB_SB_GOAL; }
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- return EXPP_incr_ret( Py_None );
+ self->object->soft->defgoal = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBDEFGOALMIN, EXPP_OBJECT_SBDEFGOALMAX );
+ self->object->recalc |= OB_RECALC_OB;
+
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBUseEdges( BPy_Object * self )
+static PyObject *Object_getSBInnerSpring( BPy_Object * self )
{
- /*short flag = self->object->softflag;*/
- PyObject *attr = NULL;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- if(self->object->softflag & OB_SB_EDGES){
- attr = PyInt_FromLong(1);
- }
- else{ attr = PyInt_FromLong(0); }
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->softflag attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->inspring );
}
-PyObject *Object_setSBUseEdges( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBInnerSpring( BPy_Object * self, PyObject * args )
{
- short value;
+ float value;
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected integer argument" ) );
-
- if(value){ self->object->softflag |= OB_SB_EDGES; }
- else{ self->object->softflag &= ~OB_SB_EDGES; }
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- return EXPP_incr_ret( Py_None );
+ self->object->soft->inspring = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBINSPRINGMIN, EXPP_OBJECT_SBINSPRINGMAX );
+ self->object->recalc |= OB_RECALC_OB;
+
+ Py_RETURN_NONE;
}
-PyObject *Object_getSBStiffQuads( BPy_Object * self )
+static PyObject *Object_getSBInnerSpringFriction( BPy_Object * self )
{
- /*short flag = self->object->softflag;*/
- PyObject *attr = NULL;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- if(self->object->softflag & OB_SB_QUADS){
- attr = PyInt_FromLong(1);
- }
- else{ attr = PyInt_FromLong(0); }
-
- if( attr )
- return attr;
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "couldn't get Object->softflag attribute" ) );
+ return PyFloat_FromDouble( ( double ) self->object->soft->infrict );
}
-PyObject *Object_setSBStiffQuads( BPy_Object * self, PyObject * args )
+static PyObject *Object_setSBInnerSpringFriction( BPy_Object * self,
+ PyObject * args )
{
- short value;
-
- if(!self->object->soft){
- if(!setupSB(self->object))
- return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "softbody could not be accessed (null pointer)" ) );
- }
-
- if( !PyArg_ParseTuple( args, "h", &value ) )
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected integer argument" ) );
-
- if(value){ self->object->softflag |= OB_SB_QUADS; }
- else{ self->object->softflag &= ~OB_SB_QUADS; }
+ float value;
- return EXPP_incr_ret( Py_None );
-}
+ if( !self->object->soft && !setupSB(self->object) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "softbody could not be accessed" );
-int setupSB(Object* ob){
- ob->soft= sbNew();
- ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- if(ob->soft){
- ob->soft->nodemass = 1.0f;
- ob->soft->grav = 0.0f;
- ob->soft->mediafrict = 0.5f;
- ob->soft->rklimit = 0.1f;
- ob->soft->goalspring = 0.5f;
- ob->soft->goalfrict = 0.0f;
- ob->soft->mingoal = 0.0f;
- ob->soft->maxgoal = 1.0f;
- ob->soft->inspring = 0.5f;
- ob->soft->infrict = 0.5f;
- ob->soft->defgoal = 0.7f;
- return 1;
- }
- else {
- return 0;
- }
-}
+ self->object->soft->infrict = EXPP_ClampFloat( value,
+ EXPP_OBJECT_SBINFRICTMIN, EXPP_OBJECT_SBINFRICTMAX );
+ self->object->recalc |= OB_RECALC_OB;
-int setupPI(Object* ob){
- if(ob->pd==NULL) {
- ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
- /* and if needed, init here */
- }
-
- if(ob->pd){
- ob->pd->deflect =0;
- ob->pd->forcefield =0;
- ob->pd->flag =0;
- ob->pd->pdef_damp =0;
- ob->pd->pdef_rdamp =0;
- ob->pd->pdef_perm =0;
- ob->pd->f_strength =0;
- ob->pd->f_power =0;
- ob->pd->maxdist =0;
- return 1;
- }
- else{
- return 0;
- }
+ Py_RETURN_NONE;
}
-/*
- * scan list of Objects looking for matching obdata.
- * if found, set OB_RECALC_DATA flag.
- * call this from a bpy type update() method.
- */
-
-void Object_updateDag( void *data )
+static PyObject *Object_SetSBUseGoal( BPy_Object * self, PyObject * args )
{
- Object *ob;
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setSBUseGoal );
+}
- if( !data)
- return;
+static PyObject *Object_SetSBUseEdges( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setSBUseEdges );
+}
- for( ob= G.main->object.first; ob; ob= ob->id.next){
- if( ob->data == data){
- ob->recalc |= OB_RECALC_DATA;
- }
- }
+static PyObject *Object_SetSBStiffQuads( BPy_Object * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (setter)Object_setSBStiffQuads );
}
diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py
index 9e69688c983..644b1a50a84 100644
--- a/source/blender/python/api2_2x/doc/Object.py
+++ b/source/blender/python/api2_2x/doc/Object.py
@@ -4,6 +4,8 @@
The Blender.Object submodule
B{New}:
+ - Addition of attributes for particle deflection, softbodies, and
+ rigidbodies.
- Objects now increment the Blender user count when they are created and
decremented it when they are destroyed. This means Python scripts can
keep the object "alive" if it is deleted in the Blender GUI.
@@ -32,6 +34,65 @@ Example::
ob.setLocation (0.0, -5.0, 1.0) # position the object in the scene
Blender.Redraw() # redraw the scene to show the updates.
+
+@type DrawModes: readonly dictionary
+@var DrawModes: Constant dict used for with L{Object.drawMode} bitfield
+ attribute. Values can be ORed together. Individual bits can also
+ be set/cleared with boolean attributes.
+ - AXIS: Enable display of active object's center and axis.
+ - TEXSPACE: Enable display of active object's texture space.
+ - NAME: Enable display of active object's name.
+ - WIRE: Enable the active object's wireframe over solid drawing.
+ - XRAY: Enable drawing the active object in front of others.
+ - TRANSP: Enable transparent materials for the active object (mesh only).
+
+@type DrawTypes: readonly dictionary
+@var DrawTypes: Constant dict used for with L{Object.drawType} attribute.
+ Only one type can be selected at a time.
+ - BOUNDBOX: Only draw object with bounding box
+ - WIRE: Draw object in wireframe
+ - SOLID: Draw object in solid
+ - SHADED: Draw object with shaded or textured
+
+@type ProtectFlags: readonly dictionary
+@var ProtectFlags: Constant dict used for with L{Object.protectFlags} attribute.
+ Values can be ORed together.
+ - LOCX, LOCY, LOCZ: lock x, y or z location individually
+ - ROTX, ROTY, ROTZ: lock x, y or z rotation individually
+ - SIZEX, SIZEY, SIZEZ: lock x, y or z size individually
+ - LOC, ROT, SIZE: lock all 3 attributes for location, rotation or size
+
+@type PITypes: readonly dictionary
+@var PITypes: Constant dict used for with L{Object.piType} attribute.
+ Only one type can be selected at a time.
+ - NONE: No force influence on particles
+ - FORCE: Object center attracts or repels particles ("Spherical")
+ - VORTEX: Particles swirl around Z-axis of the object
+ - WIND: Constant force applied in direction of object Z axis
+ - GUIDE: Use a Curve Path to guide particles
+
+@type RBFlags: readonly dictionary
+@var RBFlags: Constant dict used for with L{Object.rbFlags} attribute.
+ Values can be ORed together.
+ - SECTOR: All game elements should be in the Sector boundbox
+ - PROP: An Object fixed within a sector
+ - BOUNDS: Specify a bounds object for physics
+ - ACTOR: Enables objects that are evaluated by the engine
+ - DYNAMIC: Enables motion defined by laws of physics (requires ACTOR)
+ - GHOST: Enable objects that don't restitute collisions (requires ACTOR)
+ - MAINACTOR: Enables MainActor (requires ACTOR)
+ - RIGIDBODY: Enable rolling physics (requires ACTOR, DYNAMIC)
+ - COLLISION_RESPONSE: Disable auto (de)activation (requires ACTOR, DYNAMIC)
+ - USEFH: Use Fh settings in Materials (requires ACTOR, DYNAMIC)
+ - ROTFH: Use face normal to rotate Object (requires ACTOR, DYNAMIC)
+ - ANISOTROPIC: Enable anisotropic friction (requires ACTOR, DYNAMIC)
+ - CHILD: reserved
+
+@type RBShapes: readonly dictionary
+@var RBShapes: Constant dict used for with L{Object.rbShapeBoundType}
+ attribute. Only one type can be selected at a time. Values are
+ BOX, SPHERE, CYLINDER, CONE, and POLYHEDERON
+
"""
def New (type, name='type'):
@@ -43,7 +104,7 @@ def New (type, name='type'):
@type name: string
@param name: The name of the object. By default, the name will be the same
as the object type.
- If the name is already in use, this new object will have a number at the end of the name.
+ If the name is alredy in use, this new object will have a number at the end of the name.
@return: The created Object.
I{B{Example:}}
@@ -105,9 +166,9 @@ def GetSelected ():
objects = Blender.Object.GetSelected()
print objects
@note: The active object will always be the first object in the list (if selected).
- @note: The user selection is made up of selected objects from Blenders current scene only.
- @note: The user selection is limited to objects on visible layers,
- if the users last active 3d view is in localview then the selection will be limited to the objects in that localview.
+ @note: The user selection is made up of selected objects from Blender's current scene only.
+ @note: The user selection is limited to objects on visible layers;
+ if the user's last active 3d view is in localview then the selection will be limited to the objects in that localview.
"""
@@ -167,46 +228,68 @@ class Object:
This object gives access to generic data from all objects in Blender.
B{Note}:
- When dealing with properties and functions such as LocX/RotY/getLocation(), getSize() and getEuler()
- Keep in mind that these transformation properties are relative to the objects parent (if any).
+ When dealing with properties and functions such as LocX/RotY/getLocation(), getSize() and getEuler(),
+ keep in mind that these transformation properties are relative to the objects parent (if any).
To get these values in worldspace (taking into account vertex parents, constraints etc)
pass the argument 'worldspace' to these functions.
@ivar LocX: The X location coordinate of the object.
+ @type LocX: float
@ivar LocY: The Y location coordinate of the object.
+ @type LocY: float
@ivar LocZ: The Z location coordinate of the object.
- @ivar loc: The (X,Y,Z) location coordinates of the object (vector).
+ @type LocZ: float
+ @ivar loc: The (X,Y,Z) location coordinates of the object.
+ @type loc: tuple of 3 floats
@ivar dLocX: The delta X location coordinate of the object.
This variable applies to IPO Objects only.
+ @type dLocX: float
@ivar dLocY: The delta Y location coordinate of the object.
This variable applies to IPO Objects only.
+ @type dLocY: float
@ivar dLocZ: The delta Z location coordinate of the object.
This variable applies to IPO Objects only.
+ @type dLocZ: float
@ivar dloc: The delta (X,Y,Z) location coordinates of the object (vector).
This variable applies to IPO Objects only.
+ @type dloc: tuple of 3 floats
@ivar RotX: The X rotation angle (in radians) of the object.
+ @type RotX: float
@ivar RotY: The Y rotation angle (in radians) of the object.
+ @type RotY: float
@ivar RotZ: The Z rotation angle (in radians) of the object.
- @ivar rot: The (X,Y,Z) rotation angles (in radians) of the object (vector).
+ @type RotZ: float
+ @ivar rot: The (X,Y,Z) rotation angles (in radians) of the object.
+ @type rot: euler (Py_WRAPPED)
@ivar dRotX: The delta X rotation angle (in radians) of the object.
This variable applies to IPO Objects only.
+ @type dRotX: float
@ivar dRotY: The delta Y rotation angle (in radians) of the object.
This variable applies to IPO Objects only.
+ @type dRotY: float
@ivar dRotZ: The delta Z rotation angle (in radians) of the object.
This variable applies to IPO Objects only.
- @ivar drot: The delta (X,Y,Z) rotation angles (in radians) of the object
- (vector).
+ @type dRotZ: float
+ @ivar drot: The delta (X,Y,Z) rotation angles (in radians) of the object.
This variable applies to IPO Objects only.
+ @type drot: tuple of 3 floats
@ivar SizeX: The X size of the object.
+ @type SizeX: float
@ivar SizeY: The Y size of the object.
+ @type SizeY: float
@ivar SizeZ: The Z size of the object.
- @ivar size: The (X,Y,Z) size of the object (vector).
+ @type SizeZ: float
+ @ivar size: The (X,Y,Z) size of the object.
+ @type size: tuple of 3 floats
@ivar dSizeX: The delta X size of the object.
+ @type dSizeX: float
@ivar dSizeY: The delta Y size of the object.
+ @type dSizeY: float
@ivar dSizeZ: The delta Z size of the object.
+ @type dSizeZ: float
@ivar dsize: The delta (X,Y,Z) size of the object.
- @type Layers: integer (bitmask)
+ @type dsize: tuple of 3 floats
@ivar Layers: The object layers (also check the newer attribute
L{layers<layers>}). This value is a bitmask with at
least one position set for the 20 possible layers starting from the low
@@ -216,6 +299,7 @@ class Object:
ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 )
After setting the Layer value, call Blender.Redraw( -1 ) to update
the interface.
+ @type Layers: integer (bitmask)
@type layers: list of integers
@ivar layers: The layers this object is visible in (also check the older
attribute L{Layers<Layers>}). This returns a list of
@@ -231,51 +315,50 @@ class Object:
print ob.layers # will print: [1, 4, 10]
B{Note}: changes will only be visible after the screen (at least
the 3d View and Buttons windows) is redrawn.
- @ivar parent: The parent object of the object. (Read-only)
- @ivar track: The object tracking this object. (Read-only)
- @ivar type: The object type. (Read-only)
- @type type: string.
- @ivar data: The data of the object. (Read-only)
- @ivar ipo: The ipo data associated with the object. (Read-only)
- @ivar mat: alias for L{matrix<Object.Object.matrix>}: the matrix of the object in world space. (Read-only)
- @ivar matrix: The matrix of the object in world space, same as L{matrixWorld<Object.Object.matrixWorld>}. (Read-only)
- @ivar matrixLocal: The matrix of the object relative to its parent (or L{matrixWorld<Object.Object.matrixWorld>} if there is no parent). (Read-only)
- @ivar matrixWorld: The matrix of the object in world space. (Read-only)
+ @ivar parent: The parent object of the object (if defined). Read-only.
+ @type parent: Object or None
+ @ivar data: The Datablock object linked to this object. Read-only.
+ @type data: varies
+ @ivar ipo: Contains the Ipo if one is assigned to the object, B{None}
+ otherwise. Setting to B{None} clears the current Ipo.
+ @type ipo: Ipo
+ @ivar mat: The matrix of the object in world space (absolute, takes vertex parents, tracking
+ and Ipos into account). Read-only.
+ @type mat: Matrix
+ @ivar matrix: Same as L{mat}. Read-only.
+ @type matrix: Matrix
+ @ivar matrixLocal: The matrix of the object relative to its parent; if there is no parent,
+ returns the world matrix (L{matrixWorld<Object.Object.matrixWorld>}). Read-only.
+ @type matrixLocal: Matrix
+ @ivar matrixOldWorld: Old-type worldspace matrix (prior to Blender 2.34).
+ Read-only.
+ @type matrixOldWorld: Matrix
+ @ivar matrixWorld: Same as L{mat}. Read-only.
+ @type matrixWorld: Matrix
@ivar colbits: The Material usage mask. A set bit #n means: the Material
#n in the Object's material list is used. Otherwise, the Material #n
of the Objects Data material list is displayed.
Example::
object.colbits = (1<<0) + (1<<5) # use mesh materials 0 (1<<0) and 5 (1<<5)
# use object materials for all others
- @ivar drawType: The object's drawing type used. 1 - Bounding box,
- 2 - wire, 3 - Solid, 4- Shaded, 5 - Textured.
- @ivar drawMode: The object's drawing mode used. The value can be a sum
- of: 2 - axis, 4 - texspace, 8 - drawname, 16 - drawimage,
- 32 - drawwire, 64 - xray.
- @ivar name: The name of the object, 21 chars max.
- @ivar sel: The selection state of the object in the current scene, 1 is selected, 0 is unselected. (Selecting makes the object active)
- @ivar effects: The list of particle effects associated with the object. (Read-only)
- @ivar parentbonename: The string name of the parent bone.
- @ivar users: The number of users of the object. (Read-only)
- @type users: int
+ @ivar sel: The selection state of the object in the current scene.
+ True is selected, False is unselected. Setting makes the object active.
+ @type sel: boolean
+ @ivar effects: The list of particle effects associated with the object.
+ Read-only.
+ @type effects: list of Effect objects
+ @ivar parentbonename: The string name of the parent bone (if defined).
+ Read-only.
+ @type parentbonename: string or None
@ivar protectFlags: The "transform locking" bitfield flags for the object.
- Setting bits lock the following attributes:
- - bit 0: X location
- - bit 1: Y location
- - bit 2: Z location
- - bit 3: X rotation
- - bit 4: Y rotation
- - bit 5: Z rotation
- - bit 6: X size
- - bit 7: Y size
- - bit 8: Z size
+ See L{ProtectFlags} const dict for values.
@type protectFlags: int
- @ivar DupGroup: The DupliGroup Animation Property.
- Assign a group to DupGroup to make this object an instance of that group.
+ @ivar DupGroup: The DupliGroup Animation Property. Assign a group to
+ DupGroup to make this object an instance of that group.
This does not enable or disable the DupliGroup option, for that use
- getDupliGroup and setDupliGroup.
- The dupliGroup is None when this object does not have a dupliGroup.
- (Use with L{enableDupGroup<enableDupGroup>})
+ L{enableDupGroup}.
+ The attribute returns None when this object does not have a dupliGroup,
+ and setting the attrbute to None deletes the object from the group.
@type DupGroup: Group or None
@ivar DupObjects: The Dupli object instances. Read-only.
Returns of list of tuples for object duplicated
@@ -297,52 +380,186 @@ class Object:
Blender.Redraw()
@type DupObjects: list of tuples containing (object, matrix)
@ivar enableDupVerts: The DupliVerts status of the object.
- True/False - does not indicate that this object has any dupliVerts,
- (as returned by DupObjects) just that dupliVerts are enabled.
- @type enableDupVerts: bool (True/False)
+ Does not indicate that this object has any dupliVerts,
+ (as returned by L{DupObjects}) just that dupliVerts are enabled.
+ @type enableDupVerts: boolean
@ivar enableDupFrames: The DupliFrames status of the object.
- True/False - does not indicate that this object has any dupliFrames,
- (as returned by DupObjects) just that dupliFrames are enabled.
- @type enableDupFrames: bool (True/False)
+ Does not indicate that this object has any dupliFrames,
+ (as returned by L{DupObjects}) just that dupliFrames are enabled.
+ @type enableDupFrames: boolean
@ivar enableDupGroup: The DupliGroup status of the object.
- True/False - Set DupGroup to a group for this to take effect,
- Use DupObjects to get the object data from this instance. (Use with L{DupObjects<DupObjects>})
- @type enableDupGroup: bool (True/False)
- Set True to make this object an instance of the objects DupGroup.
+ Set True to make this object an instance of the object's L{DupGroup},
+ and set L{DupGroup} to a group for this to take effect,
+ Use L{DupObjects} to get the object data from this instance.
+ @type enableDupGroup: boolean
@ivar enableDupRot: The DupliRot status of the object.
- True/False - Use with enableDupVerts to rotate each instance
- by the vertex normal. (Use with L{enableDupVerts<enableDupVerts>})
- @type enableDupRot: bool (True/False)
+ Use with L{enableDupVerts} to rotate each instance
+ by the vertex normal.
+ @type enableDupRot: boolean
@ivar enableDupNoSpeed: The DupliNoSpeed status of the object.
- True/False - Use with enableDupFrames to ignore
- dupliFrame speed. (Use with L{enableDupFrames<enableDupFrames>})
- @type enableDupNoSpeed: bool (True/False)
- @ivar DupSta: The DupliFrame starting frame. (Use with L{enableDupFrames<enableDupFrames>})
+ Use with L{enableDupFrames} to ignore dupliFrame speed.
+ @type enableDupNoSpeed: boolean
+ @ivar DupSta: The DupliFrame starting frame. Use with L{enableDupFrames}.
+ Value clamped to [1,32767].
@type DupSta: int
- @ivar DupEnd: The DupliFrame end frame. (Use with L{enableDupFrames<enableDupFrames>})
+ @ivar DupEnd: The DupliFrame end frame. Use with L{enableDupFrames}.
+ Value clamped to [1,32767].
@type DupEnd: int
@ivar DupOn: The DupliFrames in succession between DupOff frames.
- (Use with L{enableDupFrames<enableDupFrames>} and L{DupOff<DupOff>} > 0)
+ Value is clamped to [1,1500].
+ Use with L{enableDupFrames} and L{DupOff} > 0.
@type DupOn: int
- @ivar DupOff: The DupliFrame removal of every Nth frame for this object. (Use with L{enableDupFrames<enableDupFrames>})
+ @ivar DupOff: The DupliFrame removal of every Nth frame for this object.
+ Use with L{enableDupFrames}. Value is clamped to [0,1500].
@type DupOff: int
- @ivar drawSize: The drawsize for empty objects. 1.0. is default.
+ @ivar drawSize: The size to display the Empty.
+ Value clamped to [0.01,10.0].
@type drawSize: float
- @type modifiers: BPy_Modifiers
- @ivar modifiers: a L{sequence<Modifier.Modifiers>} of
- L{modifiers<Modifier.Modifier>} for the object.
- @type constraints: BPy_Constraints
+ @ivar modifiers: The modifiers associated with the object. Read-only.
+ @type modifiers: L{Modifier Sequence<Modifier.Modifiers>}
@ivar constraints: a L{sequence<Constraint.Constraints>} of
- L{constraints<Constraint.Constraint>} for the object.
- @type rbMass: float
- @ivar rbMass: Rigid body mass. Must be a positive value.
+ L{constraints<Constraint.Constraint>} for the object. Read-only.
+ @type constraints: Constraint Sequence
+ @ivar actionStrips: a L{sequence<NLA.ActionStrips>} of
+ L{action strips<NLA.ActionStrip>} for the object. Read-only.
+ @type actionStrips: BPy_ActionStrips
+ @ivar action: The action associated with this object (if defined).
+ Read-only.
+ @type action: L{Action<NLA.Action>} or None
+ @ivar name: Object data name. Maximum length 20 characters.
+ @type name: string
+ @ivar oopsLoc: Object's (X,Y) OOPs location. Returns None if object
+ is not found in list.
+ @type oopsLoc: tuple of 2 floats
+ @ivar oopsSel: Object OOPs selection flag.
+ @type oopsSel: boolean
+ @ivar properties: The object's properties. Read-only.
+ @type properties: list of Properties.
+ @ivar timeOffset: The time offset of the object's animation.
+ Value clamped to [-300000.0,300000.0].
+ @type timeOffset: float
+ @ivar track: The object's tracked object. B{None} is returned if no
+ object is tracked. Also, assigning B{None} clear the tracked object.
+ @type track: Object or None
+ @ivar type: The object's type. Read-only.
+ @type type: string
+ @ivar users: The number of users of the object. Read-only.
+ @type users: int
+ @ivar boundingBox: The bounding box of this object. Read-only.
+ @type boundingBox: list of 8 3D vectors
+ @ivar drawType: The object's drawing type.
+ See L{DrawTypes} constant dict for values.
+ @type drawType: int
+ @ivar axis: Enable display of active object's center and axis.
+ Also see B{AXIS} bit in L{drawMode} attribute.
+ @type axis: boolean
+ @ivar texSpace: Enable display of active object's texture space.
+ Also see B{TEXSPACE} bit in L{drawMode} attribute.
+ @type texSpace: boolean
+ @ivar nameMode: Enable display of active object's name.
+ Also see B{NAME} bit in L{drawMode} attribute.
+ @type nameMode: boolean
+ @ivar wireMode: Enable the active object's wireframe over solid drawing.
+ Also see B{WIRE} bit in L{drawMode} attribute.
+ @type wireMode: boolean
+ @ivar xRay: Enable drawing the active object in front of others.
+ Also see B{XRAY} bit in L{drawMode} attribute.
+ @type xRay: boolean
+ @ivar transp: Enable transparent materials for the active object
+ (mesh only). Also see B{TRANSP} bit in L{drawMode} attribute.
+ @type transp: boolean
+ @ivar drawMode: The object's drawing mode bitfield.
+ See L{DrawModes} constant dict for values.
+ @type drawMode: int
+
+ @ivar piType: Type of particle interaction.
+ See L{PITypes} constant dict for values.
+ @type piType: int
+ @ivar piFalloff: The particle interaction falloff power.
+ Value clamped to [0.0,10.0].
+ @type piFalloff: float
+ @ivar piMaxDist: Max distance for the particle interaction field to work.
+ Value clamped to [0.0,1000.0].
+ @type piMaxDist: float
+ @ivar piPermeability: Probability that a particle will pass through the
+ mesh. Value clamped to [0.0,1.0].
+ @type piPermeability: float
+ @ivar piRandomDamp: Random variation of particle interaction damping.
+ Value clamped to [0.0,1.0].
+ @type piRandomDamp: float
+ @ivar piSoftbodyDamp: Damping factor for softbody deflection.
+ Value clamped to [0.0,1.0].
+ @type piSoftbodyDamp: float
+ @ivar piSoftbodyIThick: Inner face thickness for softbody deflection.
+ Value clamped to [0.001,1.0].
+ @type piSoftbodyIThick: float
+ @ivar piSoftbodyOThick: Outer face thickness for softbody deflection.
+ Value clamped to [0.001,1.0].
+ @type piSoftbodyOThick: float
+ @ivar piStrength: Particle interaction force field strength.
+ Value clamped to [0.0,1000.0].
+ @type piStrength: float
+ @ivar piSurfaceDamp: Amount of damping during particle collision.
+ Value clamped to [0.0,1.0].
+ @type piSurfaceDamp: float
+ @ivar piUseMaxDist: Use a maximum distance for the field to work.
+ @type piUseMaxDist: boolean
+
+ @ivar isSoftBody: True if object is a soft body. Read-only.
+ @type isSoftBody: boolean
+ @ivar SBDefaultGoal: Default softbody goal value, when no vertex group used.
+ Value clamped to [0.0,1.0].
+ @type SBDefaultGoal: float
+ @ivar SBErrorLimit: Softbody Runge-Kutta ODE solver error limit (low values give more precision).
+ Value clamped to [0.01,1.0].
+ @type SBErrorLimit: float
+ @ivar SBFriction: General media friction for softbody point movements.
+ Value clamped to [0.0,10.0].
+ @type SBFriction: float
+ @ivar SBGoalFriction: Softbody goal (vertex target position) friction.
+ Value clamped to [0.0,10.0].
+ @type SBGoalFriction: float
+ @ivar SBGoalSpring: Softbody goal (vertex target position) spring stiffness.
+ Value clamped to [0.0,0.999].
+ @type SBGoalSpring: float
+ @ivar SBGrav: Apply gravitation to softbody point movement.
+ Value clamped to [0.0,10.0].
+ @type SBGrav: float
+ @ivar SBInnerSpring: Softbody edge spring stiffness.
+ Value clamped to [0.0,0.999].
+ @type SBInnerSpring: float
+ @ivar SBInnerSpringFrict: Softbody edge spring friction.
+ Value clamped to [0.0,10.0].
+ @type SBInnerSpringFrict: float
+ @ivar SBMass: Softbody point mass (heavier is slower).
+ Value clamped to [0.001,50.0].
+ @type SBMass: float
+ @ivar SBMaxGoal: Softbody goal maximum (vertex group weights scaled to
+ match this range). Value clamped to [0.0,1.0].
+ @type SBMaxGoal: float
+ @ivar SBMinGoal: Softbody goal minimum (vertex group weights scaled to
+ match this range). Value clamped to [0.0,1.0].
+ @type SBMinGoal: float
+ @ivar SBSpeed: Tweak timing for physics to control softbody frequency and
+ speed. Value clamped to [0.0,10.0].
+ @type SBSpeed: float
+ @ivar SBStiffQuads: Softbody adds diagonal springs on 4-gons enabled.
+ @type SBStiffQuads: boolean
+ @ivar SBUseEdges: Softbody use edges as springs enabled.
+ @type SBUseEdges: boolean
+ @ivar SBUseGoal: Softbody forces for vertices to stick to animated position enabled.
+ @type SBUseGoal: boolean
+
+ @ivar rbFlags: Rigid body bitfield. See L{RBFlags} for valid values.
@type rbFlags: int
- @ivar rbFlags: Rigid body flags.
+ @ivar rbMass: Rigid body mass. Must be a positive value.
+ @type rbMass: float
+ @ivar rbRadius: Rigid body bounding sphere size. Must be a positive
+ value.
+ @type rbRadius: float
+ @ivar rbShapeBoundType: Rigid body shape bound type. See L{RBShapes}
+ const dict for values.
@type rbShapeBoundType: int
- @ivar rbShapeBoundType: Rigid body shape bound type.
- @type actionStrips: BPy_ActionStrips
- @ivar actionStrips: a L{sequence<NLA.ActionStrips>} of
- L{action strips<NLA.ActionStrip>} for the object.
"""
def buildParts():
@@ -391,12 +608,12 @@ class Object:
def getData(name_only=False, mesh=False):
"""
- Returns the Datablock object (Mesh, Lamp, Camera, etc.) linked to this Object.
- If the keyword parameter B{name_only} is True, only the Datablock
+ Returns the Datablock object (Mesh, Lamp, Camera, etc.) linked to this
+ Object. If the keyword parameter B{name_only} is True, only the Datablock
name is returned as a string. It the object is of type Mesh, then the
- B{mesh} keyword can also be used; if True the data return is a Mesh object,
- otherwise it is an NMesh object (the default).
- Using the B{mesh} keyword is ignored for non-mesh objects.
+ B{mesh} keyword can also be used; the data return is a Mesh object if
+ True, otherwise it is an NMesh object (the default).
+ The B{mesh} keyword is ignored for non-mesh objects.
@type name_only: bool
@param name_only: This is a keyword parameter. If True (or nonzero),
only the name of the data object is returned.
@@ -406,8 +623,7 @@ class Object:
@rtype: specific Object type or string
@return: Depends on the type of Datablock linked to the Object. If
B{name_only} is True, it returns a string.
- @note: For Mesh objects Mesh is faster then NMesh because Mesh is a thin
- wrapper.
+ @note: Mesh is faster than NMesh because Mesh is a thin wrapper.
@note: This function is different from L{NMesh.GetRaw} and L{Mesh.Get}
because it keeps a link to the original mesh, which is needed if you are
dealing with Mesh weight groups.
@@ -535,7 +751,7 @@ class Object:
- worldspace (default): absolute, taking vertex parents, tracking and
Ipo's into account;
- localspace: relative to the object's parent (returns worldspace
- matrix if the object doesn't have a parent);
+ matrix if the object doesn't have a parent);
- old_worldspace: old behavior, prior to Blender 2.34, where eventual
changes made by the script itself were not taken into account until
a redraw happened, either called by the script or upon its exit.
@@ -608,8 +824,9 @@ class Object:
def getType():
"""
Returns the type of the object in 'Armature', 'Camera', 'Curve', 'Lamp', 'Lattice',
- 'MBall', 'Mesh', 'Surf', 'Empty', 'Wave' (deprecated) or 'unknown' in exceptional cases.
+ 'Mball', 'Mesh', 'Surf', 'Empty', 'Wave' (deprecated) or 'unknown' in exceptional cases.
@return: The type of object.
+ @rtype: String
I{B{Example:}}
@@ -632,23 +849,20 @@ class Object:
def insertIpoKey(keytype):
"""
- Inserts keytype values in object ipo at curframe.
- Uses module constants such as Blender.Object.LOC
+ Inserts keytype values in object ipo at curframe. Uses module constants.
@type keytype: Integer
@param keytype:
-
- - LOC
- - ROT
- - SIZE
- - LOCROT
- - LOCROTSIZE
- - PI_STRENGTH
- - PI_FALLOFF
- - PI_PERM
- - PI_SURFACEDAMP
- - PI_RANDOMDAMP
-
- @return: py_none
+ -LOC
+ -ROT
+ -SIZE
+ -LOCROT
+ -LOCROTSIZE
+ -PI_STRENGTH
+ -PI_FALLOFF
+ -PI_PERM
+ -PI_SURFACEDAMP
+ -PI_RANDOMDAMP
+ @return: None
"""
def link(datablock):
@@ -684,21 +898,20 @@ class Object:
Uses the object as a base for all of the objects in the provided list to join into.
@type objects: Sequence of Blender Object
- @param objects: A list of objects matching the objects type.
- @note: Objects in the list will not be removed from the scene,
- to avoid overlapping data you may want to remove them manually after joining.
- @note: Join modifies the base objects data in place so that
- other objects are joined into it. no new object or data is created.
- @note: Join will only work for object types Mesh, Armature, Curve and Surface,
- an error will be raised if the object is not of this type.
- @note: objects in the list will be ignored if they to not match the base object.
- @note: The base object as all objects must be in the current scene to be joined.
- @note: this function will not work in background mode (no user interface)
- @note: An error in the join function input will raise a TypeError,
- otherwise an error in the data input will raise a RuntimeError,
- for situations where you don't have tight control on the data that is being joined,
- you should handle the RuntimeError error, letting the user know the data cant be joined.
- This an happen if the data is too large or one of the objects data has a shape key.
+ @param objects: A list of objects matching the object's type.
+ @note: Objects in the list will not be removed from the scene.
+ To avoid overlapping data you may want to remove them manually after joining.
+ @note: Join modifies the base object's data in place so that
+ other objects are joined into it. No new object or data is created.
+ @note: Join will only work for object types Mesh, Armature, Curve and Surface;
+ an excption will be raised if the object is not of these types.
+ @note: Objects in the list will be ignored if they to not match the base object.
+ @note: The base object must be in the current scene to be joined.
+ @note: This function will not work in background mode (no user interface).
+ @note: An error in the function input will raise a TypeError or AttributeError,
+ otherwise an error in the data input will raise a RuntimeError.
+ For situations where you don't have tight control on the data that is being joined,
+ you should handle the RuntimeError error, letting the user know the data can't be joined.
"""
def makeParentDeform(objects, noninverse = 0, fast = 0):
@@ -812,9 +1025,9 @@ class Object:
list element is either a Material or None. Also see L{colbits}.
@type materials: Materials list
@param materials: A list of Blender material objects.
- @note: Blender materials are assigned to the objects data by default.
- So unless you know the material is applied to the object or are changing the
- objects colbits then you need to look at the object datas materials.
+ @note: Materials are assigned to the object's data by default. Unless
+ you know the material is applied to the object or are changing the
+ object's L{colbits}, you need to look at the object data's materials.
"""
def setMatrix(matrix):
@@ -852,12 +1065,12 @@ class Object:
def shareFrom(object):
"""
- Link data of object specified in the argument with self. This works only
- if self and the object specified are of the same type.
+ Link data of a specified argument with this object. This works only
+ if both objects are of the same type.
@type object: Blender Object
@param object: A Blender Object of the same type.
- @note: This function is faster then using getData() and setData()
- because it skips making a python object from the objects data.
+ @note: This function is faster then using L{getData()} and setData()
+ because it skips making a Python object from the object's data.
"""
def select(boolean):
@@ -889,12 +1102,13 @@ class Object:
the "SubSurf" mode for a mesh:
Example::
- import Blender
- scene= Blender.Scene.GetCurrent()
- object= scene.getActiveObject()
- object.modifiers.append(Blender.Modifier.Type.SUBSURF)
- object.makeDisplayList()
- Blender.Window.RedrawAll()
+ import Blender
+
+ scene = Blender.Scene.GetCurrent()
+ object = scene.getActiveObject()
+ object.modifiers.append(Blender.Modifier.Type.SUBSURF)
+ object.makeDisplayList()
+ Blender.Window.RedrawAll()
If you try this example without the line to update the display list, the
object will disappear from the screen until you press "SubSurf".
@@ -1027,7 +1241,7 @@ class Object:
def setPIStrength(strength):
"""
- Set the the Object's Particle Interaction Strength.
+ Set the Object's Particle Interaction Strength.
Values between -1000.0 to 1000.0
@rtype: None
@type strength: float
@@ -1042,7 +1256,7 @@ class Object:
def setPIFalloff(falloff):
"""
- Set the the Object's Particle Interaction falloff.
+ Set the Object's Particle Interaction falloff.
Values between 0 to 10.0
@rtype: None
@type falloff: float
@@ -1057,7 +1271,7 @@ class Object:
def setPIMaxDist(MaxDist):
"""
- Set the the Object's Particle Interaction MaxDist.
+ Set the Object's Particle Interaction MaxDist.
Values between 0 to 1000.0
@rtype: None
@type MaxDist: float
@@ -1072,7 +1286,7 @@ class Object:
def setPIType(type):
"""
- Set the the Object's Particle Interaction type.
+ Set the Object's Particle Interaction type.
Use Module Constants
- NONE
- WIND
@@ -1092,7 +1306,7 @@ class Object:
def setPIUseMaxDist(status):
"""
- Set the the Object's Particle Interaction MaxDist.
+ Set the Object's Particle Interaction MaxDist.
0 = Off, 1 = on
@rtype: None
@type status: int
@@ -1107,7 +1321,7 @@ class Object:
def setPIDeflection(status):
"""
- Set the the Object's Particle Interaction Deflection Setting.
+ Set the Object's Particle Interaction Deflection Setting.
0 = Off, 1 = on
@rtype: None
@type status: int
@@ -1122,7 +1336,7 @@ class Object:
def setPIPerm(perm):
"""
- Set the the Object's Particle Interaction Permeability.
+ Set the Object's Particle Interaction Permeability.
Values between 0 to 10.0
@rtype: None
@type perm: float
@@ -1137,7 +1351,7 @@ class Object:
def setPIRandomDamp(damp):
"""
- Set the the Object's Particle Interaction RandomDamp.
+ Set the Object's Particle Interaction RandomDamp.
Values between 0 to 10.0
@rtype: None
@type damp: float
@@ -1152,7 +1366,7 @@ class Object:
def setPISurfaceDamp(damp):
"""
- Set the the Object's Particle Interaction SurfaceDamp.
+ Set the Object's Particle Interaction SurfaceDamp.
Values between 0 to 10.0
@rtype: None
@type damp: float
@@ -1167,7 +1381,7 @@ class Object:
def setSBMass(mass):
"""
- Set the the Object's SoftBody Mass.
+ Set the Object's SoftBody Mass.
Values between 0 to 50.0
@rtype: None
@type mass: float
@@ -1182,7 +1396,7 @@ class Object:
def setSBGravity(grav):
"""
- Set the the Object's SoftBody Gravity.
+ Set the Object's SoftBody Gravity.
Values between 0 to 10.0
@rtype: None
@type grav: float
@@ -1197,7 +1411,7 @@ class Object:
def setSBFriction(frict):
"""
- Set the the Object's SoftBody Friction.
+ Set the Object's SoftBody Friction.
Values between 0 to 10.0
@rtype: None
@type frict: float
@@ -1212,7 +1426,7 @@ class Object:
def setSBErrorLimit(err):
"""
- Set the the Object's SoftBody ErrorLimit.
+ Set the Object's SoftBody ErrorLimit.
Values between 0 to 1.0
@rtype: None
@type err: float
@@ -1227,7 +1441,7 @@ class Object:
def setSBGoalSpring(gs):
"""
- Set the the Object's SoftBody GoalSpring.
+ Set the Object's SoftBody GoalSpring.
Values between 0 to 0.999
@rtype: None
@type gs: float
@@ -1242,7 +1456,7 @@ class Object:
def setSBGoalFriction(gf):
"""
- Set the the Object's SoftBody GoalFriction.
+ Set the Object's SoftBody GoalFriction.
Values between 0 to 10.0
@rtype: None
@type gf: float
@@ -1257,7 +1471,7 @@ class Object:
def setSBMinGoal(mg):
"""
- Set the the Object's SoftBody MinGoal.
+ Set the Object's SoftBody MinGoal.
Values between 0 to 1.0
@rtype: None
@type mg: float
@@ -1272,7 +1486,7 @@ class Object:
def setSBMaxGoal(mg):
"""
- Set the the Object's SoftBody MaxGoal.
+ Set the Object's SoftBody MaxGoal.
Values between 0 to 1.0
@rtype: None
@type mg: float
@@ -1287,7 +1501,7 @@ class Object:
def setSBInnerSpring(sprr):
"""
- Set the the Object's SoftBody InnerSpring.
+ Set the Object's SoftBody InnerSpring.
Values between 0 to 0.999
@rtype: None
@type sprr: float
@@ -1302,7 +1516,7 @@ class Object:
def setSBInnerSpringFriction(sprf):
"""
- Set the the Object's SoftBody InnerSpringFriction.
+ Set the Object's SoftBody InnerSpringFriction.
Values between 0 to 10.0
@rtype: None
@type sprf: float
@@ -1317,7 +1531,7 @@ class Object:
def setSBDefaultGoal(goal):
"""
- Set the the Object's SoftBody DefaultGoal.
+ Set the Object's SoftBody DefaultGoal.
Values between 0 to 1.0
@rtype: None
@type goal: float
@@ -1326,8 +1540,8 @@ class Object:
def isSB():
"""
- Get if the Object's SoftBody is Enabled.
- @rtype: int
+ Returns the Object's SoftBody enabled state.
+ @rtype: boolean
"""
def getSBPostDef():
@@ -1420,13 +1634,13 @@ class Property:
@param name: The new name of the property
"""
- def getData ():
+ def getData():
"""
Get the data for this property.
@rtype: string, int, or float
"""
- def setData (data):
+ def setData(data):
"""
Set the data for this property.
@type data: string, int, or float
@@ -1443,3 +1657,65 @@ class Property:
Get the type for this property.
@rtype: string
"""
+
+ def insertPoseKey(action,chanName,actframe,curframe):
+ """
+ Inserts a key into Action.
+ @param action: action to copy poses from
+ @type action: L{Action<NLA.Action>} object
+ @param chanName: channel or bone name
+ @type chanName: string
+ @param actframe: frame to extract action from
+ @type actframe: int
+ @param curframe: frame at which to insert action key
+ @type curframe: int
+ """
+
+ def insertCurrentPoseKey(chanName,curframe):
+ """
+ Inserts a key into Action based on current pose.
+ @param chanName: channel or bone name
+ @type chanName: string
+ @param curframe: frame at which to insert action key
+ @type curframe: int
+ """
+
+ def insertMatrixKey(chanName,curframe):
+ """
+ Inserts a key into Action based on current/giventime object matrix.
+ @param chanName: channel or bone name
+ @type chanName: string
+ @param curframe: frame at which to insert action key
+ @type curframe: int
+ """
+
+ def bake_to_action():
+ """
+ Creates a new action with the information from object animations.
+ """
+
+ def setConstraintInfluenceForBone(boneName, constName, influence):
+ """
+ Sets a constraint influence for a certain bone in this (armature) object.
+ @param boneName: bone name
+ @type boneName: string
+ @param constName: constraint name
+ @type constName: string
+ @param influence: influence value
+ @type influence: float
+ """
+
+ def copyNLA(obj):
+ """
+ Copies all NLA strips from another object to this object.
+ @param obj: an object to copy NLA strips from.
+ @type obj: L{Object}
+ """
+
+ def convertActionToStrip():
+ """
+ Convert an object's action into an action strip.
+ @rtype: L{ActionStrips<NLA.ActionStrip>}
+ @return: the new action strip
+ """
+