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
diff options
context:
space:
mode:
authorStephen Swaney <sswaney@centurytel.net>2004-09-26 00:30:40 +0400
committerStephen Swaney <sswaney@centurytel.net>2004-09-26 00:30:40 +0400
commita509b8adc9b8952cdb395c69406e821f57a9a6c7 (patch)
tree7c0e3c7b81007acc6b3e268e59a6af5fcb4bd93f /source/blender/python/api2_2x
parentbd371ddb9ff947d4e598ad04af9402d89fa80d5e (diff)
Another round in the Great BPy Cleanup:
Run everything thru indent to cleanup spaces vs tabs. Clean up some of the comments by hand. BGL.c was not touched due to all that macro wackyness. There are no functional changes to the code. Pre-indent versions of source are tagged with tag bpy-cleanup-20040925 , just in case.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Armature.c813
-rw-r--r--source/blender/python/api2_2x/Armature.h12
-rw-r--r--source/blender/python/api2_2x/BGL.h127
-rw-r--r--source/blender/python/api2_2x/BezTriple.c397
-rw-r--r--source/blender/python/api2_2x/BezTriple.h15
-rw-r--r--source/blender/python/api2_2x/Blender.c549
-rw-r--r--source/blender/python/api2_2x/Blender.h3
-rw-r--r--source/blender/python/api2_2x/Bone.c2544
-rw-r--r--source/blender/python/api2_2x/Bone.h43
-rw-r--r--source/blender/python/api2_2x/Build.c381
-rw-r--r--source/blender/python/api2_2x/Build.h31
-rw-r--r--source/blender/python/api2_2x/Camera.c1139
-rw-r--r--source/blender/python/api2_2x/Camera.h5
-rw-r--r--source/blender/python/api2_2x/CurNurb.c352
-rw-r--r--source/blender/python/api2_2x/CurNurb.h38
-rw-r--r--source/blender/python/api2_2x/Curve.c1184
-rw-r--r--source/blender/python/api2_2x/Curve.h3
-rw-r--r--source/blender/python/api2_2x/Draw.c1182
-rw-r--r--source/blender/python/api2_2x/Draw.h43
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c4
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.h7
-rw-r--r--source/blender/python/api2_2x/Effect.c402
-rw-r--r--source/blender/python/api2_2x/Effect.h21
-rw-r--r--source/blender/python/api2_2x/Image.c694
-rw-r--r--source/blender/python/api2_2x/Image.h18
-rw-r--r--source/blender/python/api2_2x/Ipo.c2497
-rw-r--r--source/blender/python/api2_2x/Ipo.h13
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c655
-rw-r--r--source/blender/python/api2_2x/Ipocurve.h13
-rw-r--r--source/blender/python/api2_2x/Lamp.c1847
-rw-r--r--source/blender/python/api2_2x/Lamp.h3
-rw-r--r--source/blender/python/api2_2x/Lattice.c772
-rw-r--r--source/blender/python/api2_2x/Lattice.h212
-rw-r--r--source/blender/python/api2_2x/Library.c260
-rw-r--r--source/blender/python/api2_2x/MTex.c280
-rw-r--r--source/blender/python/api2_2x/MTex.h17
-rw-r--r--source/blender/python/api2_2x/Material.c2591
-rw-r--r--source/blender/python/api2_2x/Material.h29
-rw-r--r--source/blender/python/api2_2x/Mathutils.c1499
-rw-r--r--source/blender/python/api2_2x/Mathutils.h246
-rw-r--r--source/blender/python/api2_2x/Metaball.c1541
-rw-r--r--source/blender/python/api2_2x/Metaball.h206
-rw-r--r--source/blender/python/api2_2x/NLA.c560
-rw-r--r--source/blender/python/api2_2x/NLA.h18
-rw-r--r--source/blender/python/api2_2x/NMesh.c3012
-rw-r--r--source/blender/python/api2_2x/NMesh.h89
-rw-r--r--source/blender/python/api2_2x/Noise.c479
-rw-r--r--source/blender/python/api2_2x/Object.c3249
-rw-r--r--source/blender/python/api2_2x/Object.h16
-rw-r--r--source/blender/python/api2_2x/Particle.c1152
-rw-r--r--source/blender/python/api2_2x/Particle.h105
-rw-r--r--source/blender/python/api2_2x/Registry.c115
-rw-r--r--source/blender/python/api2_2x/Registry.h33
-rw-r--r--source/blender/python/api2_2x/Scene.c1112
-rw-r--r--source/blender/python/api2_2x/Scene.h20
-rw-r--r--source/blender/python/api2_2x/Sound.c476
-rw-r--r--source/blender/python/api2_2x/Sound.h15
-rw-r--r--source/blender/python/api2_2x/Sys.c311
-rw-r--r--source/blender/python/api2_2x/Sys.h3
-rw-r--r--source/blender/python/api2_2x/Text.c749
-rw-r--r--source/blender/python/api2_2x/Text.h3
-rw-r--r--source/blender/python/api2_2x/Texture.c2834
-rw-r--r--source/blender/python/api2_2x/Texture.h17
-rw-r--r--source/blender/python/api2_2x/Types.c113
-rw-r--r--source/blender/python/api2_2x/Types.h3
-rw-r--r--source/blender/python/api2_2x/Wave.c725
-rw-r--r--source/blender/python/api2_2x/Wave.h73
-rw-r--r--source/blender/python/api2_2x/Window.c1137
-rw-r--r--source/blender/python/api2_2x/Window.h3
-rw-r--r--source/blender/python/api2_2x/World.c750
-rw-r--r--source/blender/python/api2_2x/World.h199
-rw-r--r--source/blender/python/api2_2x/bpy_types.h118
-rw-r--r--source/blender/python/api2_2x/charRGBA.c431
-rw-r--r--source/blender/python/api2_2x/charRGBA.h11
-rw-r--r--source/blender/python/api2_2x/constant.c193
-rw-r--r--source/blender/python/api2_2x/constant.h10
-rw-r--r--source/blender/python/api2_2x/euler.c364
-rw-r--r--source/blender/python/api2_2x/euler.h22
-rw-r--r--source/blender/python/api2_2x/gen_utils.c371
-rw-r--r--source/blender/python/api2_2x/gen_utils.h54
-rw-r--r--source/blender/python/api2_2x/logic.c683
-rw-r--r--source/blender/python/api2_2x/logic.h29
-rw-r--r--source/blender/python/api2_2x/matrix.c1151
-rw-r--r--source/blender/python/api2_2x/matrix.h37
-rw-r--r--source/blender/python/api2_2x/modules.h194
-rw-r--r--source/blender/python/api2_2x/quat.c604
-rw-r--r--source/blender/python/api2_2x/quat.h29
-rw-r--r--source/blender/python/api2_2x/rgbTuple.c362
-rw-r--r--source/blender/python/api2_2x/rgbTuple.h14
-rw-r--r--source/blender/python/api2_2x/sceneRadio.c979
-rw-r--r--source/blender/python/api2_2x/sceneRadio.h19
-rw-r--r--source/blender/python/api2_2x/sceneRender.c2671
-rw-r--r--source/blender/python/api2_2x/sceneRender.h23
-rw-r--r--source/blender/python/api2_2x/vector.c779
-rw-r--r--source/blender/python/api2_2x/vector.h28
-rw-r--r--source/blender/python/api2_2x/windowTheme.c784
-rw-r--r--source/blender/python/api2_2x/windowTheme.h11
97 files changed, 25950 insertions, 24080 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index 9ad5fba0f1a..29875d3644e 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -47,165 +47,174 @@
#include "modules.h"
#include "Types.h"
-//--------------------------- Python API function prototypes for the Armature module-----------
-static PyObject *M_Armature_New (PyObject * self, PyObject * args);
-static PyObject *M_Armature_Get (PyObject * self, PyObject * args);
-//--------------------------- Python API Doc Strings for the Armature module----------------------
+//---------------- Python API function prototypes for the Armature module---
+static PyObject *M_Armature_New( PyObject * self, PyObject * args );
+static PyObject *M_Armature_Get( PyObject * self, PyObject * args );
+
+//------------- Python API Doc Strings for the Armature module-----------
static char M_Armature_doc[] = "The Blender Armature module\n\n\
This module provides control over **Armature Data** objects in Blender.\n";
-static char M_Armature_New_doc[] = "(name) - return a new Armature datablock of \n\
+static char M_Armature_New_doc[] =
+ "(name) - return a new Armature datablock of \n\
optional name 'name'.";
static char M_Armature_Get_doc[] =
- "(name) - return the armature with the name 'name', \
+ "(name) - return the armature with the name 'name', \
returns None if not found.\n If 'name' is not specified, it returns a list of all armatures in the\ncurrent scene.";
static char M_Armature_get_doc[] = "(name) - DEPRECATED. Use 'Get' instead. \
return the armature with the name 'name', returns None if not found.\n If 'name' is not specified, \
it returns a list of all armatures in the\ncurrent scene.";
-//----------------Python method structure definition for Blender.Armature module---------------
+
+//------Python method structure definition for Blender.Armature module-----
struct PyMethodDef M_Armature_methods[] = {
- {"New", (PyCFunction) M_Armature_New, METH_VARARGS, M_Armature_New_doc},
- {"Get", M_Armature_Get, METH_VARARGS, M_Armature_Get_doc},
- {"get", M_Armature_Get, METH_VARARGS, M_Armature_get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Armature_New, METH_VARARGS,
+ M_Armature_New_doc},
+ {"Get", M_Armature_Get, METH_VARARGS, M_Armature_Get_doc},
+ {"get", M_Armature_Get, METH_VARARGS, M_Armature_get_doc},
+ {NULL, NULL, 0, NULL}
};
-//----------------Python BPy_Armature methods declarations--------------------------------------------
-static PyObject *Armature_getName (BPy_Armature * self);
-static PyObject *Armature_getBones (BPy_Armature * self);
-static PyObject *Armature_addBone(BPy_Armature *self, PyObject *args);
-static PyObject *Armature_setName (BPy_Armature * self, PyObject * args);
-static PyObject *Armature_drawAxes (BPy_Armature * self, PyObject * args);
-static PyObject *Armature_drawNames (BPy_Armature * self, PyObject * args);
-//----------------Python BPy_Armature methods table---------------------------------------------------
+//--------Python BPy_Armature methods declarations----------------------------
+static PyObject *Armature_getName( BPy_Armature * self );
+static PyObject *Armature_getBones( BPy_Armature * self );
+static PyObject *Armature_addBone( BPy_Armature * self, PyObject * args );
+static PyObject *Armature_setName( BPy_Armature * self, PyObject * args );
+static PyObject *Armature_drawAxes( BPy_Armature * self, PyObject * args );
+static PyObject *Armature_drawNames( BPy_Armature * self, PyObject * args );
+//----------------Python BPy_Armature methods table---------------------------
static PyMethodDef BPy_Armature_methods[] = {
- {"getName", (PyCFunction) Armature_getName, METH_NOARGS,
- "() - return Armature name"},
- {"getBones", (PyCFunction) Armature_getBones, METH_NOARGS,
- "() - return Armature root bones"},
- {"setName", (PyCFunction) Armature_setName, METH_VARARGS,
- "(str) - rename Armature"},
- {"addBone", (PyCFunction)Armature_addBone, METH_VARARGS,
- "(bone)-add bone"},
- {"drawAxes", (PyCFunction)Armature_drawAxes, METH_VARARGS,
- "will draw the axis of each bone in armature"},
- {"drawNames", (PyCFunction)Armature_drawNames, METH_VARARGS,
- "will draw the names of each bone in armature"},
- {NULL, NULL, 0, NULL}
+ {"getName", ( PyCFunction ) Armature_getName, METH_NOARGS,
+ "() - return Armature name"},
+ {"getBones", ( PyCFunction ) Armature_getBones, METH_NOARGS,
+ "() - return Armature root bones"},
+ {"setName", ( PyCFunction ) Armature_setName, METH_VARARGS,
+ "(str) - rename Armature"},
+ {"addBone", ( PyCFunction ) Armature_addBone, METH_VARARGS,
+ "(bone)-add bone"},
+ {"drawAxes", ( PyCFunction ) Armature_drawAxes, METH_VARARGS,
+ "will draw the axis of each bone in armature"},
+ {"drawNames", ( PyCFunction ) Armature_drawNames, METH_VARARGS,
+ "will draw the names of each bone in armature"},
+ {NULL, NULL, 0, NULL}
};
-//----------------Python TypeArmature callback function prototypes------------------------------
-static void Armature_dealloc (BPy_Armature * armature);
-static PyObject *Armature_getAttr (BPy_Armature * armature, char *name);
-static int Armature_setAttr (BPy_Armature * armature, char *name, PyObject * v);
-static int Armature_compare (BPy_Armature * a1, BPy_Armature * a2);
-static PyObject *Armature_repr (BPy_Armature * armature);
-static int doesBoneName_exist(char *name, bArmature* arm);
-//---------------- Python TypeArmature structure definition:-------------------------------------------
+
+//----------------Python TypeArmature callback function prototypes-----------
+static void Armature_dealloc( BPy_Armature * armature );
+static PyObject *Armature_getAttr( BPy_Armature * armature, char *name );
+static int Armature_setAttr( BPy_Armature * armature, char *name,
+ PyObject * v );
+static int Armature_compare( BPy_Armature * a1, BPy_Armature * a2 );
+static PyObject *Armature_repr( BPy_Armature * armature );
+static int doesBoneName_exist( char *name, bArmature * arm );
+
+//---------------- Python TypeArmature structure definition:-----------
PyTypeObject Armature_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Armature", /* tp_name */
- sizeof (BPy_Armature), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) Armature_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Armature_getAttr, /* tp_getattr */
- (setattrfunc) Armature_setAttr, /* tp_setattr */
- (cmpfunc) Armature_compare, /* tp_compare */
- (reprfunc) Armature_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_Armature_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Armature", /* tp_name */
+ sizeof( BPy_Armature ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Armature_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Armature_getAttr, /* tp_getattr */
+ ( setattrfunc ) Armature_setAttr, /* tp_setattr */
+ ( cmpfunc ) Armature_compare, /* tp_compare */
+ ( reprfunc ) Armature_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_Armature_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//-------------------Blender Armature Module Init------------------------------------------------------
-PyObject *
-Armature_Init (void)
+//-------------------Blender Armature Module Init-----------------
+PyObject *Armature_Init( void )
{
- PyObject *submodule;
- PyObject *dict;
+ PyObject *submodule;
+ PyObject *dict;
- Armature_Type.ob_type = &PyType_Type;
+ Armature_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Armature",
- M_Armature_methods, M_Armature_doc);
+ submodule = Py_InitModule3( "Blender.Armature",
+ M_Armature_methods, M_Armature_doc );
- /* Add the Bone submodule to this module */
- dict = PyModule_GetDict (submodule);
- PyDict_SetItemString (dict, "Bone", Bone_Init ());
- PyDict_SetItemString (dict, "NLA", NLA_Init ());
+ /* Add the Bone submodule to this module */
+ dict = PyModule_GetDict( submodule );
+ PyDict_SetItemString( dict, "Bone", Bone_Init( ) );
+ PyDict_SetItemString( dict, "NLA", NLA_Init( ) );
- return (submodule);
+ return ( submodule );
}
-//--------------------------Blender Armature Module internal callbacks------------------------------
-//------------------append_childrenToList-------------------------------------------------------------------
-static void
-append_childrenToList(Bone *parent, PyObject *listbones)
+
+//----------------------Blender Armature Module internal callbacks----
+
+//------------------append_childrenToList-----------------------------------
+static void append_childrenToList( Bone * parent, PyObject * listbones )
{
Bone *child = NULL;
//append children
- for(child = parent->childbase.first; child; child = child->next){
- PyList_Append (listbones, Bone_CreatePyObject (child));
- if(child->childbase.first){ //has children?
- append_childrenToList(child, listbones);
+ for( child = parent->childbase.first; child; child = child->next ) {
+ PyList_Append( listbones, Bone_CreatePyObject( child ) );
+ if( child->childbase.first ) { //has children?
+ append_childrenToList( child, listbones );
}
}
}
-//------------------unique_BoneName----------------------------------------------------------------------
-static void
-unique_BoneName(char *name, bArmature* arm)
+
+//------------------unique_BoneName----------------------------
+static void unique_BoneName( char *name, bArmature * arm )
{
- char tempname[64];
- int number;
- char *dot;
-
- if (doesBoneName_exist(name, arm)){
- /* Strip off the suffix */
- dot=strchr(name, '.');
- if (dot)
- *dot=0;
-
- for (number = 1; number <=999; number++){
- sprintf (tempname, "%s.%03d", name, number);
- if (!doesBoneName_exist(tempname, arm)){
- strcpy (name, tempname);
- return;
+ char tempname[64];
+ int number;
+ char *dot;
+
+ if( doesBoneName_exist( name, arm ) ) {
+ /* Strip off the suffix */
+ dot = strchr( name, '.' );
+ if( dot )
+ *dot = 0;
+
+ for( number = 1; number <= 999; number++ ) {
+ sprintf( tempname, "%s.%03d", name, number );
+ if( !doesBoneName_exist( tempname, arm ) ) {
+ strcpy( name, tempname );
+ return;
+ }
}
}
- }
}
-//------------------doesBoneName_exist----------------------------------------------------------------------
-static int
-doesBoneName_exist(char *name, bArmature* arm)
+
+//------------------doesBoneName_exist----------------------------
+static int doesBoneName_exist( char *name, bArmature * arm )
{
- Bone *parent = NULL;
- Bone *child = NULL;
-
- for (parent = arm->bonebase.first; parent; parent = parent->next){
- if (!strcmp (name, parent->name))
- return 1;
- for (child = parent->childbase.first; child; child = child->next){
- if (!strcmp (name, child->name))
- return 1;
+ Bone *parent = NULL;
+ Bone *child = NULL;
+
+ for( parent = arm->bonebase.first; parent; parent = parent->next ) {
+ if( !strcmp( name, parent->name ) )
+ return 1;
+ for( child = parent->childbase.first; child;
+ child = child->next ) {
+ if( !strcmp( name, child->name ) )
+ return 1;
+ }
}
- }
- return 0;
+ return 0;
}
-//------------------testChildInChildbase----------------------------------------------------------------------
-static int
-testChildInChildbase(Bone *bone, Bone *test)
+
+//------------------testChildInChildbase--------------------------
+static int testChildInChildbase( Bone * bone, Bone * test )
{
Bone *child;
- for(child = bone->childbase.first; child; child = child->next){
- if(child == test){
+ for( child = bone->childbase.first; child; child = child->next ) {
+ if( child == test ) {
return 1;
- }else{
- if(child->childbase.first != NULL){
- if(testChildInChildbase(child, test)){
+ } else {
+ if( child->childbase.first != NULL ) {
+ if( testChildInChildbase( child, test ) ) {
return 1;
}
}
@@ -213,17 +222,17 @@ testChildInChildbase(Bone *bone, Bone *test)
}
return 0;
}
-//------------------testBoneInArmature----------------------------------------------------------------------
-static int
-testBoneInArmature(bArmature *arm, Bone *test)
+
+//------------------testBoneInArmature-----------------------------
+static int testBoneInArmature( bArmature * arm, Bone * test )
{
Bone *root;
- for(root = arm->bonebase.first; root; root = root->next){
- if(root == test){
+ for( root = arm->bonebase.first; root; root = root->next ) {
+ if( root == test ) {
return 1;
- }else{
- if(root->childbase.first != NULL){
- if(testChildInChildbase(root, test)){
+ } else {
+ if( root->childbase.first != NULL ) {
+ if( testChildInChildbase( root, test ) ) {
return 1;
}
}
@@ -231,413 +240,435 @@ testBoneInArmature(bArmature *arm, Bone *test)
}
return 0;
}
-//-----------------testChildNameInChildbase------------------------------------------------------------------
-static Bone *
-testChildNameInChildbase(Bone *bone, char *name)
+
+//-----------------testChildNameInChildbase--------------------------
+static Bone *testChildNameInChildbase( Bone * bone, char *name )
{
Bone *child;
Bone *test;
- for(child = bone->childbase.first; child; child = child->next){
- if(BLI_streq(child->name, name)){
+ for( child = bone->childbase.first; child; child = child->next ) {
+ if( BLI_streq( child->name, name ) ) {
return child;
- }else{
- if(child->childbase.first != NULL){
- test = testChildNameInChildbase(child, name);
- if(test) return test;
+ } else {
+ if( child->childbase.first != NULL ) {
+ test = testChildNameInChildbase( child, name );
+ if( test )
+ return test;
}
}
}
return NULL;
}
-//----------------testBoneNameInArmature------------------------------------------------------------------
-static Bone *
-testBoneNameInArmature(bArmature *arm, char *name)
+
+//----------------testBoneNameInArmature----------------------------
+static Bone *testBoneNameInArmature( bArmature * arm, char *name )
{
Bone *bone;
Bone *test;
- for(bone = arm->bonebase.first; bone; bone = bone->next){
- if(BLI_streq(bone->name, name)){
- return bone; //found it
- }else{
- if(bone->childbase.first != NULL){
- test = testChildNameInChildbase(bone, name);
- if(test) return test;
+ for( bone = arm->bonebase.first; bone; bone = bone->next ) {
+ if( BLI_streq( bone->name, name ) ) {
+ return bone; //found it
+ } else {
+ if( bone->childbase.first != NULL ) {
+ test = testChildNameInChildbase( bone, name );
+ if( test )
+ return test;
}
}
}
return NULL;
}
-//-------------------BPy_Armature internal methods--------------------------------------------------
-//------------------dealloc--------------------------------------------------------------------------------------
-static void
-Armature_dealloc (BPy_Armature * self)
+
+//-------------------BPy_Armature internal methods------------------
+
+//------------------dealloc-----------------------------------------
+static void Armature_dealloc( BPy_Armature * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-//-----------------getattr-----------------------------------------------------------------------------------------
-static PyObject *
-Armature_getAttr (BPy_Armature * self, char *name)
+
+//-----------------getattr--------------------------------------------
+static PyObject *Armature_getAttr( BPy_Armature * self, char *name )
{
- PyObject *attr = Py_None;
-
- if (strcmp (name, "name") == 0)
- attr = Armature_getName (self);
- if (strcmp (name, "bones") == 0)
- attr = Armature_getBones (self);
- else if (strcmp (name, "__members__") == 0)
- {
- /* 2 entries */
- attr = Py_BuildValue ("[s,s]", "name", "bones");
- }
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None)
- return attr; /* member attribute found, return it */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod (BPy_Armature_methods, (PyObject *) self, name);
+ PyObject *attr = Py_None;
+
+ if( strcmp( name, "name" ) == 0 )
+ attr = Armature_getName( self );
+ if( strcmp( name, "bones" ) == 0 )
+ attr = Armature_getBones( self );
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ /* 2 entries */
+ attr = Py_BuildValue( "[s,s]", "name", "bones" );
+ }
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Armature_methods, ( PyObject * ) self,
+ name );
}
-//-----------------setattr-----------------------------------------------------------------------------------------
+
+//-----------------setattr--------------------------------------------
static int
-Armature_setAttr (BPy_Armature * self, char *name, PyObject * value)
+Armature_setAttr( BPy_Armature * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
- valtuple = Py_BuildValue ("(O)", value); /*the set* functions expect a tuple */
+ valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "ArmatureSetAttr: couldn't create tuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "ArmatureSetAttr: couldn't create tuple" );
- if (strcmp (name, "name") == 0)
- error = Armature_setName (self, valtuple);
- else
- { /* Error */
- Py_DECREF (valtuple);
+ if( strcmp( name, "name" ) == 0 )
+ error = Armature_setName( self, valtuple );
+ else { /* Error */
+ Py_DECREF( valtuple );
- /* ... member with the given name was found */
- return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
- }
+ /* ... member with the given name was found */
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
+ }
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None)
- return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF (Py_None); /* was incref'ed by the called Armature_set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* was incref'ed by the called Armature_set* function */
+ return 0; /* normal exit */
}
-//-----------------repr-----------------------------------------------------------------------------------------
-static PyObject *
-Armature_repr (BPy_Armature * self)
+
+//-----------------repr-----------------------------------------------
+static PyObject *Armature_repr( BPy_Armature * self )
{
- return PyString_FromFormat ("[Armature \"%s\"]",
- self->armature->id.name + 2);
+ return PyString_FromFormat( "[Armature \"%s\"]",
+ self->armature->id.name + 2 );
}
-//-----------------compare-----------------------------------------------------------------------------------------
-static int
-Armature_compare (BPy_Armature * a, BPy_Armature * b)
+
+//-----------------compare--------------------------------------------
+static int Armature_compare( BPy_Armature * a, BPy_Armature * b )
{
- bArmature *pa = a->armature, *pb = b->armature;
- return (pa == pb) ? 0 : -1;
+ bArmature *pa = a->armature, *pb = b->armature;
+ return ( pa == pb ) ? 0 : -1;
}
-//-----------------Armature_CreatePyObject-------------------------------------------------------------------
-PyObject *
-Armature_CreatePyObject (struct bArmature * obj)
+
+//-----------------Armature_CreatePyObject----------------------------
+PyObject *Armature_CreatePyObject( struct bArmature * obj )
{
- BPy_Armature *blen_armature;
+ BPy_Armature *blen_armature;
- blen_armature =
- (BPy_Armature *) PyObject_NEW (BPy_Armature, &Armature_Type);
+ blen_armature =
+ ( BPy_Armature * ) PyObject_NEW( BPy_Armature,
+ &Armature_Type );
- if (blen_armature == NULL)
- {
- return (NULL);
- }
- blen_armature->armature = obj;
+ if( blen_armature == NULL ) {
+ return ( NULL );
+ }
+ blen_armature->armature = obj;
- return ((PyObject *) blen_armature);
+ return ( ( PyObject * ) blen_armature );
}
-//-----------------Armature_CheckPyObject -------------------------------------------------------------------
-int
-Armature_CheckPyObject (PyObject * py_obj)
+
+//-----------------Armature_CheckPyObject ----------------------------
+int Armature_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Armature_Type);
+ return ( py_obj->ob_type == &Armature_Type );
}
-//-----------------Armature_FromPyObject -------------------------------------------------------------------
-struct bArmature *
-Armature_FromPyObject (PyObject * py_obj)
+
+//-----------------Armature_FromPyObject -----------------------------
+struct bArmature *Armature_FromPyObject( PyObject * py_obj )
{
- BPy_Armature *blen_obj;
+ BPy_Armature *blen_obj;
- blen_obj = (BPy_Armature *) py_obj;
- return (blen_obj->armature);
+ blen_obj = ( BPy_Armature * ) py_obj;
+ return ( blen_obj->armature );
}
-//-----------------Blender Module function prototypes-------------------------------------------------
-//----------------Blender.Armature.New()-------------------------------------------------------------------
-static PyObject *
-M_Armature_New (PyObject * self, PyObject * args)
+
+//-----------------Blender Module function prototypes-----------------
+
+//----------------Blender.Armature.New()------------------------------
+static PyObject *M_Armature_New( PyObject * self, PyObject * args )
{
- char *name_str = "ArmatureData";
- BPy_Armature *py_armature; /* for Armature Data object wrapper in Python */
- bArmature *bl_armature; /* for actual Armature Data we create in Blender */
- char buf[21];
-
- if (!PyArg_ParseTuple(args, "|s", &name_str))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string or empty argument"));
-
- bl_armature = add_armature(); /* first create in Blender */
-
- if (bl_armature){
- /* return user count to zero because add_armature() inc'd it */
- bl_armature->id.us = 0;
- /* now create the wrapper obj in Python */
- py_armature = (BPy_Armature *)PyObject_NEW(BPy_Armature, &Armature_Type);
- }else{
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Armature Data in Blender"));
- }
-
- if (py_armature == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create ArmaturePyObject"));
-
- /* link Python armature wrapper with Blender Armature: */
- py_armature->armature = bl_armature;
-
- if (strcmp(name_str, "ArmatureData") == 0)
- return (PyObject *)py_armature;
- else { /* user gave us a name for the armature, use it */
- PyOS_snprintf(buf, sizeof(buf), "%s", name_str);
- rename_id(&bl_armature->id, buf);
- }
-
- return (PyObject *)py_armature;
+ char *name_str = "ArmatureData";
+ BPy_Armature *py_armature; /* for Armature Data object wrapper in Python */
+ bArmature *bl_armature; /* for actual Armature Data we create in Blender */
+ char buf[21];
+
+ if( !PyArg_ParseTuple( args, "|s", &name_str ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string or empty argument" ) );
+
+ bl_armature = add_armature( ); /* first create in Blender */
+
+ if( bl_armature ) {
+ /* return user count to zero because add_armature() inc'd it */
+ bl_armature->id.us = 0;
+ /* now create the wrapper obj in Python */
+ py_armature =
+ ( BPy_Armature * ) PyObject_NEW( BPy_Armature,
+ &Armature_Type );
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Armature Data in Blender" ) );
+ }
+
+ if( py_armature == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create ArmaturePyObject" ) );
+
+ /* link Python armature wrapper with Blender Armature: */
+ py_armature->armature = bl_armature;
+
+ if( strcmp( name_str, "ArmatureData" ) == 0 )
+ return ( PyObject * ) py_armature;
+ else { /* user gave us a name for the armature, use it */
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name_str );
+ rename_id( &bl_armature->id, buf );
+ }
+
+ return ( PyObject * ) py_armature;
}
-//----------------Blender.Armature.Get()-------------------------------------------------------------------
-static PyObject *
-M_Armature_Get (PyObject * self, PyObject * args)
+
+//----------------Blender.Armature.Get()------------------------------
+static PyObject *M_Armature_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
bArmature *armature_iter;
BPy_Armature *wanted_armature;
- if (!PyArg_ParseTuple (args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
armature_iter = G.main->armature.first;
/* Use the name to search for the armature requested. */
- if (name){ /* (name) - Search armature by name */
+ if( name ) { /* (name) - Search armature by name */
wanted_armature = NULL;
- while ((armature_iter) && (wanted_armature == NULL)){
- if (strcmp (name, armature_iter->id.name + 2) == 0) {
+ while( ( armature_iter ) && ( wanted_armature == NULL ) ) {
+ if( strcmp( name, armature_iter->id.name + 2 ) == 0 ) {
wanted_armature =
- (BPy_Armature *) PyObject_NEW (BPy_Armature, &Armature_Type);
- if (wanted_armature)
- wanted_armature->armature = armature_iter;
+ ( BPy_Armature * )
+ PyObject_NEW( BPy_Armature,
+ &Armature_Type );
+ if( wanted_armature )
+ wanted_armature->armature =
+ armature_iter;
}
armature_iter = armature_iter->id.next;
}
- if (wanted_armature == NULL){ /* Requested Armature doesn't exist */
+ if( wanted_armature == NULL ) { /* Requested Armature doesn't exist */
char error_msg[64];
- PyOS_snprintf (error_msg, sizeof (error_msg),
- "Armature \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Armature \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
- return (PyObject *) wanted_armature;
- }else{
+ return ( PyObject * ) wanted_armature;
+ } else {
/* Return a list of with armatures in the scene */
int index = 0;
PyObject *armlist, *pyobj;
- armlist = PyList_New (BLI_countlist (&(G.main->armature)));
+ armlist = PyList_New( BLI_countlist( &( G.main->armature ) ) );
- if (armlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( armlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (armature_iter){
- pyobj = Armature_CreatePyObject (armature_iter);
+ while( armature_iter ) {
+ pyobj = Armature_CreatePyObject( armature_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- PyList_SET_ITEM (armlist, index, pyobj);
+ PyList_SET_ITEM( armlist, index, pyobj );
armature_iter = armature_iter->id.next;
index++;
}
- return (armlist);
+ return ( armlist );
}
}
-//--------------------------Python BPy_Armature methods------------------------------------------
-//---------------------BPy_Armature.getName()-------------------------------------------------------
-static PyObject *
-Armature_getName (BPy_Armature * self)
+
+//--------------------------Python BPy_Armature methods---------------
+
+//---------------------BPy_Armature.getName()-------------------------
+static PyObject *Armature_getName( BPy_Armature * self )
{
- PyObject *attr = PyString_FromString (self->armature->id.name + 2);
+ PyObject *attr = PyString_FromString( self->armature->id.name + 2 );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Armature.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Armature.name attribute" ) );
}
-//---------------------BPy_Armature.getBones()-------------------------------------------------------
-static PyObject *
-Armature_getBones (BPy_Armature * self)
+
+//---------------------BPy_Armature.getBones()------------------------
+static PyObject *Armature_getBones( BPy_Armature * self )
{
- PyObject *listbones = NULL;
- Bone *parent = NULL;
-
- listbones = PyList_New(0);
+ PyObject *listbones = NULL;
+ Bone *parent = NULL;
- //append root bones
- for (parent = self->armature->bonebase.first; parent; parent = parent->next){
- PyList_Append (listbones, Bone_CreatePyObject (parent));
- if(parent->childbase.first){ //has children?
- append_childrenToList(parent, listbones);
- }
- }
+ listbones = PyList_New( 0 );
- return listbones;
+ //append root bones
+ for( parent = self->armature->bonebase.first; parent;
+ parent = parent->next ) {
+ PyList_Append( listbones, Bone_CreatePyObject( parent ) );
+ if( parent->childbase.first ) { //has children?
+ append_childrenToList( parent, listbones );
+ }
+ }
+
+ return listbones;
}
-//---------------------BPy_Armature.addBone()-------------------------------------------------------
-static PyObject *Armature_addBone(BPy_Armature *self, PyObject *args)
+
+//---------------------BPy_Armature.addBone()-------------------------
+static PyObject *Armature_addBone( BPy_Armature * self, PyObject * args )
{
- BPy_Bone* py_bone = NULL;
+ BPy_Bone *py_bone = NULL;
float M_boneObjectspace[4][4];
float iM_parentRest[4][4];
Bone *blen_bone;
char *parent_str = "";
Bone *parent;
-
- if (!PyArg_ParseTuple(args, "O!", &Bone_Type, &py_bone))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected bone object argument (or nothing)"));
- if(py_bone->bone != NULL)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "this bone has already been linked to an armature");
+ if( !PyArg_ParseTuple( args, "O!", &Bone_Type, &py_bone ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected bone object argument (or nothing)" ) );
+
+ if( py_bone->bone != NULL )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this bone has already been linked to an armature" );
- //check to see if we can parent this bone if it will be attempted otherwise exit
- if(!BLI_streq(py_bone->parent, parent_str)){ //parenting being attempted
+ //check to see if we can parent this bone if it will be attempted
+ //otherwise exit
+ if( !BLI_streq( py_bone->parent, parent_str ) ) { //parenting being attempted
//get parent if exists in this armature
- parent = testBoneNameInArmature(self->armature, py_bone->parent);
- if(!parent){ //could find the parent's name
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "cannot find parent's name in armature - check to see if name of parent is correct"));
+ parent = testBoneNameInArmature( self->armature,
+ py_bone->parent );
+ if( !parent ) { //could find the parent's name
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "cannot find parent's name in armature - check to see if name of parent is correct" ) );
}
- }else{ //no parent for this bone
+ } else { //no parent for this bone
parent = NULL;
}
//create a bone struct
- blen_bone = (Bone*)MEM_callocN(sizeof(Bone), "DefaultBone");
+ blen_bone = ( Bone * ) MEM_callocN( sizeof( Bone ), "DefaultBone" );
//set the bone struct pointer
py_bone->bone = blen_bone;
//update the bonestruct data from py data
- if(!updateBoneData(py_bone, parent))
- return EXPP_ReturnPyObjError (PyExc_AttributeError , "bone struct empty");
+ if( !updateBoneData( py_bone, parent ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "bone struct empty" );
//make sure the name is unique for this armature
- unique_BoneName(py_bone->bone->name, self->armature);
+ unique_BoneName( py_bone->bone->name, self->armature );
- //if bone has a parent....
- if(py_bone->bone->parent){
+ //if bone has a parent....
+ if( py_bone->bone->parent ) {
//then check to see if parent has been added to the armature - bone loop test
- if(!testBoneInArmature(self->armature, py_bone->bone->parent))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "cannot parent to a bone not yet added to armature!"));
-
+ if( !testBoneInArmature
+ ( self->armature, py_bone->bone->parent ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "cannot parent to a bone not yet added to armature!" ) );
+
//add to parent's childbase
- BLI_addtail (&py_bone->bone->parent->childbase, py_bone->bone);
+ BLI_addtail( &py_bone->bone->parent->childbase,
+ py_bone->bone );
//get the worldspace coords for the parent
- get_objectspace_bone_matrix(py_bone->bone->parent, M_boneObjectspace, 0,0);
+ get_objectspace_bone_matrix( py_bone->bone->parent,
+ M_boneObjectspace, 0, 0 );
// Invert the parent rest matrix
- Mat4Invert (iM_parentRest, M_boneObjectspace);
+ Mat4Invert( iM_parentRest, M_boneObjectspace );
//transformation of local bone
- Mat4MulVecfl(iM_parentRest, py_bone->bone->tail);
- Mat4MulVecfl(iM_parentRest, py_bone->bone->head);
+ Mat4MulVecfl( iM_parentRest, py_bone->bone->tail );
+ Mat4MulVecfl( iM_parentRest, py_bone->bone->head );
- }else //no parent....
- BLI_addtail (&self->armature->bonebase,py_bone->bone);
+ } else //no parent....
+ BLI_addtail( &self->armature->bonebase, py_bone->bone );
//rebuild_bone_parent_matrix(py_bone->bone);
- precalc_bonelist_irestmats(&self->armature->bonebase);
- precalc_armature_posemats(self->armature);
- precalc_bone_defmat (py_bone->bone);
-
- Py_INCREF(Py_None);
+ precalc_bonelist_irestmats( &self->armature->bonebase );
+ precalc_armature_posemats( self->armature );
+ precalc_bone_defmat( py_bone->bone );
+
+ Py_INCREF( Py_None );
return Py_None;
}
-//---------------------BPy_Armature.setName()-------------------------------------------------------
-static PyObject *
-Armature_setName (BPy_Armature * self, PyObject * args)
+
+//---------------------BPy_Armature.setName()-------------------------
+static PyObject *Armature_setName( BPy_Armature * self, PyObject * args )
{
- char *name;
- char buf[21];
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple (args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
- PyOS_snprintf (buf, sizeof (buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id (&self->armature->id, buf);
+ rename_id( &self->armature->id, buf );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-//---------------------BPy_Armature.drawAxes()-------------------------------------------------------
-static PyObject *
-Armature_drawAxes (BPy_Armature * self, PyObject * args)
+
+//---------------------BPy_Armature.drawAxes()------------------------
+static PyObject *Armature_drawAxes( BPy_Armature * self, PyObject * args )
{
int toggle;
- if (!PyArg_ParseTuple (args, "i", &toggle))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 1 or 0 as integer"));
+ if( !PyArg_ParseTuple( args, "i", &toggle ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 1 or 0 as integer" ) );
- if(toggle)
+ if( toggle )
self->armature->flag |= ARM_DRAWAXES;
else
self->armature->flag &= ~ARM_DRAWAXES;
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//---------------------BPy_Armature.drawNames()-------------------------------------------------------
-static PyObject *
-Armature_drawNames (BPy_Armature * self, PyObject * args)
+
+//---------------------BPy_Armature.drawNames()-------------------------
+static PyObject *Armature_drawNames( BPy_Armature * self, PyObject * args )
{
int toggle;
- if (!PyArg_ParseTuple (args, "i", &toggle))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 1 or 0 as integer"));
+ if( !PyArg_ParseTuple( args, "i", &toggle ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 1 or 0 as integer" ) );
- if(toggle)
+ if( toggle )
self->armature->flag |= ARM_DRAWNAMES;
else
self->armature->flag &= ~ARM_DRAWNAMES;
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-
diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h
index 4b40c08d300..c96736b4c5e 100644
--- a/source/blender/python/api2_2x/Armature.h
+++ b/source/blender/python/api2_2x/Armature.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -35,13 +36,12 @@
#include <Python.h>
#include <DNA_armature_types.h>
-//---------------------Python BPy_Armature structure definition------------------------------
+//---------------------Python BPy_Armature structure definition-------
typedef struct {
- PyObject_HEAD
- bArmature *armature;
+ PyObject_HEAD bArmature * armature;
} BPy_Armature;
-//--------------------visible prototypes------------------------------------------------------------
-PyObject *Armature_Init (void);
+//--------------------visible prototypes------------------------------
+PyObject *Armature_Init( void );
-#endif /* EXPP_ARMATURE_H */
+#endif /* EXPP_ARMATURE_H */
diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h
index fe9ef6d6948..c5b2d9df85c 100644
--- a/source/blender/python/api2_2x/BGL.h
+++ b/source/blender/python/api2_2x/BGL.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -60,7 +61,7 @@
#include "BIF_mywindow.h"
#include "interface.h"
-#include "mydevice.h" /*@ for all the event constants */
+#include "mydevice.h" /*@ for all the event constants */
#include "Python.h"
@@ -71,30 +72,29 @@
/*@ For Python access to OpenGL functions requiring a pointer. */
typedef struct _Buffer {
- PyObject_VAR_HEAD
-
- PyObject *parent;
-
- int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */
- int ndimensions;
- int *dimensions;
-
- union {
- char *asbyte;
- short *asshort;
- int *asint;
- float *asfloat;
-
- void *asvoid;
- } buf;
+ PyObject_VAR_HEAD PyObject * parent;
+
+ int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */
+ int ndimensions;
+ int *dimensions;
+
+ union {
+ char *asbyte;
+ short *asshort;
+ int *asint;
+ float *asfloat;
+
+ void *asvoid;
+ } buf;
} Buffer;
-static int type_size(int type);
-static Buffer *make_buffer(int type, int ndimensions, int *dimensions);
-static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq);
+static int type_size( int type );
+static Buffer *make_buffer( int type, int ndimensions, int *dimensions );
+static int Buffer_ass_slice( PyObject * self, int begin, int end,
+ PyObject * seq );
-static char Method_Buffer_doc[]=
-"(type, dimensions, [template]) - Create a new Buffer object\n\n\
+static char Method_Buffer_doc[] =
+ "(type, dimensions, [template]) - Create a new Buffer object\n\n\
(type) - The format to store data in\n\
(dimensions) - An int or sequence specifying the dimensions of the buffer\n\
[template] - A sequence of matching dimensions to the buffer to be created\n\
@@ -109,46 +109,47 @@ For example, passing [100, 100] will create a 2 dimensional\n\
square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\
buffer which is twice as deep as it is wide or high.";
-static PyObject *Method_Buffer (PyObject *self, PyObject *args);
+static PyObject *Method_Buffer( PyObject * self, PyObject * args );
/* Buffer sequence methods */
-static int Buffer_len(PyObject *self);
-static PyObject *Buffer_item(PyObject *self, int i);
-static PyObject *Buffer_slice(PyObject *self, int begin, int end);
-static int Buffer_ass_item(PyObject *self, int i, PyObject *v);
-static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq);
+static int Buffer_len( PyObject * self );
+static PyObject *Buffer_item( PyObject * self, int i );
+static PyObject *Buffer_slice( PyObject * self, int begin, int end );
+static int Buffer_ass_item( PyObject * self, int i, PyObject * v );
+static int Buffer_ass_slice( PyObject * self, int begin, int end,
+ PyObject * seq );
static PySequenceMethods Buffer_SeqMethods = {
- (inquiry) Buffer_len, /*sq_length*/
- (binaryfunc) 0, /*sq_concat*/
- (intargfunc) 0, /*sq_repeat*/
- (intargfunc) Buffer_item, /*sq_item*/
- (intintargfunc) Buffer_slice, /*sq_slice*/
- (intobjargproc) Buffer_ass_item, /*sq_ass_item*/
- (intintobjargproc) Buffer_ass_slice, /*sq_ass_slice*/
+ ( inquiry ) Buffer_len, /*sq_length */
+ ( binaryfunc ) 0, /*sq_concat */
+ ( intargfunc ) 0, /*sq_repeat */
+ ( intargfunc ) Buffer_item, /*sq_item */
+ ( intintargfunc ) Buffer_slice, /*sq_slice */
+ ( intobjargproc ) Buffer_ass_item, /*sq_ass_item */
+ ( intintobjargproc ) Buffer_ass_slice, /*sq_ass_slice */
};
-static void Buffer_dealloc(PyObject *self);
-static PyObject *Buffer_tolist(PyObject *self);
-static PyObject *Buffer_dimensions(PyObject *self);
-static PyObject *Buffer_getattr(PyObject *self, char *name);
-static PyObject *Buffer_repr(PyObject *self);
+static void Buffer_dealloc( PyObject * self );
+static PyObject *Buffer_tolist( PyObject * self );
+static PyObject *Buffer_dimensions( PyObject * self );
+static PyObject *Buffer_getattr( PyObject * self, char *name );
+static PyObject *Buffer_repr( PyObject * self );
PyTypeObject buffer_Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "buffer", /*tp_name*/
- sizeof(Buffer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Buffer_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Buffer_getattr, /*tp_getattr*/
- (setattrfunc) 0, /*tp_setattr*/
- (cmpfunc) 0, /*tp_compare*/
- (reprfunc) Buffer_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &Buffer_SeqMethods, /*tp_as_sequence*/
+ PyObject_HEAD_INIT( NULL ) /* required python macro */
+ 0, /*ob_size */
+ "buffer", /*tp_name */
+ sizeof( Buffer ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Buffer_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Buffer_getattr, /*tp_getattr */
+ ( setattrfunc ) 0, /*tp_setattr */
+ ( cmpfunc ) 0, /*tp_compare */
+ ( reprfunc ) Buffer_repr, /*tp_repr */
+ 0, /*tp_as_number */
+ &Buffer_SeqMethods, /*tp_as_sequence */
};
/* #ifndef __APPLE__ */
@@ -173,7 +174,7 @@ PyTypeObject buffer_Type = {
/* TYPE_def is the C initialization of the variable */
#define void_str ""
-#define void_var(num)
+#define void_var(num)
#define void_ref(num) &bgl_var##num
#define void_def(num) char bgl_var##num
@@ -252,7 +253,7 @@ PyTypeObject buffer_Type = {
* Py_ArgParse doesn't grok writing into unsigned variables,
* so we use signed everything (even stuff that should be unsigned.
*/
-
+
/* typedef unsigned int GLenum; */
#define GLenum_str "i"
#define GLenum_var(num) bgl_var##num
@@ -387,28 +388,28 @@ PyTypeObject buffer_Type = {
#define arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_str8(a1, a2, a3, a4, a5, a6, a7, a8) a9##_str
#define arg_str10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9) a10##_str
-#define ret_def_void
-#define ret_set_void
+#define ret_def_void
+#define ret_set_void
#define ret_ret_void return EXPP_incr_ret(Py_None)
#define ret_def_GLint int ret_int
-#define ret_set_GLint ret_int=
+#define ret_set_GLint ret_int=
#define ret_ret_GLint return PyInt_FromLong(ret_int);
#define ret_def_GLuint unsigned int ret_uint
-#define ret_set_GLuint ret_uint=
+#define ret_set_GLuint ret_uint=
#define ret_ret_GLuint return PyInt_FromLong((long) ret_uint);
#define ret_def_GLenum unsigned int ret_uint
-#define ret_set_GLenum ret_uint=
+#define ret_set_GLenum ret_uint=
#define ret_ret_GLenum return PyInt_FromLong((long) ret_uint);
#define ret_def_GLboolean unsigned char ret_bool
-#define ret_set_GLboolean ret_bool=
+#define ret_set_GLboolean ret_bool=
#define ret_ret_GLboolean return PyInt_FromLong((long) ret_bool);
#define ret_def_GLstring const unsigned char *ret_str;
-#define ret_set_GLstring ret_str=
+#define ret_set_GLstring ret_str=
#define ret_ret_GLstring return PyString_FromString(ret_str);
#define BGL_Wrap(nargs, funcname, ret, arg_list) \
@@ -431,4 +432,4 @@ static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
/* #endif */
-PyObject *BGL_Init(void);
+PyObject *BGL_Init( void );
diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c
index 9c3034aa5cd..23cd7d50d22 100644
--- a/source/blender/python/api2_2x/BezTriple.c
+++ b/source/blender/python/api2_2x/BezTriple.c
@@ -45,127 +45,124 @@
#include "modules.h"
/*****************************************************************************/
-/* Python API function prototypes for the BezTriple module. */
+/* Python API function prototypes for the BezTriple module. */
/*****************************************************************************/
-static PyObject *M_BezTriple_New (PyObject * self, PyObject * args);
-static PyObject *M_BezTriple_Get (PyObject * self, PyObject * args);
+static PyObject *M_BezTriple_New( PyObject * self, PyObject * args );
+static PyObject *M_BezTriple_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* Python C_BezTriple instance methods declarations: */
+/* Python C_BezTriple instance methods declarations: */
/*****************************************************************************/
-static PyObject *BezTriple_setPoints (C_BezTriple * self, PyObject * args);
-static PyObject *BezTriple_getPoints (C_BezTriple * self);
-static PyObject *BezTriple_getTriple (C_BezTriple * self);
+static PyObject *BezTriple_setPoints( C_BezTriple * self, PyObject * args );
+static PyObject *BezTriple_getPoints( C_BezTriple * self );
+static PyObject *BezTriple_getTriple( C_BezTriple * self );
/*****************************************************************************/
-/* Python BezTriple_Type callback function prototypes: */
+/* Python BezTriple_Type callback function prototypes: */
/*****************************************************************************/
-static void BezTripleDeAlloc (C_BezTriple * self);
-static int BezTripleSetAttr (C_BezTriple * self, char *name, PyObject * v);
-static PyObject *BezTripleGetAttr (C_BezTriple * self, char *name);
-static PyObject *BezTripleRepr (C_BezTriple * self);
+static void BezTripleDeAlloc( C_BezTriple * self );
+static int BezTripleSetAttr( C_BezTriple * self, char *name, PyObject * v );
+static PyObject *BezTripleGetAttr( C_BezTriple * self, char *name );
+static PyObject *BezTripleRepr( C_BezTriple * self );
/*****************************************************************************/
-/* Python method structure definition for Blender.BezTriple module: */
+/* Python method structure definition for Blender.BezTriple module: */
/*****************************************************************************/
struct PyMethodDef M_BezTriple_methods[] = {
- {"New", (PyCFunction) M_BezTriple_New, METH_VARARGS | METH_KEYWORDS, 0},
- {"Get", M_BezTriple_Get, METH_VARARGS, 0},
- {"get", M_BezTriple_Get, METH_VARARGS, 0},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_BezTriple_New, METH_VARARGS | METH_KEYWORDS,
+ 0},
+ {"Get", M_BezTriple_Get, METH_VARARGS, 0},
+ {"get", M_BezTriple_Get, METH_VARARGS, 0},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python C_BezTriple methods table: */
+/* Python C_BezTriple methods table: */
/*****************************************************************************/
static PyMethodDef C_BezTriple_methods[] = {
- /* name, method, flags, doc */
- {"setPoints", (PyCFunction) BezTriple_setPoints, METH_VARARGS,
- "(str) - Change BezTriple point coordinates"},
- {"getPoints", (PyCFunction) BezTriple_getPoints, METH_NOARGS,
- "() - return BezTriple knot point x and y coordinates"},
- {"getTriple", (PyCFunction) BezTriple_getTriple, METH_NOARGS,
- "() - return list of 3 floating point triplets. order is H1, knot, H2"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"setPoints", ( PyCFunction ) BezTriple_setPoints, METH_VARARGS,
+ "(str) - Change BezTriple point coordinates"},
+ {"getPoints", ( PyCFunction ) BezTriple_getPoints, METH_NOARGS,
+ "() - return BezTriple knot point x and y coordinates"},
+ {"getTriple", ( PyCFunction ) BezTriple_getTriple, METH_NOARGS,
+ "() - return list of 3 floating point triplets. order is H1, knot, H2"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BezTriple_Type structure definition: */
+/* Python BezTriple_Type structure definition: */
/*****************************************************************************/
PyTypeObject BezTriple_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "BezTriple", /* tp_name */
- sizeof (C_BezTriple), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) BezTripleDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) BezTripleGetAttr, /* tp_getattr */
- (setattrfunc) BezTripleSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) BezTripleRepr, /* 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,
- C_BezTriple_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tm_getset */
- 0
+ PyObject_HEAD_INIT( NULL ) /* required python macro */
+ 0, /* ob_size */
+ "BezTriple", /* tp_name */
+ sizeof( C_BezTriple ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) BezTripleDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) BezTripleGetAttr, /* tp_getattr */
+ ( setattrfunc ) BezTripleSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) BezTripleRepr, /* 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,
+ C_BezTriple_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tm_getset */
+ 0
};
/*****************************************************************************/
-/* Function: M_BezTriple_New */
-/* Python equivalent: Blender.BezTriple.New */
+/* Function: M_BezTriple_New */
+/* Python equivalent: Blender.BezTriple.New */
/*****************************************************************************/
-static PyObject *
-M_BezTriple_New (PyObject * self, PyObject * args)
+static PyObject *M_BezTriple_New( PyObject * self, PyObject * args )
{
- return 0;
+ return 0;
}
/*****************************************************************************/
-/* Function: M_BezTriple_Get */
-/* Python equivalent: Blender.BezTriple.Get */
+/* Function: M_BezTriple_Get */
+/* Python equivalent: Blender.BezTriple.Get */
/* Description: Receives a string and returns the ipo data obj */
/* whose name matches the string. If no argument is */
/* passed in, a list of all ipo data names in the */
/* current scene is returned. */
/*****************************************************************************/
-static PyObject *
-M_BezTriple_Get (PyObject * self, PyObject * args)
+static PyObject *M_BezTriple_Get( PyObject * self, PyObject * args )
{
- return 0;
+ return 0;
}
/*****************************************************************************/
-/* Function: BezTripleDeAlloc */
-/* Description: This is a callback function for the C_BezTriple type. It is */
+/* Function: BezTripleDeAlloc */
+/* Description: This is a callback function for the C_BezTriple type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void
-BezTripleDeAlloc (C_BezTriple * self)
+static void BezTripleDeAlloc( C_BezTriple * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *
-BezTriple_getPoints (C_BezTriple * self)
+static PyObject *BezTriple_getPoints( C_BezTriple * self )
{
- struct BezTriple *bezt = self->beztriple;
- PyObject *l = PyList_New (0);
- int i;
- for (i = 0; i < 2; i++)
- {
- PyList_Append (l, PyFloat_FromDouble (bezt->vec[1][i]));
- }
- return l;
+ struct BezTriple *bezt = self->beztriple;
+ PyObject *l = PyList_New( 0 );
+ int i;
+ for( i = 0; i < 2; i++ ) {
+ PyList_Append( l, PyFloat_FromDouble( bezt->vec[1][i] ) );
+ }
+ return l;
}
@@ -178,120 +175,112 @@ BezTriple_getPoints (C_BezTriple * self)
* each point consists of a list of x,y,z float values.
*/
-static PyObject *
-BezTriple_getTriple (C_BezTriple * self)
+static PyObject *BezTriple_getTriple( C_BezTriple * self )
{
- int i;
- struct BezTriple *bezt = self->beztriple;
- PyObject *retlist = PyList_New (0);
- PyObject *point;
+ int i;
+ struct BezTriple *bezt = self->beztriple;
+ PyObject *retlist = PyList_New( 0 );
+ PyObject *point;
- for (i = 0; i < 3; i++)
- {
- point = Py_BuildValue ("[fff]",
- bezt->vec[i][0],
- bezt->vec[i][1], bezt->vec[i][2]);
+ for( i = 0; i < 3; i++ ) {
+ point = Py_BuildValue( "[fff]",
+ bezt->vec[i][0],
+ bezt->vec[i][1], bezt->vec[i][2] );
- PyList_Append (retlist, point);
- }
+ PyList_Append( retlist, point );
+ }
- return retlist;
+ return retlist;
}
-static PyObject *
-BezTriple_setPoints (C_BezTriple * self, PyObject * args)
+static PyObject *BezTriple_setPoints( C_BezTriple * self, PyObject * args )
{
- int i;
- struct BezTriple *bezt = self->beztriple;
- PyObject *popo = 0;
-
- if (!PyArg_ParseTuple (args, "O", &popo))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected sequence argument"));
-
- if (PySequence_Check (popo) == 0)
- {
- puts ("error in BezTriple_setPoints - expected sequence");
- Py_INCREF (Py_None);
- return Py_None;
- }
-
- {
- /*
- some debug stuff
- this will become an overloaded args check
- */
- int size = PySequence_Size (popo);
- printf ("\n dbg: sequence size is %d\n", size);
- }
-
- for (i = 0; i < 2; i++)
- {
- PyObject *o = PySequence_GetItem (popo, i);
- if (!o)
- printf ("\n bad o. o no!\n");
-
- /* bezt->vec[1][i] = PyFloat_AsDouble (PyTuple_GetItem (popo, i)); */
- bezt->vec[1][i] = PyFloat_AsDouble (o);
- bezt->vec[0][i] = bezt->vec[1][i] - 1;
- bezt->vec[2][i] = bezt->vec[1][i] + 1;
- }
-
- /* experimental fussing with handles - ipo.c: calchandles_ipocurve */
- if (bezt->vec[0][0] > bezt->vec[1][0])
- bezt->vec[0][0] = bezt->vec[1][0];
-
- if (bezt->vec[2][0] < bezt->vec[1][0])
- bezt->vec[2][0] = bezt->vec[1][0];
-
- Py_INCREF (Py_None);
- return Py_None;
+ int i;
+ struct BezTriple *bezt = self->beztriple;
+ PyObject *popo = 0;
+
+ if( !PyArg_ParseTuple( args, "O", &popo ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected sequence argument" ) );
+
+ if( PySequence_Check( popo ) == 0 ) {
+ puts( "error in BezTriple_setPoints - expected sequence" );
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
+ {
+ /*
+ some debug stuff
+ this will become an overloaded args check
+ */
+ int size = PySequence_Size( popo );
+ printf( "\n dbg: sequence size is %d\n", size );
+ }
+
+ for( i = 0; i < 2; i++ ) {
+ PyObject *o = PySequence_GetItem( popo, i );
+ if( !o )
+ printf( "\n bad o. o no!\n" );
+
+ /* bezt->vec[1][i] = PyFloat_AsDouble (PyTuple_GetItem (popo, i)); */
+ bezt->vec[1][i] = PyFloat_AsDouble( o );
+ bezt->vec[0][i] = bezt->vec[1][i] - 1;
+ bezt->vec[2][i] = bezt->vec[1][i] + 1;
+ }
+
+ /* experimental fussing with handles - ipo.c: calchandles_ipocurve */
+ if( bezt->vec[0][0] > bezt->vec[1][0] )
+ bezt->vec[0][0] = bezt->vec[1][0];
+
+ if( bezt->vec[2][0] < bezt->vec[1][0] )
+ bezt->vec[2][0] = bezt->vec[1][0];
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
-/* Function: BezTripleGetAttr */
-/* Description: This is a callback function for the C_BezTriple type. It is */
-/* the function that accesses C_BezTriple "member variables" and */
-/* methods. */
+/* Function: BezTripleGetAttr */
+/* Description: This is a callback function for the C_BezTriple type. It */
+/* taccesses C_BezTriple "member variables" and methods. */
/*****************************************************************************/
-static PyObject *
-BezTripleGetAttr (C_BezTriple * self, char *name)
+static PyObject *BezTripleGetAttr( C_BezTriple * self, char *name )
{
- if (strcmp (name, "pt") == 0)
- return BezTriple_getPoints (self);
- else if (strcmp (name, "vec") == 0)
- return BezTriple_getTriple (self);
+ if( strcmp( name, "pt" ) == 0 )
+ return BezTriple_getPoints( self );
+ else if( strcmp( name, "vec" ) == 0 )
+ return BezTriple_getTriple( self );
- /* look for default methods */
- return Py_FindMethod (C_BezTriple_methods, (PyObject *) self, name);
+ /* look for default methods */
+ return Py_FindMethod( C_BezTriple_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
-/* Function: BezTripleSetAttr */
-/* Description: This is a callback function for the C_BezTriple type. It is the */
-/* function that sets BezTriple Data attributes (member variables).*/
+/* Function: BezTripleSetAttr */
+/* Description: This is a callback function for the C_BezTriple type. It */
+/* sets BezTriple Data attributes (member variables). */
/*****************************************************************************/
-static int
-BezTripleSetAttr (C_BezTriple * self, char *name, PyObject * value)
+static int BezTripleSetAttr( C_BezTriple * self, char *name, PyObject * value )
{
#if 0
- /*
- this does not work at the moment: Wed Apr 7 2004
- when the necessary code to make pt act like a sequence is
- available, it will be reenabled
- */
+ /*
+ this does not work at the moment: Wed Apr 7 2004
+ when the necessary code to make pt act like a sequence is
+ available, it will be reenabled
+ */
- if (strcmp (name, "pt") == 0)
- BezTriple_setPoints (self, value);
+ if( strcmp( name, "pt" ) == 0 )
+ BezTriple_setPoints( self, value );
- return 0; /* normal exit */
+ return 0; /* normal exit */
#endif
- return (EXPP_ReturnIntError (PyExc_AttributeError,
- "cannot set a read-only attribute"));
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "cannot set a read-only attribute" ) );
}
/*****************************************************************************/
@@ -299,72 +288,70 @@ BezTripleSetAttr (C_BezTriple * self, char *name, PyObject * value)
/* Description: This is a callback function for the C_BezTriple type. It */
/* builds a meaninful string to represent BezTriple objects. */
/*****************************************************************************/
-static PyObject *
-BezTripleRepr (C_BezTriple * self)
+static PyObject *BezTripleRepr( C_BezTriple * self )
{
- /* float vec[3][3];
- float alfa;
- short s[3][2];
- short h1, h2;
- char f1, f2, f3, hide;
- */
- char str[1000];
- sprintf (str,
- "BezTriple %f %f %f %f %f %f %f %f %f %f\n %d %d %d %d %d %d %d %d %d %d %d %d\n",
- self->beztriple->vec[0][0], self->beztriple->vec[0][1],
- self->beztriple->vec[0][2], self->beztriple->vec[1][0],
- self->beztriple->vec[1][1], self->beztriple->vec[1][2],
- self->beztriple->vec[2][0], self->beztriple->vec[2][1],
- self->beztriple->vec[2][2], self->beztriple->alfa,
- self->beztriple->s[0][0], self->beztriple->s[0][1],
- self->beztriple->s[1][0], self->beztriple->s[1][1],
- self->beztriple->s[2][0], self->beztriple->s[1][1],
- self->beztriple->h1, self->beztriple->h2, self->beztriple->f1,
- self->beztriple->f2, self->beztriple->f3, self->beztriple->hide);
- return PyString_FromString (str);
+ /* float vec[3][3];
+ float alfa;
+ short s[3][2];
+ short h1, h2;
+ char f1, f2, f3, hide;
+ */
+ char str[1000];
+ sprintf( str,
+ "BezTriple %f %f %f %f %f %f %f %f %f %f\n %d %d %d %d %d %d %d %d %d %d %d %d\n",
+ self->beztriple->vec[0][0], self->beztriple->vec[0][1],
+ self->beztriple->vec[0][2], self->beztriple->vec[1][0],
+ self->beztriple->vec[1][1], self->beztriple->vec[1][2],
+ self->beztriple->vec[2][0], self->beztriple->vec[2][1],
+ self->beztriple->vec[2][2], self->beztriple->alfa,
+ self->beztriple->s[0][0], self->beztriple->s[0][1],
+ self->beztriple->s[1][0], self->beztriple->s[1][1],
+ self->beztriple->s[2][0], self->beztriple->s[1][1],
+ self->beztriple->h1, self->beztriple->h2, self->beztriple->f1,
+ self->beztriple->f2, self->beztriple->f3,
+ self->beztriple->hide );
+ return PyString_FromString( str );
}
/* Three Python BezTriple_Type helper functions needed by the Object module: */
/*****************************************************************************/
-/* Function: BezTriple_CreatePyObject */
-/* Description: This function will create a new C_BezTriple from an existing */
+/* Function: BezTriple_CreatePyObject */
+/* Description: This function will create a new C_BezTriple from an existing */
/* Blender ipo structure. */
/*****************************************************************************/
-PyObject *
-BezTriple_CreatePyObject (BezTriple * bzt)
+PyObject *BezTriple_CreatePyObject( BezTriple * bzt )
{
- C_BezTriple *pybeztriple;
+ C_BezTriple *pybeztriple;
- pybeztriple = (C_BezTriple *) PyObject_NEW (C_BezTriple, &BezTriple_Type);
+ pybeztriple =
+ ( C_BezTriple * ) PyObject_NEW( C_BezTriple, &BezTriple_Type );
- if (!pybeztriple)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create C_BezTriple object");
+ if( !pybeztriple )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create C_BezTriple object" );
- pybeztriple->beztriple = bzt;
+ pybeztriple->beztriple = bzt;
- return (PyObject *) pybeztriple;
+ return ( PyObject * ) pybeztriple;
}
/*****************************************************************************/
-/* Function: BezTriple_CheckPyObject */
+/* Function: BezTriple_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type BezTriple. Otherwise it will return false. */
+/* type BezTriple. Otherwise it will return false. */
/*****************************************************************************/
-int
-BezTriple_CheckPyObject (PyObject * pyobj)
+int BezTriple_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &BezTriple_Type);
+ return ( pyobj->ob_type == &BezTriple_Type );
}
/*****************************************************************************/
-/* Function: BezTriple_FromPyObject */
-/* Description: This function returns the Blender beztriple from the given */
+/* Function: BezTriple_FromPyObject */
+/* Description: This function returns the Blender beztriple from the given */
/* PyObject. */
/*****************************************************************************/
-BezTriple *
-BezTriple_FromPyObject (PyObject * pyobj)
+BezTriple *BezTriple_FromPyObject( PyObject * pyobj )
{
- return ((C_BezTriple *) pyobj)->beztriple;
+ return ( ( C_BezTriple * ) pyobj )->beztriple;
}
diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h
index 992c306199a..e4795b4ff07 100644
--- a/source/blender/python/api2_2x/BezTriple.h
+++ b/source/blender/python/api2_2x/BezTriple.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -36,15 +37,13 @@
#include <DNA_curve_types.h>
/*****************************************************************************/
-/* Python C_BezTriple structure definition: */
+/* Python C_BezTriple structure definition: */
/*****************************************************************************/
-typedef struct
-{
- PyObject_HEAD /* required python macro */
- BezTriple *beztriple;
-}
-C_BezTriple;
+typedef struct {
+ PyObject_HEAD /* required python macro */
+ BezTriple * beztriple;
+} C_BezTriple;
-#endif /* EXPP_BEZTRIPLE_H */
+#endif /* EXPP_BEZTRIPLE_H */
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 0cb848fc76b..9e0c513f8b1 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -34,14 +34,14 @@
/* for open, close in Blender_Load */
#include <fcntl.h>
-#ifndef WIN32
+#ifndef WIN32
#include <unistd.h>
#else
#include "BLI_winstuff.h"
#include <io.h>
#endif
-#include <BDR_editobject.h> /* exit_editmode() */
+#include <BDR_editobject.h> /* exit_editmode() */
#include <BIF_usiblender.h>
#include <BLI_blenlib.h>
#include <BLO_writefile.h>
@@ -54,43 +54,42 @@
#include <DNA_ID.h>
#include <DNA_object_types.h>
#include <DNA_scene_types.h>
-#include <DNA_screen_types.h> /* for SPACE_VIEW3D */
-#include <DNA_space_types.h> /* for SPACE_VIEW3D */
+#include <DNA_screen_types.h> /* for SPACE_VIEW3D */
+#include <DNA_space_types.h> /* for SPACE_VIEW3D */
#include <DNA_userdef_types.h>
#include <BKE_ipo.h>
#include <blendef.h>
#include "gen_utils.h"
#include "modules.h"
-#include "../BPY_extern.h" /* for bpy_gethome() */
+#include "../BPY_extern.h" /* for bpy_gethome() */
/* From Window.h, used here by Blender_Redraw */
-PyObject *M_Window_Redraw(PyObject *self, PyObject *args);
+PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
/**********************************************************/
/* Python API function prototypes for the Blender module. */
/**********************************************************/
-static PyObject *Blender_Set (PyObject *self, PyObject *args);
-static PyObject *Blender_Get (PyObject *self, PyObject *args);
-static PyObject *Blender_Redraw(PyObject *self, PyObject *args);
-static PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args);
-static PyObject *Blender_Quit(PyObject *self);
-static PyObject *Blender_Load(PyObject *self, PyObject *args);
-static PyObject *Blender_Save(PyObject *self, PyObject *args);
+static PyObject *Blender_Set( PyObject * self, PyObject * args );
+static PyObject *Blender_Get( PyObject * self, PyObject * args );
+static PyObject *Blender_Redraw( PyObject * self, PyObject * args );
+static PyObject *Blender_ReleaseGlobalDict( PyObject * self, PyObject * args );
+static PyObject *Blender_Quit( PyObject * self );
+static PyObject *Blender_Load( PyObject * self, PyObject * args );
+static PyObject *Blender_Save( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.__doc__ */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.__doc__ */
/*****************************************************************************/
static char Blender_Set_doc[] =
-"(request, data) - Update settings in Blender\n\
+ "(request, data) - Update settings in Blender\n\
\n\
(request) A string identifying the setting to change\n\
'curframe' - Sets the current frame using the number in data";
-static char Blender_Get_doc[] =
-"(request) - Retrieve settings from Blender\n\
+static char Blender_Get_doc[] = "(request) - Retrieve settings from Blender\n\
\n\
(request) A string indentifying the data to be returned\n\
'curframe' - Returns the current animation frame\n\
@@ -105,13 +104,12 @@ static char Blender_Get_doc[] =
static char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
static char Blender_ReleaseGlobalDict_doc[] =
-"Deprecated, please use the Blender.Registry module solution instead.";
+ "Deprecated, please use the Blender.Registry module solution instead.";
static char Blender_Quit_doc[] =
-"() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
+ "() - Quit Blender. The current data is saved as 'quit.blend' before leaving.";
-static char Blender_Load_doc[] =
-"(filename) - Load the given file.\n\
+static char Blender_Load_doc[] = "(filename) - Load the given file.\n\
Supported formats:\n\
Blender, DXF, Inventor 1.0 ASCII, VRML 1.0 asc, STL, Videoscape, radiogour.\n\
\n\
@@ -125,7 +123,7 @@ Notes:\n\
only one running at the moment.";
static char Blender_Save_doc[] =
-"(filename) - Save data to a file based on the filename's extension.\n\
+ "(filename) - Save data to a file based on the filename's extension.\n\
Supported are: Blender's .blend and the builtin exporters:\n\
VRML 1.0 (.wrl), Videoscape (.obj), DXF (.dxf) and STL (.stl)\n\
(filename) - A filename with one of the supported extensions.\n\
@@ -135,193 +133,187 @@ Note 2: only .blend raises an error if file wasn't saved.\n\
\twhen writing to one of the other formats.";
/*****************************************************************************/
-/* Python method structure definition. */
+/* Python method structure definition. */
/*****************************************************************************/
static struct PyMethodDef Blender_methods[] = {
- {"Set", Blender_Set, METH_VARARGS, Blender_Set_doc},
- {"Get", Blender_Get, METH_VARARGS, Blender_Get_doc},
+ {"Set", Blender_Set, METH_VARARGS, Blender_Set_doc},
+ {"Get", Blender_Get, METH_VARARGS, Blender_Get_doc},
{"Redraw", Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
- {"Quit", (PyCFunction)Blender_Quit, METH_NOARGS, Blender_Quit_doc},
+ {"Quit", ( PyCFunction ) Blender_Quit, METH_NOARGS, Blender_Quit_doc},
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
{"ReleaseGlobalDict", &Blender_ReleaseGlobalDict,
- METH_VARARGS, Blender_ReleaseGlobalDict_doc},
- {NULL, NULL, 0, NULL}
+ METH_VARARGS, Blender_ReleaseGlobalDict_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Global variables */
+/* Global variables */
/*****************************************************************************/
PyObject *g_blenderdict;
/*****************************************************************************/
-/* Function: Blender_Set */
-/* Python equivalent: Blender.Set */
+/* Function: Blender_Set */
+/* Python equivalent: Blender.Set */
/*****************************************************************************/
-static PyObject *Blender_Set (PyObject *self, PyObject *args)
+static PyObject *Blender_Set( PyObject * self, PyObject * args )
{
- char * name;
- PyObject * arg;
- int framenum;
-
- if (!PyArg_ParseTuple(args, "sO", &name, &arg))
- {
+ char *name;
+ PyObject *arg;
+ int framenum;
+
+ if( !PyArg_ParseTuple( args, "sO", &name, &arg ) ) {
/* TODO: Do we need to generate a nice error message here? */
- return (NULL);
+ return ( NULL );
}
- if (StringEqual (name, "curframe"))
- {
- if (!PyArg_Parse(arg, "i", &framenum))
- {
- /* TODO: Do we need to generate a nice error message here? */
- return (NULL);
+ if( StringEqual( name, "curframe" ) ) {
+ if( !PyArg_Parse( arg, "i", &framenum ) ) {
+ /* TODO: Do we need to generate a nice error message here? */
+ return ( NULL );
}
G.scene->r.cfra = framenum;
- update_for_newframe();
+ update_for_newframe( );
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "bad request identifier" ) );
}
- else
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "bad request identifier"));
- }
- return ( EXPP_incr_ret (Py_None) );
+ return ( EXPP_incr_ret( Py_None ) );
}
/*****************************************************************************/
-/* Function: Blender_Get */
-/* Python equivalent: Blender.Get */
+/* Function: Blender_Get */
+/* Python equivalent: Blender.Get */
/*****************************************************************************/
-static PyObject *Blender_Get (PyObject *self, PyObject *args)
+static PyObject *Blender_Get( PyObject * self, PyObject * args )
{
- PyObject * object;
- PyObject * dict;
- char * str;
-
- if (!PyArg_ParseTuple (args, "O", &object))
- {
- /* TODO: Do we need to generate a nice error message here? */
- return (NULL);
+ PyObject *object;
+ PyObject *dict;
+ char *str;
+
+ if( !PyArg_ParseTuple( args, "O", &object ) ) {
+ /* TODO: Do we need to generate a nice error message here? */
+ return ( NULL );
}
- if (PyString_Check (object))
- {
- str = PyString_AsString (object);
+ if( PyString_Check( object ) ) {
+ str = PyString_AsString( object );
- if (StringEqual (str, "curframe"))
- {
- return ( PyInt_FromLong (G.scene->r.cfra) );
+ if( StringEqual( str, "curframe" ) ) {
+ return ( PyInt_FromLong( G.scene->r.cfra ) );
}
- if (StringEqual (str, "curtime"))
- {
- return ( PyFloat_FromDouble (frame_to_float (G.scene->r.cfra) ) );
+ if( StringEqual( str, "curtime" ) ) {
+ return ( PyFloat_FromDouble
+ ( frame_to_float( G.scene->r.cfra ) ) );
}
- if (StringEqual (str, "staframe"))
- {
- return ( PyInt_FromLong (G.scene->r.sfra) );
+ if( StringEqual( str, "staframe" ) ) {
+ return ( PyInt_FromLong( G.scene->r.sfra ) );
}
- if (StringEqual (str, "endframe"))
- {
- return ( PyInt_FromLong (G.scene->r.efra) );
+ if( StringEqual( str, "endframe" ) ) {
+ return ( PyInt_FromLong( G.scene->r.efra ) );
}
- if (StringEqual (str, "filename"))
- {
- return ( PyString_FromString (G.sce) );
+ if( StringEqual( str, "filename" ) ) {
+ return ( PyString_FromString( G.sce ) );
}
- if (StringEqual (str, "datadir"))
- {
+ if( StringEqual( str, "datadir" ) ) {
char datadir[FILE_MAXDIR];
- BLI_make_file_string("/", datadir, bpy_gethome(), "bpydata/");
- if (BLI_exists(datadir)) return PyString_FromString(datadir);
- else return EXPP_incr_ret (Py_None);
+ BLI_make_file_string( "/", datadir, bpy_gethome( ),
+ "bpydata/" );
+ if( BLI_exists( datadir ) )
+ return PyString_FromString( datadir );
+ else
+ return EXPP_incr_ret( Py_None );
}
- if (StringEqual (str, "scriptsdir"))
- {
+ if( StringEqual( str, "scriptsdir" ) ) {
char scriptsdir[FILE_MAXDIR];
- BLI_make_file_string("/", scriptsdir, bpy_gethome(), "scripts/");
- if (BLI_exists(scriptsdir)) return PyString_FromString(scriptsdir);
- else return EXPP_incr_ret (Py_None);
+ BLI_make_file_string( "/", scriptsdir, bpy_gethome( ),
+ "scripts/" );
+ if( BLI_exists( scriptsdir ) )
+ return PyString_FromString( scriptsdir );
+ else
+ return EXPP_incr_ret( Py_None );
}
/* According to the old file (opy_blender.c), the following if
- statement is a quick hack and needs some clean up. */
- if (StringEqual (str, "vrmloptions"))
- {
- dict = PyDict_New ();
-
- PyDict_SetItemString (dict, "twoside",
- PyInt_FromLong (U.vrmlflag & USER_VRML_TWOSIDED));
-
- PyDict_SetItemString (dict, "layers",
- PyInt_FromLong (U.vrmlflag & USER_VRML_LAYERS));
-
- PyDict_SetItemString (dict, "autoscale",
- PyInt_FromLong (U.vrmlflag & USER_VRML_AUTOSCALE));
-
- return (dict);
- } /* End 'quick hack' part. */
- if (StringEqual (str, "version"))
- {
- return ( PyInt_FromLong (G.version) );
+ statement is a quick hack and needs some clean up. */
+ if( StringEqual( str, "vrmloptions" ) ) {
+ dict = PyDict_New( );
+
+ PyDict_SetItemString( dict, "twoside",
+ PyInt_FromLong( U.
+ vrmlflag &
+ USER_VRML_TWOSIDED ) );
+
+ PyDict_SetItemString( dict, "layers",
+ PyInt_FromLong( U.
+ vrmlflag &
+ USER_VRML_LAYERS ) );
+
+ PyDict_SetItemString( dict, "autoscale",
+ PyInt_FromLong( U.
+ vrmlflag &
+ USER_VRML_AUTOSCALE ) );
+
+ return ( dict );
+ } /* End 'quick hack' part. */
+ if( StringEqual( str, "version" ) ) {
+ return ( PyInt_FromLong( G.version ) );
}
/* TODO: Do we want to display a usefull message here that the
- requested data is unknown?
- else
- {
- return (EXPP_ReturnPyObjError (..., "message") );
- }
- */
- }
- else
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
+ requested data is unknown?
+ else
+ {
+ return (EXPP_ReturnPyObjError (..., "message") );
+ }
+ */
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
}
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "bad request identifier"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "bad request identifier" ) );
}
/*****************************************************************************/
-/* Function: Blender_Redraw */
-/* Python equivalent: Blender.Redraw */
+/* Function: Blender_Redraw */
+/* Python equivalent: Blender.Redraw */
/*****************************************************************************/
-static PyObject *Blender_Redraw(PyObject *self, PyObject *args)
+static PyObject *Blender_Redraw( PyObject * self, PyObject * args )
{
int wintype = SPACE_VIEW3D;
- if (!PyArg_ParseTuple (args, "|i", &wintype))
- {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|i", &wintype ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument (or nothing)" );
}
- return M_Window_Redraw(self, Py_BuildValue("(i)", wintype));
+ return M_Window_Redraw( self, Py_BuildValue( "(i)", wintype ) );
}
/*****************************************************************************/
-/* Function: Blender_ReleaseGlobalDict */
-/* Python equivalent: Blender.ReleaseGlobalDict */
-/* Description: Deprecated function. */
+/* Function: Blender_ReleaseGlobalDict */
+/* Python equivalent: Blender.ReleaseGlobalDict */
+/* Description: Deprecated function. */
/*****************************************************************************/
-static PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
+static PyObject *Blender_ReleaseGlobalDict( PyObject * self, PyObject * args )
{
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: Blender_Quit */
-/* Python equivalent: Blender.Quit */
+/* Function: Blender_Quit */
+/* Python equivalent: Blender.Quit */
/*****************************************************************************/
-static PyObject *Blender_Quit(PyObject *self)
+static PyObject *Blender_Quit( PyObject * self )
{
- BIF_write_autosave(); /* save the current data first */
+ BIF_write_autosave( ); /* save the current data first */
- exit_usiblender(); /* renames last autosave to quit.blend */
+ exit_usiblender( ); /* renames last autosave to quit.blend */
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -330,7 +322,7 @@ static PyObject *Blender_Quit(PyObject *self)
* loads Blender's .blend, DXF, radiogour(?), STL, Videoscape,
* Inventor 1.0 ASCII, VRML 1.0 asc.
*/
-static PyObject *Blender_Load(PyObject *self, PyObject *args)
+static PyObject *Blender_Load( PyObject * self, PyObject * args )
{
char *fname = NULL;
int keep_oldfname = 0;
@@ -338,69 +330,73 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
char str[32], name[FILE_MAXDIR];
int file, is_blend_file = 0;
- if (!PyArg_ParseTuple(args, "|si", &fname, &keep_oldfname))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected filename and optional int or nothing as arguments");
+ if( !PyArg_ParseTuple( args, "|si", &fname, &keep_oldfname ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected filename and optional int or nothing as arguments" );
- if (fname) {
- if (strlen(fname) > FILE_MAXDIR) /* G.main->name's max length */
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "filename too long!");
- else if (!BLI_exists(fname))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "requested file doesn't exist!");
+ if( fname ) {
+ if( strlen( fname ) > FILE_MAXDIR ) /* G.main->name's max length */
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "filename too long!" );
+ else if( !BLI_exists( fname ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "requested file doesn't exist!" );
- if (keep_oldfname) BLI_strncpy(name, G.sce, FILE_MAXDIR);
+ if( keep_oldfname )
+ BLI_strncpy( name, G.sce, FILE_MAXDIR );
}
/* We won't let a new .blend file be loaded if there are still other
* scripts running, since loading a new file will close and remove them. */
- if (G.main->script.first != G.main->script.last)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "there are other scripts running at the Scripts win, close them first!");
+ if( G.main->script.first != G.main->script.last )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "there are other scripts running at the Scripts win, close them first!" );
- if (fname) {
- file = open(fname, O_BINARY|O_RDONLY);
+ if( fname ) {
+ file = open( fname, O_BINARY | O_RDONLY );
- if (file <= 0) {
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "cannot open file!");
- }
- else {
- read(file, str, 31);
- close(file);
+ if( file <= 0 ) {
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "cannot open file!" );
+ } else {
+ read( file, str, 31 );
+ close( file );
- if (strncmp(str, "BLEN", 4) == 0) is_blend_file = 1;
+ if( strncmp( str, "BLEN", 4 ) == 0 )
+ is_blend_file = 1;
}
- }
- else is_blend_file = 1; /* no arg given means default: .B.blend */
+ } else
+ is_blend_file = 1; /* no arg given means default: .B.blend */
- if (is_blend_file) {
- int during_slink = during_scriptlink();
+ if( is_blend_file ) {
+ int during_slink = during_scriptlink( );
/* when loading a .blend file from a scriptlink, the scriptlink pointer
* in BPY_do_pyscript becomes invalid during a loop. Inform it here.
* Also do not allow a nested scriptlink (called from inside another)
* to load .blend files, to avoid nasty problems. */
- if (during_slink >= 1) {
- if (during_slink == 1)
- disable_where_scriptlink(-1);
+ if( during_slink >= 1 ) {
+ if( during_slink == 1 )
+ disable_where_scriptlink( -1 );
else {
- return EXPP_ReturnPyObjError(PyExc_EnvironmentError,
- "Blender.Load: cannot load .blend files from a nested scriptlink.");
+ return EXPP_ReturnPyObjError
+ ( PyExc_EnvironmentError,
+ "Blender.Load: cannot load .blend files from a nested scriptlink." );
}
}
/* trick: mark the script so that its script struct won't be freed after
* the script is executed (to avoid a double free warning on exit): */
script = G.main->script.first;
- if (script) script->flags |= SCRIPT_GUI;
+ if( script )
+ script->flags |= SCRIPT_GUI;
- BIF_write_autosave(); /* for safety let's preserve the current data */
+ BIF_write_autosave( ); /* for safety let's preserve the current data */
}
- if (G.obedit) exit_editmode(1);
+ if( G.obedit )
+ exit_editmode( 1 );
/* for safety, any filename with .B.blend is considered the default one.
* It doesn't seem necessary to compare file attributes (like st_ino and
@@ -409,136 +405,137 @@ static PyObject *Blender_Load(PyObject *self, PyObject *args)
* default one for sure. Taking any .B.blend file as the default is good
* enough here. Note: the default file requires extra clean-up done by
* BIF_read_homefile: freeing the user theme data. */
- if (!fname || (strstr(fname, ".B.blend") && is_blend_file))
- BIF_read_homefile();
+ if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
+ BIF_read_homefile( );
else
- BIF_read_file(fname);
+ BIF_read_file( fname );
- if (fname && keep_oldfname) {
- /*BLI_strncpy(G.main->name, name, FILE_MAXDIR);*/
- BLI_strncpy(G.sce, name, FILE_MAXDIR);
+ if( fname && keep_oldfname ) {
+ /*BLI_strncpy(G.main->name, name, FILE_MAXDIR); */
+ BLI_strncpy( G.sce, name, FILE_MAXDIR );
}
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Blender_Save(PyObject *self, PyObject *args)
+static PyObject *Blender_Save( PyObject * self, PyObject * args )
{
char *fname = NULL;
int overwrite = 0, len = 0;
char *error = NULL;
Library *li;
- if (!PyArg_ParseTuple(args, "s|i", &fname, &overwrite))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected filename and optional int (overwrite flag) as arguments");
+ if( !PyArg_ParseTuple( args, "s|i", &fname, &overwrite ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected filename and optional int (overwrite flag) as arguments" );
- for (li = G.main->library.first; li; li = li->id.next) {
- if (BLI_streq(li->name, fname)) {
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "cannot overwrite used library");
+ for( li = G.main->library.first; li; li = li->id.next ) {
+ if( BLI_streq( li->name, fname ) ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "cannot overwrite used library" );
}
}
-
+
/* for safety, any filename with .B.blend is considered the default one
* and not accepted here. */
- if (strstr(fname, ".B.blend"))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "filename can't contain the substring \".B.blend\" in it.");
-
- len = strlen(fname);
-
- if (len > FILE_MAXFILE)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "filename is too long!");
- else if (BLI_exists(fname) && !overwrite)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "file already exists and overwrite flag was not given.");
-
- disable_where_script(1); /* to avoid error popups in the write_* functions */
-
- if (BLI_testextensie(fname, ".blend")) {
- if (G.fileflags & G_AUTOPACK) packAll();
- if (!BLO_write_file(fname, G.fileflags, &error)) {
- disable_where_script(0);
- return EXPP_ReturnPyObjError(PyExc_SystemError, error);
+ if( strstr( fname, ".B.blend" ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "filename can't contain the substring \".B.blend\" in it." );
+
+ len = strlen( fname );
+
+ if( len > FILE_MAXFILE )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "filename is too long!" );
+ else if( BLI_exists( fname ) && !overwrite )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "file already exists and overwrite flag was not given." );
+
+ disable_where_script( 1 ); /* to avoid error popups in the write_* functions */
+
+ if( BLI_testextensie( fname, ".blend" ) ) {
+ if( G.fileflags & G_AUTOPACK )
+ packAll( );
+ if( !BLO_write_file( fname, G.fileflags, &error ) ) {
+ disable_where_script( 0 );
+ return EXPP_ReturnPyObjError( PyExc_SystemError,
+ error );
}
- }
- else if (BLI_testextensie(fname, ".dxf"))
- write_dxf(fname);
- else if (BLI_testextensie(fname, ".stl"))
- write_stl(fname);
- else if (BLI_testextensie(fname, ".wrl"))
- write_vrml(fname);
- else if (BLI_testextensie(fname, ".obj"))
- write_videoscape(fname);
+ } else if( BLI_testextensie( fname, ".dxf" ) )
+ write_dxf( fname );
+ else if( BLI_testextensie( fname, ".stl" ) )
+ write_stl( fname );
+ else if( BLI_testextensie( fname, ".wrl" ) )
+ write_vrml( fname );
+ else if( BLI_testextensie( fname, ".obj" ) )
+ write_videoscape( fname );
else {
- disable_where_script(0);
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "unknown file extension.");
+ disable_where_script( 0 );
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown file extension." );
}
- disable_where_script(0);
+ disable_where_script( 0 );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: initBlender */
+/* Function: initBlender */
/*****************************************************************************/
-void M_Blender_Init (void)
+void M_Blender_Init( void )
{
- PyObject * module;
- PyObject * dict;
+ PyObject *module;
+ PyObject *dict;
g_blenderdict = NULL;
/* TODO: create a docstring for the Blender module */
- module = Py_InitModule3("Blender", Blender_methods, NULL);
+ module = Py_InitModule3( "Blender", Blender_methods, NULL );
- types_InitAll(); /* set all our pytypes to &PyType_Type*/
+ types_InitAll( ); /* set all our pytypes to &PyType_Type */
- dict = PyModule_GetDict (module);
+ dict = PyModule_GetDict( module );
g_blenderdict = dict;
- Py_INCREF(Py_False);
- PyDict_SetItemString(dict, "bylink", Py_False);
- Py_INCREF(Py_None);
- PyDict_SetItemString(dict, "link", Py_None);
- PyDict_SetItemString(dict, "event", PyString_FromString(""));
-
- PyDict_SetItemString (dict, "Types", Types_Init());
- PyDict_SetItemString (dict, "sys", sys_Init());
- PyDict_SetItemString (dict, "Registry", Registry_Init());
- PyDict_SetItemString (dict, "Scene", Scene_Init());
- PyDict_SetItemString (dict, "Object", Object_Init());
- PyDict_SetItemString (dict, "Material", Material_Init());
- PyDict_SetItemString (dict, "Camera", Camera_Init());
- PyDict_SetItemString (dict, "Lamp", Lamp_Init());
- PyDict_SetItemString (dict, "Lattice", Lattice_Init());
- PyDict_SetItemString (dict, "Curve", Curve_Init());
- PyDict_SetItemString (dict, "Armature", Armature_Init());
- PyDict_SetItemString (dict, "Ipo", Ipo_Init());
- PyDict_SetItemString (dict, "IpoCurve", IpoCurve_Init());
- PyDict_SetItemString (dict, "Metaball", Metaball_Init());
- PyDict_SetItemString (dict, "Image", Image_Init());
- PyDict_SetItemString (dict, "Window", Window_Init());
- PyDict_SetItemString (dict, "Draw", Draw_Init());
- PyDict_SetItemString (dict, "BGL", BGL_Init());
- PyDict_SetItemString (dict, "Effect", Effect_Init());
- PyDict_SetItemString (dict, "Text", Text_Init());
- PyDict_SetItemString (dict, "World", World_Init());
- PyDict_SetItemString (dict, "Texture", Texture_Init());
- PyDict_SetItemString (dict, "NMesh", NMesh_Init());
- PyDict_SetItemString (dict, "Noise", Noise_Init());
- PyDict_SetItemString (dict, "Mathutils",Mathutils_Init());
- PyDict_SetItemString (dict, "Library", Library_Init());
- PyDict_SetItemString (dict, "Sound", Sound_Init());
-
- PyDict_SetItemString (dict, "CurNurb", CurNurb_Init());
-
- PyModule_AddIntConstant(module, "TRUE", 1);
- PyModule_AddIntConstant(module, "FALSE", 0);
+ Py_INCREF( Py_False );
+ PyDict_SetItemString( dict, "bylink", Py_False );
+ Py_INCREF( Py_None );
+ PyDict_SetItemString( dict, "link", Py_None );
+ PyDict_SetItemString( dict, "event", PyString_FromString( "" ) );
+
+ PyDict_SetItemString( dict, "Types", Types_Init( ) );
+ PyDict_SetItemString( dict, "sys", sys_Init( ) );
+ PyDict_SetItemString( dict, "Registry", Registry_Init( ) );
+ PyDict_SetItemString( dict, "Scene", Scene_Init( ) );
+ PyDict_SetItemString( dict, "Object", Object_Init( ) );
+ PyDict_SetItemString( dict, "Material", Material_Init( ) );
+ PyDict_SetItemString( dict, "Camera", Camera_Init( ) );
+ PyDict_SetItemString( dict, "Lamp", Lamp_Init( ) );
+ PyDict_SetItemString( dict, "Lattice", Lattice_Init( ) );
+ PyDict_SetItemString( dict, "Curve", Curve_Init( ) );
+ PyDict_SetItemString( dict, "Armature", Armature_Init( ) );
+ PyDict_SetItemString( dict, "Ipo", Ipo_Init( ) );
+ PyDict_SetItemString( dict, "IpoCurve", IpoCurve_Init( ) );
+ PyDict_SetItemString( dict, "Metaball", Metaball_Init( ) );
+ PyDict_SetItemString( dict, "Image", Image_Init( ) );
+ PyDict_SetItemString( dict, "Window", Window_Init( ) );
+ PyDict_SetItemString( dict, "Draw", Draw_Init( ) );
+ PyDict_SetItemString( dict, "BGL", BGL_Init( ) );
+ PyDict_SetItemString( dict, "Effect", Effect_Init( ) );
+ PyDict_SetItemString( dict, "Text", Text_Init( ) );
+ PyDict_SetItemString( dict, "World", World_Init( ) );
+ PyDict_SetItemString( dict, "Texture", Texture_Init( ) );
+ PyDict_SetItemString( dict, "NMesh", NMesh_Init( ) );
+ PyDict_SetItemString( dict, "Noise", Noise_Init( ) );
+ PyDict_SetItemString( dict, "Mathutils", Mathutils_Init( ) );
+ PyDict_SetItemString( dict, "Library", Library_Init( ) );
+ PyDict_SetItemString( dict, "Sound", Sound_Init( ) );
+
+ PyDict_SetItemString( dict, "CurNurb", CurNurb_Init( ) );
+
+ PyModule_AddIntConstant( module, "TRUE", 1 );
+ PyModule_AddIntConstant( module, "FALSE", 0 );
}
diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h
index 40585fffd3a..af7fa7c1056 100644
--- a/source/blender/python/api2_2x/Blender.h
+++ b/source/blender/python/api2_2x/Blender.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -31,4 +32,4 @@
#ifndef EXPP_BLENDER_H
#define EXPP_BLENDER_H
-#endif /* EXPP_BLENDER_H */
+#endif /* EXPP_BLENDER_H */
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index 52c1e33d586..0367fa99a65 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -53,200 +53,215 @@
#include "matrix.h"
#include "vector.h"
-//------------------------Python API function prototypes for the Bone module---------------------------
-static PyObject *M_Bone_New (PyObject * self, PyObject * args);
-//------------------------Python API Doc strings for the Bone module--------------------------------------
+//--------------------Python API function prototypes for the Bone module----
+static PyObject *M_Bone_New( PyObject * self, PyObject * args );
+
+//------------------------Python API Doc strings for the Bone module--------
char M_Bone_doc[] = "The Blender Bone module\n\n\
This module provides control over **Bone Data** objects in Blender.\n\n\
Example::\n\n\
from Blender import Armature.Bone\n\
l = Armature.Bone.New()\n";
char M_Bone_New_doc[] = "(name) - return a new Bone of name 'name'.";
-//--------------- Python method structure definition for Blender.Armature.Bone module------------
+
+//----- Python method structure definition for Blender.Armature.Bone module---
struct PyMethodDef M_Bone_methods[] = {
- {"New", (PyCFunction) M_Bone_New, METH_VARARGS, M_Bone_New_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Bone_New, METH_VARARGS, M_Bone_New_doc},
+ {NULL, NULL, 0, NULL}
};
-//--------------- Python BPy_Bone methods declarations:---------------------------------------------------
-static PyObject *Bone_getName (BPy_Bone * self);
-static PyObject *Bone_getRoll (BPy_Bone * self);
-static PyObject *Bone_getHead (BPy_Bone * self);
-static PyObject *Bone_getTail (BPy_Bone * self);
-static PyObject *Bone_getLoc (BPy_Bone * self);
-static PyObject *Bone_getSize (BPy_Bone * self);
-static PyObject *Bone_getQuat (BPy_Bone * self);
-static PyObject *Bone_getParent (BPy_Bone * self);
-static PyObject *Bone_hasParent (BPy_Bone * self);
-static PyObject *Bone_getWeight (BPy_Bone * self);
-static PyObject *Bone_getBoneclass (BPy_Bone * self);
-static PyObject *Bone_hasIK(BPy_Bone * self);
-static PyObject *Bone_getChildren (BPy_Bone * self);
-static PyObject *Bone_clearParent (BPy_Bone * self);
-static PyObject *Bone_clearChildren (BPy_Bone * self);
-static PyObject *Bone_hide (BPy_Bone * self);
-static PyObject *Bone_unhide (BPy_Bone * self);
-static PyObject *Bone_setName (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setRoll (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setHead (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setTail (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setLoc (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setSize (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setQuat (BPy_Bone * self, PyObject * args);
-static PyObject *Bone_setParent(BPy_Bone *self, PyObject *args);
-static PyObject *Bone_setWeight(BPy_Bone *self, PyObject *args);
-static PyObject *Bone_setPose (BPy_Bone *self, PyObject *args);
-static PyObject *Bone_setBoneclass (BPy_Bone *self, PyObject *args);
-static PyObject *Bone_getRestMatrix(BPy_Bone * self, PyObject *args);
-//--------------- Python BPy_Bone methods table:-----------------------------------------------------------------
+//--------------- Python BPy_Bone methods declarations:-------------------
+static PyObject *Bone_getName( BPy_Bone * self );
+static PyObject *Bone_getRoll( BPy_Bone * self );
+static PyObject *Bone_getHead( BPy_Bone * self );
+static PyObject *Bone_getTail( BPy_Bone * self );
+static PyObject *Bone_getLoc( BPy_Bone * self );
+static PyObject *Bone_getSize( BPy_Bone * self );
+static PyObject *Bone_getQuat( BPy_Bone * self );
+static PyObject *Bone_getParent( BPy_Bone * self );
+static PyObject *Bone_hasParent( BPy_Bone * self );
+static PyObject *Bone_getWeight( BPy_Bone * self );
+static PyObject *Bone_getBoneclass( BPy_Bone * self );
+static PyObject *Bone_hasIK( BPy_Bone * self );
+static PyObject *Bone_getChildren( BPy_Bone * self );
+static PyObject *Bone_clearParent( BPy_Bone * self );
+static PyObject *Bone_clearChildren( BPy_Bone * self );
+static PyObject *Bone_hide( BPy_Bone * self );
+static PyObject *Bone_unhide( BPy_Bone * self );
+static PyObject *Bone_setName( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setRoll( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setHead( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setTail( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setLoc( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setSize( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setQuat( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setParent( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setWeight( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_setBoneclass( BPy_Bone * self, PyObject * args );
+static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args );
+
+//--------------- Python BPy_Bone methods table:--------------------------
static PyMethodDef BPy_Bone_methods[] = {
- {"getName", (PyCFunction) Bone_getName, METH_NOARGS,
- "() - return Bone name"},
- {"getRoll", (PyCFunction) Bone_getRoll, METH_NOARGS,
- "() - return Bone roll"},
- {"getHead", (PyCFunction) Bone_getHead, METH_NOARGS,
- "() - return Bone head"},
- {"getTail", (PyCFunction) Bone_getTail, METH_NOARGS,
- "() - return Bone tail"},
- {"getLoc", (PyCFunction) Bone_getLoc, METH_NOARGS, "() - return Bone loc"},
- {"getSize", (PyCFunction) Bone_getSize, METH_NOARGS,
- "() - return Bone size"},
- {"getQuat", (PyCFunction) Bone_getQuat, METH_NOARGS,
- "() - return Bone quat"},
- {"hide", (PyCFunction) Bone_hide, METH_NOARGS,
- "() - hides the bone"},
- {"unhide", (PyCFunction) Bone_unhide, METH_NOARGS,
- "() - unhides the bone"},
- {"getWeight", (PyCFunction) Bone_getWeight, METH_NOARGS,
- "() - return Bone weight"},
- {"getBoneclass", (PyCFunction) Bone_getBoneclass, METH_NOARGS,
- "() - return Bone boneclass"},
- {"hasIK", (PyCFunction)Bone_hasIK, METH_VARARGS,
- "() - get the Bone IKToParent flag."},
- {"getParent", (PyCFunction) Bone_getParent, METH_NOARGS,
- "() - return the parent bone of this one if it exists."
- " None if not found. You can check this condition with the "
- "hasParent() method."},
- {"hasParent", (PyCFunction) Bone_hasParent, METH_NOARGS,
- "() - return true if bone has a parent"},
- {"getChildren", (PyCFunction) Bone_getChildren, METH_NOARGS,
- "() - return Bone children list"},
- {"clearParent", (PyCFunction) Bone_clearParent, METH_NOARGS,
- "() - clears the bone's parent in the armature and makes it root"},
- {"clearChildren", (PyCFunction) Bone_clearChildren, METH_NOARGS,
- "() - remove the children associated with this bone"},
- {"setName", (PyCFunction) Bone_setName, METH_VARARGS,
- "(str) - rename Bone"},
- {"setRoll", (PyCFunction) Bone_setRoll, METH_VARARGS,
- "(float) - set Bone roll"},
- {"setHead", (PyCFunction) Bone_setHead, METH_VARARGS,
- "(float,float,float) - set Bone head pos"},
- {"setTail", (PyCFunction) Bone_setTail, METH_VARARGS,
- "(float,float,float) - set Bone tail pos"},
- {"setLoc", (PyCFunction) Bone_setLoc, METH_VARARGS,
- "(float,float,float) - set Bone loc"},
- {"setSize", (PyCFunction) Bone_setSize, METH_VARARGS,
- "(float,float,float) - set Bone size"},
- {"setQuat", (PyCFunction) Bone_setQuat, METH_VARARGS,
- "(float,float,float,float) - set Bone quat"},
- {"setParent", (PyCFunction)Bone_setParent, METH_VARARGS,
- "() - set the Bone parent of this one."},
- {"setWeight", (PyCFunction)Bone_setWeight, METH_VARARGS,
- "() - set the Bone weight."},
- {"setPose", (PyCFunction)Bone_setPose, METH_VARARGS,
- "() - set a pose for this bone at a frame."},
- {"setBoneclass", (PyCFunction)Bone_setBoneclass, METH_VARARGS,
- "() - set the Bone boneclass."},
- {"getRestMatrix", (PyCFunction)Bone_getRestMatrix, METH_VARARGS,
- "() - return the rest matrix for this bone"},
- {NULL, NULL, 0, NULL}
+ {"getName", ( PyCFunction ) Bone_getName, METH_NOARGS,
+ "() - return Bone name"},
+ {"getRoll", ( PyCFunction ) Bone_getRoll, METH_NOARGS,
+ "() - return Bone roll"},
+ {"getHead", ( PyCFunction ) Bone_getHead, METH_NOARGS,
+ "() - return Bone head"},
+ {"getTail", ( PyCFunction ) Bone_getTail, METH_NOARGS,
+ "() - return Bone tail"},
+ {"getLoc", ( PyCFunction ) Bone_getLoc, METH_NOARGS,
+ "() - return Bone loc"},
+ {"getSize", ( PyCFunction ) Bone_getSize, METH_NOARGS,
+ "() - return Bone size"},
+ {"getQuat", ( PyCFunction ) Bone_getQuat, METH_NOARGS,
+ "() - return Bone quat"},
+ {"hide", ( PyCFunction ) Bone_hide, METH_NOARGS,
+ "() - hides the bone"},
+ {"unhide", ( PyCFunction ) Bone_unhide, METH_NOARGS,
+ "() - unhides the bone"},
+ {"getWeight", ( PyCFunction ) Bone_getWeight, METH_NOARGS,
+ "() - return Bone weight"},
+ {"getBoneclass", ( PyCFunction ) Bone_getBoneclass, METH_NOARGS,
+ "() - return Bone boneclass"},
+ {"hasIK", ( PyCFunction ) Bone_hasIK, METH_VARARGS,
+ "() - get the Bone IKToParent flag."},
+ {"getParent", ( PyCFunction ) Bone_getParent, METH_NOARGS,
+ "() - return the parent bone of this one if it exists."
+ " None if not found. You can check this condition with the "
+ "hasParent() method."},
+ {"hasParent", ( PyCFunction ) Bone_hasParent, METH_NOARGS,
+ "() - return true if bone has a parent"},
+ {"getChildren", ( PyCFunction ) Bone_getChildren, METH_NOARGS,
+ "() - return Bone children list"},
+ {"clearParent", ( PyCFunction ) Bone_clearParent, METH_NOARGS,
+ "() - clears the bone's parent in the armature and makes it root"},
+ {"clearChildren", ( PyCFunction ) Bone_clearChildren, METH_NOARGS,
+ "() - remove the children associated with this bone"},
+ {"setName", ( PyCFunction ) Bone_setName, METH_VARARGS,
+ "(str) - rename Bone"},
+ {"setRoll", ( PyCFunction ) Bone_setRoll, METH_VARARGS,
+ "(float) - set Bone roll"},
+ {"setHead", ( PyCFunction ) Bone_setHead, METH_VARARGS,
+ "(float,float,float) - set Bone head pos"},
+ {"setTail", ( PyCFunction ) Bone_setTail, METH_VARARGS,
+ "(float,float,float) - set Bone tail pos"},
+ {"setLoc", ( PyCFunction ) Bone_setLoc, METH_VARARGS,
+ "(float,float,float) - set Bone loc"},
+ {"setSize", ( PyCFunction ) Bone_setSize, METH_VARARGS,
+ "(float,float,float) - set Bone size"},
+ {"setQuat", ( PyCFunction ) Bone_setQuat, METH_VARARGS,
+ "(float,float,float,float) - set Bone quat"},
+ {"setParent", ( PyCFunction ) Bone_setParent, METH_VARARGS,
+ "() - set the Bone parent of this one."},
+ {"setWeight", ( PyCFunction ) Bone_setWeight, METH_VARARGS,
+ "() - set the Bone weight."},
+ {"setPose", ( PyCFunction ) Bone_setPose, METH_VARARGS,
+ "() - set a pose for this bone at a frame."},
+ {"setBoneclass", ( PyCFunction ) Bone_setBoneclass, METH_VARARGS,
+ "() - set the Bone boneclass."},
+ {"getRestMatrix", ( PyCFunction ) Bone_getRestMatrix, METH_VARARGS,
+ "() - return the rest matrix for this bone"},
+ {NULL, NULL, 0, NULL}
};
-//--------------- Python TypeBone callback function prototypes----------------------------------------
-static void Bone_dealloc (BPy_Bone * bone);
-static PyObject *Bone_getAttr (BPy_Bone * bone, char *name);
-static int Bone_setAttr (BPy_Bone * bone, char *name, PyObject * v);
-static int Bone_compare (BPy_Bone * a1, BPy_Bone * a2);
-static PyObject *Bone_repr (BPy_Bone * bone);
-//--------------- Python TypeBone structure definition------------------------------------------------------
+
+//--------------- Python TypeBone callback function prototypes----------
+static void Bone_dealloc( BPy_Bone * bone );
+static PyObject *Bone_getAttr( BPy_Bone * bone, char *name );
+static int Bone_setAttr( BPy_Bone * bone, char *name, PyObject * v );
+static int Bone_compare( BPy_Bone * a1, BPy_Bone * a2 );
+static PyObject *Bone_repr( BPy_Bone * bone );
+
+//--------------- Python TypeBone structure definition-------------
PyTypeObject Bone_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Bone", /* tp_name */
- sizeof (BPy_Bone), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) Bone_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Bone_getAttr, /* tp_getattr */
- (setattrfunc) Bone_setAttr, /* tp_setattr */
- (cmpfunc) Bone_compare, /* tp_compare */
- (reprfunc) Bone_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_Bone_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Bone", /* tp_name */
+ sizeof( BPy_Bone ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Bone_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Bone_getAttr, /* tp_getattr */
+ ( setattrfunc ) Bone_setAttr, /* tp_setattr */
+ ( cmpfunc ) Bone_compare, /* tp_compare */
+ ( reprfunc ) Bone_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_Bone_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//--------------- Bone Module Init----------------------------------------------------------------------------------------
-PyObject *
-Bone_Init (void)
+
+//--------------- Bone Module Init-----------------------------
+PyObject *Bone_Init( void )
{
- PyObject *submodule;
-
- Bone_Type.ob_type = &PyType_Type;
-
- submodule = Py_InitModule3 ("Blender.Armature.Bone",
- M_Bone_methods, M_Bone_doc);
-
- PyModule_AddIntConstant(submodule, "ROT", POSE_ROT);
- PyModule_AddIntConstant(submodule, "LOC", POSE_LOC);
- PyModule_AddIntConstant(submodule, "SIZE", POSE_SIZE);
- PyModule_AddIntConstant(submodule, "SKINNABLE", 0);
- PyModule_AddIntConstant(submodule, "UNSKINNABLE", 1);
- PyModule_AddIntConstant(submodule, "HEAD", 2);
- PyModule_AddIntConstant(submodule, "NECK", 3);
- PyModule_AddIntConstant(submodule, "BACK", 4);
- PyModule_AddIntConstant(submodule, "SHOULDER", 5);
- PyModule_AddIntConstant(submodule, "ARM", 6);
- PyModule_AddIntConstant(submodule, "HAND", 7);
- PyModule_AddIntConstant(submodule, "FINGER", 8);
- PyModule_AddIntConstant(submodule, "THUMB", 9);
- PyModule_AddIntConstant(submodule, "PELVIS", 10);
- PyModule_AddIntConstant(submodule, "LEG", 11);
- PyModule_AddIntConstant(submodule, "FOOT", 12);
- PyModule_AddIntConstant(submodule, "TOE", 13);
- PyModule_AddIntConstant(submodule, "TENTACLE", 14);
-
- return (submodule);
+ PyObject *submodule;
+
+ Bone_Type.ob_type = &PyType_Type;
+
+ submodule = Py_InitModule3( "Blender.Armature.Bone",
+ M_Bone_methods, M_Bone_doc );
+
+ PyModule_AddIntConstant( submodule, "ROT", POSE_ROT );
+ PyModule_AddIntConstant( submodule, "LOC", POSE_LOC );
+ PyModule_AddIntConstant( submodule, "SIZE", POSE_SIZE );
+ PyModule_AddIntConstant( submodule, "SKINNABLE", 0 );
+ PyModule_AddIntConstant( submodule, "UNSKINNABLE", 1 );
+ PyModule_AddIntConstant( submodule, "HEAD", 2 );
+ PyModule_AddIntConstant( submodule, "NECK", 3 );
+ PyModule_AddIntConstant( submodule, "BACK", 4 );
+ PyModule_AddIntConstant( submodule, "SHOULDER", 5 );
+ PyModule_AddIntConstant( submodule, "ARM", 6 );
+ PyModule_AddIntConstant( submodule, "HAND", 7 );
+ PyModule_AddIntConstant( submodule, "FINGER", 8 );
+ PyModule_AddIntConstant( submodule, "THUMB", 9 );
+ PyModule_AddIntConstant( submodule, "PELVIS", 10 );
+ PyModule_AddIntConstant( submodule, "LEG", 11 );
+ PyModule_AddIntConstant( submodule, "FOOT", 12 );
+ PyModule_AddIntConstant( submodule, "TOE", 13 );
+ PyModule_AddIntConstant( submodule, "TENTACLE", 14 );
+
+ return ( submodule );
}
-//--------------- Bone module internal callbacks-------------------------------------------------------------
-//--------------- updatePyBone-------------------------------------------------------------------------------------
-int
-updatePyBone(BPy_Bone *self)
+
+//--------------- Bone module internal callbacks-----------------
+
+//--------------- updatePyBone------------------------------------
+int updatePyBone( BPy_Bone * self )
{
- int x,y;
+ int x, y;
char *parent_str = "";
- if(!self->bone){
+ if( !self->bone ) {
//nothing to update - not linked
return 0;
- }else{
- BLI_strncpy(self->name, self->bone->name, strlen(self->bone->name) + 1);
+ } else {
+ BLI_strncpy( self->name, self->bone->name,
+ strlen( self->bone->name ) + 1 );
self->roll = self->bone->roll;
self->flag = self->bone->flag;
self->boneclass = self->bone->boneclass;
self->dist = self->bone->dist;
self->weight = self->bone->weight;
- if(self->bone->parent){
- self->parent = BLI_strncpy(self->parent, self->bone->parent->name, strlen(self->bone->parent->name) + 1);
- }else{
- self->parent = BLI_strncpy(self->parent, parent_str, strlen(parent_str) + 1);
+ if( self->bone->parent ) {
+ self->parent =
+ BLI_strncpy( self->parent,
+ self->bone->parent->name,
+ strlen( self->bone->parent->
+ name ) + 1 );
+ } else {
+ self->parent =
+ BLI_strncpy( self->parent, parent_str,
+ strlen( parent_str ) + 1 );
}
- for(x = 0; x < 3; x++){
+ for( x = 0; x < 3; x++ ) {
self->head->vec[x] = self->bone->head[x];
self->tail->vec[x] = self->bone->tail[x];
self->loc->vec[x] = self->bone->loc[x];
@@ -254,43 +269,49 @@ updatePyBone(BPy_Bone *self)
self->size->vec[x] = self->bone->size[x];
self->dsize->vec[x] = self->bone->dsize[x];
}
- for(x = 0; x < 4; x++){
+ for( x = 0; x < 4; x++ ) {
self->quat->quat[x] = self->bone->quat[x];
self->dquat->quat[x] = self->bone->dquat[x];
}
- for(x = 0; x < 4; x++){
- for(y = 0; y < 4; y++){
- self->obmat->matrix[x][y] = self->bone->obmat[x][y];
- self->parmat->matrix[x][y] = self->bone->parmat[x][y];
- self->defmat->matrix[x][y] = self->bone->defmat[x][y];
- self->irestmat->matrix[x][y] = self->bone->irestmat[x][y];
- self->posemat->matrix[x][y] = self->bone->posemat[x][y];
+ for( x = 0; x < 4; x++ ) {
+ for( y = 0; y < 4; y++ ) {
+ self->obmat->matrix[x][y] =
+ self->bone->obmat[x][y];
+ self->parmat->matrix[x][y] =
+ self->bone->parmat[x][y];
+ self->defmat->matrix[x][y] =
+ self->bone->defmat[x][y];
+ self->irestmat->matrix[x][y] =
+ self->bone->irestmat[x][y];
+ self->posemat->matrix[x][y] =
+ self->bone->posemat[x][y];
}
}
return 1;
}
}
-//--------------- updateBoneData-------------------------------------------------------------------------------------
-int
-updateBoneData(BPy_Bone *self, Bone *parent)
+
+//--------------- updateBoneData------------------------------------
+int updateBoneData( BPy_Bone * self, Bone * parent )
{
//called from Armature.addBone()
- int x,y;
+ int x, y;
- //called in Armature.addBone() to update the Bone * data
- if(!self->bone){
+ //called in Armature.addBone() to update the Bone * data
+ if( !self->bone ) {
//nothing to update - not linked
return 0;
- }else{
- BLI_strncpy(self->bone->name, self->name, strlen(self->name) + 1);
+ } else {
+ BLI_strncpy( self->bone->name, self->name,
+ strlen( self->name ) + 1 );
self->bone->roll = self->roll;
self->bone->flag = self->flag;
self->bone->boneclass = self->boneclass;
self->bone->dist = self->dist;
self->bone->weight = self->weight;
- self->bone->parent = parent; //parent will be checked from self->parent string in addBone()
+ self->bone->parent = parent; //parent will be checked from self->parent string in addBone()
- for(x = 0; x < 3; x++){
+ for( x = 0; x < 3; x++ ) {
self->bone->head[x] = self->head->vec[x];
self->bone->tail[x] = self->tail->vec[x];
self->bone->loc[x] = self->loc->vec[x];
@@ -298,293 +319,370 @@ updateBoneData(BPy_Bone *self, Bone *parent)
self->bone->size[x] = self->size->vec[x];
self->bone->dsize[x] = self->dsize->vec[x];
}
- for(x = 0; x < 4; x++){
+ for( x = 0; x < 4; x++ ) {
self->bone->quat[x] = self->quat->quat[x];
self->bone->dquat[x] = self->dquat->quat[x];
}
- for(x = 0; x < 4; x++){
- for(y = 0; y < 4; y++){
- self->bone->obmat[x][y] = self->obmat->matrix[x][y];
- self->bone->parmat[x][y] = self->parmat->matrix[x][y];
- self->bone->defmat[x][y] = self->defmat->matrix[x][y];
- self->bone->irestmat[x][y] = self->irestmat->matrix[x][y];
- self->bone->posemat[x][y] = self->posemat->matrix[x][y];
+ for( x = 0; x < 4; x++ ) {
+ for( y = 0; y < 4; y++ ) {
+ self->bone->obmat[x][y] =
+ self->obmat->matrix[x][y];
+ self->bone->parmat[x][y] =
+ self->parmat->matrix[x][y];
+ self->bone->defmat[x][y] =
+ self->defmat->matrix[x][y];
+ self->bone->irestmat[x][y] =
+ self->irestmat->matrix[x][y];
+ self->bone->posemat[x][y] =
+ self->posemat->matrix[x][y];
}
}
return 1;
}
}
-//--------------- testChildbase--------------------------------------------------------------------------------
-static int
-testChildbase(Bone *bone, Bone *test)
+
+//--------------- testChildbase----------------------------------
+static int testChildbase( Bone * bone, Bone * test )
{
Bone *child;
- for(child = bone->childbase.first; child; child = child->next){
- if(child == test){
+ for( child = bone->childbase.first; child; child = child->next ) {
+ if( child == test ) {
return 1;
}
- if(child->childbase.first != NULL)
- testChildbase(child, test);
+ if( child->childbase.first != NULL )
+ testChildbase( child, test );
}
return 0;
}
-//--------------- returnBoneclassEnum---------------------------------------------------------------------
-static PyObject *
-returnBoneclassEnum(int value)
+
+//--------------- returnBoneclassEnum----------------------------
+static PyObject *returnBoneclassEnum( int value )
{
char *str;
- str = PyMem_Malloc(32 + 1);
-
- switch(value){
- case 0:
- BLI_strncpy(str,"SKINNABLE",32); break;
- case 1:
- BLI_strncpy(str,"UNSKINNABLE",32); break;
- case 2:
- BLI_strncpy(str,"HEAD",32); break;
- case 3:
- BLI_strncpy(str,"NECK",32); break;
- case 4:
- BLI_strncpy(str,"BACK",32); break;
- case 5:
- BLI_strncpy(str,"SHOULDER",32); break;
- case 6:
- BLI_strncpy(str,"ARM",32); break;
- case 7:
- BLI_strncpy(str,"HAND",32); break;
- case 8:
- BLI_strncpy(str,"FINGER",32); break;
- case 9:
- BLI_strncpy(str,"THUMB",32); break;
- case 10:
- BLI_strncpy(str,"PELVIS",32); break;
- case 11:
- BLI_strncpy(str,"LEG",32); break;
- case 12:
- BLI_strncpy(str,"FOOT",32); break;
- case 13:
- BLI_strncpy(str,"TOE",32); break;
- case 14:
- BLI_strncpy(str,"TENTACLE",32); break;
- default:
- BLI_strncpy(str, "SKINNABLE",32); break;
+ str = PyMem_Malloc( 32 + 1 );
+
+ switch ( value ) {
+ case 0:
+ BLI_strncpy( str, "SKINNABLE", 32 );
+ break;
+ case 1:
+ BLI_strncpy( str, "UNSKINNABLE", 32 );
+ break;
+ case 2:
+ BLI_strncpy( str, "HEAD", 32 );
+ break;
+ case 3:
+ BLI_strncpy( str, "NECK", 32 );
+ break;
+ case 4:
+ BLI_strncpy( str, "BACK", 32 );
+ break;
+ case 5:
+ BLI_strncpy( str, "SHOULDER", 32 );
+ break;
+ case 6:
+ BLI_strncpy( str, "ARM", 32 );
+ break;
+ case 7:
+ BLI_strncpy( str, "HAND", 32 );
+ break;
+ case 8:
+ BLI_strncpy( str, "FINGER", 32 );
+ break;
+ case 9:
+ BLI_strncpy( str, "THUMB", 32 );
+ break;
+ case 10:
+ BLI_strncpy( str, "PELVIS", 32 );
+ break;
+ case 11:
+ BLI_strncpy( str, "LEG", 32 );
+ break;
+ case 12:
+ BLI_strncpy( str, "FOOT", 32 );
+ break;
+ case 13:
+ BLI_strncpy( str, "TOE", 32 );
+ break;
+ case 14:
+ BLI_strncpy( str, "TENTACLE", 32 );
+ break;
+ default:
+ BLI_strncpy( str, "SKINNABLE", 32 );
+ break;
}
- return (PyObject*)PyString_FromString(str);
+ return ( PyObject * ) PyString_FromString( str );
}
-//---------------BPy_Bone internal callbacks/methods---------------------------------------------
-//--------------- dealloc---------------------------------------------------------------------------------------
-static void
-Bone_dealloc (BPy_Bone * self)
+
+//---------------BPy_Bone internal callbacks/methods---------------
+
+//--------------- dealloc------------------------------------------
+static void Bone_dealloc( BPy_Bone * self )
{
- PyMem_Free (self->name);
- PyMem_Free (self->parent);
- PyObject_DEL (self);
+ PyMem_Free( self->name );
+ PyMem_Free( self->parent );
+ PyObject_DEL( self );
}
-//---------------getattr---------------------------------------------------------------------------------------
-static PyObject *
-Bone_getAttr (BPy_Bone * self, char *name)
+
+//---------------getattr-------------------------------------------
+static PyObject *Bone_getAttr( BPy_Bone * self, char *name )
{
- PyObject *attr = Py_None;
-
- if (strcmp (name, "name") == 0)
- attr = Bone_getName (self);
- else if (strcmp (name, "roll") == 0)
- attr = Bone_getRoll (self);
- else if (strcmp (name, "head") == 0)
- attr = Bone_getHead (self);
- else if (strcmp (name, "tail") == 0)
- attr = Bone_getTail (self);
- else if (strcmp (name, "size") == 0)
- attr = Bone_getSize (self);
- else if (strcmp (name, "loc") == 0)
- attr = Bone_getLoc (self);
- else if (strcmp (name, "quat") == 0)
- attr = Bone_getQuat (self);
- else if (strcmp (name, "parent") == 0)
- /* Skip the checks for Py_None as its a valid result to this call. */
- return Bone_getParent (self);
- else if (strcmp (name, "children") == 0)
- attr = Bone_getChildren (self);
- else if (strcmp (name, "weight") == 0)
- attr = Bone_getWeight (self);
- else if (strcmp (name, "boneclass") == 0)
- attr = Bone_getBoneclass (self);
- else if (strcmp (name, "ik") == 0)
- attr = Bone_hasIK (self);
- else if (strcmp (name, "__members__") == 0)
- {
- /* 9 entries */
- attr = Py_BuildValue ("[s,s,s,s,s,s,s,s,s,s,s]",
- "name", "roll", "head", "tail", "loc", "size",
- "quat", "parent", "children", "weight", "boneclass", "ik");
- }
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None)
- return attr; /* member attribute found, return it */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod (BPy_Bone_methods, (PyObject *) self, name);
+ PyObject *attr = Py_None;
+
+ if( strcmp( name, "name" ) == 0 )
+ attr = Bone_getName( self );
+ else if( strcmp( name, "roll" ) == 0 )
+ attr = Bone_getRoll( self );
+ else if( strcmp( name, "head" ) == 0 )
+ attr = Bone_getHead( self );
+ else if( strcmp( name, "tail" ) == 0 )
+ attr = Bone_getTail( self );
+ else if( strcmp( name, "size" ) == 0 )
+ attr = Bone_getSize( self );
+ else if( strcmp( name, "loc" ) == 0 )
+ attr = Bone_getLoc( self );
+ else if( strcmp( name, "quat" ) == 0 )
+ attr = Bone_getQuat( self );
+ else if( strcmp( name, "parent" ) == 0 )
+ /* Skip the checks for Py_None as its a valid result to this call. */
+ return Bone_getParent( self );
+ else if( strcmp( name, "children" ) == 0 )
+ attr = Bone_getChildren( self );
+ else if( strcmp( name, "weight" ) == 0 )
+ attr = Bone_getWeight( self );
+ else if( strcmp( name, "boneclass" ) == 0 )
+ attr = Bone_getBoneclass( self );
+ else if( strcmp( name, "ik" ) == 0 )
+ attr = Bone_hasIK( self );
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ /* 9 entries */
+ attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s]",
+ "name", "roll", "head", "tail", "loc",
+ "size", "quat", "parent", "children",
+ "weight", "boneclass", "ik" );
+ }
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Bone_methods, ( PyObject * ) self, name );
}
-//--------------- setattr---------------------------------------------------------------------------------------
-static int
-Bone_setAttr (BPy_Bone * self, char *name, PyObject * value)
+
+//--------------- setattr-------------------------------------------
+static int Bone_setAttr( BPy_Bone * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
- valtuple = Py_BuildValue ("(O)", value); /* the set* functions expect a tuple */
+ valtuple = Py_BuildValue( "(O)", value ); /* the set* functions expect a tuple */
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "BoneSetAttr: couldn't create tuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "BoneSetAttr: couldn't create tuple" );
- if (strcmp (name, "name") == 0)
- error = Bone_setName (self, valtuple);
- else
- { /* Error */
- Py_DECREF (valtuple);
+ if( strcmp( name, "name" ) == 0 )
+ error = Bone_setName( self, valtuple );
+ else { /* Error */
+ Py_DECREF( valtuple );
- /* ... member with the given name was found */
- return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
- }
+ /* ... member with the given name was found */
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
+ }
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None)
- return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF (Py_None); /* was incref'ed by the called Bone_set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* was incref'ed by the called Bone_set* function */
+ return 0; /* normal exit */
}
-//--------------- repr---------------------------------------------------------------------------------------
-static PyObject *
-Bone_repr (BPy_Bone * self)
+
+//--------------- repr---------------------------------------------
+static PyObject *Bone_repr( BPy_Bone * self )
{
- if (self->bone)
- return PyString_FromFormat ("[Bone \"%s\"]", self->bone->name);
- else
- return PyString_FromString ("NULL");
+ if( self->bone )
+ return PyString_FromFormat( "[Bone \"%s\"]",
+ self->bone->name );
+ else
+ return PyString_FromString( "NULL" );
}
-//--------------- compare---------------------------------------------------------------------------------------
-static int
-Bone_compare (BPy_Bone * a, BPy_Bone * b)
+
+//--------------- compare------------------------------------------
+static int Bone_compare( BPy_Bone * a, BPy_Bone * b )
{
- Bone *pa = a->bone, *pb = b->bone;
- return (pa == pb) ? 0 : -1;
+ Bone *pa = a->bone, *pb = b->bone;
+ return ( pa == pb ) ? 0 : -1;
}
-//--------------- Bone_CreatePyObject--------------------------------------------------------------------
-PyObject *
-Bone_CreatePyObject (struct Bone * bone)
+
+//--------------- Bone_CreatePyObject---------------------------------
+PyObject *Bone_CreatePyObject( struct Bone * bone )
{
BPy_Bone *blen_bone;
- blen_bone = (BPy_Bone *) PyObject_NEW (BPy_Bone, &Bone_Type);
+ blen_bone = ( BPy_Bone * ) PyObject_NEW( BPy_Bone, &Bone_Type );
//set the all important Bone flag
blen_bone->bone = bone;
//allocate space for python vars
- blen_bone->name= PyMem_Malloc (32 + 1);
- blen_bone->parent =PyMem_Malloc (32 + 1);
- blen_bone->head = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->tail = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->loc = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->dloc = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->size = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->dsize = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- blen_bone->quat = (QuaternionObject*)newQuaternionObject(PyMem_Malloc (4*sizeof (float)));
- blen_bone->dquat = (QuaternionObject*)newQuaternionObject(PyMem_Malloc (4*sizeof (float)));
- blen_bone->obmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- blen_bone->parmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- blen_bone->defmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- blen_bone->irestmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- blen_bone->posemat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
-
- if(!updatePyBone(blen_bone))
- return EXPP_ReturnPyObjError (PyExc_AttributeError , "bone struct empty");
-
- return ((PyObject *) blen_bone);
+ blen_bone->name = PyMem_Malloc( 32 + 1 );
+ blen_bone->parent = PyMem_Malloc( 32 + 1 );
+ blen_bone->head =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->tail =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->loc =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->dloc =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->size =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->dsize =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ blen_bone->quat =
+ ( QuaternionObject * )
+ newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) );
+ blen_bone->dquat =
+ ( QuaternionObject * )
+ newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) );
+ blen_bone->obmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ blen_bone->parmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ blen_bone->defmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ blen_bone->irestmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ blen_bone->posemat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+
+ if( !updatePyBone( blen_bone ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "bone struct empty" );
+
+ return ( ( PyObject * ) blen_bone );
}
-//--------------- Bone_CheckPyObject--------------------------------------------------------------------
-int
-Bone_CheckPyObject (PyObject * py_obj)
+
+//--------------- Bone_CheckPyObject--------------------------------
+int Bone_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Bone_Type);
+ return ( py_obj->ob_type == &Bone_Type );
}
-//--------------- Bone_FromPyObject--------------------------------------------------------------------
-struct Bone *
-Bone_FromPyObject (PyObject * py_obj)
+
+//--------------- Bone_FromPyObject---------------------------------
+struct Bone *Bone_FromPyObject( PyObject * py_obj )
{
- BPy_Bone *blen_obj;
-
- blen_obj = (BPy_Bone *) py_obj;
- if (!((BPy_Bone*)py_obj)->bone) { //test to see if linked to armature
- //use python vars
- return NULL;
- }else{
- //use bone datastruct
- return (blen_obj->bone);
- }
+ BPy_Bone *blen_obj;
+
+ blen_obj = ( BPy_Bone * ) py_obj;
+ if( !( ( BPy_Bone * ) py_obj )->bone ) { //test to see if linked to armature
+ //use python vars
+ return NULL;
+ } else {
+ //use bone datastruct
+ return ( blen_obj->bone );
+ }
}
-//--------------- Python Bone Module methods------------------------------------------------------------------
-//--------------- Blender.Armature.Bone.New()-----------------------------------------------------------------
-static PyObject *
-M_Bone_New (PyObject * self, PyObject * args)
+
+//--------------- Python Bone Module methods------------------------
+
+//--------------- Blender.Armature.Bone.New()-----------------------
+static PyObject *M_Bone_New( PyObject * self, PyObject * args )
{
char *name_str = "BoneName";
char *parent_str = "";
BPy_Bone *py_bone = NULL; /* for Bone Data object wrapper in Python */
- if (!PyArg_ParseTuple (args, "|s", &name_str))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string or empty argument"));
+ if( !PyArg_ParseTuple( args, "|s", &name_str ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string or empty argument" ) );
//create python bone
- py_bone = (BPy_Bone *) PyObject_NEW (BPy_Bone, &Bone_Type);
+ py_bone = ( BPy_Bone * ) PyObject_NEW( BPy_Bone, &Bone_Type );
//allocate space for python vars
- py_bone->name= PyMem_Malloc (32 + 1);
- py_bone->parent =PyMem_Malloc (32 + 1);
- py_bone->head = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->tail = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->loc = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->dloc = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->size = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->dsize = (VectorObject*)newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- py_bone->quat = (QuaternionObject*)newQuaternionObject(PyMem_Malloc (4*sizeof (float)));
- py_bone->dquat = (QuaternionObject*)newQuaternionObject(PyMem_Malloc (4*sizeof (float)));
- py_bone->obmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- py_bone->parmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- py_bone->defmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- py_bone->irestmat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
- py_bone->posemat = (MatrixObject*)newMatrixObject(PyMem_Malloc(16*sizeof(float)),4,4);
-
+ py_bone->name = PyMem_Malloc( 32 + 1 );
+ py_bone->parent = PyMem_Malloc( 32 + 1 );
+ py_bone->head =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->tail =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->loc =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->dloc =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->size =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->dsize =
+ ( VectorObject * )
+ newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ py_bone->quat =
+ ( QuaternionObject * )
+ newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) );
+ py_bone->dquat =
+ ( QuaternionObject * )
+ newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) );
+ py_bone->obmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ py_bone->parmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ py_bone->defmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ py_bone->irestmat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+ py_bone->posemat =
+ ( MatrixObject * )
+ newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
+
//default py values
- BLI_strncpy(py_bone->name, name_str, strlen(name_str) + 1);
- BLI_strncpy(py_bone->parent, parent_str, strlen(parent_str) + 1);
+ BLI_strncpy( py_bone->name, name_str, strlen( name_str ) + 1 );
+ BLI_strncpy( py_bone->parent, parent_str, strlen( parent_str ) + 1 );
py_bone->roll = 0.0f;
py_bone->flag = 32;
py_bone->boneclass = BONE_SKINNABLE;
py_bone->dist = 1.0f;
py_bone->weight = 1.0f;
- Vector_Zero(py_bone->head);
- Vector_Zero(py_bone->loc);
- Vector_Zero(py_bone->dloc);
- Vector_Zero(py_bone->size);
- Vector_Zero(py_bone->dsize);
- Quaternion_Identity(py_bone->quat);
- Quaternion_Identity(py_bone->dquat);
- Matrix_Identity(py_bone->obmat);
- Matrix_Identity(py_bone->parmat);
- Matrix_Identity(py_bone->defmat);
- Matrix_Identity(py_bone->irestmat);
- Matrix_Identity(py_bone->posemat);
+ Vector_Zero( py_bone->head );
+ Vector_Zero( py_bone->loc );
+ Vector_Zero( py_bone->dloc );
+ Vector_Zero( py_bone->size );
+ Vector_Zero( py_bone->dsize );
+ Quaternion_Identity( py_bone->quat );
+ Quaternion_Identity( py_bone->dquat );
+ Matrix_Identity( py_bone->obmat );
+ Matrix_Identity( py_bone->parmat );
+ Matrix_Identity( py_bone->defmat );
+ Matrix_Identity( py_bone->irestmat );
+ Matrix_Identity( py_bone->posemat );
//default tail of 2,0,0
py_bone->tail->vec[0] = 2.0f;
@@ -594,734 +692,771 @@ M_Bone_New (PyObject * self, PyObject * args)
//set the datapointer to null (unlinked)
py_bone->bone = NULL;
- return (PyObject *) py_bone;
+ return ( PyObject * ) py_bone;
}
-//--------------- Python BPy_Bone methods------------------------------------------------------------------
-//--------------- BPy_Bone.getName()--------------------------------------------------------------------------
-static PyObject *
-Bone_getName (BPy_Bone * self)
+
+//--------------- Python BPy_Bone methods---------------------------
+
+//--------------- BPy_Bone.getName()--------------------------------
+static PyObject *Bone_getName( BPy_Bone * self )
{
- PyObject *attr = NULL;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- attr = PyString_FromString (self->name);
- }else{
- //use bone datastruct
- attr = PyString_FromString (self->bone->name);
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.name attribute"));
+ PyObject *attr = NULL;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ attr = PyString_FromString( self->name );
+ } else {
+ //use bone datastruct
+ attr = PyString_FromString( self->bone->name );
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.name attribute" ) );
}
-//--------------- BPy_Bone.getRoll()------------------------------------------------------------------------------
-static PyObject *
-Bone_getRoll (BPy_Bone * self)
+
+//--------------- BPy_Bone.getRoll()---------------------------------
+static PyObject *Bone_getRoll( BPy_Bone * self )
{
- PyObject *attr = NULL;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- attr = Py_BuildValue ("f", self->roll);
- }else{
- //use bone datastruct
- attr = Py_BuildValue ("f", self->bone->roll);
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.roll attribute"));
+ PyObject *attr = NULL;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ attr = Py_BuildValue( "f", self->roll );
+ } else {
+ //use bone datastruct
+ attr = Py_BuildValue( "f", self->bone->roll );
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.roll attribute" ) );
}
-//--------------- BPy_Bone.getWeight()----------------------------------------------------------------------------
-static PyObject *
-Bone_getWeight (BPy_Bone * self)
+
+//--------------- BPy_Bone.getWeight()---------------------------------
+static PyObject *Bone_getWeight( BPy_Bone * self )
{
- PyObject *attr = NULL;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- attr = Py_BuildValue ("f", self->weight);
- }else{
- //use bone datastruct
- attr = Py_BuildValue ("f", self->bone->weight);
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.weight attribute"));
+ PyObject *attr = NULL;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ attr = Py_BuildValue( "f", self->weight );
+ } else {
+ //use bone datastruct
+ attr = Py_BuildValue( "f", self->bone->weight );
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.weight attribute" ) );
}
-//--------------- BPy_Bone.getHead()--------------------------------------------------------------------------
-static PyObject *
-Bone_getHead (BPy_Bone * self)
+
+//--------------- BPy_Bone.getHead()----------------------------------
+static PyObject *Bone_getHead( BPy_Bone * self )
{
- PyObject *attr = NULL;
- float *vec;
- int x;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- vec = PyMem_Malloc(3 * sizeof(float));
- for(x = 0; x < 3; x++)
- vec[x] = self->head->vec[x];
- attr = (PyObject *)newVectorObject(vec, 3);
- }else{
- //use bone datastruct
- attr = newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- ((VectorObject*)attr)->vec[0] = self->bone->head[0];
- ((VectorObject*)attr)->vec[1] = self->bone->head[1];
- ((VectorObject*)attr)->vec[2] = self->bone->head[2];
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.head attribute"));
+ PyObject *attr = NULL;
+ float *vec;
+ int x;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ )
+ vec[x] = self->head->vec[x];
+ attr = ( PyObject * ) newVectorObject( vec, 3 );
+ } else {
+ //use bone datastruct
+ attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
+ 3 );
+ ( ( VectorObject * ) attr )->vec[0] = self->bone->head[0];
+ ( ( VectorObject * ) attr )->vec[1] = self->bone->head[1];
+ ( ( VectorObject * ) attr )->vec[2] = self->bone->head[2];
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.head attribute" ) );
}
-//--------------- BPy_Bone.getTail()--------------------------------------------------------------------------
-static PyObject *
-Bone_getTail (BPy_Bone * self)
+
+//--------------- BPy_Bone.getTail()---------------------------------
+static PyObject *Bone_getTail( BPy_Bone * self )
{
- PyObject *attr = NULL;
- float *vec;
- int x;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- vec = PyMem_Malloc(3 * sizeof(float));
- for(x = 0; x < 3; x++)
- vec[x] = self->tail->vec[x];
- attr = (PyObject *)newVectorObject(vec, 3);
- }else{
- //use bone datastruct
- attr = newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- ((VectorObject*)attr)->vec[0] = self->bone->tail[0];
- ((VectorObject*)attr)->vec[1] = self->bone->tail[1];
- ((VectorObject*)attr)->vec[2] = self->bone->tail[2];
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.tail attribute"));
+ PyObject *attr = NULL;
+ float *vec;
+ int x;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ )
+ vec[x] = self->tail->vec[x];
+ attr = ( PyObject * ) newVectorObject( vec, 3 );
+ } else {
+ //use bone datastruct
+ attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
+ 3 );
+ ( ( VectorObject * ) attr )->vec[0] = self->bone->tail[0];
+ ( ( VectorObject * ) attr )->vec[1] = self->bone->tail[1];
+ ( ( VectorObject * ) attr )->vec[2] = self->bone->tail[2];
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.tail attribute" ) );
}
-//--------------- BPy_Bone.getLoc()----------------------------------------------------------------------------
-static PyObject *
-Bone_getLoc (BPy_Bone * self)
+
+//--------------- BPy_Bone.getLoc()---------------------------------
+static PyObject *Bone_getLoc( BPy_Bone * self )
{
- PyObject *attr = NULL;
- float *vec;
- int x;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- vec = PyMem_Malloc(3 * sizeof(float));
- for(x = 0; x < 3; x++)
- vec[x] = self->loc->vec[x];
- attr = (PyObject *)newVectorObject(vec, 3);
- }else{
- //use bone datastruct
- attr = newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- ((VectorObject*)attr)->vec[0] = self->bone->loc[0];
- ((VectorObject*)attr)->vec[1] = self->bone->loc[1];
- ((VectorObject*)attr)->vec[2] = self->bone->loc[2];
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.loc attribute"));
+ PyObject *attr = NULL;
+ float *vec;
+ int x;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ )
+ vec[x] = self->loc->vec[x];
+ attr = ( PyObject * ) newVectorObject( vec, 3 );
+ } else {
+ //use bone datastruct
+ attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
+ 3 );
+ ( ( VectorObject * ) attr )->vec[0] = self->bone->loc[0];
+ ( ( VectorObject * ) attr )->vec[1] = self->bone->loc[1];
+ ( ( VectorObject * ) attr )->vec[2] = self->bone->loc[2];
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.loc attribute" ) );
}
-//--------------- BPy_Bone.getSize()----------------------------------------------------------------------------
-static PyObject *
-Bone_getSize (BPy_Bone * self)
+
+//--------------- BPy_Bone.getSize()-----------------------------
+static PyObject *Bone_getSize( BPy_Bone * self )
{
- PyObject *attr = NULL;
- float *vec;
- int x;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- vec = PyMem_Malloc(3 * sizeof(float));
- for(x = 0; x < 3; x++)
- vec[x] = self->size->vec[x];
- attr = (PyObject *)newVectorObject(vec, 3);
- }else{
- //use bone datastruct
- attr = newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- ((VectorObject*)attr)->vec[0] = self->bone->size[0];
- ((VectorObject*)attr)->vec[1] = self->bone->size[1];
- ((VectorObject*)attr)->vec[2] = self->bone->size[2];
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.size attribute"));
+ PyObject *attr = NULL;
+ float *vec;
+ int x;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ )
+ vec[x] = self->size->vec[x];
+ attr = ( PyObject * ) newVectorObject( vec, 3 );
+ } else {
+ //use bone datastruct
+ attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ),
+ 3 );
+ ( ( VectorObject * ) attr )->vec[0] = self->bone->size[0];
+ ( ( VectorObject * ) attr )->vec[1] = self->bone->size[1];
+ ( ( VectorObject * ) attr )->vec[2] = self->bone->size[2];
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.size attribute" ) );
}
-//--------------- BPy_Bone.getQuat()----------------------------------------------------------------------------
-static PyObject *
-Bone_getQuat (BPy_Bone * self)
+
+//--------------- BPy_Bone.getQuat()--------------------------------
+static PyObject *Bone_getQuat( BPy_Bone * self )
{
- PyObject *attr = NULL;
- float *quat;
- int x;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars - p.s. - you must return a copy or else
- //python will trash the internal var
- quat = PyMem_Malloc(4 * sizeof(float));
- for(x = 0; x < 4; x++)
- quat[x] = self->quat->quat[x];
- attr = (PyObject *)newQuaternionObject(quat);
- }else{
- //use bone datastruct
- attr = newQuaternionObject(PyMem_Malloc (4*sizeof (float)));
- ((QuaternionObject*)attr)->quat[0] = self->bone->quat[0];
- ((QuaternionObject*)attr)->quat[1] = self->bone->quat[1];
- ((QuaternionObject*)attr)->quat[2] = self->bone->quat[2];
- ((QuaternionObject*)attr)->quat[3] = self->bone->quat[3];
- }
-
- return attr;
+ PyObject *attr = NULL;
+ float *quat;
+ int x;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars - p.s. - you must return a copy or else
+ //python will trash the internal var
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ for( x = 0; x < 4; x++ )
+ quat[x] = self->quat->quat[x];
+ attr = ( PyObject * ) newQuaternionObject( quat );
+ } else {
+ //use bone datastruct
+ attr = newQuaternionObject( PyMem_Malloc
+ ( 4 * sizeof( float ) ) );
+ ( ( QuaternionObject * ) attr )->quat[0] = self->bone->quat[0];
+ ( ( QuaternionObject * ) attr )->quat[1] = self->bone->quat[1];
+ ( ( QuaternionObject * ) attr )->quat[2] = self->bone->quat[2];
+ ( ( QuaternionObject * ) attr )->quat[3] = self->bone->quat[3];
+ }
+
+ return attr;
}
-//--------------- BPy_Bone.hasParent()--------------------------------------------------------------------------
-static PyObject *
-Bone_hasParent (BPy_Bone * self)
+
+//--------------- BPy_Bone.hasParent()---------------------------
+static PyObject *Bone_hasParent( BPy_Bone * self )
{
- char * parent_str = "";
+ char *parent_str = "";
- if (!self->bone) { //test to see if linked to armature
+ if( !self->bone ) { //test to see if linked to armature
//use python vars
- if (BLI_streq(self->parent, parent_str)) {
- Py_INCREF (Py_False);
- return Py_False;
- }else{
- Py_INCREF (Py_True);
- return Py_True;
+ if( BLI_streq( self->parent, parent_str ) ) {
+ Py_INCREF( Py_False );
+ return Py_False;
+ } else {
+ Py_INCREF( Py_True );
+ return Py_True;
}
- }else{
+ } else {
//use bone datastruct
- if (self->bone->parent) {
- Py_INCREF (Py_True);
- return Py_True;
- }else{
- Py_INCREF (Py_False);
- return Py_False;
+ if( self->bone->parent ) {
+ Py_INCREF( Py_True );
+ return Py_True;
+ } else {
+ Py_INCREF( Py_False );
+ return Py_False;
}
}
}
-//--------------- BPy_Bone.getParent()--------------------------------------------------------------------------
-static PyObject *
-Bone_getParent (BPy_Bone * self)
+
+//--------------- BPy_Bone.getParent()------------------------------
+static PyObject *Bone_getParent( BPy_Bone * self )
{
- char * parent_str = "";
- if (!self->bone) { //test to see if linked to armature
+ char *parent_str = "";
+ if( !self->bone ) { //test to see if linked to armature
//use python vars
- if (BLI_streq(self->parent, parent_str)) {
- return EXPP_incr_ret (Py_None);
- }else{
- return PyString_FromString(self->parent);
- }
- }else{
+ if( BLI_streq( self->parent, parent_str ) ) {
+ return EXPP_incr_ret( Py_None );
+ } else {
+ return PyString_FromString( self->parent );
+ }
+ } else {
//use bone datastruct
- if (self->bone->parent) {
- return Bone_CreatePyObject (self->bone->parent);
- }else{
- return EXPP_incr_ret (Py_None);
+ if( self->bone->parent ) {
+ return Bone_CreatePyObject( self->bone->parent );
+ } else {
+ return EXPP_incr_ret( Py_None );
}
}
}
-//--------------- BPy_Bone.getChildren()--------------------------------------------------------------------------
-static PyObject *
-Bone_getChildren (BPy_Bone * self)
+
+//--------------- BPy_Bone.getChildren()-----------------------------
+static PyObject *Bone_getChildren( BPy_Bone * self )
{
- int totbones = 0;
- Bone *current = NULL;
- PyObject *listbones = NULL;
- int i;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- return EXPP_incr_ret (Py_None);
- }else{
- //use bone datastruct
- current = self->bone->childbase.first;
- for (; current; current = current->next)
- totbones++;
-
- /* Create a list with a bone wrapper for each bone */
- current = self->bone->childbase.first;
- listbones = PyList_New (totbones);
- for (i = 0; i < totbones; i++){
- assert (current);
- PyList_SetItem (listbones, i, Bone_CreatePyObject (current));
- current = current->next;
- }
- return listbones;
- }
+ int totbones = 0;
+ Bone *current = NULL;
+ PyObject *listbones = NULL;
+ int i;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ return EXPP_incr_ret( Py_None );
+ } else {
+ //use bone datastruct
+ current = self->bone->childbase.first;
+ for( ; current; current = current->next )
+ totbones++;
+
+ /* Create a list with a bone wrapper for each bone */
+ current = self->bone->childbase.first;
+ listbones = PyList_New( totbones );
+ for( i = 0; i < totbones; i++ ) {
+ assert( current );
+ PyList_SetItem( listbones, i,
+ Bone_CreatePyObject( current ) );
+ current = current->next;
+ }
+ return listbones;
+ }
}
-//--------------- BPy_Bone.setName()--------------------------------------------------------------------------
-static PyObject *
-Bone_setName (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setName()---------------------------------
+static PyObject *Bone_setName( BPy_Bone * self, PyObject * args )
{
- char *name;
-
- if (!PyArg_ParseTuple (args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected string argument"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- BLI_strncpy(self->name, name, strlen(name) + 1);
- }else{
- //use bone datastruct
- BLI_strncpy(self->bone->name, name, strlen(name) + 1);
- }
- return EXPP_incr_ret (Py_None);
+ char *name;
+
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected string argument" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ BLI_strncpy( self->name, name, strlen( name ) + 1 );
+ } else {
+ //use bone datastruct
+ BLI_strncpy( self->bone->name, name, strlen( name ) + 1 );
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setRoll()--------------------------------------------------------------------------
-PyObject *
-Bone_setRoll (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setRoll()--------------------------------
+PyObject *Bone_setRoll( BPy_Bone * self, PyObject * args )
{
- float roll;
-
- if (!PyArg_ParseTuple (args, "f", &roll))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->roll = roll;
- }else{
- //use bone datastruct
- self->bone->roll = roll;
- }
- return EXPP_incr_ret (Py_None);
+ float roll;
+
+ if( !PyArg_ParseTuple( args, "f", &roll ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->roll = roll;
+ } else {
+ //use bone datastruct
+ self->bone->roll = roll;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setHead()--------------------------------------------------------------------------
-static PyObject *
-Bone_setHead (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setHead()---------------------------------
+static PyObject *Bone_setHead( BPy_Bone * self, PyObject * args )
{
- float f1, f2, f3;
- int status;
+ float f1, f2, f3;
+ int status;
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3);
- else
- status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3);
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &f1, &f2, &f3 );
+ else
+ status = PyArg_ParseTuple( args, "(fff)", &f1, &f2, &f3 );
- if (!status)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 3 (or a list of 3) float arguments"));
+ if( !status )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 3 (or a list of 3) float arguments" ) );
- if (!self->bone) { //test to see if linked to armature
+ if( !self->bone ) { //test to see if linked to armature
//use python vars
self->head->vec[0] = f1;
self->head->vec[1] = f2;
self->head->vec[2] = f3;
- }else{
+ } else {
//use bone datastruct
self->bone->head[0] = f1;
self->bone->head[1] = f2;
self->bone->head[2] = f3;
- }
- return EXPP_incr_ret (Py_None);
-}
-//--------------- BPy_Bone.setTail()--------------------------------------------------------------------------
-static PyObject *
-Bone_setTail (BPy_Bone * self, PyObject * args)
-{
- float f1, f2, f3;
- int status;
-
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3);
- else
- status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3);
-
- if (!status)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 3 (or a list of 3) float arguments"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->tail->vec[0] = f1;
- self->tail->vec[1] = f2;
- self->tail->vec[2] = f3;
- }else{
- //use bone datastruct
- self->bone->tail[0] = f1;
- self->bone->tail[1] = f2;
- self->bone->tail[2] = f3;
- }
- return EXPP_incr_ret (Py_None);
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setLoc()--------------------------------------------------------------------------
-static PyObject *
-Bone_setLoc (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setTail()---------------------------------
+static PyObject *Bone_setTail( BPy_Bone * self, PyObject * args )
{
- float f1, f2, f3;
- int status;
-
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3);
- else
- status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3);
-
- if (!status)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 3 (or a list of 3) float arguments"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->loc->vec[0] = f1;
- self->loc->vec[1] = f2;
- self->loc->vec[2] = f3;
- }else{
- //use bone datastruct
- self->bone->loc[0] = f1;
- self->bone->loc[1] = f2;
- self->bone->loc[2] = f3;
- }
- return EXPP_incr_ret (Py_None);
+ float f1, f2, f3;
+ int status;
+
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &f1, &f2, &f3 );
+ else
+ status = PyArg_ParseTuple( args, "(fff)", &f1, &f2, &f3 );
+
+ if( !status )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 3 (or a list of 3) float arguments" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->tail->vec[0] = f1;
+ self->tail->vec[1] = f2;
+ self->tail->vec[2] = f3;
+ } else {
+ //use bone datastruct
+ self->bone->tail[0] = f1;
+ self->bone->tail[1] = f2;
+ self->bone->tail[2] = f3;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setSize()--------------------------------------------------------------------------
-static PyObject *
-Bone_setSize (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setLoc()----------------------------------
+static PyObject *Bone_setLoc( BPy_Bone * self, PyObject * args )
{
- float f1, f2, f3;
- int status;
-
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3);
- else
- status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3);
-
- if (!status)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 3 (or a list of 3) float arguments"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->size->vec[0] = f1;
- self->size->vec[1] = f2;
- self->size->vec[2] = f3;
- }else{
- //use bone datastruct
- self->bone->size[0] = f1;
- self->bone->size[1] = f2;
- self->bone->size[2] = f3;
- }
- return EXPP_incr_ret (Py_None);
+ float f1, f2, f3;
+ int status;
+
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &f1, &f2, &f3 );
+ else
+ status = PyArg_ParseTuple( args, "(fff)", &f1, &f2, &f3 );
+
+ if( !status )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 3 (or a list of 3) float arguments" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->loc->vec[0] = f1;
+ self->loc->vec[1] = f2;
+ self->loc->vec[2] = f3;
+ } else {
+ //use bone datastruct
+ self->bone->loc[0] = f1;
+ self->bone->loc[1] = f2;
+ self->bone->loc[2] = f3;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setQuat()--------------------------------------------------------------------------
-static PyObject *
-Bone_setQuat (BPy_Bone * self, PyObject * args)
+
+//--------------- BPy_Bone.setSize()---------------------------------
+static PyObject *Bone_setSize( BPy_Bone * self, PyObject * args )
{
- float f1, f2, f3, f4;
- PyObject *argument;
- QuaternionObject *quatOb;
- int status;
+ float f1, f2, f3;
+ int status;
+
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &f1, &f2, &f3 );
+ else
+ status = PyArg_ParseTuple( args, "(fff)", &f1, &f2, &f3 );
- if (!PyArg_ParseTuple(args, "O", &argument))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected quaternion or float list"));
+ if( !status )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 3 (or a list of 3) float arguments" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->size->vec[0] = f1;
+ self->size->vec[1] = f2;
+ self->size->vec[2] = f3;
+ } else {
+ //use bone datastruct
+ self->bone->size[0] = f1;
+ self->bone->size[1] = f2;
+ self->bone->size[2] = f3;
+ }
+ return EXPP_incr_ret( Py_None );
+}
- if(QuaternionObject_Check(argument)){
- status = PyArg_ParseTuple(args, "O!", &quaternion_Type, &quatOb);
+//--------------- BPy_Bone.setQuat()-------------------------------
+static PyObject *Bone_setQuat( BPy_Bone * self, PyObject * args )
+{
+ float f1, f2, f3, f4;
+ PyObject *argument;
+ QuaternionObject *quatOb;
+ int status;
+
+ if( !PyArg_ParseTuple( args, "O", &argument ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected quaternion or float list" ) );
+
+ if( QuaternionObject_Check( argument ) ) {
+ status = PyArg_ParseTuple( args, "O!", &quaternion_Type,
+ &quatOb );
f1 = quatOb->quat[0];
f2 = quatOb->quat[1];
f3 = quatOb->quat[2];
f4 = quatOb->quat[3];
- }else{
- status = PyArg_ParseTuple (args, "(ffff)", &f1, &f2, &f3, &f4);
- }
-
- if (!status)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unable to parse argument"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->quat->quat[0] = f1;
- self->quat->quat[1] = f2;
- self->quat->quat[2] = f3;
- self->quat->quat[3] = f4;
- }else{
- //use bone datastruct
- self->bone->quat[0] = f1;
- self->bone->quat[1] = f2;
- self->bone->quat[2] = f3;
- self->bone->quat[3] = f4;
- }
- return EXPP_incr_ret (Py_None);
+ } else {
+ status = PyArg_ParseTuple( args, "(ffff)", &f1, &f2, &f3,
+ &f4 );
+ }
+
+ if( !status )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unable to parse argument" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->quat->quat[0] = f1;
+ self->quat->quat[1] = f2;
+ self->quat->quat[2] = f3;
+ self->quat->quat[3] = f4;
+ } else {
+ //use bone datastruct
+ self->bone->quat[0] = f1;
+ self->bone->quat[1] = f2;
+ self->bone->quat[2] = f3;
+ self->bone->quat[3] = f4;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setParent()-------------------------------------------------------------------------
-static PyObject *
-Bone_setParent(BPy_Bone *self, PyObject *args)
+
+//--------------- BPy_Bone.setParent()------------------------------
+static PyObject *Bone_setParent( BPy_Bone * self, PyObject * args )
{
- BPy_Bone* py_bone;
+ BPy_Bone *py_bone;
float M_boneObjectspace[4][4];
float iM_parentRest[4][4];
- if (!PyArg_ParseTuple(args, "O", &py_bone))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected bone object argument"));
+ if( !PyArg_ParseTuple( args, "O", &py_bone ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected bone object argument" ) );
- if (!self->bone) { //test to see if linked to armature
+ if( !self->bone ) { //test to see if linked to armature
//use python vars
- BLI_strncpy(self->parent, py_bone->name, strlen(py_bone->name) + 1);
- }else{
+ BLI_strncpy( self->parent, py_bone->name,
+ strlen( py_bone->name ) + 1 );
+ } else {
//use bone datastruct
- if(!py_bone->bone)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Parent bone must be linked to armature first!"));
+ if( !py_bone->bone )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "Parent bone must be linked to armature first!" ) );
- if(py_bone->bone == self->bone)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "Cannot parent to self"));
+ if( py_bone->bone == self->bone )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "Cannot parent to self" ) );
//test to see if were creating an illegal loop by parenting to child
- if(testChildbase(self->bone, py_bone->bone))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "Cannot parent to child"));
+ if( testChildbase( self->bone, py_bone->bone ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "Cannot parent to child" ) );
- //set the parent of self - in this case we are changing the parenting after this bone
+ //set the parent of self - in this case
+ //we are changing the parenting after this bone
//has been linked in it's armature
- if(self->bone->parent){ //we are parenting something previously parented
+ if( self->bone->parent ) { //we are parenting something previously parented
//remove the childbase link from the parent bone
- BLI_remlink(&self->bone->parent->childbase, self->bone);
+ BLI_remlink( &self->bone->parent->childbase,
+ self->bone );
//now get rid of the parent transformation
- get_objectspace_bone_matrix(self->bone->parent, M_boneObjectspace, 0,0);
- Mat4MulVecfl(M_boneObjectspace, self->bone->head);
- Mat4MulVecfl(M_boneObjectspace, self->bone->tail);
-
+ get_objectspace_bone_matrix( self->bone->parent,
+ M_boneObjectspace, 0, 0 );
+ Mat4MulVecfl( M_boneObjectspace, self->bone->head );
+ Mat4MulVecfl( M_boneObjectspace, self->bone->tail );
+
//add to the childbase of new parent
- BLI_addtail (&py_bone->bone->childbase, self->bone);
+ BLI_addtail( &py_bone->bone->childbase, self->bone );
//transform bone according to new parent
- get_objectspace_bone_matrix(py_bone->bone, M_boneObjectspace, 0,0);
- Mat4Invert (iM_parentRest, M_boneObjectspace);
- Mat4MulVecfl(iM_parentRest, self->bone->head);
- Mat4MulVecfl(iM_parentRest, self->bone->tail);
+ get_objectspace_bone_matrix( py_bone->bone,
+ M_boneObjectspace, 0, 0 );
+ Mat4Invert( iM_parentRest, M_boneObjectspace );
+ Mat4MulVecfl( iM_parentRest, self->bone->head );
+ Mat4MulVecfl( iM_parentRest, self->bone->tail );
//set parent
self->bone->parent = py_bone->bone;
- }else{ //not previously parented
+ } else { //not previously parented
//add to the childbase of new parent
- BLI_addtail (&py_bone->bone->childbase, self->bone);
+ BLI_addtail( &py_bone->bone->childbase, self->bone );
//transform bone according to new parent
- get_objectspace_bone_matrix(py_bone->bone, M_boneObjectspace, 0,0);
- Mat4Invert (iM_parentRest, M_boneObjectspace);
- Mat4MulVecfl(iM_parentRest, self->bone->head);
- Mat4MulVecfl(iM_parentRest, self->bone->tail);
+ get_objectspace_bone_matrix( py_bone->bone,
+ M_boneObjectspace, 0, 0 );
+ Mat4Invert( iM_parentRest, M_boneObjectspace );
+ Mat4MulVecfl( iM_parentRest, self->bone->head );
+ Mat4MulVecfl( iM_parentRest, self->bone->tail );
self->bone->parent = py_bone->bone;
}
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setWeight()-------------------------------------------------------------------------
-static PyObject *
-Bone_setWeight(BPy_Bone *self, PyObject *args)
+
+//--------------- BPy_Bone.setWeight()----------------------------
+static PyObject *Bone_setWeight( BPy_Bone * self, PyObject * args )
{
- float weight;
-
- if (!PyArg_ParseTuple (args, "f", &weight))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->weight = weight;
- }else{
- //use bone datastruct
- self->bone->weight = weight;
- }
- return EXPP_incr_ret (Py_None);
+ float weight;
+
+ if( !PyArg_ParseTuple( args, "f", &weight ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->weight = weight;
+ } else {
+ //use bone datastruct
+ self->bone->weight = weight;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.clearParent()-------------------------------------------------------------------------
-static PyObject *
-Bone_clearParent(BPy_Bone *self)
+
+//--------------- BPy_Bone.clearParent()--------------------------
+static PyObject *Bone_clearParent( BPy_Bone * self )
{
- bArmature *arm = NULL;
- Bone *bone = NULL;
- Bone *parent = NULL;
- Bone *child = NULL;
- Bone *childPrev = NULL;
- int firstChild;
- float M_boneObjectspace[4][4];
- char *parent_str = "";
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- BLI_strncpy(self->parent, parent_str, strlen(parent_str) + 1);
- }else{
- //use bone datastruct
- if(self->bone->parent == NULL)
- return EXPP_incr_ret(Py_None);
-
- //get parent and remove link
- parent = self->bone->parent;
- self->bone->parent = NULL;
-
- //remove the childbase link from the parent bone
- firstChild = 1;
- for(child = parent->childbase.first; child; child = child->next){
- if(child == self->bone && firstChild){
+ bArmature *arm = NULL;
+ Bone *bone = NULL;
+ Bone *parent = NULL;
+ Bone *child = NULL;
+ Bone *childPrev = NULL;
+ int firstChild;
+ float M_boneObjectspace[4][4];
+ char *parent_str = "";
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ BLI_strncpy( self->parent, parent_str,
+ strlen( parent_str ) + 1 );
+ } else {
+ //use bone datastruct
+ if( self->bone->parent == NULL )
+ return EXPP_incr_ret( Py_None );
+
+ //get parent and remove link
+ parent = self->bone->parent;
+ self->bone->parent = NULL;
+
+ //remove the childbase link from the parent bone
+ firstChild = 1;
+ for( child = parent->childbase.first; child;
+ child = child->next ) {
+ if( child == self->bone && firstChild ) {
parent->childbase.first = child->next;
child->next = NULL;
break;
+ }
+ if( child == self->bone && !firstChild ) {
+ childPrev->next = child->next;
+ child->next = NULL;
+ break;
+ }
+ firstChild = 0;
+ childPrev = child;
}
- if(child == self->bone && !firstChild){
- childPrev->next = child->next;
- child->next = NULL;
- break;
- }
- firstChild = 0;
- childPrev = child;
- }
- //now get rid of the parent transformation
- get_objectspace_bone_matrix(parent, M_boneObjectspace, 0,0);
+ //now get rid of the parent transformation
+ get_objectspace_bone_matrix( parent, M_boneObjectspace, 0, 0 );
- //transformation of local bone
- Mat4MulVecfl(M_boneObjectspace, self->bone->head);
- Mat4MulVecfl(M_boneObjectspace, self->bone->tail);
+ //transformation of local bone
+ Mat4MulVecfl( M_boneObjectspace, self->bone->head );
+ Mat4MulVecfl( M_boneObjectspace, self->bone->tail );
- //get the root bone
- while(parent->parent != NULL){
- parent = parent->parent;
- }
+ //get the root bone
+ while( parent->parent != NULL ) {
+ parent = parent->parent;
+ }
- //add unlinked bone to the bonebase of the armature
- for (arm = G.main->armature.first; arm; arm= arm->id.next) {
- for(bone = arm->bonebase.first; bone; bone = bone->next){
- if(parent == bone){
- //we found the correct armature - now add it as root bone
- BLI_addtail (&arm->bonebase, self->bone);
- break;
+ //add unlinked bone to the bonebase of the armature
+ for( arm = G.main->armature.first; arm; arm = arm->id.next ) {
+ for( bone = arm->bonebase.first; bone;
+ bone = bone->next ) {
+ if( parent == bone ) {
+ //we found the correct armature - now add it as root bone
+ BLI_addtail( &arm->bonebase,
+ self->bone );
+ break;
+ }
}
- }
+ }
}
- }
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.clearChildren()-------------------------------------------------------------------------
-static PyObject *
-Bone_clearChildren(BPy_Bone *self)
-{
- Bone *root = NULL;
- Bone *child = NULL;
- bArmature *arm = NULL;
- Bone *bone = NULL;
- Bone *prev = NULL;
- Bone *next = NULL;
- float M_boneObjectspace[4][4];
- int first;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- return EXPP_incr_ret (Py_None);
- }else{
- //use bone datastruct
- if(self->bone->childbase.first == NULL)
- return EXPP_incr_ret(Py_None);
+
+//--------------- BPy_Bone.clearChildren()------------------------
+static PyObject *Bone_clearChildren( BPy_Bone * self )
+{
+ Bone *root = NULL;
+ Bone *child = NULL;
+ bArmature *arm = NULL;
+ Bone *bone = NULL;
+ Bone *prev = NULL;
+ Bone *next = NULL;
+ float M_boneObjectspace[4][4];
+ int first;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ return EXPP_incr_ret( Py_None );
+ } else {
+ //use bone datastruct
+ if( self->bone->childbase.first == NULL )
+ return EXPP_incr_ret( Py_None );
//is this bone a part of an armature....
//get root bone for testing
root = self->bone->parent;
- if(root != NULL){
- while (root->parent != NULL){
+ if( root != NULL ) {
+ while( root->parent != NULL ) {
root = root->parent;
}
- }else{
+ } else {
root = self->bone;
}
//test armatures for root bone
- for(arm= G.main->armature.first; arm; arm = arm->id.next){
- for(bone = arm->bonebase.first; bone; bone = bone->next){
- if(bone == root)
+ for( arm = G.main->armature.first; arm; arm = arm->id.next ) {
+ for( bone = arm->bonebase.first; bone;
+ bone = bone->next ) {
+ if( bone == root )
break;
}
- if(bone == root)
+ if( bone == root )
break;
}
- if(arm == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't find armature that contains this bone"));
-
- //now get rid of the parent transformation
- get_objectspace_bone_matrix(self->bone, M_boneObjectspace, 0,0);
-
- //set children as root
- first = 1;
- for(child = self->bone->childbase.first; child; child = next){
- //undo transformation of local bone
- Mat4MulVecfl(M_boneObjectspace, child->head);
- Mat4MulVecfl(M_boneObjectspace, child->tail);
-
- //set next pointers to NULL
- if(first){
- prev = child;
- first = 0;
- }else{
- prev->next = NULL;
- prev = child;
- }
- next = child->next;
+ if( arm == NULL )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "couldn't find armature that contains this bone" ) );
+
+ //now get rid of the parent transformation
+ get_objectspace_bone_matrix( self->bone, M_boneObjectspace, 0,
+ 0 );
+
+ //set children as root
+ first = 1;
+ for( child = self->bone->childbase.first; child; child = next ) {
+ //undo transformation of local bone
+ Mat4MulVecfl( M_boneObjectspace, child->head );
+ Mat4MulVecfl( M_boneObjectspace, child->tail );
+
+ //set next pointers to NULL
+ if( first ) {
+ prev = child;
+ first = 0;
+ } else {
+ prev->next = NULL;
+ prev = child;
+ }
+ next = child->next;
- //remove parenting and linking
- child->parent = NULL;
- BLI_remlink(&self->bone->childbase, child);
+ //remove parenting and linking
+ child->parent = NULL;
+ BLI_remlink( &self->bone->childbase, child );
- //add as root
- BLI_addtail (&arm->bonebase, child);
+ //add as root
+ BLI_addtail( &arm->bonebase, child );
+ }
}
- }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-//--------------- BPy_Bone.hide()---------------------------------------------------------------------------------
-static PyObject *
-Bone_hide(BPy_Bone *self)
+
+//--------------- BPy_Bone.hide()-----------------------------------
+static PyObject *Bone_hide( BPy_Bone * self )
{
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- return EXPP_ReturnPyObjError (PyExc_TypeError, "link bone to armature before attempting to hide/unhide");
- }else{
- //use bone datastruct
- if(!(self->bone->flag & BONE_HIDDEN))
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "link bone to armature before attempting to hide/unhide" );
+ } else {
+ //use bone datastruct
+ if( !( self->bone->flag & BONE_HIDDEN ) )
self->bone->flag |= BONE_HIDDEN;
- }
- return EXPP_incr_ret (Py_None);
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.unhide()---------------------------------------------------------------------------------
-static PyObject *
-Bone_unhide(BPy_Bone *self)
+
+//--------------- BPy_Bone.unhide()-------------------------------
+static PyObject *Bone_unhide( BPy_Bone * self )
{
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- return EXPP_ReturnPyObjError (PyExc_TypeError, "link bone to armature before attempting to hide/unhide");
- }else{
- //use bone datastruct
- if(self->bone->flag & BONE_HIDDEN)
- self->bone->flag &= ~BONE_HIDDEN;
- }
- return EXPP_incr_ret (Py_None);
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "link bone to armature before attempting to hide/unhide" );
+ } else {
+ //use bone datastruct
+ if( self->bone->flag & BONE_HIDDEN )
+ self->bone->flag &= ~BONE_HIDDEN;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.setPose()-----------------------------------------------------------------------------------
-static PyObject *
-Bone_setPose (BPy_Bone *self, PyObject *args)
+
+//--------------- BPy_Bone.setPose()-------------------------------
+static PyObject *Bone_setPose( BPy_Bone * self, PyObject * args )
{
Bone *root = NULL;
bPoseChannel *chan = NULL;
bPoseChannel *setChan = NULL;
bPoseChannel *test = NULL;
- Object *object =NULL;
+ Object *object = NULL;
bArmature *arm = NULL;
Bone *bone = NULL;
PyObject *flaglist = NULL;
@@ -1331,230 +1466,253 @@ Bone_setPose (BPy_Bone *self, PyObject *args)
int flagValue = 0;
int makeCurve = 1;
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- return EXPP_ReturnPyObjError (PyExc_TypeError, "cannot set pose unless bone is linked to armature");
- }else{
- //use bone datastruct
- if (!PyArg_ParseTuple (args, "O!|O!", &PyList_Type, &flaglist, &Action_Type, &py_action))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list of flags and optional action"));
-
- for(x = 0; x < PyList_Size(flaglist); x++){
- item = PyList_GetItem(flaglist, x);
- if(PyInt_Check(item)){
- flagValue |= PyInt_AsLong(item);
- }else{
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list of flags (ints)"));
- }
- }
-
- //is this bone a part of an armature....
- //get root bone for testing
- root = self->bone->parent;
- if(root != NULL){
- while (root->parent != NULL){
- root = root->parent;
- }
- }else{
- root = self->bone;
- }
- //test armatures for root bone
- for(arm= G.main->armature.first; arm; arm = arm->id.next){
- for(bone = arm->bonebase.first; bone; bone = bone->next){
- if(bone == root)
- break;
- }
- if(bone == root)
- break;
- }
- if(arm == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "bone must belong to an armature to set it's pose!"));
-
- //find if armature is object linked....
- for(object = G.main->object.first; object; object = object->id.next){
- if(object->data == arm){
- break;
- }
- }
-
- if(object == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "armature must be linked to an object to set a pose!"));
-
- //set the active action as this one
- if(py_action !=NULL){
- if(py_action->action != NULL){
- object->action = py_action->action;
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "cannot set pose unless bone is linked to armature" );
+ } else {
+ //use bone datastruct
+ if( !PyArg_ParseTuple
+ ( args, "O!|O!", &PyList_Type, &flaglist, &Action_Type,
+ &py_action ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected list of flags and optional action" ) );
+
+ for( x = 0; x < PyList_Size( flaglist ); x++ ) {
+ item = PyList_GetItem( flaglist, x );
+ if( PyInt_Check( item ) ) {
+ flagValue |= PyInt_AsLong( item );
+ } else {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected list of flags (ints)" ) );
+ }
+ }
+
+ //is this bone a part of an armature....
+ //get root bone for testing
+ root = self->bone->parent;
+ if( root != NULL ) {
+ while( root->parent != NULL ) {
+ root = root->parent;
+ }
+ } else {
+ root = self->bone;
}
- }
-
- //if object doesn't have a pose create one
- if (!object->pose)
- object->pose = MEM_callocN(sizeof(bPose), "Pose");
-
- //if bone does have a channel create one
- verify_pose_channel(object->pose, self->bone->name);
- //create temp Pose Channel
- chan = MEM_callocN(sizeof(bPoseChannel), "PoseChannel");
- //set the variables for this pose
- memcpy (chan->loc, self->bone->loc, sizeof (chan->loc));
- memcpy (chan->quat, self->bone->quat, sizeof (chan->quat));
- memcpy (chan->size, self->bone->size, sizeof (chan->size));
- strcpy (chan->name, self->bone->name);
- chan->flag |= flagValue;
- //set it to the channel
- setChan = set_pose_channel(object->pose, chan);
- //frees unlinked pose/bone channels from object
- collect_pose_garbage(object);
-
- //create an action if one not already assigned to object
- if (!py_action && !object->action){
- object->action = (bAction*)add_empty_action();
- object->ipowin= ID_AC;
- }else{
- //test if posechannel is already in action
- for(test = object->action->chanbase.first; test; test = test->next){
- if(test == setChan)
- makeCurve = 0; //already there
+ //test armatures for root bone
+ for( arm = G.main->armature.first; arm; arm = arm->id.next ) {
+ for( bone = arm->bonebase.first; bone;
+ bone = bone->next ) {
+ if( bone == root )
+ break;
+ }
+ if( bone == root )
+ break;
+ }
+ if( arm == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "bone must belong to an armature to set it's pose!" ) );
+
+ //find if armature is object linked....
+ for( object = G.main->object.first; object;
+ object = object->id.next ) {
+ if( object->data == arm ) {
+ break;
+ }
}
- }
-
- //set action keys
- if (setChan->flag & POSE_ROT){
- set_action_key(object->action, setChan, AC_QUAT_X, makeCurve);
- set_action_key(object->action, setChan, AC_QUAT_Y, makeCurve);
- set_action_key(object->action, setChan, AC_QUAT_Z, makeCurve);
- set_action_key(object->action, setChan, AC_QUAT_W, makeCurve);
- }
- if (setChan->flag & POSE_SIZE){
- set_action_key(object->action, setChan, AC_SIZE_X, makeCurve);
- set_action_key(object->action, setChan, AC_SIZE_Y, makeCurve);
- set_action_key(object->action, setChan, AC_SIZE_Z, makeCurve);
- }
- if (setChan->flag & POSE_LOC){
- set_action_key(object->action, setChan, AC_LOC_X, makeCurve);
- set_action_key(object->action, setChan, AC_LOC_Y, makeCurve);
- set_action_key(object->action, setChan, AC_LOC_Z, makeCurve);
- }
- //rebuild ipos
- remake_action_ipos(object->action);
-
- //rebuild displists
- rebuild_all_armature_displists();
+
+ if( object == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "armature must be linked to an object to set a pose!" ) );
+
+ //set the active action as this one
+ if( py_action != NULL ) {
+ if( py_action->action != NULL ) {
+ object->action = py_action->action;
+ }
+ }
+ //if object doesn't have a pose create one
+ if( !object->pose )
+ object->pose = MEM_callocN( sizeof( bPose ), "Pose" );
+
+ //if bone does have a channel create one
+ verify_pose_channel( object->pose, self->bone->name );
+ //create temp Pose Channel
+ chan = MEM_callocN( sizeof( bPoseChannel ), "PoseChannel" );
+ //set the variables for this pose
+ memcpy( chan->loc, self->bone->loc, sizeof( chan->loc ) );
+ memcpy( chan->quat, self->bone->quat, sizeof( chan->quat ) );
+ memcpy( chan->size, self->bone->size, sizeof( chan->size ) );
+ strcpy( chan->name, self->bone->name );
+ chan->flag |= flagValue;
+ //set it to the channel
+ setChan = set_pose_channel( object->pose, chan );
+ //frees unlinked pose/bone channels from object
+ collect_pose_garbage( object );
+
+ //create an action if one not already assigned to object
+ if( !py_action && !object->action ) {
+ object->action = ( bAction * ) add_empty_action( );
+ object->ipowin = ID_AC;
+ } else {
+ //test if posechannel is already in action
+ for( test = object->action->chanbase.first; test;
+ test = test->next ) {
+ if( test == setChan )
+ makeCurve = 0; //already there
+ }
+ }
+
+ //set action keys
+ if( setChan->flag & POSE_ROT ) {
+ set_action_key( object->action, setChan, AC_QUAT_X,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_QUAT_Y,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_QUAT_Z,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_QUAT_W,
+ makeCurve );
+ }
+ if( setChan->flag & POSE_SIZE ) {
+ set_action_key( object->action, setChan, AC_SIZE_X,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_SIZE_Y,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_SIZE_Z,
+ makeCurve );
+ }
+ if( setChan->flag & POSE_LOC ) {
+ set_action_key( object->action, setChan, AC_LOC_X,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_LOC_Y,
+ makeCurve );
+ set_action_key( object->action, setChan, AC_LOC_Z,
+ makeCurve );
+ }
+ //rebuild ipos
+ remake_action_ipos( object->action );
+
+ //rebuild displists
+ rebuild_all_armature_displists( );
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.getBoneclass()----------------------------------------------------------------------------
-static PyObject *
-Bone_getBoneclass (BPy_Bone * self)
+//--------------- BPy_Bone.getBoneclass()--------------------------
+static PyObject *Bone_getBoneclass( BPy_Bone * self )
{
- PyObject *attr = NULL;
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- attr = returnBoneclassEnum(self->boneclass);
- }else{
- //use bone datastruct
- attr = returnBoneclassEnum(self->bone->boneclass);
- }
- if (attr)
- return attr;
-
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.Boneclass attribute"));
+ PyObject *attr = NULL;
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ attr = returnBoneclassEnum( self->boneclass );
+ } else {
+ //use bone datastruct
+ attr = returnBoneclassEnum( self->bone->boneclass );
+ }
+ if( attr )
+ return attr;
+
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.Boneclass attribute" ) );
}
-//--------------- BPy_Bone.setBoneclass()-------------------------------------------------------------------------
-static PyObject *
-Bone_setBoneclass(BPy_Bone *self, PyObject *args)
+
+//--------------- BPy_Bone.setBoneclass()---------------------------
+static PyObject *Bone_setBoneclass( BPy_Bone * self, PyObject * args )
{
- int boneclass;
-
- if (!PyArg_ParseTuple (args, "i", &boneclass))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected enum argument"));
-
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- self->boneclass = boneclass;
- }else{
- //use bone datastruct
- self->bone->boneclass = boneclass;
- }
- return EXPP_incr_ret (Py_None);
+ int boneclass;
+
+ if( !PyArg_ParseTuple( args, "i", &boneclass ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected enum argument" ) );
+
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ self->boneclass = boneclass;
+ } else {
+ //use bone datastruct
+ self->bone->boneclass = boneclass;
+ }
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Bone.hasIK()----------------------------------------------------------------------------
-static PyObject *
-Bone_hasIK (BPy_Bone * self)
+
+//--------------- BPy_Bone.hasIK()-------------------------------
+static PyObject *Bone_hasIK( BPy_Bone * self )
{
- if (!self->bone) { //test to see if linked to armature
- //use python vars
- if(self->flag & BONE_IK_TOPARENT){
- Py_INCREF (Py_True);
+ if( !self->bone ) { //test to see if linked to armature
+ //use python vars
+ if( self->flag & BONE_IK_TOPARENT ) {
+ Py_INCREF( Py_True );
return Py_True;
- }else{
- Py_INCREF (Py_False);
+ } else {
+ Py_INCREF( Py_False );
return Py_False;
- }
- }else{
- //use bone datastruct
- if(self->bone->flag & BONE_IK_TOPARENT){
- Py_INCREF (Py_True);
+ }
+ } else {
+ //use bone datastruct
+ if( self->bone->flag & BONE_IK_TOPARENT ) {
+ Py_INCREF( Py_True );
return Py_True;
- }else{
- Py_INCREF (Py_False);
+ } else {
+ Py_INCREF( Py_False );
return Py_False;
- }
- }
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Bone.Boneclass attribute"));
+ }
+ }
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Bone.Boneclass attribute" ) );
}
-//--------------- BPy_Bone.getRestMatrix()----------------------------------------------------------------------------
-static PyObject *
-Bone_getRestMatrix(BPy_Bone * self, PyObject *args)
+
+//--------------- BPy_Bone.getRestMatrix()-------------------------
+static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args )
{
char *local = "worldspace";
char *bonespace = "bonespace";
char *worldspace = "worldspace";
- PyObject *matrix;
+ PyObject *matrix;
float delta[3];
float root[3];
float p_root[3];
- if (!PyArg_ParseTuple (args, "|s", &local))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string"));
+ if( !PyArg_ParseTuple( args, "|s", &local ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string" ) );
- if(!BLI_streq(local, bonespace) && !BLI_streq(local, worldspace))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 'bonespace' or 'worldspace'"));
+ if( !BLI_streq( local, bonespace ) && !BLI_streq( local, worldspace ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 'bonespace' or 'worldspace'" ) );
- matrix = newMatrixObject(PyMem_Malloc(16 * sizeof(float)),4,4);
+ matrix = newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 );
- if (!self->bone) { //test to see if linked to armature
+ if( !self->bone ) { //test to see if linked to armature
//use python vars
- if(BLI_streq(local, worldspace)){
- VecSubf (delta, self->tail->vec, self->head->vec);
- make_boneMatrixvr( *((MatrixObject*)matrix)->matrix, delta, self->roll);
- }else if(BLI_streq(local, bonespace)){
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "bone not yet linked to an armature....'"));
+ if( BLI_streq( local, worldspace ) ) {
+ VecSubf( delta, self->tail->vec, self->head->vec );
+ make_boneMatrixvr( *( ( MatrixObject * ) matrix )->
+ matrix, delta, self->roll );
+ } else if( BLI_streq( local, bonespace ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "bone not yet linked to an armature....'" ) );
}
- }else{
+ } else {
//use bone datastruct
- if(BLI_streq(local, worldspace)){
- get_objectspace_bone_matrix (self->bone, *((MatrixObject*)matrix)->matrix, 1, 1);
- }else if(BLI_streq(local, bonespace)){
- VecSubf (delta, self->bone->tail, self->bone->head);
- make_boneMatrixvr( *((MatrixObject*)matrix)->matrix, delta, self->bone->roll);
- if(self->bone->parent){
- get_bone_root_pos(self->bone,root,1);
- get_bone_root_pos(self->bone->parent,p_root,1);
- VecSubf(delta,root,p_root);
- VECCOPY(((MatrixObject*)matrix)->matrix[3], delta);
+ if( BLI_streq( local, worldspace ) ) {
+ get_objectspace_bone_matrix( self->bone,
+ *( ( MatrixObject * )
+ matrix )->matrix, 1,
+ 1 );
+ } else if( BLI_streq( local, bonespace ) ) {
+ VecSubf( delta, self->bone->tail, self->bone->head );
+ make_boneMatrixvr( *( ( MatrixObject * ) matrix )->
+ matrix, delta, self->bone->roll );
+ if( self->bone->parent ) {
+ get_bone_root_pos( self->bone, root, 1 );
+ get_bone_root_pos( self->bone->parent, p_root,
+ 1 );
+ VecSubf( delta, root, p_root );
+ VECCOPY( ( ( MatrixObject * ) matrix )->
+ matrix[3], delta );
}
}
}
diff --git a/source/blender/python/api2_2x/Bone.h b/source/blender/python/api2_2x/Bone.h
index 06c1df3529e..088616da591 100644
--- a/source/blender/python/api2_2x/Bone.h
+++ b/source/blender/python/api2_2x/Bone.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -38,39 +39,39 @@
#include "quat.h"
#include "matrix.h"
-//--------------------------Python BPy_Bone structure definition.---------------------
-typedef struct{
- PyObject_HEAD
- //reference to data if bone is linked to an armature
- Bone *bone;
+//--------------------------Python BPy_Bone structure definition.-------
+typedef struct {
+ PyObject_HEAD
+ //reference to data if bone is linked to an armature
+ Bone * bone;
//list of vars that define the boneclass
- char *name;
+ char *name;
char *parent;
- float roll;
+ float roll;
int flag;
int boneclass;
float dist;
float weight;
- VectorObject *head;
- VectorObject *tail;
- VectorObject *loc;
- VectorObject *dloc;
- VectorObject *size;
- VectorObject *dsize;
+ VectorObject *head;
+ VectorObject *tail;
+ VectorObject *loc;
+ VectorObject *dloc;
+ VectorObject *size;
+ VectorObject *dsize;
QuaternionObject *quat;
QuaternionObject *dquat;
MatrixObject *obmat;
MatrixObject *parmat;
MatrixObject *defmat;
MatrixObject *irestmat;
- MatrixObject *posemat;
-}BPy_Bone;
+ MatrixObject *posemat;
+} BPy_Bone;
-//------------------------------visible prototypes----------------------------------------------
-PyObject *Bone_CreatePyObject (struct Bone *obj);
-int Bone_CheckPyObject (PyObject * py_obj);
-Bone *Bone_FromPyObject (PyObject * py_obj);
-PyObject *Bone_Init (void);
-int updateBoneData(BPy_Bone *self, Bone *parent);
+//------------------------------visible prototypes----------------------
+PyObject *Bone_CreatePyObject( struct Bone *obj );
+int Bone_CheckPyObject( PyObject * py_obj );
+Bone *Bone_FromPyObject( PyObject * py_obj );
+PyObject *Bone_Init( void );
+int updateBoneData( BPy_Bone * self, Bone * parent );
#endif
diff --git a/source/blender/python/api2_2x/Build.c b/source/blender/python/api2_2x/Build.c
index 23485cb4030..a5c4c34219b 100644
--- a/source/blender/python/api2_2x/Build.c
+++ b/source/blender/python/api2_2x/Build.c
@@ -44,18 +44,18 @@
#include <stdio.h>
/*****************************************************************************/
-/* Python BPy_Build methods table: */
+/* Python BPy_Build methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Build_methods[] = {
- {"getLen", (PyCFunction) Build_getLen,
- METH_NOARGS, "()-Return Build len"},
- {"setLen", (PyCFunction) Build_setLen, METH_VARARGS,
- "()- Sets Build len"},
- {"getSfra", (PyCFunction) Build_getSfra,
- METH_NOARGS, "()-Return Build sfra"},
- {"setSfra", (PyCFunction) Build_setSfra, METH_VARARGS,
- "()- Sets Build sfra"},
- {NULL, NULL, 0, NULL}
+ {"getLen", ( PyCFunction ) Build_getLen,
+ METH_NOARGS, "()-Return Build len"},
+ {"setLen", ( PyCFunction ) Build_setLen, METH_VARARGS,
+ "()- Sets Build len"},
+ {"getSfra", ( PyCFunction ) Build_getSfra,
+ METH_NOARGS, "()-Return Build sfra"},
+ {"setSfra", ( PyCFunction ) Build_setSfra, METH_VARARGS,
+ "()- Sets Build sfra"},
+ {NULL, NULL, 0, NULL}
};
@@ -63,26 +63,27 @@ static PyMethodDef BPy_Build_methods[] = {
/* Python Build_Type structure definition: */
/*****************************************************************************/
PyTypeObject Build_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Build", /* tp_name */
- sizeof (BPy_Build), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) BuildDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) BuildGetAttr, /* tp_getattr */
- (setattrfunc) BuildSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) BuildRepr, /* 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_Build_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Build", /* tp_name */
+ sizeof( BPy_Build ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) BuildDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) BuildGetAttr, /* tp_getattr */
+ ( setattrfunc ) BuildSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) BuildRepr, /* 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_Build_methods, /* tp_methods */
+ 0, /* tp_members */
};
@@ -108,224 +109,215 @@ static char M_Build_Get_doc[] = "Build.Get (name = None):\n\
/* Function: M_Build_New */
/* Python equivalent: Blender.Effect.Build.New */
/*****************************************************************************/
-PyObject *
-M_Build_New (PyObject * self, PyObject * args)
+PyObject *M_Build_New( PyObject * self, PyObject * args )
{
- int type = EFF_BUILD;
- BPy_Effect *pyeffect;
- Effect *bleffect = 0;
+ int type = EFF_BUILD;
+ BPy_Effect *pyeffect;
+ Effect *bleffect = 0;
- bleffect = add_effect (type);
- if (bleffect == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Effect Data in Blender"));
+ bleffect = add_effect( type );
+ if( bleffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Effect Data in Blender" ) );
- pyeffect = (BPy_Effect *) PyObject_NEW (BPy_Effect, &Effect_Type);
+ pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
- if (pyeffect == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Effect Data object"));
+ if( pyeffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Effect Data object" ) );
- pyeffect->effect = bleffect;
+ pyeffect->effect = bleffect;
- return (PyObject *) pyeffect;
- return 0;
+ return ( PyObject * ) pyeffect;
+ return 0;
}
/*****************************************************************************/
/* Function: M_Build_Get */
/* Python equivalent: Blender.Effect.Build.Get */
/*****************************************************************************/
-PyObject *
-M_Build_Get (PyObject * self, PyObject * args)
+PyObject *M_Build_Get( PyObject * self, PyObject * args )
{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = 0;
- Object *object_iter;
- Effect *eff;
- BPy_Build *wanted_eff;
- int num, i;
- if (!PyArg_ParseTuple (args, "si", &name, &num))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string int argument"));
-
- object_iter = G.main->object.first;
- if (!object_iter)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Scene contains no object"));
-
- while (object_iter)
- {
- if (strcmp (name, object_iter->id.name + 2))
- {
- object_iter = object_iter->id.next;
- continue;
+ /*arguments : string object name
+ int : position of effect in the obj's effect list */
+ char *name = 0;
+ Object *object_iter;
+ Effect *eff;
+ BPy_Build *wanted_eff;
+ int num, i;
+ if( !PyArg_ParseTuple( args, "si", &name, &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string int argument" ) );
+
+ object_iter = G.main->object.first;
+ if( !object_iter )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Scene contains no object" ) );
+
+ while( object_iter ) {
+ if( strcmp( name, object_iter->id.name + 2 ) ) {
+ object_iter = object_iter->id.next;
+ continue;
+ }
+
+
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ for( i = 0; i < num; i++ ) {
+ if( eff->type != EFF_BUILD )
+ continue;
+ eff = eff->next;
+ if( !eff )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "object not created" ) );
+ }
+ wanted_eff =
+ ( BPy_Build * ) PyObject_NEW( BPy_Build,
+ &Build_Type );
+ wanted_eff->build = eff;
+ return ( PyObject * ) wanted_eff;
+ }
+ object_iter = object_iter->id.next;
}
-
-
- if (object_iter->effect.first != NULL)
- {
- eff = object_iter->effect.first;
- for (i = 0; i < num; i++)
- {
- if (eff->type != EFF_BUILD)
- continue;
- eff = eff->next;
- if (!eff)
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError, "object not created"));
- }
- wanted_eff = (BPy_Build *) PyObject_NEW (BPy_Build, &Build_Type);
- wanted_eff->build = eff;
- return (PyObject *) wanted_eff;
- }
- object_iter = object_iter->id.next;
- }
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
struct PyMethodDef M_Build_methods[] = {
- {"New", (PyCFunction) M_Build_New, METH_VARARGS, M_Build_New_doc},
- {"Get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
- {"get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Build_New, METH_VARARGS, M_Build_New_doc},
+ {"Get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
+ {"get", M_Build_Get, METH_VARARGS, M_Build_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Function: Build_Init */
/*****************************************************************************/
-PyObject *
-Build_Init (void)
+PyObject *Build_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Build_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Build", M_Build_methods, M_Build_doc);
- return (submodule);
+ Build_Type.ob_type = &PyType_Type;
+ submodule =
+ Py_InitModule3( "Blender.Build", M_Build_methods,
+ M_Build_doc );
+ return ( submodule );
}
/*****************************************************************************/
-/* Python BPy_Build methods: */
+/* Python BPy_Build methods: */
/*****************************************************************************/
-PyObject *
-Build_getLen (BPy_Build * self)
+PyObject *Build_getLen( BPy_Build * self )
{
- BuildEff *ptr = (BuildEff *) self->build;
- return PyFloat_FromDouble (ptr->len);
+ BuildEff *ptr = ( BuildEff * ) self->build;
+ return PyFloat_FromDouble( ptr->len );
}
-PyObject *
-Build_setLen (BPy_Build * self, PyObject * args)
+PyObject *Build_setLen( BPy_Build * self, PyObject * args )
{
- BuildEff *ptr = (BuildEff *) self->build;
- float val = 0;
- if (!PyArg_ParseTuple (args, "f", &val))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
- ptr->len = val;
- Py_INCREF (Py_None);
- return Py_None;
+ BuildEff *ptr = ( BuildEff * ) self->build;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->len = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *
-Build_getSfra (BPy_Build * self)
+PyObject *Build_getSfra( BPy_Build * self )
{
- BuildEff *ptr = (BuildEff *) self->build;
- return PyFloat_FromDouble (ptr->sfra);
+ BuildEff *ptr = ( BuildEff * ) self->build;
+ return PyFloat_FromDouble( ptr->sfra );
}
-PyObject *
-Build_setSfra (BPy_Build * self, PyObject * args)
+PyObject *Build_setSfra( BPy_Build * self, PyObject * args )
{
- BuildEff *ptr = (BuildEff *) self->build;
- float val = 0;
- if (!PyArg_ParseTuple (args, "f", &val))
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError, "expected float argument"));
-
- ptr->sfra = val;
- Py_INCREF (Py_None);
- return Py_None;
+ BuildEff *ptr = ( BuildEff * ) self->build;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, "expected float argument" ) );
+
+ ptr->sfra = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: BuildDeAlloc */
-/* Description: This is a callback function for the BPy_Build type. It is */
+/* Description: This is a callback function for the BPy_Build type. It is */
/* the destructor function. */
/*****************************************************************************/
-void
-BuildDeAlloc (BPy_Build * self)
+void BuildDeAlloc( BPy_Build * self )
{
- BuildEff *ptr = (BuildEff *) self;
- PyObject_DEL (ptr);
+ BuildEff *ptr = ( BuildEff * ) self;
+ PyObject_DEL( ptr );
}
/*****************************************************************************/
/* Function: BuildGetAttr */
-/* Description: This is a callback function for the BPy_Build type. It is */
-/* the function that accesses BPy_Build "member variables" and */
+/* Description: This is a callback function for the BPy_Build type. It is */
+/* the function that accesses BPy_Build "member variables" and */
/* methods. */
/*****************************************************************************/
-PyObject *
-BuildGetAttr (BPy_Build * self, char *name)
+PyObject *BuildGetAttr( BPy_Build * self, char *name )
{
- if (!strcmp (name, "sfra"))
- return Build_getSfra (self);
- if (!strcmp (name, "len"))
- return Build_getLen (self);
- return Py_FindMethod (BPy_Build_methods, (PyObject *) self, name);
+ if( !strcmp( name, "sfra" ) )
+ return Build_getSfra( self );
+ if( !strcmp( name, "len" ) )
+ return Build_getLen( self );
+ return Py_FindMethod( BPy_Build_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
-/* Function: BuildSetAttr */
-/* Description: This is a callback function for the BPy_Build type. It is the */
-/* function that sets Build Data attributes (member variables). */
+/* Function: BuildSetAttr */
+/* Description: This is a callback function for the BPy_Build type. It */
+/* sets Build Data attributes (member variables). */
/*****************************************************************************/
-int
-BuildSetAttr (BPy_Build * self, char *name, PyObject * value)
+int BuildSetAttr( BPy_Build * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
- valtuple = Py_BuildValue ("(N)", value);
-
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "CameraSetAttr: couldn't create PyTuple");
-
- if (!strcmp (name, "sfra"))
- error = Build_setSfra (self, valtuple);
- else if (!strcmp (name, "len"))
- error = Build_setLen (self, valtuple);
-
- else
- {
- Py_DECREF (valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
- }
+ PyObject *valtuple;
+ PyObject *error = NULL;
+ valtuple = Py_BuildValue( "(N)", value );
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "CameraSetAttr: couldn't create PyTuple" );
+
+ if( !strcmp( name, "sfra" ) )
+ error = Build_setSfra( self, valtuple );
+ else if( !strcmp( name, "len" ) )
+ error = Build_setLen( self, valtuple );
+
+ else {
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
+ }
- /* Py_DECREF(valtuple); */
+ /* Py_DECREF(valtuple); */
- if (error != Py_None)
- return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF (Py_None);
- return 0;
+ Py_DECREF( Py_None );
+ return 0;
}
/*****************************************************************************/
/* Function: BuildPrint */
-/* Description: This is a callback function for the BPy_Build type. It */
+/* Description: This is a callback function for the BPy_Build type. It */
/* builds a meaninful string to 'print' build objects. */
/*****************************************************************************/
/*
@@ -336,45 +328,40 @@ int BuildPrint(BPy_Build *self, FILE *fp, int flags)
*/
/*****************************************************************************/
/* Function: BuildRepr */
-/* Description: This is a callback function for the BPy_Build type. It */
+/* Description: This is a callback function for the BPy_Build type. It */
/* builds a meaninful string to represent build objects. */
/*****************************************************************************/
-PyObject *
-BuildRepr (BPy_Build * self)
+PyObject *BuildRepr( BPy_Build * self )
{
- return PyString_FromString ("Build effect");
+ return PyString_FromString( "Build effect" );
}
-PyObject *
-BuildCreatePyObject (struct Effect * build)
+PyObject *BuildCreatePyObject( struct Effect * build )
{
- BPy_Build *blen_object;
+ BPy_Build *blen_object;
- blen_object = (BPy_Build *) PyObject_NEW (BPy_Build, &Build_Type);
+ blen_object = ( BPy_Build * ) PyObject_NEW( BPy_Build, &Build_Type );
- if (blen_object == NULL)
- {
- return (NULL);
- }
- blen_object->build = build;
- return ((PyObject *) blen_object);
+ if( blen_object == NULL ) {
+ return ( NULL );
+ }
+ blen_object->build = build;
+ return ( ( PyObject * ) blen_object );
}
-int
-BuildCheckPyObject (PyObject * py_obj)
+int BuildCheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Build_Type);
+ return ( py_obj->ob_type == &Build_Type );
}
-struct Build *
-BuildFromPyObject (PyObject * py_obj)
+struct Build *BuildFromPyObject( PyObject * py_obj )
{
- BPy_Build *blen_obj;
+ BPy_Build *blen_obj;
- blen_obj = (BPy_Build *) py_obj;
- return ((struct Build *) blen_obj->build);
+ blen_obj = ( BPy_Build * ) py_obj;
+ return ( ( struct Build * ) blen_obj->build );
}
diff --git a/source/blender/python/api2_2x/Build.h b/source/blender/python/api2_2x/Build.h
index 78485081a45..d98155d7269 100644
--- a/source/blender/python/api2_2x/Build.h
+++ b/source/blender/python/api2_2x/Build.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -45,33 +46,33 @@
/*****************************************************************************/
/* Python API function prototypes for the Build module. */
/*****************************************************************************/
-PyObject *M_Build_New (PyObject * self, PyObject * args);
-PyObject *M_Build_Get (PyObject * self, PyObject * args);
+PyObject *M_Build_New( PyObject * self, PyObject * args );
+PyObject *M_Build_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* Python BPy_Build methods declarations: */
+/* Python BPy_Build methods declarations: */
/*****************************************************************************/
-PyObject *Build_getLen (BPy_Build * self);
-PyObject *Build_setLen (BPy_Build * self, PyObject * a);
-PyObject *Build_getSfra (BPy_Build * self);
-PyObject *Build_setSfra (BPy_Build * self, PyObject * a);
+PyObject *Build_getLen( BPy_Build * self );
+PyObject *Build_setLen( BPy_Build * self, PyObject * a );
+PyObject *Build_getSfra( BPy_Build * self );
+PyObject *Build_setSfra( BPy_Build * self, PyObject * a );
/*****************************************************************************/
/* Python Build_Type callback function prototypes: */
/*****************************************************************************/
-void BuildDeAlloc (BPy_Build * msh);
+void BuildDeAlloc( BPy_Build * msh );
//int BuildPrint (BPy_Build *msh, FILE *fp, int flags);
-int BuildSetAttr (BPy_Build * msh, char *name, PyObject * v);
-PyObject *BuildGetAttr (BPy_Build * msh, char *name);
-PyObject *BuildRepr (BPy_Build * msh);
-PyObject *BuildCreatePyObject (struct Effect *build);
-int BuildCheckPyObject (PyObject * py_obj);
-struct Build *BuildFromPyObject (PyObject * py_obj);
+int BuildSetAttr( BPy_Build * msh, char *name, PyObject * v );
+PyObject *BuildGetAttr( BPy_Build * msh, char *name );
+PyObject *BuildRepr( BPy_Build * msh );
+PyObject *BuildCreatePyObject( struct Effect *build );
+int BuildCheckPyObject( PyObject * py_obj );
+struct Build *BuildFromPyObject( PyObject * py_obj );
-#endif /* EXPP_BUILD_H */
+#endif /* EXPP_BUILD_H */
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index 9c12d964b1a..69e0152cb4c 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -48,9 +48,9 @@
/*****************************************************************************/
/* Python API function prototypes for the Camera module. */
/*****************************************************************************/
-static PyObject *M_Camera_New (PyObject * self, PyObject * args,
- PyObject * keywords);
-static PyObject *M_Camera_Get (PyObject * self, PyObject * args);
+static PyObject *M_Camera_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Camera_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -73,7 +73,7 @@ Example::\n\
cur.setCurrentCamera(ob) # make this camera the active";
static char M_Camera_New_doc[] =
- "Camera.New (type = 'persp', name = 'CamData'):\n\
+ "Camera.New (type = 'persp', name = 'CamData'):\n\
Return a new Camera Data object with the given type and name.";
static char M_Camera_Get_doc[] = "Camera.Get (name = None):\n\
@@ -85,336 +85,326 @@ static char M_Camera_Get_doc[] = "Camera.Get (name = None):\n\
/* Python method structure definition for Blender.Camera module: */
/*****************************************************************************/
struct PyMethodDef M_Camera_methods[] = {
- {"New", (PyCFunction) M_Camera_New, METH_VARARGS | METH_KEYWORDS,
- M_Camera_New_doc},
- {"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Camera_New, METH_VARARGS | METH_KEYWORDS,
+ M_Camera_New_doc},
+ {"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
+ {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Camera methods declarations: */
/*****************************************************************************/
-static PyObject *Camera_getIpo (BPy_Camera * self);
-static PyObject *Camera_getName (BPy_Camera * self);
-static PyObject *Camera_getType (BPy_Camera * self);
-static PyObject *Camera_getMode (BPy_Camera * self);
-static PyObject *Camera_getLens (BPy_Camera * self);
-static PyObject *Camera_getClipStart (BPy_Camera * self);
-static PyObject *Camera_getClipEnd (BPy_Camera * self);
-static PyObject *Camera_getDrawSize (BPy_Camera * self);
-static PyObject *Camera_setIpo (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_clearIpo (BPy_Camera * self);
-static PyObject *Camera_setName (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setType (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setIntType (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setMode (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setIntMode (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setLens (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setClipStart (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setClipEnd (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_setDrawSize (BPy_Camera * self, PyObject * args);
-static PyObject *Camera_getScriptLinks(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_addScriptLink(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_clearScriptLinks(BPy_Camera *self);
+static PyObject *Camera_getIpo( BPy_Camera * self );
+static PyObject *Camera_getName( BPy_Camera * self );
+static PyObject *Camera_getType( BPy_Camera * self );
+static PyObject *Camera_getMode( BPy_Camera * self );
+static PyObject *Camera_getLens( BPy_Camera * self );
+static PyObject *Camera_getClipStart( BPy_Camera * self );
+static PyObject *Camera_getClipEnd( BPy_Camera * self );
+static PyObject *Camera_getDrawSize( BPy_Camera * self );
+static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_clearIpo( BPy_Camera * self );
+static PyObject *Camera_setName( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setType( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setIntType( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setMode( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setIntMode( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_clearScriptLinks( BPy_Camera * self );
/*****************************************************************************/
/* Python BPy_Camera methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Camera_methods[] = {
- /* name, method, flags, doc */
- {"getIpo", (PyCFunction) Camera_getIpo, METH_NOARGS,
- "() - Return Camera Data Ipo"},
- {"getName", (PyCFunction) Camera_getName, METH_NOARGS,
- "() - Return Camera Data name"},
- {"getType", (PyCFunction) Camera_getType, METH_NOARGS,
- "() - Return Camera type - 'persp':0, 'ortho':1"},
- {"getMode", (PyCFunction) Camera_getMode, METH_NOARGS,
- "() - Return Camera mode flags (or'ed value) -\n"
- " 'showLimits':1, 'showMist':2"},
- {"getLens", (PyCFunction) Camera_getLens, METH_NOARGS,
- "() - Return Camera lens value"},
- {"getClipStart", (PyCFunction) Camera_getClipStart, METH_NOARGS,
- "() - Return Camera clip start value"},
- {"getClipEnd", (PyCFunction) Camera_getClipEnd, METH_NOARGS,
- "() - Return Camera clip end value"},
- {"getDrawSize", (PyCFunction) Camera_getDrawSize, METH_NOARGS,
- "() - Return Camera draw size value"},
- {"setIpo", (PyCFunction) Camera_setIpo, METH_VARARGS,
- "(Blender Ipo) - Set Camera Ipo"},
- {"clearIpo", (PyCFunction) Camera_clearIpo, METH_NOARGS,
- "() - Unlink Ipo from this Camera."},
- {"setName", (PyCFunction) Camera_setName, METH_VARARGS,
- "(s) - Set Camera Data name"},
- {"setType", (PyCFunction) Camera_setType, METH_VARARGS,
- "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
- {"setMode", (PyCFunction) Camera_setMode, METH_VARARGS,
- "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
- {"setLens", (PyCFunction) Camera_setLens, METH_VARARGS,
- "(f) - Set Camera lens value"},
- {"setClipStart", (PyCFunction) Camera_setClipStart, METH_VARARGS,
- "(f) - Set Camera clip start value"},
- {"setClipEnd", (PyCFunction) Camera_setClipEnd, METH_VARARGS,
- "(f) - Set Camera clip end value"},
- {"setDrawSize", (PyCFunction) Camera_setDrawSize, METH_VARARGS,
- "(f) - Set Camera draw size value"},
- {"getScriptLinks", (PyCFunction)Camera_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this camera's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", (PyCFunction)Camera_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new camera scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", (PyCFunction)Camera_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this camera."},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
+ "() - Return Camera Data Ipo"},
+ {"getName", ( PyCFunction ) Camera_getName, METH_NOARGS,
+ "() - Return Camera Data name"},
+ {"getType", ( PyCFunction ) Camera_getType, METH_NOARGS,
+ "() - Return Camera type - 'persp':0, 'ortho':1"},
+ {"getMode", ( PyCFunction ) Camera_getMode, METH_NOARGS,
+ "() - Return Camera mode flags (or'ed value) -\n"
+ " 'showLimits':1, 'showMist':2"},
+ {"getLens", ( PyCFunction ) Camera_getLens, METH_NOARGS,
+ "() - Return Camera lens value"},
+ {"getClipStart", ( PyCFunction ) Camera_getClipStart, METH_NOARGS,
+ "() - Return Camera clip start value"},
+ {"getClipEnd", ( PyCFunction ) Camera_getClipEnd, METH_NOARGS,
+ "() - Return Camera clip end value"},
+ {"getDrawSize", ( PyCFunction ) Camera_getDrawSize, METH_NOARGS,
+ "() - Return Camera draw size value"},
+ {"setIpo", ( PyCFunction ) Camera_setIpo, METH_VARARGS,
+ "(Blender Ipo) - Set Camera Ipo"},
+ {"clearIpo", ( PyCFunction ) Camera_clearIpo, METH_NOARGS,
+ "() - Unlink Ipo from this Camera."},
+ {"setName", ( PyCFunction ) Camera_setName, METH_VARARGS,
+ "(s) - Set Camera Data name"},
+ {"setType", ( PyCFunction ) Camera_setType, METH_VARARGS,
+ "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
+ {"setMode", ( PyCFunction ) Camera_setMode, METH_VARARGS,
+ "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
+ {"setLens", ( PyCFunction ) Camera_setLens, METH_VARARGS,
+ "(f) - Set Camera lens value"},
+ {"setClipStart", ( PyCFunction ) Camera_setClipStart, METH_VARARGS,
+ "(f) - Set Camera clip start value"},
+ {"setClipEnd", ( PyCFunction ) Camera_setClipEnd, METH_VARARGS,
+ "(f) - Set Camera clip end value"},
+ {"setDrawSize", ( PyCFunction ) Camera_setDrawSize, METH_VARARGS,
+ "(f) - Set Camera draw size value"},
+ {"getScriptLinks", ( PyCFunction ) Camera_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this camera's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) Camera_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new camera scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) Camera_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this camera."},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Camera_Type callback function prototypes: */
/*****************************************************************************/
-static void Camera_dealloc (BPy_Camera * self);
-static int Camera_setAttr (BPy_Camera * self, char *name, PyObject * v);
-static int Camera_compare (BPy_Camera * a, BPy_Camera * b);
-static PyObject *Camera_getAttr (BPy_Camera * self, char *name);
-static PyObject *Camera_repr (BPy_Camera * self);
+static void Camera_dealloc( BPy_Camera * self );
+static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * v );
+static int Camera_compare( BPy_Camera * a, BPy_Camera * b );
+static PyObject *Camera_getAttr( BPy_Camera * self, char *name );
+static PyObject *Camera_repr( BPy_Camera * self );
/*****************************************************************************/
-/* Python Camera_Type structure definition: */
+/* Python Camera_Type structure definition: */
/*****************************************************************************/
PyTypeObject Camera_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Camera", /* tp_name */
- sizeof (BPy_Camera), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) Camera_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Camera_getAttr, /* tp_getattr */
- (setattrfunc) Camera_setAttr, /* tp_setattr */
- (cmpfunc) Camera_compare, /* tp_compare */
- (reprfunc) Camera_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_Camera_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL ) /* required macro */
+ 0, /* ob_size */
+ "Blender Camera", /* tp_name */
+ sizeof( BPy_Camera ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Camera_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Camera_getAttr, /* tp_getattr */
+ ( setattrfunc ) Camera_setAttr, /* tp_setattr */
+ ( cmpfunc ) Camera_compare, /* tp_compare */
+ ( reprfunc ) Camera_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_Camera_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static PyObject *
-M_Camera_New (PyObject * self, PyObject * args, PyObject * kwords)
-{
- char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
- char *name_str = "CamData";
- static char *kwlist[] = { "type_str", "name_str", NULL };
- PyObject *pycam; /* for Camera Data object wrapper in Python */
- Camera *blcam; /* for actual Camera Data we create in Blender */
- char buf[21];
-
- /* Parse the arguments passed in by the Python interpreter */
- if (!PyArg_ParseTupleAndKeywords (args, kwords, "|ss", kwlist,
- &type_str, &name_str))
- /* We expected string(s) (or nothing) as argument, but we didn't get that. */
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected zero, one or two strings as arguments");
-
- blcam = add_camera (); /* first create the Camera Data in Blender */
-
- if (blcam) /* now create the wrapper obj in Python */
- pycam = Camera_CreatePyObject (blcam);
- else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Camera Data in Blender");
-
- /* let's return user count to zero, because ... */
- blcam->id.us = 0; /* ... add_camera() incref'ed it */
- /* XXX XXX Do this in other modules, too */
-
- if (pycam == NULL)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Camera PyObject");
-
- if (strcmp (type_str, "persp") == 0) /* default, no need to set, so */
- /*blcam->type = (short)EXPP_CAM_TYPE_PERSP */ ;
- /* we comment this line */
- else if (strcmp (type_str, "ortho") == 0)
- blcam->type = (short) EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown camera type");
-
- if (strcmp (name_str, "CamData") == 0)
- return pycam;
- else
- { /* user gave us a name for the camera, use it */
- PyOS_snprintf (buf, sizeof (buf), "%s", name_str);
- rename_id (&blcam->id, buf); /* proper way in Blender */
- }
+static PyObject *M_Camera_New( PyObject * self, PyObject * args,
+ PyObject * kwords )
+{
+ char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
+ char *name_str = "CamData";
+ static char *kwlist[] = { "type_str", "name_str", NULL };
+ PyObject *pycam; /* for Camera Data object wrapper in Python */
+ Camera *blcam; /* for actual Camera Data we create in Blender */
+ char buf[21];
+
+ /* Parse the arguments passed in by the Python interpreter */
+ if( !PyArg_ParseTupleAndKeywords( args, kwords, "|ss", kwlist,
+ &type_str, &name_str ) )
+ /* We expected string(s) (or nothing) as argument, but we didn't get that. */
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected zero, one or two strings as arguments" );
+
+ blcam = add_camera( ); /* first create the Camera Data in Blender */
+
+ if( blcam ) /* now create the wrapper obj in Python */
+ pycam = Camera_CreatePyObject( blcam );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Camera Data in Blender" );
+
+ /* let's return user count to zero, because ... */
+ blcam->id.us = 0; /* ... add_camera() incref'ed it */
+ /* XXX XXX Do this in other modules, too */
+
+ if( pycam == NULL )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Camera PyObject" );
+
+ if( strcmp( type_str, "persp" ) == 0 )
+ /* default, no need to set, so */
+ /*blcam->type = (short)EXPP_CAM_TYPE_PERSP */
+ ;
+ /* we comment this line */
+ else if( strcmp( type_str, "ortho" ) == 0 )
+ blcam->type = ( short ) EXPP_CAM_TYPE_ORTHO;
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown camera type" );
+
+ if( strcmp( name_str, "CamData" ) == 0 )
+ return pycam;
+ else { /* user gave us a name for the camera, use it */
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name_str );
+ rename_id( &blcam->id, buf ); /* proper way in Blender */
+ }
- return pycam;
+ return pycam;
}
-static PyObject *
-M_Camera_Get (PyObject * self, PyObject * args)
+static PyObject *M_Camera_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
- Camera *cam_iter;
+ char *name = NULL;
+ Camera *cam_iter;
- if (!PyArg_ParseTuple (args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" );
- cam_iter = G.main->camera.first;
+ cam_iter = G.main->camera.first;
- if (name)
- { /* (name) - Search camera by name */
+ if( name ) { /* (name) - Search camera by name */
- PyObject *wanted_cam = NULL;
+ PyObject *wanted_cam = NULL;
- while (cam_iter && !wanted_cam)
- {
+ while( cam_iter && !wanted_cam ) {
- if (strcmp (name, cam_iter->id.name + 2) == 0)
- {
- wanted_cam = Camera_CreatePyObject (cam_iter);
- break;
- }
+ if( strcmp( name, cam_iter->id.name + 2 ) == 0 ) {
+ wanted_cam = Camera_CreatePyObject( cam_iter );
+ break;
+ }
- cam_iter = cam_iter->id.next;
- }
+ cam_iter = cam_iter->id.next;
+ }
- if (!wanted_cam)
- { /* Requested camera doesn't exist */
- char error_msg[64];
- PyOS_snprintf (error_msg, sizeof (error_msg),
- "Camera \"%s\" not found", name);
- return EXPP_ReturnPyObjError (PyExc_NameError, error_msg);
+ if( !wanted_cam ) { /* Requested camera doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Camera \"%s\" not found", name );
+ return EXPP_ReturnPyObjError( PyExc_NameError,
+ error_msg );
+ }
+
+ return wanted_cam;
}
- return wanted_cam;
- }
+ else { /* () - return a list of wrappers for all cameras in the scene */
+ int index = 0;
+ PyObject *cam_pylist, *pyobj;
- else
- { /* () - return a list of wrappers for all cameras in the scene */
- int index = 0;
- PyObject *cam_pylist, *pyobj;
+ cam_pylist =
+ PyList_New( BLI_countlist( &( G.main->camera ) ) );
- cam_pylist = PyList_New (BLI_countlist (&(G.main->camera)));
+ if( !cam_pylist )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- if (!cam_pylist)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList");
+ while( cam_iter ) {
+ pyobj = Camera_CreatePyObject( cam_iter );
- while (cam_iter)
- {
- pyobj = Camera_CreatePyObject (cam_iter);
+ if( !pyobj )
+ return EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create Camera PyObject" );
- if (!pyobj)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Camera PyObject");
+ PyList_SET_ITEM( cam_pylist, index, pyobj );
- PyList_SET_ITEM (cam_pylist, index, pyobj);
+ cam_iter = cam_iter->id.next;
+ index++;
+ }
- cam_iter = cam_iter->id.next;
- index++;
+ return cam_pylist;
}
-
- return cam_pylist;
- }
}
-PyObject *
-Camera_Init (void)
+PyObject *Camera_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Camera_Type.ob_type = &PyType_Type;
+ Camera_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Camera",
- M_Camera_methods, M_Camera_doc);
+ submodule = Py_InitModule3( "Blender.Camera",
+ M_Camera_methods, M_Camera_doc );
- return submodule;
+ return submodule;
}
/* Three Python Camera_Type helper functions needed by the Object module: */
-PyObject *
-Camera_CreatePyObject (Camera * cam)
+PyObject *Camera_CreatePyObject( Camera * cam )
{
- BPy_Camera *pycam;
+ BPy_Camera *pycam;
- pycam = (BPy_Camera *) PyObject_NEW (BPy_Camera, &Camera_Type);
+ pycam = ( BPy_Camera * ) PyObject_NEW( BPy_Camera, &Camera_Type );
- if (!pycam)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Camera PyObject");
+ if( !pycam )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Camera PyObject" );
- pycam->camera = cam;
+ pycam->camera = cam;
- return (PyObject *) pycam;
+ return ( PyObject * ) pycam;
}
-int
-Camera_CheckPyObject (PyObject * pyobj)
+int Camera_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Camera_Type);
+ return ( pyobj->ob_type == &Camera_Type );
}
-Camera *
-Camera_FromPyObject (PyObject * pyobj)
+Camera *Camera_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Camera *) pyobj)->camera;
+ return ( ( BPy_Camera * ) pyobj )->camera;
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
-Camera *
-GetCameraByName (char *name)
+Camera *GetCameraByName( char *name )
{
- Camera *cam_iter;
+ Camera *cam_iter;
- cam_iter = G.main->camera.first;
- while (cam_iter)
- {
- if (StringEqual (name, GetIdName (&(cam_iter->id))))
- {
- return (cam_iter);
+ cam_iter = G.main->camera.first;
+ while( cam_iter ) {
+ if( StringEqual( name, GetIdName( &( cam_iter->id ) ) ) ) {
+ return ( cam_iter );
+ }
+ cam_iter = cam_iter->id.next;
}
- cam_iter = cam_iter->id.next;
- }
- /* There is no camera with the given name */
- return (NULL);
+ /* There is no camera with the given name */
+ return ( NULL );
}
/*****************************************************************************/
-/* Python BPy_Camera methods: */
+/* Python BPy_Camera methods: */
/*****************************************************************************/
-static PyObject *
-Camera_getIpo (BPy_Camera * self)
+static PyObject *Camera_getIpo( BPy_Camera * self )
{
- struct Ipo *ipo = self->camera->ipo;
+ struct Ipo *ipo = self->camera->ipo;
- if (!ipo)
- {
- Py_INCREF (Py_None);
- return Py_None;
- }
+ if( !ipo ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
- return Ipo_CreatePyObject (ipo);
+ return Ipo_CreatePyObject( ipo );
}
@@ -422,187 +412,175 @@ Camera_getIpo (BPy_Camera * self)
-static PyObject *
-Camera_getName (BPy_Camera * self)
+static PyObject *Camera_getName( BPy_Camera * self )
{
- PyObject *attr = PyString_FromString (self->camera->id.name + 2);
+ PyObject *attr = PyString_FromString( self->camera->id.name + 2 );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.name attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.name attribute" );
}
-static PyObject *
-Camera_getType (BPy_Camera * self)
+static PyObject *Camera_getType( BPy_Camera * self )
{
- PyObject *attr = PyInt_FromLong (self->camera->type);
+ PyObject *attr = PyInt_FromLong( self->camera->type );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.type attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.type attribute" );
}
-static PyObject *
-Camera_getMode (BPy_Camera * self)
+static PyObject *Camera_getMode( BPy_Camera * self )
{
- PyObject *attr = PyInt_FromLong (self->camera->flag);
+ PyObject *attr = PyInt_FromLong( self->camera->flag );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.Mode attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.Mode attribute" );
}
-static PyObject *
-Camera_getLens (BPy_Camera * self)
+static PyObject *Camera_getLens( BPy_Camera * self )
{
- PyObject *attr = PyFloat_FromDouble (self->camera->lens);
+ PyObject *attr = PyFloat_FromDouble( self->camera->lens );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.lens attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.lens attribute" );
}
-static PyObject *
-Camera_getClipStart (BPy_Camera * self)
+static PyObject *Camera_getClipStart( BPy_Camera * self )
{
- PyObject *attr = PyFloat_FromDouble (self->camera->clipsta);
+ PyObject *attr = PyFloat_FromDouble( self->camera->clipsta );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.clipStart attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.clipStart attribute" );
}
-static PyObject *
-Camera_getClipEnd (BPy_Camera * self)
+static PyObject *Camera_getClipEnd( BPy_Camera * self )
{
- PyObject *attr = PyFloat_FromDouble (self->camera->clipend);
+ PyObject *attr = PyFloat_FromDouble( self->camera->clipend );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.clipEnd attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.clipEnd attribute" );
}
-static PyObject *
-Camera_getDrawSize (BPy_Camera * self)
+static PyObject *Camera_getDrawSize( BPy_Camera * self )
{
- PyObject *attr = PyFloat_FromDouble (self->camera->drawsize);
+ PyObject *attr = PyFloat_FromDouble( self->camera->drawsize );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.drawSize attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Camera.drawSize attribute" );
}
-static PyObject *
-Camera_setIpo (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setIpo( BPy_Camera * self, PyObject * args )
{
- PyObject *pyipo = 0;
- Ipo *ipo = NULL;
- Ipo *oldipo;
+ 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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject (pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ if( !ipo )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "null ipo!" );
- if (ipo->blocktype != ID_CA)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this ipo is not a camera data ipo");
+ if( ipo->blocktype != ID_CA )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not a camera data ipo" );
- oldipo = self->camera->ipo;
- if (oldipo)
- {
- ID *id = &oldipo->id;
- if (id->us > 0)
- id->us--;
- }
+ oldipo = self->camera->ipo;
+ if( oldipo ) {
+ ID *id = &oldipo->id;
+ if( id->us > 0 )
+ id->us--;
+ }
- ((ID *) & ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
- self->camera->ipo = ipo;
+ self->camera->ipo = ipo;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_clearIpo (BPy_Camera * self)
+static PyObject *Camera_clearIpo( BPy_Camera * self )
{
- Camera *cam = self->camera;
- Ipo *ipo = (Ipo *) cam->ipo;
+ Camera *cam = self->camera;
+ Ipo *ipo = ( Ipo * ) cam->ipo;
- if (ipo)
- {
- ID *id = &ipo->id;
- if (id->us > 0)
- id->us--;
- cam->ipo = NULL;
+ if( ipo ) {
+ ID *id = &ipo->id;
+ if( id->us > 0 )
+ id->us--;
+ cam->ipo = NULL;
- Py_INCREF (Py_True);
- return Py_True;
- }
+ Py_INCREF( Py_True );
+ return Py_True;
+ }
- Py_INCREF (Py_False); /* no ipo found */
- return Py_False;
+ Py_INCREF( Py_False ); /* no ipo found */
+ return Py_False;
}
-static PyObject *
-Camera_setName (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setName( BPy_Camera * self, PyObject * args )
{
- char *name;
- char buf[21];
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple (args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- PyOS_snprintf (buf, sizeof (buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id (&self->camera->id, buf);
+ rename_id( &self->camera->id, buf );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_setType (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setType( BPy_Camera * self, PyObject * args )
{
- char *type;
+ char *type;
- if (!PyArg_ParseTuple (args, "s", &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if (strcmp (type, "persp") == 0)
- self->camera->type = (short) EXPP_CAM_TYPE_PERSP;
- else if (strcmp (type, "ortho") == 0)
- self->camera->type = (short) EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown camera type");
+ if( strcmp( type, "persp" ) == 0 )
+ self->camera->type = ( short ) EXPP_CAM_TYPE_PERSP;
+ else if( strcmp( type, "ortho" ) == 0 )
+ self->camera->type = ( short ) EXPP_CAM_TYPE_ORTHO;
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown camera type" );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/* This one is 'private'. It is not really a method, just a helper function for
@@ -611,255 +589,251 @@ Camera_setType (BPy_Camera * self, PyObject * args)
* the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */
-static PyObject *
-Camera_setIntType (BPy_Camera * self, PyObject * args)
-{
- short value;
-
- if (!PyArg_ParseTuple (args, "h", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument: 0 or 1");
-
- if (value == 0 || value == 1)
- self->camera->type = value;
- else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument: 0 or 1");
-
- Py_INCREF (Py_None);
- return Py_None;
-}
-
-static PyObject *
-Camera_setMode (BPy_Camera * self, PyObject * args)
-{
- char *mode_str1 = NULL, *mode_str2 = NULL;
- short flag = 0;
-
- if (!PyArg_ParseTuple (args, "|ss", &mode_str1, &mode_str2))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected one or two strings as arguments");
-
- if (mode_str1 != NULL)
- {
- if (strcmp (mode_str1, "showLimits") == 0)
- flag |= (short) EXPP_CAM_MODE_SHOWLIMITS;
- else if (strcmp (mode_str1, "showMist") == 0)
- flag |= (short) EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "first argument is an unknown camera flag");
-
- if (mode_str2 != NULL)
- {
- if (strcmp (mode_str2, "showLimits") == 0)
- flag |= (short) EXPP_CAM_MODE_SHOWLIMITS;
- else if (strcmp (mode_str2, "showMist") == 0)
- flag |= (short) EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "second argument is an unknown camera flag");
+static PyObject *Camera_setIntType( BPy_Camera * self, PyObject * args )
+{
+ short value;
+
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument: 0 or 1" );
+
+ if( value == 0 || value == 1 )
+ self->camera->type = value;
+ else
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected int argument: 0 or 1" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Camera_setMode( BPy_Camera * self, PyObject * args )
+{
+ char *mode_str1 = NULL, *mode_str2 = NULL;
+ short flag = 0;
+
+ if( !PyArg_ParseTuple( args, "|ss", &mode_str1, &mode_str2 ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected one or two strings as arguments" );
+
+ if( mode_str1 != NULL ) {
+ if( strcmp( mode_str1, "showLimits" ) == 0 )
+ flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS;
+ else if( strcmp( mode_str1, "showMist" ) == 0 )
+ flag |= ( short ) EXPP_CAM_MODE_SHOWMIST;
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "first argument is an unknown camera flag" );
+
+ if( mode_str2 != NULL ) {
+ if( strcmp( mode_str2, "showLimits" ) == 0 )
+ flag |= ( short ) EXPP_CAM_MODE_SHOWLIMITS;
+ else if( strcmp( mode_str2, "showMist" ) == 0 )
+ flag |= ( short ) EXPP_CAM_MODE_SHOWMIST;
+ else
+ return EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "second argument is an unknown camera flag" );
+ }
}
- }
- self->camera->flag = flag;
+ self->camera->flag = flag;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/* Another helper function, for the same reason.
* (See comment before Camera_setIntType above). */
-static PyObject *
-Camera_setIntMode (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setIntMode( BPy_Camera * self, PyObject * args )
{
- short value;
+ short value;
- if (!PyArg_ParseTuple (args, "h", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0,3]");
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [0,3]" );
- if (value >= 0 && value <= 3)
- self->camera->flag = value;
- else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument in [0,3]");
+ if( value >= 0 && value <= 3 )
+ self->camera->flag = value;
+ else
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected int argument in [0,3]" );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_setLens (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setLens( BPy_Camera * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple (args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError, "expected float argument");
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- self->camera->lens = EXPP_ClampFloat (value,
- EXPP_CAM_LENS_MIN, EXPP_CAM_LENS_MAX);
+ self->camera->lens = EXPP_ClampFloat( value,
+ EXPP_CAM_LENS_MIN,
+ EXPP_CAM_LENS_MAX );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_setClipStart (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setClipStart( BPy_Camera * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple (args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError, "expected float argument");
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- self->camera->clipsta = EXPP_ClampFloat (value,
- EXPP_CAM_CLIPSTART_MIN,
- EXPP_CAM_CLIPSTART_MAX);
+ self->camera->clipsta = EXPP_ClampFloat( value,
+ EXPP_CAM_CLIPSTART_MIN,
+ EXPP_CAM_CLIPSTART_MAX );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_setClipEnd (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setClipEnd( BPy_Camera * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple (args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError, "expected float argument");
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- self->camera->clipend = EXPP_ClampFloat (value,
- EXPP_CAM_CLIPEND_MIN,
- EXPP_CAM_CLIPEND_MAX);
+ self->camera->clipend = EXPP_ClampFloat( value,
+ EXPP_CAM_CLIPEND_MIN,
+ EXPP_CAM_CLIPEND_MAX );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Camera_setDrawSize (BPy_Camera * self, PyObject * args)
+static PyObject *Camera_setDrawSize( BPy_Camera * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple (args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float number as argument");
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float number as argument" );
- self->camera->drawsize = EXPP_ClampFloat (value,
- EXPP_CAM_DRAWSIZE_MIN,
- EXPP_CAM_DRAWSIZE_MAX);
+ self->camera->drawsize = EXPP_ClampFloat( value,
+ EXPP_CAM_DRAWSIZE_MIN,
+ EXPP_CAM_DRAWSIZE_MAX );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
+
/* cam.addScriptLink */
-static PyObject *Camera_addScriptLink (BPy_Camera *self, PyObject *args)
+static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args )
{
Camera *cam = self->camera;
ScriptLink *slink = NULL;
- slink = &(cam)->scriptlink;
+ slink = &( cam )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 0))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 0 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* cam.clearScriptLinks */
-static PyObject *Camera_clearScriptLinks (BPy_Camera *self)
+static PyObject *Camera_clearScriptLinks( BPy_Camera * self )
{
Camera *cam = self->camera;
ScriptLink *slink = NULL;
- slink = &(cam)->scriptlink;
+ slink = &( cam )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* cam.getScriptLinks */
-static PyObject *Camera_getScriptLinks (BPy_Camera *self, PyObject *args)
+static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args )
{
Camera *cam = self->camera;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- slink = &(cam)->scriptlink;
+ slink = &( cam )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 0);
+ ret = EXPP_getScriptLinks( slink, args, 0 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
-static void
-Camera_dealloc (BPy_Camera * self)
+static void Camera_dealloc( BPy_Camera * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *
-Camera_getAttr (BPy_Camera * self, char *name)
+static PyObject *Camera_getAttr( BPy_Camera * self, char *name )
{
- PyObject *attr = Py_None;
+ PyObject *attr = Py_None;
- if (strcmp (name, "name") == 0)
- attr = PyString_FromString (self->camera->id.name + 2);
- else if (strcmp (name, "type") == 0)
- attr = PyInt_FromLong (self->camera->type);
- else if (strcmp (name, "mode") == 0)
- attr = PyInt_FromLong (self->camera->flag);
- else if (strcmp (name, "lens") == 0)
- attr = PyFloat_FromDouble (self->camera->lens);
- else if (strcmp (name, "clipStart") == 0)
- attr = PyFloat_FromDouble (self->camera->clipsta);
- else if (strcmp (name, "clipEnd") == 0)
- attr = PyFloat_FromDouble (self->camera->clipend);
- else if (strcmp (name, "drawSize") == 0)
- attr = PyFloat_FromDouble (self->camera->drawsize);
- else if (strcmp (name, "ipo") == 0)
- {
- Ipo *ipo = self->camera->ipo;
- if (ipo)
- attr = Ipo_CreatePyObject (ipo);
- }
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->camera->id.name + 2 );
+ else if( strcmp( name, "type" ) == 0 )
+ attr = PyInt_FromLong( self->camera->type );
+ else if( strcmp( name, "mode" ) == 0 )
+ attr = PyInt_FromLong( self->camera->flag );
+ else if( strcmp( name, "lens" ) == 0 )
+ attr = PyFloat_FromDouble( self->camera->lens );
+ else if( strcmp( name, "clipStart" ) == 0 )
+ attr = PyFloat_FromDouble( self->camera->clipsta );
+ else if( strcmp( name, "clipEnd" ) == 0 )
+ attr = PyFloat_FromDouble( self->camera->clipend );
+ else if( strcmp( name, "drawSize" ) == 0 )
+ attr = PyFloat_FromDouble( self->camera->drawsize );
+ else if( strcmp( name, "ipo" ) == 0 ) {
+ Ipo *ipo = self->camera->ipo;
+ if( ipo )
+ attr = Ipo_CreatePyObject( ipo );
+ }
- else if (strcmp (name, "Types") == 0)
- {
- attr = Py_BuildValue ("{s:h,s:h}", "persp", EXPP_CAM_TYPE_PERSP,
- "ortho", EXPP_CAM_TYPE_ORTHO);
- }
+ else if( strcmp( name, "Types" ) == 0 ) {
+ attr = Py_BuildValue( "{s:h,s:h}", "persp",
+ EXPP_CAM_TYPE_PERSP, "ortho",
+ EXPP_CAM_TYPE_ORTHO );
+ }
- else if (strcmp (name, "Modes") == 0)
- {
- attr =
- Py_BuildValue ("{s:h,s:h}", "showLimits", EXPP_CAM_MODE_SHOWLIMITS,
- "showMist", EXPP_CAM_MODE_SHOWMIST);
- }
+ else if( strcmp( name, "Modes" ) == 0 ) {
+ attr = Py_BuildValue( "{s:h,s:h}", "showLimits",
+ EXPP_CAM_MODE_SHOWLIMITS, "showMist",
+ EXPP_CAM_MODE_SHOWMIST );
+ }
- else if (strcmp (name, "__members__") == 0)
- {
- attr = Py_BuildValue ("[s,s,s,s,s,s,s,s,s,s]",
- "name", "type", "mode", "lens", "clipStart",
- "ipo", "clipEnd", "drawSize", "Types", "Modes");
- }
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s]",
+ "name", "type", "mode", "lens",
+ "clipStart", "ipo", "clipEnd",
+ "drawSize", "Types", "Modes" );
+ }
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject");
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" );
- if (attr != Py_None)
- return attr; /* member attribute found, return it */
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
- /* not an attribute, search the methods table */
- return Py_FindMethod (BPy_Camera_methods, (PyObject *) self, name);
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Camera_methods, ( PyObject * ) self, name );
}
-static int
-Camera_setAttr (BPy_Camera * self, char *name, PyObject * value)
+static int Camera_setAttr( BPy_Camera * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
* Camera.member = val instead of Camera.setMember(val), we end up using the
@@ -868,63 +842,62 @@ Camera_setAttr (BPy_Camera * self, char *name, PyObject * value)
/* First we put "value" in a tuple, because we want to pass it to functions
* that only accept PyTuples. */
- valtuple = Py_BuildValue ("(O)", value);
+ valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple) /* everything OK with our PyObject? */
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "CameraSetAttr: couldn't create PyTuple");
+ if( !valtuple ) /* everything OK with our PyObject? */
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "CameraSetAttr: couldn't create PyTuple" );
/* Now we just compare "name" with all possible BPy_Camera member variables */
- if (strcmp (name, "name") == 0)
- error = Camera_setName (self, valtuple);
- else if (strcmp (name, "type") == 0)
- error = Camera_setIntType (self, valtuple); /* special case */
- else if (strcmp (name, "mode") == 0)
- error = Camera_setIntMode (self, valtuple); /* special case */
- else if (strcmp (name, "lens") == 0)
- error = Camera_setLens (self, valtuple);
- else if (strcmp (name, "clipStart") == 0)
- error = Camera_setClipStart (self, valtuple);
- else if (strcmp (name, "clipEnd") == 0)
- error = Camera_setClipEnd (self, valtuple);
- else if (strcmp (name, "drawSize") == 0)
- error = Camera_setDrawSize (self, valtuple);
-
- else
- { /* Error */
- Py_DECREF (valtuple);
-
- if ((strcmp (name, "Types") == 0) || /* user tried to change a */
- (strcmp (name, "Modes") == 0)) /* constant dict type ... */
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed");
-
- else /* ... or no member with the given name was found */
- return EXPP_ReturnIntError (PyExc_KeyError, "attribute not found");
- }
+ if( strcmp( name, "name" ) == 0 )
+ error = Camera_setName( self, valtuple );
+ else if( strcmp( name, "type" ) == 0 )
+ error = Camera_setIntType( self, valtuple ); /* special case */
+ else if( strcmp( name, "mode" ) == 0 )
+ error = Camera_setIntMode( self, valtuple ); /* special case */
+ else if( strcmp( name, "lens" ) == 0 )
+ error = Camera_setLens( self, valtuple );
+ else if( strcmp( name, "clipStart" ) == 0 )
+ error = Camera_setClipStart( self, valtuple );
+ else if( strcmp( name, "clipEnd" ) == 0 )
+ error = Camera_setClipEnd( self, valtuple );
+ else if( strcmp( name, "drawSize" ) == 0 )
+ error = Camera_setDrawSize( self, valtuple );
+
+ else { /* Error */
+ Py_DECREF( valtuple );
+
+ if( ( strcmp( name, "Types" ) == 0 ) || /* user tried to change a */
+ ( strcmp( name, "Modes" ) == 0 ) ) /* constant dict type ... */
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" );
+
+ else /* ... or no member with the given name was found */
+ return EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" );
+ }
/* valtuple won't be returned to the caller, so we need to DECREF it */
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None)
- return -1;
+ if( error != Py_None )
+ return -1;
/* Py_None was incref'ed by the called Camera_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 exit */
+ Py_DECREF( Py_None );
+ return 0; /* normal exit */
}
-static int
-Camera_compare (BPy_Camera * a, BPy_Camera * b)
+static int Camera_compare( BPy_Camera * a, BPy_Camera * b )
{
- Camera *pa = a->camera, *pb = b->camera;
- return (pa == pb) ? 0 : -1;
+ Camera *pa = a->camera, *pb = b->camera;
+ return ( pa == pb ) ? 0 : -1;
}
-static PyObject *
-Camera_repr (BPy_Camera * self)
+static PyObject *Camera_repr( BPy_Camera * self )
{
- return PyString_FromFormat ("[Camera \"%s\"]", self->camera->id.name + 2);
+ return PyString_FromFormat( "[Camera \"%s\"]",
+ self->camera->id.name + 2 );
}
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
index 164c29ace95..4d69017122f 100644
--- a/source/blender/python/api2_2x/Camera.h
+++ b/source/blender/python/api2_2x/Camera.h
@@ -1,4 +1,5 @@
-/*
+/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -61,4 +62,4 @@
-#endif /* EXPP_CAMERA_H */
+#endif /* EXPP_CAMERA_H */
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
index 1d5da99cbf4..d49c6121190 100644
--- a/source/blender/python/api2_2x/CurNurb.c
+++ b/source/blender/python/api2_2x/CurNurb.c
@@ -24,7 +24,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s):
+ * Contributor(s): Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -52,17 +52,17 @@ stuff in this section should be placed in bpy_types.h
extern PyMethodDef BPy_CurNurb_methods[];
-PyObject *CurNurb_CreatePyObject (Nurb * blen_nurb);
-static PyObject *CurNurb_setMatIndex (BPy_CurNurb * self, PyObject * args);
-static PyObject *CurNurb_getMatIndex (BPy_CurNurb * self);
+PyObject *CurNurb_CreatePyObject( Nurb * blen_nurb );
+static PyObject *CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args );
+static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self );
/* static PyObject* CurNurb_setXXX( BPy_CurNurb* self, PyObject* args ); */
-PyObject *CurNurb_getPoint (BPy_CurNurb * self, int index);
-static int CurNurb_length (PyInstanceObject * inst);
-static PyObject *CurNurb_getIter (BPy_CurNurb * self);
-static PyObject *CurNurb_iterNext (BPy_CurNurb * self);
-PyObject *CurNurb_append (BPy_CurNurb * self, PyObject * args);
-PyObject *CurNurb_pointAtIndex (Nurb * nurb, int index);
-static PyObject *CurNurb_isNurb (BPy_CurNurb * self);
+PyObject *CurNurb_getPoint( BPy_CurNurb * self, int index );
+static int CurNurb_length( PyInstanceObject * inst );
+static PyObject *CurNurb_getIter( BPy_CurNurb * self );
+static PyObject *CurNurb_iterNext( BPy_CurNurb * self );
+PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * args );
+PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index );
+static PyObject *CurNurb_isNurb( BPy_CurNurb * self );
char M_CurNurb_doc[] = "CurNurb";
@@ -71,42 +71,42 @@ char M_CurNurb_doc[] = "CurNurb";
CurNurb_Type callback function prototypes:
*/
-static void CurNurb_dealloc (BPy_CurNurb * self);
-static int CurNurb_compare (BPy_CurNurb * a, BPy_CurNurb * b);
-static PyObject *CurNurb_getAttr (BPy_CurNurb * self, char *name);
-static int CurNurb_setAttr (BPy_CurNurb * self, char *name, PyObject * v);
-static PyObject *CurNurb_repr (BPy_CurNurb * self);
+static void CurNurb_dealloc( BPy_CurNurb * self );
+static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b );
+static PyObject *CurNurb_getAttr( BPy_CurNurb * self, char *name );
+static int CurNurb_setAttr( BPy_CurNurb * self, char *name, PyObject * v );
+static PyObject *CurNurb_repr( BPy_CurNurb * self );
-void CurNurb_dealloc (BPy_CurNurb * self)
+void CurNurb_dealloc( BPy_CurNurb * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *CurNurb_getAttr (BPy_CurNurb * self, char *name)
+static PyObject *CurNurb_getAttr( BPy_CurNurb * self, char *name )
{
PyObject *attr = Py_None;
- if(strcmp (name, "mat_index") == 0)
- attr = PyInt_FromLong (self->nurb->mat_nr);
+ if( strcmp( name, "mat_index" ) == 0 )
+ attr = PyInt_FromLong( self->nurb->mat_nr );
- else if(strcmp (name, "points") == 0)
- attr = PyInt_FromLong (self->nurb->pntsu);
+ else if( strcmp( name, "points" ) == 0 )
+ attr = PyInt_FromLong( self->nurb->pntsu );
- if(!attr)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject");
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" );
/* member attribute found, return it */
- if(attr != Py_None)
+ if( attr != Py_None )
return attr;
/* not an attribute, search the methods table */
- return Py_FindMethod (BPy_CurNurb_methods, (PyObject *) self, name);
+ return Py_FindMethod( BPy_CurNurb_methods, ( PyObject * ) self, name );
}
@@ -114,39 +114,39 @@ static PyObject *CurNurb_getAttr (BPy_CurNurb * self, char *name)
setattr
*/
-static int CurNurb_setAttr (BPy_CurNurb * self, char *name, PyObject * value)
+static int CurNurb_setAttr( BPy_CurNurb * self, char *name, PyObject * value )
{
PyObject *valtuple;
PyObject *error = NULL;
/* make a tuple to pass to our type methods */
- valtuple = Py_BuildValue ("(O)", value);
+ valtuple = Py_BuildValue( "(O)", value );
- if(!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "CurNurb.setAttr: cannot create pytuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "CurNurb.setAttr: cannot create pytuple" );
- if(strcmp (name, "mat_index") == 0)
- error = CurNurb_setMatIndex (self, valtuple);
+ if( strcmp( name, "mat_index" ) == 0 )
+ error = CurNurb_setMatIndex( self, valtuple );
else { /* error - no match for name */
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if((strcmp (name, "ZZZZ") == 0) || /* user tried to change a */
- (strcmp (name, "ZZZZ") == 0)) /* constant dict type ... */
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed");
+ if( ( strcmp( name, "ZZZZ" ) == 0 ) || /* user tried to change a */
+ ( strcmp( name, "ZZZZ" ) == 0 ) ) /* constant dict type ... */
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" );
else
- return EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found");
+ return EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" );
}
- Py_DECREF (valtuple); /* since it is not being returned */
- if(error != Py_None)
+ Py_DECREF( valtuple ); /* since it is not being returned */
+ if( error != Py_None )
return -1;
- Py_DECREF (Py_None);
+ Py_DECREF( Py_None );
return 0; /* normal exit */
}
@@ -156,12 +156,12 @@ static int CurNurb_setAttr (BPy_CurNurb * self, char *name, PyObject * value)
blender data.
*/
-static int CurNurb_compare (BPy_CurNurb * a, BPy_CurNurb * b)
+static int CurNurb_compare( BPy_CurNurb * a, BPy_CurNurb * b )
{
Nurb *pa = a->nurb;
Nurb *pb = b->nurb;
- return (pa == pb) ? 0 : -1;
+ return ( pa == pb ) ? 0 : -1;
}
@@ -169,34 +169,34 @@ static int CurNurb_compare (BPy_CurNurb * a, BPy_CurNurb * b)
factory method to create a BPy_CurNurb from a Blender Nurb
*/
-PyObject *CurNurb_CreatePyObject (Nurb * blen_nurb)
+PyObject *CurNurb_CreatePyObject( Nurb * blen_nurb )
{
BPy_CurNurb *pyNurb;
- pyNurb = (BPy_CurNurb *) PyObject_NEW (BPy_CurNurb, &CurNurb_Type);
+ pyNurb = ( BPy_CurNurb * ) PyObject_NEW( BPy_CurNurb, &CurNurb_Type );
- if(!pyNurb)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "could not create BPy_CurNurb PyObject");
+ if( !pyNurb )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "could not create BPy_CurNurb PyObject" );
pyNurb->nurb = blen_nurb;
- return (PyObject *) pyNurb;
+ return ( PyObject * ) pyNurb;
}
/*
* CurNurb_repr
*/
-static PyObject *CurNurb_repr (BPy_CurNurb * self)
+static PyObject *CurNurb_repr( BPy_CurNurb * self )
{ /* used by 'repr' */
- return PyString_FromFormat ("[CurNurb \"%d\"]", self->nurb->type);
+ return PyString_FromFormat( "[CurNurb \"%d\"]", self->nurb->type );
}
-static PyObject *M_CurNurb_New (PyObject * self, PyObject * args)
+static PyObject *M_CurNurb_New( PyObject * self, PyObject * args )
{
- return (PyObject *) 0;
+ return ( PyObject * ) 0;
}
@@ -208,11 +208,11 @@ static PyObject *M_CurNurb_New (PyObject * self, PyObject * args)
* arg is BezTriple or list of xyzw floats
*/
-PyObject *CurNurb_append (BPy_CurNurb * self, PyObject * args)
+PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * args )
{
Nurb *nurb = self->nurb;
- return CurNurb_appendPointToNurb (nurb, args);
+ return CurNurb_appendPointToNurb( nurb, args );
}
@@ -222,7 +222,7 @@ PyObject *CurNurb_append (BPy_CurNurb * self, PyObject * args)
* this is a non-bpy utility func to add a point to a given nurb
*/
-PyObject *CurNurb_appendPointToNurb (Nurb * nurb, PyObject * args)
+PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args )
{
int i;
@@ -233,81 +233,82 @@ PyObject *CurNurb_appendPointToNurb (Nurb * nurb, PyObject * args)
/*
do we have a list of four floats or a BezTriple?
*/
- PyArg_ParseTuple (args, "O", &pyOb);
+ PyArg_ParseTuple( args, "O", &pyOb );
- if(BezTriple_CheckPyObject (pyOb)) {
+ if( BezTriple_CheckPyObject( pyOb ) ) {
BezTriple *tmp;
npoints = nurb->pntsu;
/* printf("\ndbg: got a BezTriple\n"); */
tmp = nurb->bezt; /* save old points */
nurb->bezt =
- (BezTriple *) MEM_mallocN (sizeof (BezTriple) *
- (npoints + 1),
- "CurNurb_append2");
+ ( BezTriple * ) MEM_mallocN( sizeof( BezTriple ) *
+ ( npoints + 1 ),
+ "CurNurb_append2" );
- if(!nurb->bezt)
- return (EXPP_ReturnPyObjError
- (PyExc_MemoryError, "allocation failed"));
+ if( !nurb->bezt )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError, "allocation failed" ) );
/* copy old points to new */
- memmove (nurb->bezt, tmp, sizeof (BezTriple) * npoints);
+ memmove( nurb->bezt, tmp, sizeof( BezTriple ) * npoints );
if( tmp )
- MEM_freeN (tmp);
+ MEM_freeN( tmp );
nurb->pntsu++;
/* add new point to end of list */
- memcpy (nurb->bezt + npoints,
- BezTriple_FromPyObject (pyOb), sizeof (BezTriple));
+ memcpy( nurb->bezt + npoints,
+ BezTriple_FromPyObject( pyOb ), sizeof( BezTriple ) );
- } else if(PySequence_Check (pyOb)) {
- size = PySequence_Size (pyOb);
+ } else if( PySequence_Check( pyOb ) ) {
+ size = PySequence_Size( pyOb );
/* printf("\ndbg: got a sequence of size %d\n", size ); */
- if(size == 4) {
+ if( size == 4 ) {
BPoint *tmp;
npoints = nurb->pntsu;
tmp = nurb->bp; /* save old pts */
nurb->bp =
- (BPoint *) MEM_mallocN (sizeof (BPoint) *
- (npoints + 1),
- "CurNurb_append1");
- if(!nurb->bp)
- return (EXPP_ReturnPyObjError
- (PyExc_MemoryError,
- "allocation failed"));
-
- memmove (nurb->bp, tmp, sizeof (BPoint) * npoints);
- if( tmp)
- MEM_freeN (tmp);
+ ( BPoint * ) MEM_mallocN( sizeof( BPoint ) *
+ ( npoints + 1 ),
+ "CurNurb_append1" );
+ if( !nurb->bp )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "allocation failed" ) );
+
+ memmove( nurb->bp, tmp, sizeof( BPoint ) * npoints );
+ if( tmp )
+ MEM_freeN( tmp );
++nurb->pntsu;
/* initialize new BPoint from old */
- memcpy (nurb->bp + npoints, nurb->bp, sizeof (BPoint));
+ memcpy( nurb->bp + npoints, nurb->bp,
+ sizeof( BPoint ) );
- for(i = 0; i < 4; ++i) {
+ for( i = 0; i < 4; ++i ) {
float tmpx =
- (float) PyFloat_AsDouble
- (PySequence_GetItem (pyOb, i));
+ ( float ) PyFloat_AsDouble
+ ( PySequence_GetItem( pyOb, i ) );
nurb->bp[npoints].vec[i] = tmpx;
}
- makeknots (nurb, 1, nurb->flagu >> 1);
+ makeknots( nurb, 1, nurb->flagu >> 1 );
- } else if(size == 3) { /* 3 xyz coords */
- printf ("\nNot Yet Implemented!\n");
+ } else if( size == 3 ) { /* 3 xyz coords */
+ printf( "\nNot Yet Implemented!\n" );
}
} else {
/* bail with error */
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError, "expected better stuff"));
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, "expected better stuff" ) );
}
- return (EXPP_incr_ret (Py_None));
+ return ( EXPP_incr_ret( Py_None ) );
}
@@ -317,18 +318,19 @@ PyObject *CurNurb_appendPointToNurb (Nurb * nurb, PyObject * args)
* set index into material list
*/
-static PyObject *CurNurb_setMatIndex (BPy_CurNurb * self, PyObject * args)
+static PyObject *CurNurb_setMatIndex( BPy_CurNurb * self, PyObject * args )
{
int index;
- if(!PyArg_ParseTuple (args, "i", &(index)))
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError, "expected integer argument"));
+ if( !PyArg_ParseTuple( args, "i", &( index ) ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected integer argument" ) );
/* fixme: some range checking would be nice! */
self->nurb->mat_nr = index;
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -338,15 +340,15 @@ static PyObject *CurNurb_setMatIndex (BPy_CurNurb * self, PyObject * args)
* returns index into material list
*/
-static PyObject *CurNurb_getMatIndex (BPy_CurNurb * self)
+static PyObject *CurNurb_getMatIndex( BPy_CurNurb * self )
{
- PyObject *index = PyInt_FromLong ((long) self->nurb->mat_nr);
+ PyObject *index = PyInt_FromLong( ( long ) self->nurb->mat_nr );
- if(index)
+ if( index )
return index;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "could not get material index"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "could not get material index" ) );
}
@@ -357,7 +359,7 @@ static PyObject *CurNurb_getMatIndex (BPy_CurNurb * self)
* this iterator returns the points for this CurNurb.
*/
-static PyObject *CurNurb_getIter (BPy_CurNurb * self)
+static PyObject *CurNurb_getIter( BPy_CurNurb * self )
{
self->bp = self->nurb->bp;
self->bezt = self->nurb->bezt;
@@ -365,29 +367,29 @@ static PyObject *CurNurb_getIter (BPy_CurNurb * self)
self->nextPoint = 0;
/* set exhausted flag if both bp and bezt are zero */
- if((!self->bp) && (!self->bezt))
+ if( ( !self->bp ) && ( !self->bezt ) )
self->atEnd = 1;
- Py_INCREF (self);
- return (PyObject *) self;
+ Py_INCREF( self );
+ return ( PyObject * ) self;
}
-static PyObject *CurNurb_iterNext (BPy_CurNurb * self)
+static PyObject *CurNurb_iterNext( BPy_CurNurb * self )
{
PyObject *po; /* return value */
Nurb *pnurb = self->nurb;
int npoints = pnurb->pntsu;
/* are we at end already? */
- if(self->atEnd)
- return (EXPP_ReturnPyObjError (PyExc_StopIteration,
- "iterator at end"));
+ if( self->atEnd )
+ return ( EXPP_ReturnPyObjError( PyExc_StopIteration,
+ "iterator at end" ) );
- if(self->nextPoint < npoints) {
+ if( self->nextPoint < npoints ) {
- po = CurNurb_pointAtIndex (self->nurb, self->nextPoint);
+ po = CurNurb_pointAtIndex( self->nurb, self->nextPoint );
self->nextPoint++;
return po;
@@ -396,8 +398,8 @@ static PyObject *CurNurb_iterNext (BPy_CurNurb * self)
self->atEnd = 1; /* set flag true */
}
- return (EXPP_ReturnPyObjError (PyExc_StopIteration,
- "iterator at end"));
+ return ( EXPP_ReturnPyObjError( PyExc_StopIteration,
+ "iterator at end" ) );
}
@@ -407,7 +409,7 @@ static PyObject *CurNurb_iterNext (BPy_CurNurb * self)
* test whether spline nurb or bezier
*/
-static PyObject *CurNurb_isNurb (BPy_CurNurb * self)
+static PyObject *CurNurb_isNurb( BPy_CurNurb * self )
{
/* NOTE: a Nurb has bp and bezt pointers
* depending on type.
@@ -415,12 +417,12 @@ static PyObject *CurNurb_isNurb (BPy_CurNurb * self)
* in that case, we return False
*/
- if(self->nurb->bp) {
- Py_INCREF (Py_True);
+ if( self->nurb->bp ) {
+ Py_INCREF( Py_True );
return Py_True;
} else {
- Py_INCREF (Py_False);
- return (Py_False);
+ Py_INCREF( Py_False );
+ return ( Py_False );
}
}
@@ -434,7 +436,7 @@ static PyObject *CurNurb_isNurb (BPy_CurNurb * self)
static PyMethodDef M_CurNurb_methods[] = {
/* name, method, flags, doc_string */
- {"New", (PyCFunction) M_CurNurb_New, METH_VARARGS | METH_KEYWORDS,
+ {"New", ( PyCFunction ) M_CurNurb_New, METH_VARARGS | METH_KEYWORDS,
" () - doc string"},
/* {"Get", (PyCFunction) M_CurNurb_method, METH_NOARGS, " () - doc string"}, */
/* {"method", (PyCFunction) M_CurNurb_method, METH_NOARGS, " () - doc string"}, */
@@ -453,13 +455,13 @@ static PyMethodDef M_CurNurb_methods[] = {
static PyMethodDef BPy_CurNurb_methods[] = {
/* name, method, flags, doc */
/* {"method", (PyCFunction) CurNurb_method, METH_NOARGS, " () - doc string"} */
- {"setMatIndex", (PyCFunction) CurNurb_setMatIndex, METH_VARARGS,
+ {"setMatIndex", ( PyCFunction ) CurNurb_setMatIndex, METH_VARARGS,
"( index ) - set index into materials list"},
- {"getMatIndex", (PyCFunction) CurNurb_getMatIndex, METH_NOARGS,
+ {"getMatIndex", ( PyCFunction ) CurNurb_getMatIndex, METH_NOARGS,
"( ) - get current material index"},
- {"append", (PyCFunction) CurNurb_append, METH_VARARGS,
+ {"append", ( PyCFunction ) CurNurb_append, METH_VARARGS,
"( point ) - add a new point. arg is BezTriple or list of x,y,z,w floats"},
- {"isNurb", (PyCFunction) CurNurb_isNurb, METH_NOARGS,
+ {"isNurb", ( PyCFunction ) CurNurb_isNurb, METH_NOARGS,
"( ) - boolean function tests if this spline is type nurb or bezier"},
{NULL, NULL, 0, NULL}
};
@@ -470,14 +472,14 @@ static PyMethodDef BPy_CurNurb_methods[] = {
*/
static PySequenceMethods CurNurb_as_sequence = {
- (inquiry) CurNurb_length, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) CurNurb_getPoint, /* sq_item */
- (intintargfunc) 0, /* sq_slice */
+ ( inquiry ) CurNurb_length, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) CurNurb_getPoint, /* sq_item */
+ ( intintargfunc ) 0, /* sq_slice */
0, /* sq_ass_item */
0, /* sq_ass_slice */
- (objobjproc) 0, /* sq_contains */
+ ( objobjproc ) 0, /* sq_contains */
0,
0
};
@@ -490,20 +492,21 @@ static PySequenceMethods CurNurb_as_sequence = {
*/
PyTypeObject CurNurb_Type = {
- PyObject_HEAD_INIT (NULL) /* required py macro */ 0, /* ob_size */
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"CurNurb", /* char *tp_name; */
- sizeof (CurNurb_Type), /* int tp_basicsize, */
+ sizeof( CurNurb_Type ), /* int tp_basicsize, */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
- (destructor) CurNurb_dealloc, /* destructor tp_dealloc; */
+ ( destructor ) CurNurb_dealloc, /* destructor tp_dealloc; */
0, /* printfunc tp_print; */
- (getattrfunc) CurNurb_getAttr, /* getattrfunc tp_getattr; */
- (setattrfunc) CurNurb_setAttr, /* setattrfunc tp_setattr; */
- (cmpfunc) CurNurb_compare, /* cmpfunc tp_compare; */
- (reprfunc) CurNurb_repr, /* reprfunc tp_repr; */
+ ( getattrfunc ) CurNurb_getAttr, /* getattrfunc tp_getattr; */
+ ( setattrfunc ) CurNurb_setAttr, /* setattrfunc tp_setattr; */
+ ( cmpfunc ) CurNurb_compare, /* cmpfunc tp_compare; */
+ ( reprfunc ) CurNurb_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
@@ -542,8 +545,8 @@ PyTypeObject CurNurb_Type = {
/*** Added in release 2.2 ***/
/* Iterators */
- (getiterfunc) CurNurb_getIter, /* getiterfunc tp_iter; */
- (iternextfunc) CurNurb_iterNext, /* iternextfunc tp_iternext; */
+ ( getiterfunc ) CurNurb_getIter, /* getiterfunc tp_iter; */
+ ( iternextfunc ) CurNurb_iterNext, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_CurNurb_methods, /* struct PyMethodDef *tp_methods; */
@@ -577,19 +580,19 @@ PyTypeObject CurNurb_Type = {
* this is a tp_as_sequence method, not a regular instance method.
*/
-static int CurNurb_length (PyInstanceObject * inst)
+static int CurNurb_length( PyInstanceObject * inst )
{
Nurb *nurb;
int len;
- if(CurNurb_CheckPyObject ((PyObject *) inst)) {
- nurb = ((BPy_CurNurb *) inst)->nurb;
+ if( CurNurb_CheckPyObject( ( PyObject * ) inst ) ) {
+ nurb = ( ( BPy_CurNurb * ) inst )->nurb;
len = nurb->pntsu;
return len;
}
- return EXPP_ReturnIntError (PyExc_RuntimeError,
- "arg is not a BPy_CurNurb");
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "arg is not a BPy_CurNurb" );
}
@@ -600,7 +603,7 @@ static int CurNurb_length (PyInstanceObject * inst)
* it is called via the [] operator, not as a usual instance method.
*/
-PyObject *CurNurb_getPoint (BPy_CurNurb * self, int index)
+PyObject *CurNurb_getPoint( BPy_CurNurb * self, int index )
{
PyObject *pyo;
Nurb *myNurb;
@@ -616,17 +619,17 @@ PyObject *CurNurb_getPoint (BPy_CurNurb * self, int index)
/* negative indices as starting from the right end of a sequence */
/* bail if no Nurbs in Curve */
- if(npoints == 0)
- return (EXPP_ReturnPyObjError (PyExc_IndexError,
- "no points in this CurNurb"));
+ if( npoints == 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_IndexError,
+ "no points in this CurNurb" ) );
- if(index >= npoints) /* out of range! */
- return (EXPP_ReturnPyObjError (PyExc_IndexError,
- "index out of range"));
+ if( index >= npoints ) /* out of range! */
+ return ( EXPP_ReturnPyObjError( PyExc_IndexError,
+ "index out of range" ) );
- pyo = CurNurb_pointAtIndex (myNurb, index);
+ pyo = CurNurb_pointAtIndex( myNurb, index );
- return (PyObject *) pyo;
+ return ( PyObject * ) pyo;
}
@@ -634,47 +637,48 @@ PyObject *CurNurb_getPoint (BPy_CurNurb * self, int index)
* this is an internal routine. not callable directly from python
*/
-PyObject *CurNurb_pointAtIndex (Nurb * nurb, int index)
+PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index )
{
PyObject *pyo;
- if(nurb->bp) { /* we have a nurb curve */
+ if( nurb->bp ) { /* we have a nurb curve */
int i;
- pyo = PyList_New (4);
+ pyo = PyList_New( 4 );
- for(i = 0; i < 4; i++) {
- PyList_SetItem (pyo, i,
- PyFloat_FromDouble (nurb->bp[index].vec[i]));
+ for( i = 0; i < 4; i++ ) {
+ PyList_SetItem( pyo, i,
+ PyFloat_FromDouble( nurb->bp[index].
+ vec[i] ) );
}
- } else if(nurb->bezt) { /* we have a bezier */
+ } else if( nurb->bezt ) { /* we have a bezier */
/* if an error occurs, we just pass it on */
- pyo = BezTriple_CreatePyObject (&(nurb->bezt[index]));
+ pyo = BezTriple_CreatePyObject( &( nurb->bezt[index] ) );
} else /* something is horribly wrong */
/* neither bp or bezt is set && pntsu != 0 */
- return (EXPP_ReturnPyObjError (PyExc_SystemError,
- "inconsistant structure found"));
+ return ( EXPP_ReturnPyObjError( PyExc_SystemError,
+ "inconsistant structure found" ) );
- return (pyo);
+ return ( pyo );
}
-int CurNurb_CheckPyObject (PyObject * py_obj)
+int CurNurb_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &CurNurb_Type);
+ return ( py_obj->ob_type == &CurNurb_Type );
}
-PyObject *CurNurb_Init (void)
+PyObject *CurNurb_Init( void )
{
PyObject *submodule;
Curve_Type.ob_type = &PyType_Type;
submodule =
- Py_InitModule3 ("Blender.CurNurb", M_CurNurb_methods,
- M_CurNurb_doc);
- return (submodule);
+ Py_InitModule3( "Blender.CurNurb", M_CurNurb_methods,
+ M_CurNurb_doc );
+ return ( submodule );
}
diff --git a/source/blender/python/api2_2x/CurNurb.h b/source/blender/python/api2_2x/CurNurb.h
index 2cc3e1e5786..f0a90f28888 100644
--- a/source/blender/python/api2_2x/CurNurb.h
+++ b/source/blender/python/api2_2x/CurNurb.h
@@ -1,11 +1,41 @@
+/*
+ * $Id$
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * This is a new part of Blender.
+ *
+ * Contributor(s): Stephen Swaney
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
#ifndef EXPP_NURB_H
#define EXPP_NURB_H
-PyObject* CurNurb_getPoint( BPy_CurNurb* self, int index );
-PyObject* CurNurb_pointAtIndex( Nurb* nurb, int index );
+PyObject *CurNurb_getPoint( BPy_CurNurb * self, int index );
+PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index );
-PyObject* CurNurb_appendPointToNurb( Nurb* nurb, PyObject* args );
+PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args );
-#endif /* EXPP_NURB_H */
+#endif /* EXPP_NURB_H */
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 8b6e3132875..36370ec6077 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -66,67 +66,67 @@ char M_Curve_Get_doc[] = "xxx";
/*****************************************************************************/
/* Python API function prototypes for the Curve module. */
/*****************************************************************************/
-static PyObject *M_Curve_New (PyObject * self, PyObject * args);
-static PyObject *M_Curve_Get (PyObject * self, PyObject * args);
+static PyObject *M_Curve_New( PyObject * self, PyObject * args );
+static PyObject *M_Curve_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Curve instance methods declarations: */
/*****************************************************************************/
-static PyObject *Curve_getName (BPy_Curve * self);
-static PyObject *Curve_setName (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getPathLen (BPy_Curve * self);
-static PyObject *Curve_setPathLen (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getTotcol (BPy_Curve * self);
-static PyObject *Curve_setTotcol (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getMode (BPy_Curve * self);
-static PyObject *Curve_setMode (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getBevresol (BPy_Curve * self);
-static PyObject *Curve_setBevresol (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getResolu (BPy_Curve * self);
-static PyObject *Curve_setResolu (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getResolv (BPy_Curve * self);
-static PyObject *Curve_setResolv (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getWidth (BPy_Curve * self);
-static PyObject *Curve_setWidth (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getExt1 (BPy_Curve * self);
-static PyObject *Curve_setExt1 (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getExt2 (BPy_Curve * self);
-static PyObject *Curve_setExt2 (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getControlPoint (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_setControlPoint (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getLoc (BPy_Curve * self);
-static PyObject *Curve_setLoc (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getRot (BPy_Curve * self);
-static PyObject *Curve_setRot (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getSize (BPy_Curve * self);
-static PyObject *Curve_setSize (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getNumCurves (BPy_Curve * self);
-static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args);
-
-static PyObject *Curve_appendPoint (BPy_Curve * self, PyObject * args);
-static PyObject *Curve_appendNurb (BPy_Curve * self, PyObject * args );
-
-static PyObject *Curve_getMaterials (BPy_Curve * self);
-
-static PyObject *Curve_getIter (BPy_Curve * self);
-static PyObject *Curve_iterNext (BPy_Curve * self);
-static PyObject *Curve_update (BPy_Curve * self);
-PyObject *Curve_getNurb (BPy_Curve * self, int n);
-static int Curve_length (PyInstanceObject * inst);
-void update_displists( void* data );
-
-void makeDispList(Object *ob);
-struct chartrans *text_to_curve(Object *ob, int mode);
+static PyObject *Curve_getName( BPy_Curve * self );
+static PyObject *Curve_setName( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getPathLen( BPy_Curve * self );
+static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getTotcol( BPy_Curve * self );
+static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getMode( BPy_Curve * self );
+static PyObject *Curve_setMode( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getBevresol( BPy_Curve * self );
+static PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getResolu( BPy_Curve * self );
+static PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getResolv( BPy_Curve * self );
+static PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getWidth( BPy_Curve * self );
+static PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getExt1( BPy_Curve * self );
+static PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getExt2( BPy_Curve * self );
+static PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getLoc( BPy_Curve * self );
+static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getRot( BPy_Curve * self );
+static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getSize( BPy_Curve * self );
+static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getNumCurves( BPy_Curve * self );
+static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
+
+static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args );
+static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args );
+
+static PyObject *Curve_getMaterials( BPy_Curve * self );
+
+static PyObject *Curve_getIter( BPy_Curve * self );
+static PyObject *Curve_iterNext( BPy_Curve * self );
+static PyObject *Curve_update( BPy_Curve * self );
+PyObject *Curve_getNurb( BPy_Curve * self, int n );
+static int Curve_length( PyInstanceObject * inst );
+void update_displists( void *data );
+
+void makeDispList( Object * ob );
+struct chartrans *text_to_curve( Object * ob, int mode );
/*****************************************************************************/
/* Python method definitions for Blender.Curve module: */
/*****************************************************************************/
struct PyMethodDef M_Curve_methods[] = {
- {"New", (PyCFunction) M_Curve_New, METH_VARARGS, M_Curve_New_doc},
+ {"New", ( PyCFunction ) M_Curve_New, METH_VARARGS, M_Curve_New_doc},
{"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
{"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
{NULL, NULL, 0, NULL}
@@ -134,110 +134,110 @@ struct PyMethodDef M_Curve_methods[] = {
/*****************************************************************************/
-/* Python BPy_Curve instance methods table: */
+/* Python BPy_Curve instance methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Curve_methods[] = {
- {"getName", (PyCFunction) Curve_getName,
+ {"getName", ( PyCFunction ) Curve_getName,
METH_NOARGS, "() - Return Curve Data name"},
- {"setName", (PyCFunction) Curve_setName,
+ {"setName", ( PyCFunction ) Curve_setName,
METH_VARARGS, "() - Sets Curve Data name"},
- {"getPathLen", (PyCFunction) Curve_getPathLen,
+ {"getPathLen", ( PyCFunction ) Curve_getPathLen,
METH_NOARGS, "() - Return Curve path length"},
- {"setPathLen", (PyCFunction) Curve_setPathLen,
+ {"setPathLen", ( PyCFunction ) Curve_setPathLen,
METH_VARARGS, "(int) - Sets Curve path length"},
- {"getTotcol", (PyCFunction) Curve_getTotcol,
+ {"getTotcol", ( PyCFunction ) Curve_getTotcol,
METH_NOARGS, "() - Return the number of materials of the curve"},
- {"setTotcol", (PyCFunction) Curve_setTotcol,
+ {"setTotcol", ( PyCFunction ) Curve_setTotcol,
METH_VARARGS, "(int) - Sets the number of materials of the curve"},
- {"getFlag", (PyCFunction) Curve_getMode,
+ {"getFlag", ( PyCFunction ) Curve_getMode,
METH_NOARGS, "() - Return flag (see the doc for semantic)"},
- {"setFlag", (PyCFunction) Curve_setMode,
+ {"setFlag", ( PyCFunction ) Curve_setMode,
METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"},
- {"getBevresol", (PyCFunction) Curve_getBevresol,
+ {"getBevresol", ( PyCFunction ) Curve_getBevresol,
METH_NOARGS, "() - Return bevel resolution"},
- {"setBevresol", (PyCFunction) Curve_setBevresol,
+ {"setBevresol", ( PyCFunction ) Curve_setBevresol,
METH_VARARGS, "(int) - Sets bevel resolution"},
- {"getResolu", (PyCFunction) Curve_getResolu,
+ {"getResolu", ( PyCFunction ) Curve_getResolu,
METH_NOARGS, "() - Return U resolution"},
- {"setResolu", (PyCFunction) Curve_setResolu,
+ {"setResolu", ( PyCFunction ) Curve_setResolu,
METH_VARARGS, "(int) - Sets U resolution"},
- {"getResolv", (PyCFunction) Curve_getResolv,
+ {"getResolv", ( PyCFunction ) Curve_getResolv,
METH_NOARGS, "() - Return V resolution"},
- {"setResolv", (PyCFunction) Curve_setResolv,
+ {"setResolv", ( PyCFunction ) Curve_setResolv,
METH_VARARGS, "(int) - Sets V resolution"},
- {"getWidth", (PyCFunction) Curve_getWidth,
+ {"getWidth", ( PyCFunction ) Curve_getWidth,
METH_NOARGS, "() - Return curve width"},
- {"setWidth", (PyCFunction) Curve_setWidth,
+ {"setWidth", ( PyCFunction ) Curve_setWidth,
METH_VARARGS, "(int) - Sets curve width"},
- {"getExt1", (PyCFunction) Curve_getExt1,
+ {"getExt1", ( PyCFunction ) Curve_getExt1,
METH_NOARGS, "() - Returns extent 1 of the bevel"},
- {"setExt1", (PyCFunction) Curve_setExt1,
+ {"setExt1", ( PyCFunction ) Curve_setExt1,
METH_VARARGS, "(int) - Sets extent 1 of the bevel"},
- {"getExt2", (PyCFunction) Curve_getExt2,
+ {"getExt2", ( PyCFunction ) Curve_getExt2,
METH_NOARGS, "() - Return extent 2 of the bevel "},
- {"setExt2", (PyCFunction) Curve_setExt2,
+ {"setExt2", ( PyCFunction ) Curve_setExt2,
METH_VARARGS, "(int) - Sets extent 2 of the bevel "},
- {"getControlPoint", (PyCFunction) Curve_getControlPoint,
+ {"getControlPoint", ( PyCFunction ) Curve_getControlPoint,
METH_VARARGS, "(int numcurve,int numpoint) -\
Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"},
- {"setControlPoint", (PyCFunction) Curve_setControlPoint,
+ {"setControlPoint", ( PyCFunction ) Curve_setControlPoint,
METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\
float w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\
Sets a control point "},
- {"getLoc", (PyCFunction) Curve_getLoc,
+ {"getLoc", ( PyCFunction ) Curve_getLoc,
METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "},
- {"setLoc", (PyCFunction) Curve_setLoc,
+ {"setLoc", ( PyCFunction ) Curve_setLoc,
METH_VARARGS, "(3-tuple) - Sets Location "},
- {"getRot", (PyCFunction) Curve_getRot,
+ {"getRot", ( PyCFunction ) Curve_getRot,
METH_NOARGS, "() - Gets curve rotation"},
- {"setRot", (PyCFunction) Curve_setRot,
+ {"setRot", ( PyCFunction ) Curve_setRot,
METH_VARARGS, "(3-tuple) - Sets curve rotation"},
- {"getSize", (PyCFunction) Curve_getSize,
+ {"getSize", ( PyCFunction ) Curve_getSize,
METH_NOARGS, "() - Gets curve size"},
- {"setSize", (PyCFunction) Curve_setSize,
+ {"setSize", ( PyCFunction ) Curve_setSize,
METH_VARARGS, "(3-tuple) - Sets curve size"},
- {"getNumCurves", (PyCFunction) Curve_getNumCurves,
+ {"getNumCurves", ( PyCFunction ) Curve_getNumCurves,
METH_NOARGS, "() - Gets number of curves in Curve"},
- {"isNurb", (PyCFunction) Curve_isNurb,
+ {"isNurb", ( PyCFunction ) Curve_isNurb,
METH_VARARGS,
"(nothing or integer) - returns 1 if curve is type Nurb, O otherwise."},
- {"getNumPoints", (PyCFunction) Curve_getNumPoints,
+ {"getNumPoints", ( PyCFunction ) Curve_getNumPoints,
METH_VARARGS,
"(nothing or integer) - returns the number of points of the specified curve"},
- {"appendPoint", (PyCFunction) Curve_appendPoint, METH_VARARGS,
+ {"appendPoint", ( PyCFunction ) Curve_appendPoint, METH_VARARGS,
"( int numcurve, list of coordinates) - adds a new point to end of curve"},
- {"appendNurb", (PyCFunction) Curve_appendNurb, METH_VARARGS,
+ {"appendNurb", ( PyCFunction ) Curve_appendNurb, METH_VARARGS,
"( new_nurb ) - adds a new nurb to the Curve"},
- {"update", (PyCFunction) Curve_update, METH_NOARGS,
+ {"update", ( PyCFunction ) Curve_update, METH_NOARGS,
"( ) - updates display lists after changes to Curve"},
- {"getMaterials", (PyCFunction) Curve_getMaterials, METH_NOARGS,
+ {"getMaterials", ( PyCFunction ) Curve_getMaterials, METH_NOARGS,
"() - returns list of materials assigned to this Curve"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Curve_Type callback function prototypes: */
+/* Python Curve_Type callback function prototypes: */
/*****************************************************************************/
-static void CurveDeAlloc (BPy_Curve * msh);
+static void CurveDeAlloc( BPy_Curve * msh );
/* static int CurvePrint (BPy_Curve *msh, FILE *fp, int flags); */
-static int CurveSetAttr (BPy_Curve * msh, char *name, PyObject * v);
-static PyObject *CurveGetAttr (BPy_Curve * msh, char *name);
-static PyObject *CurveRepr (BPy_Curve * msh);
+static int CurveSetAttr( BPy_Curve * msh, char *name, PyObject * v );
+static PyObject *CurveGetAttr( BPy_Curve * msh, char *name );
+static PyObject *CurveRepr( BPy_Curve * msh );
-PyObject *Curve_CreatePyObject (struct Curve *curve);
-int Curve_CheckPyObject (PyObject * py_obj);
-struct Curve *Curve_FromPyObject (PyObject * py_obj);
+PyObject *Curve_CreatePyObject( struct Curve *curve );
+int Curve_CheckPyObject( PyObject * py_obj );
+struct Curve *Curve_FromPyObject( PyObject * py_obj );
static PySequenceMethods Curve_as_sequence = {
- (inquiry) Curve_length, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Curve_getNurb, /* sq_item */
- (intintargfunc) 0, /* sq_slice */
+ ( inquiry ) Curve_length, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) Curve_getNurb, /* sq_item */
+ ( intintargfunc ) 0, /* sq_slice */
0, /* sq_ass_item */
0, /* sq_ass_slice */
- (objobjproc) 0, /* sq_contains */
+ ( objobjproc ) 0, /* sq_contains */
0,
0
};
@@ -247,17 +247,18 @@ static PySequenceMethods Curve_as_sequence = {
/* Python Curve_Type structure definition: */
/*****************************************************************************/
PyTypeObject Curve_Type = {
- PyObject_HEAD_INIT (NULL) /* required macro */ 0, /* ob_size */
+ PyObject_HEAD_INIT( NULL ) /* required macro */
+ 0, /* ob_size */
"Curve", /* tp_name - for printing */
- sizeof (BPy_Curve), /* tp_basicsize - for allocation */
+ sizeof( BPy_Curve ), /* tp_basicsize - for allocation */
0, /* tp_itemsize - for allocation */
/* methods for standard operations */
- (destructor) CurveDeAlloc, /* tp_dealloc */
+ ( destructor ) CurveDeAlloc, /* tp_dealloc */
0, /* tp_print */
- (getattrfunc) CurveGetAttr, /* tp_getattr */
- (setattrfunc) CurveSetAttr, /* tp_setattr */
+ ( getattrfunc ) CurveGetAttr, /* tp_getattr */
+ ( setattrfunc ) CurveSetAttr, /* tp_setattr */
0, /* tp_compare */
- (reprfunc) CurveRepr, /* tp_repr */
+ ( reprfunc ) CurveRepr, /* tp_repr */
/* methods for standard classes */
0, /* tp_as_number */
&Curve_as_sequence, /* tp_as_sequence */
@@ -280,8 +281,8 @@ PyTypeObject Curve_Type = {
0, /* tp_weaklistoffset - weak reference enabler */
/* new release 2.2 stuff - Iterators */
- (getiterfunc) Curve_getIter, /* tp_iter */
- (iternextfunc) Curve_iterNext, /* tp_iternext */
+ ( getiterfunc ) Curve_getIter, /* tp_iter */
+ ( iternextfunc ) Curve_iterNext, /* tp_iternext */
/* Attribute descriptor and subclassing stuff */
BPy_Curve_methods, /* tp_methods */
@@ -309,128 +310,128 @@ PyTypeObject Curve_Type = {
/* Function: M_Curve_New */
/* Python equivalent: Blender.Curve.New */
/*****************************************************************************/
-static PyObject *M_Curve_New (PyObject * self, PyObject * args)
+static PyObject *M_Curve_New( PyObject * self, PyObject * args )
{
char buf[24];
char *name = NULL;
BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
- if(!PyArg_ParseTuple (args, "|s", &name))
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError,
- "expected string argument or no argument"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected string argument or no argument" ) );
- blcurve = add_curve (OB_CURVE); /* first create the Curve Data in Blender */
+ blcurve = add_curve( OB_CURVE ); /* first create the Curve Data in Blender */
- if(blcurve == NULL) /* bail out if add_curve() failed */
- return (EXPP_ReturnPyObjError
- (PyExc_RuntimeError,
- "couldn't create Curve Data in Blender"));
+ if( blcurve == NULL ) /* bail out if add_curve() failed */
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "couldn't create Curve Data in Blender" ) );
/* return user count to zero because add_curve() inc'd it */
blcurve->id.us = 0;
/* create python wrapper obj */
- pycurve = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type);
+ pycurve = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
- if(pycurve == NULL)
- return (EXPP_ReturnPyObjError
- (PyExc_MemoryError,
- "couldn't create Curve Data object"));
+ if( pycurve == NULL )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create Curve Data object" ) );
pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
- if(name) {
- PyOS_snprintf (buf, sizeof (buf), "%s", name);
- rename_id (&blcurve->id, buf);
+ if( name ) {
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &blcurve->id, buf );
}
- return (PyObject *) pycurve;
+ return ( PyObject * ) pycurve;
}
/*****************************************************************************/
/* Function: M_Curve_Get */
/* Python equivalent: Blender.Curve.Get */
/*****************************************************************************/
-static PyObject *M_Curve_Get (PyObject * self, PyObject * args)
+static PyObject *M_Curve_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Curve *curv_iter;
BPy_Curve *wanted_curv;
- if(!PyArg_ParseTuple (args, "|s", &name)) /* expects nothing or a string */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
- if(name) { /*a name has been given */
+ if( !PyArg_ParseTuple( args, "|s", &name ) ) /* expects nothing or a string */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
+ if( name ) { /*a name has been given */
/* Use the name to search for the curve requested */
wanted_curv = NULL;
curv_iter = G.main->curve.first;
- while((curv_iter) && (wanted_curv == NULL)) {
+ while( ( curv_iter ) && ( wanted_curv == NULL ) ) {
- if(strcmp (name, curv_iter->id.name + 2) == 0) {
- wanted_curv =
- (BPy_Curve *) PyObject_NEW (BPy_Curve,
- &Curve_Type);
- if(wanted_curv)
+ if( strcmp( name, curv_iter->id.name + 2 ) == 0 ) {
+ wanted_curv = ( BPy_Curve * )
+ PyObject_NEW( BPy_Curve, &Curve_Type );
+ if( wanted_curv )
wanted_curv->curve = curv_iter;
}
curv_iter = curv_iter->id.next;
}
- if(wanted_curv == NULL) { /* Requested curve doesn't exist */
+ if( wanted_curv == NULL ) { /* Requested curve doesn't exist */
char error_msg[64];
- PyOS_snprintf (error_msg, sizeof (error_msg),
- "Curve \"%s\" not found", name);
- return (EXPP_ReturnPyObjError
- (PyExc_NameError, error_msg));
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Curve \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
- return (PyObject *) wanted_curv;
+ return ( PyObject * ) wanted_curv;
} /* end of if(name) */
else {
/* no name has been given; return a list of all curves by name. */
PyObject *curvlist;
curv_iter = G.main->curve.first;
- curvlist = PyList_New (0);
+ curvlist = PyList_New( 0 );
- if(curvlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( curvlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while(curv_iter) {
+ while( curv_iter ) {
BPy_Curve *found_cur =
- (BPy_Curve *) PyObject_NEW (BPy_Curve,
- &Curve_Type);
+ ( BPy_Curve * ) PyObject_NEW( BPy_Curve,
+ &Curve_Type );
found_cur->curve = curv_iter;
- PyList_Append (curvlist, (PyObject *) found_cur);
+ PyList_Append( curvlist, ( PyObject * ) found_cur );
curv_iter = curv_iter->id.next;
}
- return (curvlist);
+ return ( curvlist );
} /* end of else */
}
/*****************************************************************************/
/* Function: Curve_Init */
/*****************************************************************************/
-PyObject *Curve_Init (void)
+PyObject *Curve_Init( void )
{
PyObject *submodule;
Curve_Type.ob_type = &PyType_Type;
submodule =
- Py_InitModule3 ("Blender.Curve", M_Curve_methods, M_Curve_doc);
- return (submodule);
+ Py_InitModule3( "Blender.Curve", M_Curve_methods,
+ M_Curve_doc );
+ return ( submodule );
}
/*****************************************************************************/
-/* Python BPy_Curve methods: */
+/* Python BPy_Curve methods: */
/* gives access to */
/* name, pathlen totcol flag bevresol */
/* resolu resolv width ext1 ext2 */
@@ -439,247 +440,247 @@ PyObject *Curve_Init (void)
/*****************************************************************************/
-static PyObject *Curve_getName (BPy_Curve * self)
+static PyObject *Curve_getName( BPy_Curve * self )
{
- PyObject *attr = PyString_FromString (self->curve->id.name + 2);
+ PyObject *attr = PyString_FromString( self->curve->id.name + 2 );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.name attribute" ) );
}
-static PyObject *Curve_setName (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setName( BPy_Curve * self, PyObject * args )
{
char *name;
char buf[50];
- if(!PyArg_ParseTuple (args, "s", &(name)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
- PyOS_snprintf (buf, sizeof (buf), "%s", name);
- rename_id (&self->curve->id, buf); /* proper way in Blender */
+ if( !PyArg_ParseTuple( args, "s", &( name ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &self->curve->id, buf ); /* proper way in Blender */
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getPathLen (BPy_Curve * self)
+static PyObject *Curve_getPathLen( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->pathlen);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->pathlen );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.pathlen attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.pathlen attribute" ) );
}
-static PyObject *Curve_setPathLen (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->pathlen)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->pathlen ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getTotcol (BPy_Curve * self)
+static PyObject *Curve_getTotcol( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->totcol);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->totcol );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.totcol attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.totcol attribute" ) );
}
-static PyObject *Curve_setTotcol (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->totcol)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->totcol ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getMode (BPy_Curve * self)
+static PyObject *Curve_getMode( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->flag);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->flag );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.flag attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.flag attribute" ) );
}
-static PyObject *Curve_setMode (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setMode( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->flag)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->flag ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getBevresol (BPy_Curve * self)
+static PyObject *Curve_getBevresol( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->bevresol);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->bevresol );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.bevresol attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.bevresol attribute" ) );
}
-static PyObject *Curve_setBevresol (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->bevresol)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->bevresol ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getResolu (BPy_Curve * self)
+static PyObject *Curve_getResolu( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->resolu);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->resolu );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.resolu attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.resolu attribute" ) );
}
-static PyObject *Curve_setResolu (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->resolu)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->resolu ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getResolv (BPy_Curve * self)
+static PyObject *Curve_getResolv( BPy_Curve * self )
{
- PyObject *attr = PyInt_FromLong ((long) self->curve->resolv);
+ PyObject *attr = PyInt_FromLong( ( long ) self->curve->resolv );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.resolv attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.resolv attribute" ) );
}
-static PyObject *Curve_setResolv (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "i", &(self->curve->resolv)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &( self->curve->resolv ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getWidth (BPy_Curve * self)
+static PyObject *Curve_getWidth( BPy_Curve * self )
{
- PyObject *attr = PyFloat_FromDouble ((double) self->curve->width);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->width );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.width attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.width attribute" ) );
}
-static PyObject *Curve_setWidth (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "f", &(self->curve->width)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &( self->curve->width ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getExt1 (BPy_Curve * self)
+static PyObject *Curve_getExt1( BPy_Curve * self )
{
- PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext1);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->ext1 );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.ext1 attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.ext1 attribute" ) );
}
-static PyObject *Curve_setExt1 (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "f", &(self->curve->ext1)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &( self->curve->ext1 ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getExt2 (BPy_Curve * self)
+static PyObject *Curve_getExt2( BPy_Curve * self )
{
- PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext2);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->ext2 );
- if(attr)
+ if( attr )
return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Curve.ext2 attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Curve.ext2 attribute" ) );
}
-static PyObject *Curve_setExt2 (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args )
{
- if(!PyArg_ParseTuple (args, "f", &(self->curve->ext2)))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &( self->curve->ext2 ) ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -732,101 +733,102 @@ static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args)
* it does NOT add a new one.
*/
-static PyObject *Curve_setControlPoint (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args )
{
PyObject *listargs = 0;
Nurb *ptrnurb = self->curve->nurb.first;
int numcourbe, numpoint, i, j;
- if(!ptrnurb) {
- Py_INCREF (Py_None);
+ if( !ptrnurb ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- if(ptrnurb->bp)
- if(!PyArg_ParseTuple
- (args, "iiO", &numcourbe, &numpoint, &listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError,
- "expected int int list arguments"));
- if(ptrnurb->bezt)
- if(!PyArg_ParseTuple
- (args, "iiO", &numcourbe, &numpoint, &listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_AttributeError,
- "expected int int list arguments"));
-
- for(i = 0; i < numcourbe; i++)
+ if( ptrnurb->bp )
+ if( !PyArg_ParseTuple
+ ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected int int list arguments" ) );
+ if( ptrnurb->bezt )
+ if( !PyArg_ParseTuple
+ ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected int int list arguments" ) );
+
+ for( i = 0; i < numcourbe; i++ )
ptrnurb = ptrnurb->next;
- if(ptrnurb->bp)
- for(i = 0; i < 4; i++)
+ if( ptrnurb->bp )
+ for( i = 0; i < 4; i++ )
ptrnurb->bp[numpoint].vec[i] =
- PyFloat_AsDouble (PyList_GetItem
- (listargs, i));
+ PyFloat_AsDouble( PyList_GetItem
+ ( listargs, i ) );
- if(ptrnurb->bezt)
- for(i = 0; i < 3; i++)
- for(j = 0; j < 3; j++)
+ if( ptrnurb->bezt )
+ for( i = 0; i < 3; i++ )
+ for( j = 0; j < 3; j++ )
ptrnurb->bezt[numpoint].vec[i][j] =
- PyFloat_AsDouble (PyList_GetItem
- (listargs,
- i * 3 + j));
+ PyFloat_AsDouble( PyList_GetItem
+ ( listargs,
+ i * 3 + j ) );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getControlPoint (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
{
- PyObject *liste = PyList_New (0); /* return values */
+ PyObject *liste = PyList_New( 0 ); /* return values */
Nurb *ptrnurb;
int i, j;
/* input args: requested curve and point number on curve */
int numcourbe, numpoint;
- if(!PyArg_ParseTuple (args, "ii", &numcourbe, &numpoint))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int int arguments"));
- if((numcourbe < 0) || (numpoint < 0))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- " arguments must be non-negative"));
+ if( !PyArg_ParseTuple( args, "ii", &numcourbe, &numpoint ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int int arguments" ) );
+ if( ( numcourbe < 0 ) || ( numpoint < 0 ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ " arguments must be non-negative" ) );
/* if no nurbs in this curve obj */
- if(!self->curve->nurb.first)
+ if( !self->curve->nurb.first )
return liste;
/* walk the list of nurbs to find requested numcourbe */
ptrnurb = self->curve->nurb.first;
- for(i = 0; i < numcourbe; i++) {
+ for( i = 0; i < numcourbe; i++ ) {
ptrnurb = ptrnurb->next;
- if(!ptrnurb) /* if zero, we ran just ran out of curves */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "curve index out of range"));
+ if( !ptrnurb ) /* if zero, we ran just ran out of curves */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "curve index out of range" ) );
}
/* check numpoint param against pntsu */
- if(numpoint >= ptrnurb->pntsu)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "point index out of range"));
-
- if(ptrnurb->bp) { /* if we are a nurb curve, you get 4 values */
- for(i = 0; i < 4; i++)
- PyList_Append (liste,
- PyFloat_FromDouble (ptrnurb->
+ if( numpoint >= ptrnurb->pntsu )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "point index out of range" ) );
+
+ if( ptrnurb->bp ) { /* if we are a nurb curve, you get 4 values */
+ for( i = 0; i < 4; i++ )
+ PyList_Append( liste,
+ PyFloat_FromDouble( ptrnurb->
bp[numpoint].
- vec[i]));
+ vec[i] ) );
}
- if(ptrnurb->bezt) { /* if we are a bezier, you get 9 values */
- for(i = 0; i < 3; i++)
- for(j = 0; j < 3; j++)
- PyList_Append (liste,
- PyFloat_FromDouble (ptrnurb->
+ if( ptrnurb->bezt ) { /* if we are a bezier, you get 9 values */
+ for( i = 0; i < 3; i++ )
+ for( j = 0; j < 3; j++ )
+ PyList_Append( liste,
+ PyFloat_FromDouble( ptrnurb->
bezt
[numpoint].
- vec[i][j]));
+ vec[i]
+ [j] ) );
}
return liste;
@@ -834,90 +836,90 @@ static PyObject *Curve_getControlPoint (BPy_Curve * self, PyObject * args)
-static PyObject *Curve_getLoc (BPy_Curve * self)
+static PyObject *Curve_getLoc( BPy_Curve * self )
{
int i;
- PyObject *liste = PyList_New (3);
- for(i = 0; i < 3; i++)
- PyList_SetItem (liste, i,
- PyFloat_FromDouble (self->curve->loc[i]));
+ PyObject *liste = PyList_New( 3 );
+ for( i = 0; i < 3; i++ )
+ PyList_SetItem( liste, i,
+ PyFloat_FromDouble( self->curve->loc[i] ) );
return liste;
}
-static PyObject *Curve_setLoc (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args )
{
PyObject *listargs = 0;
int i;
- if(!PyArg_ParseTuple (args, "O", &listargs))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument");
- if(!PyList_Check (listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected a list"));
- for(i = 0; i < 3; i++) {
- PyObject *xx = PyList_GetItem (listargs, i);
- self->curve->loc[i] = PyFloat_AsDouble (xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument" );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->curve->loc[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getRot (BPy_Curve * self)
+static PyObject *Curve_getRot( BPy_Curve * self )
{
int i;
- PyObject *liste = PyList_New (3);
- for(i = 0; i < 3; i++)
- PyList_SetItem (liste, i,
- PyFloat_FromDouble (self->curve->rot[i]));
+ PyObject *liste = PyList_New( 3 );
+ for( i = 0; i < 3; i++ )
+ PyList_SetItem( liste, i,
+ PyFloat_FromDouble( self->curve->rot[i] ) );
return liste;
}
-static PyObject *Curve_setRot (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args )
{
PyObject *listargs = 0;
int i;
- if(!PyArg_ParseTuple (args, "O", &listargs))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument");
- if(!PyList_Check (listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected a list"));
- for(i = 0; i < 3; i++) {
- PyObject *xx = PyList_GetItem (listargs, i);
- self->curve->rot[i] = PyFloat_AsDouble (xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument" );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->curve->rot[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Curve_getSize (BPy_Curve * self)
+static PyObject *Curve_getSize( BPy_Curve * self )
{
int i;
- PyObject *liste = PyList_New (3);
- for(i = 0; i < 3; i++)
- PyList_SetItem (liste, i,
- PyFloat_FromDouble (self->curve->size[i]));
+ PyObject *liste = PyList_New( 3 );
+ for( i = 0; i < 3; i++ )
+ PyList_SetItem( liste, i,
+ PyFloat_FromDouble( self->curve->size[i] ) );
return liste;
}
-static PyObject *Curve_setSize (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args )
{
PyObject *listargs = 0;
int i;
- if(!PyArg_ParseTuple (args, "O", &listargs))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument");
- if(!PyList_Check (listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected a list"));
- for(i = 0; i < 3; i++) {
- PyObject *xx = PyList_GetItem (listargs, i);
- self->curve->size[i] = PyFloat_AsDouble (xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument" );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->curve->size[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -927,7 +929,7 @@ static PyObject *Curve_setSize (BPy_Curve * self, PyObject * args)
* int getNumCurves()
*/
-static PyObject *Curve_getNumCurves (BPy_Curve * self)
+static PyObject *Curve_getNumCurves( BPy_Curve * self )
{
Nurb *ptrnurb;
PyObject *ret_val;
@@ -935,23 +937,23 @@ static PyObject *Curve_getNumCurves (BPy_Curve * self)
/* get curve */
ptrnurb = self->curve->nurb.first;
- if(ptrnurb) { /* we have some nurbs in this curve */
- while(1) {
+ if( ptrnurb ) { /* we have some nurbs in this curve */
+ while( 1 ) {
++num_curves;
ptrnurb = ptrnurb->next;
- if(!ptrnurb) /* no more curves */
+ if( !ptrnurb ) /* no more curves */
break;
}
}
- ret_val = PyInt_FromLong ((long) num_curves);
+ ret_val = PyInt_FromLong( ( long ) num_curves );
- if(ret_val)
+ if( ret_val )
return ret_val;
/* oops! */
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get number of curves"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get number of curves" ) );
}
@@ -961,7 +963,7 @@ static PyObject *Curve_getNumCurves (BPy_Curve * self)
*
*/
-static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args )
{
Nurb *ptrnurb;
PyObject *ret_val;
@@ -969,39 +971,39 @@ static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args)
int i;
/* parse input arg */
- if(!PyArg_ParseTuple (args, "|i", &curve_num))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "|i", &curve_num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
/* check arg - must be non-negative */
- if(curve_num < 0)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "argument must be non-negative"));
+ if( curve_num < 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "argument must be non-negative" ) );
/* walk the list of curves looking for our curve */
ptrnurb = self->curve->nurb.first;
- if(!ptrnurb) { /* no splines in this Curve */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no splines in this Curve"));
+ if( !ptrnurb ) { /* no splines in this Curve */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no splines in this Curve" ) );
}
- for(i = 0; i < curve_num; i++) {
+ for( i = 0; i < curve_num; i++ ) {
ptrnurb = ptrnurb->next;
- if(!ptrnurb) /* if zero, we ran just ran out of curves */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "curve index out of range"));
+ if( !ptrnurb ) /* if zero, we ran just ran out of curves */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "curve index out of range" ) );
}
/* pntsu is the number of points in curve */
- ret_val = PyInt_FromLong ((long) ptrnurb->pntsu);
+ ret_val = PyInt_FromLong( ( long ) ptrnurb->pntsu );
- if(ret_val)
+ if( ret_val )
return ret_val;
/* oops! */
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get number of points for curve"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get number of points for curve" ) );
}
/*
@@ -1010,7 +1012,7 @@ static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args)
* int isNurb( curve_num=0 )
*/
-static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args )
{
int curve_num = 0; /* default value */
int is_nurb;
@@ -1019,38 +1021,38 @@ static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args)
int i;
/* parse and check input args */
- if(!PyArg_ParseTuple (args, "|i", &curve_num)) {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "|i", &curve_num ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
}
- if(curve_num < 0) {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "curve number must be non-negative"));
+ if( curve_num < 0 ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "curve number must be non-negative" ) );
}
ptrnurb = self->curve->nurb.first;
- if(!ptrnurb) /* no splines in this curve */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no splines in this Curve"));
+ if( !ptrnurb ) /* no splines in this curve */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no splines in this Curve" ) );
- for(i = 0; i < curve_num; i++) {
+ for( i = 0; i < curve_num; i++ ) {
ptrnurb = ptrnurb->next;
- if(!ptrnurb) /* if zero, we ran just ran out of curves */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "curve index out of range"));
+ if( !ptrnurb ) /* if zero, we ran just ran out of curves */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "curve index out of range" ) );
}
/* right now, there are only two curve types, nurb and bezier. */
is_nurb = ptrnurb->bp ? 1 : 0;
- ret_val = PyInt_FromLong ((long) is_nurb);
- if(ret_val)
+ ret_val = PyInt_FromLong( ( long ) is_nurb );
+ if( ret_val )
return ret_val;
/* oops */
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get curve type"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get curve type" ) );
}
@@ -1059,49 +1061,48 @@ static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args)
* append a new point to indicated spline
*/
-static PyObject *Curve_appendPoint (BPy_Curve * self, PyObject * args)
+static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args )
{
int i;
- int nurb_num; /* index of curve we append to */
- PyObject* coord_args; /* coords for new point */
- Nurb* nurb = self->curve->nurb.first; /* first nurb in Curve */
+ int nurb_num; /* index of curve we append to */
+ PyObject *coord_args; /* coords for new point */
+ Nurb *nurb = self->curve->nurb.first; /* first nurb in Curve */
/* fixme - need to malloc new Nurb */
- if( ! nurb )
- return( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "no nurbs in this Curve"));
-
- if( ! PyArg_ParseTuple( args,"iO", &nurb_num, &coord_args ))
- return( EXPP_ReturnPyObjError
- (PyExc_AttributeError,
- "expected int, coords as arguments"));
-
+ if( !nurb )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, "no nurbs in this Curve" ) );
+
+ if( !PyArg_ParseTuple( args, "iO", &nurb_num, &coord_args ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected int, coords as arguments" ) );
+
/*
chase down the list of Nurbs looking for our curve.
- */
- for( i = 0; i < nurb_num; i++){
+ */
+ for( i = 0; i < nurb_num; i++ ) {
nurb = nurb->next;
- if( ! nurb ) /* we ran off end of list */
- return( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "curve index out of range"));
+ if( !nurb ) /* we ran off end of list */
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "curve index out of range" ) );
}
- return CurNurb_appendPointToNurb( nurb, coord_args );
+ return CurNurb_appendPointToNurb( nurb, coord_args );
}
-static PyObject *Curve_appendNurb (BPy_Curve * self, PyObject * args )
+static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args )
{
Nurb *nurb_ptr = self->curve->nurb.first;
- Nurb **pptr = (Nurb**) &( self->curve->nurb.first );
+ Nurb **pptr = ( Nurb ** ) & ( self->curve->nurb.first );
Nurb *new_nurb;
-
+
/* walk to end of nurblist */
- if( nurb_ptr){
+ if( nurb_ptr ) {
while( nurb_ptr->next ) {
nurb_ptr = nurb_ptr->next;
}
@@ -1109,18 +1110,17 @@ static PyObject *Curve_appendNurb (BPy_Curve * self, PyObject * args )
}
/* malloc new nurb */
- new_nurb = (Nurb*)MEM_callocN( sizeof(Nurb), "appendNurb");
- if( !new_nurb)
+ new_nurb = ( Nurb * ) MEM_callocN( sizeof( Nurb ), "appendNurb" );
+ if( !new_nurb )
return EXPP_ReturnPyObjError
- (PyExc_MemoryError,
- "unable to malloc Nurb");
+ ( PyExc_MemoryError, "unable to malloc Nurb" );
- if( CurNurb_appendPointToNurb( new_nurb, args )){
+ if( CurNurb_appendPointToNurb( new_nurb, args ) ) {
*pptr = new_nurb;
new_nurb->resolu = 12;
new_nurb->resolv = 12;
- if( new_nurb->bezt ){ /* do setup for bezt */
+ if( new_nurb->bezt ) { /* do setup for bezt */
new_nurb->type = CU_BEZIER;
new_nurb->bezt->h1 = HD_ALIGN;
new_nurb->bezt->h2 = HD_ALIGN;
@@ -1128,25 +1128,23 @@ static PyObject *Curve_appendNurb (BPy_Curve * self, PyObject * args )
new_nurb->bezt->f2 = 1;
new_nurb->bezt->f3 = 1;
/* calchandlesNurb( new_nurb ); */
- }
- else{ /* set up bp */
+ } else { /* set up bp */
new_nurb->pntsv = 1;
new_nurb->type = CU_NURBS;
new_nurb->orderu = 4;
new_nurb->flagu = 0;
new_nurb->flagv = 0;
new_nurb->bp->f1 = 0;
- new_nurb->knotsu=0;
+ new_nurb->knotsu = 0;
/*makenots( new_nurb, 1, new_nurb->flagu >> 1); */
}
-
- }
- else{
- freeNurb( new_nurb);
- return NULL; /* with PyErr already set */
+
+ } else {
+ freeNurb( new_nurb );
+ return NULL; /* with PyErr already set */
}
-
- return EXPP_incr_ret (Py_None);
+
+ return EXPP_incr_ret( Py_None );
}
@@ -1156,11 +1154,11 @@ static PyObject *Curve_appendNurb (BPy_Curve * self, PyObject * args )
* used. after messing with control points
*/
-static PyObject *Curve_update( BPy_Curve *self )
+static PyObject *Curve_update( BPy_Curve * self )
{
- update_displists( (void*) self->curve );
+ update_displists( ( void * ) self->curve );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -1169,11 +1167,10 @@ static PyObject *Curve_update( BPy_Curve *self )
*
*/
-static PyObject *Curve_getMaterials (BPy_Curve * self)
+static PyObject *Curve_getMaterials( BPy_Curve * self )
{
- return (EXPP_PyList_fromMaterialList (self->curve->mat,
- self->curve->totcol,
- 1 ) );
+ return ( EXPP_PyList_fromMaterialList( self->curve->mat,
+ self->curve->totcol, 1 ) );
}
@@ -1187,13 +1184,13 @@ static PyObject *Curve_getMaterials (BPy_Curve * self)
* the iter_pointer always points to the next available item or null
*/
-static PyObject *Curve_getIter (BPy_Curve * self)
+static PyObject *Curve_getIter( BPy_Curve * self )
{
self->iter_pointer = self->curve->nurb.first;
Py_INCREF( self );
- return (PyObject*) self;
-
+ return ( PyObject * ) self;
+
}
@@ -1204,22 +1201,22 @@ static PyObject *Curve_getIter (BPy_Curve * self)
* or NULL if at the end of the list.
*/
-static PyObject *Curve_iterNext (BPy_Curve * self)
+static PyObject *Curve_iterNext( BPy_Curve * self )
{
PyObject *po; /* return value */
Nurb *pnurb;
- if(self->iter_pointer) {
+ if( self->iter_pointer ) {
pnurb = self->iter_pointer;
self->iter_pointer = pnurb->next; /* advance iterator */
- po = CurNurb_CreatePyObject (pnurb); /* make a bpy_nurb */
+ po = CurNurb_CreatePyObject( pnurb ); /* make a bpy_nurb */
- return (PyObject *) po;
+ return ( PyObject * ) po;
}
/* if iter_pointer was null, we are at end */
- return (EXPP_ReturnPyObjError
- (PyExc_StopIteration, "iterator at end"));
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_StopIteration, "iterator at end" ) );
}
@@ -1232,14 +1229,14 @@ static PyObject *Curve_iterNext (BPy_Curve * self)
* this is a tp_as_sequence method, not a regular instance method.
*/
-static int Curve_length (PyInstanceObject * inst)
+static int Curve_length( PyInstanceObject * inst )
{
- if(Curve_CheckPyObject ((PyObject *) inst))
- return( (int) PyInt_AsLong
- (Curve_getNumCurves ((BPy_Curve *) inst)));
+ if( Curve_CheckPyObject( ( PyObject * ) inst ) )
+ return ( ( int ) PyInt_AsLong
+ ( Curve_getNumCurves( ( BPy_Curve * ) inst ) ) );
- return EXPP_ReturnIntError (PyExc_RuntimeError,
- "arg is not a BPy_Curve");
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "arg is not a BPy_Curve" );
}
@@ -1252,31 +1249,31 @@ static int Curve_length (PyInstanceObject * inst)
* it is called via the [] operator, not as a usual instance method.
*/
-PyObject *Curve_getNurb (BPy_Curve * self, int n)
+PyObject *Curve_getNurb( BPy_Curve * self, int n )
{
PyObject *pyo;
Nurb *pNurb;
int i;
/* bail if index < 0 */
- if(n < 0)
- return (EXPP_ReturnPyObjError (PyExc_IndexError,
- "index less than 0"));
+ if( n < 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_IndexError,
+ "index less than 0" ) );
/* bail if no Nurbs in Curve */
- if(self->curve->nurb.first == 0)
- return (EXPP_ReturnPyObjError (PyExc_IndexError,
- "no Nurbs in this Curve"));
+ if( self->curve->nurb.first == 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_IndexError,
+ "no Nurbs in this Curve" ) );
/* set pointer to nth Nurb */
- for(pNurb = self->curve->nurb.first, i = 0;
- pNurb != 0 && i < n; pNurb = pNurb->next, ++i)
+ for( pNurb = self->curve->nurb.first, i = 0;
+ pNurb != 0 && i < n; pNurb = pNurb->next, ++i )
/**/;
- if(!pNurb) /* we came to the end of the list */
- return (EXPP_ReturnPyObjError (PyExc_IndexError,
- "index out of range"));
+ if( !pNurb ) /* we came to the end of the list */
+ return ( EXPP_ReturnPyObjError( PyExc_IndexError,
+ "index out of range" ) );
- pyo = CurNurb_CreatePyObject (pNurb); /* make a bpy_curnurb */
- return (PyObject *) pyo;
+ pyo = CurNurb_CreatePyObject( pNurb ); /* make a bpy_curnurb */
+ return ( PyObject * ) pyo;
}
@@ -1284,136 +1281,136 @@ PyObject *Curve_getNurb (BPy_Curve * self, int n)
/*****************************************************************************/
/* Function: CurveDeAlloc */
-/* Description: This is a callback function for the BPy_Curve type. It is */
+/* Description: This is a callback function for the BPy_Curve type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void CurveDeAlloc (BPy_Curve * self)
+static void CurveDeAlloc( BPy_Curve * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
/* Function: CurveGetAttr */
-/* Description: This is a callback function for the BPy_Curve type. It is */
-/* the function that accesses BPy_Curve "member variables" and */
+/* Description: This is a callback function for the BPy_Curve type. It is */
+/* the function that accesses BPy_Curve "member variables" and */
/* methods. */
/*****************************************************************************/
-static PyObject *CurveGetAttr (BPy_Curve * self, char *name)
+static PyObject *CurveGetAttr( BPy_Curve * self, char *name )
{ /* getattr */
PyObject *attr = Py_None;
- if(strcmp (name, "name") == 0)
- attr = PyString_FromString (self->curve->id.name + 2);
- if(strcmp (name, "pathlen") == 0)
- attr = PyInt_FromLong (self->curve->pathlen);
- if(strcmp (name, "totcol") == 0)
- attr = PyInt_FromLong (self->curve->totcol);
- if(strcmp (name, "flag") == 0)
- attr = PyInt_FromLong (self->curve->flag);
- if(strcmp (name, "bevresol") == 0)
- attr = PyInt_FromLong (self->curve->bevresol);
- if(strcmp (name, "resolu") == 0)
- attr = PyInt_FromLong (self->curve->resolu);
- if(strcmp (name, "resolv") == 0)
- attr = PyInt_FromLong (self->curve->resolv);
- if(strcmp (name, "width") == 0)
- attr = PyFloat_FromDouble (self->curve->width);
- if(strcmp (name, "ext1") == 0)
- attr = PyFloat_FromDouble (self->curve->ext1);
- if(strcmp (name, "ext2") == 0)
- attr = PyFloat_FromDouble (self->curve->ext2);
- if(strcmp (name, "loc") == 0)
- return Curve_getLoc (self);
- if(strcmp (name, "rot") == 0)
- return Curve_getRot (self);
- if(strcmp (name, "size") == 0)
- return Curve_getSize (self);
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->curve->id.name + 2 );
+ if( strcmp( name, "pathlen" ) == 0 )
+ attr = PyInt_FromLong( self->curve->pathlen );
+ if( strcmp( name, "totcol" ) == 0 )
+ attr = PyInt_FromLong( self->curve->totcol );
+ if( strcmp( name, "flag" ) == 0 )
+ attr = PyInt_FromLong( self->curve->flag );
+ if( strcmp( name, "bevresol" ) == 0 )
+ attr = PyInt_FromLong( self->curve->bevresol );
+ if( strcmp( name, "resolu" ) == 0 )
+ attr = PyInt_FromLong( self->curve->resolu );
+ if( strcmp( name, "resolv" ) == 0 )
+ attr = PyInt_FromLong( self->curve->resolv );
+ if( strcmp( name, "width" ) == 0 )
+ attr = PyFloat_FromDouble( self->curve->width );
+ if( strcmp( name, "ext1" ) == 0 )
+ attr = PyFloat_FromDouble( self->curve->ext1 );
+ if( strcmp( name, "ext2" ) == 0 )
+ attr = PyFloat_FromDouble( self->curve->ext2 );
+ if( strcmp( name, "loc" ) == 0 )
+ return Curve_getLoc( self );
+ if( strcmp( name, "rot" ) == 0 )
+ return Curve_getRot( self );
+ if( strcmp( name, "size" ) == 0 )
+ return Curve_getSize( self );
#if 0
- if(strcmp (name, "numpts") == 0)
- return Curve_getNumPoints (self);
+ if( strcmp( name, "numpts" ) == 0 )
+ return Curve_getNumPoints( self );
#endif
- if(!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- if(attr != Py_None)
+ if( attr != Py_None )
return attr; /* member attribute found, return it */
/* not an attribute, search the methods table */
- return Py_FindMethod (BPy_Curve_methods, (PyObject *) self, name);
+ return Py_FindMethod( BPy_Curve_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
/* Function: CurveSetAttr */
-/* Description: This is a callback function for the BPy_Curve type. It is the */
-/* function that sets Curve Data attributes (member variables). */
+/* Description: This is a callback function for the BPy_Curve type. It */
+/* sets Curve Data attributes (member variables). */
/*****************************************************************************/
-static int CurveSetAttr (BPy_Curve * self, char *name, PyObject * value)
+static int CurveSetAttr( BPy_Curve * self, char *name, PyObject * value )
{
PyObject *valtuple;
PyObject *error = NULL;
- valtuple = Py_BuildValue ("(O)", value);
+ valtuple = Py_BuildValue( "(O)", value );
/* resolu resolv width ext1 ext2 */
- if(!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "CurveSetAttr: couldn't create PyTuple");
-
- if(strcmp (name, "name") == 0)
- error = Curve_setName (self, valtuple);
- else if(strcmp (name, "pathlen") == 0)
- error = Curve_setPathLen (self, valtuple);
- else if(strcmp (name, "resolu") == 0)
- error = Curve_setResolu (self, valtuple);
- else if(strcmp (name, "resolv") == 0)
- error = Curve_setResolv (self, valtuple);
- else if(strcmp (name, "width") == 0)
- error = Curve_setWidth (self, valtuple);
- else if(strcmp (name, "ext1") == 0)
- error = Curve_setExt1 (self, valtuple);
- else if(strcmp (name, "ext2") == 0)
- error = Curve_setExt2 (self, valtuple);
- else if(strcmp (name, "loc") == 0)
- error = Curve_setLoc (self, valtuple);
- else if(strcmp (name, "rot") == 0)
- error = Curve_setRot (self, valtuple);
- else if(strcmp (name, "size") == 0)
- error = Curve_setSize (self, valtuple);
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "CurveSetAttr: couldn't create PyTuple" );
+
+ if( strcmp( name, "name" ) == 0 )
+ error = Curve_setName( self, valtuple );
+ else if( strcmp( name, "pathlen" ) == 0 )
+ error = Curve_setPathLen( self, valtuple );
+ else if( strcmp( name, "resolu" ) == 0 )
+ error = Curve_setResolu( self, valtuple );
+ else if( strcmp( name, "resolv" ) == 0 )
+ error = Curve_setResolv( self, valtuple );
+ else if( strcmp( name, "width" ) == 0 )
+ error = Curve_setWidth( self, valtuple );
+ else if( strcmp( name, "ext1" ) == 0 )
+ error = Curve_setExt1( self, valtuple );
+ else if( strcmp( name, "ext2" ) == 0 )
+ error = Curve_setExt2( self, valtuple );
+ else if( strcmp( name, "loc" ) == 0 )
+ error = Curve_setLoc( self, valtuple );
+ else if( strcmp( name, "rot" ) == 0 )
+ error = Curve_setRot( self, valtuple );
+ else if( strcmp( name, "size" ) == 0 )
+ error = Curve_setSize( self, valtuple );
else { /* Error */
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if((strcmp (name, "Types") == 0)
- || (strcmp (name, "Modes") == 0))
- return (EXPP_ReturnIntError
- (PyExc_AttributeError,
- "constant dictionary -- cannot be changed"));
+ if( ( strcmp( name, "Types" ) == 0 )
+ || ( strcmp( name, "Modes" ) == 0 ) )
+ return ( EXPP_ReturnIntError
+ ( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" ) );
else
- return (EXPP_ReturnIntError
- (PyExc_KeyError, "attribute not found"));
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
}
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if(error != Py_None)
+ if( error != Py_None )
return -1;
- Py_DECREF (Py_None);
+ Py_DECREF( Py_None );
return 0;
}
/*****************************************************************************/
/* Function: CurveRepr */
-/* Description: This is a callback function for the BPy_Curve type. It */
+/* Description: This is a callback function for the BPy_Curve type. It */
/* builds a meaninful string to represent curve objects. */
/*****************************************************************************/
-static PyObject *CurveRepr (BPy_Curve * self)
+static PyObject *CurveRepr( BPy_Curve * self )
{ /* used by 'repr' */
- return PyString_FromFormat ("[Curve \"%s\"]",
- self->curve->id.name + 2);
+ return PyString_FromFormat( "[Curve \"%s\"]",
+ self->curve->id.name + 2 );
}
@@ -1422,32 +1419,32 @@ static PyObject *CurveRepr (BPy_Curve * self)
* constructor to build a py object from blender data
*/
-PyObject *Curve_CreatePyObject (struct Curve * curve)
+PyObject *Curve_CreatePyObject( struct Curve * curve )
{
BPy_Curve *blen_object;
- blen_object = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type);
+ blen_object = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
- if(blen_object == NULL) {
- return (NULL);
+ if( blen_object == NULL ) {
+ return ( NULL );
}
blen_object->curve = curve;
- return ((PyObject *) blen_object);
+ return ( ( PyObject * ) blen_object );
}
-int Curve_CheckPyObject (PyObject * py_obj)
+int Curve_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Curve_Type);
+ return ( py_obj->ob_type == &Curve_Type );
}
-struct Curve *Curve_FromPyObject (PyObject * py_obj)
+struct Curve *Curve_FromPyObject( PyObject * py_obj )
{
BPy_Curve *blen_obj;
- blen_obj = (BPy_Curve *) py_obj;
- return (blen_obj->curve);
+ blen_obj = ( BPy_Curve * ) py_obj;
+ return ( blen_obj->curve );
}
@@ -1458,7 +1455,7 @@ struct Curve *Curve_FromPyObject (PyObject * py_obj)
* so we can update their ob's disp list
*/
-void update_displists( void* data )
+void update_displists( void *data )
{
Base *base;
Object *ob;
@@ -1468,32 +1465,31 @@ void update_displists( void* data )
layer = G.scene->lay;
base = G.scene->base.first;
- while(base) {
- if(base->lay & layer)
- {
+ while( base ) {
+ if( base->lay & layer ) {
ob = base->object;
- if ELEM(ob->type, OB_CURVE, OB_SURF) {
- if(ob != G.obedit) {
- if ( ob->data == data ){
+ if( ELEM( ob->type, OB_CURVE, OB_SURF ) ) {
+ if( ob != G.obedit ) {
+ if( ob->data == data ) {
makeDispList( ob );
}
}
- }
- else if(ob->type == OB_FONT) {
- Curve *cu= ob->data;
- if(cu->textoncurve) {
- if( ((Curve *)cu->textoncurve->data)->key ) {
- text_to_curve(ob, 0);
- makeDispList(ob);
+ } else if( ob->type == OB_FONT ) {
+ Curve *cu = ob->data;
+ if( cu->textoncurve ) {
+ if( ( ( Curve * ) cu->textoncurve->
+ data )->key ) {
+ text_to_curve( ob, 0 );
+ makeDispList( ob );
}
}
}
}
- if( base->next == 0 && G.scene->set && base == G.scene->base.last)
- base= G.scene->set->base.first;
+ if( base->next == 0 && G.scene->set
+ && base == G.scene->base.last )
+ base = G.scene->set->base.first;
else
- base= base->next;
+ base = base->next;
}
}
-
diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h
index 713905d3ff5..ab5e1961b25 100644
--- a/source/blender/python/api2_2x/Curve.h
+++ b/source/blender/python/api2_2x/Curve.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -34,4 +35,4 @@
#include "bpy_types.h"
-#endif /* EXPP_CURVE_H */
+#endif /* EXPP_CURVE_H */
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 707323b9955..24d45fcc993 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -65,10 +65,10 @@
#include "BIF_mywindow.h"
#include "BIF_toolbox.h"
-#include "BPI_script.h" /* script struct */
+#include "BPI_script.h" /* script struct */
#include "interface.h"
-#include "mydevice.h" /*@ for all the event constants */
+#include "mydevice.h" /*@ for all the event constants */
/* This one was an extern in BPY_main.h, but only opy_draw.c was using it */
int g_window_redrawn;
@@ -77,49 +77,49 @@ int g_window_redrawn;
int EXPP_disable_force_draw = 0;
/* forward declarations for internal functions */
-static void Button_dealloc (PyObject *self);
-static PyObject *Button_getattr (PyObject *self, char *name);
-static PyObject *Button_repr (PyObject *self);
-static int Button_setattr (PyObject *self, char *name, PyObject *v);
+static void Button_dealloc( PyObject * self );
+static PyObject *Button_getattr( PyObject * self, char *name );
+static PyObject *Button_repr( PyObject * self );
+static int Button_setattr( PyObject * self, char *name, PyObject * v );
-static Button *newbutton (void);
+static Button *newbutton( void );
/* GUI interface routines */
-static void exit_pydraw (SpaceScript *sc, short error);
-static void exec_callback (SpaceScript *sc, PyObject *callback,
- PyObject *args);
-static void spacescript_do_pywin_buttons (SpaceScript *sc,
- unsigned short event);
-
-static PyObject *Method_Exit (PyObject * self, PyObject * args);
-static PyObject *Method_Register (PyObject * self, PyObject * args);
-static PyObject *Method_Redraw (PyObject * self, PyObject * args);
-static PyObject *Method_Draw (PyObject * self, PyObject * args);
-static PyObject *Method_Create (PyObject * self, PyObject * args);
-
-static PyObject *Method_Button (PyObject * self, PyObject * args);
-static PyObject *Method_Menu (PyObject * self, PyObject * args);
-static PyObject *Method_Toggle (PyObject * self, PyObject * args);
-static PyObject *Method_Slider (PyObject * self, PyObject * args);
-static PyObject *Method_Scrollbar (PyObject * self, PyObject * args);
-static PyObject *Method_Number (PyObject * self, PyObject * args);
-static PyObject *Method_String (PyObject * self, PyObject * args);
-static PyObject *Method_GetStringWidth (PyObject * self, PyObject * args);
-static PyObject *Method_Text (PyObject * self, PyObject * args);
-static PyObject *Method_PupMenu (PyObject * self, PyObject * args);
+static void exit_pydraw( SpaceScript * sc, short error );
+static void exec_callback( SpaceScript * sc, PyObject * callback,
+ PyObject * args );
+static void spacescript_do_pywin_buttons( SpaceScript * sc,
+ unsigned short event );
+
+static PyObject *Method_Exit( PyObject * self, PyObject * args );
+static PyObject *Method_Register( PyObject * self, PyObject * args );
+static PyObject *Method_Redraw( PyObject * self, PyObject * args );
+static PyObject *Method_Draw( PyObject * self, PyObject * args );
+static PyObject *Method_Create( PyObject * self, PyObject * args );
+
+static PyObject *Method_Button( PyObject * self, PyObject * args );
+static PyObject *Method_Menu( PyObject * self, PyObject * args );
+static PyObject *Method_Toggle( PyObject * self, PyObject * args );
+static PyObject *Method_Slider( PyObject * self, PyObject * args );
+static PyObject *Method_Scrollbar( PyObject * self, PyObject * args );
+static PyObject *Method_Number( PyObject * self, PyObject * args );
+static PyObject *Method_String( PyObject * self, PyObject * args );
+static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args );
+static PyObject *Method_Text( PyObject * self, PyObject * args );
+static PyObject *Method_PupMenu( PyObject * self, PyObject * args );
/* next three by Campbell: */
-static PyObject *Method_PupIntInput (PyObject * self, PyObject * args);
-static PyObject *Method_PupFloatInput (PyObject * self, PyObject * args);
-static PyObject *Method_PupStrInput (PyObject * self, PyObject * args);
+static PyObject *Method_PupIntInput( PyObject * self, PyObject * args );
+static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args );
+static PyObject *Method_PupStrInput( PyObject * self, PyObject * args );
-static uiBlock *Get_uiBlock (void);
-static void py_slider_update (void *butv, void *data2_unused);
+static uiBlock *Get_uiBlock( void );
+static void py_slider_update( void *butv, void *data2_unused );
static char Draw_doc[] = "The Blender.Draw submodule";
static char Method_Register_doc[] =
-"(draw, event, button) - Register callbacks for windowing\n\n\
+ "(draw, event, button) - Register callbacks for windowing\n\n\
(draw) A function to draw the screen, taking no arguments\n\
(event) A function to handle events, taking 2 arguments (evt, val)\n\
(evt) The event number\n\
@@ -141,12 +141,12 @@ exactly once for everytime this function is called.";
static char Method_Create_doc[] =
-"(value) - Create a default Button object\n\n\
+ "(value) - Create a default Button object\n\n\
(value) - The value to store in the button\n\n\
Valid values are ints, floats, and strings";
static char Method_Button_doc[] =
-"(name, event, x, y, width, height, [tooltip]) - Create a new Button \
+ "(name, event, x, y, width, height, [tooltip]) - Create a new Button \
(push) button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -156,7 +156,7 @@ static char Method_Button_doc[] =
This function can be called as Button() or PushButton().";
static char Method_Menu_doc[] =
-"(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \
+ "(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \
button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -172,7 +172,7 @@ Valid format codes are\n\
%xN - The option should set the integer N in the button value.";
static char Method_Toggle_doc[] =
-"(name, event, x, y, width, height, default, [tooltip]) - Create a new Toggle \
+ "(name, event, x, y, width, height, default, [tooltip]) - Create a new Toggle \
button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -183,7 +183,7 @@ button\n\n\
static char Method_Slider_doc[] =
-"(name, event, x, y, width, height, initial, min, max, [update, tooltip]) - \
+ "(name, event, x, y, width, height, initial, min, max, [update, tooltip]) - \
Create a new Slider button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -198,7 +198,7 @@ is edited.\n\
static char Method_Scrollbar_doc[] =
-"(event, x, y, width, height, initial, min, max, [update, tooltip]) - Create a \
+ "(event, x, y, width, height, initial, min, max, [update, tooltip]) - Create a \
new Scrollbar\n\n\
(event) The event number to pass to the button event function when activated\n\
(x, y) The lower left coordinate of the button\n\
@@ -209,7 +209,7 @@ new Scrollbar\n\n\
[tooltip=] The button's tooltip";
static char Method_Number_doc[] =
-"(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \
+ "(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \
new Number button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -220,7 +220,7 @@ limit values.\n\
[tooltip=] The button's tooltip";
static char Method_String_doc[] =
-"(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \
+ "(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \
new String button\n\n\
(name) A string to display on the button\n\
(event) The event number to pass to the button event function when activated\n\
@@ -231,17 +231,17 @@ new String button\n\n\
[tooltip=] The button's tooltip";
static char Method_GetStringWidth_doc[] =
-"(text, font = 'normal') - Return the width in pixels of the given string\n\
+ "(text, font = 'normal') - Return the width in pixels of the given string\n\
(font) The font size: 'normal' (default), 'small' or 'tiny'.";
static char Method_Text_doc[] =
-"(text, font = 'normal') - Draw text onscreen\n\n\
+ "(text, font = 'normal') - Draw text onscreen\n\n\
(text) The text to draw\n\
(font) The font size: 'normal' (default), 'small' or 'tiny'.\n\n\
This function returns the width of the drawn string.";
static char Method_PupMenu_doc[] =
-"(string, maxrow = None) - Display a pop-up menu at the screen.\n\
+ "(string, maxrow = None) - Display a pop-up menu at the screen.\n\
The contents of the pop-up are specified through the 'string' argument,\n\
like with Draw.Menu.\n\
'maxrow' is an optional int to control how many rows the pop-up should have.\n\
@@ -253,13 +253,13 @@ Valid format codes are\n\
Ex: Draw.PupMenu('OK?%t|QUIT BLENDER') # should be familiar ...";
static char Method_PupIntInput_doc[] =
-"(text, default, min, max) - Display an int pop-up input.\n\
+ "(text, default, min, max) - Display an int pop-up input.\n\
(text) - text string to display on the button;\n\
(default, min, max) - the default, min and max int values for the button;\n\
Return the user input value or None on user exit";
static char Method_PupFloatInput_doc[] =
-"(text, default, min, max, clickStep, floatLen) - Display a float pop-up input.\n\
+ "(text, default, min, max, clickStep, floatLen) - Display a float pop-up input.\n\
(text) - text string to display on the button;\n\
(default, min, max) - the default, min and max float values for the button;\n\
(clickStep) - float increment/decrement for each click on the button arrows;\n\
@@ -268,7 +268,7 @@ the float value show.\n\
Return the user input value or None on user exit";
static char Method_PupStrInput_doc[] =
-"(text, default, max = 20) - Display a float pop-up input.\n\
+ "(text, default, max = 20) - Display a float pop-up input.\n\
(text) - text string to display on the button;\n\
(default) - the initial string to display (truncated to 'max' chars);\n\
(max = 20) - The maximum number of chars the user can input;\n\
@@ -290,163 +290,170 @@ static char Method_Exit_doc[] = "() - Exit the windowing interface";
#define MethodDef(func) _MethodDef(func, Method)
static struct PyMethodDef Draw_methods[] = {
- MethodDef (Create),
- MethodDef (Button),
- MethodDef (Toggle),
- MethodDef (Menu),
- MethodDef (Slider),
- MethodDef (Scrollbar),
- MethodDef (Number),
- MethodDef (String),
- MethodDef (GetStringWidth),
- MethodDef (Text),
- MethodDef (PupMenu),
- MethodDef (PupIntInput),
- MethodDef (PupFloatInput),
- MethodDef (PupStrInput),
- MethodDef (Exit),
- MethodDef (Redraw),
- MethodDef (Draw),
- MethodDef (Register),
- {"PushButton", Method_Button, METH_VARARGS, Method_Button_doc},
- {NULL, NULL,0,NULL}
+ MethodDef( Create ),
+ MethodDef( Button ),
+ MethodDef( Toggle ),
+ MethodDef( Menu ),
+ MethodDef( Slider ),
+ MethodDef( Scrollbar ),
+ MethodDef( Number ),
+ MethodDef( String ),
+ MethodDef( GetStringWidth ),
+ MethodDef( Text ),
+ MethodDef( PupMenu ),
+ MethodDef( PupIntInput ),
+ MethodDef( PupFloatInput ),
+ MethodDef( PupStrInput ),
+ MethodDef( Exit ),
+ MethodDef( Redraw ),
+ MethodDef( Draw ),
+ MethodDef( Register ),
+ {"PushButton", Method_Button, METH_VARARGS, Method_Button_doc},
+ {NULL, NULL, 0, NULL}
};
PyTypeObject Button_Type = {
- PyObject_HEAD_INIT (NULL) 0, /*ob_size */
- "Button", /*tp_name */
- sizeof (Button), /*tp_basicsize */
- 0, /*tp_itemsize */
- (destructor) Button_dealloc, /*tp_dealloc */
- (printfunc) 0, /*tp_print */
- (getattrfunc) Button_getattr, /*tp_getattr */
- (setattrfunc) Button_setattr, /*tp_setattr */
- (cmpfunc) 0, /*tp_cmp */
- (reprfunc) Button_repr, /*tp_repr */
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Button", /*tp_name */
+ sizeof( Button ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Button_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Button_getattr, /*tp_getattr */
+ ( setattrfunc ) Button_setattr, /*tp_setattr */
+ ( cmpfunc ) 0, /*tp_cmp */
+ ( reprfunc ) Button_repr, /*tp_repr */
};
-static void Button_dealloc (PyObject *self)
+static void Button_dealloc( PyObject * self )
{
- Button *but = (Button *) self;
+ Button *but = ( Button * ) self;
- if (but->type == 3) {
- if (but->val.asstr) MEM_freeN (but->val.asstr);
+ if( but->type == 3 ) {
+ if( but->val.asstr )
+ MEM_freeN( but->val.asstr );
}
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Button_getattr (PyObject *self, char *name)
+static PyObject *Button_getattr( PyObject * self, char *name )
{
- Button *but = (Button *) self;
-
- if (strcmp (name, "val") == 0) {
- if (but->type == 1)
- return Py_BuildValue ("i", but->val.asint);
- else if (but->type == 2)
- return Py_BuildValue ("f", but->val.asfloat);
- else if (but->type == 3)
- return Py_BuildValue ("s", but->val.asstr);
+ Button *but = ( Button * ) self;
+
+ if( strcmp( name, "val" ) == 0 ) {
+ if( but->type == 1 )
+ return Py_BuildValue( "i", but->val.asint );
+ else if( but->type == 2 )
+ return Py_BuildValue( "f", but->val.asfloat );
+ else if( but->type == 3 )
+ return Py_BuildValue( "s", but->val.asstr );
}
- PyErr_SetString (PyExc_AttributeError, name);
+ PyErr_SetString( PyExc_AttributeError, name );
return NULL;
}
-static int Button_setattr (PyObject *self, char *name, PyObject *v)
+static int Button_setattr( PyObject * self, char *name, PyObject * v )
{
- Button *but = (Button *) self;
-
- if (strcmp (name, "val") == 0) {
- if (but->type == 1)
- PyArg_Parse (v, "i", &but->val.asint);
- else if (but->type == 2)
- PyArg_Parse (v, "f", &but->val.asfloat);
- else if (but->type == 3) {
+ Button *but = ( Button * ) self;
+
+ if( strcmp( name, "val" ) == 0 ) {
+ if( but->type == 1 )
+ PyArg_Parse( v, "i", &but->val.asint );
+ else if( but->type == 2 )
+ PyArg_Parse( v, "f", &but->val.asfloat );
+ else if( but->type == 3 ) {
char *newstr;
- PyArg_Parse (v, "s", &newstr);
+ PyArg_Parse( v, "s", &newstr );
/* if the length of the new string is the same as */
/* the old one, just copy, else delete and realloc. */
- if (but->slen == strlen (newstr)) {
- BLI_strncpy (but->val.asstr, newstr, but->slen + 1);
- }
- else {
- MEM_freeN (but->val.asstr);
- but->slen = strlen (newstr);
- but->val.asstr = MEM_mallocN (but->slen + 1, "button setattr");
- BLI_strncpy (but->val.asstr, newstr, but->slen + 1);
+ if( but->slen == strlen( newstr ) ) {
+ BLI_strncpy( but->val.asstr, newstr,
+ but->slen + 1 );
+ } else {
+ MEM_freeN( but->val.asstr );
+ but->slen = strlen( newstr );
+ but->val.asstr =
+ MEM_mallocN( but->slen + 1,
+ "button setattr" );
+ BLI_strncpy( but->val.asstr, newstr,
+ but->slen + 1 );
}
}
- }
- else {
- PyErr_SetString (PyExc_AttributeError, name);
+ } else {
+ PyErr_SetString( PyExc_AttributeError, name );
return -1;
}
return 0;
}
-static PyObject *Button_repr (PyObject * self)
+static PyObject *Button_repr( PyObject * self )
{
- return PyObject_Repr (Button_getattr (self, "val"));
+ return PyObject_Repr( Button_getattr( self, "val" ) );
}
-static Button *newbutton (void)
+static Button *newbutton( void )
{
- Button *but = (Button *) PyObject_NEW (Button, &Button_Type);
+ Button *but = ( Button * ) PyObject_NEW( Button, &Button_Type );
return but;
}
/* GUI interface routines */
-static void exit_pydraw (SpaceScript *sc, short err)
+static void exit_pydraw( SpaceScript * sc, short err )
{
Script *script = NULL;
- if (!sc || !sc->script) return;
+ if( !sc || !sc->script )
+ return;
script = sc->script;
- if (err) {
- PyErr_Print ();
+ if( err ) {
+ PyErr_Print( );
script->flags = 0; /* mark script struct for deletion */
- error ("Python script error: check console");
- scrarea_queue_redraw (sc->area);
+ error( "Python script error: check console" );
+ scrarea_queue_redraw( sc->area );
}
- Py_XDECREF ((PyObject *) script->py_draw);
- Py_XDECREF ((PyObject *) script->py_event);
- Py_XDECREF ((PyObject *) script->py_button);
+ Py_XDECREF( ( PyObject * ) script->py_draw );
+ Py_XDECREF( ( PyObject * ) script->py_event );
+ Py_XDECREF( ( PyObject * ) script->py_button );
script->py_draw = script->py_event = script->py_button = NULL;
}
-static void exec_callback (SpaceScript *sc, PyObject *callback, PyObject *args)
+static void exec_callback( SpaceScript * sc, PyObject * callback,
+ PyObject * args )
{
- PyObject *result = PyObject_CallObject (callback, args);
+ PyObject *result = PyObject_CallObject( callback, args );
- if (result == NULL && sc->script) {/* errors in the script */
+ if( result == NULL && sc->script ) { /* errors in the script */
- if (sc->script->lastspace == SPACE_TEXT) {/*if it can be an ALT+P script */
+ if( sc->script->lastspace == SPACE_TEXT ) { /*if it can be an ALT+P script */
Text *text = G.main->text.first;
- while (text) {/* find it and free its compiled code */
+ while( text ) { /* find it and free its compiled code */
- if (!strcmp (text->id.name + 2, sc->script->id.name + 2)) {
- BPY_free_compiled_text (text);
+ if( !strcmp
+ ( text->id.name + 2,
+ sc->script->id.name + 2 ) ) {
+ BPY_free_compiled_text( text );
break;
}
text = text->id.next;
}
}
- exit_pydraw (sc, 1);
+ exit_pydraw( sc, 1 );
}
- Py_XDECREF (result);
- Py_DECREF (args);
+ Py_XDECREF( result );
+ Py_DECREF( args );
}
/* BPY_spacescript_do_pywin_draw, the static spacescript_do_pywin_buttons and
@@ -455,39 +462,40 @@ static void exec_callback (SpaceScript *sc, PyObject *callback, PyObject *args)
* (see Method_Register below). They are called (only the two BPY_ ones)
* from blender/src/drawscript.c */
-void BPY_spacescript_do_pywin_draw (SpaceScript *sc)
+void BPY_spacescript_do_pywin_draw( SpaceScript * sc )
{
uiBlock *block;
char butblock[20];
Script *script = sc->script;
- sprintf (butblock, "win %d", curarea->win);
- block = uiNewBlock (&curarea->uiblocks, butblock, UI_EMBOSSX,
- UI_HELV, curarea->win);
-
- if (script->py_draw) {
- glPushAttrib (GL_ALL_ATTRIB_BITS);
- exec_callback (sc, script->py_draw, Py_BuildValue ("()"));
- glPopAttrib ();
- }
- else {
- glClearColor (0.4375, 0.4375, 0.4375, 0.0);
- glClear (GL_COLOR_BUFFER_BIT);
+ sprintf( butblock, "win %d", curarea->win );
+ block = uiNewBlock( &curarea->uiblocks, butblock, UI_EMBOSSX,
+ UI_HELV, curarea->win );
+
+ if( script->py_draw ) {
+ glPushAttrib( GL_ALL_ATTRIB_BITS );
+ exec_callback( sc, script->py_draw, Py_BuildValue( "()" ) );
+ glPopAttrib( );
+ } else {
+ glClearColor( 0.4375, 0.4375, 0.4375, 0.0 );
+ glClear( GL_COLOR_BUFFER_BIT );
}
- uiDrawBlock (block);
+ uiDrawBlock( block );
curarea->win_swap = WIN_BACK_OK;
}
-static void spacescript_do_pywin_buttons (SpaceScript *sc, unsigned short event)
+static void spacescript_do_pywin_buttons( SpaceScript * sc,
+ unsigned short event )
{
- if (sc->script->py_button)
- exec_callback (sc, sc->script->py_button, Py_BuildValue ("(i)", event));
+ if( sc->script->py_button )
+ exec_callback( sc, sc->script->py_button,
+ Py_BuildValue( "(i)", event ) );
}
-void BPY_spacescript_do_pywin_event (SpaceScript *sc, unsigned short event,
- short val)
+void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event,
+ short val )
{
static int menu_hack = 0;
@@ -498,63 +506,65 @@ void BPY_spacescript_do_pywin_event (SpaceScript *sc, unsigned short event,
* What we do is set menu_hack to 1 if a button event occurs.
* Then if the next one is also a button event, w/ val = 4, we discard it. */
- if (event != UI_BUT_EVENT || !val) menu_hack = 0;
+ if( event != UI_BUT_EVENT || !val )
+ menu_hack = 0;
- if (event == QKEY && G.qual & (LR_ALTKEY | LR_CTRLKEY)) {
+ if( event == QKEY && G.qual & ( LR_ALTKEY | LR_CTRLKEY ) ) {
/* finish script: user pressed ALT+Q or CONTROL+Q */
Script *script = sc->script;
- exit_pydraw (sc, 0);
+ exit_pydraw( sc, 0 );
script->flags &= ~SCRIPT_GUI; /* we're done with this script */
return;
}
- if (val) {
- if (uiDoBlocks (&curarea->uiblocks, event) != UI_NOTHING) event = 0;
+ if( val ) {
+ if( uiDoBlocks( &curarea->uiblocks, event ) != UI_NOTHING )
+ event = 0;
- if (event == UI_BUT_EVENT) {
+ if( event == UI_BUT_EVENT ) {
- if (menu_hack && (val == 4)) { /* "false" event? */
- menu_hack = 0; /* if so, discard it and clear menu_hack */
- }
- else {
+ if( menu_hack && ( val == 4 ) ) { /* "false" event? */
+ menu_hack = 0; /* if so, discard it and clear menu_hack */
+ } else {
menu_hack = 1;
- spacescript_do_pywin_buttons (sc, val);
+ spacescript_do_pywin_buttons( sc, val );
}
}
}
- if (sc->script->py_event)
- exec_callback (sc, sc->script->py_event, Py_BuildValue("(ii)", event, val));
+ if( sc->script->py_event )
+ exec_callback( sc, sc->script->py_event,
+ Py_BuildValue( "(ii)", event, val ) );
}
-static PyObject *Method_Exit (PyObject *self, PyObject *args)
+static PyObject *Method_Exit( PyObject * self, PyObject * args )
{
SpaceScript *sc;
Script *script;
/* if users call Draw.Exit when we are already out of the SPACE_SCRIPT, we
* simply return, for compatibility */
- if (curarea->spacetype == SPACE_SCRIPT)
+ if( curarea->spacetype == SPACE_SCRIPT )
sc = curarea->spacedata.first;
else
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
- if (!PyArg_ParseTuple (args, ""))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected empty argument list");
+ if( !PyArg_ParseTuple( args, "" ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected empty argument list" );
- exit_pydraw (sc, 0);
+ exit_pydraw( sc, 0 );
script = sc->script;
/* remove our lock to the current namespace */
script->flags &= ~SCRIPT_GUI;
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/* Method_Register (Draw.Register) registers callbacks for drawing, events
@@ -562,32 +572,33 @@ static PyObject *Method_Exit (PyObject *self, PyObject *args)
* interpreter reached its end and returned control to Blender. Everytime
* the SPACE_SCRIPT window with this script is redrawn, the registered
* callbacks are executed. */
-static PyObject *Method_Register (PyObject *self, PyObject *args)
+static PyObject *Method_Register( PyObject * self, PyObject * args )
{
PyObject *newdrawc = NULL, *neweventc = NULL, *newbuttonc = NULL;
SpaceScript *sc;
Script *script;
int startspace = 0;
- if (!PyArg_ParseTuple (args, "O|OO", &newdrawc, &neweventc, &newbuttonc))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected one or three PyObjects");
+ if( !PyArg_ParseTuple
+ ( args, "O|OO", &newdrawc, &neweventc, &newbuttonc ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or three PyObjects" );
- if (!PyCallable_Check (newdrawc))
+ if( !PyCallable_Check( newdrawc ) )
newdrawc = NULL;
- if (!PyCallable_Check (neweventc))
+ if( !PyCallable_Check( neweventc ) )
neweventc = NULL;
- if (!PyCallable_Check (newbuttonc))
+ if( !PyCallable_Check( newbuttonc ) )
newbuttonc = NULL;
- if (!(newdrawc || neweventc || newbuttonc))
- return EXPP_incr_ret (Py_None);
+ if( !( newdrawc || neweventc || newbuttonc ) )
+ return EXPP_incr_ret( Py_None );
startspace = curarea->spacetype;
/* first make sure the current area is of type SPACE_SCRIPT */
- if (startspace != SPACE_SCRIPT)
- newspace (curarea, SPACE_SCRIPT);
+ if( startspace != SPACE_SCRIPT )
+ newspace( curarea, SPACE_SCRIPT );
sc = curarea->spacedata.first;
@@ -603,13 +614,13 @@ static PyObject *Method_Register (PyObject *self, PyObject *args)
* created one: */
script = G.main->script.last;
- if (!script) {
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Draw.Register: couldn't get pointer to script struct");
+ if( !script ) {
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Draw.Register: couldn't get pointer to script struct" );
}
/* if the flag SCRIPT_RUNNING is set, this script is case a): */
- if (!(script->flags & SCRIPT_RUNNING)) {
+ if( !( script->flags & SCRIPT_RUNNING ) ) {
script = sc->script;
}
/* otherwise it's case b) and the script we want is here: */
@@ -621,123 +632,122 @@ static PyObject *Method_Register (PyObject *self, PyObject *args)
script->flags |= SCRIPT_GUI;
/* save the last space so we can go back to it upon finishing */
- if (!script->lastspace)
+ if( !script->lastspace )
script->lastspace = startspace;
/* clean the old callbacks */
- exit_pydraw (sc, 0);
+ exit_pydraw( sc, 0 );
/* prepare the new ones and insert them */
- Py_XINCREF (newdrawc);
- Py_XINCREF (neweventc);
- Py_XINCREF (newbuttonc);
+ Py_XINCREF( newdrawc );
+ Py_XINCREF( neweventc );
+ Py_XINCREF( newbuttonc );
script->py_draw = newdrawc;
script->py_event = neweventc;
script->py_button = newbuttonc;
- scrarea_queue_redraw (sc->area);
+ scrarea_queue_redraw( sc->area );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Method_Redraw (PyObject *self, PyObject *args)
+static PyObject *Method_Redraw( PyObject * self, PyObject * args )
{
int after = 0;
- if (!PyArg_ParseTuple (args, "|i", &after))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|i", &after ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument (or nothing)" );
/* XXX shouldn't we redraw all spacescript wins with this script on ? */
- if (after)
- addafterqueue (curarea->win, REDRAW, 1);
+ if( after )
+ addafterqueue( curarea->win, REDRAW, 1 );
else
- scrarea_queue_winredraw (curarea);
+ scrarea_queue_winredraw( curarea );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Method_Draw (PyObject * self, PyObject * args)
+static PyObject *Method_Draw( PyObject * self, PyObject * args )
{
/*@ If forced drawing is disable queue a redraw event instead */
- if (EXPP_disable_force_draw) {
- scrarea_queue_winredraw (curarea);
- return EXPP_incr_ret (Py_None);
+ if( EXPP_disable_force_draw ) {
+ scrarea_queue_winredraw( curarea );
+ return EXPP_incr_ret( Py_None );
}
- if (!PyArg_ParseTuple (args, ""))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected empty argument list");
+ if( !PyArg_ParseTuple( args, "" ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected empty argument list" );
- scrarea_do_windraw (curarea);
+ scrarea_do_windraw( curarea );
- screen_swapbuffers ();
+ screen_swapbuffers( );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Method_Create (PyObject *self, PyObject *args)
+static PyObject *Method_Create( PyObject * self, PyObject * args )
{
Button *but;
PyObject *in;
- if (!PyArg_ParseTuple (args, "O", &in))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected PyObject argument");
+ if( !PyArg_ParseTuple( args, "O", &in ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected PyObject argument" );
- but = newbutton ();
- if (PyFloat_Check (in)) {
+ but = newbutton( );
+ if( PyFloat_Check( in ) ) {
but->type = 2;
- but->val.asfloat = PyFloat_AsDouble (in);
- }
- else if (PyInt_Check (in)) {
+ but->val.asfloat = PyFloat_AsDouble( in );
+ } else if( PyInt_Check( in ) ) {
but->type = 1;
- but->val.asint = PyInt_AsLong (in);
- }
- else if (PyString_Check (in)) {
- char *newstr = PyString_AsString (in);
+ but->val.asint = PyInt_AsLong( in );
+ } else if( PyString_Check( in ) ) {
+ char *newstr = PyString_AsString( in );
but->type = 3;
- but->slen = strlen (newstr);
- but->val.asstr = MEM_mallocN (but->slen + 1, "button string");
+ but->slen = strlen( newstr );
+ but->val.asstr = MEM_mallocN( but->slen + 1, "button string" );
- strcpy (but->val.asstr, newstr);
+ strcpy( but->val.asstr, newstr );
}
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static uiBlock *Get_uiBlock (void)
+static uiBlock *Get_uiBlock( void )
{
char butblock[32];
- sprintf (butblock, "win %d", curarea->win);
+ sprintf( butblock, "win %d", curarea->win );
- return uiGetBlock (butblock, curarea);
+ return uiGetBlock( butblock, curarea );
}
-static PyObject *Method_Button (PyObject *self, PyObject *args)
+static PyObject *Method_Button( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL;
int event;
int x, y, w, h;
- if (!PyArg_ParseTuple (args, "siiiii|s", &name, &event,
- &x, &y, &w, &h, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, five ints and optionally another string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiii|s", &name, &event,
+ &x, &y, &w, &h, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, five ints and optionally another string as arguments" );
- block = Get_uiBlock ();
+ block = Get_uiBlock( );
- if (block)
- uiDefBut (block, BUT, event, name, x, y, w, h, 0, 0, 0, 0, 0, tip);
+ if( block )
+ uiDefBut( block, BUT, event, name, x, y, w, h, 0, 0, 0, 0, 0,
+ tip );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Method_Menu (PyObject *self, PyObject *args)
+static PyObject *Method_Menu( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL;
@@ -745,24 +755,24 @@ static PyObject *Method_Menu (PyObject *self, PyObject *args)
int x, y, w, h;
Button *but;
- if (!PyArg_ParseTuple (args, "siiiiii|s", &name, &event,
- &x, &y, &w, &h, &def, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, six ints and optionally another string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiiii|s", &name, &event,
+ &x, &y, &w, &h, &def, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, six ints and optionally another string as arguments" );
- but = newbutton ();
+ but = newbutton( );
but->type = 1;
but->val.asint = def;
- block = Get_uiBlock ();
- if (block)
- uiDefButI (block, MENU, event, name, x, y, w, h,
- &but->val.asint, 0, 0, 0, 0, tip);
+ block = Get_uiBlock( );
+ if( block )
+ uiDefButI( block, MENU, event, name, x, y, w, h,
+ &but->val.asint, 0, 0, 0, 0, tip );
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static PyObject *Method_Toggle (PyObject *self, PyObject *args)
+static PyObject *Method_Toggle( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL;
@@ -770,21 +780,21 @@ static PyObject *Method_Toggle (PyObject *self, PyObject *args)
int x, y, w, h, def;
Button *but;
- if (!PyArg_ParseTuple (args, "siiiiii|s", &name, &event,
- &x, &y, &w, &h, &def, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, six ints and optionally another string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiiii|s", &name, &event,
+ &x, &y, &w, &h, &def, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, six ints and optionally another string as arguments" );
- but = newbutton ();
+ but = newbutton( );
but->type = 1;
but->val.asint = def;
- block = Get_uiBlock ();
- if (block)
- uiDefButI (block, TOG, event, name, x, y, w, h,
- &but->val.asint, 0, 0, 0, 0, tip);
+ block = Get_uiBlock( );
+ if( block )
+ uiDefButI( block, TOG, event, name, x, y, w, h,
+ &but->val.asint, 0, 0, 0, 0, tip );
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
/*@DO NOT TOUCH THIS FUNCTION !
@@ -794,35 +804,35 @@ static PyObject *Method_Toggle (PyObject *self, PyObject *args)
XXX This is condemned to be dinosource in future - it's a hack.
*/
-static void py_slider_update (void *butv, void *data2_unused)
+static void py_slider_update( void *butv, void *data2_unused )
{
uiBut *but = butv;
EXPP_disable_force_draw = 1;
/*@
- Disable forced drawing, otherwise the button object which
- is still being used might be deleted
+ Disable forced drawing, otherwise the button object which
+ is still being used might be deleted
*/
/*@
- spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */
+ spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */
g_window_redrawn = 0;
curarea->win_swap = WIN_BACK_OK;
/* removed global uiFrontBuf (contact ton when this goes wrong here) */
- spacescript_do_pywin_buttons (curarea->spacedata.first,
- uiButGetRetVal (but));
+ spacescript_do_pywin_buttons( curarea->spacedata.first,
+ uiButGetRetVal( but ) );
- if (!g_window_redrawn) { /*@ if Redraw already called */
- disable_where_script (1);
- M_Window_Redraw (0, Py_BuildValue ("(i)", SPACE_VIEW3D));
- disable_where_script (0);
+ if( !g_window_redrawn ) { /*@ if Redraw already called */
+ disable_where_script( 1 );
+ M_Window_Redraw( 0, Py_BuildValue( "(i)", SPACE_VIEW3D ) );
+ disable_where_script( 0 );
}
EXPP_disable_force_draw = 0;
}
-static PyObject *Method_Slider (PyObject *self, PyObject *args)
+static PyObject *Method_Slider( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL;
@@ -831,56 +841,60 @@ static PyObject *Method_Slider (PyObject *self, PyObject *args)
Button *but;
PyObject *mino, *maxo, *inio;
- if (!PyArg_ParseTuple (args, "siiiiiOOO|is", &name, &event,
- &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, five ints, three PyObjects\n\
- and optionally another int and string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiiiOOO|is", &name, &event,
+ &x, &y, &w, &h, &inio, &mino, &maxo, &realtime,
+ &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, five ints, three PyObjects\n\
+ and optionally another int and string as arguments" );
- but = newbutton ();
+ but = newbutton( );
- if (PyFloat_Check (inio)) {
+ if( PyFloat_Check( inio ) ) {
float ini, min, max;
- ini = PyFloat_AsDouble (inio);
- min = PyFloat_AsDouble (mino);
- max = PyFloat_AsDouble (maxo);
+ ini = PyFloat_AsDouble( inio );
+ min = PyFloat_AsDouble( mino );
+ max = PyFloat_AsDouble( maxo );
but->type = 2;
but->val.asfloat = ini;
- block = Get_uiBlock ();
- if (block) {
+ block = Get_uiBlock( );
+ if( block ) {
uiBut *ubut;
- ubut = uiDefButF (block, NUMSLI, event, name, x, y, w, h,
- &but->val.asfloat, min, max, 0, 0, tip);
- if (realtime)
- uiButSetFunc (ubut, py_slider_update, ubut, NULL);
+ ubut = uiDefButF( block, NUMSLI, event, name, x, y, w,
+ h, &but->val.asfloat, min, max, 0, 0,
+ tip );
+ if( realtime )
+ uiButSetFunc( ubut, py_slider_update, ubut,
+ NULL );
}
- }
- else {
+ } else {
int ini, min, max;
- ini = PyInt_AsLong (inio);
- min = PyInt_AsLong (mino);
- max = PyInt_AsLong (maxo);
+ ini = PyInt_AsLong( inio );
+ min = PyInt_AsLong( mino );
+ max = PyInt_AsLong( maxo );
but->type = 1;
but->val.asint = ini;
- block = Get_uiBlock ();
- if (block) {
+ block = Get_uiBlock( );
+ if( block ) {
uiBut *ubut;
- ubut = uiDefButI (block, NUMSLI, event, name, x, y, w, h,
- &but->val.asint, min, max, 0, 0, tip);
- if (realtime)
- uiButSetFunc (ubut, py_slider_update, ubut, NULL);
+ ubut = uiDefButI( block, NUMSLI, event, name, x, y, w,
+ h, &but->val.asint, min, max, 0, 0,
+ tip );
+ if( realtime )
+ uiButSetFunc( ubut, py_slider_update, ubut,
+ NULL );
}
}
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static PyObject *Method_Scrollbar (PyObject *self, PyObject *args)
+static PyObject *Method_Scrollbar( PyObject * self, PyObject * args )
{
char *tip = NULL;
uiBlock *block;
@@ -890,55 +904,58 @@ static PyObject *Method_Scrollbar (PyObject *self, PyObject *args)
PyObject *mino, *maxo, *inio;
float ini, min, max;
- if (!PyArg_ParseTuple (args, "iiiiiOOO|is", &event, &x, &y, &w, &h,
- &inio, &mino, &maxo, &realtime, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected five ints, three PyObjects and optionally\n\
- another int and string as arguments");
+ if( !PyArg_ParseTuple( args, "iiiiiOOO|is", &event, &x, &y, &w, &h,
+ &inio, &mino, &maxo, &realtime, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected five ints, three PyObjects and optionally\n\
+ another int and string as arguments" );
- if (!PyNumber_Check (inio) || !PyNumber_Check (inio)
- || !PyNumber_Check (inio))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected numbers for initial, min, and max");
+ if( !PyNumber_Check( inio ) || !PyNumber_Check( inio )
+ || !PyNumber_Check( inio ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected numbers for initial, min, and max" );
- but = newbutton ();
+ but = newbutton( );
- if (PyFloat_Check (inio))
+ if( PyFloat_Check( inio ) )
but->type = 2;
else
but->type = 1;
- ini = PyFloat_AsDouble (inio);
- min = PyFloat_AsDouble (mino);
- max = PyFloat_AsDouble (maxo);
+ ini = PyFloat_AsDouble( inio );
+ min = PyFloat_AsDouble( mino );
+ max = PyFloat_AsDouble( maxo );
- if (but->type == 2) {
+ if( but->type == 2 ) {
but->val.asfloat = ini;
- block = Get_uiBlock ();
- if (block) {
+ block = Get_uiBlock( );
+ if( block ) {
uiBut *ubut;
- ubut = uiDefButF (block, SCROLL, event, "", x, y, w, h,
- &but->val.asfloat, min, max, 0, 0, tip);
- if (realtime)
- uiButSetFunc (ubut, py_slider_update, ubut, NULL);
+ ubut = uiDefButF( block, SCROLL, event, "", x, y, w, h,
+ &but->val.asfloat, min, max, 0, 0,
+ tip );
+ if( realtime )
+ uiButSetFunc( ubut, py_slider_update, ubut,
+ NULL );
}
- }
- else {
+ } else {
but->val.asint = ini;
- block = Get_uiBlock ();
- if (block) {
+ block = Get_uiBlock( );
+ if( block ) {
uiBut *ubut;
- ubut = uiDefButI (block, SCROLL, event, "", x, y, w, h,
- &but->val.asint, min, max, 0, 0, tip);
- if (realtime)
- uiButSetFunc (ubut, py_slider_update, ubut, NULL);
+ ubut = uiDefButI( block, SCROLL, event, "", x, y, w, h,
+ &but->val.asint, min, max, 0, 0,
+ tip );
+ if( realtime )
+ uiButSetFunc( ubut, py_slider_update, ubut,
+ NULL );
}
}
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static PyObject *Method_Number (PyObject *self, PyObject *args)
+static PyObject *Method_Number( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL;
@@ -947,49 +964,48 @@ static PyObject *Method_Number (PyObject *self, PyObject *args)
Button *but;
PyObject *mino, *maxo, *inio;
- if (!PyArg_ParseTuple (args, "siiiiiOOO|s", &name, &event,
- &x, &y, &w, &h, &inio, &mino, &maxo, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, five ints, three PyObjects and\n\
- optionally another string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiiiOOO|s", &name, &event,
+ &x, &y, &w, &h, &inio, &mino, &maxo, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, five ints, three PyObjects and\n\
+ optionally another string as arguments" );
- but = newbutton ();
+ but = newbutton( );
- if (PyFloat_Check (inio)) {
+ if( PyFloat_Check( inio ) ) {
float ini, min, max;
- ini = PyFloat_AsDouble (inio);
- min = PyFloat_AsDouble (mino);
- max = PyFloat_AsDouble (maxo);
+ ini = PyFloat_AsDouble( inio );
+ min = PyFloat_AsDouble( mino );
+ max = PyFloat_AsDouble( maxo );
but->type = 2;
but->val.asfloat = ini;
- block = Get_uiBlock ();
- if (block)
- uiDefButF (block, NUM, event, name, x, y, w, h,
- &but->val.asfloat, min, max, 0, 0, tip);
- }
- else {
+ block = Get_uiBlock( );
+ if( block )
+ uiDefButF( block, NUM, event, name, x, y, w, h,
+ &but->val.asfloat, min, max, 0, 0, tip );
+ } else {
int ini, min, max;
- ini = PyInt_AsLong (inio);
- min = PyInt_AsLong (mino);
- max = PyInt_AsLong (maxo);
+ ini = PyInt_AsLong( inio );
+ min = PyInt_AsLong( mino );
+ max = PyInt_AsLong( maxo );
but->type = 1;
but->val.asint = ini;
- block = Get_uiBlock ();
- if (block)
- uiDefButI (block, NUM, event, name, x, y, w, h,
- &but->val.asint, min, max, 0, 0, tip);
+ block = Get_uiBlock( );
+ if( block )
+ uiDefButI( block, NUM, event, name, x, y, w, h,
+ &but->val.asint, min, max, 0, 0, tip );
}
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static PyObject *Method_String (PyObject *self, PyObject *args)
+static PyObject *Method_String( PyObject * self, PyObject * args )
{
uiBlock *block;
char *name, *tip = NULL, *newstr;
@@ -997,187 +1013,197 @@ static PyObject *Method_String (PyObject *self, PyObject *args)
int x, y, w, h, len;
Button *but;
- if (!PyArg_ParseTuple (args, "siiiiisi|s", &name, &event,
- &x, &y, &w, &h, &newstr, &len, &tip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string, five ints, a string, an int and\n\
- optionally another string as arguments");
+ if( !PyArg_ParseTuple( args, "siiiiisi|s", &name, &event,
+ &x, &y, &w, &h, &newstr, &len, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string, five ints, a string, an int and\n\
+ optionally another string as arguments" );
- but = newbutton ();
+ but = newbutton( );
but->type = 3;
but->slen = len;
- but->val.asstr = MEM_mallocN (len + 1, "button string");
+ but->val.asstr = MEM_mallocN( len + 1, "button string" );
- strncpy (but->val.asstr, newstr, len);
+ strncpy( but->val.asstr, newstr, len );
but->val.asstr[len] = '\0';
- block = Get_uiBlock ();
- if (block)
- uiDefBut (block, TEX, event, name, x, y, w, h,
- but->val.asstr, 0, len, 0, 0, tip);
+ block = Get_uiBlock( );
+ if( block )
+ uiDefBut( block, TEX, event, name, x, y, w, h,
+ but->val.asstr, 0, len, 0, 0, tip );
- return (PyObject *) but;
+ return ( PyObject * ) but;
}
-static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args)
+static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args )
{
char *text;
char *font_str = "normal";
struct BMF_Font *font;
PyObject *width;
- if (!PyArg_ParseTuple (args, "s|s", &text, &font_str))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected one or two string arguments");
+ if( !PyArg_ParseTuple( args, "s|s", &text, &font_str ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or two string arguments" );
- if (!strcmp (font_str, "normal"))
- font = (&G)->font;
- else if (!strcmp (font_str, "small"))
- font = (&G)->fonts;
- else if (!strcmp (font_str, "tiny"))
- font = (&G)->fontss;
+ if( !strcmp( font_str, "normal" ) )
+ font = ( &G )->font;
+ else if( !strcmp( font_str, "small" ) )
+ font = ( &G )->fonts;
+ else if( !strcmp( font_str, "tiny" ) )
+ font = ( &G )->fontss;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "\"font\" must be: 'normal' (default), 'small' or 'tiny'.");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "\"font\" must be: 'normal' (default), 'small' or 'tiny'." );
- width = PyInt_FromLong (BMF_GetStringWidth (font, text));
+ width = PyInt_FromLong( BMF_GetStringWidth( font, text ) );
- if (!width)
- return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create PyInt");
+ if( !width )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyInt" );
return width;
}
-static PyObject *Method_Text (PyObject *self, PyObject *args)
+static PyObject *Method_Text( PyObject * self, PyObject * args )
{
char *text;
char *font_str = NULL;
struct BMF_Font *font;
- if (!PyArg_ParseTuple (args, "s|s", &text, &font_str))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected one or two string arguments");
-
- if (!font_str)
- font = (&G)->font;
- else if (!strcmp (font_str, "normal"))
- font = (&G)->font;
- else if (!strcmp (font_str, "small"))
- font = (&G)->fonts;
- else if (!strcmp (font_str, "tiny"))
- font = (&G)->fontss;
+ if( !PyArg_ParseTuple( args, "s|s", &text, &font_str ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or two string arguments" );
+
+ if( !font_str )
+ font = ( &G )->font;
+ else if( !strcmp( font_str, "normal" ) )
+ font = ( &G )->font;
+ else if( !strcmp( font_str, "small" ) )
+ font = ( &G )->fonts;
+ else if( !strcmp( font_str, "tiny" ) )
+ font = ( &G )->fontss;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "\"font\" must be: 'normal' (default), 'small' or 'tiny'.");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "\"font\" must be: 'normal' (default), 'small' or 'tiny'." );
- BMF_DrawString (font, text);
+ BMF_DrawString( font, text );
- return PyInt_FromLong (BMF_GetStringWidth (font, text));
+ return PyInt_FromLong( BMF_GetStringWidth( font, text ) );
}
-static PyObject *Method_PupMenu (PyObject *self, PyObject *args)
+static PyObject *Method_PupMenu( PyObject * self, PyObject * args )
{
char *text;
int maxrow = -1;
PyObject *ret;
- if (!PyArg_ParseTuple (args, "s|i", &text, &maxrow))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string and optionally an int as arguments");
+ if( !PyArg_ParseTuple( args, "s|i", &text, &maxrow ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string and optionally an int as arguments" );
- if (maxrow >= 0)
- ret = PyInt_FromLong (pupmenu_col (text, maxrow));
+ if( maxrow >= 0 )
+ ret = PyInt_FromLong( pupmenu_col( text, maxrow ) );
else
- ret = PyInt_FromLong (pupmenu (text));
+ ret = PyInt_FromLong( pupmenu( text ) );
- if (ret) return ret;
+ if( ret )
+ return ret;
- return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create a PyInt");
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create a PyInt" );
}
-static PyObject *Method_PupIntInput (PyObject *self, PyObject *args)
+static PyObject *Method_PupIntInput( PyObject * self, PyObject * args )
{
char *text = NULL;
int min = 0, max = 1;
short var = 0;
PyObject *ret = NULL;
-
- if (!PyArg_ParseTuple (args, "s|hii", &text, &var, &min, &max))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 1 string and 3 int arguments");
-
- if (button(&var, min, max, text) == 0) {
- Py_INCREF(Py_None);
+
+ if( !PyArg_ParseTuple( args, "s|hii", &text, &var, &min, &max ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 1 string and 3 int arguments" );
+
+ if( button( &var, min, max, text ) == 0 ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- ret = PyInt_FromLong (var);
- if (ret) return ret;
-
- return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create a PyInt");
+ ret = PyInt_FromLong( var );
+ if( ret )
+ return ret;
+
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create a PyInt" );
}
-static PyObject *Method_PupFloatInput (PyObject *self, PyObject *args)
+static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args )
{
char *text = NULL;
float min = 0, max = 1, var = 0, a1 = 10, a2 = 2;
PyObject *ret = NULL;
- if (!PyArg_ParseTuple (args, "s|fffff", &text, &var, &min, &max, &a1, &a2))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 1 string and 5 float arguments");
+ if( !PyArg_ParseTuple
+ ( args, "s|fffff", &text, &var, &min, &max, &a1, &a2 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 1 string and 5 float arguments" );
- if(fbutton(&var, min, max, a1, a2, text)==0) {
- Py_INCREF(Py_None);
+ if( fbutton( &var, min, max, a1, a2, text ) == 0 ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- ret = PyFloat_FromDouble (var);
- if (ret) return ret;
+ ret = PyFloat_FromDouble( var );
+ if( ret )
+ return ret;
- return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create a PyFloat");
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create a PyFloat" );
}
-static PyObject *Method_PupStrInput (PyObject *self, PyObject *args)
+static PyObject *Method_PupStrInput( PyObject * self, PyObject * args )
{
char *text = NULL, *textMsg = NULL;
char tmp[101];
char max = 20;
PyObject *ret = NULL;
- if (!PyArg_ParseTuple (args, "ss|b", &textMsg, &text, &max))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 2 strings and 1 int");
+ if( !PyArg_ParseTuple( args, "ss|b", &textMsg, &text, &max ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 2 strings and 1 int" );
- if ((max <= 0) || (max > 100))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "max string length value must be in the range [1, 100].");
+ if( ( max <= 0 ) || ( max > 100 ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "max string length value must be in the range [1, 100]." );
/* copying the text string handles both cases:
* max < strlen(text) (by truncating) and
* max > strlen(text) (by expanding to strlen(tmp)) */
- BLI_strncpy(tmp, text, max + 1);
+ BLI_strncpy( tmp, text, max + 1 );
- if (sbutton (tmp, 0, max, textMsg) == 0) {
- Py_INCREF (Py_None);
+ if( sbutton( tmp, 0, max, textMsg ) == 0 ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- ret = Py_BuildValue ("s", tmp);
+ ret = Py_BuildValue( "s", tmp );
+
+ if( ret )
+ return ret;
- if (ret) return ret;
-
- return EXPP_ReturnPyObjError(PyExc_MemoryError, "couldn't create a PyString");
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create a PyString" );
}
-PyObject *Draw_Init (void)
+PyObject *Draw_Init( void )
{
PyObject *submodule, *dict;
Button_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Draw", Draw_methods, Draw_doc);
+ submodule = Py_InitModule3( "Blender.Draw", Draw_methods, Draw_doc );
- dict = PyModule_GetDict (submodule);
+ dict = PyModule_GetDict( submodule );
#define EXPP_ADDCONST(x) \
PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
@@ -1187,128 +1213,128 @@ PyObject *Draw_Init (void)
* PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE))
*/
- EXPP_ADDCONST (LEFTMOUSE);
- EXPP_ADDCONST (MIDDLEMOUSE);
- EXPP_ADDCONST (RIGHTMOUSE);
- EXPP_ADDCONST (WHEELUPMOUSE);
- EXPP_ADDCONST (WHEELDOWNMOUSE);
- EXPP_ADDCONST (MOUSEX);
- EXPP_ADDCONST (MOUSEY);
- EXPP_ADDCONST (TIMER0);
- EXPP_ADDCONST (TIMER1);
- EXPP_ADDCONST (TIMER2);
- EXPP_ADDCONST (TIMER3);
- EXPP_ADDCONST (KEYBD);
- EXPP_ADDCONST (RAWKEYBD);
- EXPP_ADDCONST (REDRAW);
- EXPP_ADDCONST (INPUTCHANGE);
- EXPP_ADDCONST (QFULL);
- EXPP_ADDCONST (WINFREEZE);
- EXPP_ADDCONST (WINTHAW);
- EXPP_ADDCONST (WINCLOSE);
- EXPP_ADDCONST (WINQUIT);
+ EXPP_ADDCONST( LEFTMOUSE );
+ EXPP_ADDCONST( MIDDLEMOUSE );
+ EXPP_ADDCONST( RIGHTMOUSE );
+ EXPP_ADDCONST( WHEELUPMOUSE );
+ EXPP_ADDCONST( WHEELDOWNMOUSE );
+ EXPP_ADDCONST( MOUSEX );
+ EXPP_ADDCONST( MOUSEY );
+ EXPP_ADDCONST( TIMER0 );
+ EXPP_ADDCONST( TIMER1 );
+ EXPP_ADDCONST( TIMER2 );
+ EXPP_ADDCONST( TIMER3 );
+ EXPP_ADDCONST( KEYBD );
+ EXPP_ADDCONST( RAWKEYBD );
+ EXPP_ADDCONST( REDRAW );
+ EXPP_ADDCONST( INPUTCHANGE );
+ EXPP_ADDCONST( QFULL );
+ EXPP_ADDCONST( WINFREEZE );
+ EXPP_ADDCONST( WINTHAW );
+ EXPP_ADDCONST( WINCLOSE );
+ EXPP_ADDCONST( WINQUIT );
#ifndef IRISGL
- EXPP_ADDCONST (Q_FIRSTTIME);
+ EXPP_ADDCONST( Q_FIRSTTIME );
#endif
- EXPP_ADDCONST (AKEY);
- EXPP_ADDCONST (BKEY);
- EXPP_ADDCONST (CKEY);
- EXPP_ADDCONST (DKEY);
- EXPP_ADDCONST (EKEY);
- EXPP_ADDCONST (FKEY);
- EXPP_ADDCONST (GKEY);
- EXPP_ADDCONST (HKEY);
- EXPP_ADDCONST (IKEY);
- EXPP_ADDCONST (JKEY);
- EXPP_ADDCONST (KKEY);
- EXPP_ADDCONST (LKEY);
- EXPP_ADDCONST (MKEY);
- EXPP_ADDCONST (NKEY);
- EXPP_ADDCONST (OKEY);
- EXPP_ADDCONST (PKEY);
- EXPP_ADDCONST (QKEY);
- EXPP_ADDCONST (RKEY);
- EXPP_ADDCONST (SKEY);
- EXPP_ADDCONST (TKEY);
- EXPP_ADDCONST (UKEY);
- EXPP_ADDCONST (VKEY);
- EXPP_ADDCONST (WKEY);
- EXPP_ADDCONST (XKEY);
- EXPP_ADDCONST (YKEY);
- EXPP_ADDCONST (ZKEY);
- EXPP_ADDCONST (ZEROKEY);
- EXPP_ADDCONST (ONEKEY);
- EXPP_ADDCONST (TWOKEY);
- EXPP_ADDCONST (THREEKEY);
- EXPP_ADDCONST (FOURKEY);
- EXPP_ADDCONST (FIVEKEY);
- EXPP_ADDCONST (SIXKEY);
- EXPP_ADDCONST (SEVENKEY);
- EXPP_ADDCONST (EIGHTKEY);
- EXPP_ADDCONST (NINEKEY);
- EXPP_ADDCONST (CAPSLOCKKEY);
- EXPP_ADDCONST (LEFTCTRLKEY);
- EXPP_ADDCONST (LEFTALTKEY);
- EXPP_ADDCONST (RIGHTALTKEY);
- EXPP_ADDCONST (RIGHTCTRLKEY);
- EXPP_ADDCONST (RIGHTSHIFTKEY);
- EXPP_ADDCONST (LEFTSHIFTKEY);
- EXPP_ADDCONST (ESCKEY);
- EXPP_ADDCONST (TABKEY);
- EXPP_ADDCONST (RETKEY);
- EXPP_ADDCONST (SPACEKEY);
- EXPP_ADDCONST (LINEFEEDKEY);
- EXPP_ADDCONST (BACKSPACEKEY);
- EXPP_ADDCONST (DELKEY);
- EXPP_ADDCONST (SEMICOLONKEY);
- EXPP_ADDCONST (PERIODKEY);
- EXPP_ADDCONST (COMMAKEY);
- EXPP_ADDCONST (QUOTEKEY);
- EXPP_ADDCONST (ACCENTGRAVEKEY);
- EXPP_ADDCONST (MINUSKEY);
- EXPP_ADDCONST (SLASHKEY);
- EXPP_ADDCONST (BACKSLASHKEY);
- EXPP_ADDCONST (EQUALKEY);
- EXPP_ADDCONST (LEFTBRACKETKEY);
- EXPP_ADDCONST (RIGHTBRACKETKEY);
- EXPP_ADDCONST (LEFTARROWKEY);
- EXPP_ADDCONST (DOWNARROWKEY);
- EXPP_ADDCONST (RIGHTARROWKEY);
- EXPP_ADDCONST (UPARROWKEY);
- EXPP_ADDCONST (PAD2);
- EXPP_ADDCONST (PAD4);
- EXPP_ADDCONST (PAD6);
- EXPP_ADDCONST (PAD8);
- EXPP_ADDCONST (PAD1);
- EXPP_ADDCONST (PAD3);
- EXPP_ADDCONST (PAD5);
- EXPP_ADDCONST (PAD7);
- EXPP_ADDCONST (PAD9);
- EXPP_ADDCONST (PADPERIOD);
- EXPP_ADDCONST (PADSLASHKEY);
- EXPP_ADDCONST (PADASTERKEY);
- EXPP_ADDCONST (PAD0);
- EXPP_ADDCONST (PADMINUS);
- EXPP_ADDCONST (PADENTER);
- EXPP_ADDCONST (PADPLUSKEY);
- EXPP_ADDCONST (F1KEY);
- EXPP_ADDCONST (F2KEY);
- EXPP_ADDCONST (F3KEY);
- EXPP_ADDCONST (F4KEY);
- EXPP_ADDCONST (F5KEY);
- EXPP_ADDCONST (F6KEY);
- EXPP_ADDCONST (F7KEY);
- EXPP_ADDCONST (F8KEY);
- EXPP_ADDCONST (F9KEY);
- EXPP_ADDCONST (F10KEY);
- EXPP_ADDCONST (F11KEY);
- EXPP_ADDCONST (F12KEY);
- EXPP_ADDCONST (PAUSEKEY);
- EXPP_ADDCONST (INSERTKEY);
- EXPP_ADDCONST (HOMEKEY);
- EXPP_ADDCONST (PAGEUPKEY);
- EXPP_ADDCONST (PAGEDOWNKEY);
- EXPP_ADDCONST (ENDKEY);
+ EXPP_ADDCONST( AKEY );
+ EXPP_ADDCONST( BKEY );
+ EXPP_ADDCONST( CKEY );
+ EXPP_ADDCONST( DKEY );
+ EXPP_ADDCONST( EKEY );
+ EXPP_ADDCONST( FKEY );
+ EXPP_ADDCONST( GKEY );
+ EXPP_ADDCONST( HKEY );
+ EXPP_ADDCONST( IKEY );
+ EXPP_ADDCONST( JKEY );
+ EXPP_ADDCONST( KKEY );
+ EXPP_ADDCONST( LKEY );
+ EXPP_ADDCONST( MKEY );
+ EXPP_ADDCONST( NKEY );
+ EXPP_ADDCONST( OKEY );
+ EXPP_ADDCONST( PKEY );
+ EXPP_ADDCONST( QKEY );
+ EXPP_ADDCONST( RKEY );
+ EXPP_ADDCONST( SKEY );
+ EXPP_ADDCONST( TKEY );
+ EXPP_ADDCONST( UKEY );
+ EXPP_ADDCONST( VKEY );
+ EXPP_ADDCONST( WKEY );
+ EXPP_ADDCONST( XKEY );
+ EXPP_ADDCONST( YKEY );
+ EXPP_ADDCONST( ZKEY );
+ EXPP_ADDCONST( ZEROKEY );
+ EXPP_ADDCONST( ONEKEY );
+ EXPP_ADDCONST( TWOKEY );
+ EXPP_ADDCONST( THREEKEY );
+ EXPP_ADDCONST( FOURKEY );
+ EXPP_ADDCONST( FIVEKEY );
+ EXPP_ADDCONST( SIXKEY );
+ EXPP_ADDCONST( SEVENKEY );
+ EXPP_ADDCONST( EIGHTKEY );
+ EXPP_ADDCONST( NINEKEY );
+ EXPP_ADDCONST( CAPSLOCKKEY );
+ EXPP_ADDCONST( LEFTCTRLKEY );
+ EXPP_ADDCONST( LEFTALTKEY );
+ EXPP_ADDCONST( RIGHTALTKEY );
+ EXPP_ADDCONST( RIGHTCTRLKEY );
+ EXPP_ADDCONST( RIGHTSHIFTKEY );
+ EXPP_ADDCONST( LEFTSHIFTKEY );
+ EXPP_ADDCONST( ESCKEY );
+ EXPP_ADDCONST( TABKEY );
+ EXPP_ADDCONST( RETKEY );
+ EXPP_ADDCONST( SPACEKEY );
+ EXPP_ADDCONST( LINEFEEDKEY );
+ EXPP_ADDCONST( BACKSPACEKEY );
+ EXPP_ADDCONST( DELKEY );
+ EXPP_ADDCONST( SEMICOLONKEY );
+ EXPP_ADDCONST( PERIODKEY );
+ EXPP_ADDCONST( COMMAKEY );
+ EXPP_ADDCONST( QUOTEKEY );
+ EXPP_ADDCONST( ACCENTGRAVEKEY );
+ EXPP_ADDCONST( MINUSKEY );
+ EXPP_ADDCONST( SLASHKEY );
+ EXPP_ADDCONST( BACKSLASHKEY );
+ EXPP_ADDCONST( EQUALKEY );
+ EXPP_ADDCONST( LEFTBRACKETKEY );
+ EXPP_ADDCONST( RIGHTBRACKETKEY );
+ EXPP_ADDCONST( LEFTARROWKEY );
+ EXPP_ADDCONST( DOWNARROWKEY );
+ EXPP_ADDCONST( RIGHTARROWKEY );
+ EXPP_ADDCONST( UPARROWKEY );
+ EXPP_ADDCONST( PAD2 );
+ EXPP_ADDCONST( PAD4 );
+ EXPP_ADDCONST( PAD6 );
+ EXPP_ADDCONST( PAD8 );
+ EXPP_ADDCONST( PAD1 );
+ EXPP_ADDCONST( PAD3 );
+ EXPP_ADDCONST( PAD5 );
+ EXPP_ADDCONST( PAD7 );
+ EXPP_ADDCONST( PAD9 );
+ EXPP_ADDCONST( PADPERIOD );
+ EXPP_ADDCONST( PADSLASHKEY );
+ EXPP_ADDCONST( PADASTERKEY );
+ EXPP_ADDCONST( PAD0 );
+ EXPP_ADDCONST( PADMINUS );
+ EXPP_ADDCONST( PADENTER );
+ EXPP_ADDCONST( PADPLUSKEY );
+ EXPP_ADDCONST( F1KEY );
+ EXPP_ADDCONST( F2KEY );
+ EXPP_ADDCONST( F3KEY );
+ EXPP_ADDCONST( F4KEY );
+ EXPP_ADDCONST( F5KEY );
+ EXPP_ADDCONST( F6KEY );
+ EXPP_ADDCONST( F7KEY );
+ EXPP_ADDCONST( F8KEY );
+ EXPP_ADDCONST( F9KEY );
+ EXPP_ADDCONST( F10KEY );
+ EXPP_ADDCONST( F11KEY );
+ EXPP_ADDCONST( F12KEY );
+ EXPP_ADDCONST( PAUSEKEY );
+ EXPP_ADDCONST( INSERTKEY );
+ EXPP_ADDCONST( HOMEKEY );
+ EXPP_ADDCONST( PAGEUPKEY );
+ EXPP_ADDCONST( PAGEDOWNKEY );
+ EXPP_ADDCONST( ENDKEY );
return submodule;
}
diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h
index fbf2fb85c0e..7ec1c886849 100644
--- a/source/blender/python/api2_2x/Draw.h
+++ b/source/blender/python/api2_2x/Draw.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -44,40 +45,36 @@
#include "modules.h"
/* From Window.h, used here by py_slider_update() */
-PyObject *M_Window_Redraw (PyObject * self, PyObject * args);
+PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
-void initDraw (void);
+void initDraw( void );
/*
* Button Object stuct
*/
-typedef struct _Button
-{
- PyObject_VAR_HEAD /* required Py Macro */
- int type; /*@ 1 == int, 2 == float, 3 == string */
- unsigned int slen; /*@ length of string (if type == 3) */
- union
- {
- int asint;
- float asfloat;
- char *asstr;
- }
- val;
- char *tooltip;
-}
-Button;
+typedef struct _Button {
+ PyObject_VAR_HEAD /* required Py Macro */
+ int type; /*@ 1 == int, 2 == float, 3 == string */
+ unsigned int slen; /*@ length of string (if type == 3) */
+ union {
+ int asint;
+ float asfloat;
+ char *asstr;
+ } val;
+ char *tooltip;
+} Button;
/*
* these are declared in ../BPY_extern.h
*/
-void BPY_spacescript_do_pywin_draw (SpaceScript * sc);
-void BPY_spacescript_do_pywin_event (SpaceScript * sc,
- unsigned short event, short val);
-void BPY_free_compiled_text (Text * text);
+void BPY_spacescript_do_pywin_draw( SpaceScript * sc );
+void BPY_spacescript_do_pywin_event( SpaceScript * sc,
+ unsigned short event, short val );
+void BPY_free_compiled_text( Text * text );
-PyObject *M_Draw_Init (void);
+PyObject *M_Draw_Init( void );
-#endif /* EXPP_DRAW_H */
+#endif /* EXPP_DRAW_H */
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
index 69a8fc6090e..6c836ab9eac 100644
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ b/source/blender/python/api2_2x/EXPP_interface.c
@@ -42,8 +42,8 @@
#include "gen_utils.h"
#include "modules.h"
-void initBlenderApi2_2x (void)
+void initBlenderApi2_2x( void )
{
g_blenderdict = NULL;
- M_Blender_Init ();
+ M_Blender_Init( );
}
diff --git a/source/blender/python/api2_2x/EXPP_interface.h b/source/blender/python/api2_2x/EXPP_interface.h
index c50e419aa7c..ba267c5c935 100644
--- a/source/blender/python/api2_2x/EXPP_interface.h
+++ b/source/blender/python/api2_2x/EXPP_interface.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -33,6 +34,6 @@
struct Script;
-void initBlenderApi2_2x (void);
-void discardFromBDict (char *key);
-void EXPP_Library_Close (void); /* in Library.c, used by BPY_end_python */
+void initBlenderApi2_2x( void );
+void discardFromBDict( char *key );
+void EXPP_Library_Close( void ); /* in Library.c, used by BPY_end_python */
diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c
index 30340de1165..388f93db0b9 100644
--- a/source/blender/python/api2_2x/Effect.c
+++ b/source/blender/python/api2_2x/Effect.c
@@ -38,35 +38,34 @@
/* Python BPy_Effect methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Effect_methods[] = {
- {NULL, NULL, 0, NULL}
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Effect_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Effect_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Effect", /* tp_name */
- sizeof (BPy_Effect), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)EffectDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)EffectGetAttr, /* tp_getattr */
- (setattrfunc)EffectSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)EffectRepr, /* 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_Effect_methods, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject Effect_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Effect", /* tp_name */
+ sizeof( BPy_Effect ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) EffectDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) EffectGetAttr, /* tp_getattr */
+ ( setattrfunc ) EffectSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) EffectRepr, /* 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_Effect_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
@@ -77,109 +76,119 @@ PyTypeObject Effect_Type =
struct PyMethodDef M_Effect_methods[] = {
- {"New",(PyCFunction)M_Effect_New, METH_VARARGS,NULL},
- {"Get", M_Effect_Get, METH_VARARGS,NULL},
- {"get", M_Effect_Get, METH_VARARGS, NULL},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Effect_New, METH_VARARGS, NULL},
+ {"Get", M_Effect_Get, METH_VARARGS, NULL},
+ {"get", M_Effect_Get, METH_VARARGS, NULL},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Function: M_Effect_New */
/* Python equivalent: Blender.Effect.New */
/*****************************************************************************/
-PyObject *M_Effect_New(PyObject *self, PyObject *args)
+PyObject *M_Effect_New( PyObject * self, PyObject * args )
{
- BPy_Effect *pyeffect;
- Effect *bleffect = 0;
- int type = -1;
- char * btype = NULL;
- Py_INCREF(Py_None);
- return Py_None;
- if (!PyArg_ParseTuple(args, "s",&btype))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected type argument(wave,build or particle)"));
- if (!strcmp( btype,"wave"))type = EFF_WAVE;
- if (!strcmp( btype,"build"))type = EFF_BUILD;
- if (!strcmp( btype,"particle"))type = EFF_PARTICLE;
- if (type == -1)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "unknown type "));
-
-
- bleffect = add_effect(type);
- if (bleffect == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Effect Data in Blender"));
-
- pyeffect = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
-
-
- if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Effect Data object"));
-
- pyeffect->effect = bleffect;
-
- return (PyObject *)pyeffect;
+ BPy_Effect *pyeffect;
+ Effect *bleffect = 0;
+ int type = -1;
+ char *btype = NULL;
+ Py_INCREF( Py_None );
+ return Py_None;
+ if( !PyArg_ParseTuple( args, "s", &btype ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected type argument(wave,build or particle)" ) );
+ if( !strcmp( btype, "wave" ) )
+ type = EFF_WAVE;
+ if( !strcmp( btype, "build" ) )
+ type = EFF_BUILD;
+ if( !strcmp( btype, "particle" ) )
+ type = EFF_PARTICLE;
+ if( type == -1 )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unknown type " ) );
+
+
+ bleffect = add_effect( type );
+ if( bleffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Effect Data in Blender" ) );
+
+ pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
+
+
+ if( pyeffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Effect Data object" ) );
+
+ pyeffect->effect = bleffect;
+
+ return ( PyObject * ) pyeffect;
}
/*****************************************************************************/
/* Function: M_Effect_Get */
/* Python equivalent: Blender.Effect.Get */
/*****************************************************************************/
-PyObject *M_Effect_Get(PyObject *self, PyObject *args)
+PyObject *M_Effect_Get( PyObject * self, PyObject * args )
{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = 0;
- Object *object_iter;
- Effect *eff;
- BPy_Effect *wanted_eff;
- int num,i;
- if (!PyArg_ParseTuple(args, "|si", &name, &num ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected string int argument"));
- object_iter = G.main->object.first;
- if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "Scene contains no object"));
- if(name){
- while (object_iter)
- {
- if (strcmp(name,object_iter->id.name+2))
- {
- object_iter = object_iter->id.next;
- continue;
- }
-
-
- if (object_iter->effect.first != NULL){
- eff = object_iter->effect.first;
- for(i = 0;i<num;i++)eff = eff->next;
- wanted_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
- wanted_eff->effect = eff;
- return (PyObject*)wanted_eff;
- }
+ /*arguments : string object name
+ int : position of effect in the obj's effect list */
+ char *name = 0;
+ Object *object_iter;
+ Effect *eff;
+ BPy_Effect *wanted_eff;
+ int num, i;
+ if( !PyArg_ParseTuple( args, "|si", &name, &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string int argument" ) );
+ object_iter = G.main->object.first;
+ if( !object_iter )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Scene contains no object" ) );
+ if( name ) {
+ while( object_iter ) {
+ if( strcmp( name, object_iter->id.name + 2 ) ) {
object_iter = object_iter->id.next;
+ continue;
}
- }
- else{
-PyObject * effectlist = PyList_New (0);
- while (object_iter)
- {
- if (object_iter->effect.first != NULL){
- eff = object_iter->effect.first;
- while (eff){
- BPy_Effect *found_eff = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
- found_eff->effect = eff;
- PyList_Append (effectlist , (PyObject *)found_eff);
- eff = eff->next;
- }
+
+
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ for( i = 0; i < num; i++ )
+ eff = eff->next;
+ wanted_eff =
+ ( BPy_Effect * )
+ PyObject_NEW( BPy_Effect,
+ &Effect_Type );
+ wanted_eff->effect = eff;
+ return ( PyObject * ) wanted_eff;
+ }
+ object_iter = object_iter->id.next;
+ }
+ } else {
+ PyObject *effectlist = PyList_New( 0 );
+ while( object_iter ) {
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ while( eff ) {
+ BPy_Effect *found_eff =
+ ( BPy_Effect * )
+ PyObject_NEW( BPy_Effect,
+ &Effect_Type );
+ found_eff->effect = eff;
+ PyList_Append( effectlist,
+ ( PyObject * )
+ found_eff );
+ eff = eff->next;
}
- object_iter = object_iter->id.next;
}
+ object_iter = object_iter->id.next;
+ }
return effectlist;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
@@ -187,66 +196,68 @@ PyObject * effectlist = PyList_New (0);
/*****************************************************************************/
-PyObject *Build_Init (void);
-PyObject *Wave_Init (void);
-PyObject *Particle_Init (void);
+PyObject *Build_Init( void );
+PyObject *Wave_Init( void );
+PyObject *Particle_Init( void );
-PyObject *Effect_Init (void)
+PyObject *Effect_Init( void )
{
- PyObject *submodule, *dict;
+ PyObject *submodule, *dict;
- Effect_Type.ob_type = &PyType_Type;
+ Effect_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Effect",M_Effect_methods, 0 );
- dict = PyModule_GetDict (submodule);
- PyDict_SetItemString (dict, "Wave", Wave_Init());
- PyDict_SetItemString (dict, "Build", Build_Init());
- PyDict_SetItemString (dict, "Particle", Particle_Init());
- return (submodule);
+ submodule = Py_InitModule3( "Blender.Effect", M_Effect_methods, 0 );
+ dict = PyModule_GetDict( submodule );
+ PyDict_SetItemString( dict, "Wave", Wave_Init( ) );
+ PyDict_SetItemString( dict, "Build", Build_Init( ) );
+ PyDict_SetItemString( dict, "Particle", Particle_Init( ) );
+ return ( submodule );
}
/*****************************************************************************/
-/* Python BPy_Effect methods: */
+/* Python BPy_Effect methods: */
/*****************************************************************************/
-PyObject *Effect_getType(BPy_Effect *self)
+PyObject *Effect_getType( BPy_Effect * self )
{
- PyObject *attr = PyInt_FromLong((long)self->effect->type);
- if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,\
- "couldn't get mode attribute"));
+ PyObject *attr = PyInt_FromLong( ( long ) self->effect->type );
+ if( attr )
+ return attr;
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get mode attribute" ) );
}
-PyObject *Effect_setType(BPy_Effect *self, PyObject *args)
+PyObject *Effect_setType( BPy_Effect * self, PyObject * args )
{
- int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,\
- "expected an int as argument"));
- self->effect->type = value;
- Py_INCREF(Py_None);
- return Py_None;
+ int value;
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int as argument" ) );
+ self->effect->type = value;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Effect_getFlag(BPy_Effect *self)
+PyObject *Effect_getFlag( BPy_Effect * self )
{
- PyObject *attr = PyInt_FromLong((long)self->effect->flag);
- if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,\
- "couldn't get mode attribute"));
+ PyObject *attr = PyInt_FromLong( ( long ) self->effect->flag );
+ if( attr )
+ return attr;
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get mode attribute" ) );
}
-PyObject *Effect_setFlag(BPy_Effect *self, PyObject *args)
+PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args )
{
- int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,\
- "expected an int as argument"));
- self->effect->flag = value;
- Py_INCREF(Py_None);
- return Py_None;
+ int value;
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int as argument" ) );
+ self->effect->flag = value;
+ Py_INCREF( Py_None );
+ return Py_None;
}
@@ -255,55 +266,59 @@ PyObject *Effect_setFlag(BPy_Effect *self, PyObject *args)
/*****************************************************************************/
/* Function: EffectDeAlloc */
-/* Description: This is a callback function for the BPy_Effect type. It is */
+/* Description: This is a callback function for the BPy_Effect type. It is */
/* the destructor function. */
/*****************************************************************************/
-void EffectDeAlloc (BPy_Effect *self)
+void EffectDeAlloc( BPy_Effect * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
/* Function: EffectGetAttr */
-/* Description: This is a callback function for the BPy_Effect type. It is */
-/* the function that accesses BPy_Effect "member variables" and */
+/* Description: This is a callback function for the BPy_Effect type. It is */
+/* the function that accesses BPy_Effect "member variables" and */
/* methods. */
/*****************************************************************************/
-PyObject *EffectGetAttr (BPy_Effect *self, char *name)
+PyObject *EffectGetAttr( BPy_Effect * self, char *name )
{
- switch(self->effect->type)
- {
- case EFF_BUILD : return BuildGetAttr( (BPy_Build*)self, name);
- case EFF_WAVE : return WaveGetAttr ((BPy_Wave*)self, name);
- case EFF_PARTICLE : return ParticleGetAttr ((BPy_Particle*)self, name);
- }
+ switch ( self->effect->type ) {
+ case EFF_BUILD:
+ return BuildGetAttr( ( BPy_Build * ) self, name );
+ case EFF_WAVE:
+ return WaveGetAttr( ( BPy_Wave * ) self, name );
+ case EFF_PARTICLE:
+ return ParticleGetAttr( ( BPy_Particle * ) self, name );
+ }
- return Py_FindMethod(BPy_Effect_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Effect_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
/* Function: EffectSetAttr */
-/* Description: This is a callback function for the BPy_Effect type. It is the */
-/* function that sets Effect Data attributes (member variables).*/
+/* Description: This is a callback function for the BPy_Effect type. It */
+/* sets Effect Data attributes (member variables). */
/*****************************************************************************/
-int EffectSetAttr (BPy_Effect *self, char *name, PyObject *value)
+int EffectSetAttr( BPy_Effect * self, char *name, PyObject * value )
{
- switch(self->effect->type)
- {
- case EFF_BUILD : return BuildSetAttr( (BPy_Build*)self, name,value);
- case EFF_WAVE : return WaveSetAttr ((BPy_Wave*)self, name,value);
- case EFF_PARTICLE : return ParticleSetAttr ((BPy_Particle*)self, name,value);
- }
- return 0; /* normal exit */
+ switch ( self->effect->type ) {
+ case EFF_BUILD:
+ return BuildSetAttr( ( BPy_Build * ) self, name, value );
+ case EFF_WAVE:
+ return WaveSetAttr( ( BPy_Wave * ) self, name, value );
+ case EFF_PARTICLE:
+ return ParticleSetAttr( ( BPy_Particle * ) self, name, value );
+ }
+ return 0; /* normal exit */
}
/*****************************************************************************/
/* Function: EffectPrint */
-/* Description: This is a callback function for the BPy_Effect type. It */
+/* Description: This is a callback function for the BPy_Effect type. It */
/* builds a meaninful string to 'print' effcte objects. */
/*****************************************************************************/
/*
@@ -318,45 +333,48 @@ if (self->effect->type == EFF_WAVE)puts("Effect Wave");
*/
/*****************************************************************************/
/* Function: EffectRepr */
-/* Description: This is a callback function for the BPy_Effect type. It */
+/* Description: This is a callback function for the BPy_Effect type. It */
/* builds a meaninful string to represent effcte objects. */
/*****************************************************************************/
-PyObject *EffectRepr (BPy_Effect *self)
+PyObject *EffectRepr( BPy_Effect * self )
{
-char*str="";
-if (self->effect->type == EFF_BUILD)str = "Effect Build";
-if (self->effect->type == EFF_PARTICLE)str = "Effect Particle";
-if (self->effect->type == EFF_WAVE)str = "Effect Wave";
-return PyString_FromString(str);
+ char *str = "";
+ if( self->effect->type == EFF_BUILD )
+ str = "Effect Build";
+ if( self->effect->type == EFF_PARTICLE )
+ str = "Effect Particle";
+ if( self->effect->type == EFF_WAVE )
+ str = "Effect Wave";
+ return PyString_FromString( str );
}
-PyObject* EffectCreatePyObject (struct Effect *effect)
+PyObject *EffectCreatePyObject( struct Effect * effect )
{
- BPy_Effect * blen_object;
+ BPy_Effect *blen_object;
- blen_object = (BPy_Effect*)PyObject_NEW (BPy_Effect, &Effect_Type);
+ blen_object =
+ ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
- if (blen_object == NULL)
- {
- return (NULL);
- }
- blen_object->effect = effect;
- return ((PyObject*)blen_object);
+ if( blen_object == NULL ) {
+ return ( NULL );
+ }
+ blen_object->effect = effect;
+ return ( ( PyObject * ) blen_object );
}
-int EffectCheckPyObject (PyObject *py_obj)
+int EffectCheckPyObject( PyObject * py_obj )
{
-return (py_obj->ob_type == &Effect_Type);
+ return ( py_obj->ob_type == &Effect_Type );
}
-struct Effect* EffectFromPyObject (PyObject *py_obj)
+struct Effect *EffectFromPyObject( PyObject * py_obj )
{
- BPy_Effect * blen_obj;
+ BPy_Effect *blen_obj;
- blen_obj = (BPy_Effect*)py_obj;
- return ((Effect*)blen_obj->effect);
+ blen_obj = ( BPy_Effect * ) py_obj;
+ return ( ( Effect * ) blen_obj->effect );
}
diff --git a/source/blender/python/api2_2x/Effect.h b/source/blender/python/api2_2x/Effect.h
index 8b0562db2a4..9546acdbfd3 100644
--- a/source/blender/python/api2_2x/Effect.h
+++ b/source/blender/python/api2_2x/Effect.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -49,8 +50,8 @@
/*****************************************************************************/
/* Python API function prototypes for the Effect module. */
/*****************************************************************************/
-PyObject *M_Effect_New (PyObject *self, PyObject *args);
-PyObject *M_Effect_Get (PyObject *self, PyObject *args);
+PyObject *M_Effect_New( PyObject * self, PyObject * args );
+PyObject *M_Effect_Get( PyObject * self, PyObject * args );
@@ -63,13 +64,13 @@ PyObject *M_Effect_Get (PyObject *self, PyObject *args);
/*****************************************************************************/
/* Python Effect_Type callback function prototypes: */
/*****************************************************************************/
-void EffectDeAlloc (BPy_Effect *msh);
+void EffectDeAlloc( BPy_Effect * msh );
//int EffectPrint (BPy_Effect *msh, FILE *fp, int flags);
-int EffectSetAttr (BPy_Effect *msh, char *name, PyObject *v);
-PyObject *EffectGetAttr (BPy_Effect *msh, char *name);
-PyObject *EffectRepr (BPy_Effect *msh);
-PyObject* EffectCreatePyObject (struct Effect *effect);
-int EffectCheckPyObject (PyObject *py_obj);
-struct Effect* EffectFromPyObject (PyObject *py_obj);
+int EffectSetAttr( BPy_Effect * msh, char *name, PyObject * v );
+PyObject *EffectGetAttr( BPy_Effect * msh, char *name );
+PyObject *EffectRepr( BPy_Effect * msh );
+PyObject *EffectCreatePyObject( struct Effect *effect );
+int EffectCheckPyObject( PyObject * py_obj );
+struct Effect *EffectFromPyObject( PyObject * py_obj );
-#endif /* EXPP_EFFECT_H */
+#endif /* EXPP_EFFECT_H */
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index a4a01c62af1..02a2a47b8ba 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -32,7 +32,7 @@
#ifdef WIN32
#include "BLI_winstuff.h"
-#endif /* WIN32*/
+#endif /* WIN32 */
#include <BKE_main.h>
#include <BKE_global.h>
@@ -40,7 +40,7 @@
#include <BKE_image.h>
#include <BIF_drawimage.h>
#include <BLI_blenlib.h>
-#include <IMB_imbuf_types.h> /* for the IB_rect define */
+#include <IMB_imbuf_types.h> /* for the IB_rect define */
#include <BIF_gl.h>
#include "gen_utils.h"
@@ -59,169 +59,176 @@
/************************/
/*****************************************************************************/
-/* Python API function prototypes for the Image module. */
+/* Python API function prototypes for the Image module. */
/*****************************************************************************/
-static PyObject *M_Image_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Image_Get (PyObject *self, PyObject *args);
-static PyObject *M_Image_Load (PyObject *self, PyObject *args);
+static PyObject *M_Image_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Image_Get( PyObject * self, PyObject * args );
+static PyObject *M_Image_Load( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Image.__doc__ */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Image.__doc__ */
/*****************************************************************************/
-static char M_Image_doc[] =
-"The Blender Image module\n\n";
+static char M_Image_doc[] = "The Blender Image module\n\n";
static char M_Image_New_doc[] =
-"() - return a new Image object -- unimplemented";
+ "() - return a new Image object -- unimplemented";
static char M_Image_Get_doc[] =
-"(name) - return the image with the name 'name', \
+ "(name) - return the image with the name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all images in the\ncurrent scene.";
static char M_Image_Load_doc[] =
-"(filename) - return image from file filename as Image Object, \
+ "(filename) - return image from file filename as Image Object, \
returns None if not found.\n";
/*****************************************************************************/
-/* Python method structure definition for Blender.Image module: */
+/* Python method structure definition for Blender.Image module: */
/*****************************************************************************/
struct PyMethodDef M_Image_methods[] = {
- {"New",(PyCFunction)M_Image_New, METH_VARARGS|METH_KEYWORDS,
- M_Image_New_doc},
- {"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
- {"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
- {"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc},
+ {"New", ( PyCFunction ) M_Image_New, METH_VARARGS | METH_KEYWORDS,
+ M_Image_New_doc},
+ {"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
+ {"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
+ {"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Function: M_Image_New */
-/* Python equivalent: Blender.Image.New */
+/* Function: M_Image_New */
+/* Python equivalent: Blender.Image.New */
/*****************************************************************************/
-static PyObject *M_Image_New(PyObject *self, PyObject *args, PyObject *keywords)
+static PyObject *M_Image_New( PyObject * self, PyObject * args,
+ PyObject * keywords )
{
- printf ("In Image_New() - unimplemented in 2.25\n");
+ printf( "In Image_New() - unimplemented in 2.25\n" );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: M_Image_Get */
-/* Python equivalent: Blender.Image.Get */
-/* Description: Receives a string and returns the image object */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all image names in the */
-/* current scene is returned. */
+/* Function: M_Image_Get */
+/* Python equivalent: Blender.Image.Get */
+/* Description: Receives a string and returns the image object */
+/* whose name matches the string. If no argument is */
+/* passed in, a list of all image names in the */
+/* current scene is returned. */
/*****************************************************************************/
-static PyObject *M_Image_Get(PyObject *self, PyObject *args)
+static PyObject *M_Image_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
Image *img_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
img_iter = G.main->image.first;
- if (name) { /* (name) - Search image by name */
+ if( name ) { /* (name) - Search image by name */
BPy_Image *wanted_image = NULL;
- while ((img_iter) && (wanted_image == NULL)) {
- if (strcmp (name, img_iter->id.name+2) == 0) {
- wanted_image = (BPy_Image *)PyObject_NEW(BPy_Image, &Image_Type);
- if (wanted_image) wanted_image->image = img_iter;
+ while( ( img_iter ) && ( wanted_image == NULL ) ) {
+ if( strcmp( name, img_iter->id.name + 2 ) == 0 ) {
+ wanted_image =
+ ( BPy_Image * )
+ PyObject_NEW( BPy_Image, &Image_Type );
+ if( wanted_image )
+ wanted_image->image = img_iter;
}
img_iter = img_iter->id.next;
}
- if (wanted_image == NULL) { /* Requested image doesn't exist */
+ if( wanted_image == NULL ) { /* Requested image doesn't exist */
char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Image \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Image \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
- return (PyObject *)wanted_image;
+ return ( PyObject * ) wanted_image;
}
- else { /* () - return a list of all images in the scene */
+ else { /* () - return a list of all images in the scene */
int index = 0;
PyObject *img_list, *pyobj;
- img_list = PyList_New (BLI_countlist (&(G.main->image)));
+ img_list = PyList_New( BLI_countlist( &( G.main->image ) ) );
- if (img_list == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( img_list == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (img_iter) {
- pyobj = Image_CreatePyObject (img_iter);
+ while( img_iter ) {
+ pyobj = Image_CreatePyObject( img_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- PyList_SET_ITEM (img_list, index, pyobj);
+ PyList_SET_ITEM( img_list, index, pyobj );
img_iter = img_iter->id.next;
index++;
}
- return (img_list);
+ return ( img_list );
}
}
/*****************************************************************************/
-/* Function: M_Image_Load */
-/* Python equivalent: Blender.Image.Load */
-/* Description: Receives a string and returns the image object */
-/* whose filename matches the string. */
+/* Function: M_Image_Load */
+/* Python equivalent: Blender.Image.Load */
+/* Description: Receives a string and returns the image object */
+/* whose filename matches the string. */
/*****************************************************************************/
-static PyObject *M_Image_Load(PyObject *self, PyObject *args)
+static PyObject *M_Image_Load( PyObject * self, PyObject * args )
{
- char *fname;
- Image *img_ptr;
+ char *fname;
+ Image *img_ptr;
BPy_Image *img;
- if (!PyArg_ParseTuple(args, "s", &fname))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &fname ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- img = (BPy_Image *)PyObject_NEW(BPy_Image, &Image_Type);
+ img = ( BPy_Image * ) PyObject_NEW( BPy_Image, &Image_Type );
- if (!img)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject Image_Type"));
+ if( !img )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject Image_Type" ) );
- img_ptr = add_image(fname);
- if (!img_ptr)
- return (EXPP_ReturnPyObjError (PyExc_IOError,
- "couldn't load image"));
+ img_ptr = add_image( fname );
+ if( !img_ptr )
+ return ( EXPP_ReturnPyObjError( PyExc_IOError,
+ "couldn't load image" ) );
img->image = img_ptr;
- return (PyObject *)img;
+ return ( PyObject * ) img;
}
/*****************************************************************************/
-/* Function: Image_Init */
+/* Function: Image_Init */
/*****************************************************************************/
-PyObject *Image_Init (void)
+PyObject *Image_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
Image_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Image", M_Image_methods, M_Image_doc);
+ submodule =
+ Py_InitModule3( "Blender.Image", M_Image_methods,
+ M_Image_doc );
- return (submodule);
+ return ( submodule );
}
/************************/
@@ -229,378 +236,389 @@ PyObject *Image_Init (void)
/************************/
/*****************************************************************************/
-/* Python BPy_Image methods declarations: */
+/* Python BPy_Image methods declarations: */
/*****************************************************************************/
-static PyObject *Image_getName(BPy_Image *self);
-static PyObject *Image_getFilename(BPy_Image *self);
-static PyObject *Image_getSize(BPy_Image *self);
-static PyObject *Image_getDepth(BPy_Image *self);
-static PyObject *Image_getXRep(BPy_Image *self);
-static PyObject *Image_getYRep(BPy_Image *self);
-static PyObject *Image_getBindCode(BPy_Image *self);
-static PyObject *Image_setName(BPy_Image *self, PyObject *args);
-static PyObject *Image_setXRep(BPy_Image *self, PyObject *args);
-static PyObject *Image_setYRep(BPy_Image *self, PyObject *args);
-static PyObject *Image_reload(BPy_Image *self); /* by Campbell */
-static PyObject *Image_glLoad(BPy_Image *self);
+static PyObject *Image_getName( BPy_Image * self );
+static PyObject *Image_getFilename( BPy_Image * self );
+static PyObject *Image_getSize( BPy_Image * self );
+static PyObject *Image_getDepth( BPy_Image * self );
+static PyObject *Image_getXRep( BPy_Image * self );
+static PyObject *Image_getYRep( BPy_Image * self );
+static PyObject *Image_getBindCode( BPy_Image * self );
+static PyObject *Image_setName( BPy_Image * self, PyObject * args );
+static PyObject *Image_setXRep( BPy_Image * self, PyObject * args );
+static PyObject *Image_setYRep( BPy_Image * self, PyObject * args );
+static PyObject *Image_reload( BPy_Image * self ); /* by Campbell */
+static PyObject *Image_glLoad( BPy_Image * self );
/*****************************************************************************/
-/* Python BPy_Image methods table: */
+/* Python BPy_Image methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Image_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Image_getName, METH_NOARGS,
- "() - Return Image object name"},
- {"getFilename", (PyCFunction)Image_getFilename, METH_NOARGS,
- "() - Return Image object filename"},
- {"getSize", (PyCFunction)Image_getSize, METH_NOARGS,
- "() - Return Image object [width, height] dimension in pixels"},
- {"getDepth", (PyCFunction)Image_getDepth, METH_NOARGS,
- "() - Return Image object pixel depth"},
- {"getXRep", (PyCFunction)Image_getXRep, METH_NOARGS,
- "() - Return Image object x repetition value"},
- {"getYRep", (PyCFunction)Image_getYRep, METH_NOARGS,
- "() - Return Image object y repetition value"},
- {"getBindCode", (PyCFunction)Image_getBindCode, METH_NOARGS,
- "() - Return Image object's bind code value"},
- {"reload", (PyCFunction)Image_reload, METH_NOARGS,
- "() - Reload the image from the filesystem"},
- {"glLoad", (PyCFunction)Image_glLoad, METH_NOARGS,
- "() - Load the image data in OpenGL texture memory.\n\
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Image_getName, METH_NOARGS,
+ "() - Return Image object name"},
+ {"getFilename", ( PyCFunction ) Image_getFilename, METH_NOARGS,
+ "() - Return Image object filename"},
+ {"getSize", ( PyCFunction ) Image_getSize, METH_NOARGS,
+ "() - Return Image object [width, height] dimension in pixels"},
+ {"getDepth", ( PyCFunction ) Image_getDepth, METH_NOARGS,
+ "() - Return Image object pixel depth"},
+ {"getXRep", ( PyCFunction ) Image_getXRep, METH_NOARGS,
+ "() - Return Image object x repetition value"},
+ {"getYRep", ( PyCFunction ) Image_getYRep, METH_NOARGS,
+ "() - Return Image object y repetition value"},
+ {"getBindCode", ( PyCFunction ) Image_getBindCode, METH_NOARGS,
+ "() - Return Image object's bind code value"},
+ {"reload", ( PyCFunction ) Image_reload, METH_NOARGS,
+ "() - Reload the image from the filesystem"},
+ {"glLoad", ( PyCFunction ) Image_glLoad, METH_NOARGS,
+ "() - Load the image data in OpenGL texture memory.\n\
The bindcode (int) is returned."},
- {"setName", (PyCFunction)Image_setName, METH_VARARGS,
- "(str) - Change Image object name"},
- {"setXRep", (PyCFunction)Image_setXRep, METH_VARARGS,
- "(int) - Change Image object x repetition value"},
- {"setYRep", (PyCFunction)Image_setYRep, METH_VARARGS,
- "(int) - Change Image object y repetition value"},
+ {"setName", ( PyCFunction ) Image_setName, METH_VARARGS,
+ "(str) - Change Image object name"},
+ {"setXRep", ( PyCFunction ) Image_setXRep, METH_VARARGS,
+ "(int) - Change Image object x repetition value"},
+ {"setYRep", ( PyCFunction ) Image_setYRep, METH_VARARGS,
+ "(int) - Change Image object y repetition value"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Image_Type callback function prototypes: */
+/* Python Image_Type callback function prototypes: */
/*****************************************************************************/
-static void Image_dealloc (BPy_Image *self);
-static int Image_setAttr (BPy_Image *self, char *name, PyObject *v);
-static int Image_compare (BPy_Image *a, BPy_Image *b);
-static PyObject *Image_getAttr (BPy_Image *self, char *name);
-static PyObject *Image_repr (BPy_Image *self);
+static void Image_dealloc( BPy_Image * self );
+static int Image_setAttr( BPy_Image * self, char *name, PyObject * v );
+static int Image_compare( BPy_Image * a, BPy_Image * b );
+static PyObject *Image_getAttr( BPy_Image * self, char *name );
+static PyObject *Image_repr( BPy_Image * self );
/*****************************************************************************/
-/* Python Image_Type structure definition: */
+/* Python Image_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Image_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Image", /* tp_name */
- sizeof (BPy_Image), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject Image_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Image", /* tp_name */
+ sizeof( BPy_Image ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Image_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Image_getAttr, /* tp_getattr */
- (setattrfunc)Image_setAttr, /* tp_setattr */
- (cmpfunc)Image_compare, /* tp_compare */
- (reprfunc)Image_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_Image_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) Image_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Image_getAttr, /* tp_getattr */
+ ( setattrfunc ) Image_setAttr, /* tp_setattr */
+ ( cmpfunc ) Image_compare, /* tp_compare */
+ ( reprfunc ) Image_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_Image_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
-/* Function: Image_dealloc */
-/* Description: This is a callback function for the BPy_Image type. It is */
-/* the destructor function. */
+/* Function: Image_dealloc */
+/* Description: This is a callback function for the BPy_Image type. It is */
+/* the destructor function. */
/*****************************************************************************/
-static void Image_dealloc (BPy_Image *self)
+static void Image_dealloc( BPy_Image * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
-/* Function: Image_CreatePyObject */
-/* Description: This function will create a new BPy_Image from an existing */
-/* Blender image structure. */
+/* Function: Image_CreatePyObject */
+/* Description: This function will create a new BPy_Image from an existing */
+/* Blender image structure. */
/*****************************************************************************/
-PyObject *Image_CreatePyObject (Image *image)
+PyObject *Image_CreatePyObject( Image * image )
{
BPy_Image *py_img;
- py_img = (BPy_Image *)PyObject_NEW (BPy_Image, &Image_Type);
+ py_img = ( BPy_Image * ) PyObject_NEW( BPy_Image, &Image_Type );
- if (!py_img)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Image object");
+ if( !py_img )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Image object" );
py_img->image = image;
- return (PyObject *)py_img;
+ return ( PyObject * ) py_img;
}
/*****************************************************************************/
-/* Function: Image_CheckPyObject */
+/* Function: Image_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type Image. Otherwise it will return false. */
+/* type Image. Otherwise it will return false. */
/*****************************************************************************/
-int Image_CheckPyObject (PyObject *pyobj)
+int Image_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Image_Type);
+ return ( pyobj->ob_type == &Image_Type );
}
/*****************************************************************************/
-/* Function: Image_FromPyObject */
-/* Description: Returns the Blender Image associated with this object */
+/* Function: Image_FromPyObject */
+/* Description: Returns the Blender Image associated with this object */
/*****************************************************************************/
-Image *Image_FromPyObject (PyObject *pyobj)
+Image *Image_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Image *)pyobj)->image;
+ return ( ( BPy_Image * ) pyobj )->image;
}
/*****************************************************************************/
-/* Python BPy_Image methods: */
+/* Python BPy_Image methods: */
/*****************************************************************************/
-static PyObject *Image_getName(BPy_Image *self)
+static PyObject *Image_getName( BPy_Image * self )
{
- PyObject *attr = PyString_FromString(self->image->id.name+2);
+ PyObject *attr = PyString_FromString( self->image->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.name attribute" ) );
}
-static PyObject *Image_getFilename(BPy_Image *self)
+static PyObject *Image_getFilename( BPy_Image * self )
{
- PyObject *attr = PyString_FromString(self->image->name);
+ PyObject *attr = PyString_FromString( self->image->name );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.filename attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.filename attribute" ) );
}
-static PyObject *Image_getSize(BPy_Image *self)
+static PyObject *Image_getSize( BPy_Image * self )
{
PyObject *attr;
Image *image = self->image;
- if (!image->ibuf) /* if no image data available */
- load_image(image, IB_rect, "", 0); /* loading it */
+ if( !image->ibuf ) /* if no image data available */
+ load_image( image, IB_rect, "", 0 ); /* loading it */
- if (!image->ibuf) /* didn't work */
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't load image data in Blender");
+ if( !image->ibuf ) /* didn't work */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't load image data in Blender" );
- attr = Py_BuildValue("[hh]", image->ibuf->x, image->ibuf->y);
+ attr = Py_BuildValue( "[hh]", image->ibuf->x, image->ibuf->y );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.size attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.size attribute" );
}
-static PyObject *Image_getDepth(BPy_Image *self)
+static PyObject *Image_getDepth( BPy_Image * self )
{
PyObject *attr;
Image *image = self->image;
- if (!image->ibuf) /* if no image data available */
- load_image(image, IB_rect, "", 0); /* loading it */
+ if( !image->ibuf ) /* if no image data available */
+ load_image( image, IB_rect, "", 0 ); /* loading it */
- if (!image->ibuf) /* didn't work */
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't load image data in Blender");
+ if( !image->ibuf ) /* didn't work */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't load image data in Blender" );
- attr = Py_BuildValue("h", image->ibuf->depth);
+ attr = Py_BuildValue( "h", image->ibuf->depth );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.depth attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.depth attribute" );
}
-static PyObject *Image_getXRep(BPy_Image *self)
+static PyObject *Image_getXRep( BPy_Image * self )
{
- PyObject *attr = PyInt_FromLong(self->image->xrep);
+ PyObject *attr = PyInt_FromLong( self->image->xrep );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.xrep attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.xrep attribute" );
}
-static PyObject *Image_getYRep(BPy_Image *self)
+static PyObject *Image_getYRep( BPy_Image * self )
{
- PyObject *attr = PyInt_FromLong(self->image->yrep);
+ PyObject *attr = PyInt_FromLong( self->image->yrep );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.yrep attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.yrep attribute" );
}
-static PyObject *Image_getBindCode(BPy_Image *self)
+static PyObject *Image_getBindCode( BPy_Image * self )
{
- PyObject *attr = PyLong_FromUnsignedLong(self->image->bindcode);
+ PyObject *attr = PyLong_FromUnsignedLong( self->image->bindcode );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Image.bindcode attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Image.bindcode attribute" );
}
-static PyObject *Image_reload(BPy_Image *self)
+static PyObject *Image_reload( BPy_Image * self )
{
Image *img = self->image;
-
- free_image_buffers(img); /* force read again */
+
+ free_image_buffers( img ); /* force read again */
img->ok = 1;
- image_changed(G.sima, 0);
-
- Py_INCREF(Py_None);
+ image_changed( G.sima, 0 );
+
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Image_glLoad(BPy_Image *self)
+static PyObject *Image_glLoad( BPy_Image * self )
{
Image *img = self->image;
unsigned int *bind = &img->bindcode;
- if (*bind == 0) {
+ if( *bind == 0 ) {
- if (!img->ibuf) /* if no image data is available */
- load_image(img, IB_rect, "", 0); /* loading it */
+ if( !img->ibuf ) /* if no image data is available */
+ load_image( img, IB_rect, "", 0 ); /* loading it */
- if (!img->ibuf) /* didn't work */
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't load image data in Blender");
+ if( !img->ibuf ) /* didn't work */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't load image data in Blender" );
- glGenTextures(1, (GLuint *)bind);
- glBindTexture(GL_TEXTURE_2D, *bind);
+ glGenTextures( 1, ( GLuint * ) bind );
+ glBindTexture( GL_TEXTURE_2D, *bind );
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, img->ibuf->x, img->ibuf->y,
- GL_RGBA, GL_UNSIGNED_BYTE, img->ibuf->rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, img->ibuf->x,
+ img->ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE,
+ img->ibuf->rect );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR );
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->ibuf->x, img->ibuf->y, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, img->ibuf->rect);
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, img->ibuf->x,
+ img->ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ img->ibuf->rect );
}
- return PyLong_FromUnsignedLong (img->bindcode);
+ return PyLong_FromUnsignedLong( img->bindcode );
}
-static PyObject *Image_setName(BPy_Image *self, PyObject *args)
+static PyObject *Image_setName( BPy_Image * self, PyObject * args )
{
char *name;
char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
-
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
-
- rename_id(&self->image->id, buf);
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
+
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+
+ rename_id( &self->image->id, buf );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Image_setXRep(BPy_Image *self, PyObject *args)
+static PyObject *Image_setXRep( BPy_Image * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1,16]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1,16]" ) );
- if (value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX)
+ if( value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX )
self->image->xrep = value;
else
- return (EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument in [1,16]"));
+ return ( EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected int argument in [1,16]" ) );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Image_setYRep(BPy_Image *self, PyObject *args)
+static PyObject *Image_setYRep( BPy_Image * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1,16]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1,16]" ) );
- if (value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX)
+ if( value >= EXPP_IMAGE_REP_MIN || value <= EXPP_IMAGE_REP_MAX )
self->image->yrep = value;
else
- return (EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument in [1,16]"));
+ return ( EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected int argument in [1,16]" ) );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: Image_getAttr */
-/* Description: This is a callback function for the BPy_Image type. It is */
-/* the function that accesses BPy_Image member variables and */
-/* methods. */
+/* Function: Image_getAttr */
+/* Description: This is a callback function for the BPy_Image type. It is */
+/* the function that accesses BPy_Image member variables and */
+/* methods. */
/*****************************************************************************/
-static PyObject *Image_getAttr (BPy_Image *self, char *name)
+static PyObject *Image_getAttr( BPy_Image * self, char *name )
{
PyObject *attr = Py_None;
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->image->id.name+2);
- else if (strcmp(name, "filename") == 0)
- attr = PyString_FromString(self->image->name);
- else if (strcmp(name, "size") == 0)
- attr = Image_getSize(self);
- else if (strcmp(name, "depth") == 0)
- attr = Image_getDepth(self);
- else if (strcmp(name, "xrep") == 0)
- attr = PyInt_FromLong(self->image->xrep);
- else if (strcmp(name, "yrep") == 0)
- attr = PyInt_FromLong(self->image->yrep);
- else if (strcmp(name, "bindcode") == 0)
- attr = PyInt_FromLong(self->image->bindcode);
-
- else if (strcmp(name, "__members__") == 0)
- attr = Py_BuildValue("[s,s,s,s,s,s,s]",
- "name", "filename", "size", "depth", "xrep", "yrep", "bindcode");
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None) return attr; /* attribute found, return its value */
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->image->id.name + 2 );
+ else if( strcmp( name, "filename" ) == 0 )
+ attr = PyString_FromString( self->image->name );
+ else if( strcmp( name, "size" ) == 0 )
+ attr = Image_getSize( self );
+ else if( strcmp( name, "depth" ) == 0 )
+ attr = Image_getDepth( self );
+ else if( strcmp( name, "xrep" ) == 0 )
+ attr = PyInt_FromLong( self->image->xrep );
+ else if( strcmp( name, "yrep" ) == 0 )
+ attr = PyInt_FromLong( self->image->yrep );
+ else if( strcmp( name, "bindcode" ) == 0 )
+ attr = PyInt_FromLong( self->image->bindcode );
+
+ else if( strcmp( name, "__members__" ) == 0 )
+ attr = Py_BuildValue( "[s,s,s,s,s,s,s]",
+ "name", "filename", "size", "depth",
+ "xrep", "yrep", "bindcode" );
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; /* attribute found, return its value */
/* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Image_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Image_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
-/* Function: Image_setAttr */
+/* Function: Image_setAttr */
/* Description: This is a callback function for the BPy_Image type. It is the*/
-/* function that changes Image object members values. If this */
-/* data is linked to a Blender Image, it also gets updated. */
+/* function that changes Image object members values. If this */
+/* data is linked to a Blender Image, it also gets updated. */
/*****************************************************************************/
-static int Image_setAttr (BPy_Image *self, char *name, PyObject *value)
+static int Image_setAttr( BPy_Image * self, char *name, PyObject * value )
{
- PyObject *valtuple;
+ PyObject *valtuple;
PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
@@ -608,53 +626,55 @@ static int Image_setAttr (BPy_Image *self, char *name, PyObject *value)
* function anyway, since it already has error checking, clamps to the right
* interval and updates the Blender Image structure when necessary. */
- valtuple = Py_BuildValue("(O)", value); /*the set* functions expect a tuple*/
-
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "ImageSetAttr: couldn't create PyTuple");
-
- if (strcmp (name, "name") == 0)
- error = Image_setName (self, valtuple);
- else if (strcmp (name, "xrep") == 0)
- error = Image_setXRep (self, valtuple);
- else if (strcmp (name, "yrep") == 0)
- error = Image_setYRep (self, valtuple);
- else { /* Error: no such member in the Image object structure */
- Py_DECREF(value);
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found or immutable"));
+ valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "ImageSetAttr: couldn't create PyTuple" );
+
+ if( strcmp( name, "name" ) == 0 )
+ error = Image_setName( self, valtuple );
+ else if( strcmp( name, "xrep" ) == 0 )
+ error = Image_setXRep( self, valtuple );
+ else if( strcmp( name, "yrep" ) == 0 )
+ error = Image_setYRep( self, valtuple );
+ else { /* Error: no such member in the Image object structure */
+ Py_DECREF( value );
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found or immutable" ) );
}
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF(Py_None); /* incref'ed by the called set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* incref'ed by the called set* function */
+ return 0; /* normal exit */
}
/*****************************************************************************/
-/* Function: Image_compare */
-/* Description: This is a callback function for the BPy_Image type. It */
-/* compares two Image_Type objects. Only the "==" and "!=" */
-/* comparisons are meaninful. Returns 0 for equality and -1 if */
-/* they don't point to the same Blender Image struct. */
-/* In Python it becomes 1 if they are equal, 0 otherwise. */
+/* Function: Image_compare */
+/* Description: This is a callback function for the BPy_Image type. It */
+/* compares two Image_Type objects. Only the "==" and "!=" */
+/* comparisons are meaninful. Returns 0 for equality and -1 if */
+/* they don't point to the same Blender Image struct. */
+/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static int Image_compare (BPy_Image *a, BPy_Image *b)
+static int Image_compare( BPy_Image * a, BPy_Image * b )
{
Image *pa = a->image, *pb = b->image;
- return (pa == pb) ? 0:-1;
+ return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
-/* Function: Image_repr */
-/* Description: This is a callback function for the BPy_Image type. It */
-/* builds a meaninful string to represent image objects. */
+/* Function: Image_repr */
+/* Description: This is a callback function for the BPy_Image type. It */
+/* builds a meaninful string to represent image objects. */
/*****************************************************************************/
-static PyObject *Image_repr (BPy_Image *self)
+static PyObject *Image_repr( BPy_Image * self )
{
- return PyString_FromFormat("[Image \"%s\"]", self->image->id.name+2);
+ return PyString_FromFormat( "[Image \"%s\"]",
+ self->image->id.name + 2 );
}
diff --git a/source/blender/python/api2_2x/Image.h b/source/blender/python/api2_2x/Image.h
index e758e924f53..384c28b9661 100644
--- a/source/blender/python/api2_2x/Image.h
+++ b/source/blender/python/api2_2x/Image.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -40,21 +41,20 @@
/* Python BPy_Image structure definition */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Image *image;
+ PyObject_HEAD Image * image;
} BPy_Image;
-extern PyTypeObject Image_Type; /* The Image PyType Object */
+extern PyTypeObject Image_Type; /* The Image PyType Object */
-#define BPy_Image_Check(v) ((v)->ob_type == &Image_Type)/*for type checking*/
+#define BPy_Image_Check(v) ((v)->ob_type == &Image_Type) /*for type checking */
/*****************************************************************************/
/* Module Blender.Image - public functions */
/*****************************************************************************/
-PyObject *Image_Init (void);
-PyObject *Image_CreatePyObject (Image *image);
-int Image_CheckPyObject (PyObject *pyobj);
-Image *Image_FromPyObject (PyObject *pyobj);
+PyObject *Image_Init( void );
+PyObject *Image_CreatePyObject( Image * image );
+int Image_CheckPyObject( PyObject * pyobj );
+Image *Image_FromPyObject( PyObject * pyobj );
-#endif /* EXPP_IMAGE_H */
+#endif /* EXPP_IMAGE_H */
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 475817095a3..4a5b245e352 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -45,14 +45,14 @@
/* forward declarations */
-char *GetIpoCurveName (IpoCurve * icu);
+char *GetIpoCurveName( IpoCurve * icu );
/*****************************************************************************/
/* Python API function prototypes for the Ipo module. */
/*****************************************************************************/
-static PyObject *M_Ipo_New (PyObject * self, PyObject * args);
-static PyObject *M_Ipo_Get (PyObject * self, PyObject * args);
-static PyObject *M_Ipo_Recalc (PyObject * self, PyObject * args);
+static PyObject *M_Ipo_New( PyObject * self, PyObject * args );
+static PyObject *M_Ipo_Get( PyObject * self, PyObject * args );
+static PyObject *M_Ipo_Recalc( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -69,113 +69,116 @@ char M_Ipo_Get_doc[] = "";
/*****************************************************************************/
struct PyMethodDef M_Ipo_methods[] = {
- {"New", (PyCFunction) M_Ipo_New, METH_VARARGS | METH_KEYWORDS,
- M_Ipo_New_doc},
- {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
- {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
- {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Ipo_New, METH_VARARGS | METH_KEYWORDS,
+ M_Ipo_New_doc},
+ {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
+ {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
+ {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Ipo methods declarations: */
/*****************************************************************************/
-static PyObject *Ipo_getName (BPy_Ipo * self);
-static PyObject *Ipo_setName (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getBlocktype (BPy_Ipo * self);
-static PyObject *Ipo_setBlocktype (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getRctf (BPy_Ipo * self);
-static PyObject *Ipo_setRctf (BPy_Ipo * self, PyObject * args);
-
-static PyObject *Ipo_getCurve (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getCurves (BPy_Ipo * self);
-static PyObject *Ipo_addCurve (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getNcurves (BPy_Ipo * self);
-static PyObject *Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getCurveBP (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args);
-
-
-static PyObject *Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args);
-static PyObject *Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args);
+static PyObject *Ipo_getName( BPy_Ipo * self );
+static PyObject *Ipo_setName( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getBlocktype( BPy_Ipo * self );
+static PyObject *Ipo_setBlocktype( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getRctf( BPy_Ipo * self );
+static PyObject *Ipo_setRctf( BPy_Ipo * self, PyObject * args );
+
+static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getCurves( BPy_Ipo * self );
+static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getNcurves( BPy_Ipo * self );
+static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args );
+
+
+static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Ipo methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Ipo_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction) Ipo_getName, METH_NOARGS,
- "() - Return Ipo Data name"},
- {"setName", (PyCFunction) Ipo_setName, METH_VARARGS,
- "(str) - Change Ipo Data name"},
- {"getBlocktype", (PyCFunction) Ipo_getBlocktype, METH_NOARGS,
- "() - Return Ipo blocktype -"},
- {"setBlocktype", (PyCFunction) Ipo_setBlocktype, METH_VARARGS,
- "(str) - Change Ipo blocktype"},
- {"getRctf", (PyCFunction) Ipo_getRctf, METH_NOARGS,
- "() - Return Ipo rctf - "},
- {"setRctf", (PyCFunction) Ipo_setRctf, METH_VARARGS,
- "(str) - Change Ipo rctf"},
- {"addCurve", (PyCFunction) Ipo_addCurve, METH_VARARGS,
- "() - Return Ipo ncurves"},
- {"getNcurves", (PyCFunction) Ipo_getNcurves, METH_NOARGS,
- "() - Return Ipo ncurves"},
- {"getNBezPoints", (PyCFunction) Ipo_getNBezPoints, METH_VARARGS,
- "() - Return curve number of Bez points"},
- {"delBezPoint", (PyCFunction) Ipo_DeleteBezPoints, METH_VARARGS,
- "() - Return curve number of Bez points"},
- {"getCurveBP", (PyCFunction) Ipo_getCurveBP, METH_VARARGS,
- "() - Return Ipo ncurves"},
- {"EvaluateCurveOn", (PyCFunction) Ipo_EvaluateCurveOn, METH_VARARGS,
- "() - Return curve value at given time"},
- {"getCurveCurval", (PyCFunction) Ipo_getCurvecurval, METH_VARARGS,
- "() - Return curval"},
- {"getCurveBeztriple", (PyCFunction) Ipo_getCurveBeztriple, METH_VARARGS,
- "() - Return Ipo ncurves"},
- {"setCurveBeztriple", (PyCFunction) Ipo_setCurveBeztriple, METH_VARARGS,
- "() - Return curval"},
- {"getCurves", (PyCFunction) Ipo_getCurves, METH_NOARGS,
- "() - Return curval"},
- {"getCurve", (PyCFunction) Ipo_getCurve, METH_VARARGS,
- "() - Return curval"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Ipo_getName, METH_NOARGS,
+ "() - Return Ipo Data name"},
+ {"setName", ( PyCFunction ) Ipo_setName, METH_VARARGS,
+ "(str) - Change Ipo Data name"},
+ {"getBlocktype", ( PyCFunction ) Ipo_getBlocktype, METH_NOARGS,
+ "() - Return Ipo blocktype -"},
+ {"setBlocktype", ( PyCFunction ) Ipo_setBlocktype, METH_VARARGS,
+ "(str) - Change Ipo blocktype"},
+ {"getRctf", ( PyCFunction ) Ipo_getRctf, METH_NOARGS,
+ "() - Return Ipo rctf - "},
+ {"setRctf", ( PyCFunction ) Ipo_setRctf, METH_VARARGS,
+ "(str) - Change Ipo rctf"},
+ {"addCurve", ( PyCFunction ) Ipo_addCurve, METH_VARARGS,
+ "() - Return Ipo ncurves"},
+ {"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS,
+ "() - Return Ipo ncurves"},
+ {"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS,
+ "() - Return curve number of Bez points"},
+ {"delBezPoint", ( PyCFunction ) Ipo_DeleteBezPoints, METH_VARARGS,
+ "() - Return curve number of Bez points"},
+ {"getCurveBP", ( PyCFunction ) Ipo_getCurveBP, METH_VARARGS,
+ "() - Return Ipo ncurves"},
+ {"EvaluateCurveOn", ( PyCFunction ) Ipo_EvaluateCurveOn, METH_VARARGS,
+ "() - Return curve value at given time"},
+ {"getCurveCurval", ( PyCFunction ) Ipo_getCurvecurval, METH_VARARGS,
+ "() - Return curval"},
+ {"getCurveBeztriple", ( PyCFunction ) Ipo_getCurveBeztriple,
+ METH_VARARGS,
+ "() - Return Ipo ncurves"},
+ {"setCurveBeztriple", ( PyCFunction ) Ipo_setCurveBeztriple,
+ METH_VARARGS,
+ "() - Return curval"},
+ {"getCurves", ( PyCFunction ) Ipo_getCurves, METH_NOARGS,
+ "() - Return curval"},
+ {"getCurve", ( PyCFunction ) Ipo_getCurve, METH_VARARGS,
+ "() - Return curval"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Ipo_Type callback function prototypes: */
/*****************************************************************************/
-static void IpoDeAlloc (BPy_Ipo * self);
+static void IpoDeAlloc( BPy_Ipo * self );
//static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags);
-static int IpoSetAttr (BPy_Ipo * self, char *name, PyObject * v);
-static PyObject *IpoGetAttr (BPy_Ipo * self, char *name);
-static PyObject *IpoRepr (BPy_Ipo * self);
+static int IpoSetAttr( BPy_Ipo * self, char *name, PyObject * v );
+static PyObject *IpoGetAttr( BPy_Ipo * self, char *name );
+static PyObject *IpoRepr( BPy_Ipo * self );
/*****************************************************************************/
/* Python Ipo_Type structure definition: */
/*****************************************************************************/
PyTypeObject Ipo_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Ipo", /* tp_name */
- sizeof (BPy_Ipo), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) IpoDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) IpoGetAttr, /* tp_getattr */
- (setattrfunc) IpoSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) IpoRepr, /* 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_Ipo_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Ipo", /* tp_name */
+ sizeof( BPy_Ipo ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) IpoDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) IpoGetAttr, /* tp_getattr */
+ ( setattrfunc ) IpoSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) IpoRepr, /* 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_Ipo_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
@@ -183,66 +186,65 @@ PyTypeObject Ipo_Type = {
/* Python equivalent: Blender.Ipo.New */
/*****************************************************************************/
-static PyObject *
-M_Ipo_New (PyObject * self, PyObject * args)
+static PyObject *M_Ipo_New( PyObject * self, PyObject * args )
{
- Ipo *add_ipo (char *name, int idcode);
- char *name = NULL, *code = NULL;
- int idcode = -1;
- BPy_Ipo *pyipo;
- Ipo *blipo;
-
- if (!PyArg_ParseTuple (args, "ss", &code, &name))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string string arguments"));
-
- if (!strcmp (code, "Object"))
- idcode = ID_OB;
- if (!strcmp (code, "Camera"))
- idcode = ID_CA;
- if (!strcmp (code, "World"))
- idcode = ID_WO;
- if (!strcmp (code, "Material"))
- idcode = ID_MA;
- if (!strcmp (code, "Texture"))
- idcode = ID_TE;
- if (!strcmp (code, "Lamp"))
- idcode = ID_LA;
- if (!strcmp (code, "Action"))
- idcode = ID_AC;
- if (!strcmp (code, "Constraint"))
- idcode = IPO_CO;
- if (!strcmp (code, "Sequence"))
- idcode = ID_SEQ;
- if (!strcmp (code, "Curve"))
- idcode = ID_CU;
- if (!strcmp (code, "Key"))
- idcode = ID_KE;
-
- if (idcode == -1)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad code"));
-
-
- blipo = add_ipo (name, idcode);
-
- if (blipo)
- {
- /* return user count to zero because add_ipo() inc'd it */
- blipo->id.us = 0;
- /* create python wrapper obj */
- pyipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Ipo Data in Blender"));
-
- if (pyipo == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Ipo Data object"));
-
- pyipo->ipo = blipo;
-
- return (PyObject *) pyipo;
+ Ipo *add_ipo( char *name, int idcode );
+ char *name = NULL, *code = NULL;
+ int idcode = -1;
+ BPy_Ipo *pyipo;
+ Ipo *blipo;
+
+ if( !PyArg_ParseTuple( args, "ss", &code, &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected string string arguments" ) );
+
+ if( !strcmp( code, "Object" ) )
+ idcode = ID_OB;
+ if( !strcmp( code, "Camera" ) )
+ idcode = ID_CA;
+ if( !strcmp( code, "World" ) )
+ idcode = ID_WO;
+ if( !strcmp( code, "Material" ) )
+ idcode = ID_MA;
+ if( !strcmp( code, "Texture" ) )
+ idcode = ID_TE;
+ if( !strcmp( code, "Lamp" ) )
+ idcode = ID_LA;
+ if( !strcmp( code, "Action" ) )
+ idcode = ID_AC;
+ if( !strcmp( code, "Constraint" ) )
+ idcode = IPO_CO;
+ if( !strcmp( code, "Sequence" ) )
+ idcode = ID_SEQ;
+ if( !strcmp( code, "Curve" ) )
+ idcode = ID_CU;
+ if( !strcmp( code, "Key" ) )
+ idcode = ID_KE;
+
+ if( idcode == -1 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad code" ) );
+
+
+ blipo = add_ipo( name, idcode );
+
+ if( blipo ) {
+ /* return user count to zero because add_ipo() inc'd it */
+ blipo->id.us = 0;
+ /* create python wrapper obj */
+ pyipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Ipo Data in Blender" ) );
+
+ if( pyipo == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Ipo Data object" ) );
+
+ pyipo->ipo = blipo;
+
+ return ( PyObject * ) pyipo;
}
/*****************************************************************************/
@@ -253,1282 +255,1170 @@ M_Ipo_New (PyObject * self, PyObject * args)
/* passed in, a list of all ipo data names in the */
/* current scene is returned. */
/*****************************************************************************/
-static PyObject *
-M_Ipo_Get (PyObject * self, PyObject * args)
+static PyObject *M_Ipo_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
- Ipo *ipo_iter;
- PyObject *ipolist, *pyobj;
- BPy_Ipo *wanted_ipo = NULL;
- char error_msg[64];
-
- if (!PyArg_ParseTuple (args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
-
- ipo_iter = G.main->ipo.first;
-
- if (name)
- { /* (name) - Search ipo by name */
- while ((ipo_iter) && (wanted_ipo == NULL))
- {
- if (strcmp (name, ipo_iter->id.name + 2) == 0)
- {
- wanted_ipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type);
- if (wanted_ipo)
- wanted_ipo->ipo = ipo_iter;
- }
- ipo_iter = ipo_iter->id.next;
+ char *name = NULL;
+ Ipo *ipo_iter;
+ PyObject *ipolist, *pyobj;
+ BPy_Ipo *wanted_ipo = NULL;
+ char error_msg[64];
+
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
+
+ ipo_iter = G.main->ipo.first;
+
+ if( name ) { /* (name) - Search ipo by name */
+ while( ( ipo_iter ) && ( wanted_ipo == NULL ) ) {
+ if( strcmp( name, ipo_iter->id.name + 2 ) == 0 ) {
+ wanted_ipo =
+ ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo,
+ &Ipo_Type );
+ if( wanted_ipo )
+ wanted_ipo->ipo = ipo_iter;
+ }
+ ipo_iter = ipo_iter->id.next;
+ }
+
+ if( wanted_ipo == NULL ) { /* Requested ipo doesn't exist */
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Ipo \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+ }
+
+ return ( PyObject * ) wanted_ipo;
}
- if (wanted_ipo == NULL)
- { /* Requested ipo doesn't exist */
- PyOS_snprintf (error_msg, sizeof (error_msg),
- "Ipo \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ else { /* () - return a list with all ipos in the scene */
+ int index = 0;
- return (PyObject *) wanted_ipo;
- }
+ ipolist = PyList_New( BLI_countlist( &( G.main->ipo ) ) );
- else
- { /* () - return a list with all ipos in the scene */
- int index = 0;
+ if( ipolist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- ipolist = PyList_New (BLI_countlist (&(G.main->ipo)));
+ while( ipo_iter ) {
+ pyobj = Ipo_CreatePyObject( ipo_iter );
- if (ipolist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- while (ipo_iter)
- {
- pyobj = Ipo_CreatePyObject (ipo_iter);
+ PyList_SET_ITEM( ipolist, index, pyobj );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ ipo_iter = ipo_iter->id.next;
+ index++;
+ }
- PyList_SET_ITEM (ipolist, index, pyobj);
-
- ipo_iter = ipo_iter->id.next;
- index++;
+ return ( ipolist );
}
-
- return (ipolist);
- }
}
-static PyObject *
-M_Ipo_Recalc (PyObject * self, PyObject * args)
+static PyObject *M_Ipo_Recalc( PyObject * self, PyObject * args )
{
- void testhandles_ipocurve (IpoCurve * icu);
- PyObject *a;
- IpoCurve *icu;
- if (!PyArg_ParseTuple (args, "O", &a))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected ipo argument)"));
- icu = IpoCurve_FromPyObject (a);
- testhandles_ipocurve (icu);
-
- Py_INCREF (Py_None);
- return Py_None;
+ void testhandles_ipocurve( IpoCurve * icu );
+ PyObject *a;
+ IpoCurve *icu;
+ if( !PyArg_ParseTuple( args, "O", &a ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected ipo argument)" ) );
+ icu = IpoCurve_FromPyObject( a );
+ testhandles_ipocurve( icu );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: Ipo_Init */
/*****************************************************************************/
-PyObject *
-Ipo_Init (void)
+PyObject *Ipo_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Ipo_Type.ob_type = &PyType_Type;
+ Ipo_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Ipo", M_Ipo_methods, M_Ipo_doc);
+ submodule = Py_InitModule3( "Blender.Ipo", M_Ipo_methods, M_Ipo_doc );
- return (submodule);
+ return ( submodule );
}
/*****************************************************************************/
/* Python BPy_Ipo methods: */
/*****************************************************************************/
-static PyObject *
-Ipo_getName (BPy_Ipo * self)
+static PyObject *Ipo_getName( BPy_Ipo * self )
{
- PyObject *attr = PyString_FromString (self->ipo->id.name + 2);
+ PyObject *attr = PyString_FromString( self->ipo->id.name + 2 );
- if (attr)
- return attr;
- Py_INCREF (Py_None);
- return Py_None;
+ if( attr )
+ return attr;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Ipo_setName (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_setName( BPy_Ipo * self, PyObject * args )
{
- char *name;
- char buf[21];
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple (args, "s", &name))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
- PyOS_snprintf (buf, sizeof (buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id (&self->ipo->id, buf);
+ rename_id( &self->ipo->id, buf );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Ipo_getBlocktype (BPy_Ipo * self)
+static PyObject *Ipo_getBlocktype( BPy_Ipo * self )
{
- PyObject *attr = PyInt_FromLong (self->ipo->blocktype);
- if (attr)
- return attr;
- return (EXPP_ReturnPyObjError
- (PyExc_RuntimeError, "couldn't get Ipo.blocktype attribute"));
+ PyObject *attr = PyInt_FromLong( self->ipo->blocktype );
+ if( attr )
+ return attr;
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "couldn't get Ipo.blocktype attribute" ) );
}
-static PyObject *
-Ipo_setBlocktype (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_setBlocktype( BPy_Ipo * self, PyObject * args )
{
- int blocktype = 0;
+ int blocktype = 0;
- if (!PyArg_ParseTuple (args, "i", &blocktype))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
+ if( !PyArg_ParseTuple( args, "i", &blocktype ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
- self->ipo->blocktype = (short) blocktype;
+ self->ipo->blocktype = ( short ) blocktype;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Ipo_getRctf (BPy_Ipo * self)
+static PyObject *Ipo_getRctf( BPy_Ipo * self )
{
- PyObject *l = PyList_New (0);
- PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmin));
- PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmax));
- PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymin));
- PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymax));
- return l;
+ PyObject *l = PyList_New( 0 );
+ PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmin ) );
+ PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmax ) );
+ PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymin ) );
+ PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymax ) );
+ return l;
}
-static PyObject *
-Ipo_setRctf (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_setRctf( BPy_Ipo * self, PyObject * args )
{
- float v[4];
- if (!PyArg_ParseTuple (args, "ffff", v, v + 1, v + 2, v + 3))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected 4 float argument"));
-
- self->ipo->cur.xmin = v[0];
- self->ipo->cur.xmax = v[1];
- self->ipo->cur.ymin = v[2];
- self->ipo->cur.ymax = v[3];
-
- Py_INCREF (Py_None);
- return Py_None;
+ float v[4];
+ if( !PyArg_ParseTuple( args, "ffff", v, v + 1, v + 2, v + 3 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected 4 float argument" ) );
+
+ self->ipo->cur.xmin = v[0];
+ self->ipo->cur.xmax = v[1];
+ self->ipo->cur.ymin = v[2];
+ self->ipo->cur.ymax = v[3];
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Ipo_getNcurves (BPy_Ipo * self)
+static PyObject *Ipo_getNcurves( BPy_Ipo * self )
{
- int i = 0;
+ int i = 0;
- IpoCurve *icu;
- for (icu = self->ipo->curve.first; icu; icu = icu->next)
- {
- i++;
- }
+ IpoCurve *icu;
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ i++;
+ }
- return (PyInt_FromLong (i));
+ return ( PyInt_FromLong( i ) );
}
-int Ipo_laIcuName(char * s, int * param)
+int Ipo_laIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "Energy"))
- {
- *param = LA_ENERGY;
- ok = 1;
- }
- if (!strcmp (s, "R"))
- {
- *param = LA_COL_R;
- ok = 1;
- }
- if (!strcmp (s, "G"))
- {
- *param = LA_COL_G;
- ok = 1;
- }
- if (!strcmp (s, "B"))
- {
- *param = LA_COL_B;
- ok = 1;
- }
- if (!strcmp (s, "Dist"))
- {
- *param = LA_DIST;
- ok = 1;
- }
- if (!strcmp (s, "SpoSi"))
- {
- *param = LA_SPOTSI;
- ok = 1;
- }
- if (!strcmp (s, "SpoBl"))
- {
- *param = LA_SPOTBL;
- ok = 1;
- }
- if (!strcmp (s, "Quad1"))
- {
- *param = LA_QUAD1;
- ok = 1;
- }
- if (!strcmp (s, "Quad2"))
- {
- *param = LA_QUAD2;
- ok = 1;
- }
- if (!strcmp (s, "HaInt"))
- {
- *param = LA_HALOINT;
- ok = 1;
- }
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "Energy" ) ) {
+ *param = LA_ENERGY;
+ ok = 1;
+ }
+ if( !strcmp( s, "R" ) ) {
+ *param = LA_COL_R;
+ ok = 1;
+ }
+ if( !strcmp( s, "G" ) ) {
+ *param = LA_COL_G;
+ ok = 1;
+ }
+ if( !strcmp( s, "B" ) ) {
+ *param = LA_COL_B;
+ ok = 1;
+ }
+ if( !strcmp( s, "Dist" ) ) {
+ *param = LA_DIST;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpoSi" ) ) {
+ *param = LA_SPOTSI;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpoBl" ) ) {
+ *param = LA_SPOTBL;
+ ok = 1;
+ }
+ if( !strcmp( s, "Quad1" ) ) {
+ *param = LA_QUAD1;
+ ok = 1;
+ }
+ if( !strcmp( s, "Quad2" ) ) {
+ *param = LA_QUAD2;
+ ok = 1;
+ }
+ if( !strcmp( s, "HaInt" ) ) {
+ *param = LA_HALOINT;
+ ok = 1;
+ }
+ return ok;
}
-int Ipo_woIcuName(char * s, int * param)
+int Ipo_woIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "HorR"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "HorG"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "HorB"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "ZenR"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "ZenG"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "ZenB"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "Expos"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "Misi"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "MisDi"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "MisHi"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "StarR"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "StarB"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "StarG"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "ClSta"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "StarDi"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "StarSi"))
- {
- *param = CAM_END;
- ok = 1;
- }
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "HorR" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "HorG" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "HorB" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "ZenR" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "ZenG" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "ZenB" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "Expos" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "Misi" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "MisDi" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "MisHi" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "StarR" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "StarB" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "StarG" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "ClSta" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "StarDi" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "StarSi" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ return ok;
}
-int Ipo_maIcuName(char * s, int * param)
+int Ipo_maIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "R"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "G"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "B"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "SpecR"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "SpecG"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "SpecB"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "MirR"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "MirG"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "MirB"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "Ref"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "Alpha"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "Emit"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "Amb"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "Spec"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "Hard"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "SpTra"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "Ior"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "Mode"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "HaSize"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "Translu"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "RayMir"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "FresMir"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "FresMirI"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "FresTra"))
- {
- *param = CAM_END;
- ok = 1;
- }
- if (!strcmp (s, "FresTraI"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "TraGlow"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "R" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "G" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "B" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpecR" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpecG" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpecB" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "MirR" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "MirG" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "MirB" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "Ref" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "Alpha" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "Emit" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "Amb" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "Spec" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "Hard" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "SpTra" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "Ior" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "Mode" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "HaSize" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "Translu" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "RayMir" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "FresMir" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "FresMirI" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "FresTra" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ if( !strcmp( s, "FresTraI" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "TraGlow" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ return ok;
}
-int Ipo_keIcuName(char *s, int * param)
+int Ipo_keIcuName( char *s, int *param )
{
- char key[10];
- int ok = 0;
- int nr = 0;
- if (!strcmp (s, "Speed"))
- {
- *param = KEY_SPEED;
- ok = 1;
- }
- for(nr = 1; nr<64; nr++) {
- sprintf(key, "Key %d", nr);
- if (!strcmp (s, key)) {
- *param = nr;
- ok = 1;
- break;
- }
- }
-
- return ok;
+ char key[10];
+ int ok = 0;
+ int nr = 0;
+ if( !strcmp( s, "Speed" ) ) {
+ *param = KEY_SPEED;
+ ok = 1;
+ }
+ for( nr = 1; nr < 64; nr++ ) {
+ sprintf( key, "Key %d", nr );
+ if( !strcmp( s, key ) ) {
+ *param = nr;
+ ok = 1;
+ break;
+ }
+ }
+
+ return ok;
}
-int Ipo_seqIcuName(char *s, int * param)
+int Ipo_seqIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "Fac"))
- {
- *param = SEQ_FAC1;
- ok = 1;
- }
-
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "Fac" ) ) {
+ *param = SEQ_FAC1;
+ ok = 1;
+ }
+
+ return ok;
}
-int Ipo_cuIcuName(char *s, int * param)
+int Ipo_cuIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "Speed"))
- {
- *param = CU_SPEED;
- ok = 1;
- }
-
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "Speed" ) ) {
+ *param = CU_SPEED;
+ ok = 1;
+ }
+
+ return ok;
}
-int Ipo_coIcuName(char *s, int * param)
+int Ipo_coIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "Inf"))
- {
- *param = CO_ENFORCE;
- ok = 1;
- }
-
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "Inf" ) ) {
+ *param = CO_ENFORCE;
+ ok = 1;
+ }
+
+ return ok;
}
-int Ipo_acIcuName(char *s, int * param)
+int Ipo_acIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "LocX"))
- {
- *param = AC_LOC_X;
- ok = 1;
- }
- if (!strcmp (s, "LocY"))
- {
- *param = AC_LOC_Y;
- ok = 1;
- }
- if (!strcmp (s, "LocZ"))
- {
- *param = AC_LOC_Z;
- ok = 1;
- }
- if (!strcmp (s, "SizeX"))
- {
- *param = AC_SIZE_X;
- ok = 1;
- }
- if (!strcmp (s, "SizeY"))
- {
- *param = AC_SIZE_Y;
- ok = 1;
- }
- if (!strcmp (s, "SizeZ"))
- {
- *param = AC_SIZE_Z;
- ok = 1;
- }
- if (!strcmp (s, "QuatX"))
- {
- *param = AC_QUAT_X;
- ok = 1;
- }
- if (!strcmp (s, "QuatY"))
- {
- *param = AC_QUAT_Y;
- ok = 1;
- }
- if (!strcmp (s, "QuatZ"))
- {
- *param = AC_QUAT_Z;
- ok = 1;
- }
- if (!strcmp (s, "QuatW"))
- {
- *param = AC_QUAT_W;
- ok = 1;
- }
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "LocX" ) ) {
+ *param = AC_LOC_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "LocY" ) ) {
+ *param = AC_LOC_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "LocZ" ) ) {
+ *param = AC_LOC_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeX" ) ) {
+ *param = AC_SIZE_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeY" ) ) {
+ *param = AC_SIZE_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeZ" ) ) {
+ *param = AC_SIZE_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "QuatX" ) ) {
+ *param = AC_QUAT_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "QuatY" ) ) {
+ *param = AC_QUAT_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "QuatZ" ) ) {
+ *param = AC_QUAT_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "QuatW" ) ) {
+ *param = AC_QUAT_W;
+ ok = 1;
+ }
+ return ok;
}
-int Ipo_caIcuName(char * s, int * param)
+int Ipo_caIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "Lens"))
- {
- *param = CAM_LENS;
- ok = 1;
- }
- if (!strcmp (s, "ClSta"))
- {
- *param = CAM_STA;
- ok = 1;
- }
- if (!strcmp (s, "ClEnd"))
- {
- *param = CAM_END;
- ok = 1;
- }
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "Lens" ) ) {
+ *param = CAM_LENS;
+ ok = 1;
+ }
+ if( !strcmp( s, "ClSta" ) ) {
+ *param = CAM_STA;
+ ok = 1;
+ }
+ if( !strcmp( s, "ClEnd" ) ) {
+ *param = CAM_END;
+ ok = 1;
+ }
+ return ok;
}
-int Ipo_texIcuName(char * s, int * param)
+int Ipo_texIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "NSize"))
- {
- *param = TE_NSIZE;
- ok = 1;
- }
- if (!strcmp (s, "NDepth"))
- {
- *param = TE_NDEPTH;
- ok = 1;
- }
- if (!strcmp (s, "NType"))
- {
- *param = TE_NTYPE;
- ok = 1;
- }
- if (!strcmp (s, "Turb"))
- {
- *param = TE_TURB;
- ok = 1;
- }
- if (!strcmp (s, "Vnw1"))
- {
- *param = TE_VNW1;
- ok = 1;
- }
- if (!strcmp (s, "Vnw2"))
- {
- *param = TE_VNW2;
- ok = 1;
- }
- if (!strcmp (s, "Vnw3"))
- {
- *param = TE_VNW3;
- ok = 1;
- }
- if (!strcmp (s, "Vnw4"))
- {
- *param = TE_VNW4;
- ok = 1;
- }
- if (!strcmp (s, "MinkMExp"))
- {
- *param = TE_VNMEXP;
- ok = 1;
- }
- if (!strcmp (s, "DistM"))
- {
- *param = TE_VN_DISTM;
- ok = 1;
- }
- if (!strcmp (s, "ColT"))
- {
- *param = TE_VN_COLT;
- ok = 1;
- }
- if (!strcmp (s, "iScale"))
- {
- *param = TE_ISCA;
- ok = 1;
- }
- if (!strcmp (s, "DistA"))
- {
- *param = TE_DISTA;
- ok = 1;
- }
- if (!strcmp (s, "MgType"))
- {
- *param = TE_MG_TYP;
- ok = 1;
- }
- if (!strcmp (s, "MgH"))
- {
- *param = TE_MGH;
- ok = 1;
- }
- if (!strcmp (s, "Lacu"))
- {
- *param = TE_MG_LAC;
- ok = 1;
- }
- if (!strcmp (s, "Oct"))
- {
- *param = TE_MG_OCT;
- ok = 1;
- }
- if (!strcmp (s, "MgOff"))
- {
- *param = TE_MG_OFF;
- ok = 1;
- }
- if (!strcmp (s, "MgGain"))
- {
- *param = TE_MG_GAIN;
- ok = 1;
- }
- if (!strcmp (s, "NBase1"))
- {
- *param = TE_N_BAS1;
- ok = 1;
- }
- if (!strcmp (s, "NBase2"))
- {
- *param = TE_N_BAS2;
- ok = 1;
- }
-
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "NSize" ) ) {
+ *param = TE_NSIZE;
+ ok = 1;
+ }
+ if( !strcmp( s, "NDepth" ) ) {
+ *param = TE_NDEPTH;
+ ok = 1;
+ }
+ if( !strcmp( s, "NType" ) ) {
+ *param = TE_NTYPE;
+ ok = 1;
+ }
+ if( !strcmp( s, "Turb" ) ) {
+ *param = TE_TURB;
+ ok = 1;
+ }
+ if( !strcmp( s, "Vnw1" ) ) {
+ *param = TE_VNW1;
+ ok = 1;
+ }
+ if( !strcmp( s, "Vnw2" ) ) {
+ *param = TE_VNW2;
+ ok = 1;
+ }
+ if( !strcmp( s, "Vnw3" ) ) {
+ *param = TE_VNW3;
+ ok = 1;
+ }
+ if( !strcmp( s, "Vnw4" ) ) {
+ *param = TE_VNW4;
+ ok = 1;
+ }
+ if( !strcmp( s, "MinkMExp" ) ) {
+ *param = TE_VNMEXP;
+ ok = 1;
+ }
+ if( !strcmp( s, "DistM" ) ) {
+ *param = TE_VN_DISTM;
+ ok = 1;
+ }
+ if( !strcmp( s, "ColT" ) ) {
+ *param = TE_VN_COLT;
+ ok = 1;
+ }
+ if( !strcmp( s, "iScale" ) ) {
+ *param = TE_ISCA;
+ ok = 1;
+ }
+ if( !strcmp( s, "DistA" ) ) {
+ *param = TE_DISTA;
+ ok = 1;
+ }
+ if( !strcmp( s, "MgType" ) ) {
+ *param = TE_MG_TYP;
+ ok = 1;
+ }
+ if( !strcmp( s, "MgH" ) ) {
+ *param = TE_MGH;
+ ok = 1;
+ }
+ if( !strcmp( s, "Lacu" ) ) {
+ *param = TE_MG_LAC;
+ ok = 1;
+ }
+ if( !strcmp( s, "Oct" ) ) {
+ *param = TE_MG_OCT;
+ ok = 1;
+ }
+ if( !strcmp( s, "MgOff" ) ) {
+ *param = TE_MG_OFF;
+ ok = 1;
+ }
+ if( !strcmp( s, "MgGain" ) ) {
+ *param = TE_MG_GAIN;
+ ok = 1;
+ }
+ if( !strcmp( s, "NBase1" ) ) {
+ *param = TE_N_BAS1;
+ ok = 1;
+ }
+ if( !strcmp( s, "NBase2" ) ) {
+ *param = TE_N_BAS2;
+ ok = 1;
+ }
+
+ return ok;
}
-int Ipo_obIcuName(char * s, int * param)
+int Ipo_obIcuName( char *s, int *param )
{
- int ok = 0;
- if (!strcmp (s, "LocX"))
- {
- *param = OB_LOC_X;
- ok = 1;
- }
- if (!strcmp (s, "LocY"))
- {
- *param = OB_LOC_Y;
- ok = 1;
- }
- if (!strcmp (s, "LocZ"))
- {
- *param = OB_LOC_Z;
- ok = 1;
- }
- if (!strcmp (s, "RotX"))
- {
- *param = OB_ROT_X;
- ok = 1;
- }
- if (!strcmp (s, "RotY"))
- {
- *param = OB_ROT_Y;
- ok = 1;
- }
- if (!strcmp (s, "RotZ"))
- {
- *param = OB_ROT_Z;
- ok = 1;
- }
- if (!strcmp (s, "SizeX"))
- {
- *param = OB_SIZE_X;
- ok = 1;
- }
- if (!strcmp (s, "SizeY"))
- {
- *param = OB_SIZE_Y;
- ok = 1;
- }
- if (!strcmp (s, "SizeZ"))
- {
- *param = OB_SIZE_Z;
- ok = 1;
- }
-
- if (!strcmp (s, "dLocX"))
- {
- *param = OB_DLOC_X;
- ok = 1;
- }
- if (!strcmp (s, "dLocY"))
- {
- *param = OB_DLOC_Y;
- ok = 1;
- }
- if (!strcmp (s, "dLocZ"))
- {
- *param = OB_DLOC_Z;
- ok = 1;
- }
- if (!strcmp (s, "dRotX"))
- {
- *param = OB_DROT_X;
- ok = 1;
- }
- if (!strcmp (s, "dRotY"))
- {
- *param = OB_DROT_Y;
- ok = 1;
- }
- if (!strcmp (s, "dRotZ"))
- {
- *param = OB_DROT_Z;
- ok = 1;
- }
- if (!strcmp (s, "dSizeX"))
- {
- *param = OB_DSIZE_X;
- ok = 1;
- }
- if (!strcmp (s, "dSizeY"))
- {
- *param = OB_DSIZE_Y;
- ok = 1;
- }
- if (!strcmp (s, "dSizeZ"))
- {
- *param = OB_DSIZE_Z;
- ok = 1;
- }
-
- if (!strcmp (s, "Layer"))
- {
- *param = OB_LAY;
- ok = 1;
- }
- if (!strcmp (s, "Time"))
- {
- *param = OB_TIME;
- ok = 1;
- }
-
- if (!strcmp (s, "ColR"))
- {
- *param = OB_COL_R;
- ok = 1;
- }
- if (!strcmp (s, "ColG"))
- {
- *param = OB_COL_G;
- ok = 1;
- }
- if (!strcmp (s, "ColB"))
- {
- *param = OB_COL_B;
- ok = 1;
- }
- if (!strcmp (s, "ColA"))
- {
- *param = OB_COL_A;
- ok = 1;
- }
- if (!strcmp (s, "FStreng"))
- {
- *param = OB_PD_FSTR;
- ok = 1;
- }
- if (!strcmp (s, "FFall"))
- {
- *param = OB_PD_FFALL;
- ok = 1;
- }
- if (!strcmp (s, "Damping"))
- {
- *param = OB_PD_SDAMP;
- ok = 1;
- }
- if (!strcmp (s, "RDamp"))
- {
- *param = OB_PD_RDAMP;
- ok = 1;
- }
- if (!strcmp (s, "Perm"))
- {
- *param = OB_PD_PERM;
- ok = 1;
- }
-
- return ok;
+ int ok = 0;
+ if( !strcmp( s, "LocX" ) ) {
+ *param = OB_LOC_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "LocY" ) ) {
+ *param = OB_LOC_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "LocZ" ) ) {
+ *param = OB_LOC_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "RotX" ) ) {
+ *param = OB_ROT_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "RotY" ) ) {
+ *param = OB_ROT_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "RotZ" ) ) {
+ *param = OB_ROT_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeX" ) ) {
+ *param = OB_SIZE_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeY" ) ) {
+ *param = OB_SIZE_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "SizeZ" ) ) {
+ *param = OB_SIZE_Z;
+ ok = 1;
+ }
+
+ if( !strcmp( s, "dLocX" ) ) {
+ *param = OB_DLOC_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "dLocY" ) ) {
+ *param = OB_DLOC_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "dLocZ" ) ) {
+ *param = OB_DLOC_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "dRotX" ) ) {
+ *param = OB_DROT_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "dRotY" ) ) {
+ *param = OB_DROT_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "dRotZ" ) ) {
+ *param = OB_DROT_Z;
+ ok = 1;
+ }
+ if( !strcmp( s, "dSizeX" ) ) {
+ *param = OB_DSIZE_X;
+ ok = 1;
+ }
+ if( !strcmp( s, "dSizeY" ) ) {
+ *param = OB_DSIZE_Y;
+ ok = 1;
+ }
+ if( !strcmp( s, "dSizeZ" ) ) {
+ *param = OB_DSIZE_Z;
+ ok = 1;
+ }
+
+ if( !strcmp( s, "Layer" ) ) {
+ *param = OB_LAY;
+ ok = 1;
+ }
+ if( !strcmp( s, "Time" ) ) {
+ *param = OB_TIME;
+ ok = 1;
+ }
+
+ if( !strcmp( s, "ColR" ) ) {
+ *param = OB_COL_R;
+ ok = 1;
+ }
+ if( !strcmp( s, "ColG" ) ) {
+ *param = OB_COL_G;
+ ok = 1;
+ }
+ if( !strcmp( s, "ColB" ) ) {
+ *param = OB_COL_B;
+ ok = 1;
+ }
+ if( !strcmp( s, "ColA" ) ) {
+ *param = OB_COL_A;
+ ok = 1;
+ }
+ if( !strcmp( s, "FStreng" ) ) {
+ *param = OB_PD_FSTR;
+ ok = 1;
+ }
+ if( !strcmp( s, "FFall" ) ) {
+ *param = OB_PD_FFALL;
+ ok = 1;
+ }
+ if( !strcmp( s, "Damping" ) ) {
+ *param = OB_PD_SDAMP;
+ ok = 1;
+ }
+ if( !strcmp( s, "RDamp" ) ) {
+ *param = OB_PD_RDAMP;
+ ok = 1;
+ }
+ if( !strcmp( s, "Perm" ) ) {
+ *param = OB_PD_PERM;
+ ok = 1;
+ }
+
+ return ok;
}
-static PyObject *
-Ipo_addCurve (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
{
- IpoCurve *get_ipocurve (ID * from, short type, int adrcode, Ipo * useipo);
- void allspace (unsigned short event, short val);
- void allqueue (unsigned short event, short val);
- int param = 0, ok = 0, ipofound = 0;
- char *s = 0;
- Ipo *ipo = 0;
- IpoCurve *icu = 0;
- Link *link;
-
- if (!PyArg_ParseTuple (args, "s", &s))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
-
-
- link = G.main->ipo.first;
-
- while(link)
- {
- ipo = (Ipo *)link;
- if(ipo == self->ipo) {
- ipofound = 1;
- break;
- }
- link = link->next;
- }
-
- if(ipo && ipofound) {
- switch(ipo->blocktype) {
- case ID_OB:
- ok = Ipo_obIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_CA:
- ok = Ipo_caIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_LA:
- ok = Ipo_laIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_TE:
- ok = Ipo_texIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_WO:
- ok = Ipo_woIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_MA:
- ok = Ipo_maIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_AC:
- ok = Ipo_acIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case IPO_CO:
- ok = Ipo_coIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_CU:
- ok = Ipo_cuIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_KE:
- ok = Ipo_keIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- case ID_SEQ:
- ok = Ipo_seqIcuName(s, &param);
- icu = get_ipocurve (NULL, ipo->blocktype, param, self->ipo );
- break;
- }
- }
-
- if (icu==0) return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param."));
+ IpoCurve *get_ipocurve( ID * from, short type, int adrcode,
+ Ipo * useipo );
+ void allspace( unsigned short event, short val );
+ void allqueue( unsigned short event, short val );
+ int param = 0, ok = 0, ipofound = 0;
+ char *s = 0;
+ Ipo *ipo = 0;
+ IpoCurve *icu = 0;
+ Link *link;
+
+ if( !PyArg_ParseTuple( args, "s", &s ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
+
+
+ link = G.main->ipo.first;
+
+ while( link ) {
+ ipo = ( Ipo * ) link;
+ if( ipo == self->ipo ) {
+ ipofound = 1;
+ break;
+ }
+ link = link->next;
+ }
+
+ if( ipo && ipofound ) {
+ switch ( ipo->blocktype ) {
+ case ID_OB:
+ ok = Ipo_obIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_CA:
+ ok = Ipo_caIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_LA:
+ ok = Ipo_laIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_TE:
+ ok = Ipo_texIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_WO:
+ ok = Ipo_woIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_MA:
+ ok = Ipo_maIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_AC:
+ ok = Ipo_acIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case IPO_CO:
+ ok = Ipo_coIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_CU:
+ ok = Ipo_cuIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_KE:
+ ok = Ipo_keIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ case ID_SEQ:
+ ok = Ipo_seqIcuName( s, &param );
+ icu = get_ipocurve( NULL, ipo->blocktype, param,
+ self->ipo );
+ break;
+ }
+ }
+
+ if( icu == 0 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_ValueError, "Not a valid param." ) );
#define REMAKEIPO 1
#define REDRAWIPO 0x4023
- allspace (REMAKEIPO, 0);
- allqueue (REDRAWIPO, 0);
+ allspace( REMAKEIPO, 0 );
+ allqueue( REDRAWIPO, 0 );
- return IpoCurve_CreatePyObject (icu);
+ return IpoCurve_CreatePyObject( icu );
}
-static PyObject *
-Ipo_getCurve (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
{
- char *str, *str1;
- IpoCurve *icu = 0;
- if (!PyArg_ParseTuple (args, "s", &str))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
- for (icu = self->ipo->curve.first; icu; icu = icu->next)
- {
- str1 = GetIpoCurveName (icu);
- if (!strcmp (str1, str))
- return IpoCurve_CreatePyObject (icu);
- }
-
- Py_INCREF (Py_None);
- return Py_None;
+ char *str, *str1;
+ IpoCurve *icu = 0;
+ if( !PyArg_ParseTuple( args, "s", &str ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ str1 = GetIpoCurveName( icu );
+ if( !strcmp( str1, str ) )
+ return IpoCurve_CreatePyObject( icu );
+ }
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-char *
-GetIpoCurveName(IpoCurve * icu)
+char *GetIpoCurveName( IpoCurve * icu )
{
- switch (icu->blocktype)
- {
- case ID_MA:
- {
- return getname_mat_ei (icu->adrcode);
- }
- case ID_WO:
- {
- return getname_world_ei (icu->adrcode);
- }
- case ID_CA:
- {
- return getname_cam_ei (icu->adrcode);
- }
- case ID_OB:
- {
- return getname_ob_ei (icu->adrcode, 1); /* solve: what if EffX/Y/Z are wanted? */
- }
- case ID_TE:
- {
- return getname_tex_ei (icu->adrcode);
- }
- case ID_LA:
- {
- return getname_la_ei(icu->adrcode);
- }
- case ID_AC:
- {
- return getname_ac_ei(icu->adrcode);
- }
- case ID_CU:
- {
- return getname_cu_ei(icu->adrcode);
- }
- case ID_KE:
- {
- return getname_key_ei(icu->adrcode);
- }
- case ID_SEQ:
- {
- return getname_seq_ei(icu->adrcode);
- }
- case IPO_CO:
- {
- return getname_co_ei(icu->adrcode);
- }
- }
- return NULL;
+ switch ( icu->blocktype ) {
+ case ID_MA:
+ {
+ return getname_mat_ei( icu->adrcode );
+ }
+ case ID_WO:
+ {
+ return getname_world_ei( icu->adrcode );
+ }
+ case ID_CA:
+ {
+ return getname_cam_ei( icu->adrcode );
+ }
+ case ID_OB:
+ {
+ return getname_ob_ei( icu->adrcode, 1 ); /* solve: what if EffX/Y/Z are wanted? */
+ }
+ case ID_TE:
+ {
+ return getname_tex_ei( icu->adrcode );
+ }
+ case ID_LA:
+ {
+ return getname_la_ei( icu->adrcode );
+ }
+ case ID_AC:
+ {
+ return getname_ac_ei( icu->adrcode );
+ }
+ case ID_CU:
+ {
+ return getname_cu_ei( icu->adrcode );
+ }
+ case ID_KE:
+ {
+ return getname_key_ei( icu->adrcode );
+ }
+ case ID_SEQ:
+ {
+ return getname_seq_ei( icu->adrcode );
+ }
+ case IPO_CO:
+ {
+ return getname_co_ei( icu->adrcode );
+ }
+ }
+ return NULL;
}
-static PyObject *
-Ipo_getCurves (BPy_Ipo * self)
+static PyObject *Ipo_getCurves( BPy_Ipo * self )
{
- PyObject *attr = PyList_New (0);
- IpoCurve *icu;
- for (icu = self->ipo->curve.first; icu; icu = icu->next)
- {
- PyList_Append (attr, IpoCurve_CreatePyObject (icu));
- }
- return attr;
+ PyObject *attr = PyList_New( 0 );
+ IpoCurve *icu;
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ PyList_Append( attr, IpoCurve_CreatePyObject( icu ) );
+ }
+ return attr;
}
-static PyObject *
-Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args )
{
- int num = 0, i = 0;
- IpoCurve *icu = 0;
- if (!PyArg_ParseTuple (args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
- icu = icu->next;
-
- }
- return (PyInt_FromLong (icu->totvert));
+ int num = 0, i = 0;
+ IpoCurve *icu = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad curve number" ) );
+ icu = icu->next;
+
+ }
+ return ( PyInt_FromLong( icu->totvert ) );
}
-static PyObject *
-Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args )
{
- int num = 0, i = 0;
- IpoCurve *icu = 0;
- if (!PyArg_ParseTuple (args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
- icu = icu->next;
-
- }
- icu->totvert--;
- return (PyInt_FromLong (icu->totvert));
+ int num = 0, i = 0;
+ IpoCurve *icu = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad curve number" ) );
+ icu = icu->next;
+
+ }
+ icu->totvert--;
+ return ( PyInt_FromLong( icu->totvert ) );
}
-static PyObject *
-Ipo_getCurveBP (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args )
{
- struct BPoint *ptrbpoint;
- int num = 0, i;
- IpoCurve *icu;
- PyObject *l;
-
- if (!PyArg_ParseTuple (args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
- icu = icu->next;
-
- }
- ptrbpoint = icu->bp;
- if (!ptrbpoint)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "No base point");
-
- l = PyList_New (0);
- for (i = 0; i < 4; i++)
- PyList_Append (l, PyFloat_FromDouble (ptrbpoint->vec[i]));
- return l;
+ struct BPoint *ptrbpoint;
+ int num = 0, i;
+ IpoCurve *icu;
+ PyObject *l;
+
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad curve number" ) );
+ icu = icu->next;
+
+ }
+ ptrbpoint = icu->bp;
+ if( !ptrbpoint )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "No base point" );
+
+ l = PyList_New( 0 );
+ for( i = 0; i < 4; i++ )
+ PyList_Append( l, PyFloat_FromDouble( ptrbpoint->vec[i] ) );
+ return l;
}
-static PyObject *
-Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
{
- struct BezTriple *ptrbt;
- int num = 0, pos, i, j;
- IpoCurve *icu;
- PyObject *l = PyList_New (0);
-
- if (!PyArg_ParseTuple (args, "ii", &num, &pos))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
- icu = icu->next;
- }
- if (pos >= icu->totvert)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number");
-
- ptrbt = icu->bezt + pos;
- if (!ptrbt)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple");
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- PyList_Append (l, PyFloat_FromDouble (ptrbt->vec[i][j]));
- return l;
+ struct BezTriple *ptrbt;
+ int num = 0, pos, i, j;
+ IpoCurve *icu;
+ PyObject *l = PyList_New( 0 );
+
+ if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad ipo number" ) );
+ icu = icu->next;
+ }
+ if( pos >= icu->totvert )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Bad bezt number" );
+
+ ptrbt = icu->bezt + pos;
+ if( !ptrbt )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "No bez triple" );
+
+ for( i = 0; i < 3; i++ )
+ for( j = 0; j < 3; j++ )
+ PyList_Append( l,
+ PyFloat_FromDouble( ptrbt->
+ vec[i][j] ) );
+ return l;
}
-static PyObject *
-Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args )
{
- struct BezTriple *ptrbt;
- int num = 0, pos, i;
- IpoCurve *icu;
- PyObject *listargs = 0;
-
- if (!PyArg_ParseTuple (args, "iiO", &num, &pos, &listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected int int object argument"));
- if (!PyTuple_Check (listargs))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "3rd arg should be a tuple"));
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
- icu = icu->next;
- }
- if (pos >= icu->totvert)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number");
-
- ptrbt = icu->bezt + pos;
- if (!ptrbt)
- return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple");
-
- for (i = 0; i < 9; i++)
- {
- PyObject *xx = PyTuple_GetItem (listargs, i);
- ptrbt->vec[i / 3][i % 3] = PyFloat_AsDouble (xx);
- }
-
- Py_INCREF (Py_None);
- return Py_None;
+ struct BezTriple *ptrbt;
+ int num = 0, pos, i;
+ IpoCurve *icu;
+ PyObject *listargs = 0;
+
+ if( !PyArg_ParseTuple( args, "iiO", &num, &pos, &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected int int object argument" ) );
+ if( !PyTuple_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "3rd arg should be a tuple" ) );
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad ipo number" ) );
+ icu = icu->next;
+ }
+ if( pos >= icu->totvert )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Bad bezt number" );
+
+ ptrbt = icu->bezt + pos;
+ if( !ptrbt )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "No bez triple" );
+
+ for( i = 0; i < 9; i++ ) {
+ PyObject *xx = PyTuple_GetItem( listargs, i );
+ ptrbt->vec[i / 3][i % 3] = PyFloat_AsDouble( xx );
+ }
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args )
{
- float eval_icu (IpoCurve * icu, float ipotime);
+ float eval_icu( IpoCurve * icu, float ipotime );
- int num = 0, i;
- IpoCurve *icu;
- float time = 0;
+ int num = 0, i;
+ IpoCurve *icu;
+ float time = 0;
- if (!PyArg_ParseTuple (args, "if", &num, &time))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
+ if( !PyArg_ParseTuple( args, "if", &num, &time ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
- for (i = 0; i < num; i++)
- {
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
- icu = icu->next;
+ for( i = 0; i < num; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "Bad ipo number" ) );
+ icu = icu->next;
- }
- return PyFloat_FromDouble (eval_icu (icu, time));
+ }
+ return PyFloat_FromDouble( eval_icu( icu, time ) );
}
-static PyObject *
-Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args)
+static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args )
{
- int numcurve = 0, i;
- IpoCurve *icu;
- char *stringname = 0, *str1 = 0;
-
- icu = self->ipo->curve.first;
- if (!icu)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
-
- if (PyNumber_Check (PySequence_GetItem (args, 0))) // args is an integer
- {
- if (!PyArg_ParseTuple (args, "i", &numcurve))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected int or string argument"));
- for (i = 0; i < numcurve; i++)
+ int numcurve = 0, i;
+ IpoCurve *icu;
+ char *stringname = 0, *str1 = 0;
+
+ icu = self->ipo->curve.first;
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No IPO curve" ) );
+
+ if( PyNumber_Check( PySequence_GetItem( args, 0 ) ) ) // args is an integer
{
- if (!icu)
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "Bad ipo number"));
- icu = icu->next;
- }
- }
-
- else // args is a string
- {
- if (!PyArg_ParseTuple (args, "s", &stringname))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected int or string argument"));
- while (icu)
+ if( !PyArg_ParseTuple( args, "i", &numcurve ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected int or string argument" ) );
+ for( i = 0; i < numcurve; i++ ) {
+ if( !icu )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "Bad ipo number" ) );
+ icu = icu->next;
+ }
+ }
+
+ else // args is a string
{
- /*char str1[10];
- GetIpoCurveName (icu, str1);*/
- str1 = GetIpoCurveName(icu);
- if (!strcmp (str1, stringname))
- break;
- icu = icu->next;
- }
- }
-
- if (icu)
- return PyFloat_FromDouble (icu->curval);
- Py_INCREF (Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "s", &stringname ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected int or string argument" ) );
+ while( icu ) {
+ /*char str1[10];
+ GetIpoCurveName (icu, str1); */
+ str1 = GetIpoCurveName( icu );
+ if( !strcmp( str1, stringname ) )
+ break;
+ icu = icu->next;
+ }
+ }
+
+ if( icu )
+ return PyFloat_FromDouble( icu->curval );
+ Py_INCREF( Py_None );
+ return Py_None;
}
@@ -1537,10 +1427,9 @@ Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args)
/* Description: This is a callback function for the BPy_Ipo type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void
-IpoDeAlloc (BPy_Ipo * self)
+static void IpoDeAlloc( BPy_Ipo * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
@@ -1549,12 +1438,11 @@ IpoDeAlloc (BPy_Ipo * self)
/* the function that accesses BPy_Ipo "member variables" and */
/* methods. */
/*****************************************************************************/
-static PyObject *
-IpoGetAttr (BPy_Ipo * self, char *name)
+static PyObject *IpoGetAttr( BPy_Ipo * self, char *name )
{
- if (strcmp (name, "curves") == 0)
- return Ipo_getCurves (self);
- return Py_FindMethod (BPy_Ipo_methods, (PyObject *) self, name);
+ if( strcmp( name, "curves" ) == 0 )
+ return Ipo_getCurves( self );
+ return Py_FindMethod( BPy_Ipo_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
@@ -1562,10 +1450,9 @@ IpoGetAttr (BPy_Ipo * self, char *name)
/* Description: This is a callback function for the BPy_Ipo type. It is the */
/* function that sets Ipo Data attributes (member variables).*/
/*****************************************************************************/
-static int
-IpoSetAttr (BPy_Ipo * self, char *name, PyObject * value)
+static int IpoSetAttr( BPy_Ipo * self, char *name, PyObject * value )
{
- return 0; /* normal exit */
+ return 0; /* normal exit */
}
/*****************************************************************************/
@@ -1573,11 +1460,10 @@ IpoSetAttr (BPy_Ipo * self, char *name, PyObject * value)
/* Description: This is a callback function for the BPy_Ipo type. It */
/* builds a meaninful string to represent ipo objects. */
/*****************************************************************************/
-static PyObject *
-IpoRepr (BPy_Ipo * self)
+static PyObject *IpoRepr( BPy_Ipo * self )
{
- return PyString_FromFormat ("[Ipo \"%s\" %d]", self->ipo->id.name + 2,
- self->ipo->blocktype);
+ return PyString_FromFormat( "[Ipo \"%s\" %d]", self->ipo->id.name + 2,
+ self->ipo->blocktype );
}
/* Three Python Ipo_Type helper functions needed by the Object module: */
@@ -1587,16 +1473,15 @@ IpoRepr (BPy_Ipo * self)
/* Description: This function will create a new BPy_Ipo from an existing */
/* Blender ipo structure. */
/*****************************************************************************/
-PyObject *
-Ipo_CreatePyObject (Ipo * ipo)
+PyObject *Ipo_CreatePyObject( Ipo * ipo )
{
- BPy_Ipo *pyipo;
- pyipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type);
- if (!pyipo)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Ipo object");
- pyipo->ipo = ipo;
- return (PyObject *) pyipo;
+ BPy_Ipo *pyipo;
+ pyipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type );
+ if( !pyipo )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Ipo object" );
+ pyipo->ipo = ipo;
+ return ( PyObject * ) pyipo;
}
/*****************************************************************************/
@@ -1604,10 +1489,9 @@ Ipo_CreatePyObject (Ipo * ipo)
/* Description: This function returns true when the given PyObject is of the */
/* type Ipo. Otherwise it will return false. */
/*****************************************************************************/
-int
-Ipo_CheckPyObject (PyObject * pyobj)
+int Ipo_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Ipo_Type);
+ return ( pyobj->ob_type == &Ipo_Type );
}
/*****************************************************************************/
@@ -1615,8 +1499,7 @@ Ipo_CheckPyObject (PyObject * pyobj)
/* Description: This function returns the Blender ipo from the given */
/* PyObject. */
/*****************************************************************************/
-Ipo *
-Ipo_FromPyObject (PyObject * pyobj)
+Ipo *Ipo_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Ipo *) pyobj)->ipo;
+ return ( ( BPy_Ipo * ) pyobj )->ipo;
}
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
index 24b55e0480b..3974df722f0 100644
--- a/source/blender/python/api2_2x/Ipo.h
+++ b/source/blender/python/api2_2x/Ipo.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -38,12 +39,10 @@
/*****************************************************************************/
/* Python BPy_Ipo structure definition: */
/*****************************************************************************/
-typedef struct
-{
- PyObject_HEAD /* required macro */
- Ipo * ipo;
-}
-BPy_Ipo;
+typedef struct {
+ PyObject_HEAD /* required macro */
+ Ipo * ipo;
+} BPy_Ipo;
-#endif /* EXPP_IPO_H */
+#endif /* EXPP_IPO_H */
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index 3133233413e..6a9cc243c39 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -47,8 +47,8 @@
/*****************************************************************************/
/* Python API function prototypes for the IpoCurve module. */
/*****************************************************************************/
-static PyObject *M_IpoCurve_New (PyObject * self, PyObject * args);
-static PyObject *M_IpoCurve_Get (PyObject * self, PyObject * args);
+static PyObject *M_IpoCurve_New( PyObject * self, PyObject * args );
+static PyObject *M_IpoCurve_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -64,120 +64,123 @@ char M_IpoCurve_Get_doc[] = "";
/*****************************************************************************/
struct PyMethodDef M_IpoCurve_methods[] = {
- {"New", (PyCFunction) M_IpoCurve_New, METH_VARARGS | METH_KEYWORDS,
- M_IpoCurve_New_doc},
- {"Get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc},
- {"get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_IpoCurve_New, METH_VARARGS | METH_KEYWORDS,
+ M_IpoCurve_New_doc},
+ {"Get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc},
+ {"get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python C_IpoCurve methods declarations: */
/*****************************************************************************/
-static PyObject *IpoCurve_getName (C_IpoCurve * self);
-static PyObject *IpoCurve_Recalc (C_IpoCurve * self);
-static PyObject *IpoCurve_setName (C_IpoCurve * self, PyObject * args);
-static PyObject *IpoCurve_addBezier (C_IpoCurve * self, PyObject * args);
-static PyObject *IpoCurve_setInterpolation (C_IpoCurve * self,
- PyObject * args);
-static PyObject *IpoCurve_getInterpolation (C_IpoCurve * self);
-static PyObject *IpoCurve_setExtrapolation (C_IpoCurve * self,
- PyObject * args);
-static PyObject *IpoCurve_getExtrapolation (C_IpoCurve * self);
-static PyObject *IpoCurve_getPoints (C_IpoCurve * self);
-static int IpoCurve_setPoints (C_IpoCurve * self, PyObject * value);
-static PyObject *IpoCurve_evaluate (C_IpoCurve * self, PyObject * args);
+static PyObject *IpoCurve_getName( C_IpoCurve * self );
+static PyObject *IpoCurve_Recalc( C_IpoCurve * self );
+static PyObject *IpoCurve_setName( C_IpoCurve * self, PyObject * args );
+static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args );
+static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self,
+ PyObject * args );
+static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self );
+static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self,
+ PyObject * args );
+static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self );
+static PyObject *IpoCurve_getPoints( C_IpoCurve * self );
+static int IpoCurve_setPoints( C_IpoCurve * self, PyObject * value );
+static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args );
/*****************************************************************************/
/* Python C_IpoCurve methods table: */
/*****************************************************************************/
static PyMethodDef C_IpoCurve_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction) IpoCurve_getName, METH_NOARGS,
- "() - Return IpoCurve Data name"},
- {"Recalc", (PyCFunction) IpoCurve_Recalc, METH_NOARGS,
- "() - Return IpoCurve Data name"},
- {"update", (PyCFunction) IpoCurve_Recalc, METH_NOARGS,
- "() - Return IpoCurve Data name"},
- {"setName", (PyCFunction) IpoCurve_setName, METH_VARARGS,
- "(str) - Change IpoCurve Data name"},
- {"addBezier", (PyCFunction) IpoCurve_addBezier, METH_VARARGS,
- "(str) - Change IpoCurve Data name"},
- {"setInterpolation", (PyCFunction) IpoCurve_setInterpolation, METH_VARARGS,
- "(str) - Change IpoCurve Data name"},
- {"getInterpolation", (PyCFunction) IpoCurve_getInterpolation, METH_NOARGS,
- "(str) - Change IpoCurve Data name"},
- {"setExtrapolation", (PyCFunction) IpoCurve_setExtrapolation, METH_VARARGS,
- "(str) - Change IpoCurve Data name"},
- {"getExtrapolation", (PyCFunction) IpoCurve_getExtrapolation, METH_NOARGS,
- "(str) - Change IpoCurve Data name"},
- {"getPoints", (PyCFunction) IpoCurve_getPoints, METH_NOARGS,
- "(str) - Change IpoCurve Data name"},
- {"evaluate", (PyCFunction) IpoCurve_evaluate, METH_VARARGS,
- "(float) - Evaluate curve at given time"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) IpoCurve_getName, METH_NOARGS,
+ "() - Return IpoCurve Data name"},
+ {"Recalc", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS,
+ "() - Return IpoCurve Data name"},
+ {"update", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS,
+ "() - Return IpoCurve Data name"},
+ {"setName", ( PyCFunction ) IpoCurve_setName, METH_VARARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"addBezier", ( PyCFunction ) IpoCurve_addBezier, METH_VARARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"setInterpolation", ( PyCFunction ) IpoCurve_setInterpolation,
+ METH_VARARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"getInterpolation", ( PyCFunction ) IpoCurve_getInterpolation,
+ METH_NOARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"setExtrapolation", ( PyCFunction ) IpoCurve_setExtrapolation,
+ METH_VARARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"getExtrapolation", ( PyCFunction ) IpoCurve_getExtrapolation,
+ METH_NOARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"getPoints", ( PyCFunction ) IpoCurve_getPoints, METH_NOARGS,
+ "(str) - Change IpoCurve Data name"},
+ {"evaluate", ( PyCFunction ) IpoCurve_evaluate, METH_VARARGS,
+ "(float) - Evaluate curve at given time"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python IpoCurve_Type callback function prototypes: */
/*****************************************************************************/
-static void IpoCurveDeAlloc (C_IpoCurve * self);
+static void IpoCurveDeAlloc( C_IpoCurve * self );
//static int IpoCurvePrint (C_IpoCurve *self, FILE *fp, int flags);
-static int IpoCurveSetAttr (C_IpoCurve * self, char *name, PyObject * v);
-static PyObject *IpoCurveGetAttr (C_IpoCurve * self, char *name);
-static PyObject *IpoCurveRepr (C_IpoCurve * self);
+static int IpoCurveSetAttr( C_IpoCurve * self, char *name, PyObject * v );
+static PyObject *IpoCurveGetAttr( C_IpoCurve * self, char *name );
+static PyObject *IpoCurveRepr( C_IpoCurve * self );
/*****************************************************************************/
/* Python IpoCurve_Type structure definition: */
/*****************************************************************************/
PyTypeObject IpoCurve_Type = {
- PyObject_HEAD_INIT (NULL) /* required macro */
- 0, /* ob_size */
- "IpoCurve", /* tp_name */
- sizeof (C_IpoCurve), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) IpoCurveDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) IpoCurveGetAttr, /* tp_getattr */
- (setattrfunc) IpoCurveSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) IpoCurveRepr, /* 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,
- C_IpoCurve_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL ) /* required macro */
+ 0, /* ob_size */
+ "IpoCurve", /* tp_name */
+ sizeof( C_IpoCurve ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) IpoCurveDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) IpoCurveGetAttr, /* tp_getattr */
+ ( setattrfunc ) IpoCurveSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) IpoCurveRepr, /* 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,
+ C_IpoCurve_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
-/* Function: M_IpoCurve_New */
-/* Python equivalent: Blender.IpoCurve.New */
+/* Function: M_IpoCurve_New */
+/* Python equivalent: Blender.IpoCurve.New */
/*****************************************************************************/
-static PyObject *
-M_IpoCurve_New (PyObject * self, PyObject * args)
+static PyObject *M_IpoCurve_New( PyObject * self, PyObject * args )
{
- return 0;
+ return 0;
}
/*****************************************************************************/
/* Function: Ipo_Init */
/*****************************************************************************/
-PyObject *
-IpoCurve_Init (void)
+PyObject *IpoCurve_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- IpoCurve_Type.ob_type = &PyType_Type;
+ IpoCurve_Type.ob_type = &PyType_Type;
- submodule =
- Py_InitModule3 ("Blender.IpoCurve", M_IpoCurve_methods, M_IpoCurve_doc);
+ submodule =
+ Py_InitModule3( "Blender.IpoCurve", M_IpoCurve_methods,
+ M_IpoCurve_doc );
- return (submodule);
+ return ( submodule );
}
/*****************************************************************************/
@@ -188,336 +191,327 @@ IpoCurve_Init (void)
/* passed in, a list of all ipo data names in the */
/* current scene is returned. */
/*****************************************************************************/
-static PyObject *
-M_IpoCurve_Get (PyObject * self, PyObject * args)
+static PyObject *M_IpoCurve_Get( PyObject * self, PyObject * args )
{
- return 0;
+ return 0;
}
/*****************************************************************************/
/* Python C_IpoCurve methods: */
/*****************************************************************************/
-static PyObject *
-IpoCurve_setInterpolation (C_IpoCurve * self, PyObject * args)
+static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self,
+ PyObject * args )
{
- char *interpolationtype = 0;
- int id = -1;
- if (!PyArg_ParseTuple (args, "s", &interpolationtype))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
- if (!strcmp (interpolationtype, "Bezier"))
- id = IPO_BEZ;
- if (!strcmp (interpolationtype, "Constant"))
- id = IPO_CONST;
- if (!strcmp (interpolationtype, "Linear"))
- id = IPO_LIN;
- if (id == -1)
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "bad interpolation type"));
-
- self->ipocurve->ipo = id;
- Py_INCREF (Py_None);
- return Py_None;
+ char *interpolationtype = 0;
+ int id = -1;
+ if( !PyArg_ParseTuple( args, "s", &interpolationtype ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
+ if( !strcmp( interpolationtype, "Bezier" ) )
+ id = IPO_BEZ;
+ if( !strcmp( interpolationtype, "Constant" ) )
+ id = IPO_CONST;
+ if( !strcmp( interpolationtype, "Linear" ) )
+ id = IPO_LIN;
+ if( id == -1 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "bad interpolation type" ) );
+
+ self->ipocurve->ipo = id;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-IpoCurve_getInterpolation (C_IpoCurve * self)
+static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self )
{
- char *str = 0;
- IpoCurve *icu = self->ipocurve;
- if (icu->ipo == IPO_BEZ)
- str = "Bezier";
- if (icu->ipo == IPO_CONST)
- str = "Constant";
- if (icu->ipo == IPO_LIN)
- str = "Linear";
-
- if (!str)
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "unknown interpolation type"));
- return PyString_FromString (str);
+ char *str = 0;
+ IpoCurve *icu = self->ipocurve;
+ if( icu->ipo == IPO_BEZ )
+ str = "Bezier";
+ if( icu->ipo == IPO_CONST )
+ str = "Constant";
+ if( icu->ipo == IPO_LIN )
+ str = "Linear";
+
+ if( !str )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "unknown interpolation type" ) );
+ return PyString_FromString( str );
}
-static PyObject *
-IpoCurve_setExtrapolation (C_IpoCurve * self, PyObject * args)
+static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self,
+ PyObject * args )
{
- char *extrapolationtype = 0;
- int id = -1;
- if (!PyArg_ParseTuple (args, "s", &extrapolationtype))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected string argument"));
- if (!strcmp (extrapolationtype, "Constant"))
- id = 0;
- if (!strcmp (extrapolationtype, "Extrapolation"))
- id = 1;
- if (!strcmp (extrapolationtype, "Cyclic"))
- id = 2;
- if (!strcmp (extrapolationtype, "Cyclic_extrapolation"))
- id = 3;
-
- if (id == -1)
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "bad interpolation type"));
- self->ipocurve->extrap = id;
- Py_INCREF (Py_None);
- return Py_None;
+ char *extrapolationtype = 0;
+ int id = -1;
+ if( !PyArg_ParseTuple( args, "s", &extrapolationtype ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
+ if( !strcmp( extrapolationtype, "Constant" ) )
+ id = 0;
+ if( !strcmp( extrapolationtype, "Extrapolation" ) )
+ id = 1;
+ if( !strcmp( extrapolationtype, "Cyclic" ) )
+ id = 2;
+ if( !strcmp( extrapolationtype, "Cyclic_extrapolation" ) )
+ id = 3;
+
+ if( id == -1 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "bad interpolation type" ) );
+ self->ipocurve->extrap = id;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-IpoCurve_getExtrapolation (C_IpoCurve * self)
+static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self )
{
- char *str = 0;
- IpoCurve *icu = self->ipocurve;
- if (icu->extrap == 0)
- str = "Constant";
- if (icu->extrap == 1)
- str = "Extrapolation";
- if (icu->extrap == 2)
- str = "Cyclic";
- if (icu->extrap == 3)
- str = "Cyclic_extrapolation";
-
- return PyString_FromString (str);
+ char *str = 0;
+ IpoCurve *icu = self->ipocurve;
+ if( icu->extrap == 0 )
+ str = "Constant";
+ if( icu->extrap == 1 )
+ str = "Extrapolation";
+ if( icu->extrap == 2 )
+ str = "Cyclic";
+ if( icu->extrap == 3 )
+ str = "Cyclic_extrapolation";
+
+ return PyString_FromString( str );
}
-static PyObject *
-IpoCurve_addBezier (C_IpoCurve * self, PyObject * args)
+static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args )
{
- short MEM_freeN (void *vmemh);
- void *MEM_mallocN (unsigned int len, char *str);
- float x, y;
- int npoints;
- IpoCurve *icu;
- BezTriple *bzt, *tmp;
- static char name[10] = "mlml";
- PyObject *popo = 0;
- if (!PyArg_ParseTuple (args, "O", &popo))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected tuple argument"));
-
- x = PyFloat_AsDouble (PyTuple_GetItem (popo, 0));
- y = PyFloat_AsDouble (PyTuple_GetItem (popo, 1));
- icu = self->ipocurve;
- npoints = icu->totvert;
- tmp = icu->bezt;
- icu->bezt = MEM_mallocN (sizeof (BezTriple) * (npoints + 1), name);
- if (tmp)
- {
- memmove (icu->bezt, tmp, sizeof (BezTriple) * npoints);
- MEM_freeN (tmp);
- }
- memmove (icu->bezt + npoints, icu->bezt, sizeof (BezTriple));
- icu->totvert++;
- bzt = icu->bezt + npoints;
- bzt->vec[0][0] = x - 1;
- bzt->vec[1][0] = x;
- bzt->vec[2][0] = x + 1;
- bzt->vec[0][1] = y - 1;
- bzt->vec[1][1] = y;
- bzt->vec[2][1] = y + 1;
- /* set handle type to Auto */
- bzt->h1 = HD_AUTO;
- bzt->h2 = HD_AUTO;
-
- Py_INCREF (Py_None);
- return Py_None;
+ short MEM_freeN( void *vmemh );
+ void *MEM_mallocN( unsigned int len, char *str );
+ float x, y;
+ int npoints;
+ IpoCurve *icu;
+ BezTriple *bzt, *tmp;
+ static char name[10] = "mlml";
+ PyObject *popo = 0;
+ if( !PyArg_ParseTuple( args, "O", &popo ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected tuple argument" ) );
+
+ x = PyFloat_AsDouble( PyTuple_GetItem( popo, 0 ) );
+ y = PyFloat_AsDouble( PyTuple_GetItem( popo, 1 ) );
+ icu = self->ipocurve;
+ npoints = icu->totvert;
+ tmp = icu->bezt;
+ icu->bezt = MEM_mallocN( sizeof( BezTriple ) * ( npoints + 1 ), name );
+ if( tmp ) {
+ memmove( icu->bezt, tmp, sizeof( BezTriple ) * npoints );
+ MEM_freeN( tmp );
+ }
+ memmove( icu->bezt + npoints, icu->bezt, sizeof( BezTriple ) );
+ icu->totvert++;
+ bzt = icu->bezt + npoints;
+ bzt->vec[0][0] = x - 1;
+ bzt->vec[1][0] = x;
+ bzt->vec[2][0] = x + 1;
+ bzt->vec[0][1] = y - 1;
+ bzt->vec[1][1] = y;
+ bzt->vec[2][1] = y + 1;
+ /* set handle type to Auto */
+ bzt->h1 = HD_AUTO;
+ bzt->h2 = HD_AUTO;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-IpoCurve_setName (C_IpoCurve * self, PyObject * args)
+static PyObject *IpoCurve_setName( C_IpoCurve * self, PyObject * args )
{
- return 0;
+ return 0;
}
-static PyObject *
-IpoCurve_Recalc (C_IpoCurve * self)
+static PyObject *IpoCurve_Recalc( C_IpoCurve * self )
{
- IpoCurve *icu = self->ipocurve;
+ IpoCurve *icu = self->ipocurve;
- /* testhandles_ipocurve (icu); */
- /* call calchandles_* instead of testhandles_* */
- /* I'm not sure this is a complete solution but since we do not */
- /* deal with curve handles right now, it seems ok */
- calchandles_ipocurve (icu);
+ /* testhandles_ipocurve (icu); */
+ /* call calchandles_* instead of testhandles_* */
+ /* I'm not sure this is a complete solution but since we do not */
+ /* deal with curve handles right now, it seems ok */
+ calchandles_ipocurve( icu );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-IpoCurve_getName (C_IpoCurve * self)
+static PyObject *IpoCurve_getName( C_IpoCurve * self )
{
- switch (self->ipocurve->blocktype) {
- case ID_OB:
- return PyString_FromString(getname_ob_ei(self->ipocurve->adrcode, 1)); /* solve: what if EffX/Y/Z are wanted? */
- case ID_TE:
- return PyString_FromString(getname_tex_ei(self->ipocurve->adrcode));
- case ID_LA:
- return PyString_FromString(getname_la_ei(self->ipocurve->adrcode));
- case ID_MA:
- return PyString_FromString(getname_mat_ei(self->ipocurve->adrcode));
- case ID_CA:
- return PyString_FromString(getname_cam_ei(self->ipocurve->adrcode));
- case ID_WO:
- return PyString_FromString(getname_world_ei(self->ipocurve->adrcode));
- case ID_AC:
- return PyString_FromString(getname_ac_ei(self->ipocurve->adrcode));
- case ID_CU:
- return PyString_FromString(getname_cu_ei(self->ipocurve->adrcode));
- case ID_KE:
- return PyString_FromString(getname_key_ei(self->ipocurve->adrcode));
- case ID_SEQ:
- return PyString_FromString(getname_seq_ei(self->ipocurve->adrcode));
- case IPO_CO:
- return PyString_FromString(getname_co_ei(self->ipocurve->adrcode));
- default:
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "This function doesn't support this ipocurve type yet");
- }
-
- return PyString_FromString("");
+ switch ( self->ipocurve->blocktype ) {
+ case ID_OB:
+ return PyString_FromString( getname_ob_ei( self->ipocurve->adrcode, 1 ) ); /* solve: what if EffX/Y/Z are wanted? */
+ case ID_TE:
+ return PyString_FromString( getname_tex_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_LA:
+ return PyString_FromString( getname_la_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_MA:
+ return PyString_FromString( getname_mat_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_CA:
+ return PyString_FromString( getname_cam_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_WO:
+ return PyString_FromString( getname_world_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_AC:
+ return PyString_FromString( getname_ac_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_CU:
+ return PyString_FromString( getname_cu_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_KE:
+ return PyString_FromString( getname_key_ei
+ ( self->ipocurve->adrcode ) );
+ case ID_SEQ:
+ return PyString_FromString( getname_seq_ei
+ ( self->ipocurve->adrcode ) );
+ case IPO_CO:
+ return PyString_FromString( getname_co_ei
+ ( self->ipocurve->adrcode ) );
+ default:
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "This function doesn't support this ipocurve type yet" );
+ }
+
+ return PyString_FromString( "" );
}
-static void
-IpoCurveDeAlloc (C_IpoCurve * self)
+static void IpoCurveDeAlloc( C_IpoCurve * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *
-IpoCurve_getPoints (C_IpoCurve * self)
+static PyObject *IpoCurve_getPoints( C_IpoCurve * self )
{
- struct BezTriple *bezt;
- PyObject *po;
+ struct BezTriple *bezt;
+ PyObject *po;
- PyObject *list = PyList_New (0);
- int i;
+ PyObject *list = PyList_New( 0 );
+ int i;
- for (i = 0; i < self->ipocurve->totvert; i++)
- {
- bezt = self->ipocurve->bezt + i;
- po = BezTriple_CreatePyObject (bezt);
+ for( i = 0; i < self->ipocurve->totvert; i++ ) {
+ bezt = self->ipocurve->bezt + i;
+ po = BezTriple_CreatePyObject( bezt );
#if 0
- if (BezTriple_CheckPyObject (po))
- printf ("po is ok\n");
- else
- printf ("po is hosed\n");
+ if( BezTriple_CheckPyObject( po ) )
+ printf( "po is ok\n" );
+ else
+ printf( "po is hosed\n" );
#endif
- PyList_Append (list, po);
- /*
- PyList_Append( list, BezTriple_CreatePyObject(bezt));
- */
- }
- return list;
+ PyList_Append( list, po );
+ /*
+ PyList_Append( list, BezTriple_CreatePyObject(bezt));
+ */
+ }
+ return list;
}
-int
-IpoCurve_setPoints (C_IpoCurve * self, PyObject * value)
+int IpoCurve_setPoints( C_IpoCurve * self, PyObject * value )
{
- struct BezTriple *bezt;
- PyObject *l = PyList_New (0);
- int i;
- for (i = 0; i < self->ipocurve->totvert; i++)
- {
- bezt = self->ipocurve->bezt + i;
- PyList_Append (l, BezTriple_CreatePyObject (bezt));
- }
- return 0;
+ struct BezTriple *bezt;
+ PyObject *l = PyList_New( 0 );
+ int i;
+ for( i = 0; i < self->ipocurve->totvert; i++ ) {
+ bezt = self->ipocurve->bezt + i;
+ PyList_Append( l, BezTriple_CreatePyObject( bezt ) );
+ }
+ return 0;
}
/*****************************************************************************/
-/* Function: IpoCurveGetAttr */
-/* Description: This is a callback function for the C_IpoCurve type. It is */
-/* the function that accesses C_IpoCurve "member variables" and */
+/* Function: IpoCurveGetAttr */
+/* Description: This is a callback function for the C_IpoCurve type. It is */
+/* the function that accesses C_IpoCurve "member variables" and */
/* methods. */
/*****************************************************************************/
-static PyObject *
-IpoCurveGetAttr (C_IpoCurve * self, char *name)
+static PyObject *IpoCurveGetAttr( C_IpoCurve * self, char *name )
{
- if (strcmp (name, "bezierPoints") == 0)
- return IpoCurve_getPoints (self);
- if (strcmp (name, "name") == 0)
- return IpoCurve_getName (self);
- return Py_FindMethod (C_IpoCurve_methods, (PyObject *) self, name);
+ if( strcmp( name, "bezierPoints" ) == 0 )
+ return IpoCurve_getPoints( self );
+ if( strcmp( name, "name" ) == 0 )
+ return IpoCurve_getName( self );
+ return Py_FindMethod( C_IpoCurve_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
-/* Function: IpoCurveSetAttr */
-/* Description: This is a callback function for the C_IpoCurve type. It is the */
-/* function that sets IpoCurve Data attributes (member variables).*/
+/* Function: IpoCurveSetAttr */
+/* Description: This is a callback function for the C_IpoCurve type. It */
+/* sets IpoCurve Data attributes (member variables).*/
/*****************************************************************************/
-static int
-IpoCurveSetAttr (C_IpoCurve * self, char *name, PyObject * value)
+static int IpoCurveSetAttr( C_IpoCurve * self, char *name, PyObject * value )
{
- if (strcmp (name, "bezierPoints") == 0)
- return IpoCurve_setPoints (self, value);
- return 0; /* normal exit */
+ if( strcmp( name, "bezierPoints" ) == 0 )
+ return IpoCurve_setPoints( self, value );
+ return 0; /* normal exit */
}
/*****************************************************************************/
-/* Function: IpoCurveRepr */
-/* Description: This is a callback function for the C_IpoCurve type. It */
+/* Function: IpoCurveRepr */
+/* Description: This is a callback function for the C_IpoCurve type. It */
/* builds a meaninful string to represent ipo objects. */
/*****************************************************************************/
-static PyObject *
-IpoCurveRepr (C_IpoCurve * self)
+static PyObject *IpoCurveRepr( C_IpoCurve * self )
{
- void GetIpoCurveName (IpoCurve * icu, char *s);
- char s[100], s1[100];
- GetIpoCurveName (self->ipocurve, s1);
- sprintf (s, "IpoCurve %s \n", s1);
- return PyString_FromString (s);
+ void GetIpoCurveName( IpoCurve * icu, char *s );
+ char s[100], s1[100];
+ GetIpoCurveName( self->ipocurve, s1 );
+ sprintf( s, "IpoCurve %s \n", s1 );
+ return PyString_FromString( s );
}
/* Three Python IpoCurve_Type helper functions needed by the Object module: */
/*****************************************************************************/
-/* Function: IpoCurve_CreatePyObject */
-/* Description: This function will create a new C_IpoCurve from an existing */
+/* Function: IpoCurve_CreatePyObject */
+/* Description: This function will create a new C_IpoCurve from an existing */
/* Blender ipo structure. */
/*****************************************************************************/
-PyObject *
-IpoCurve_CreatePyObject (IpoCurve * ipo)
+PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo )
{
- C_IpoCurve *pyipo;
+ C_IpoCurve *pyipo;
- pyipo = (C_IpoCurve *) PyObject_NEW (C_IpoCurve, &IpoCurve_Type);
+ pyipo = ( C_IpoCurve * ) PyObject_NEW( C_IpoCurve, &IpoCurve_Type );
- if (!pyipo)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create C_IpoCurve object");
+ if( !pyipo )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create C_IpoCurve object" );
- pyipo->ipocurve = ipo;
+ pyipo->ipocurve = ipo;
- return (PyObject *) pyipo;
+ return ( PyObject * ) pyipo;
}
/*****************************************************************************/
-/* Function: IpoCurve_CheckPyObject */
+/* Function: IpoCurve_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type IpoCurve. Otherwise it will return false. */
+/* type IpoCurve. Otherwise it will return false. */
/*****************************************************************************/
-int
-IpoCurve_CheckPyObject (PyObject * pyobj)
+int IpoCurve_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &IpoCurve_Type);
+ return ( pyobj->ob_type == &IpoCurve_Type );
}
/*****************************************************************************/
-/* Function: IpoCurve_FromPyObject */
+/* Function: IpoCurve_FromPyObject */
/* Description: This function returns the Blender ipo from the given */
/* PyObject. */
/*****************************************************************************/
-IpoCurve *
-IpoCurve_FromPyObject (PyObject * pyobj)
+IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj )
{
- return ((C_IpoCurve *) pyobj)->ipocurve;
+ return ( ( C_IpoCurve * ) pyobj )->ipocurve;
}
/***************************************************************************/
@@ -525,20 +519,19 @@ IpoCurve_FromPyObject (PyObject * pyobj)
/* Description: Evaluates IPO curve at the given time. */
/***************************************************************************/
-static PyObject *
-IpoCurve_evaluate (C_IpoCurve * self, PyObject * args)
+static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args )
{
- float time = 0;
- double eval = 0;
+ float time = 0;
+ double eval = 0;
- /* expecting float */
- if (!PyArg_ParseTuple (args, "f", &time))
- return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected float argument"));
+ /* expecting float */
+ if( !PyArg_ParseTuple( args, "f", &time ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected float argument" ) );
- eval= (double)eval_icu(self->ipocurve, time);
+ eval = ( double ) eval_icu( self->ipocurve, time );
+
+ return PyFloat_FromDouble( eval );
- return PyFloat_FromDouble(eval);
-
}
diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h
index f0085f02009..4cac8796277 100644
--- a/source/blender/python/api2_2x/Ipocurve.h
+++ b/source/blender/python/api2_2x/Ipocurve.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -38,12 +39,10 @@
/*****************************************************************************/
/* Python C_IpoCurve structure definition: */
/*****************************************************************************/
-typedef struct
-{
- PyObject_HEAD /* required macro */
- IpoCurve * ipocurve;
-}
-C_IpoCurve;
+typedef struct {
+ PyObject_HEAD /* required macro */
+ IpoCurve * ipocurve;
+} C_IpoCurve;
-#endif /* EXPP_IPOCURVE_H */
+#endif /* EXPP_IPOCURVE_H */
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index 7f48ce53960..dc4e6f17159 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -43,7 +43,7 @@
#include "rgbTuple.h"
#include "gen_utils.h"
#include "modules.h"
-#include "bpy_types.h" /* for the BPy_Lamp declaration */
+#include "bpy_types.h" /* for the BPy_Lamp declaration */
/*****************************************************************************/
/* Python BPy_Lamp defaults: */
@@ -107,16 +107,16 @@
/*****************************************************************************/
/* Python API function prototypes for the Lamp module. */
/*****************************************************************************/
-static PyObject *M_Lamp_New (PyObject *self, PyObject *args, PyObject *keywords);
-static PyObject *M_Lamp_Get (PyObject *self, PyObject *args);
+static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Lamp_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Lamp.__doc__ */
/*****************************************************************************/
-static char M_Lamp_doc[] =
-"The Blender Lamp module\n\n\
+static char M_Lamp_doc[] = "The Blender Lamp module\n\n\
This module provides control over **Lamp Data** objects in Blender.\n\n\
Example::\n\n\
from Blender import Lamp\n\
@@ -125,12 +125,10 @@ Example::\n\n\
ob = Object.New('Lamp') # create new lamp object\n\
ob.link(l) # link lamp obj with lamp data\n";
-static char M_Lamp_New_doc[] =
-"Lamp.New (type = 'Lamp', name = 'LampData'):\n\
+static char M_Lamp_New_doc[] = "Lamp.New (type = 'Lamp', name = 'LampData'):\n\
Return a new Lamp Data object with the given type and name.";
-static char M_Lamp_Get_doc[] =
-"Lamp.Get (name = None):\n\
+static char M_Lamp_Get_doc[] = "Lamp.Get (name = None):\n\
Return the Lamp Data with the given name, None if not found, or\n\
Return a list with all Lamp Data objects in the current scene,\n\
if no argument was given.";
@@ -139,249 +137,250 @@ static char M_Lamp_Get_doc[] =
/* Python method structure definition for Blender.Lamp module: */
/*****************************************************************************/
struct PyMethodDef M_Lamp_methods[] = {
- {"New",(PyCFunction)M_Lamp_New, METH_VARARGS|METH_KEYWORDS,
- M_Lamp_New_doc},
- {"Get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
- {"get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Lamp_New, METH_VARARGS | METH_KEYWORDS,
+ M_Lamp_New_doc},
+ {"Get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
+ {"get", M_Lamp_Get, METH_VARARGS, M_Lamp_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Lamp methods declarations: */
/*****************************************************************************/
-static PyObject *Lamp_getName(BPy_Lamp *self);
-static PyObject *Lamp_getType(BPy_Lamp *self);
-static PyObject *Lamp_getMode(BPy_Lamp *self);
-static PyObject *Lamp_getSamples(BPy_Lamp *self);
-static PyObject *Lamp_getBufferSize(BPy_Lamp *self);
-static PyObject *Lamp_getHaloStep(BPy_Lamp *self);
-static PyObject *Lamp_getEnergy(BPy_Lamp *self);
-static PyObject *Lamp_getDist(BPy_Lamp *self);
-static PyObject *Lamp_getSpotSize(BPy_Lamp *self);
-static PyObject *Lamp_getSpotBlend(BPy_Lamp *self);
-static PyObject *Lamp_getClipStart(BPy_Lamp *self);
-static PyObject *Lamp_getClipEnd(BPy_Lamp *self);
-static PyObject *Lamp_getBias(BPy_Lamp *self);
-static PyObject *Lamp_getSoftness(BPy_Lamp *self);
-static PyObject *Lamp_getHaloInt(BPy_Lamp *self);
-static PyObject *Lamp_getQuad1(BPy_Lamp *self);
-static PyObject *Lamp_getQuad2(BPy_Lamp *self);
-static PyObject *Lamp_getCol(BPy_Lamp *self);
-static PyObject *Lamp_getIpo(BPy_Lamp *self);
-static PyObject *Lamp_clearIpo(BPy_Lamp *self);
-static PyObject *Lamp_setIpo(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
- PyObject *args);
-static PyObject *Lamp_getScriptLinks(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_addScriptLink(BPy_Lamp *self, PyObject *args);
-static PyObject *Lamp_clearScriptLinks(BPy_Lamp *self);
+static PyObject *Lamp_getName( BPy_Lamp * self );
+static PyObject *Lamp_getType( BPy_Lamp * self );
+static PyObject *Lamp_getMode( BPy_Lamp * self );
+static PyObject *Lamp_getSamples( BPy_Lamp * self );
+static PyObject *Lamp_getBufferSize( BPy_Lamp * self );
+static PyObject *Lamp_getHaloStep( BPy_Lamp * self );
+static PyObject *Lamp_getEnergy( BPy_Lamp * self );
+static PyObject *Lamp_getDist( BPy_Lamp * self );
+static PyObject *Lamp_getSpotSize( BPy_Lamp * self );
+static PyObject *Lamp_getSpotBlend( BPy_Lamp * self );
+static PyObject *Lamp_getClipStart( BPy_Lamp * self );
+static PyObject *Lamp_getClipEnd( BPy_Lamp * self );
+static PyObject *Lamp_getBias( BPy_Lamp * self );
+static PyObject *Lamp_getSoftness( BPy_Lamp * self );
+static PyObject *Lamp_getHaloInt( BPy_Lamp * self );
+static PyObject *Lamp_getQuad1( BPy_Lamp * self );
+static PyObject *Lamp_getQuad2( BPy_Lamp * self );
+static PyObject *Lamp_getCol( BPy_Lamp * self );
+static PyObject *Lamp_getIpo( BPy_Lamp * self );
+static PyObject *Lamp_clearIpo( BPy_Lamp * self );
+static PyObject *Lamp_setIpo( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setName( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setType( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setIntType( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setMode( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setIntMode( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setSamples( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setBufferSize( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setHaloStep( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setEnergy( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setDist( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setSpotSize( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setSpotBlend( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setClipStart( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setClipEnd( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setBias( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setSoftness( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setHaloInt( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setQuad1( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setQuad2( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setCol( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_setColorComponent( BPy_Lamp * self, char *key,
+ PyObject * args );
+static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args );
+static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self );
/*****************************************************************************/
/* Python BPy_Lamp methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Lamp_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
- "() - return Lamp name"},
- {"getType", (PyCFunction)Lamp_getType, METH_NOARGS,
- "() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3"},
- {"getMode", (PyCFunction)Lamp_getMode, METH_NOARGS,
- "() - return Lamp mode flags (or'ed value)"},
- {"getSamples", (PyCFunction)Lamp_getSamples, METH_NOARGS,
- "() - return Lamp samples value"},
- {"getBufferSize", (PyCFunction)Lamp_getBufferSize, METH_NOARGS,
- "() - return Lamp buffer size value"},
- {"getHaloStep", (PyCFunction)Lamp_getHaloStep, METH_NOARGS,
- "() - return Lamp halo step value"},
- {"getEnergy", (PyCFunction)Lamp_getEnergy, METH_NOARGS,
- "() - return Lamp energy value"},
- {"getDist", (PyCFunction)Lamp_getDist, METH_NOARGS,
- "() - return Lamp clipping distance value"},
- {"getSpotSize", (PyCFunction)Lamp_getSpotSize, METH_NOARGS,
- "() - return Lamp spot size value"},
- {"getSpotBlend", (PyCFunction)Lamp_getSpotBlend, METH_NOARGS,
- "() - return Lamp spot blend value"},
- {"getClipStart", (PyCFunction)Lamp_getClipStart, METH_NOARGS,
- "() - return Lamp clip start value"},
- {"getClipEnd", (PyCFunction)Lamp_getClipEnd, METH_NOARGS,
- "() - return Lamp clip end value"},
- {"getBias", (PyCFunction)Lamp_getBias, METH_NOARGS,
- "() - return Lamp bias value"},
- {"getSoftness", (PyCFunction)Lamp_getSoftness, METH_NOARGS,
- "() - return Lamp softness value"},
- {"getHaloInt", (PyCFunction)Lamp_getHaloInt, METH_NOARGS,
- "() - return Lamp halo intensity value"},
- {"getQuad1", (PyCFunction)Lamp_getQuad1, METH_NOARGS,
- "() - return light intensity value #1 for a Quad Lamp"},
- {"getQuad2", (PyCFunction)Lamp_getQuad2, METH_NOARGS,
- "() - return light intensity value #2 for a Quad Lamp"},
- {"getCol", (PyCFunction)Lamp_getCol, METH_NOARGS,
- "() - return light rgb color triplet"},
- {"setName", (PyCFunction)Lamp_setName, METH_VARARGS,
- "(str) - rename Lamp"},
- {"setType", (PyCFunction)Lamp_setType, METH_VARARGS,
- "(str) - change Lamp type, which can be 'persp' or 'ortho'"},
- {"setMode", (PyCFunction)Lamp_setMode, METH_VARARGS,
- "([up to eight str's]) - Set Lamp mode flag(s)"},
- {"setSamples", (PyCFunction)Lamp_setSamples, METH_VARARGS,
- "(int) - change Lamp samples value"},
- {"setBufferSize", (PyCFunction)Lamp_setBufferSize, METH_VARARGS,
- "(int) - change Lamp buffer size value"},
- {"setHaloStep", (PyCFunction)Lamp_setHaloStep, METH_VARARGS,
- "(int) - change Lamp halo step value"},
- {"setEnergy", (PyCFunction)Lamp_setEnergy, METH_VARARGS,
- "(float) - change Lamp energy value"},
- {"setDist", (PyCFunction)Lamp_setDist, METH_VARARGS,
- "(float) - change Lamp clipping distance value"},
- {"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
- "(float) - change Lamp spot size value"},
- {"setSpotBlend", (PyCFunction)Lamp_setSpotBlend, METH_VARARGS,
- "(float) - change Lamp spot blend value"},
- {"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
- "(float) - change Lamp clip start value"},
- {"setClipEnd", (PyCFunction)Lamp_setClipEnd, METH_VARARGS,
- "(float) - change Lamp clip end value"},
- {"setBias", (PyCFunction)Lamp_setBias, METH_VARARGS,
- "(float) - change Lamp draw size value"},
- {"setSoftness", (PyCFunction)Lamp_setSoftness, METH_VARARGS,
- "(float) - change Lamp softness value"},
- {"setHaloInt", (PyCFunction)Lamp_setHaloInt, METH_VARARGS,
- "(float) - change Lamp halo intensity value"},
- {"setQuad1", (PyCFunction)Lamp_setQuad1, METH_VARARGS,
- "(float) - change light intensity value #1 for a Quad Lamp"},
- {"setQuad2", (PyCFunction)Lamp_setQuad2, METH_VARARGS,
- "(float) - change light intensity value #2 for a Quad Lamp"},
- {"setCol", (PyCFunction)Lamp_setCol, METH_VARARGS,
- "(f,f,f) or ([f,f,f]) - change light's rgb color triplet"},
- {"getScriptLinks", (PyCFunction)Lamp_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this lamp's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", (PyCFunction)Lamp_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new lamp scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", (PyCFunction)Lamp_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this lamp."},
- {"getIpo", (PyCFunction)Lamp_getIpo, METH_NOARGS,
- "() - get IPO for this lamp"},
- {"clearIpo", (PyCFunction)Lamp_clearIpo, METH_NOARGS,
- "() - unlink the IPO for this lamp"},
- {"setIpo", (PyCFunction)Lamp_setIpo, METH_VARARGS,
- "( lamp-ipo ) - link an IPO to this lamp"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Lamp_getName, METH_NOARGS,
+ "() - return Lamp name"},
+ {"getType", ( PyCFunction ) Lamp_getType, METH_NOARGS,
+ "() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3"},
+ {"getMode", ( PyCFunction ) Lamp_getMode, METH_NOARGS,
+ "() - return Lamp mode flags (or'ed value)"},
+ {"getSamples", ( PyCFunction ) Lamp_getSamples, METH_NOARGS,
+ "() - return Lamp samples value"},
+ {"getBufferSize", ( PyCFunction ) Lamp_getBufferSize, METH_NOARGS,
+ "() - return Lamp buffer size value"},
+ {"getHaloStep", ( PyCFunction ) Lamp_getHaloStep, METH_NOARGS,
+ "() - return Lamp halo step value"},
+ {"getEnergy", ( PyCFunction ) Lamp_getEnergy, METH_NOARGS,
+ "() - return Lamp energy value"},
+ {"getDist", ( PyCFunction ) Lamp_getDist, METH_NOARGS,
+ "() - return Lamp clipping distance value"},
+ {"getSpotSize", ( PyCFunction ) Lamp_getSpotSize, METH_NOARGS,
+ "() - return Lamp spot size value"},
+ {"getSpotBlend", ( PyCFunction ) Lamp_getSpotBlend, METH_NOARGS,
+ "() - return Lamp spot blend value"},
+ {"getClipStart", ( PyCFunction ) Lamp_getClipStart, METH_NOARGS,
+ "() - return Lamp clip start value"},
+ {"getClipEnd", ( PyCFunction ) Lamp_getClipEnd, METH_NOARGS,
+ "() - return Lamp clip end value"},
+ {"getBias", ( PyCFunction ) Lamp_getBias, METH_NOARGS,
+ "() - return Lamp bias value"},
+ {"getSoftness", ( PyCFunction ) Lamp_getSoftness, METH_NOARGS,
+ "() - return Lamp softness value"},
+ {"getHaloInt", ( PyCFunction ) Lamp_getHaloInt, METH_NOARGS,
+ "() - return Lamp halo intensity value"},
+ {"getQuad1", ( PyCFunction ) Lamp_getQuad1, METH_NOARGS,
+ "() - return light intensity value #1 for a Quad Lamp"},
+ {"getQuad2", ( PyCFunction ) Lamp_getQuad2, METH_NOARGS,
+ "() - return light intensity value #2 for a Quad Lamp"},
+ {"getCol", ( PyCFunction ) Lamp_getCol, METH_NOARGS,
+ "() - return light rgb color triplet"},
+ {"setName", ( PyCFunction ) Lamp_setName, METH_VARARGS,
+ "(str) - rename Lamp"},
+ {"setType", ( PyCFunction ) Lamp_setType, METH_VARARGS,
+ "(str) - change Lamp type, which can be 'persp' or 'ortho'"},
+ {"setMode", ( PyCFunction ) Lamp_setMode, METH_VARARGS,
+ "([up to eight str's]) - Set Lamp mode flag(s)"},
+ {"setSamples", ( PyCFunction ) Lamp_setSamples, METH_VARARGS,
+ "(int) - change Lamp samples value"},
+ {"setBufferSize", ( PyCFunction ) Lamp_setBufferSize, METH_VARARGS,
+ "(int) - change Lamp buffer size value"},
+ {"setHaloStep", ( PyCFunction ) Lamp_setHaloStep, METH_VARARGS,
+ "(int) - change Lamp halo step value"},
+ {"setEnergy", ( PyCFunction ) Lamp_setEnergy, METH_VARARGS,
+ "(float) - change Lamp energy value"},
+ {"setDist", ( PyCFunction ) Lamp_setDist, METH_VARARGS,
+ "(float) - change Lamp clipping distance value"},
+ {"setSpotSize", ( PyCFunction ) Lamp_setSpotSize, METH_VARARGS,
+ "(float) - change Lamp spot size value"},
+ {"setSpotBlend", ( PyCFunction ) Lamp_setSpotBlend, METH_VARARGS,
+ "(float) - change Lamp spot blend value"},
+ {"setClipStart", ( PyCFunction ) Lamp_setClipStart, METH_VARARGS,
+ "(float) - change Lamp clip start value"},
+ {"setClipEnd", ( PyCFunction ) Lamp_setClipEnd, METH_VARARGS,
+ "(float) - change Lamp clip end value"},
+ {"setBias", ( PyCFunction ) Lamp_setBias, METH_VARARGS,
+ "(float) - change Lamp draw size value"},
+ {"setSoftness", ( PyCFunction ) Lamp_setSoftness, METH_VARARGS,
+ "(float) - change Lamp softness value"},
+ {"setHaloInt", ( PyCFunction ) Lamp_setHaloInt, METH_VARARGS,
+ "(float) - change Lamp halo intensity value"},
+ {"setQuad1", ( PyCFunction ) Lamp_setQuad1, METH_VARARGS,
+ "(float) - change light intensity value #1 for a Quad Lamp"},
+ {"setQuad2", ( PyCFunction ) Lamp_setQuad2, METH_VARARGS,
+ "(float) - change light intensity value #2 for a Quad Lamp"},
+ {"setCol", ( PyCFunction ) Lamp_setCol, METH_VARARGS,
+ "(f,f,f) or ([f,f,f]) - change light's rgb color triplet"},
+ {"getScriptLinks", ( PyCFunction ) Lamp_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this lamp's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) Lamp_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new lamp scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) Lamp_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this lamp."},
+ {"getIpo", ( PyCFunction ) Lamp_getIpo, METH_NOARGS,
+ "() - get IPO for this lamp"},
+ {"clearIpo", ( PyCFunction ) Lamp_clearIpo, METH_NOARGS,
+ "() - unlink the IPO for this lamp"},
+ {"setIpo", ( PyCFunction ) Lamp_setIpo, METH_VARARGS,
+ "( lamp-ipo ) - link an IPO to this lamp"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python TypeLamp callback function prototypes: */
/*****************************************************************************/
-static void Lamp_dealloc (BPy_Lamp *lamp);
-static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
-static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
-static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
-static PyObject *Lamp_repr (BPy_Lamp *lamp);
+static void Lamp_dealloc( BPy_Lamp * lamp );
+static PyObject *Lamp_getAttr( BPy_Lamp * lamp, char *name );
+static int Lamp_setAttr( BPy_Lamp * lamp, char *name, PyObject * v );
+static int Lamp_compare( BPy_Lamp * a, BPy_Lamp * b );
+static PyObject *Lamp_repr( BPy_Lamp * lamp );
/*****************************************************************************/
/* Python TypeLamp structure definition: */
/*****************************************************************************/
-PyTypeObject Lamp_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Lamp", /* tp_name */
- sizeof (BPy_Lamp), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Lamp_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Lamp_getAttr, /* tp_getattr */
- (setattrfunc)Lamp_setAttr, /* tp_setattr */
- (cmpfunc)Lamp_compare, /* tp_compare */
- (reprfunc)Lamp_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_Lamp_methods, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject Lamp_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Lamp", /* tp_name */
+ sizeof( BPy_Lamp ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Lamp_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Lamp_getAttr, /* tp_getattr */
+ ( setattrfunc ) Lamp_setAttr, /* tp_setattr */
+ ( cmpfunc ) Lamp_compare, /* tp_compare */
+ ( reprfunc ) Lamp_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_Lamp_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
/* Function: M_Lamp_New */
/* Python equivalent: Blender.Lamp.New */
/*****************************************************************************/
-static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
+static PyObject *M_Lamp_New( PyObject * self, PyObject * args,
+ PyObject * keywords )
{
- char *type_str = "Lamp";
- char *name_str = "LampData";
- static char *kwlist[] = {"type_str", "name_str", NULL};
- BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
- Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
- char buf[21];
-
- if (!PyArg_ParseTupleAndKeywords(args, keywords, "|ss", kwlist,
- &type_str, &name_str))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string(s) or empty argument"));
-
- bl_lamp = add_lamp(); /* first create in Blender */
- if (bl_lamp) /* now create the wrapper obj in Python */
- py_lamp = (BPy_Lamp *)Lamp_CreatePyObject(bl_lamp);
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Lamp Data in Blender"));
+ char *type_str = "Lamp";
+ char *name_str = "LampData";
+ static char *kwlist[] = { "type_str", "name_str", NULL };
+ BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
+ Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
+ char buf[21];
+
+ if( !PyArg_ParseTupleAndKeywords( args, keywords, "|ss", kwlist,
+ &type_str, &name_str ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string(s) or empty argument" ) );
+
+ bl_lamp = add_lamp( ); /* first create in Blender */
+ if( bl_lamp ) /* now create the wrapper obj in Python */
+ py_lamp = ( BPy_Lamp * ) Lamp_CreatePyObject( bl_lamp );
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Lamp Data in Blender" ) );
/* let's return user count to zero, because ... */
- bl_lamp->id.us = 0; /* ... add_lamp() incref'ed it */
-
- if (py_lamp == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Lamp Data object"));
-
- if (strcmp (type_str, "Lamp") == 0)
- bl_lamp->type = (short)EXPP_LAMP_TYPE_LAMP;
- else if (strcmp (type_str, "Sun") == 0)
- bl_lamp->type = (short)EXPP_LAMP_TYPE_SUN;
- else if (strcmp (type_str, "Spot") == 0)
- bl_lamp->type = (short)EXPP_LAMP_TYPE_SPOT;
- else if (strcmp (type_str, "Hemi") == 0)
- bl_lamp->type = (short)EXPP_LAMP_TYPE_HEMI;
- else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown lamp type"));
-
- if (strcmp(name_str, "LampData") == 0)
- return (PyObject *)py_lamp;
- else { /* user gave us a name for the lamp, use it */
- PyOS_snprintf(buf, sizeof(buf), "%s", name_str);
- rename_id(&bl_lamp->id, buf);
- }
-
- return (PyObject *)py_lamp;
+ bl_lamp->id.us = 0; /* ... add_lamp() incref'ed it */
+
+ if( py_lamp == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Lamp Data object" ) );
+
+ if( strcmp( type_str, "Lamp" ) == 0 )
+ bl_lamp->type = ( short ) EXPP_LAMP_TYPE_LAMP;
+ else if( strcmp( type_str, "Sun" ) == 0 )
+ bl_lamp->type = ( short ) EXPP_LAMP_TYPE_SUN;
+ else if( strcmp( type_str, "Spot" ) == 0 )
+ bl_lamp->type = ( short ) EXPP_LAMP_TYPE_SPOT;
+ else if( strcmp( type_str, "Hemi" ) == 0 )
+ bl_lamp->type = ( short ) EXPP_LAMP_TYPE_HEMI;
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown lamp type" ) );
+
+ if( strcmp( name_str, "LampData" ) == 0 )
+ return ( PyObject * ) py_lamp;
+ else { /* user gave us a name for the lamp, use it */
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name_str );
+ rename_id( &bl_lamp->id, buf );
+ }
+
+ return ( PyObject * ) py_lamp;
}
/*****************************************************************************/
@@ -392,127 +391,145 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
/* passed in, a list of all lamp data names in the */
/* current scene is returned. */
/*****************************************************************************/
-static PyObject *M_Lamp_Get(PyObject *self, PyObject *args)
+static PyObject *M_Lamp_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
- Lamp *lamp_iter;
+ char *name = NULL;
+ Lamp *lamp_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
- lamp_iter = G.main->lamp.first;
+ lamp_iter = G.main->lamp.first;
- if (name) { /* (name) - Search lamp by name */
+ if( name ) { /* (name) - Search lamp by name */
- BPy_Lamp *wanted_lamp = NULL;
+ BPy_Lamp *wanted_lamp = NULL;
- while ((lamp_iter) && (wanted_lamp == NULL)) {
+ while( ( lamp_iter ) && ( wanted_lamp == NULL ) ) {
- if (strcmp (name, lamp_iter->id.name+2) == 0)
- wanted_lamp = (BPy_Lamp *)Lamp_CreatePyObject(lamp_iter);
+ if( strcmp( name, lamp_iter->id.name + 2 ) == 0 )
+ wanted_lamp =
+ ( BPy_Lamp * )
+ Lamp_CreatePyObject( lamp_iter );
- lamp_iter = lamp_iter->id.next;
- }
+ lamp_iter = lamp_iter->id.next;
+ }
- if (wanted_lamp == NULL) { /* Requested lamp doesn't exist */
- char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Lamp \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ if( wanted_lamp == NULL ) { /* Requested lamp doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Lamp \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+ }
- return (PyObject *)wanted_lamp;
- }
+ return ( PyObject * ) wanted_lamp;
+ }
- else { /* () - return a list of all lamps in the scene */
- int index = 0;
- PyObject *lamplist, *pyobj;
+ else { /* () - return a list of all lamps in the scene */
+ int index = 0;
+ PyObject *lamplist, *pyobj;
- lamplist = PyList_New (BLI_countlist (&(G.main->lamp)));
+ lamplist = PyList_New( BLI_countlist( &( G.main->lamp ) ) );
- if (lamplist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( lamplist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (lamp_iter) {
- pyobj = Lamp_CreatePyObject (lamp_iter);
+ while( lamp_iter ) {
+ pyobj = Lamp_CreatePyObject( lamp_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- PyList_SET_ITEM (lamplist, index, pyobj);
+ PyList_SET_ITEM( lamplist, index, pyobj );
- lamp_iter = lamp_iter->id.next;
- index++;
- }
+ lamp_iter = lamp_iter->id.next;
+ index++;
+ }
- return lamplist;
- }
+ return lamplist;
+ }
}
-static PyObject *Lamp_TypesDict (void)
-{ /* create the Blender.Lamp.Types constant dict */
- PyObject *Types = M_constant_New();
+static PyObject *Lamp_TypesDict( void )
+{ /* create the Blender.Lamp.Types constant dict */
+ PyObject *Types = M_constant_New( );
- if (Types) {
- BPy_constant *c = (BPy_constant *)Types;
+ if( Types ) {
+ BPy_constant *c = ( BPy_constant * ) Types;
- constant_insert (c, "Lamp", PyInt_FromLong (EXPP_LAMP_TYPE_LAMP));
- constant_insert (c, "Sun", PyInt_FromLong (EXPP_LAMP_TYPE_SUN));
- constant_insert (c, "Spot", PyInt_FromLong (EXPP_LAMP_TYPE_SPOT));
- constant_insert (c, "Hemi", PyInt_FromLong (EXPP_LAMP_TYPE_HEMI));
+ constant_insert( c, "Lamp",
+ PyInt_FromLong( EXPP_LAMP_TYPE_LAMP ) );
+ constant_insert( c, "Sun",
+ PyInt_FromLong( EXPP_LAMP_TYPE_SUN ) );
+ constant_insert( c, "Spot",
+ PyInt_FromLong( EXPP_LAMP_TYPE_SPOT ) );
+ constant_insert( c, "Hemi",
+ PyInt_FromLong( EXPP_LAMP_TYPE_HEMI ) );
- }
+ }
- return Types;
+ return Types;
}
-static PyObject *Lamp_ModesDict (void)
-{ /* create the Blender.Lamp.Modes constant dict */
- PyObject *Modes = M_constant_New();
-
- if (Modes) {
- BPy_constant *c = (BPy_constant *)Modes;
-
- constant_insert (c, "Shadows", PyInt_FromLong (EXPP_LAMP_MODE_SHADOWS));
- constant_insert (c, "Halo", PyInt_FromLong (EXPP_LAMP_MODE_HALO));
- constant_insert (c, "Layer", PyInt_FromLong (EXPP_LAMP_MODE_LAYER));
- constant_insert (c, "Quad", PyInt_FromLong (EXPP_LAMP_MODE_QUAD));
- constant_insert (c, "Negative", PyInt_FromLong (EXPP_LAMP_MODE_NEGATIVE));
- constant_insert (c, "Sphere", PyInt_FromLong (EXPP_LAMP_MODE_SPHERE));
- constant_insert (c, "Square", PyInt_FromLong (EXPP_LAMP_MODE_SQUARE));
- constant_insert (c, "OnlyShadow",
- PyInt_FromLong (EXPP_LAMP_MODE_ONLYSHADOW));
- constant_insert (c, "NoDiffuse",
- PyInt_FromLong (EXPP_LAMP_MODE_NODIFFUSE));
- constant_insert (c, "NoSpecular",
- PyInt_FromLong (EXPP_LAMP_MODE_NOSPECULAR));
- }
-
- return Modes;
+static PyObject *Lamp_ModesDict( void )
+{ /* create the Blender.Lamp.Modes constant dict */
+ PyObject *Modes = M_constant_New( );
+
+ if( Modes ) {
+ BPy_constant *c = ( BPy_constant * ) Modes;
+
+ constant_insert( c, "Shadows",
+ PyInt_FromLong( EXPP_LAMP_MODE_SHADOWS ) );
+ constant_insert( c, "Halo",
+ PyInt_FromLong( EXPP_LAMP_MODE_HALO ) );
+ constant_insert( c, "Layer",
+ PyInt_FromLong( EXPP_LAMP_MODE_LAYER ) );
+ constant_insert( c, "Quad",
+ PyInt_FromLong( EXPP_LAMP_MODE_QUAD ) );
+ constant_insert( c, "Negative",
+ PyInt_FromLong( EXPP_LAMP_MODE_NEGATIVE ) );
+ constant_insert( c, "Sphere",
+ PyInt_FromLong( EXPP_LAMP_MODE_SPHERE ) );
+ constant_insert( c, "Square",
+ PyInt_FromLong( EXPP_LAMP_MODE_SQUARE ) );
+ constant_insert( c, "OnlyShadow",
+ PyInt_FromLong( EXPP_LAMP_MODE_ONLYSHADOW ) );
+ constant_insert( c, "NoDiffuse",
+ PyInt_FromLong( EXPP_LAMP_MODE_NODIFFUSE ) );
+ constant_insert( c, "NoSpecular",
+ PyInt_FromLong( EXPP_LAMP_MODE_NOSPECULAR ) );
+ }
+
+ return Modes;
}
/*****************************************************************************/
/* Function: Lamp_Init */
/*****************************************************************************/
/* Needed by the Blender module, to register the Blender.Lamp submodule */
-PyObject *Lamp_Init (void)
+PyObject *Lamp_Init( void )
{
- PyObject *submodule, *Types, *Modes;
+ PyObject *submodule, *Types, *Modes;
- Lamp_Type.ob_type = &PyType_Type;
+ Lamp_Type.ob_type = &PyType_Type;
- Types = Lamp_TypesDict ();
- Modes = Lamp_ModesDict ();
+ Types = Lamp_TypesDict( );
+ Modes = Lamp_ModesDict( );
- submodule = Py_InitModule3("Blender.Lamp", M_Lamp_methods, M_Lamp_doc);
+ submodule =
+ Py_InitModule3( "Blender.Lamp", M_Lamp_methods, M_Lamp_doc );
- if (Types) PyModule_AddObject(submodule, "Types", Types);
- if (Modes) PyModule_AddObject(submodule, "Modes", Modes);
+ if( Types )
+ PyModule_AddObject( submodule, "Types", Types );
+ if( Modes )
+ PyModule_AddObject( submodule, "Modes", Modes );
- return submodule;
+ return submodule;
}
/* Three Python Lamp_Type helper functions needed by the Object module: */
@@ -522,26 +539,26 @@ PyObject *Lamp_Init (void)
/* Description: This function will create a new BPy_Lamp from an existing */
/* Blender lamp structure. */
/*****************************************************************************/
-PyObject *Lamp_CreatePyObject (Lamp *lamp)
+PyObject *Lamp_CreatePyObject( Lamp * lamp )
{
- BPy_Lamp *pylamp;
- float *rgb[3];
+ BPy_Lamp *pylamp;
+ float *rgb[3];
- pylamp = (BPy_Lamp *)PyObject_NEW (BPy_Lamp, &Lamp_Type);
+ pylamp = ( BPy_Lamp * ) PyObject_NEW( BPy_Lamp, &Lamp_Type );
- if (!pylamp)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Lamp object");
+ if( !pylamp )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Lamp object" );
- pylamp->lamp = lamp;
+ pylamp->lamp = lamp;
- rgb[0] = &lamp->r;
- rgb[1] = &lamp->g;
- rgb[2] = &lamp->b;
+ rgb[0] = &lamp->r;
+ rgb[1] = &lamp->g;
+ rgb[2] = &lamp->b;
- pylamp->color = (BPy_rgbTuple *)rgbTuple_New(rgb);
+ pylamp->color = ( BPy_rgbTuple * ) rgbTuple_New( rgb );
- return (PyObject *)pylamp;
+ return ( PyObject * ) pylamp;
}
/*****************************************************************************/
@@ -549,9 +566,9 @@ PyObject *Lamp_CreatePyObject (Lamp *lamp)
/* Description: This function returns true when the given PyObject is of the */
/* type Lamp. Otherwise it will return false. */
/*****************************************************************************/
-int Lamp_CheckPyObject (PyObject *pyobj)
+int Lamp_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Lamp_Type);
+ return ( pyobj->ob_type == &Lamp_Type );
}
/*****************************************************************************/
@@ -559,9 +576,9 @@ int Lamp_CheckPyObject (PyObject *pyobj)
/* Description: This function returns the Blender lamp from the given */
/* PyObject. */
/*****************************************************************************/
-Lamp *Lamp_FromPyObject (PyObject *pyobj)
+Lamp *Lamp_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Lamp *)pyobj)->lamp;
+ return ( ( BPy_Lamp * ) pyobj )->lamp;
}
/*****************************************************************************/
@@ -572,15 +589,13 @@ Lamp *Lamp_FromPyObject (PyObject *pyobj)
/* The function will return NULL when no lamp with the given */
/* name is found. */
/*****************************************************************************/
-Lamp * GetLampByName (char * name)
+Lamp *GetLampByName( char *name )
{
- Lamp * lamp_iter;
+ Lamp *lamp_iter;
- lamp_iter = G.main->lamp.first;
- while (lamp_iter)
- {
- if (StringEqual (name, GetIdName (&(lamp_iter->id))))
- {
+ lamp_iter = G.main->lamp.first;
+ while( lamp_iter ) {
+ if( StringEqual( name, GetIdName( &( lamp_iter->id ) ) ) ) {
return lamp_iter;
}
lamp_iter = lamp_iter->id.next;
@@ -593,220 +608,237 @@ Lamp * GetLampByName (char * name)
/*****************************************************************************/
/* Python BPy_Lamp methods: */
/*****************************************************************************/
-static PyObject *Lamp_getName(BPy_Lamp *self)
+static PyObject *Lamp_getName( BPy_Lamp * self )
{
- PyObject *attr = PyString_FromString(self->lamp->id.name+2);
+ PyObject *attr = PyString_FromString( self->lamp->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.name attribute" ) );
}
-static PyObject *Lamp_getType(BPy_Lamp *self)
-{
- PyObject *attr = PyInt_FromLong(self->lamp->type);
+static PyObject *Lamp_getType( BPy_Lamp * self )
+{
+ PyObject *attr = PyInt_FromLong( self->lamp->type );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.type attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.type attribute" ) );
}
-static PyObject *Lamp_getMode(BPy_Lamp *self)
+static PyObject *Lamp_getMode( BPy_Lamp * self )
{
- PyObject *attr = PyInt_FromLong(self->lamp->mode);
+ PyObject *attr = PyInt_FromLong( self->lamp->mode );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.mode attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.mode attribute" ) );
}
-static PyObject *Lamp_getSamples(BPy_Lamp *self)
+static PyObject *Lamp_getSamples( BPy_Lamp * self )
{
- PyObject *attr = PyInt_FromLong(self->lamp->samp);
+ PyObject *attr = PyInt_FromLong( self->lamp->samp );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.samples attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.samples attribute" ) );
}
-static PyObject *Lamp_getBufferSize(BPy_Lamp *self)
+static PyObject *Lamp_getBufferSize( BPy_Lamp * self )
{
- PyObject *attr = PyInt_FromLong(self->lamp->bufsize);
+ PyObject *attr = PyInt_FromLong( self->lamp->bufsize );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.bufferSize attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.bufferSize attribute" ) );
}
-static PyObject *Lamp_getHaloStep(BPy_Lamp *self)
+static PyObject *Lamp_getHaloStep( BPy_Lamp * self )
{
- PyObject *attr = PyInt_FromLong(self->lamp->shadhalostep);
+ PyObject *attr = PyInt_FromLong( self->lamp->shadhalostep );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.haloStep attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.haloStep attribute" ) );
}
-static PyObject *Lamp_getEnergy(BPy_Lamp *self)
+static PyObject *Lamp_getEnergy( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->energy);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->energy );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.energy attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.energy attribute" ) );
}
-static PyObject *Lamp_getDist(BPy_Lamp *self)
+static PyObject *Lamp_getDist( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->dist);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->dist );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.dist attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.dist attribute" ) );
}
-static PyObject *Lamp_getSpotSize(BPy_Lamp *self)
+static PyObject *Lamp_getSpotSize( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->spotsize);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->spotsize );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.spotSize attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.spotSize attribute" ) );
}
-static PyObject *Lamp_getSpotBlend(BPy_Lamp *self)
+static PyObject *Lamp_getSpotBlend( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->spotblend);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->spotblend );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.spotBlend attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.spotBlend attribute" ) );
}
-static PyObject *Lamp_getClipStart(BPy_Lamp *self)
+static PyObject *Lamp_getClipStart( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->clipsta);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->clipsta );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.clipStart attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.clipStart attribute" ) );
}
-static PyObject *Lamp_getClipEnd(BPy_Lamp *self)
+static PyObject *Lamp_getClipEnd( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->clipend);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->clipend );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.clipEnd attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.clipEnd attribute" ) );
}
-static PyObject *Lamp_getBias(BPy_Lamp *self)
+static PyObject *Lamp_getBias( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->bias);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->bias );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.bias attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.bias attribute" ) );
}
-static PyObject *Lamp_getSoftness(BPy_Lamp *self)
+static PyObject *Lamp_getSoftness( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->soft);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->soft );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.softness attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.softness attribute" ) );
}
-static PyObject *Lamp_getHaloInt(BPy_Lamp *self)
+static PyObject *Lamp_getHaloInt( BPy_Lamp * self )
{
- PyObject *attr = PyFloat_FromDouble(self->lamp->haint);
+ PyObject *attr = PyFloat_FromDouble( self->lamp->haint );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.haloInt attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.haloInt attribute" ) );
}
-static PyObject *Lamp_getQuad1(BPy_Lamp *self)
-{ /* should we complain if Lamp is not of type Quad? */
- PyObject *attr = PyFloat_FromDouble(self->lamp->att1);
+static PyObject *Lamp_getQuad1( BPy_Lamp * self )
+{ /* should we complain if Lamp is not of type Quad? */
+ PyObject *attr = PyFloat_FromDouble( self->lamp->att1 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.quad1 attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.quad1 attribute" ) );
}
-static PyObject *Lamp_getQuad2(BPy_Lamp *self)
-{ /* should we complain if Lamp is not of type Quad? */
- PyObject *attr = PyFloat_FromDouble(self->lamp->att2);
+static PyObject *Lamp_getQuad2( BPy_Lamp * self )
+{ /* should we complain if Lamp is not of type Quad? */
+ PyObject *attr = PyFloat_FromDouble( self->lamp->att2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lamp.quad2 attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lamp.quad2 attribute" ) );
}
-static PyObject *Lamp_getCol(BPy_Lamp *self)
+static PyObject *Lamp_getCol( BPy_Lamp * self )
{
- return rgbTuple_getCol(self->color);
+ return rgbTuple_getCol( self->color );
}
-static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setName( BPy_Lamp * self, PyObject * args )
{
- char *name = NULL;
- char buf[21];
+ char *name = NULL;
+ char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
-
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- rename_id(&self->lamp->id, buf);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- Py_INCREF(Py_None);
- return Py_None;
+ rename_id( &self->lamp->id, buf );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setType( BPy_Lamp * self, PyObject * args )
{
- char *type;
-
- if (!PyArg_ParseTuple(args, "s", &type))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
-
- if (strcmp (type, "Lamp") == 0)
- self->lamp->type = (short)EXPP_LAMP_TYPE_LAMP;
- else if (strcmp (type, "Sun") == 0)
- self->lamp->type = (short)EXPP_LAMP_TYPE_SUN;
- else if (strcmp (type, "Spot") == 0)
- self->lamp->type = (short)EXPP_LAMP_TYPE_SPOT;
- else if (strcmp (type, "Hemi") == 0)
- self->lamp->type = (short)EXPP_LAMP_TYPE_HEMI;
- else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown lamp type"));
-
- Py_INCREF(Py_None);
- return Py_None;
+ char *type;
+
+ if( !PyArg_ParseTuple( args, "s", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
+
+ if( strcmp( type, "Lamp" ) == 0 )
+ self->lamp->type = ( short ) EXPP_LAMP_TYPE_LAMP;
+ else if( strcmp( type, "Sun" ) == 0 )
+ self->lamp->type = ( short ) EXPP_LAMP_TYPE_SUN;
+ else if( strcmp( type, "Spot" ) == 0 )
+ self->lamp->type = ( short ) EXPP_LAMP_TYPE_SPOT;
+ else if( strcmp( type, "Hemi" ) == 0 )
+ self->lamp->type = ( short ) EXPP_LAMP_TYPE_HEMI;
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown lamp type" ) );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
/* This one is 'private'. It is not really a method, just a helper function for
@@ -814,359 +846,380 @@ static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args)
* the first case t shoud be an int and in the second it should be a string. So
* while the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */
-static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setIntType( BPy_Lamp * self, PyObject * args )
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0,3]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [0,3]" ) );
- if (value >= 0 && value <= 3)
- self->lamp->type = value;
- else
- return (EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument in [0,3]"));
+ if( value >= 0 && value <= 3 )
+ self->lamp->type = value;
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected int argument in [0,3]" ) );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setMode( BPy_Lamp * self, PyObject * args )
{
- char *m[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
- short i, flag = 0;
-
- if (!PyArg_ParseTuple(args, "|ssssssss", &m[0], &m[1], &m[2],
- &m[3], &m[4], &m[5], &m[6], &m[7], &m[8], &m[9]))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected from none to 10 string argument(s)"));
-
- for (i = 0; i < 10; i++) {
- if (m[i] == NULL) break;
- if (strcmp(m[i], "Shadows") == 0)
- flag |= (short)EXPP_LAMP_MODE_SHADOWS;
- else if (strcmp(m[i], "Halo") == 0)
- flag |= (short)EXPP_LAMP_MODE_HALO;
- else if (strcmp(m[i], "Layer") == 0)
- flag |= (short)EXPP_LAMP_MODE_LAYER;
- else if (strcmp(m[i], "Quad") == 0)
- flag |= (short)EXPP_LAMP_MODE_QUAD;
- else if (strcmp(m[i], "Negative") == 0)
- flag |= (short)EXPP_LAMP_MODE_NEGATIVE;
- else if (strcmp(m[i], "OnlyShadow") == 0)
- flag |= (short)EXPP_LAMP_MODE_ONLYSHADOW;
- else if (strcmp(m[i], "Sphere") == 0)
- flag |= (short)EXPP_LAMP_MODE_SPHERE;
- else if (strcmp(m[i], "Square") == 0)
- flag |= (short)EXPP_LAMP_MODE_SQUARE;
- else if (strcmp(m[i], "NoDiffuse") == 0)
- flag |= (short)EXPP_LAMP_MODE_NODIFFUSE;
- else if (strcmp(m[i], "NoSpecular") == 0)
- flag |= (short)EXPP_LAMP_MODE_NOSPECULAR;
- else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown lamp flag argument"));
- }
-
- self->lamp->mode = flag;
-
- Py_INCREF(Py_None);
- return Py_None;
+ char *m[10] =
+ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ short i, flag = 0;
+
+ if( !PyArg_ParseTuple( args, "|ssssssss", &m[0], &m[1], &m[2],
+ &m[3], &m[4], &m[5], &m[6], &m[7], &m[8],
+ &m[9] ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected from none to 10 string argument(s)" ) );
+
+ for( i = 0; i < 10; i++ ) {
+ if( m[i] == NULL )
+ break;
+ if( strcmp( m[i], "Shadows" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_SHADOWS;
+ else if( strcmp( m[i], "Halo" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_HALO;
+ else if( strcmp( m[i], "Layer" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_LAYER;
+ else if( strcmp( m[i], "Quad" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_QUAD;
+ else if( strcmp( m[i], "Negative" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_NEGATIVE;
+ else if( strcmp( m[i], "OnlyShadow" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_ONLYSHADOW;
+ else if( strcmp( m[i], "Sphere" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_SPHERE;
+ else if( strcmp( m[i], "Square" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_SQUARE;
+ else if( strcmp( m[i], "NoDiffuse" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_NODIFFUSE;
+ else if( strcmp( m[i], "NoSpecular" ) == 0 )
+ flag |= ( short ) EXPP_LAMP_MODE_NOSPECULAR;
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown lamp flag argument" ) );
+ }
+
+ self->lamp->mode = flag;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
/* Another helper function, for the same reason.
* (See comment before Lamp_setIntType above). */
-static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setIntMode( BPy_Lamp * self, PyObject * args )
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
/* well, with so many flag bits, we just accept any short int, no checking */
- self->lamp->mode = value;
+ self->lamp->mode = value;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSamples( BPy_Lamp * self, PyObject * args )
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1,16]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1,16]" ) );
- self->lamp->samp = EXPP_ClampInt (value,
- EXPP_LAMP_SAMPLES_MIN, EXPP_LAMP_SAMPLES_MAX);
+ self->lamp->samp = EXPP_ClampInt( value,
+ EXPP_LAMP_SAMPLES_MIN,
+ EXPP_LAMP_SAMPLES_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setBufferSize( BPy_Lamp * self, PyObject * args )
{
- short value;
+ short value;
+
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [512, 5120]" ) );
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [512, 5120]"));
-
- self->lamp->bufsize = EXPP_ClampInt (value,
- EXPP_LAMP_BUFFERSIZE_MIN, EXPP_LAMP_BUFFERSIZE_MAX);
+ self->lamp->bufsize = EXPP_ClampInt( value,
+ EXPP_LAMP_BUFFERSIZE_MIN,
+ EXPP_LAMP_BUFFERSIZE_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setHaloStep( BPy_Lamp * self, PyObject * args )
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0,12]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [0,12]" ) );
- self->lamp->shadhalostep = EXPP_ClampInt (value,
- EXPP_LAMP_HALOSTEP_MIN, EXPP_LAMP_HALOSTEP_MAX);
+ self->lamp->shadhalostep = EXPP_ClampInt( value,
+ EXPP_LAMP_HALOSTEP_MIN,
+ EXPP_LAMP_HALOSTEP_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setEnergy( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->energy = EXPP_ClampFloat (value,
- EXPP_LAMP_ENERGY_MIN, EXPP_LAMP_ENERGY_MAX);
+ self->lamp->energy = EXPP_ClampFloat( value,
+ EXPP_LAMP_ENERGY_MIN,
+ EXPP_LAMP_ENERGY_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setDist( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
- self->lamp->dist = EXPP_ClampFloat (value,
- EXPP_LAMP_DIST_MIN, EXPP_LAMP_DIST_MAX);
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- Py_INCREF(Py_None);
- return Py_None;
+ self->lamp->dist = EXPP_ClampFloat( value,
+ EXPP_LAMP_DIST_MIN,
+ EXPP_LAMP_DIST_MAX );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSpotSize( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->spotsize = EXPP_ClampFloat (value,
- EXPP_LAMP_SPOTSIZE_MIN, EXPP_LAMP_SPOTSIZE_MAX);
+ self->lamp->spotsize = EXPP_ClampFloat( value,
+ EXPP_LAMP_SPOTSIZE_MIN,
+ EXPP_LAMP_SPOTSIZE_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSpotBlend( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->spotblend = EXPP_ClampFloat (value,
- EXPP_LAMP_SPOTBLEND_MIN, EXPP_LAMP_SPOTBLEND_MAX);
+ self->lamp->spotblend = EXPP_ClampFloat( value,
+ EXPP_LAMP_SPOTBLEND_MIN,
+ EXPP_LAMP_SPOTBLEND_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setClipStart( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
-
- self->lamp->clipsta = EXPP_ClampFloat (value,
- EXPP_LAMP_CLIPSTART_MIN, EXPP_LAMP_CLIPSTART_MAX);
-
- Py_INCREF(Py_None);
- return Py_None;
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
+
+ self->lamp->clipsta = EXPP_ClampFloat( value,
+ EXPP_LAMP_CLIPSTART_MIN,
+ EXPP_LAMP_CLIPSTART_MAX );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setClipEnd( BPy_Lamp * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->clipend = EXPP_ClampFloat (value,
- EXPP_LAMP_CLIPEND_MIN, EXPP_LAMP_CLIPEND_MAX);
+ self->lamp->clipend = EXPP_ClampFloat( value,
+ EXPP_LAMP_CLIPEND_MIN,
+ EXPP_LAMP_CLIPEND_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setBias( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->bias = EXPP_ClampFloat (value,
- EXPP_LAMP_BIAS_MIN, EXPP_LAMP_BIAS_MAX);
+ self->lamp->bias = EXPP_ClampFloat( value,
+ EXPP_LAMP_BIAS_MIN,
+ EXPP_LAMP_BIAS_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSoftness( BPy_Lamp * self, PyObject * args )
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ float value;
+
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->soft = EXPP_ClampFloat (value,
- EXPP_LAMP_SOFTNESS_MIN, EXPP_LAMP_SOFTNESS_MAX);
+ self->lamp->soft = EXPP_ClampFloat( value,
+ EXPP_LAMP_SOFTNESS_MIN,
+ EXPP_LAMP_SOFTNESS_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setHaloInt( BPy_Lamp * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->haint = EXPP_ClampFloat (value,
- EXPP_LAMP_HALOINT_MIN, EXPP_LAMP_HALOINT_MAX);
+ self->lamp->haint = EXPP_ClampFloat( value,
+ EXPP_LAMP_HALOINT_MIN,
+ EXPP_LAMP_HALOINT_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setQuad1( BPy_Lamp * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->att1 = EXPP_ClampFloat (value,
- EXPP_LAMP_QUAD1_MIN, EXPP_LAMP_QUAD1_MAX);
+ self->lamp->att1 = EXPP_ClampFloat( value,
+ EXPP_LAMP_QUAD1_MIN,
+ EXPP_LAMP_QUAD1_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setQuad2( BPy_Lamp * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" ) );
- self->lamp->att2 = EXPP_ClampFloat (value,
- EXPP_LAMP_QUAD2_MIN, EXPP_LAMP_QUAD2_MAX);
+ self->lamp->att2 = EXPP_ClampFloat( value,
+ EXPP_LAMP_QUAD2_MIN,
+ EXPP_LAMP_QUAD2_MAX );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
- PyObject *args)
-{ /* for compatibility with old bpython */
- float value;
+static PyObject *Lamp_setColorComponent( BPy_Lamp * self, char *key,
+ PyObject * args )
+{ /* for compatibility with old bpython */
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- value = EXPP_ClampFloat (value, EXPP_LAMP_COL_MIN,
- EXPP_LAMP_COL_MAX);
+ value = EXPP_ClampFloat( value, EXPP_LAMP_COL_MIN, EXPP_LAMP_COL_MAX );
- if (!strcmp(key, "R"))
- self->lamp->r = value;
- else if (!strcmp(key, "G"))
- self->lamp->g = value;
- else if (!strcmp(key, "B"))
- self->lamp->b = value;
+ if( !strcmp( key, "R" ) )
+ self->lamp->r = value;
+ else if( !strcmp( key, "G" ) )
+ self->lamp->g = value;
+ else if( !strcmp( key, "B" ) )
+ self->lamp->b = value;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_setCol( BPy_Lamp * self, PyObject * args )
{
- return rgbTuple_setCol(self->color, args);
+ return rgbTuple_setCol( self->color, args );
}
/* lamp.addScriptLink */
-static PyObject *Lamp_addScriptLink (BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args )
{
Lamp *lamp = self->lamp;
ScriptLink *slink = NULL;
- slink = &(lamp)->scriptlink;
+ slink = &( lamp )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 0))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 0 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* lamp.clearScriptLinks */
-static PyObject *Lamp_clearScriptLinks (BPy_Lamp *self)
+static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self )
{
Lamp *lamp = self->lamp;
ScriptLink *slink = NULL;
- slink = &(lamp)->scriptlink;
+ slink = &( lamp )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* mat.getScriptLinks */
-static PyObject *Lamp_getScriptLinks (BPy_Lamp *self, PyObject *args)
+static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * args )
{
Lamp *lamp = self->lamp;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- slink = &(lamp)->scriptlink;
+ slink = &( lamp )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 0);
+ ret = EXPP_getScriptLinks( slink, args, 0 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
/*****************************************************************************/
@@ -1174,10 +1227,10 @@ static PyObject *Lamp_getScriptLinks (BPy_Lamp *self, PyObject *args)
/* Description: This is a callback function for the BPy_Lamp type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void Lamp_dealloc (BPy_Lamp *self)
+static void Lamp_dealloc( BPy_Lamp * self )
{
- Py_DECREF (self->color);
- PyObject_DEL (self);
+ Py_DECREF( self->color );
+ PyObject_DEL( self );
}
/*****************************************************************************/
@@ -1186,93 +1239,95 @@ static void Lamp_dealloc (BPy_Lamp *self)
/* the function that accesses BPy_Lamp member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject *Lamp_getAttr (BPy_Lamp *self, char *name)
+static PyObject *Lamp_getAttr( BPy_Lamp * self, char *name )
{
- PyObject *attr = Py_None;
-
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->lamp->id.name+2);
- else if (strcmp(name, "type") == 0)
- attr = PyInt_FromLong(self->lamp->type);
- else if (strcmp(name, "mode") == 0)
- attr = PyInt_FromLong(self->lamp->mode);
- else if (strcmp(name, "samples") == 0)
- attr = PyInt_FromLong(self->lamp->samp);
- else if (strcmp(name, "bufferSize") == 0)
- attr = PyInt_FromLong(self->lamp->bufsize);
- else if (strcmp(name, "haloStep") == 0)
- attr = PyInt_FromLong(self->lamp->shadhalostep);
- else if (strcmp(name, "R") == 0)
- attr = PyFloat_FromDouble(self->lamp->r);
- else if (strcmp(name, "G") == 0)
- attr = PyFloat_FromDouble(self->lamp->g);
- else if (strcmp(name, "B") == 0)
- attr = PyFloat_FromDouble(self->lamp->b);
- else if (strcmp(name, "col") == 0)
- attr = Lamp_getCol(self);
- else if (strcmp(name, "energy") == 0)
- attr = PyFloat_FromDouble(self->lamp->energy);
- else if (strcmp(name, "dist") == 0)
- attr = PyFloat_FromDouble(self->lamp->dist);
- else if (strcmp(name, "spotSize") == 0)
- attr = PyFloat_FromDouble(self->lamp->spotsize);
- else if (strcmp(name, "spotBlend") == 0)
- attr = PyFloat_FromDouble(self->lamp->spotblend);
- else if (strcmp(name, "clipStart") == 0)
- attr = PyFloat_FromDouble(self->lamp->clipsta);
- else if (strcmp(name, "clipEnd") == 0)
- attr = PyFloat_FromDouble(self->lamp->clipend);
- else if (strcmp(name, "bias") == 0)
- attr = PyFloat_FromDouble(self->lamp->bias);
- else if (strcmp(name, "softness") == 0)
- attr = PyFloat_FromDouble(self->lamp->soft);
- else if (strcmp(name, "haloInt") == 0)
- attr = PyFloat_FromDouble(self->lamp->haint);
- else if (strcmp(name, "quad1") == 0)
- attr = PyFloat_FromDouble(self->lamp->att1);
- else if (strcmp(name, "quad2") == 0)
- attr = PyFloat_FromDouble(self->lamp->att2);
-
- else if (strcmp(name, "Types") == 0) {
- attr = Py_BuildValue("{s:h,s:h,s:h,s:h}",
- "Lamp", EXPP_LAMP_TYPE_LAMP,
- "Sun" , EXPP_LAMP_TYPE_SUN,
- "Spot", EXPP_LAMP_TYPE_SPOT,
- "Hemi", EXPP_LAMP_TYPE_HEMI);
- }
-
- else if (strcmp(name, "Modes") == 0) {
- attr = Py_BuildValue("{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
- "Shadows", EXPP_LAMP_MODE_SHADOWS,
- "Halo", EXPP_LAMP_MODE_HALO,
- "Layer", EXPP_LAMP_MODE_LAYER,
- "Quad", EXPP_LAMP_MODE_QUAD,
- "Negative", EXPP_LAMP_MODE_NEGATIVE,
- "OnlyShadow", EXPP_LAMP_MODE_ONLYSHADOW,
- "Sphere", EXPP_LAMP_MODE_SPHERE,
- "Square", EXPP_LAMP_MODE_SQUARE,
- "NoDiffuse", EXPP_LAMP_MODE_NODIFFUSE,
- "NoSpecular", EXPP_LAMP_MODE_NOSPECULAR);
- }
-
- else if (strcmp(name, "__members__") == 0) {
- /* 23 entries */
- attr = Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
- "name", "type", "mode", "samples", "bufferSize",
- "haloStep", "R", "G", "B", "energy", "dist",
- "spotSize", "spotBlend", "clipStart", "clipEnd",
- "bias", "softness", "haloInt", "quad1", "quad2",
- "Types", "Modes", "col");
- }
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None) return attr; /* member attribute found, return it */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Lamp_methods, (PyObject *)self, name);
+ PyObject *attr = Py_None;
+
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->lamp->id.name + 2 );
+ else if( strcmp( name, "type" ) == 0 )
+ attr = PyInt_FromLong( self->lamp->type );
+ else if( strcmp( name, "mode" ) == 0 )
+ attr = PyInt_FromLong( self->lamp->mode );
+ else if( strcmp( name, "samples" ) == 0 )
+ attr = PyInt_FromLong( self->lamp->samp );
+ else if( strcmp( name, "bufferSize" ) == 0 )
+ attr = PyInt_FromLong( self->lamp->bufsize );
+ else if( strcmp( name, "haloStep" ) == 0 )
+ attr = PyInt_FromLong( self->lamp->shadhalostep );
+ else if( strcmp( name, "R" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->r );
+ else if( strcmp( name, "G" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->g );
+ else if( strcmp( name, "B" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->b );
+ else if( strcmp( name, "col" ) == 0 )
+ attr = Lamp_getCol( self );
+ else if( strcmp( name, "energy" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->energy );
+ else if( strcmp( name, "dist" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->dist );
+ else if( strcmp( name, "spotSize" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->spotsize );
+ else if( strcmp( name, "spotBlend" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->spotblend );
+ else if( strcmp( name, "clipStart" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->clipsta );
+ else if( strcmp( name, "clipEnd" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->clipend );
+ else if( strcmp( name, "bias" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->bias );
+ else if( strcmp( name, "softness" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->soft );
+ else if( strcmp( name, "haloInt" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->haint );
+ else if( strcmp( name, "quad1" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->att1 );
+ else if( strcmp( name, "quad2" ) == 0 )
+ attr = PyFloat_FromDouble( self->lamp->att2 );
+
+ else if( strcmp( name, "Types" ) == 0 ) {
+ attr = Py_BuildValue( "{s:h,s:h,s:h,s:h}",
+ "Lamp", EXPP_LAMP_TYPE_LAMP,
+ "Sun", EXPP_LAMP_TYPE_SUN,
+ "Spot", EXPP_LAMP_TYPE_SPOT,
+ "Hemi", EXPP_LAMP_TYPE_HEMI );
+ }
+
+ else if( strcmp( name, "Modes" ) == 0 ) {
+ attr = Py_BuildValue
+ ( "{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
+ "Shadows", EXPP_LAMP_MODE_SHADOWS, "Halo",
+ EXPP_LAMP_MODE_HALO, "Layer", EXPP_LAMP_MODE_LAYER,
+ "Quad", EXPP_LAMP_MODE_QUAD, "Negative",
+ EXPP_LAMP_MODE_NEGATIVE, "OnlyShadow",
+ EXPP_LAMP_MODE_ONLYSHADOW, "Sphere",
+ EXPP_LAMP_MODE_SPHERE, "Square",
+ EXPP_LAMP_MODE_SQUARE, "NoDiffuse",
+ EXPP_LAMP_MODE_NODIFFUSE, "NoSpecular",
+ EXPP_LAMP_MODE_NOSPECULAR );
+ }
+
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ /* 23 entries */
+ attr = Py_BuildValue
+ ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+ "name", "type", "mode", "samples", "bufferSize",
+ "haloStep", "R", "G", "B", "energy", "dist",
+ "spotSize", "spotBlend", "clipStart", "clipEnd",
+ "bias", "softness", "haloInt", "quad1", "quad2",
+ "Types", "Modes", "col" );
+ }
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Lamp_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
@@ -1281,79 +1336,80 @@ static PyObject *Lamp_getAttr (BPy_Lamp *self, char *name)
/* function that changes Lamp Data members values. If this */
/* data is linked to a Blender Lamp, it also gets updated. */
/*****************************************************************************/
-static int Lamp_setAttr (BPy_Lamp *self, char *name, PyObject *value)
+static int Lamp_setAttr( BPy_Lamp * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- valtuple = Py_BuildValue("(O)", value); /*the set* functions expect a tuple*/
-
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "LampSetAttr: couldn't create tuple");
-
- if (strcmp (name, "name") == 0)
- error = Lamp_setName (self, valtuple);
- else if (strcmp (name, "type") == 0)
- error = Lamp_setIntType (self, valtuple); /* special case */
- else if (strcmp (name, "mode") == 0)
- error = Lamp_setIntMode (self, valtuple); /* special case */
- else if (strcmp (name, "samples") == 0)
- error = Lamp_setSamples (self, valtuple);
- else if (strcmp (name, "bufferSize") == 0)
- error = Lamp_setBufferSize (self, valtuple);
- else if (strcmp (name, "haloStep") == 0)
- error = Lamp_setHaloStep (self, valtuple);
- else if (strcmp (name, "R") == 0)
- error = Lamp_setColorComponent (self, "R", valtuple);
- else if (strcmp (name, "G") == 0)
- error = Lamp_setColorComponent (self, "G", valtuple);
- else if (strcmp (name, "B") == 0)
- error = Lamp_setColorComponent (self, "B", valtuple);
- else if (strcmp (name, "energy") == 0)
- error = Lamp_setEnergy (self, valtuple);
- else if (strcmp (name, "dist") == 0)
- error = Lamp_setDist (self, valtuple);
- else if (strcmp (name, "spotSize") == 0)
- error = Lamp_setSpotSize (self, valtuple);
- else if (strcmp (name, "spotBlend") == 0)
- error = Lamp_setSpotBlend (self, valtuple);
- else if (strcmp (name, "clipStart") == 0)
- error = Lamp_setClipStart (self, valtuple);
- else if (strcmp (name, "clipEnd") == 0)
- error = Lamp_setClipEnd (self, valtuple);
- else if (strcmp (name, "bias") == 0)
- error = Lamp_setBias (self, valtuple);
- else if (strcmp (name, "softness") == 0)
- error = Lamp_setSoftness (self, valtuple);
- else if (strcmp (name, "haloInt") == 0)
- error = Lamp_setHaloInt (self, valtuple);
- else if (strcmp (name, "quad1") == 0)
- error = Lamp_setQuad1 (self, valtuple);
- else if (strcmp (name, "quad2") == 0)
- error = Lamp_setQuad2 (self, valtuple);
- else if (strcmp (name, "col") == 0)
- error = Lamp_setCol (self, valtuple);
-
- else { /* Error */
- Py_DECREF(valtuple);
-
- if ((strcmp (name, "Types") == 0) || /* user tried to change a */
- (strcmp (name, "Modes") == 0)) /* constant dict type ... */
- return (EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed"));
-
- else /* ... or no member with the given name was found */
- return (EXPP_ReturnIntError (PyExc_AttributeError,
- "attribute not found"));
- }
-
- Py_DECREF(valtuple);
-
- if (error != Py_None) return -1;
-
- Py_DECREF(Py_None); /* was incref'ed by the called Lamp_set* function */
- return 0; /* normal exit */
+ PyObject *valtuple;
+ PyObject *error = NULL;
+
+ valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "LampSetAttr: couldn't create tuple" );
+
+ if( strcmp( name, "name" ) == 0 )
+ error = Lamp_setName( self, valtuple );
+ else if( strcmp( name, "type" ) == 0 )
+ error = Lamp_setIntType( self, valtuple ); /* special case */
+ else if( strcmp( name, "mode" ) == 0 )
+ error = Lamp_setIntMode( self, valtuple ); /* special case */
+ else if( strcmp( name, "samples" ) == 0 )
+ error = Lamp_setSamples( self, valtuple );
+ else if( strcmp( name, "bufferSize" ) == 0 )
+ error = Lamp_setBufferSize( self, valtuple );
+ else if( strcmp( name, "haloStep" ) == 0 )
+ error = Lamp_setHaloStep( self, valtuple );
+ else if( strcmp( name, "R" ) == 0 )
+ error = Lamp_setColorComponent( self, "R", valtuple );
+ else if( strcmp( name, "G" ) == 0 )
+ error = Lamp_setColorComponent( self, "G", valtuple );
+ else if( strcmp( name, "B" ) == 0 )
+ error = Lamp_setColorComponent( self, "B", valtuple );
+ else if( strcmp( name, "energy" ) == 0 )
+ error = Lamp_setEnergy( self, valtuple );
+ else if( strcmp( name, "dist" ) == 0 )
+ error = Lamp_setDist( self, valtuple );
+ else if( strcmp( name, "spotSize" ) == 0 )
+ error = Lamp_setSpotSize( self, valtuple );
+ else if( strcmp( name, "spotBlend" ) == 0 )
+ error = Lamp_setSpotBlend( self, valtuple );
+ else if( strcmp( name, "clipStart" ) == 0 )
+ error = Lamp_setClipStart( self, valtuple );
+ else if( strcmp( name, "clipEnd" ) == 0 )
+ error = Lamp_setClipEnd( self, valtuple );
+ else if( strcmp( name, "bias" ) == 0 )
+ error = Lamp_setBias( self, valtuple );
+ else if( strcmp( name, "softness" ) == 0 )
+ error = Lamp_setSoftness( self, valtuple );
+ else if( strcmp( name, "haloInt" ) == 0 )
+ error = Lamp_setHaloInt( self, valtuple );
+ else if( strcmp( name, "quad1" ) == 0 )
+ error = Lamp_setQuad1( self, valtuple );
+ else if( strcmp( name, "quad2" ) == 0 )
+ error = Lamp_setQuad2( self, valtuple );
+ else if( strcmp( name, "col" ) == 0 )
+ error = Lamp_setCol( self, valtuple );
+
+ else { /* Error */
+ Py_DECREF( valtuple );
+
+ if( ( strcmp( name, "Types" ) == 0 ) || /* user tried to change a */
+ ( strcmp( name, "Modes" ) == 0 ) ) /* constant dict type ... */
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" ) );
+
+ else /* ... or no member with the given name was found */
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "attribute not found" ) );
+ }
+
+ Py_DECREF( valtuple );
+
+ if( error != Py_None )
+ return -1;
+
+ Py_DECREF( Py_None ); /* was incref'ed by the called Lamp_set* function */
+ return 0; /* normal exit */
}
/*****************************************************************************/
@@ -1364,10 +1420,10 @@ static int Lamp_setAttr (BPy_Lamp *self, char *name, PyObject *value)
/* they don't point to the same Blender Lamp struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
+static int Lamp_compare( BPy_Lamp * a, BPy_Lamp * b )
{
- Lamp *pa = a->lamp, *pb = b->lamp;
- return (pa == pb) ? 0:-1;
+ Lamp *pa = a->lamp, *pb = b->lamp;
+ return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
@@ -1375,80 +1431,75 @@ static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
/* Description: This is a callback function for the BPy_Lamp type. It */
/* builds a meaninful string to represent lamp objects. */
/*****************************************************************************/
-static PyObject *Lamp_repr (BPy_Lamp *self)
+static PyObject *Lamp_repr( BPy_Lamp * self )
{
- return PyString_FromFormat("[Lamp \"%s\"]", self->lamp->id.name+2);
+ return PyString_FromFormat( "[Lamp \"%s\"]", self->lamp->id.name + 2 );
}
-static PyObject *
-Lamp_getIpo (BPy_Lamp * self)
+static PyObject *Lamp_getIpo( BPy_Lamp * self )
{
- struct Ipo *ipo = self->lamp->ipo;
+ struct Ipo *ipo = self->lamp->ipo;
- if (!ipo)
- {
- Py_INCREF (Py_None);
- return Py_None;
- }
+ if( !ipo ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
- return Ipo_CreatePyObject (ipo);
+ return Ipo_CreatePyObject( ipo );
}
extern PyTypeObject Ipo_Type;
-static PyObject *
-Lamp_setIpo (BPy_Lamp * self, PyObject * args)
+static PyObject *Lamp_setIpo( BPy_Lamp * self, PyObject * args )
{
- PyObject *pyipo = 0;
- Ipo *ipo = NULL;
- Ipo *oldipo;
+ 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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject (pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ if( !ipo )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "null ipo!" );
- if (ipo->blocktype != ID_TE)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this ipo is not a lamp data ipo");
+ if( ipo->blocktype != ID_TE )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not a lamp data ipo" );
- oldipo = self->lamp->ipo;
- if (oldipo)
- {
- ID *id = &oldipo->id;
- if (id->us > 0)
- id->us--;
- }
+ oldipo = self->lamp->ipo;
+ if( oldipo ) {
+ ID *id = &oldipo->id;
+ if( id->us > 0 )
+ id->us--;
+ }
- ((ID *) & ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
- self->lamp->ipo = ipo;
+ self->lamp->ipo = ipo;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Lamp_clearIpo (BPy_Lamp * self)
+static PyObject *Lamp_clearIpo( BPy_Lamp * self )
{
- Lamp *lamp = self->lamp;
- Ipo *ipo = (Ipo *) lamp->ipo;
-
- if (ipo)
- {
- ID *id = &ipo->id;
- if (id->us > 0)
- id->us--;
- lamp->ipo = NULL;
-
- Py_INCREF (Py_True);
- return Py_True;
- }
-
- Py_INCREF (Py_False); /* no ipo found */
- return Py_False;
+ Lamp *lamp = self->lamp;
+ Ipo *ipo = ( Ipo * ) lamp->ipo;
+
+ if( ipo ) {
+ ID *id = &ipo->id;
+ if( id->us > 0 )
+ id->us--;
+ lamp->ipo = NULL;
+
+ Py_INCREF( Py_True );
+ return Py_True;
+ }
+
+ Py_INCREF( Py_False ); /* no ipo found */
+ return Py_False;
}
diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h
index 08bbbfef67e..d1cc0b33262 100644
--- a/source/blender/python/api2_2x/Lamp.h
+++ b/source/blender/python/api2_2x/Lamp.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -32,4 +33,4 @@
#ifndef EXPP_LAMP_H
#define EXPP_LAMP_H
-#endif /* EXPP_LAMP_H */
+#endif /* EXPP_LAMP_H */
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
index aec39d53d9d..d2b3bc84115 100644
--- a/source/blender/python/api2_2x/Lattice.c
+++ b/source/blender/python/api2_2x/Lattice.c
@@ -33,231 +33,238 @@
#include "Lattice.h"
//***************************************************************************
-// Function: Lattice_CreatePyObject
+// Function: Lattice_CreatePyObject
//***************************************************************************
-PyObject *Lattice_CreatePyObject (Lattice *lt)
+PyObject *Lattice_CreatePyObject( Lattice * lt )
{
BPy_Lattice *pyLat;
- pyLat = (BPy_Lattice *)PyObject_NEW (BPy_Lattice, &Lattice_Type);
+ pyLat = ( BPy_Lattice * ) PyObject_NEW( BPy_Lattice, &Lattice_Type );
- if (!pyLat)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Lattice PyObject");
+ if( !pyLat )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Lattice PyObject" );
pyLat->Lattice = lt;
- return (PyObject *)pyLat;
+ return ( PyObject * ) pyLat;
}
//***************************************************************************
-// Function: Lattice_FromPyObject
+// Function: Lattice_FromPyObject
//***************************************************************************
-Lattice *Lattice_FromPyObject (PyObject *pyobj)
+Lattice *Lattice_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Lattice *)pyobj)->Lattice;
+ return ( ( BPy_Lattice * ) pyobj )->Lattice;
}
//***************************************************************************
-// Function: Lattice_CheckPyObject
+// Function: Lattice_CheckPyObject
//***************************************************************************
-int Lattice_CheckPyObject (PyObject *pyobj)
+int Lattice_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Lattice_Type);
+ return ( pyobj->ob_type == &Lattice_Type );
}
-
+
//***************************************************************************
-// Function: M_Lattice_New
-// Python equivalent: Blender.Lattice.New
+// Function: M_Lattice_New
+// Python equivalent: Blender.Lattice.New
//***************************************************************************
-static PyObject *M_Lattice_New(PyObject *self, PyObject *args)
+static PyObject *M_Lattice_New( PyObject * self, PyObject * args )
{
char *name = NULL;
char buf[21];
- Lattice * bl_Lattice; // blender Lattice object
- PyObject * py_Lattice; // python wrapper
+ Lattice *bl_Lattice; // blender Lattice object
+ PyObject *py_Lattice; // python wrapper
- if (!PyArg_ParseTuple(args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string and int arguments (or nothing)");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string and int arguments (or nothing)" );
- bl_Lattice = add_lattice();
+ bl_Lattice = add_lattice( );
bl_Lattice->id.us = 0;
- if (bl_Lattice)
- py_Lattice = Lattice_CreatePyObject (bl_Lattice);
+ if( bl_Lattice )
+ py_Lattice = Lattice_CreatePyObject( bl_Lattice );
else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Lattice Object in Blender");
- if (!py_Lattice)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Lattice Object wrapper");
-
- if (name) {
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&bl_Lattice->id, buf);
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Lattice Object in Blender" );
+ if( !py_Lattice )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Lattice Object wrapper" );
+
+ if( name ) {
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &bl_Lattice->id, buf );
}
return py_Lattice;
}
//***************************************************************************
-// Function: M_Lattice_Get
-// Python equivalent: Blender.Lattice.Get
+// Function: M_Lattice_Get
+// Python equivalent: Blender.Lattice.Get
//***************************************************************************
-static PyObject *M_Lattice_Get(PyObject *self, PyObject *args)
+static PyObject *M_Lattice_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
- Lattice *lat_iter;
+ char *name = NULL;
+ Lattice *lat_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
- lat_iter = G.main->latt.first;
+ lat_iter = G.main->latt.first;
- if (name) { /* (name) - Search Lattice by name */
+ if( name ) { /* (name) - Search Lattice by name */
- PyObject *wanted_lat = NULL;
+ PyObject *wanted_lat = NULL;
- while ((lat_iter) && (wanted_lat == NULL)) {
- if (strcmp (name, lat_iter->id.name+2) == 0) {
- wanted_lat = Lattice_CreatePyObject (lat_iter);
- }
+ while( ( lat_iter ) && ( wanted_lat == NULL ) ) {
+ if( strcmp( name, lat_iter->id.name + 2 ) == 0 ) {
+ wanted_lat =
+ Lattice_CreatePyObject( lat_iter );
+ }
- lat_iter = lat_iter->id.next;
- }
+ lat_iter = lat_iter->id.next;
+ }
- if (wanted_lat == NULL) { /* Requested Lattice doesn't exist */
- char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Lattice \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ if( wanted_lat == NULL ) { /* Requested Lattice doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Lattice \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+ }
- return wanted_lat;
- }
+ return wanted_lat;
+ }
- else { /* () - return a list of all Lattices in the scene */
- int index = 0;
- PyObject *latlist, *pyobj;
+ else { /* () - return a list of all Lattices in the scene */
+ int index = 0;
+ PyObject *latlist, *pyobj;
- latlist = PyList_New (BLI_countlist (&(G.main->latt)));
+ latlist = PyList_New( BLI_countlist( &( G.main->latt ) ) );
- if (latlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( latlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (lat_iter) {
- pyobj = Lattice_CreatePyObject(lat_iter);
+ while( lat_iter ) {
+ pyobj = Lattice_CreatePyObject( lat_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- PyList_SET_ITEM (latlist, index, pyobj);
+ PyList_SET_ITEM( latlist, index, pyobj );
- lat_iter = lat_iter->id.next;
- index++;
- }
+ lat_iter = lat_iter->id.next;
+ index++;
+ }
- return (latlist);
- }
+ return ( latlist );
+ }
}
+
//***************************************************************************
-// Function: Lattice_Init
+// Function: Lattice_Init
//***************************************************************************
-PyObject *Lattice_Init (void)
+PyObject *Lattice_Init( void )
{
- PyObject *mod= Py_InitModule3("Blender.Lattice", M_Lattice_methods, M_Lattice_doc);
- PyObject *dict= PyModule_GetDict(mod);
+ PyObject *mod =
+ Py_InitModule3( "Blender.Lattice", M_Lattice_methods,
+ M_Lattice_doc );
+ PyObject *dict = PyModule_GetDict( mod );
Lattice_Type.ob_type = &PyType_Type;
//Module dictionary
- #define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(LT_##x))
- EXPP_ADDCONST(GRID);
- EXPP_ADDCONST(OUTSIDE);
+#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(LT_##x))
+ EXPP_ADDCONST( GRID );
+ EXPP_ADDCONST( OUTSIDE );
- #undef EXPP_ADDCONST
- #define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(KEY_##x))
- EXPP_ADDCONST(LINEAR);
- EXPP_ADDCONST(CARDINAL);
- EXPP_ADDCONST(BSPLINE);
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(KEY_##x))
+ EXPP_ADDCONST( LINEAR );
+ EXPP_ADDCONST( CARDINAL );
+ EXPP_ADDCONST( BSPLINE );
- return(mod);
+ return ( mod );
}
//***************************************************************************
-// Python BPy_Lattice methods:
+// Python BPy_Lattice methods:
//***************************************************************************
-static PyObject *Lattice_getName(BPy_Lattice *self)
+static PyObject *Lattice_getName( BPy_Lattice * self )
{
- PyObject *attr = PyString_FromString(self->Lattice->id.name+2);
+ PyObject *attr = PyString_FromString( self->Lattice->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Lattice.name attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Lattice.name attribute" );
}
-static PyObject *Lattice_setName(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args )
{
char *name;
char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id(&self->Lattice->id, buf);
+ rename_id( &self->Lattice->id, buf );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_setPartitions(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args )
{
int x = 0;
int y = 0;
int z = 0;
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
- if (!PyArg_ParseTuple(args, "iii", &x, &y, &z))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int,int,int argument"));
+ if( !PyArg_ParseTuple( args, "iii", &x, &y, &z ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int,int,int argument" ) );
bl_Lattice = self->Lattice;
- if(x <2 || y < 2 || z < 2)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "partition values must be 2 or greater"));
+ if( x < 2 || y < 2 || z < 2 )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "partition values must be 2 or greater" ) );
- bl_Lattice->pntsu = (short)x;
- bl_Lattice->pntsv = (short)y;
- bl_Lattice->pntsw = (short)z;
- resizelattice(bl_Lattice);
+ bl_Lattice->pntsu = ( short ) x;
+ bl_Lattice->pntsv = ( short ) y;
+ bl_Lattice->pntsw = ( short ) z;
+ resizelattice( bl_Lattice );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_getPartitions(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_getPartitions( BPy_Lattice * self, PyObject * args )
{
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
bl_Lattice = self->Lattice;
- return Py_BuildValue("[i,i,i]", (int)bl_Lattice->pntsu,
- (int)bl_Lattice->pntsv,
- (int)bl_Lattice->pntsw);
+ return Py_BuildValue( "[i,i,i]", ( int ) bl_Lattice->pntsu,
+ ( int ) bl_Lattice->pntsv,
+ ( int ) bl_Lattice->pntsw );
}
-
-static PyObject *Lattice_getKeyTypes(BPy_Lattice *self, PyObject *args)
+
+static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args )
{
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
char *linear = "linear";
char *cardinal = "cardinal";
char *bspline = "bspline";
@@ -265,463 +272,460 @@ static PyObject *Lattice_getKeyTypes(BPy_Lattice *self, PyObject *args)
bl_Lattice = self->Lattice;
- if ((bl_Lattice->typeu) == KEY_LINEAR)
+ if( ( bl_Lattice->typeu ) == KEY_LINEAR )
s_x = linear;
- else if ((bl_Lattice->typeu) == KEY_CARDINAL)
+ else if( ( bl_Lattice->typeu ) == KEY_CARDINAL )
s_x = cardinal;
- else if ((bl_Lattice->typeu) == KEY_BSPLINE)
+ else if( ( bl_Lattice->typeu ) == KEY_BSPLINE )
s_x = bspline;
else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "bad key type...");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "bad key type..." );
- if ((bl_Lattice->typev) == KEY_LINEAR)
+ if( ( bl_Lattice->typev ) == KEY_LINEAR )
s_y = linear;
- else if ((bl_Lattice->typev) == KEY_CARDINAL)
+ else if( ( bl_Lattice->typev ) == KEY_CARDINAL )
s_y = cardinal;
- else if ((bl_Lattice->typev) == KEY_BSPLINE)
+ else if( ( bl_Lattice->typev ) == KEY_BSPLINE )
s_z = bspline;
else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "bad key type...");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "bad key type..." );
- if ((bl_Lattice->typew) == KEY_LINEAR)
+ if( ( bl_Lattice->typew ) == KEY_LINEAR )
s_z = linear;
- else if ((bl_Lattice->typew) == KEY_CARDINAL)
+ else if( ( bl_Lattice->typew ) == KEY_CARDINAL )
s_z = cardinal;
- else if ((bl_Lattice->typew) == KEY_BSPLINE)
+ else if( ( bl_Lattice->typew ) == KEY_BSPLINE )
s_z = bspline;
else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "bad key type...");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "bad key type..." );
/* we made sure no s_[xyz] is NULL */
- return Py_BuildValue("[s,s,s]", s_x, s_y, s_z);
+ return Py_BuildValue( "[s,s,s]", s_x, s_y, s_z );
}
-static PyObject *Lattice_setKeyTypes(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args )
{
int x;
int y;
int z;
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
- if (!PyArg_ParseTuple(args, "iii", &x, &y, &z))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int,int,int argument"));
+ if( !PyArg_ParseTuple( args, "iii", &x, &y, &z ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int,int,int argument" ) );
bl_Lattice = self->Lattice;
-
- if (x == KEY_LINEAR)
+
+ if( x == KEY_LINEAR )
bl_Lattice->typeu = KEY_LINEAR;
- else if (x == KEY_CARDINAL)
+ else if( x == KEY_CARDINAL )
bl_Lattice->typeu = KEY_CARDINAL;
- else if (x == KEY_BSPLINE)
+ else if( x == KEY_BSPLINE )
bl_Lattice->typeu = KEY_BSPLINE;
else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "type must be LINEAR, CARDINAL OR BSPLINE");
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "type must be LINEAR, CARDINAL OR BSPLINE" );
- if (y == KEY_LINEAR)
+ if( y == KEY_LINEAR )
bl_Lattice->typev = KEY_LINEAR;
- else if (y == KEY_CARDINAL)
+ else if( y == KEY_CARDINAL )
bl_Lattice->typev = KEY_CARDINAL;
- else if (y == KEY_BSPLINE)
+ else if( y == KEY_BSPLINE )
bl_Lattice->typev = KEY_BSPLINE;
else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "type must be LINEAR, CARDINAL OR BSPLINE");
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "type must be LINEAR, CARDINAL OR BSPLINE" );
- if (z == KEY_LINEAR)
+ if( z == KEY_LINEAR )
bl_Lattice->typew = KEY_LINEAR;
- else if (z == KEY_CARDINAL)
+ else if( z == KEY_CARDINAL )
bl_Lattice->typew = KEY_CARDINAL;
- else if (z == KEY_BSPLINE)
+ else if( z == KEY_BSPLINE )
bl_Lattice->typew = KEY_BSPLINE;
else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "type must be LINEAR, CARDINAL OR BSPLINE");
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "type must be LINEAR, CARDINAL OR BSPLINE" );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_setMode(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args )
{
short type;
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
bl_Lattice = self->Lattice;
- if (!PyArg_ParseTuple(args, "h", &type))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "h", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- if (type == LT_GRID)
+ if( type == LT_GRID )
bl_Lattice->flag = LT_GRID;
- else if (type == LT_OUTSIDE)
- {
+ else if( type == LT_OUTSIDE ) {
bl_Lattice->flag = LT_OUTSIDE + LT_GRID;
- outside_lattice(bl_Lattice);
- }
- else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "type must be either GRID or OUTSIDE");
+ outside_lattice( bl_Lattice );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "type must be either GRID or OUTSIDE" );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_getMode(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_getMode( BPy_Lattice * self, PyObject * args )
{
char type[24];
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
bl_Lattice = self->Lattice;
- if (bl_Lattice->flag & LT_GRID)
- sprintf(type, "Grid");
- else if (bl_Lattice->flag & LT_OUTSIDE)
- sprintf(type, "Outside");
+ if( bl_Lattice->flag & LT_GRID )
+ sprintf( type, "Grid" );
+ else if( bl_Lattice->flag & LT_OUTSIDE )
+ sprintf( type, "Outside" );
else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "bad mode type...");
-
- return Py_BuildValue("s", type);
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "bad mode type..." );
+
+ return Py_BuildValue( "s", type );
}
-static PyObject *Lattice_setPoint(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args )
{
BPoint *bp, *bpoint;
short size;
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
int index, x;
float tempInt;
- PyObject * listObject;
+ PyObject *listObject;
- if (!PyArg_ParseTuple(args, "iO!", &index, &PyList_Type, &listObject))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int & list argument"));
+ if( !PyArg_ParseTuple
+ ( args, "iO!", &index, &PyList_Type, &listObject ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int & list argument" ) );
- if(!PyList_Check(listObject))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "2nd parameter should be a python list"));
+ if( !PyList_Check( listObject ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "2nd parameter should be a python list" ) );
- if (!(PyList_Size(listObject) == 3))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "Please pass 3 parameters in the list [x,y,z]"));
+ if( !( PyList_Size( listObject ) == 3 ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Please pass 3 parameters in the list [x,y,z]" ) );
//init
- bp= 0;
+ bp = 0;
bl_Lattice = self->Lattice;
//get bpoints
- bp= bl_Lattice->def;
+ bp = bl_Lattice->def;
+
+ if( bp == 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no lattice points!" ) );
- if(bp == 0)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no lattice points!"));
-
//calculate size of lattice
- size= bl_Lattice->pntsu*bl_Lattice->pntsv*bl_Lattice->pntsw;
+ size = bl_Lattice->pntsu * bl_Lattice->pntsv * bl_Lattice->pntsw;
+
+ if( index < 0 || index > size )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "index outside of lattice size!" ) );
- if (index < 0 || index > size)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "index outside of lattice size!"));
-
//get the bpoint
- while (index)
- {
+ while( index ) {
index--;
bp++;
}
bpoint = bp;
- for (x = 0; x < PyList_Size(listObject); x++) {
- if (!(PyArg_Parse((PyList_GetItem(listObject, x)), "f", &tempInt)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list integer not parseable");
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !
+ ( PyArg_Parse
+ ( ( PyList_GetItem( listObject, x ) ), "f",
+ &tempInt ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list integer not parseable" );
bpoint->vec[x] = tempInt;
}
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_getPoint(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args )
{
BPoint *bp, *bpoint;
short size;
- Lattice * bl_Lattice;
+ Lattice *bl_Lattice;
int index;
- if (!PyArg_ParseTuple(args, "i", &index))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &index ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
//init
- bp= 0;
+ bp = 0;
bl_Lattice = self->Lattice;
//get bpoints
- bp= bl_Lattice->def;
+ bp = bl_Lattice->def;
+
+ if( bp == 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no lattice points!" ) );
- if(bp == 0)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no lattice points!"));
-
//calculate size of lattice
- size= bl_Lattice->pntsu*bl_Lattice->pntsv*bl_Lattice->pntsw;
+ size = bl_Lattice->pntsu * bl_Lattice->pntsv * bl_Lattice->pntsw;
+
+ if( index < 0 || index > size )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "index outside of lattice size!" ) );
- if (index < 0 || index > size)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "index outside of lattice size!"));
-
//get the bpoint
- while (index)
- {
+ while( index ) {
index--;
bp++;
}
bpoint = bp;
- if(bpoint == 0)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "bpoint does not exist"));
+ if( bpoint == 0 )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "bpoint does not exist" ) );
- return Py_BuildValue("[f,f,f]", bp->vec[0] ,bp->vec[1] ,bp->vec[2]);
+ return Py_BuildValue( "[f,f,f]", bp->vec[0], bp->vec[1], bp->vec[2] );
}
//This function will not do anything if there are no children
-static PyObject *Lattice_applyDeform(BPy_Lattice *self)
+static PyObject *Lattice_applyDeform( BPy_Lattice * self )
{
//Object* ob; unused
Base *base;
Object *par;
- if (!Lattice_IsLinkedToObject(self))
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Lattice must be linked to an object to apply it's deformation!"));
+ if( !Lattice_IsLinkedToObject( self ) )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Lattice must be linked to an object to apply it's deformation!" ) );
//deform children
- base= FIRSTBASE;
- while(base) {
- if( (par= base->object->parent) ) {
- if(par->type==OB_LATTICE) {
- object_deform(base->object);
- }
- }
- base= base->next;
+ base = FIRSTBASE;
+ while( base ) {
+ if( ( par = base->object->parent ) ) {
+ if( par->type == OB_LATTICE ) {
+ object_deform( base->object );
+ }
+ }
+ base = base->next;
}
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Lattice_insertKey(BPy_Lattice *self, PyObject *args)
+static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args )
{
Lattice *lt;
int frame = -1, oldfra = -1;
- if (!PyArg_ParseTuple(args, "i", &frame))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &frame ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
lt = self->Lattice;
//set the current frame
- if (frame > 0) {
- frame = EXPP_ClampInt (frame, 1, 18000);
+ if( frame > 0 ) {
+ frame = EXPP_ClampInt( frame, 1, 18000 );
oldfra = G.scene->r.cfra;
G.scene->r.cfra = frame;
}
-// else just use current frame, then
-// return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
-// "frame value has to be greater than 0"));
+// else just use current frame, then
+// return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+// "frame value has to be greater than 0"));
//insert a keybock for the lattice
- insert_lattkey(lt);
+ insert_lattkey( lt );
- if (frame > 0) G.scene->r.cfra = oldfra;
+ if( frame > 0 )
+ G.scene->r.cfra = oldfra;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
//***************************************************************************
-// Function: Lattice_dealloc
-// Description: This is a callback function for the BPy_Lattice type. It is
-// the destructor function.
+// Function: Lattice_dealloc
+// Description: This is a callback function for the BPy_Lattice type. It is
+// the destructor function.
//***************************************************************************
-static void Lattice_dealloc (BPy_Lattice *self)
+static void Lattice_dealloc( BPy_Lattice * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
//***************************************************************************
-// Function: Lattice_getAttr
-// Description: This is a callback function for the BPy_Lattice type. It is
-// the function that accesses BPy_Lattice member variables and
-// methods.
+// Function: Lattice_getAttr
+// Description: This is a callback function for the BPy_Lattice type. It is
+// the function that accesses BPy_Lattice member variables and
+// methods.
//***************************************************************************
-static PyObject *Lattice_getAttr (BPy_Lattice *self, char *name)
+static PyObject *Lattice_getAttr( BPy_Lattice * self, char *name )
{
PyObject *attr = Py_None;
- if (!self->Lattice || !Lattice_InLatList(self))
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Lattice was already deleted!");
-
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->Lattice->id.name+2);
- else if (strcmp(name, "width") == 0)
- attr = Py_BuildValue("i",self->Lattice->pntsu);
- else if (strcmp(name, "height") == 0)
- attr = Py_BuildValue("i",self->Lattice->pntsv);
- else if (strcmp(name, "depth") == 0)
- attr = Py_BuildValue("i",self->Lattice->pntsw);
- else if (strcmp(name, "widthType") == 0)
- {
- if(self->Lattice->typeu == 0)
- attr = Py_BuildValue("s","Linear");
- else if (self->Lattice->typeu == 1)
- attr = Py_BuildValue("s","Cardinal");
- else if (self->Lattice->typeu == 2)
- attr = Py_BuildValue("s","Bspline");
+ if( !self->Lattice || !Lattice_InLatList( self ) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Lattice was already deleted!" );
+
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->Lattice->id.name + 2 );
+ else if( strcmp( name, "width" ) == 0 )
+ attr = Py_BuildValue( "i", self->Lattice->pntsu );
+ else if( strcmp( name, "height" ) == 0 )
+ attr = Py_BuildValue( "i", self->Lattice->pntsv );
+ else if( strcmp( name, "depth" ) == 0 )
+ attr = Py_BuildValue( "i", self->Lattice->pntsw );
+ else if( strcmp( name, "widthType" ) == 0 ) {
+ if( self->Lattice->typeu == 0 )
+ attr = Py_BuildValue( "s", "Linear" );
+ else if( self->Lattice->typeu == 1 )
+ attr = Py_BuildValue( "s", "Cardinal" );
+ else if( self->Lattice->typeu == 2 )
+ attr = Py_BuildValue( "s", "Bspline" );
else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad widthType...");
- }
- else if (strcmp(name, "heightType") == 0)
- {
- if(self->Lattice->typev == 0)
- attr = Py_BuildValue("s","Linear");
- else if (self->Lattice->typev== 1)
- attr = Py_BuildValue("s","Cardinal");
- else if (self->Lattice->typev == 2)
- attr = Py_BuildValue("s","Bspline");
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad widthType..." );
+ } else if( strcmp( name, "heightType" ) == 0 ) {
+ if( self->Lattice->typev == 0 )
+ attr = Py_BuildValue( "s", "Linear" );
+ else if( self->Lattice->typev == 1 )
+ attr = Py_BuildValue( "s", "Cardinal" );
+ else if( self->Lattice->typev == 2 )
+ attr = Py_BuildValue( "s", "Bspline" );
else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad widthType...");
- }
- else if (strcmp(name, "depthType") == 0)
- {
- if(self->Lattice->typew == 0)
- attr = Py_BuildValue("s","Linear");
- else if (self->Lattice->typew == 1)
- attr = Py_BuildValue("s","Cardinal");
- else if (self->Lattice->typew == 2)
- attr = Py_BuildValue("s","Bspline");
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad widthType..." );
+ } else if( strcmp( name, "depthType" ) == 0 ) {
+ if( self->Lattice->typew == 0 )
+ attr = Py_BuildValue( "s", "Linear" );
+ else if( self->Lattice->typew == 1 )
+ attr = Py_BuildValue( "s", "Cardinal" );
+ else if( self->Lattice->typew == 2 )
+ attr = Py_BuildValue( "s", "Bspline" );
else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad widthType...");
- }
- else if (strcmp(name, "mode") == 0)
- {
- if(self->Lattice->flag == 1)
- attr = Py_BuildValue("s","Grid");
- else if (self->Lattice->flag == 3)
- attr = Py_BuildValue("s","Outside");
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad widthType..." );
+ } else if( strcmp( name, "mode" ) == 0 ) {
+ if( self->Lattice->flag == 1 )
+ attr = Py_BuildValue( "s", "Grid" );
+ else if( self->Lattice->flag == 3 )
+ attr = Py_BuildValue( "s", "Outside" );
else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad mode...");
- }
- else if (strcmp(name, "latSize") == 0)
- {
- attr = Py_BuildValue("i",self->Lattice->pntsu *
- self->Lattice->pntsv *
- self->Lattice->pntsw);
- }
- else if (strcmp(name, "__members__") == 0)
- attr = Py_BuildValue("[s,s,s,s,s,s,s,s,s]", "name","width","height","depth",
- "widthType","heightType","depthType","mode","latSize");
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None) return attr; // attribute found, return its value
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad mode..." );
+ } else if( strcmp( name, "latSize" ) == 0 ) {
+ attr = Py_BuildValue( "i", self->Lattice->pntsu *
+ self->Lattice->pntsv *
+ self->Lattice->pntsw );
+ } else if( strcmp( name, "__members__" ) == 0 )
+ attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s]", "name", "width",
+ "height", "depth", "widthType",
+ "heightType", "depthType", "mode",
+ "latSize" );
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; // attribute found, return its value
// not an attribute, search the methods table
- return Py_FindMethod(BPy_Lattice_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Lattice_methods, ( PyObject * ) self, name );
}
//***************************************************************************
-// Function: Lattice_setAttr
-// Description: This is a callback function for the BPy_Lattice type. It is the
-// function that changes Lattice Data members values. If this
-// data is linked to a Blender Lattice, it also gets updated.
+// Function: Lattice_setAttr
+// Description: This is a callback function for the BPy_Lattice type. It is the
+// function that changes Lattice Data members values. If this
+// data is linked to a Blender Lattice, it also gets updated.
//***************************************************************************
-static int Lattice_setAttr (BPy_Lattice *self, char *name, PyObject *value)
+static int Lattice_setAttr( BPy_Lattice * self, char *name, PyObject * value )
{
- PyObject *valtuple;
+ PyObject *valtuple;
PyObject *error = NULL;
- if (!self->Lattice || !Lattice_InLatList(self))
- return EXPP_ReturnIntError (PyExc_RuntimeError,
- "Lattice was already deleted!");
+ if( !self->Lattice || !Lattice_InLatList( self ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "Lattice was already deleted!" );
- valtuple = Py_BuildValue("(O)", value);// the set* functions expect a tuple
+ valtuple = Py_BuildValue( "(O)", value ); // the set* functions expect a tuple
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "LatticeSetAttr: couldn't create PyTuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "LatticeSetAttr: couldn't create PyTuple" );
- if (strcmp (name, "name") == 0)
- error = Lattice_setName (self, valtuple);
- else { // Error: no such member in the Lattice Data structure
- Py_DECREF(value);
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found or immutable"));
+ if( strcmp( name, "name" ) == 0 )
+ error = Lattice_setName( self, valtuple );
+ else { // Error: no such member in the Lattice Data structure
+ Py_DECREF( value );
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found or immutable" ) );
}
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- return 0; // normal exit
+ return 0; // normal exit
}
//***************************************************************************
-// Function: Lattice_repr
-// Description: This is a callback function for the BPy_Lattice type. It
-// builds a meaninful string to represent Lattice objects.
+// Function: Lattice_repr
+// Description: This is a callback function for the BPy_Lattice type. It
+// builds a meaninful string to represent Lattice objects.
//***************************************************************************
-static PyObject *Lattice_repr (BPy_Lattice *self)
+static PyObject *Lattice_repr( BPy_Lattice * self )
{
- if (self->Lattice && Lattice_InLatList(self))
- return PyString_FromFormat("[Lattice \"%s\"]", self->Lattice->id.name+2);
+ if( self->Lattice && Lattice_InLatList( self ) )
+ return PyString_FromFormat( "[Lattice \"%s\"]",
+ self->Lattice->id.name + 2 );
else
- return PyString_FromString("[Lattice <deleted>]");
+ return PyString_FromString( "[Lattice <deleted>]" );
}
//***************************************************************************
-// Function: Internal Lattice functions
+// Function: Internal Lattice functions
//***************************************************************************
// Internal function to confirm if a Lattice wasn't unlinked from main.
-static int Lattice_InLatList(BPy_Lattice *self)
+static int Lattice_InLatList( BPy_Lattice * self )
{
Lattice *lat_iter = G.main->latt.first;
- while (lat_iter) {
- if (self->Lattice == lat_iter) return 1; // ok, still linked
+ while( lat_iter ) {
+ if( self->Lattice == lat_iter )
+ return 1; // ok, still linked
lat_iter = lat_iter->id.next;
}
// uh-oh, it was already deleted
- self->Lattice = NULL; // so we invalidate the pointer
+ self->Lattice = NULL; // so we invalidate the pointer
return 0;
}
// Internal function to confirm if a Lattice has an object it's linked to.
-static int Lattice_IsLinkedToObject(BPy_Lattice *self)
+static int Lattice_IsLinkedToObject( BPy_Lattice * self )
{
//check to see if lattice is linked to an object
- Object * ob= G.main->object.first;
- while(ob) {
- if(ob->type==OB_LATTICE){
- if(self->Lattice == ob->data){
+ Object *ob = G.main->object.first;
+ while( ob ) {
+ if( ob->type == OB_LATTICE ) {
+ if( self->Lattice == ob->data ) {
return 1;
}
- }
+ }
ob = ob->id.next;
}
return 0;
diff --git a/source/blender/python/api2_2x/Lattice.h b/source/blender/python/api2_2x/Lattice.h
index fed500de2c2..a7acc79515d 100644
--- a/source/blender/python/api2_2x/Lattice.h
+++ b/source/blender/python/api2_2x/Lattice.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -51,170 +52,163 @@
#include "modules.h"
/*****************************************************************************/
-/* Python API function prototypes for the Lattice module. */
+/* Python API function prototypes for the Lattice module. */
/*****************************************************************************/
-static PyObject *M_Lattice_New (PyObject *self, PyObject *args);
-static PyObject *M_Lattice_Get(PyObject *self, PyObject *args);
+static PyObject *M_Lattice_New( PyObject * self, PyObject * args );
+static PyObject *M_Lattice_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Lattice.__doc__ Lattice Module strings */
+/* Lattice Module strings */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Lattice.__doc__ */
/*****************************************************************************/
-static char M_Lattice_doc[] =
-"The Blender Lattice module\n\n";
+static char M_Lattice_doc[] = "The Blender Lattice module\n\n";
-static char M_Lattice_New_doc[] =
-"() - return a new Lattice object";
+static char M_Lattice_New_doc[] = "() - return a new Lattice object";
-static char M_Lattice_Get_doc[] =
-"() - geta a Lattice from blender";
+static char M_Lattice_Get_doc[] = "() - geta a Lattice from blender";
/*****************************************************************************/
-/* Python method structure definition for Blender.Lattice module: */
+/* Python method structure definition for Blender.Lattice module: */
/*****************************************************************************/
struct PyMethodDef M_Lattice_methods[] = {
- {"New",(PyCFunction)M_Lattice_New, METH_VARARGS,
- M_Lattice_New_doc},
- {"Get",(PyCFunction)M_Lattice_Get, METH_VARARGS,
- M_Lattice_Get_doc},
+ {"New", ( PyCFunction ) M_Lattice_New, METH_VARARGS,
+ M_Lattice_New_doc},
+ {"Get", ( PyCFunction ) M_Lattice_Get, METH_VARARGS,
+ M_Lattice_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BPy_Lattice structure definition: */
+/* Python BPy_Lattice structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Lattice *Lattice;
+ PyObject_HEAD Lattice * Lattice;
} BPy_Lattice;
/*****************************************************************************/
-/* Python BPy_Lattice methods declarations: */
+/* Python BPy_Lattice methods declarations: */
/*****************************************************************************/
-static PyObject *Lattice_getName(BPy_Lattice *self);
-static PyObject *Lattice_setName(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_setPartitions(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_getPartitions(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_setKeyTypes(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_getKeyTypes(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_setMode(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_getMode(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_setPoint(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_getPoint(BPy_Lattice *self, PyObject *args);
-static PyObject *Lattice_applyDeform(BPy_Lattice *self);
-static PyObject *Lattice_insertKey(BPy_Lattice *self, PyObject *args);
+static PyObject *Lattice_getName( BPy_Lattice * self );
+static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getPartitions( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getMode( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_applyDeform( BPy_Lattice * self );
+static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Lattice.__doc__ Lattice Strings */
+/* Lattice Strings */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Lattice.__doc__ */
/*****************************************************************************/
-static char Lattice_getName_doc[] =
-"() - Return Lattice Object name";
+static char Lattice_getName_doc[] = "() - Return Lattice Object name";
-static char Lattice_setName_doc[] =
-"(str) - Change Lattice Object name";
+static char Lattice_setName_doc[] = "(str) - Change Lattice Object name";
static char Lattice_setPartitions_doc[] =
-"(str) - Set the number of Partitions in x,y,z";
+ "(str) - Set the number of Partitions in x,y,z";
static char Lattice_getPartitions_doc[] =
-"(str) - Get the number of Partitions in x,y,z";
+ "(str) - Get the number of Partitions in x,y,z";
static char Lattice_setKeyTypes_doc[] =
-"(str) - Set the key types for x,y,z dimensions";
+ "(str) - Set the key types for x,y,z dimensions";
static char Lattice_getKeyTypes_doc[] =
-"(str) - Get the key types for x,y,z dimensions";
+ "(str) - Get the key types for x,y,z dimensions";
-static char Lattice_setMode_doc[] =
-"(str) - Make an outside or grid lattice";
+static char Lattice_setMode_doc[] = "(str) - Make an outside or grid lattice";
-static char Lattice_getMode_doc[] =
-"(str) - Get lattice mode type";
+static char Lattice_getMode_doc[] = "(str) - Get lattice mode type";
static char Lattice_setPoint_doc[] =
-"(str) - Set the coordinates of a point on the lattice";
+ "(str) - Set the coordinates of a point on the lattice";
static char Lattice_getPoint_doc[] =
-"(str) - Get the coordinates of a point on the lattice";
+ "(str) - Get the coordinates of a point on the lattice";
static char Lattice_applyDeform_doc[] =
-"(str) - Apply the new lattice deformation to children";
+ "(str) - Apply the new lattice deformation to children";
static char Lattice_insertKey_doc[] =
-"(str) - Set a new key for the lattice at specified frame";
+ "(str) - Set a new key for the lattice at specified frame";
/*****************************************************************************/
-/* Python BPy_Lattice methods table: */
+/* Python BPy_Lattice methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Lattice_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Lattice_getName, METH_NOARGS,
- Lattice_getName_doc},
- {"setName", (PyCFunction)Lattice_setName, METH_VARARGS,
- Lattice_setName_doc},
- {"setPartitions", (PyCFunction)Lattice_setPartitions, METH_VARARGS,
- Lattice_setPartitions_doc},
- {"getPartitions", (PyCFunction)Lattice_getPartitions, METH_NOARGS,
- Lattice_getPartitions_doc},
- {"setKeyTypes", (PyCFunction)Lattice_setKeyTypes, METH_VARARGS,
- Lattice_setKeyTypes_doc},
- {"getKeyTypes", (PyCFunction)Lattice_getKeyTypes, METH_NOARGS,
- Lattice_getKeyTypes_doc},
- {"setMode", (PyCFunction)Lattice_setMode, METH_VARARGS,
- Lattice_setMode_doc},
- {"getMode", (PyCFunction)Lattice_getMode, METH_NOARGS,
- Lattice_getMode_doc},
- {"setPoint", (PyCFunction)Lattice_setPoint, METH_VARARGS,
- Lattice_setPoint_doc},
- {"getPoint", (PyCFunction)Lattice_getPoint, METH_VARARGS,
- Lattice_getPoint_doc},
- {"applyDeform", (PyCFunction)Lattice_applyDeform, METH_NOARGS,
- Lattice_applyDeform_doc},
- {"insertKey", (PyCFunction)Lattice_insertKey, METH_VARARGS,
- Lattice_insertKey_doc},
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Lattice_getName, METH_NOARGS,
+ Lattice_getName_doc},
+ {"setName", ( PyCFunction ) Lattice_setName, METH_VARARGS,
+ Lattice_setName_doc},
+ {"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
+ Lattice_setPartitions_doc},
+ {"getPartitions", ( PyCFunction ) Lattice_getPartitions, METH_NOARGS,
+ Lattice_getPartitions_doc},
+ {"setKeyTypes", ( PyCFunction ) Lattice_setKeyTypes, METH_VARARGS,
+ Lattice_setKeyTypes_doc},
+ {"getKeyTypes", ( PyCFunction ) Lattice_getKeyTypes, METH_NOARGS,
+ Lattice_getKeyTypes_doc},
+ {"setMode", ( PyCFunction ) Lattice_setMode, METH_VARARGS,
+ Lattice_setMode_doc},
+ {"getMode", ( PyCFunction ) Lattice_getMode, METH_NOARGS,
+ Lattice_getMode_doc},
+ {"setPoint", ( PyCFunction ) Lattice_setPoint, METH_VARARGS,
+ Lattice_setPoint_doc},
+ {"getPoint", ( PyCFunction ) Lattice_getPoint, METH_VARARGS,
+ Lattice_getPoint_doc},
+ {"applyDeform", ( PyCFunction ) Lattice_applyDeform, METH_NOARGS,
+ Lattice_applyDeform_doc},
+ {"insertKey", ( PyCFunction ) Lattice_insertKey, METH_VARARGS,
+ Lattice_insertKey_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Lattice_Type callback function prototypes: */
+/* Python Lattice_Type callback function prototypes: */
/*****************************************************************************/
-static void Lattice_dealloc (BPy_Lattice *self);
-static int Lattice_setAttr (BPy_Lattice *self, char *name, PyObject *v);
-static PyObject *Lattice_getAttr (BPy_Lattice *self, char *name);
-static PyObject *Lattice_repr (BPy_Lattice *self);
+static void Lattice_dealloc( BPy_Lattice * self );
+static int Lattice_setAttr( BPy_Lattice * self, char *name, PyObject * v );
+static PyObject *Lattice_getAttr( BPy_Lattice * self, char *name );
+static PyObject *Lattice_repr( BPy_Lattice * self );
/*****************************************************************************/
-/* Python Lattice_Type structure definition: */
+/* Python Lattice_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Lattice_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Lattice", /* tp_name */
- sizeof (BPy_Lattice), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject Lattice_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Lattice", /* tp_name */
+ sizeof( BPy_Lattice ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Lattice_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Lattice_getAttr, /* tp_getattr */
- (setattrfunc)Lattice_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)Lattice_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_Lattice_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) Lattice_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Lattice_getAttr, /* tp_getattr */
+ ( setattrfunc ) Lattice_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) Lattice_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_Lattice_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static int Lattice_InLatList(BPy_Lattice *self);
-static int Lattice_IsLinkedToObject(BPy_Lattice *self);
+static int Lattice_InLatList( BPy_Lattice * self );
+static int Lattice_IsLinkedToObject( BPy_Lattice * self );
-#endif /* EXPP_LATTICE_H */
+#endif /* EXPP_LATTICE_H */
diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c
index d281c21dbc4..09d7424b708 100644
--- a/source/blender/python/api2_2x/Library.c
+++ b/source/blender/python/api2_2x/Library.c
@@ -37,9 +37,9 @@
#include <stdio.h>
#include <DNA_ID.h>
-#include <BKE_library.h> /* for all_local */
-#include "BKE_displist.h" /* for set_displist_onlyzero */
-#include "BKE_font.h" /* for text_to_curve */
+#include <BKE_library.h> /* for all_local */
+#include "BKE_displist.h" /* for set_displist_onlyzero */
+#include "BKE_font.h" /* for text_to_curve */
#include <BLO_readfile.h>
#include <BLI_linklist.h>
#include <MEM_guardedalloc.h>
@@ -50,45 +50,44 @@
/**
* Global variables.
*/
-static BlendHandle *bpy_openlib; /* ptr to the open .blend file */
-static char *bpy_openlibname; /* its pathname */
+static BlendHandle *bpy_openlib; /* ptr to the open .blend file */
+static char *bpy_openlibname; /* its pathname */
/**
* Function prototypes for the Library submodule.
*/
-static PyObject *M_Library_Open(PyObject *self, PyObject *args);
-static PyObject *M_Library_Close(PyObject *self);
-static PyObject *M_Library_GetName(PyObject *self);
-static PyObject *M_Library_Update(PyObject *self);
-static PyObject *M_Library_Datablocks(PyObject *self, PyObject *args);
-static PyObject *M_Library_Load(PyObject *self, PyObject *args);
-static PyObject *M_Library_LinkableGroups(PyObject *self);
+static PyObject *M_Library_Open( PyObject * self, PyObject * args );
+static PyObject *M_Library_Close( PyObject * self );
+static PyObject *M_Library_GetName( PyObject * self );
+static PyObject *M_Library_Update( PyObject * self );
+static PyObject *M_Library_Datablocks( PyObject * self, PyObject * args );
+static PyObject *M_Library_Load( PyObject * self, PyObject * args );
+static PyObject *M_Library_LinkableGroups( PyObject * self );
/**
* Module doc strings.
- */
-static char M_Library_doc[]=
-"The Blender.Library submodule:\n\n\
+ */
+static char M_Library_doc[] = "The Blender.Library submodule:\n\n\
This module gives access to .blend files, using them as libraries of\n\
data that can be loaded into the current scene in Blender.";
static char Library_Open_doc[] =
-"(filename) - Open the given .blend file for access to its objects.\n\
+ "(filename) - Open the given .blend file for access to its objects.\n\
If another library file is still open, it's closed automatically.";
static char Library_Close_doc[] =
-"() - Close the currently open library file, if any.";
+ "() - Close the currently open library file, if any.";
static char Library_GetName_doc[] =
-"() - Get the filename of the currently open library file, if any.";
+ "() - Get the filename of the currently open library file, if any.";
static char Library_Datablocks_doc[] =
-"(datablock) - List all datablocks of the given type in the currently\n\
+ "(datablock) - List all datablocks of the given type in the currently\n\
open library file.\n\
(datablock) - datablock name as a string: Object, Mesh, etc.";
static char Library_Load_doc[] =
-"(name, datablock [,update = 1]) - Append object 'name' of type 'datablock'\n\
+ "(name, datablock [,update = 1]) - Append object 'name' of type 'datablock'\n\
from the open library file to the current scene.\n\
(name) - (str) the name of the object.\n\
(datablock) - (str) the datablock of the object.\n\
@@ -97,27 +96,31 @@ links are updated. This is slow, set it to zero if you have more than one\n\
object to load, then call Library.Update() after loading them all.";
static char Library_Update_doc[] =
-"() - Update the current scene, linking all loaded library objects and\n\
+ "() - Update the current scene, linking all loaded library objects and\n\
remaking all display lists. This is slow, call it only once after loading\n\
all objects (load each of them with update = 0:\n\
Library.Load(name, datablock, 0), or the update will be automatic, repeated\n\
for each loaded object.";
static char Library_LinkableGroups_doc[] =
-"() - Get all linkable groups from the open .blend library file.";
+ "() - Get all linkable groups from the open .blend library file.";
/**
* Python method structure definition for Blender.Library submodule.
*/
struct PyMethodDef M_Library_methods[] = {
{"Open", M_Library_Open, METH_VARARGS, Library_Open_doc},
- {"Close",(PyCFunction)M_Library_Close, METH_NOARGS, Library_Close_doc},
- {"GetName",(PyCFunction)M_Library_GetName, METH_NOARGS, Library_GetName_doc},
- {"Update",(PyCFunction)M_Library_Update, METH_NOARGS, Library_Update_doc},
- {"Datablocks", M_Library_Datablocks, METH_VARARGS, Library_Datablocks_doc},
+ {"Close", ( PyCFunction ) M_Library_Close, METH_NOARGS,
+ Library_Close_doc},
+ {"GetName", ( PyCFunction ) M_Library_GetName, METH_NOARGS,
+ Library_GetName_doc},
+ {"Update", ( PyCFunction ) M_Library_Update, METH_NOARGS,
+ Library_Update_doc},
+ {"Datablocks", M_Library_Datablocks, METH_VARARGS,
+ Library_Datablocks_doc},
{"Load", M_Library_Load, METH_VARARGS, Library_Load_doc},
- {"LinkableGroups",(PyCFunction)M_Library_LinkableGroups,
- METH_NOARGS, Library_LinkableGroups_doc},
+ {"LinkableGroups", ( PyCFunction ) M_Library_LinkableGroups,
+ METH_NOARGS, Library_LinkableGroups_doc},
{NULL, NULL, 0, NULL}
};
@@ -128,51 +131,52 @@ struct PyMethodDef M_Library_methods[] = {
* Only one can be open at a time, so this function also closes
* the previously opened file, if any.
*/
-PyObject *M_Library_Open(PyObject *self, PyObject *args)
+PyObject *M_Library_Open( PyObject * self, PyObject * args )
{
char *fname = NULL;
int len = 0;
- if (!PyArg_ParseTuple (args, "s", &fname)) {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a .blend filename");
+ if( !PyArg_ParseTuple( args, "s", &fname ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a .blend filename" );
}
- if (bpy_openlib) {
- M_Library_Close(self);
- Py_DECREF(Py_None); /* incref'ed by above function */
+ if( bpy_openlib ) {
+ M_Library_Close( self );
+ Py_DECREF( Py_None ); /* incref'ed by above function */
}
- bpy_openlib = BLO_blendhandle_from_file(fname);
+ bpy_openlib = BLO_blendhandle_from_file( fname );
- if (!bpy_openlib) return Py_BuildValue("i", 0);
+ if( !bpy_openlib )
+ return Py_BuildValue( "i", 0 );
- len = strlen(fname) + 1; /* +1 for terminating '\0' */
+ len = strlen( fname ) + 1; /* +1 for terminating '\0' */
- bpy_openlibname = MEM_mallocN(len, "bpy_openlibname");
+ bpy_openlibname = MEM_mallocN( len, "bpy_openlibname" );
- if (bpy_openlibname)
- PyOS_snprintf (bpy_openlibname, len, "%s", fname);
+ if( bpy_openlibname )
+ PyOS_snprintf( bpy_openlibname, len, "%s", fname );
- return Py_BuildValue("i", 1);
+ return Py_BuildValue( "i", 1 );
}
/**
* Close the current .blend file, if any.
*/
-PyObject *M_Library_Close(PyObject *self)
+PyObject *M_Library_Close( PyObject * self )
{
- if (bpy_openlib) {
- BLO_blendhandle_close(bpy_openlib);
+ if( bpy_openlib ) {
+ BLO_blendhandle_close( bpy_openlib );
bpy_openlib = NULL;
}
- if (bpy_openlibname) {
- MEM_freeN (bpy_openlibname);
+ if( bpy_openlibname ) {
+ MEM_freeN( bpy_openlibname );
bpy_openlibname = NULL;
}
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -180,15 +184,15 @@ PyObject *M_Library_Close(PyObject *self)
* helper function for 'atexit' clean-ups, used by BPY_end_python,
* declared in EXPP_interface.h.
*/
-void EXPP_Library_Close(void)
+void EXPP_Library_Close( void )
{
- if (bpy_openlib) {
- BLO_blendhandle_close(bpy_openlib);
+ if( bpy_openlib ) {
+ BLO_blendhandle_close( bpy_openlib );
bpy_openlib = NULL;
}
- if (bpy_openlibname) {
- MEM_freeN (bpy_openlibname);
+ if( bpy_openlibname ) {
+ MEM_freeN( bpy_openlibname );
bpy_openlibname = NULL;
}
}
@@ -196,12 +200,12 @@ void EXPP_Library_Close(void)
/**
* Get the filename of the currently open library file, if any.
*/
-PyObject *M_Library_GetName(PyObject *self)
+PyObject *M_Library_GetName( PyObject * self )
{
- if (bpy_openlib && bpy_openlibname)
- return Py_BuildValue("s", bpy_openlibname);
+ if( bpy_openlib && bpy_openlibname )
+ return Py_BuildValue( "s", bpy_openlibname );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -209,44 +213,46 @@ PyObject *M_Library_GetName(PyObject *self)
* Return a list with all items of a given datablock type
* (like 'Object', 'Mesh', etc.) in the open library file.
*/
-PyObject *M_Library_Datablocks(PyObject *self, PyObject *args)
+PyObject *M_Library_Datablocks( PyObject * self, PyObject * args )
{
char *name = NULL;
int blocktype = 0;
LinkNode *l = NULL, *names = NULL;
PyObject *list = NULL;
- if (!bpy_openlib) {
- return EXPP_ReturnPyObjError(PyExc_IOError,
- "no library file: open one first with Blender.Lib_Open(filename)");
+ if( !bpy_openlib ) {
+ return EXPP_ReturnPyObjError( PyExc_IOError,
+ "no library file: open one first with Blender.Lib_Open(filename)" );
}
- if (!PyArg_ParseTuple (args, "s", &name)) {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string (datablock type) as argument.");
+ if( !PyArg_ParseTuple( args, "s", &name ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string (datablock type) as argument." );
}
- blocktype = (int)BLO_idcode_from_name(name);
+ blocktype = ( int ) BLO_idcode_from_name( name );
- if (!blocktype) {
- return EXPP_ReturnPyObjError (PyExc_NameError,
- "no such Blender datablock type");
+ if( !blocktype ) {
+ return EXPP_ReturnPyObjError( PyExc_NameError,
+ "no such Blender datablock type" );
}
- names = BLO_blendhandle_get_datablock_names(bpy_openlib, blocktype);
+ names = BLO_blendhandle_get_datablock_names( bpy_openlib, blocktype );
- if (names) {
+ if( names ) {
int counter = 0;
- list = PyList_New(BLI_linklist_length(names));
- for (l = names; l; l = l->next) {
- PyList_SET_ITEM(list, counter, Py_BuildValue("s", (char *)l->link));
+ list = PyList_New( BLI_linklist_length( names ) );
+ for( l = names; l; l = l->next ) {
+ PyList_SET_ITEM( list, counter,
+ Py_BuildValue( "s",
+ ( char * ) l->link ) );
counter++;
}
- BLI_linklist_free(names, free); /* free linklist *and* each node's data */
+ BLI_linklist_free( names, free ); /* free linklist *and* each node's data */
return list;
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -254,30 +260,32 @@ PyObject *M_Library_Datablocks(PyObject *self, PyObject *args)
* Return a list with the names of all linkable groups in the
* open library file.
*/
-PyObject *M_Library_LinkableGroups(PyObject *self)
+PyObject *M_Library_LinkableGroups( PyObject * self )
{
LinkNode *l = NULL, *names = NULL;
PyObject *list = NULL;
- if (!bpy_openlib) {
- return EXPP_ReturnPyObjError(PyExc_IOError,
- "no library file: open one first with Blender.Lib_Open(filename)");
+ if( !bpy_openlib ) {
+ return EXPP_ReturnPyObjError( PyExc_IOError,
+ "no library file: open one first with Blender.Lib_Open(filename)" );
}
- names = BLO_blendhandle_get_linkable_groups(bpy_openlib);
+ names = BLO_blendhandle_get_linkable_groups( bpy_openlib );
- if (names) {
+ if( names ) {
int counter = 0;
- list = PyList_New(BLI_linklist_length(names));
- for (l = names; l; l = l->next) {
- PyList_SET_ITEM(list, counter, Py_BuildValue("s", (char *)l->link));
+ list = PyList_New( BLI_linklist_length( names ) );
+ for( l = names; l; l = l->next ) {
+ PyList_SET_ITEM( list, counter,
+ Py_BuildValue( "s",
+ ( char * ) l->link ) );
counter++;
}
- BLI_linklist_free(names, free); /* free linklist *and* each node's data */
+ BLI_linklist_free( names, free ); /* free linklist *and* each node's data */
return list;
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -285,81 +293,84 @@ PyObject *M_Library_LinkableGroups(PyObject *self)
* Load (append) a given datablock of a given datablock type
* to the current scene.
*/
-PyObject *M_Library_Load(PyObject *self, PyObject *args)
+PyObject *M_Library_Load( PyObject * self, PyObject * args )
{
char *name = NULL;
char *base = NULL;
int update = 1;
int blocktype = 0;
- if (!bpy_openlib) {
- return EXPP_ReturnPyObjError(PyExc_IOError,
- "no library file: you need to open one, first.");
+ if( !bpy_openlib ) {
+ return EXPP_ReturnPyObjError( PyExc_IOError,
+ "no library file: you need to open one, first." );
}
- if (!PyArg_ParseTuple (args, "ss|i", &name, &base, &update)) {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected two strings as arguments.");
+ if( !PyArg_ParseTuple( args, "ss|i", &name, &base, &update ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected two strings as arguments." );
}
- blocktype = (int)BLO_idcode_from_name(base);
+ blocktype = ( int ) BLO_idcode_from_name( base );
- if (!blocktype) {
- return EXPP_ReturnPyObjError (PyExc_NameError,
- "no such Blender datablock type");
+ if( !blocktype ) {
+ return EXPP_ReturnPyObjError( PyExc_NameError,
+ "no such Blender datablock type" );
}
- BLO_script_library_append(bpy_openlib, bpy_openlibname, name, blocktype);
+ BLO_script_library_append( bpy_openlib, bpy_openlibname, name,
+ blocktype );
- if (update) {
- M_Library_Update(self);
- Py_DECREF(Py_None); /* incref'ed by above function */
+ if( update ) {
+ M_Library_Update( self );
+ Py_DECREF( Py_None ); /* incref'ed by above function */
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/**
* Update all links and remake displists.
*/
-PyObject *M_Library_Update(PyObject *self)
-{ /* code adapted from do_library_append in src/filesel.c: */
+PyObject *M_Library_Update( PyObject * self )
+{ /* code adapted from do_library_append in src/filesel.c: */
Object *ob = NULL;
Library *lib = NULL;
ob = G.main->object.first;
- set_displist_onlyzero(1);
- while (ob) {
- if (ob->id.lib) {
- if (ob->type==OB_FONT) {
- Curve *cu= ob->data;
- if (cu->nurb.first==0) text_to_curve(ob, 0);
+ set_displist_onlyzero( 1 );
+ while( ob ) {
+ if( ob->id.lib ) {
+ if( ob->type == OB_FONT ) {
+ Curve *cu = ob->data;
+ if( cu->nurb.first == 0 )
+ text_to_curve( ob, 0 );
}
- makeDispList(ob);
- }
- else {
- if (ob->type == OB_MESH && ob->parent && ob->parent->type == OB_LATTICE)
- makeDispList(ob);
+ makeDispList( ob );
+ } else {
+ if( ob->type == OB_MESH && ob->parent
+ && ob->parent->type == OB_LATTICE )
+ makeDispList( ob );
}
ob = ob->id.next;
}
- set_displist_onlyzero(0);
+ set_displist_onlyzero( 0 );
- if (bpy_openlibname) {
- strcpy(G.lib, bpy_openlibname);
+ if( bpy_openlibname ) {
+ strcpy( G.lib, bpy_openlibname );
/* and now find the latest append lib file */
lib = G.main->library.first;
- while (lib) {
- if (strcmp(bpy_openlibname, lib->name) == 0) break;
+ while( lib ) {
+ if( strcmp( bpy_openlibname, lib->name ) == 0 )
+ break;
lib = lib->id.next;
}
- all_local(lib);
+ all_local( lib );
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -368,11 +379,12 @@ PyObject *M_Library_Update(PyObject *self)
* Called by Blender_Init in Blender.c .
* @return the registered submodule.
*/
-PyObject *Library_Init (void)
+PyObject *Library_Init( void )
{
PyObject *submod;
- submod = Py_InitModule3("Blender.Library", M_Library_methods, M_Library_doc);
+ submod = Py_InitModule3( "Blender.Library", M_Library_methods,
+ M_Library_doc );
return submod;
}
diff --git a/source/blender/python/api2_2x/MTex.c b/source/blender/python/api2_2x/MTex.c
index 8a8d247b320..0e870cd385f 100644
--- a/source/blender/python/api2_2x/MTex.c
+++ b/source/blender/python/api2_2x/MTex.c
@@ -48,97 +48,96 @@
/*****************************************************************************/
/* Python BPy_MTex methods declarations: */
/*****************************************************************************/
-static PyObject *MTex_setTex(BPy_MTex *self, PyObject *args);
+static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args );
/*****************************************************************************/
/* Python method structure definition for Blender.Texture.MTex module: */
/*****************************************************************************/
struct PyMethodDef M_MTex_methods[] = {
- {NULL, NULL, 0, NULL}
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_MTex methods table: */
/*****************************************************************************/
static PyMethodDef BPy_MTex_methods[] = {
- /* name, method, flags, doc */
- {"setTex", (PyCFunction)MTex_setTex, METH_VARARGS,
- "(i) - Set MTex Texture"},
- {NULL, NULL,0, NULL}
+ /* name, method, flags, doc */
+ {"setTex", ( PyCFunction ) MTex_setTex, METH_VARARGS,
+ "(i) - Set MTex Texture"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python MTex_Type callback function prototypes: */
/*****************************************************************************/
-static void MTex_dealloc (BPy_MTex *self);
-static int MTex_setAttr (BPy_MTex *self, char *name, PyObject *v);
-static int MTex_compare (BPy_MTex *a, BPy_MTex *b);
-static PyObject *MTex_getAttr (BPy_MTex *self, char *name);
-static PyObject *MTex_repr (BPy_MTex *self);
+static void MTex_dealloc( BPy_MTex * self );
+static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * v );
+static int MTex_compare( BPy_MTex * a, BPy_MTex * b );
+static PyObject *MTex_getAttr( BPy_MTex * self, char *name );
+static PyObject *MTex_repr( BPy_MTex * self );
/*****************************************************************************/
/* Python MTex_Type structure definition: */
/*****************************************************************************/
-PyTypeObject MTex_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender MTex", /* tp_name */
- sizeof (BPy_MTex), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)MTex_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)MTex_getAttr, /* tp_getattr */
- (setattrfunc)MTex_setAttr, /* tp_setattr */
- (cmpfunc)MTex_compare, /* tp_compare */
- (reprfunc)MTex_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,
- 0, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject MTex_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender MTex", /* tp_name */
+ sizeof( BPy_MTex ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) MTex_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) MTex_getAttr, /* tp_getattr */
+ ( setattrfunc ) MTex_setAttr, /* tp_setattr */
+ ( cmpfunc ) MTex_compare, /* tp_compare */
+ ( reprfunc ) MTex_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,
+ 0, /* tp_methods */
+ 0, /* tp_members */
};
-PyObject *MTex_Init (void)
+PyObject *MTex_Init( void )
{
- PyObject *submodule;
-
- MTex_Type.ob_type = &PyType_Type;
+ PyObject *submodule;
+
+ MTex_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule("Blender.Texture.MTex", M_MTex_methods);
-
- return submodule;
+ submodule = Py_InitModule( "Blender.Texture.MTex", M_MTex_methods );
+
+ return submodule;
}
-PyObject *MTex_CreatePyObject (MTex *mtex)
+PyObject *MTex_CreatePyObject( MTex * mtex )
{
- BPy_MTex *pymtex;
+ BPy_MTex *pymtex;
- pymtex = (BPy_MTex *) PyObject_NEW (BPy_MTex, &MTex_Type);
- if (!pymtex)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_MTex PyObject");
+ pymtex = ( BPy_MTex * ) PyObject_NEW( BPy_MTex, &MTex_Type );
+ if( !pymtex )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_MTex PyObject" );
- pymtex->mtex = mtex;
- return (PyObject *) pymtex;
+ pymtex->mtex = mtex;
+ return ( PyObject * ) pymtex;
}
-MTex *MTex_FromPyObject (PyObject *pyobj)
+MTex *MTex_FromPyObject( PyObject * pyobj )
{
- return ((BPy_MTex *)pyobj)->mtex;
+ return ( ( BPy_MTex * ) pyobj )->mtex;
}
-int MTex_CheckPyObject (PyObject *pyobj)
+int MTex_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &MTex_Type);
+ return ( pyobj->ob_type == &MTex_Type );
}
@@ -146,111 +145,104 @@ int MTex_CheckPyObject (PyObject *pyobj)
/* Python BPy_MTex methods: */
/*****************************************************************************/
-static PyObject *MTex_setTex(BPy_MTex *self, PyObject *args)
+static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args )
{
- BPy_Texture *pytex = NULL;
- if (!PyArg_ParseTuple(args, "O!", &Texture_Type, &pytex))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Texture argument");
-
- if (self->mtex->tex)
- self->mtex->tex->id.us--;
-
- self->mtex->tex = Texture_FromPyObject((PyObject*)pytex);
-
- Py_INCREF(Py_None);
- return Py_None;
+ BPy_Texture *pytex = NULL;
+ if( !PyArg_ParseTuple( args, "O!", &Texture_Type, &pytex ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Texture argument" );
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us--;
+
+ self->mtex->tex = Texture_FromPyObject( ( PyObject * ) pytex );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static void MTex_dealloc (BPy_MTex *self)
+static void MTex_dealloc( BPy_MTex * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *MTex_getAttr (BPy_MTex *self, char *name)
+static PyObject *MTex_getAttr( BPy_MTex * self, char *name )
{
- if (STREQ(name, "tex"))
- {
- if (self->mtex->tex)
- return Texture_CreatePyObject (self->mtex->tex);
- else
- {
- Py_INCREF (Py_None);
- return Py_None;
- }
- }
- else if (STREQ(name, "texco"))
- return PyInt_FromLong(self->mtex->texco);
- else if (STREQ(name, "mapto"))
- return PyInt_FromLong(self->mtex->mapto);
-
- else if (STREQ(name, "__members__"))
- return Py_BuildValue("[s,s,s]", "tex", "texco", "mapto");
-
- /* not an attribute, search the methods table */
- return Py_FindMethod(BPy_MTex_methods, (PyObject *)self, name);
+ if( STREQ( name, "tex" ) ) {
+ if( self->mtex->tex )
+ return Texture_CreatePyObject( self->mtex->tex );
+ else {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ } else if( STREQ( name, "texco" ) )
+ return PyInt_FromLong( self->mtex->texco );
+ else if( STREQ( name, "mapto" ) )
+ return PyInt_FromLong( self->mtex->mapto );
+
+ else if( STREQ( name, "__members__" ) )
+ return Py_BuildValue( "[s,s,s]", "tex", "texco", "mapto" );
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_MTex_methods, ( PyObject * ) self, name );
}
-static int MTex_setAttr (BPy_MTex *self, char *name, PyObject *value)
+static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- /* Put "value" in a tuple, because we want to pass it to functions *
- * that only accept PyTuples. */
- valtuple = Py_BuildValue("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "MTex_setAttr: couldn't create PyTuple");
-
- if (STREQ(name, "tex"))
- error = MTex_setTex(self, valtuple);
- else if (STREQ(name, "texco"))
- {
- if (PyInt_Check(value))
- {
- int texco = PyInt_AsLong(value);
- /* TODO: sanity-check this input! */
- self->mtex->texco = texco;
- Py_INCREF (Py_None); /* because we decref it below */
- error = Py_None;
- }
- }
- else if (STREQ(name, "mapto"))
- {
- if (PyInt_Check(value))
- {
- int mapto = PyInt_AsLong(value);
- /* TODO: sanity-check this input! */
- self->mtex->mapto = mapto;
- Py_INCREF (Py_None); /* because we decref it below */
- error = Py_None;
- }
- }
-
- else {
- /* Error */
- Py_DECREF(valtuple);
- return EXPP_ReturnIntError (PyExc_KeyError, "attribute not found");
- }
-
- Py_DECREF (valtuple);
-
- if (error != Py_None) return -1;
-
- /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
- Py_DECREF (Py_None);
-
- return 0;
+ PyObject *valtuple;
+ PyObject *error = NULL;
+
+ /* Put "value" in a tuple, because we want to pass it to functions *
+ * that only accept PyTuples. */
+ valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "MTex_setAttr: couldn't create PyTuple" );
+
+ if( STREQ( name, "tex" ) )
+ error = MTex_setTex( self, valtuple );
+ else if( STREQ( name, "texco" ) ) {
+ if( PyInt_Check( value ) ) {
+ int texco = PyInt_AsLong( value );
+ /* TODO: sanity-check this input! */
+ self->mtex->texco = texco;
+ Py_INCREF( Py_None ); /* because we decref it below */
+ error = Py_None;
+ }
+ } else if( STREQ( name, "mapto" ) ) {
+ if( PyInt_Check( value ) ) {
+ int mapto = PyInt_AsLong( value );
+ /* TODO: sanity-check this input! */
+ self->mtex->mapto = mapto;
+ Py_INCREF( Py_None ); /* because we decref it below */
+ error = Py_None;
+ }
+ }
+
+ else {
+ /* Error */
+ Py_DECREF( valtuple );
+ return EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" );
+ }
+
+ Py_DECREF( valtuple );
+
+ if( error != Py_None )
+ return -1;
+
+ /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
+ Py_DECREF( Py_None );
+
+ return 0;
}
-static int MTex_compare (BPy_MTex *a, BPy_MTex *b)
+static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
{
- return (a->mtex == b->mtex) ? 0 : -1;
+ return ( a->mtex == b->mtex ) ? 0 : -1;
}
-static PyObject *MTex_repr (BPy_MTex *self)
+static PyObject *MTex_repr( BPy_MTex * self )
{
- return PyString_FromFormat("[MTex]");
+ return PyString_FromFormat( "[MTex]" );
}
-
diff --git a/source/blender/python/api2_2x/MTex.h b/source/blender/python/api2_2x/MTex.h
index 0363f16c4da..c73b787197f 100644
--- a/source/blender/python/api2_2x/MTex.h
+++ b/source/blender/python/api2_2x/MTex.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -42,11 +43,10 @@
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- MTex *mtex;
+ PyObject_HEAD MTex * mtex;
} BPy_MTex;
-extern PyTypeObject MTex_Type;
+extern PyTypeObject MTex_Type;
#define BPy_MTex_Check(v) ((v)->ob_type == &MTex_Type)
@@ -55,11 +55,10 @@ extern PyTypeObject MTex_Type;
/* Module Blender.Texture.MTex - public functions */
/*****************************************************************************/
-PyObject *MTex_Init (void);
-PyObject* MTex_CreatePyObject (struct MTex *obj);
-int MTex_CheckPyObject (PyObject *py_obj);
-MTex* MTex_FromPyObject (PyObject *py_obj);
+PyObject *MTex_Init( void );
+PyObject *MTex_CreatePyObject( struct MTex *obj );
+int MTex_CheckPyObject( PyObject * py_obj );
+MTex *MTex_FromPyObject( PyObject * py_obj );
-#endif /* EXPP_MTEX_H */
-
+#endif /* EXPP_MTEX_H */
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index b17d7d2c93b..6b0b7f35c42 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -48,55 +48,55 @@
#include "Material.h"
/*****************************************************************************/
-/* Python BPy_Material defaults: */
+/* Python BPy_Material defaults: */
/*****************************************************************************/
-#define EXPP_MAT_MODE_TRACEABLE MA_TRACEBLE
-#define EXPP_MAT_MODE_SHADOW MA_SHADOW
-#define EXPP_MAT_MODE_SHADELESS MA_SHLESS
-#define EXPP_MAT_MODE_WIRE MA_WIRE
-#define EXPP_MAT_MODE_VCOL_LIGHT MA_VERTEXCOL
-#define EXPP_MAT_MODE_HALO MA_HALO
-#define EXPP_MAT_MODE_ZTRANSP MA_ZTRA
-#define EXPP_MAT_MODE_VCOL_PAINT MA_VERTEXCOLP
-#define EXPP_MAT_MODE_ZINVERT MA_ZINV
-#define EXPP_MAT_MODE_HALORINGS MA_HALO_RINGS
-#define EXPP_MAT_MODE_ENV MA_ENV
-#define EXPP_MAT_MODE_HALOLINES MA_HALO_LINES
-#define EXPP_MAT_MODE_ONLYSHADOW MA_ONLYSHADOW
-#define EXPP_MAT_MODE_HALOXALPHA MA_HALO_XALPHA
-#define EXPP_MAT_MODE_HALOSTAR MA_STAR
-#define EXPP_MAT_MODE_TEXFACE MA_FACETEXTURE
-#define EXPP_MAT_MODE_HALOTEX MA_HALOTEX
-#define EXPP_MAT_MODE_HALOPUNO MA_HALOPUNO
-#define EXPP_MAT_MODE_NOMIST MA_NOMIST
-#define EXPP_MAT_MODE_HALOSHADE MA_HALO_SHADE
-#define EXPP_MAT_MODE_HALOFLARE MA_HALO_FLARE
-#define EXPP_MAT_MODE_RADIO MA_RADIO
-#define EXPP_MAT_MODE_RAYMIRROR MA_RAYMIRROR
-#define EXPP_MAT_MODE_ZTRA MA_ZTRA
-#define EXPP_MAT_MODE_RAYTRANSP MA_RAYTRANSP
-#define EXPP_MAT_MODE_ONLYSHADOW MA_ONLYSHADOW
-#define EXPP_MAT_MODE_NOMIST MA_NOMIST
-#define EXPP_MAT_MODE_ENV MA_ENV
+#define EXPP_MAT_MODE_TRACEABLE MA_TRACEBLE
+#define EXPP_MAT_MODE_SHADOW MA_SHADOW
+#define EXPP_MAT_MODE_SHADELESS MA_SHLESS
+#define EXPP_MAT_MODE_WIRE MA_WIRE
+#define EXPP_MAT_MODE_VCOL_LIGHT MA_VERTEXCOL
+#define EXPP_MAT_MODE_HALO MA_HALO
+#define EXPP_MAT_MODE_ZTRANSP MA_ZTRA
+#define EXPP_MAT_MODE_VCOL_PAINT MA_VERTEXCOLP
+#define EXPP_MAT_MODE_ZINVERT MA_ZINV
+#define EXPP_MAT_MODE_HALORINGS MA_HALO_RINGS
+#define EXPP_MAT_MODE_ENV MA_ENV
+#define EXPP_MAT_MODE_HALOLINES MA_HALO_LINES
+#define EXPP_MAT_MODE_ONLYSHADOW MA_ONLYSHADOW
+#define EXPP_MAT_MODE_HALOXALPHA MA_HALO_XALPHA
+#define EXPP_MAT_MODE_HALOSTAR MA_STAR
+#define EXPP_MAT_MODE_TEXFACE MA_FACETEXTURE
+#define EXPP_MAT_MODE_HALOTEX MA_HALOTEX
+#define EXPP_MAT_MODE_HALOPUNO MA_HALOPUNO
+#define EXPP_MAT_MODE_NOMIST MA_NOMIST
+#define EXPP_MAT_MODE_HALOSHADE MA_HALO_SHADE
+#define EXPP_MAT_MODE_HALOFLARE MA_HALO_FLARE
+#define EXPP_MAT_MODE_RADIO MA_RADIO
+#define EXPP_MAT_MODE_RAYMIRROR MA_RAYMIRROR
+#define EXPP_MAT_MODE_ZTRA MA_ZTRA
+#define EXPP_MAT_MODE_RAYTRANSP MA_RAYTRANSP
+#define EXPP_MAT_MODE_ONLYSHADOW MA_ONLYSHADOW
+#define EXPP_MAT_MODE_NOMIST MA_NOMIST
+#define EXPP_MAT_MODE_ENV MA_ENV
/* Material MIN, MAX values */
-#define EXPP_MAT_ADD_MIN 0.0
-#define EXPP_MAT_ADD_MAX 1.0
-#define EXPP_MAT_ALPHA_MIN 0.0
-#define EXPP_MAT_ALPHA_MAX 1.0
-#define EXPP_MAT_AMB_MIN 0.0
-#define EXPP_MAT_AMB_MAX 1.0
-#define EXPP_MAT_COL_MIN 0.0 /* min/max for all ... */
-#define EXPP_MAT_COL_MAX 1.0 /* ... color triplets */
-#define EXPP_MAT_EMIT_MIN 0.0
-#define EXPP_MAT_EMIT_MAX 1.0
-#define EXPP_MAT_REF_MIN 0.0
-#define EXPP_MAT_REF_MAX 1.0
-#define EXPP_MAT_SPEC_MIN 0.0
-#define EXPP_MAT_SPEC_MAX 2.0
+#define EXPP_MAT_ADD_MIN 0.0
+#define EXPP_MAT_ADD_MAX 1.0
+#define EXPP_MAT_ALPHA_MIN 0.0
+#define EXPP_MAT_ALPHA_MAX 1.0
+#define EXPP_MAT_AMB_MIN 0.0
+#define EXPP_MAT_AMB_MAX 1.0
+#define EXPP_MAT_COL_MIN 0.0 /* min/max for all ... */
+#define EXPP_MAT_COL_MAX 1.0 /* ... color triplets */
+#define EXPP_MAT_EMIT_MIN 0.0
+#define EXPP_MAT_EMIT_MAX 1.0
+#define EXPP_MAT_REF_MIN 0.0
+#define EXPP_MAT_REF_MAX 1.0
+#define EXPP_MAT_SPEC_MIN 0.0
+#define EXPP_MAT_SPEC_MAX 2.0
#define EXPP_MAT_SPECTRA_MIN 0.0
#define EXPP_MAT_SPECTRA_MAX 1.0
-#define EXPP_MAT_ZOFFS_MIN 0.0
-#define EXPP_MAT_ZOFFS_MAX 10.0
+#define EXPP_MAT_ZOFFS_MIN 0.0
+#define EXPP_MAT_ZOFFS_MAX 10.0
#define EXPP_MAT_HALOSIZE_MIN 0.0
#define EXPP_MAT_HALOSIZE_MAX 100.0
#define EXPP_MAT_FLARESIZE_MIN 0.1
@@ -107,9 +107,9 @@
#define EXPP_MAT_SUBSIZE_MAX 25.0
#define EXPP_MAT_HARD_MIN 1
-#define EXPP_MAT_HARD_MAX 255 /* 127 with MODE HALO ON */
+#define EXPP_MAT_HARD_MAX 255 /* 127 with MODE HALO ON */
#define EXPP_MAT_HALOSEED_MIN 1
-#define EXPP_MAT_HALOSEED_MAX 255
+#define EXPP_MAT_HALOSEED_MAX 255
#define EXPP_MAT_NFLARES_MIN 1
#define EXPP_MAT_NFLARES_MAX 32
#define EXPP_MAT_FLARESEED_MIN 1
@@ -151,135 +151,140 @@
/*****************************************************************************/
-/* Python API function prototypes for the Material module. */
+/* Python API function prototypes for the Material module. */
/*****************************************************************************/
-static PyObject *M_Material_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Material_Get (PyObject *self, PyObject *args);
+static PyObject *M_Material_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Material_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Material.__doc__ */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Material.__doc__ */
/*****************************************************************************/
-static char M_Material_doc[] =
-"The Blender Material module";
+static char M_Material_doc[] = "The Blender Material module";
static char M_Material_New_doc[] =
-"(name) - return a new material called 'name'\n\
+ "(name) - return a new material called 'name'\n\
() - return a new material called 'Mat'";
static char M_Material_Get_doc[] =
-"(name) - return the material called 'name', None if not found.\n\
+ "(name) - return the material called 'name', None if not found.\n\
() - return a list of all materials in the current scene.";
/*****************************************************************************/
-/* Python method structure definition for Blender.Material module: */
+/* Python method structure definition for Blender.Material module: */
/*****************************************************************************/
struct PyMethodDef M_Material_methods[] = {
- {"New",(PyCFunction)M_Material_New, METH_VARARGS|METH_KEYWORDS,
- M_Material_New_doc},
- {"Get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
- {"get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
+ {"New", ( PyCFunction ) M_Material_New, METH_VARARGS | METH_KEYWORDS,
+ M_Material_New_doc},
+ {"Get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
+ {"get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Function: M_Material_New */
-/* Python equivalent: Blender.Material.New */
+/* Function: M_Material_New */
+/* Python equivalent: Blender.Material.New */
/*****************************************************************************/
-static PyObject *M_Material_New(PyObject *self, PyObject *args,
- PyObject *keywords)
+static PyObject *M_Material_New( PyObject * self, PyObject * args,
+ PyObject * keywords )
{
char *name = "Mat";
- static char *kwlist[] = {"name", NULL};
+ static char *kwlist[] = { "name", NULL };
BPy_Material *pymat; /* for Material Data object wrapper in Python */
Material *blmat; /* for actual Material Data we create in Blender */
char buf[21];
- if (!PyArg_ParseTupleAndKeywords(args, keywords, "|s", kwlist, &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string or nothing as argument"));
+ if( !PyArg_ParseTupleAndKeywords
+ ( args, keywords, "|s", kwlist, &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected string or nothing as argument" ) );
- if (strcmp(name, "Mat") != 0) /* use gave us a name ?*/
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ if( strcmp( name, "Mat" ) != 0 ) /* use gave us a name ? */
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- blmat = add_material(name); /* first create the Material Data in Blender */
+ blmat = add_material( name ); /* first create the Material Data in Blender */
- if (blmat) /* now create the wrapper obj in Python */
- pymat = (BPy_Material *)Material_CreatePyObject (blmat);
+ if( blmat ) /* now create the wrapper obj in Python */
+ pymat = ( BPy_Material * ) Material_CreatePyObject( blmat );
else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Material Data in Blender"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Material Data in Blender" ) );
- blmat->id.us = 0; /* was incref'ed by add_material() above */
+ blmat->id.us = 0; /* was incref'ed by add_material() above */
- if (pymat == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Material Data object"));
+ if( pymat == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Material Data object" ) );
- return (PyObject *)pymat;
+ return ( PyObject * ) pymat;
}
/*****************************************************************************/
-/* Function: M_Material_Get */
-/* Python equivalent: Blender.Material.Get */
-/* Description: Receives a string and returns the material whose */
-/* name matches the string. If no argument is */
-/* passed in, a list with all materials in the */
-/* current scene is returned. */
+/* Function: M_Material_Get */
+/* Python equivalent: Blender.Material.Get */
+/* Description: Receives a string and returns the material whose */
+/* name matches the string. If no argument is */
+/* passed in, a list with all materials in the */
+/* current scene is returned. */
/*****************************************************************************/
-static PyObject *M_Material_Get(PyObject *self, PyObject *args)
+static PyObject *M_Material_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
Material *mat_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
mat_iter = G.main->mat.first;
- if (name) { /* (name) - Search material by name */
+ if( name ) { /* (name) - Search material by name */
BPy_Material *wanted_mat = NULL;
- while (mat_iter) {
- if (strcmp (name, mat_iter->id.name+2) == 0) {
- wanted_mat = (BPy_Material *)Material_CreatePyObject (mat_iter);
+ while( mat_iter ) {
+ if( strcmp( name, mat_iter->id.name + 2 ) == 0 ) {
+ wanted_mat =
+ ( BPy_Material * )
+ Material_CreatePyObject( mat_iter );
break;
}
mat_iter = mat_iter->id.next;
}
- if (wanted_mat == NULL) { /* Requested material doesn't exist */
+ if( wanted_mat == NULL ) { /* Requested material doesn't exist */
char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Material \"%s\" not found", name);
- return EXPP_ReturnPyObjError (PyExc_NameError, error_msg);
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Material \"%s\" not found", name );
+ return EXPP_ReturnPyObjError( PyExc_NameError,
+ error_msg );
}
- return (PyObject *)wanted_mat;
+ return ( PyObject * ) wanted_mat;
}
- else { /* () - return a list with all materials in the scene */
+ else { /* () - return a list with all materials in the scene */
int index = 0;
PyObject *matlist, *pyobj;
- matlist = PyList_New (BLI_countlist (&(G.main->mat)));
+ matlist = PyList_New( BLI_countlist( &( G.main->mat ) ) );
- if (!matlist)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( !matlist )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (mat_iter) {
- pyobj = Material_CreatePyObject (mat_iter);
+ while( mat_iter ) {
+ pyobj = Material_CreatePyObject( mat_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- PyList_SET_ITEM (matlist, index, pyobj);
+ PyList_SET_ITEM( matlist, index, pyobj );
mat_iter = mat_iter->id.next;
index++;
@@ -289,9 +294,9 @@ static PyObject *M_Material_Get(PyObject *self, PyObject *args)
}
}
-static PyObject *Lamp_ModesDict (void)
+static PyObject *Lamp_ModesDict( void )
{
- PyObject *Modes = M_constant_New();
+ PyObject *Modes = M_constant_New( );
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
@@ -302,37 +307,37 @@ static PyObject *Lamp_ModesDict (void)
* constant_insert(c, "TRACEABLE", PyInt_FromLong(EXPP_MAT_MODE_TRACEABLE))
*/
- if (Modes) {
- BPy_constant *c = (BPy_constant *)Modes;
-
- EXPP_ADDCONST(TRACEABLE);
- EXPP_ADDCONST(SHADOW);
- EXPP_ADDCONST(SHADELESS);
- EXPP_ADDCONST(WIRE);
- EXPP_ADDCONST(VCOL_LIGHT);
- EXPP_ADDCONST(HALO);
- EXPP_ADDCONST(ZTRANSP);
- EXPP_ADDCONST(VCOL_PAINT);
- EXPP_ADDCONST(ZINVERT);
- EXPP_ADDCONST(HALORINGS);
- EXPP_ADDCONST(ENV);
- EXPP_ADDCONST(HALOLINES);
- EXPP_ADDCONST(ONLYSHADOW);
- EXPP_ADDCONST(HALOXALPHA);
- EXPP_ADDCONST(HALOSTAR);
- EXPP_ADDCONST(TEXFACE);
- EXPP_ADDCONST(HALOTEX);
- EXPP_ADDCONST(HALOPUNO);
- EXPP_ADDCONST(NOMIST);
- EXPP_ADDCONST(HALOSHADE);
- EXPP_ADDCONST(HALOFLARE);
- EXPP_ADDCONST(RADIO);
- EXPP_ADDCONST(RAYMIRROR);
- EXPP_ADDCONST(ZTRA);
- EXPP_ADDCONST(RAYTRANSP);
- EXPP_ADDCONST(ONLYSHADOW);
- EXPP_ADDCONST(NOMIST);
- EXPP_ADDCONST(ENV);
+ if( Modes ) {
+ BPy_constant *c = ( BPy_constant * ) Modes;
+
+ EXPP_ADDCONST( TRACEABLE );
+ EXPP_ADDCONST( SHADOW );
+ EXPP_ADDCONST( SHADELESS );
+ EXPP_ADDCONST( WIRE );
+ EXPP_ADDCONST( VCOL_LIGHT );
+ EXPP_ADDCONST( HALO );
+ EXPP_ADDCONST( ZTRANSP );
+ EXPP_ADDCONST( VCOL_PAINT );
+ EXPP_ADDCONST( ZINVERT );
+ EXPP_ADDCONST( HALORINGS );
+ EXPP_ADDCONST( ENV );
+ EXPP_ADDCONST( HALOLINES );
+ EXPP_ADDCONST( ONLYSHADOW );
+ EXPP_ADDCONST( HALOXALPHA );
+ EXPP_ADDCONST( HALOSTAR );
+ EXPP_ADDCONST( TEXFACE );
+ EXPP_ADDCONST( HALOTEX );
+ EXPP_ADDCONST( HALOPUNO );
+ EXPP_ADDCONST( NOMIST );
+ EXPP_ADDCONST( HALOSHADE );
+ EXPP_ADDCONST( HALOFLARE );
+ EXPP_ADDCONST( RADIO );
+ EXPP_ADDCONST( RAYMIRROR );
+ EXPP_ADDCONST( ZTRA );
+ EXPP_ADDCONST( RAYTRANSP );
+ EXPP_ADDCONST( ONLYSHADOW );
+ EXPP_ADDCONST( NOMIST );
+ EXPP_ADDCONST( ENV );
}
@@ -340,21 +345,22 @@ static PyObject *Lamp_ModesDict (void)
}
/*****************************************************************************/
-/* Function: Material_Init */
+/* Function: Material_Init */
/*****************************************************************************/
-PyObject *Material_Init (void)
+PyObject *Material_Init( void )
{
- PyObject *submodule, *Modes;
+ PyObject *submodule, *Modes;
Material_Type.ob_type = &PyType_Type;
- Modes = Lamp_ModesDict ();
+ Modes = Lamp_ModesDict( );
- submodule = Py_InitModule3("Blender.Material",
- M_Material_methods, M_Material_doc);
+ submodule = Py_InitModule3( "Blender.Material",
+ M_Material_methods, M_Material_doc );
- if (Modes) PyModule_AddObject(submodule, "Modes", Modes);
- return (submodule);
+ if( Modes )
+ PyModule_AddObject( submodule, "Modes", Modes );
+ return ( submodule );
}
/***************************/
@@ -362,321 +368,340 @@ PyObject *Material_Init (void)
/***************************/
/*****************************************************************************/
-/* Python BPy_Material methods declarations: */
+/* Python BPy_Material methods declarations: */
/*****************************************************************************/
-static PyObject *Material_getIpo(BPy_Material *self);
-static PyObject *Material_getName(BPy_Material *self);
-static PyObject *Material_getMode(BPy_Material *self);
-static PyObject *Material_getRGBCol(BPy_Material *self);
+static PyObject *Material_getIpo( BPy_Material * self );
+static PyObject *Material_getName( BPy_Material * self );
+static PyObject *Material_getMode( BPy_Material * self );
+static PyObject *Material_getRGBCol( BPy_Material * self );
/*static PyObject *Material_getAmbCol(BPy_Material *self);*/
-static PyObject *Material_getSpecCol(BPy_Material *self);
-static PyObject *Material_getMirCol(BPy_Material *self);
-static PyObject *Material_getAmb(BPy_Material *self);
-static PyObject *Material_getEmit(BPy_Material *self);
-static PyObject *Material_getAlpha(BPy_Material *self);
-static PyObject *Material_getRef(BPy_Material *self);
-static PyObject *Material_getSpec(BPy_Material *self);
-static PyObject *Material_getSpecTransp(BPy_Material *self);
-static PyObject *Material_getAdd(BPy_Material *self);
-static PyObject *Material_getZOffset(BPy_Material *self);
-static PyObject *Material_getHaloSize(BPy_Material *self);
-static PyObject *Material_getHaloSeed(BPy_Material *self);
-static PyObject *Material_getFlareSize(BPy_Material *self);
-static PyObject *Material_getFlareSeed(BPy_Material *self);
-static PyObject *Material_getFlareBoost(BPy_Material *self);
-static PyObject *Material_getSubSize(BPy_Material *self);
-static PyObject *Material_getHardness(BPy_Material *self);
-static PyObject *Material_getNFlares(BPy_Material *self);
-static PyObject *Material_getNStars(BPy_Material *self);
-static PyObject *Material_getNLines(BPy_Material *self);
-static PyObject *Material_getNRings(BPy_Material *self);
-static PyObject *Material_getRayMirr(BPy_Material *self);
-static PyObject *Material_getMirrDepth(BPy_Material *self);
-static PyObject *Material_getFresnelMirr(BPy_Material *self);
-static PyObject *Material_getFresnelMirrFac(BPy_Material *self);
-static PyObject *Material_getIOR(BPy_Material *self);
-static PyObject *Material_getTransDepth(BPy_Material *self);
-static PyObject *Material_getFresnelTrans(BPy_Material *self);
-static PyObject *Material_getFresnelTransFac(BPy_Material *self);
-static PyObject *Material_getTextures(BPy_Material *self);
-static PyObject *Material_setIpo(BPy_Material *self, PyObject *args);
-static PyObject *Material_clearIpo(BPy_Material *self);
-static PyObject *Material_setName(BPy_Material *self, PyObject *args);
-static PyObject *Material_setMode(BPy_Material *self, PyObject *args);
-static PyObject *Material_setIntMode(BPy_Material *self, PyObject *args);
-static PyObject *Material_setRGBCol(BPy_Material *self, PyObject *args);
+static PyObject *Material_getSpecCol( BPy_Material * self );
+static PyObject *Material_getMirCol( BPy_Material * self );
+static PyObject *Material_getAmb( BPy_Material * self );
+static PyObject *Material_getEmit( BPy_Material * self );
+static PyObject *Material_getAlpha( BPy_Material * self );
+static PyObject *Material_getRef( BPy_Material * self );
+static PyObject *Material_getSpec( BPy_Material * self );
+static PyObject *Material_getSpecTransp( BPy_Material * self );
+static PyObject *Material_getAdd( BPy_Material * self );
+static PyObject *Material_getZOffset( BPy_Material * self );
+static PyObject *Material_getHaloSize( BPy_Material * self );
+static PyObject *Material_getHaloSeed( BPy_Material * self );
+static PyObject *Material_getFlareSize( BPy_Material * self );
+static PyObject *Material_getFlareSeed( BPy_Material * self );
+static PyObject *Material_getFlareBoost( BPy_Material * self );
+static PyObject *Material_getSubSize( BPy_Material * self );
+static PyObject *Material_getHardness( BPy_Material * self );
+static PyObject *Material_getNFlares( BPy_Material * self );
+static PyObject *Material_getNStars( BPy_Material * self );
+static PyObject *Material_getNLines( BPy_Material * self );
+static PyObject *Material_getNRings( BPy_Material * self );
+static PyObject *Material_getRayMirr( BPy_Material * self );
+static PyObject *Material_getMirrDepth( BPy_Material * self );
+static PyObject *Material_getFresnelMirr( BPy_Material * self );
+static PyObject *Material_getFresnelMirrFac( BPy_Material * self );
+static PyObject *Material_getIOR( BPy_Material * self );
+static PyObject *Material_getTransDepth( BPy_Material * self );
+static PyObject *Material_getFresnelTrans( BPy_Material * self );
+static PyObject *Material_getFresnelTransFac( BPy_Material * self );
+static PyObject *Material_getTextures( BPy_Material * self );
+static PyObject *Material_setIpo( BPy_Material * self, PyObject * args );
+static PyObject *Material_clearIpo( BPy_Material * self );
+static PyObject *Material_setName( BPy_Material * self, PyObject * args );
+static PyObject *Material_setMode( BPy_Material * self, PyObject * args );
+static PyObject *Material_setIntMode( BPy_Material * self, PyObject * args );
+static PyObject *Material_setRGBCol( BPy_Material * self, PyObject * args );
/*static PyObject *Material_setAmbCol(BPy_Material *self, PyObject *args);*/
-static PyObject *Material_setSpecCol(BPy_Material *self, PyObject *args);
-static PyObject *Material_setMirCol(BPy_Material *self, PyObject *args);
-static PyObject *Material_setAmb(BPy_Material *self, PyObject *args);
-static PyObject *Material_setEmit(BPy_Material *self, PyObject *args);
-static PyObject *Material_setAlpha(BPy_Material *self, PyObject *args);
-static PyObject *Material_setRef(BPy_Material *self, PyObject *args);
-static PyObject *Material_setSpec(BPy_Material *self, PyObject *args);
-static PyObject *Material_setSpecTransp(BPy_Material *self, PyObject *args);
-static PyObject *Material_setAdd(BPy_Material *self, PyObject *args);
-static PyObject *Material_setZOffset(BPy_Material *self, PyObject *args);
-static PyObject *Material_setHaloSize(BPy_Material *self, PyObject *args);
-static PyObject *Material_setHaloSeed(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFlareSize(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFlareSeed(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFlareBoost(BPy_Material *self, PyObject *args);
-static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args);
-static PyObject *Material_setHardness(BPy_Material *self, PyObject *args);
-static PyObject *Material_setNFlares(BPy_Material *self, PyObject *args);
-static PyObject *Material_setNStars(BPy_Material *self, PyObject *args);
-static PyObject *Material_setNLines(BPy_Material *self, PyObject *args);
-static PyObject *Material_setNRings(BPy_Material *self, PyObject *args);
+static PyObject *Material_setSpecCol( BPy_Material * self, PyObject * args );
+static PyObject *Material_setMirCol( BPy_Material * self, PyObject * args );
+static PyObject *Material_setAmb( BPy_Material * self, PyObject * args );
+static PyObject *Material_setEmit( BPy_Material * self, PyObject * args );
+static PyObject *Material_setAlpha( BPy_Material * self, PyObject * args );
+static PyObject *Material_setRef( BPy_Material * self, PyObject * args );
+static PyObject *Material_setSpec( BPy_Material * self, PyObject * args );
+static PyObject *Material_setSpecTransp( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setAdd( BPy_Material * self, PyObject * args );
+static PyObject *Material_setZOffset( BPy_Material * self, PyObject * args );
+static PyObject *Material_setHaloSize( BPy_Material * self, PyObject * args );
+static PyObject *Material_setHaloSeed( BPy_Material * self, PyObject * args );
+static PyObject *Material_setFlareSize( BPy_Material * self, PyObject * args );
+static PyObject *Material_setFlareSeed( BPy_Material * self, PyObject * args );
+static PyObject *Material_setFlareBoost( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setSubSize( BPy_Material * self, PyObject * args );
+static PyObject *Material_setHardness( BPy_Material * self, PyObject * args );
+static PyObject *Material_setNFlares( BPy_Material * self, PyObject * args );
+static PyObject *Material_setNStars( BPy_Material * self, PyObject * args );
+static PyObject *Material_setNLines( BPy_Material * self, PyObject * args );
+static PyObject *Material_setNRings( BPy_Material * self, PyObject * args );
/* ** Mirror and transp ** */
-static PyObject *Material_setRayMirr(BPy_Material *self, PyObject *args);
-static PyObject *Material_setMirrDepth(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFresnelMirr(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFresnelMirrFac(BPy_Material *self, PyObject *args);
-static PyObject *Material_setIOR(BPy_Material *self, PyObject *args);
-static PyObject *Material_setTransDepth(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFresnelTrans(BPy_Material *self, PyObject *args);
-static PyObject *Material_setFresnelTransFac(BPy_Material *self, PyObject *args);
+static PyObject *Material_setRayMirr( BPy_Material * self, PyObject * args );
+static PyObject *Material_setMirrDepth( BPy_Material * self, PyObject * args );
+static PyObject *Material_setFresnelMirr( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setFresnelMirrFac( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setIOR( BPy_Material * self, PyObject * args );
+static PyObject *Material_setTransDepth( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setFresnelTrans( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_setFresnelTransFac( BPy_Material * self,
+ PyObject * args );
/* ** */
-static PyObject *Material_setTexture(BPy_Material *self, PyObject *args);
-static PyObject *Material_clearTexture(BPy_Material *self, PyObject *args);
+static PyObject *Material_setTexture( BPy_Material * self, PyObject * args );
+static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args );
-static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
- PyObject *args);
+static PyObject *Material_setColorComponent( BPy_Material * self, char *key,
+ PyObject * args );
-static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject *args);
-static PyObject *Material_addScriptLink(BPy_Material *self, PyObject *args);
-static PyObject *Material_clearScriptLinks(BPy_Material *self);
+static PyObject *Material_getScriptLinks( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_addScriptLink( BPy_Material * self,
+ PyObject * args );
+static PyObject *Material_clearScriptLinks( BPy_Material * self );
/*****************************************************************************/
-/* Python BPy_Material methods table: */
+/* Python BPy_Material methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Material_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Material_getName, METH_NOARGS,
- "() - Return Material's name"},
- {"getIpo", (PyCFunction)Material_getIpo, METH_NOARGS,
- "() - Return Material's ipo or None if not found"},
- {"getMode", (PyCFunction)Material_getMode, METH_NOARGS,
- "() - Return Material's mode flags"},
- {"getRGBCol", (PyCFunction)Material_getRGBCol, METH_NOARGS,
- "() - Return Material's rgb color triplet"},
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Material_getName, METH_NOARGS,
+ "() - Return Material's name"},
+ {"getIpo", ( PyCFunction ) Material_getIpo, METH_NOARGS,
+ "() - Return Material's ipo or None if not found"},
+ {"getMode", ( PyCFunction ) Material_getMode, METH_NOARGS,
+ "() - Return Material's mode flags"},
+ {"getRGBCol", ( PyCFunction ) Material_getRGBCol, METH_NOARGS,
+ "() - Return Material's rgb color triplet"},
/* {"getAmbCol", (PyCFunction)Material_getAmbCol, METH_NOARGS,
"() - Return Material's ambient color"},*/
- {"getSpecCol", (PyCFunction)Material_getSpecCol, METH_NOARGS,
- "() - Return Material's specular color"},
- {"getMirCol", (PyCFunction)Material_getMirCol, METH_NOARGS,
- "() - Return Material's mirror color"},
- {"getAmb", (PyCFunction)Material_getAmb, METH_NOARGS,
- "() - Return Material's ambient color blend factor"},
- {"getEmit", (PyCFunction)Material_getEmit, METH_NOARGS,
- "() - Return Material's emitting light intensity"},
- {"getAlpha", (PyCFunction)Material_getAlpha, METH_NOARGS,
- "() - Return Material's alpha (transparency) value"},
- {"getRef", (PyCFunction)Material_getRef, METH_NOARGS,
- "() - Return Material's reflectivity"},
- {"getSpec", (PyCFunction)Material_getSpec, METH_NOARGS,
- "() - Return Material's specularity"},
- {"getSpecTransp", (PyCFunction)Material_getSpecTransp, METH_NOARGS,
- "() - Return Material's specular transparency"},
- {"getAdd", (PyCFunction)Material_getAdd, METH_NOARGS,
- "() - Return Material's glow factor"},
- {"getZOffset", (PyCFunction)Material_getZOffset, METH_NOARGS,
- "() - Return Material's artificial offset for faces"},
- {"getHaloSize", (PyCFunction)Material_getHaloSize, METH_NOARGS,
- "() - Return Material's halo size"},
- {"getHaloSeed", (PyCFunction)Material_getHaloSeed, METH_NOARGS,
- "() - Return Material's seed for random ring dimension and line "
- "location in halos"},
- {"getFlareSize", (PyCFunction)Material_getFlareSize, METH_NOARGS,
- "() - Return Material's (flare size)/(halo size) factor"},
- {"getFlareSeed", (PyCFunction)Material_getFlareSeed, METH_NOARGS,
- "() - Return Material's flare offset in the seed table"},
- {"getFlareBoost", (PyCFunction)Material_getFlareBoost, METH_NOARGS,
- "() - Return Material's flare boost"},
- {"getSubSize", (PyCFunction)Material_getSubSize, METH_NOARGS,
- "() - Return Material's dimension of subflare, dots and circles"},
- {"getHardness", (PyCFunction)Material_getHardness, METH_NOARGS,
- "() - Return Material's specular hardness"},
- {"getNFlares", (PyCFunction)Material_getNFlares, METH_NOARGS,
- "() - Return Material's number of flares in halo"},
- {"getNStars", (PyCFunction)Material_getNStars, METH_NOARGS,
- "() - Return Material's number of points in the halo stars"},
- {"getNLines", (PyCFunction)Material_getNLines, METH_NOARGS,
- "() - Return Material's number of lines in halo"},
- {"getNRings", (PyCFunction)Material_getNRings, METH_NOARGS,
- "() - Return Material's number of rings in halo"},
- {"getRayMirr", (PyCFunction)Material_getRayMirr, METH_NOARGS,
- "() - Return mount mirror"},
- {"getMirrDepth", (PyCFunction)Material_getMirrDepth, METH_NOARGS,
- "() - Return amount mirror depth"},
- {"getFresnelMirr", (PyCFunction)Material_getFresnelMirr, METH_NOARGS,
- "() - Return fresnel power for refractions"},
- {"getFresnelMirrFac", (PyCFunction)Material_getFresnelMirrFac, METH_NOARGS,
- "() - Return fresnel power for refractions factor"},
- {"getIOR", (PyCFunction)Material_getIOR, METH_NOARGS,
- "() - Return IOR"},
- {"getTransDepth", (PyCFunction)Material_getTransDepth, METH_NOARGS,
- "() - Return amount inter-refractions"},
- {"getFresnelTrans", (PyCFunction)Material_getFresnelTrans, METH_NOARGS,
- "() - Return fresnel power for refractions"},
- {"getFresnelTransFac", (PyCFunction)Material_getFresnelTransFac, METH_NOARGS,
- "() - Return fresnel power for refractions factor"},
- {"getTextures", (PyCFunction)Material_getTextures, METH_NOARGS,
- "() - Return Material's texture list as a tuple"},
- {"setName", (PyCFunction)Material_setName, METH_VARARGS,
- "(s) - Change Material's name"},
- {"setIpo", (PyCFunction)Material_setIpo, METH_VARARGS,
- "(Blender Ipo) - Change Material's Ipo"},
- {"clearIpo", (PyCFunction)Material_clearIpo, METH_NOARGS,
- "(Blender Ipo) - Unlink Ipo from this Material"},
- {"setMode", (PyCFunction)Material_setMode, METH_VARARGS,
- "([s[,s]]) - Set Material's mode flag(s)"},
- {"setRGBCol", (PyCFunction)Material_setRGBCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's rgb color triplet"},
+ {"getSpecCol", ( PyCFunction ) Material_getSpecCol, METH_NOARGS,
+ "() - Return Material's specular color"},
+ {"getMirCol", ( PyCFunction ) Material_getMirCol, METH_NOARGS,
+ "() - Return Material's mirror color"},
+ {"getAmb", ( PyCFunction ) Material_getAmb, METH_NOARGS,
+ "() - Return Material's ambient color blend factor"},
+ {"getEmit", ( PyCFunction ) Material_getEmit, METH_NOARGS,
+ "() - Return Material's emitting light intensity"},
+ {"getAlpha", ( PyCFunction ) Material_getAlpha, METH_NOARGS,
+ "() - Return Material's alpha (transparency) value"},
+ {"getRef", ( PyCFunction ) Material_getRef, METH_NOARGS,
+ "() - Return Material's reflectivity"},
+ {"getSpec", ( PyCFunction ) Material_getSpec, METH_NOARGS,
+ "() - Return Material's specularity"},
+ {"getSpecTransp", ( PyCFunction ) Material_getSpecTransp, METH_NOARGS,
+ "() - Return Material's specular transparency"},
+ {"getAdd", ( PyCFunction ) Material_getAdd, METH_NOARGS,
+ "() - Return Material's glow factor"},
+ {"getZOffset", ( PyCFunction ) Material_getZOffset, METH_NOARGS,
+ "() - Return Material's artificial offset for faces"},
+ {"getHaloSize", ( PyCFunction ) Material_getHaloSize, METH_NOARGS,
+ "() - Return Material's halo size"},
+ {"getHaloSeed", ( PyCFunction ) Material_getHaloSeed, METH_NOARGS,
+ "() - Return Material's seed for random ring dimension and line "
+ "location in halos"},
+ {"getFlareSize", ( PyCFunction ) Material_getFlareSize, METH_NOARGS,
+ "() - Return Material's (flare size)/(halo size) factor"},
+ {"getFlareSeed", ( PyCFunction ) Material_getFlareSeed, METH_NOARGS,
+ "() - Return Material's flare offset in the seed table"},
+ {"getFlareBoost", ( PyCFunction ) Material_getFlareBoost, METH_NOARGS,
+ "() - Return Material's flare boost"},
+ {"getSubSize", ( PyCFunction ) Material_getSubSize, METH_NOARGS,
+ "() - Return Material's dimension of subflare, dots and circles"},
+ {"getHardness", ( PyCFunction ) Material_getHardness, METH_NOARGS,
+ "() - Return Material's specular hardness"},
+ {"getNFlares", ( PyCFunction ) Material_getNFlares, METH_NOARGS,
+ "() - Return Material's number of flares in halo"},
+ {"getNStars", ( PyCFunction ) Material_getNStars, METH_NOARGS,
+ "() - Return Material's number of points in the halo stars"},
+ {"getNLines", ( PyCFunction ) Material_getNLines, METH_NOARGS,
+ "() - Return Material's number of lines in halo"},
+ {"getNRings", ( PyCFunction ) Material_getNRings, METH_NOARGS,
+ "() - Return Material's number of rings in halo"},
+ {"getRayMirr", ( PyCFunction ) Material_getRayMirr, METH_NOARGS,
+ "() - Return mount mirror"},
+ {"getMirrDepth", ( PyCFunction ) Material_getMirrDepth, METH_NOARGS,
+ "() - Return amount mirror depth"},
+ {"getFresnelMirr", ( PyCFunction ) Material_getFresnelMirr,
+ METH_NOARGS,
+ "() - Return fresnel power for refractions"},
+ {"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac,
+ METH_NOARGS,
+ "() - Return fresnel power for refractions factor"},
+ {"getIOR", ( PyCFunction ) Material_getIOR, METH_NOARGS,
+ "() - Return IOR"},
+ {"getTransDepth", ( PyCFunction ) Material_getTransDepth, METH_NOARGS,
+ "() - Return amount inter-refractions"},
+ {"getFresnelTrans", ( PyCFunction ) Material_getFresnelTrans,
+ METH_NOARGS,
+ "() - Return fresnel power for refractions"},
+ {"getFresnelTransFac", ( PyCFunction ) Material_getFresnelTransFac,
+ METH_NOARGS,
+ "() - Return fresnel power for refractions factor"},
+ {"getTextures", ( PyCFunction ) Material_getTextures, METH_NOARGS,
+ "() - Return Material's texture list as a tuple"},
+ {"setName", ( PyCFunction ) Material_setName, METH_VARARGS,
+ "(s) - Change Material's name"},
+ {"setIpo", ( PyCFunction ) Material_setIpo, METH_VARARGS,
+ "(Blender Ipo) - Change Material's Ipo"},
+ {"clearIpo", ( PyCFunction ) Material_clearIpo, METH_NOARGS,
+ "(Blender Ipo) - Unlink Ipo from this Material"},
+ {"setMode", ( PyCFunction ) Material_setMode, METH_VARARGS,
+ "([s[,s]]) - Set Material's mode flag(s)"},
+ {"setRGBCol", ( PyCFunction ) Material_setRGBCol, METH_VARARGS,
+ "(f,f,f or [f,f,f]) - Set Material's rgb color triplet"},
/* {"setAmbCol", (PyCFunction)Material_setAmbCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's ambient color"},*/
- {"setSpecCol", (PyCFunction)Material_setSpecCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's specular color"},
- {"setMirCol", (PyCFunction)Material_setMirCol, METH_VARARGS,
- "(f,f,f or [f,f,f]) - Set Material's mirror color"},
- {"setAmb", (PyCFunction)Material_setAmb, METH_VARARGS,
- "(f) - Set how much the Material's color is affected"
- " by \nthe global ambient colors - [0.0, 1.0]"},
- {"setEmit", (PyCFunction)Material_setEmit, METH_VARARGS,
- "(f) - Set Material's emitting light intensity - [0.0, 1.0]"},
- {"setAlpha", (PyCFunction)Material_setAlpha, METH_VARARGS,
- "(f) - Set Material's alpha (transparency) - [0.0, 1.0]"},
- {"setRef", (PyCFunction)Material_setRef, METH_VARARGS,
- "(f) - Set Material's reflectivity - [0.0, 1.0]"},
- {"setSpec", (PyCFunction)Material_setSpec, METH_VARARGS,
- "(f) - Set Material's specularity - [0.0, 2.0]"},
- {"setSpecTransp", (PyCFunction)Material_setSpecTransp, METH_VARARGS,
- "(f) - Set Material's specular transparency - [0.0, 1.0]"},
- {"setAdd", (PyCFunction)Material_setAdd, METH_VARARGS,
- "(f) - Set Material's glow factor - [0.0, 1.0]"},
- {"setZOffset", (PyCFunction)Material_setZOffset, METH_VARARGS,
- "(f) - Set Material's artificial offset - [0.0, 10.0]"},
- {"setHaloSize", (PyCFunction)Material_setHaloSize, METH_VARARGS,
- "(f) - Set Material's halo size - [0.0, 100.0]"},
- {"setHaloSeed", (PyCFunction)Material_setHaloSeed, METH_VARARGS,
- "(i) - Set Material's halo seed - [0, 255]"},
- {"setFlareSize", (PyCFunction)Material_setFlareSize, METH_VARARGS,
- "(f) - Set Material's factor: (flare size)/(halo size) - [0.1, 25.0]"},
- {"setFlareSeed", (PyCFunction)Material_setFlareSeed, METH_VARARGS,
- "(i) - Set Material's flare seed - [0, 255]"},
- {"setFlareBoost", (PyCFunction)Material_setFlareBoost, METH_VARARGS,
- "(f) - Set Material's flare boost - [0.1, 10.0]"},
- {"setSubSize", (PyCFunction)Material_setSubSize, METH_VARARGS,
- "(f) - Set Material's dimension of subflare,"
- " dots and circles - [0.1, 25.0]"},
- {"setHardness", (PyCFunction)Material_setHardness, METH_VARARGS,
- "(i) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"},
- {"setNFlares", (PyCFunction)Material_setNFlares, METH_VARARGS,
- "(i) - Set Material's number of flares in halo - [1, 32]"},
- {"setNStars", (PyCFunction)Material_setNStars, METH_VARARGS,
- "(i) - Set Material's number of stars in halo - [3, 50]"},
- {"setNLines", (PyCFunction)Material_setNLines, METH_VARARGS,
- "(i) - Set Material's number of lines in halo - [0, 250]"},
- {"setNRings", (PyCFunction)Material_setNRings, METH_VARARGS,
- "(i) - Set Material's number of rings in halo - [0, 24]"},
- {"setRayMirr", (PyCFunction)Material_setRayMirr, METH_VARARGS,
- "(f) - Set amount mirror - [0.0, 1.0]"},
- {"setMirrDepth", (PyCFunction)Material_setMirrDepth, METH_VARARGS,
- "(i) - Set amount inter-reflections - [0, 10]"},
- {"setFresnelMirr", (PyCFunction)Material_setFresnelMirr, METH_VARARGS,
- "(f) - Set fresnel power for mirror - [0.0, 5.0]"},
- {"setFresnelMirrFac", (PyCFunction)Material_setFresnelMirrFac, METH_VARARGS,
- "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"},
- {"setIOR", (PyCFunction)Material_setIOR, METH_VARARGS,
- "(f) - Set IOR - [1.0, 3.0]"},
- {"setTransDepth", (PyCFunction)Material_setTransDepth, METH_VARARGS,
- "(i) - Set amount inter-refractions - [0, 10]"},
- {"setFresnelTrans", (PyCFunction)Material_setFresnelTrans, METH_VARARGS,
- "(f) - Set fresnel power for refractions - [0.0, 5.0]"},
- {"setFresnelTransFac", (PyCFunction)Material_setFresnelTransFac, METH_VARARGS,
- "(f) - Set fresnel power for refractions factot- [0.0, 5.0]"},
- {"setTexture", (PyCFunction)Material_setTexture, METH_VARARGS,
- "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
- {"clearTexture", (PyCFunction)Material_clearTexture, METH_VARARGS,
- "(n) - Remove texture from numbered slot"},
- {"getScriptLinks", (PyCFunction)Material_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this material's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", (PyCFunction)Material_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new material scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", (PyCFunction)Material_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this material."},
+ {"setSpecCol", ( PyCFunction ) Material_setSpecCol, METH_VARARGS,
+ "(f,f,f or [f,f,f]) - Set Material's specular color"},
+ {"setMirCol", ( PyCFunction ) Material_setMirCol, METH_VARARGS,
+ "(f,f,f or [f,f,f]) - Set Material's mirror color"},
+ {"setAmb", ( PyCFunction ) Material_setAmb, METH_VARARGS,
+ "(f) - Set how much the Material's color is affected"
+ " by \nthe global ambient colors - [0.0, 1.0]"},
+ {"setEmit", ( PyCFunction ) Material_setEmit, METH_VARARGS,
+ "(f) - Set Material's emitting light intensity - [0.0, 1.0]"},
+ {"setAlpha", ( PyCFunction ) Material_setAlpha, METH_VARARGS,
+ "(f) - Set Material's alpha (transparency) - [0.0, 1.0]"},
+ {"setRef", ( PyCFunction ) Material_setRef, METH_VARARGS,
+ "(f) - Set Material's reflectivity - [0.0, 1.0]"},
+ {"setSpec", ( PyCFunction ) Material_setSpec, METH_VARARGS,
+ "(f) - Set Material's specularity - [0.0, 2.0]"},
+ {"setSpecTransp", ( PyCFunction ) Material_setSpecTransp, METH_VARARGS,
+ "(f) - Set Material's specular transparency - [0.0, 1.0]"},
+ {"setAdd", ( PyCFunction ) Material_setAdd, METH_VARARGS,
+ "(f) - Set Material's glow factor - [0.0, 1.0]"},
+ {"setZOffset", ( PyCFunction ) Material_setZOffset, METH_VARARGS,
+ "(f) - Set Material's artificial offset - [0.0, 10.0]"},
+ {"setHaloSize", ( PyCFunction ) Material_setHaloSize, METH_VARARGS,
+ "(f) - Set Material's halo size - [0.0, 100.0]"},
+ {"setHaloSeed", ( PyCFunction ) Material_setHaloSeed, METH_VARARGS,
+ "(i) - Set Material's halo seed - [0, 255]"},
+ {"setFlareSize", ( PyCFunction ) Material_setFlareSize, METH_VARARGS,
+ "(f) - Set Material's factor: (flare size)/(halo size) - [0.1, 25.0]"},
+ {"setFlareSeed", ( PyCFunction ) Material_setFlareSeed, METH_VARARGS,
+ "(i) - Set Material's flare seed - [0, 255]"},
+ {"setFlareBoost", ( PyCFunction ) Material_setFlareBoost, METH_VARARGS,
+ "(f) - Set Material's flare boost - [0.1, 10.0]"},
+ {"setSubSize", ( PyCFunction ) Material_setSubSize, METH_VARARGS,
+ "(f) - Set Material's dimension of subflare,"
+ " dots and circles - [0.1, 25.0]"},
+ {"setHardness", ( PyCFunction ) Material_setHardness, METH_VARARGS,
+ "(i) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"},
+ {"setNFlares", ( PyCFunction ) Material_setNFlares, METH_VARARGS,
+ "(i) - Set Material's number of flares in halo - [1, 32]"},
+ {"setNStars", ( PyCFunction ) Material_setNStars, METH_VARARGS,
+ "(i) - Set Material's number of stars in halo - [3, 50]"},
+ {"setNLines", ( PyCFunction ) Material_setNLines, METH_VARARGS,
+ "(i) - Set Material's number of lines in halo - [0, 250]"},
+ {"setNRings", ( PyCFunction ) Material_setNRings, METH_VARARGS,
+ "(i) - Set Material's number of rings in halo - [0, 24]"},
+ {"setRayMirr", ( PyCFunction ) Material_setRayMirr, METH_VARARGS,
+ "(f) - Set amount mirror - [0.0, 1.0]"},
+ {"setMirrDepth", ( PyCFunction ) Material_setMirrDepth, METH_VARARGS,
+ "(i) - Set amount inter-reflections - [0, 10]"},
+ {"setFresnelMirr", ( PyCFunction ) Material_setFresnelMirr,
+ METH_VARARGS,
+ "(f) - Set fresnel power for mirror - [0.0, 5.0]"},
+ {"setFresnelMirrFac", ( PyCFunction ) Material_setFresnelMirrFac,
+ METH_VARARGS,
+ "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"},
+ {"setIOR", ( PyCFunction ) Material_setIOR, METH_VARARGS,
+ "(f) - Set IOR - [1.0, 3.0]"},
+ {"setTransDepth", ( PyCFunction ) Material_setTransDepth, METH_VARARGS,
+ "(i) - Set amount inter-refractions - [0, 10]"},
+ {"setFresnelTrans", ( PyCFunction ) Material_setFresnelTrans,
+ METH_VARARGS,
+ "(f) - Set fresnel power for refractions - [0.0, 5.0]"},
+ {"setFresnelTransFac", ( PyCFunction ) Material_setFresnelTransFac,
+ METH_VARARGS,
+ "(f) - Set fresnel power for refractions factot- [0.0, 5.0]"},
+ {"setTexture", ( PyCFunction ) Material_setTexture, METH_VARARGS,
+ "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
+ {"clearTexture", ( PyCFunction ) Material_clearTexture, METH_VARARGS,
+ "(n) - Remove texture from numbered slot"},
+ {"getScriptLinks", ( PyCFunction ) Material_getScriptLinks,
+ METH_VARARGS,
+ "(eventname) - Get a list of this material's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) Material_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new material scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) Material_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this material."},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Material_Type callback function prototypes: */
+/* Python Material_Type callback function prototypes: */
/*****************************************************************************/
-static void Material_dealloc (BPy_Material *self);
-static int Material_setAttr (BPy_Material *self, char *name, PyObject *v);
-static PyObject *Material_getAttr (BPy_Material *self, char *name);
-static PyObject *Material_repr (BPy_Material *self);
+static void Material_dealloc( BPy_Material * self );
+static int Material_setAttr( BPy_Material * self, char *name, PyObject * v );
+static PyObject *Material_getAttr( BPy_Material * self, char *name );
+static PyObject *Material_repr( BPy_Material * self );
/*****************************************************************************/
-/* Python Material_Type structure definition: */
+/* Python Material_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Material_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Material", /* tp_name */
- sizeof (BPy_Material), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject Material_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Material", /* tp_name */
+ sizeof( BPy_Material ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Material_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Material_getAttr, /* tp_getattr */
- (setattrfunc)Material_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)Material_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_Material_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) Material_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Material_getAttr, /* tp_getattr */
+ ( setattrfunc ) Material_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) Material_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_Material_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
-/* Function: Material_dealloc */
+/* Function: Material_dealloc */
/* Description: This is a callback function for the BPy_Material type. It is */
-/* the destructor function. */
+/* the destructor function. */
/*****************************************************************************/
-static void Material_dealloc (BPy_Material *self)
+static void Material_dealloc( BPy_Material * self )
{
- Py_DECREF (self->col);
- Py_DECREF (self->amb);
- Py_DECREF (self->spec);
- Py_DECREF (self->mir);
- PyObject_DEL (self);
+ Py_DECREF( self->col );
+ Py_DECREF( self->amb );
+ Py_DECREF( self->spec );
+ Py_DECREF( self->mir );
+ PyObject_DEL( self );
}
/*****************************************************************************/
-/* Function: Material_CreatePyObject */
-/* Description: This function will create a new BPy_Material from an existing*/
-/* Blender material structure. */
+/* Function: Material_CreatePyObject */
+/* Description: Create a new BPy_Material from an existing */
+/* Blender material structure. */
/*****************************************************************************/
-PyObject *Material_CreatePyObject (struct Material *mat)
+PyObject *Material_CreatePyObject( struct Material *mat )
{
BPy_Material *pymat;
float *col[3], *amb[3], *spec[3], *mir[3];
- pymat = (BPy_Material *)PyObject_NEW (BPy_Material, &Material_Type);
+ pymat = ( BPy_Material * ) PyObject_NEW( BPy_Material,
+ &Material_Type );
- if (!pymat)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Material object");
+ if( !pymat )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Material object" );
pymat->material = mat;
@@ -696,479 +721,524 @@ PyObject *Material_CreatePyObject (struct Material *mat)
mir[1] = &mat->mirg;
mir[2] = &mat->mirb;
- pymat->col = (BPy_rgbTuple *)rgbTuple_New(col);
- pymat->amb = (BPy_rgbTuple *)rgbTuple_New(amb);
- pymat->spec = (BPy_rgbTuple *)rgbTuple_New(spec);
- pymat->mir = (BPy_rgbTuple *)rgbTuple_New(mir);
+ pymat->col = ( BPy_rgbTuple * ) rgbTuple_New( col );
+ pymat->amb = ( BPy_rgbTuple * ) rgbTuple_New( amb );
+ pymat->spec = ( BPy_rgbTuple * ) rgbTuple_New( spec );
+ pymat->mir = ( BPy_rgbTuple * ) rgbTuple_New( mir );
- return (PyObject *)pymat;
+ return ( PyObject * ) pymat;
}
/*****************************************************************************/
-/* Function: Material_CheckPyObject */
+/* Function: Material_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type Material. Otherwise it will return false. */
+/* type Material. Otherwise it will return false. */
/*****************************************************************************/
-int Material_CheckPyObject (PyObject *pyobj)
+int Material_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Material_Type);
+ return ( pyobj->ob_type == &Material_Type );
}
/*****************************************************************************/
-/* Function: Material_FromPyObject */
-/* Description: This function returns the Blender material from the given */
-/* PyObject. */
+/* Function: Material_FromPyObject */
+/* Description: This function returns the Blender material from the given */
+/* PyObject. */
/*****************************************************************************/
-Material *Material_FromPyObject (PyObject *pyobj)
+Material *Material_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Material *)pyobj)->material;
+ return ( ( BPy_Material * ) pyobj )->material;
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
-Material * GetMaterialByName (char * name)
+Material *GetMaterialByName( char *name )
{
- Material * mat_iter;
+ Material *mat_iter;
mat_iter = G.main->mat.first;
- while (mat_iter)
- {
- if (StringEqual (name, GetIdName (&(mat_iter->id))))
- {
- return (mat_iter);
+ while( mat_iter ) {
+ if( StringEqual( name, GetIdName( &( mat_iter->id ) ) ) ) {
+ return ( mat_iter );
}
mat_iter = mat_iter->id.next;
}
/* There is no material with the given name */
- return (NULL);
+ return ( NULL );
}
/*****************************************************************************/
-/* Python BPy_Material methods: */
+/* Python BPy_Material methods: */
/*****************************************************************************/
-static PyObject *Material_getIpo(BPy_Material *self)
+static PyObject *Material_getIpo( BPy_Material * self )
{
Ipo *ipo = self->material->ipo;
- if (!ipo) {
- Py_INCREF(Py_None);
+ if( !ipo ) {
+ Py_INCREF( Py_None );
return Py_None;
}
-
- return Ipo_CreatePyObject (ipo);
+
+ return Ipo_CreatePyObject( ipo );
}
-static PyObject *Material_getName(BPy_Material *self)
+static PyObject *Material_getName( BPy_Material * self )
{
- PyObject *attr = PyString_FromString(self->material->id.name+2);
+ PyObject *attr = PyString_FromString( self->material->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.name attribute" ) );
}
-static PyObject *Material_getMode(BPy_Material *self)
+static PyObject *Material_getMode( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->mode);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->mode );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.Mode attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.Mode attribute" );
}
-static PyObject *Material_getRGBCol(BPy_Material *self)
+static PyObject *Material_getRGBCol( BPy_Material * self )
{
- return rgbTuple_getCol(self->col);
+ return rgbTuple_getCol( self->col );
}
+
/*
static PyObject *Material_getAmbCol(BPy_Material *self)
{
return rgbTuple_getCol(self->amb);
}
*/
-static PyObject *Material_getSpecCol(BPy_Material *self)
+static PyObject *Material_getSpecCol( BPy_Material * self )
{
- return rgbTuple_getCol(self->spec);
+ return rgbTuple_getCol( self->spec );
}
-static PyObject *Material_getMirCol(BPy_Material *self)
+static PyObject *Material_getMirCol( BPy_Material * self )
{
- return rgbTuple_getCol(self->mir);
+ return rgbTuple_getCol( self->mir );
}
-static PyObject *Material_getAmb(BPy_Material *self)
+static PyObject *Material_getAmb( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->amb);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->amb );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.amb attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.amb attribute" );
}
-static PyObject *Material_getEmit(BPy_Material *self)
+static PyObject *Material_getEmit( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->emit);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->emit );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.emit attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.emit attribute" );
}
-static PyObject *Material_getAlpha(BPy_Material *self)
+static PyObject *Material_getAlpha( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->alpha);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->alpha );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.alpha attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.alpha attribute" );
}
-static PyObject *Material_getRef(BPy_Material *self)
+static PyObject *Material_getRef( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->ref);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->ref );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.ref attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.ref attribute" );
}
-static PyObject *Material_getSpec(BPy_Material *self)
+static PyObject *Material_getSpec( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->spec);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->spec );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.spec attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.spec attribute" );
}
-static PyObject *Material_getSpecTransp(BPy_Material *self)
+static PyObject *Material_getSpecTransp( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->spectra);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->spectra );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.specTransp attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.specTransp attribute" );
}
-static PyObject *Material_getAdd(BPy_Material *self)
+static PyObject *Material_getAdd( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->add);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->add );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.add attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.add attribute" );
}
-static PyObject *Material_getZOffset(BPy_Material *self)
+static PyObject *Material_getZOffset( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->zoffs);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->zoffs );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.zOffset attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.zOffset attribute" );
}
-static PyObject *Material_getHaloSize(BPy_Material *self)
+static PyObject *Material_getHaloSize( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->hasize);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->hasize );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.haloSize attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.haloSize attribute" );
}
-static PyObject *Material_getFlareSize(BPy_Material *self)
+static PyObject *Material_getFlareSize( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->flaresize);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->flaresize );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.flareSize attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.flareSize attribute" );
}
-static PyObject *Material_getFlareBoost(BPy_Material *self)
+static PyObject *Material_getFlareBoost( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->flareboost);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->flareboost );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.flareBoost attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.flareBoost attribute" );
}
-static PyObject *Material_getSubSize(BPy_Material *self)
+static PyObject *Material_getSubSize( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->subsize);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->subsize );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.subSize attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.subSize attribute" );
}
-static PyObject *Material_getHaloSeed(BPy_Material *self)
+static PyObject *Material_getHaloSeed( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->seed1);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->seed1 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.haloSeed attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.haloSeed attribute" );
}
-static PyObject *Material_getFlareSeed(BPy_Material *self)
+static PyObject *Material_getFlareSeed( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->seed2);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->seed2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.flareSeed attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.flareSeed attribute" );
}
-static PyObject *Material_getHardness(BPy_Material *self)
+static PyObject *Material_getHardness( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->har);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->har );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.hard attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.hard attribute" );
}
-static PyObject *Material_getNFlares(BPy_Material *self)
+static PyObject *Material_getNFlares( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->flarec);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->flarec );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nFlares attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nFlares attribute" );
}
-static PyObject *Material_getNStars(BPy_Material *self)
+static PyObject *Material_getNStars( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->starc);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->starc );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nStars attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nStars attribute" );
}
-static PyObject *Material_getNLines(BPy_Material *self)
+static PyObject *Material_getNLines( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->linec);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->linec );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nLines attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nLines attribute" );
}
-static PyObject *Material_getNRings(BPy_Material *self)
+static PyObject *Material_getNRings( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->ringc);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->ringc );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getRayMirr(BPy_Material *self)
+static PyObject *Material_getRayMirr( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->ray_mirror);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->ray_mirror );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getMirrDepth(BPy_Material *self)
+static PyObject *Material_getMirrDepth( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->ray_depth);
+ PyObject *attr = PyInt_FromLong( ( long ) self->material->ray_depth );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getFresnelMirr(BPy_Material *self)
+static PyObject *Material_getFresnelMirr( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->fresnel_mir);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->fresnel_mir );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getFresnelMirrFac(BPy_Material *self)
+static PyObject *Material_getFresnelMirrFac( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->fresnel_mir_i);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->fresnel_mir_i );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getIOR(BPy_Material *self)
+static PyObject *Material_getIOR( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->ang);
+ PyObject *attr = PyFloat_FromDouble( ( double ) self->material->ang );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getTransDepth(BPy_Material *self)
+static PyObject *Material_getTransDepth( BPy_Material * self )
{
- PyObject *attr = PyInt_FromLong((long)self->material->ray_depth_tra);
+ PyObject *attr =
+ PyInt_FromLong( ( long ) self->material->ray_depth_tra );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getFresnelTrans(BPy_Material *self)
+static PyObject *Material_getFresnelTrans( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->fresnel_tra);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->fresnel_tra );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getFresnelTransFac(BPy_Material *self)
+static PyObject *Material_getFresnelTransFac( BPy_Material * self )
{
- PyObject *attr = PyFloat_FromDouble((double)self->material->fresnel_tra_i);
+ PyObject *attr =
+ PyFloat_FromDouble( ( double ) self->material->fresnel_tra_i );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.nRings attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Material.nRings attribute" );
}
-static PyObject *Material_getTextures(BPy_Material *self)
+static PyObject *Material_getTextures( BPy_Material * self )
{
int i;
struct MTex *mtex;
PyObject *t[8];
PyObject *tuple;
-
+
/* build a texture list */
- for (i=0; i<8; ++i) {
+ for( i = 0; i < 8; ++i ) {
mtex = self->material->mtex[i];
-
- if (mtex) {
- t[i] = MTex_CreatePyObject (mtex);
- }
- else {
- Py_INCREF (Py_None);
+
+ if( mtex ) {
+ t[i] = MTex_CreatePyObject( mtex );
+ } else {
+ Py_INCREF( Py_None );
t[i] = Py_None;
}
}
/* turn the array into a tuple */
- tuple = Py_BuildValue ("NNNNNNNN", t[0], t[1], t[2], t[3],
- t[4], t[5], t[6], t[7]);
- if (!tuple)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "Material_getTextures: couldn't create PyTuple");
+ tuple = Py_BuildValue( "NNNNNNNN", t[0], t[1], t[2], t[3],
+ t[4], t[5], t[6], t[7] );
+ if( !tuple )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "Material_getTextures: couldn't create PyTuple" );
return tuple;
}
-PyObject *Material_setIpo(BPy_Material *self, PyObject *args)
+PyObject *Material_setIpo( BPy_Material * 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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject(pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ if( !ipo )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "null ipo!" );
- if (ipo->blocktype != ID_MA)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this ipo is not a Material type ipo");
+ if( ipo->blocktype != ID_MA )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not a Material type ipo" );
oldipo = self->material->ipo;
- if (oldipo) {
+ if( oldipo ) {
ID *id = &oldipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
}
- ((ID *)&ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
self->material->ipo = ipo;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Material_clearIpo(BPy_Material *self)
+static PyObject *Material_clearIpo( BPy_Material * self )
{
Material *mat = self->material;
- Ipo *ipo = (Ipo *)mat->ipo;
+ Ipo *ipo = ( Ipo * ) mat->ipo;
- if (ipo) {
+ if( ipo ) {
ID *id = &ipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
mat->ipo = NULL;
- Py_INCREF (Py_True);
+ Py_INCREF( Py_True );
return Py_True;
}
- Py_INCREF (Py_False); /* no ipo found */
+ Py_INCREF( Py_False ); /* no ipo found */
return Py_False;
}
-static PyObject *Material_setName(BPy_Material *self, PyObject *args)
+static PyObject *Material_setName( BPy_Material * self, PyObject * args )
{
char *name;
char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id(&self->material->id, buf);
+ rename_id( &self->material->id, buf );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -1176,970 +1246,1009 @@ static PyObject *Material_setName(BPy_Material *self, PyObject *args)
* vcolPaint, halo, ztransp, zinvert, haloRings, env, haloLines,
* onlyShadow, xalpha, star, faceTexture, haloTex, haloPuno, noMist,
* haloShaded, haloFlare */
-static PyObject *Material_setMode(BPy_Material *self, PyObject *args)
+static PyObject *Material_setMode( BPy_Material * self, PyObject * args )
{
int i, flag = 0;
char *m[28] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL,NULL,NULL, NULL, NULL, NULL};
-
- if (!PyArg_ParseTuple( args, "|ssssssssssssssssssssssssssss",
- &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
- &m[7], &m[8], &m[9], &m[10], &m[11], &m[12], &m[13],
- &m[14], &m[15], &m[16], &m[17], &m[18], &m[19], &m[20], &m[21],
- &m[22],&m[23],&m[24], &m[25], &m[26], &m[27]))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected from none to 22 string argument(s)"));
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL
+ };
+
+ if( !PyArg_ParseTuple( args, "|ssssssssssssssssssssssssssss",
+ &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
+ &m[7], &m[8], &m[9], &m[10], &m[11], &m[12],
+ &m[13], &m[14], &m[15], &m[16], &m[17], &m[18],
+ &m[19], &m[20], &m[21], &m[22], &m[23], &m[24],
+ &m[25], &m[26], &m[27] ) ) {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected from none to 22 string argument(s)" ) );
}
- for (i = 0; i < 28; i++) {
- if (m[i] == NULL) break;
- if (strcmp(m[i], "Traceable") == 0)
+ for( i = 0; i < 28; i++ ) {
+ if( m[i] == NULL )
+ break;
+ if( strcmp( m[i], "Traceable" ) == 0 )
flag |= EXPP_MAT_MODE_TRACEABLE;
- else if (strcmp(m[i], "Shadow") == 0)
+ else if( strcmp( m[i], "Shadow" ) == 0 )
flag |= EXPP_MAT_MODE_SHADOW;
- else if (strcmp(m[i], "Shadeless") == 0)
+ else if( strcmp( m[i], "Shadeless" ) == 0 )
flag |= EXPP_MAT_MODE_SHADELESS;
- else if (strcmp(m[i], "Wire") == 0)
+ else if( strcmp( m[i], "Wire" ) == 0 )
flag |= EXPP_MAT_MODE_WIRE;
- else if (strcmp(m[i], "VColLight") == 0)
+ else if( strcmp( m[i], "VColLight" ) == 0 )
flag |= EXPP_MAT_MODE_VCOL_LIGHT;
- else if (strcmp(m[i], "VColPaint") == 0)
+ else if( strcmp( m[i], "VColPaint" ) == 0 )
flag |= EXPP_MAT_MODE_VCOL_PAINT;
- else if (strcmp(m[i], "Halo") == 0)
+ else if( strcmp( m[i], "Halo" ) == 0 )
flag |= EXPP_MAT_MODE_HALO;
- else if (strcmp(m[i], "ZTransp") == 0)
+ else if( strcmp( m[i], "ZTransp" ) == 0 )
flag |= EXPP_MAT_MODE_ZTRANSP;
- else if (strcmp(m[i], "ZInvert") == 0)
+ else if( strcmp( m[i], "ZInvert" ) == 0 )
flag |= EXPP_MAT_MODE_ZINVERT;
- else if (strcmp(m[i], "HaloRings") == 0)
+ else if( strcmp( m[i], "HaloRings" ) == 0 )
flag |= EXPP_MAT_MODE_HALORINGS;
- else if (strcmp(m[i], "Env") == 0)
+ else if( strcmp( m[i], "Env" ) == 0 )
flag |= EXPP_MAT_MODE_ENV;
- else if (strcmp(m[i], "HaloLines") == 0)
+ else if( strcmp( m[i], "HaloLines" ) == 0 )
flag |= EXPP_MAT_MODE_HALOLINES;
- else if (strcmp(m[i], "OnlyShadow") == 0)
+ else if( strcmp( m[i], "OnlyShadow" ) == 0 )
flag |= EXPP_MAT_MODE_ONLYSHADOW;
- else if (strcmp(m[i], "HaloXAlpha") == 0)
+ else if( strcmp( m[i], "HaloXAlpha" ) == 0 )
flag |= EXPP_MAT_MODE_HALOXALPHA;
- else if (strcmp(m[i], "HaloStar") == 0)
+ else if( strcmp( m[i], "HaloStar" ) == 0 )
flag |= EXPP_MAT_MODE_HALOSTAR;
- else if (strcmp(m[i], "TexFace") == 0)
+ else if( strcmp( m[i], "TexFace" ) == 0 )
flag |= EXPP_MAT_MODE_TEXFACE;
- else if (strcmp(m[i], "HaloTex") == 0)
+ else if( strcmp( m[i], "HaloTex" ) == 0 )
flag |= EXPP_MAT_MODE_HALOTEX;
- else if (strcmp(m[i], "HaloPuno") == 0)
+ else if( strcmp( m[i], "HaloPuno" ) == 0 )
flag |= EXPP_MAT_MODE_HALOPUNO;
- else if (strcmp(m[i], "NoMist") == 0)
+ else if( strcmp( m[i], "NoMist" ) == 0 )
flag |= EXPP_MAT_MODE_NOMIST;
- else if (strcmp(m[i], "HaloShaded") == 0)
+ else if( strcmp( m[i], "HaloShaded" ) == 0 )
flag |= EXPP_MAT_MODE_HALOSHADE;
- else if (strcmp(m[i], "HaloFlare") == 0)
+ else if( strcmp( m[i], "HaloFlare" ) == 0 )
flag |= EXPP_MAT_MODE_HALOFLARE;
- else if (strcmp(m[i], "Radio") == 0)
+ else if( strcmp( m[i], "Radio" ) == 0 )
flag |= EXPP_MAT_MODE_RADIO;
/* ** Mirror ** */
- else if (strcmp(m[i], "RayMirr") == 0)
- flag |= EXPP_MAT_MODE_RAYMIRROR;
- else if (strcmp(m[i], "ZTransp") == 0)
- flag |= EXPP_MAT_MODE_ZTRA;
- else if (strcmp(m[i], "RayTransp") == 0)
+ else if( strcmp( m[i], "RayMirr" ) == 0 )
+ flag |= EXPP_MAT_MODE_RAYMIRROR;
+ else if( strcmp( m[i], "ZTransp" ) == 0 )
+ flag |= EXPP_MAT_MODE_ZTRA;
+ else if( strcmp( m[i], "RayTransp" ) == 0 )
flag |= EXPP_MAT_MODE_RAYTRANSP;
- else if (strcmp(m[i], "OnlyShadow") == 0)
- flag |= EXPP_MAT_MODE_ONLYSHADOW;
- else if (strcmp(m[i], "NoMist") == 0)
+ else if( strcmp( m[i], "OnlyShadow" ) == 0 )
+ flag |= EXPP_MAT_MODE_ONLYSHADOW;
+ else if( strcmp( m[i], "NoMist" ) == 0 )
flag |= EXPP_MAT_MODE_NOMIST;
- else if (strcmp(m[i], "Env") == 0)
+ else if( strcmp( m[i], "Env" ) == 0 )
flag |= EXPP_MAT_MODE_ENV;
/* ** */
else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown Material mode argument"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown Material mode argument" ) );
}
self->material->mode = flag;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/* Another helper function, for the same reason.
* (See comment before Material_setIntType above). */
-static PyObject *Material_setIntMode(BPy_Material *self, PyObject *args)
+static PyObject *Material_setIntMode( BPy_Material * self, PyObject * args )
{
int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
self->material->mode = value;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Material_setRGBCol (BPy_Material *self, PyObject *args)
+static PyObject *Material_setRGBCol( BPy_Material * self, PyObject * args )
{
- return rgbTuple_setCol(self->col, args);
+ return rgbTuple_setCol( self->col, args );
}
+
/*
static PyObject *Material_setAmbCol (BPy_Material *self, PyObject *args)
{
return rgbTuple_setCol(self->amb, args);
}
*/
-static PyObject *Material_setSpecCol (BPy_Material *self, PyObject *args)
+static PyObject *Material_setSpecCol( BPy_Material * self, PyObject * args )
{
- return rgbTuple_setCol(self->spec, args);
+ return rgbTuple_setCol( self->spec, args );
}
-static PyObject *Material_setMirCol (BPy_Material *self, PyObject *args)
+static PyObject *Material_setMirCol( BPy_Material * self, PyObject * args )
{
- return rgbTuple_setCol(self->mir, args);
+ return rgbTuple_setCol( self->mir, args );
}
-static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
- PyObject *args)
-{ /* for compatibility with old bpython */
+static PyObject *Material_setColorComponent( BPy_Material * self, char *key,
+ PyObject * args )
+{ /* for compatibility with old bpython */
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- value = EXPP_ClampFloat (value, EXPP_MAT_COL_MIN,
- EXPP_MAT_COL_MAX);
+ value = EXPP_ClampFloat( value, EXPP_MAT_COL_MIN, EXPP_MAT_COL_MAX );
- if (!strcmp(key, "R"))
+ if( !strcmp( key, "R" ) )
self->material->r = value;
- else if (!strcmp(key, "G"))
+ else if( !strcmp( key, "G" ) )
self->material->g = value;
- else if (!strcmp(key, "B"))
+ else if( !strcmp( key, "B" ) )
self->material->b = value;
- else if (!strcmp(key, "specR"))
+ else if( !strcmp( key, "specR" ) )
self->material->specr = value;
- else if (!strcmp(key, "specG"))
+ else if( !strcmp( key, "specG" ) )
self->material->specg = value;
- else if (!strcmp(key, "specB"))
+ else if( !strcmp( key, "specB" ) )
self->material->specb = value;
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setAmb(BPy_Material *self, PyObject *args)
+static PyObject *Material_setAmb( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->amb = EXPP_ClampFloat (value, EXPP_MAT_AMB_MIN,
- EXPP_MAT_AMB_MAX);
+ self->material->amb = EXPP_ClampFloat( value, EXPP_MAT_AMB_MIN,
+ EXPP_MAT_AMB_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setEmit(BPy_Material *self, PyObject *args)
+static PyObject *Material_setEmit( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->emit = EXPP_ClampFloat (value, EXPP_MAT_EMIT_MIN,
- EXPP_MAT_EMIT_MAX);
+ self->material->emit = EXPP_ClampFloat( value, EXPP_MAT_EMIT_MIN,
+ EXPP_MAT_EMIT_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setSpecTransp(BPy_Material *self, PyObject *args)
+static PyObject *Material_setSpecTransp( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->spectra = EXPP_ClampFloat (value, EXPP_MAT_SPECTRA_MIN,
- EXPP_MAT_SPECTRA_MAX);
+ self->material->spectra = EXPP_ClampFloat( value, EXPP_MAT_SPECTRA_MIN,
+ EXPP_MAT_SPECTRA_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setAlpha(BPy_Material *self, PyObject *args)
+static PyObject *Material_setAlpha( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->alpha = EXPP_ClampFloat (value, EXPP_MAT_ALPHA_MIN,
- EXPP_MAT_ALPHA_MAX);
+ self->material->alpha = EXPP_ClampFloat( value, EXPP_MAT_ALPHA_MIN,
+ EXPP_MAT_ALPHA_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setRef(BPy_Material *self, PyObject *args)
+static PyObject *Material_setRef( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->ref = EXPP_ClampFloat (value, EXPP_MAT_REF_MIN,
- EXPP_MAT_REF_MAX);
+ self->material->ref = EXPP_ClampFloat( value, EXPP_MAT_REF_MIN,
+ EXPP_MAT_REF_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setSpec(BPy_Material *self, PyObject *args)
+static PyObject *Material_setSpec( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->spec = EXPP_ClampFloat (value, EXPP_MAT_SPEC_MIN,
- EXPP_MAT_SPEC_MAX);
+ self->material->spec = EXPP_ClampFloat( value, EXPP_MAT_SPEC_MIN,
+ EXPP_MAT_SPEC_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setZOffset(BPy_Material *self, PyObject *args)
+static PyObject *Material_setZOffset( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 10.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 10.0]" ) );
- self->material->zoffs = EXPP_ClampFloat (value, EXPP_MAT_ZOFFS_MIN,
- EXPP_MAT_ZOFFS_MAX);
+ self->material->zoffs = EXPP_ClampFloat( value, EXPP_MAT_ZOFFS_MIN,
+ EXPP_MAT_ZOFFS_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setAdd(BPy_Material *self, PyObject *args)
+static PyObject *Material_setAdd( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->add = EXPP_ClampFloat (value, EXPP_MAT_ADD_MIN,
- EXPP_MAT_ADD_MAX);
+ self->material->add = EXPP_ClampFloat( value, EXPP_MAT_ADD_MIN,
+ EXPP_MAT_ADD_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setHaloSize(BPy_Material *self, PyObject *args)
+static PyObject *Material_setHaloSize( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 100.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 100.0]" ) );
- self->material->hasize = EXPP_ClampFloat (value, EXPP_MAT_HALOSIZE_MIN,
- EXPP_MAT_HALOSIZE_MAX);
+ self->material->hasize = EXPP_ClampFloat( value, EXPP_MAT_HALOSIZE_MIN,
+ EXPP_MAT_HALOSIZE_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFlareSize(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFlareSize( BPy_Material * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.1, 25.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.1, 25.0]" ) );
- self->material->flaresize = EXPP_ClampFloat (value, EXPP_MAT_FLARESIZE_MIN,
- EXPP_MAT_FLARESIZE_MAX);
+ self->material->flaresize =
+ EXPP_ClampFloat( value, EXPP_MAT_FLARESIZE_MIN,
+ EXPP_MAT_FLARESIZE_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFlareBoost(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFlareBoost( BPy_Material * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.1, 10.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.1, 10.0]" ) );
- self->material->flareboost = EXPP_ClampFloat(value, EXPP_MAT_FLAREBOOST_MIN,
- EXPP_MAT_FLAREBOOST_MAX);
+ self->material->flareboost =
+ EXPP_ClampFloat( value, EXPP_MAT_FLAREBOOST_MIN,
+ EXPP_MAT_FLAREBOOST_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args)
+static PyObject *Material_setSubSize( BPy_Material * self, PyObject * args )
{
- float value;
+ float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.1, 25.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.1, 25.0]" ) );
- self->material->subsize = EXPP_ClampFloat (value, EXPP_MAT_SUBSIZE_MIN,
- EXPP_MAT_SUBSIZE_MAX);
+ self->material->subsize = EXPP_ClampFloat( value, EXPP_MAT_SUBSIZE_MIN,
+ EXPP_MAT_SUBSIZE_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setHaloSeed(BPy_Material *self, PyObject *args)
+static PyObject *Material_setHaloSeed( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1, 255]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1, 255]" ) );
- self->material->seed1 = EXPP_ClampInt (value, EXPP_MAT_HALOSEED_MIN,
- EXPP_MAT_HALOSEED_MAX);
+ self->material->seed1 = EXPP_ClampInt( value, EXPP_MAT_HALOSEED_MIN,
+ EXPP_MAT_HALOSEED_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFlareSeed(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFlareSeed( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1, 255]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1, 255]" ) );
- self->material->seed2 = EXPP_ClampInt (value, EXPP_MAT_FLARESEED_MIN,
- EXPP_MAT_FLARESEED_MAX);
+ self->material->seed2 = EXPP_ClampInt( value, EXPP_MAT_FLARESEED_MIN,
+ EXPP_MAT_FLARESEED_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setHardness(BPy_Material *self, PyObject *args)
+static PyObject *Material_setHardness( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1, 255]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1, 255]" ) );
- self->material->har = EXPP_ClampInt (value, EXPP_MAT_HARD_MIN,
- EXPP_MAT_HARD_MAX);
+ self->material->har = EXPP_ClampInt( value, EXPP_MAT_HARD_MIN,
+ EXPP_MAT_HARD_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setNFlares(BPy_Material *self, PyObject *args)
+static PyObject *Material_setNFlares( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [1, 32]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [1, 32]" ) );
- self->material->flarec = EXPP_ClampInt (value, EXPP_MAT_NFLARES_MIN,
- EXPP_MAT_NFLARES_MAX);
+ self->material->flarec = EXPP_ClampInt( value, EXPP_MAT_NFLARES_MIN,
+ EXPP_MAT_NFLARES_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setNStars(BPy_Material *self, PyObject *args)
+static PyObject *Material_setNStars( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [3, 50]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [3, 50]" ) );
- self->material->starc = EXPP_ClampInt (value, EXPP_MAT_NSTARS_MIN,
- EXPP_MAT_NSTARS_MAX);
+ self->material->starc = EXPP_ClampInt( value, EXPP_MAT_NSTARS_MIN,
+ EXPP_MAT_NSTARS_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setNLines(BPy_Material *self, PyObject *args)
+static PyObject *Material_setNLines( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0, 250]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [0, 250]" ) );
- self->material->linec = EXPP_ClampInt (value, EXPP_MAT_NLINES_MIN,
- EXPP_MAT_NLINES_MAX);
+ self->material->linec = EXPP_ClampInt( value, EXPP_MAT_NLINES_MIN,
+ EXPP_MAT_NLINES_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setNRings(BPy_Material *self, PyObject *args)
+static PyObject *Material_setNRings( BPy_Material * self, PyObject * args )
{
short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0, 24]"));
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument in [0, 24]" ) );
- self->material->ringc = EXPP_ClampInt (value, EXPP_MAT_NRINGS_MIN,
- EXPP_MAT_NRINGS_MAX);
+ self->material->ringc = EXPP_ClampInt( value, EXPP_MAT_NRINGS_MIN,
+ EXPP_MAT_NRINGS_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setRayMirr(BPy_Material *self, PyObject *args)
+static PyObject *Material_setRayMirr( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 1.0]" ) );
- self->material->ray_mirror = EXPP_ClampFloat (value, EXPP_MAT_RAYMIRR_MIN,
- EXPP_MAT_RAYMIRR_MAX);
+ self->material->ray_mirror =
+ EXPP_ClampFloat( value, EXPP_MAT_RAYMIRR_MIN,
+ EXPP_MAT_RAYMIRR_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setMirrDepth(BPy_Material *self, PyObject *args)
+static PyObject *Material_setMirrDepth( BPy_Material * self, PyObject * args )
{
int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0, 10]"));
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0, 10]" ) );
- self->material->ray_depth = EXPP_ClampInt (value, EXPP_MAT_MIRRDEPTH_MIN,
- EXPP_MAT_MIRRDEPTH_MAX);
+ self->material->ray_depth =
+ EXPP_ClampInt( value, EXPP_MAT_MIRRDEPTH_MIN,
+ EXPP_MAT_MIRRDEPTH_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFresnelMirr(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFresnelMirr( BPy_Material * self,
+ PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 5.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 5.0]" ) );
- self->material->fresnel_mir = EXPP_ClampFloat (value, EXPP_MAT_FRESNELMIRR_MIN,
- EXPP_MAT_FRESNELMIRR_MAX);
+ self->material->fresnel_mir =
+ EXPP_ClampFloat( value, EXPP_MAT_FRESNELMIRR_MIN,
+ EXPP_MAT_FRESNELMIRR_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFresnelMirrFac(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFresnelMirrFac( BPy_Material * self,
+ PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 5.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 5.0]" ) );
- self->material->fresnel_mir_i = EXPP_ClampFloat (value, EXPP_MAT_FRESNELMIRRFAC_MIN,
- EXPP_MAT_FRESNELMIRRFAC_MAX);
+ self->material->fresnel_mir_i =
+ EXPP_ClampFloat( value, EXPP_MAT_FRESNELMIRRFAC_MIN,
+ EXPP_MAT_FRESNELMIRRFAC_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setIOR(BPy_Material *self, PyObject *args)
+static PyObject *Material_setIOR( BPy_Material * self, PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 5.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 5.0]" ) );
- self->material->ang = EXPP_ClampFloat (value, EXPP_MAT_IOR_MIN,
- EXPP_MAT_IOR_MAX);
+ self->material->ang = EXPP_ClampFloat( value, EXPP_MAT_IOR_MIN,
+ EXPP_MAT_IOR_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setTransDepth(BPy_Material *self, PyObject *args)
+static PyObject *Material_setTransDepth( BPy_Material * self, PyObject * args )
{
int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0, 10]"));
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0, 10]" ) );
- self->material->ray_depth_tra = EXPP_ClampInt (value, EXPP_MAT_TRANSDEPTH_MIN,
- EXPP_MAT_TRANSDEPTH_MAX);
+ self->material->ray_depth_tra =
+ EXPP_ClampInt( value, EXPP_MAT_TRANSDEPTH_MIN,
+ EXPP_MAT_TRANSDEPTH_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFresnelTrans(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFresnelTrans( BPy_Material * self,
+ PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 5.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 5.0]" ) );
- self->material->fresnel_tra = EXPP_ClampFloat (value, EXPP_MAT_FRESNELTRANS_MIN,
- EXPP_MAT_FRESNELTRANS_MAX);
+ self->material->fresnel_tra =
+ EXPP_ClampFloat( value, EXPP_MAT_FRESNELTRANS_MIN,
+ EXPP_MAT_FRESNELTRANS_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setFresnelTransFac(BPy_Material *self, PyObject *args)
+static PyObject *Material_setFresnelTransFac( BPy_Material * self,
+ PyObject * args )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 5.0]"));
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument in [0.0, 5.0]" ) );
- self->material->fresnel_tra_i = EXPP_ClampFloat (value, EXPP_MAT_FRESNELTRANSFAC_MIN,
- EXPP_MAT_FRESNELTRANSFAC_MAX);
+ self->material->fresnel_tra_i =
+ EXPP_ClampFloat( value, EXPP_MAT_FRESNELTRANSFAC_MIN,
+ EXPP_MAT_FRESNELTRANSFAC_MAX );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Material_setTexture(BPy_Material *self, PyObject *args)
+static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
{
int texnum;
PyObject *pytex;
Tex *bltex;
- int texco=TEXCO_ORCO, mapto=MAP_COL;
-
- if (!PyArg_ParseTuple(args, "iO!|ii", &texnum, &Texture_Type, &pytex,
- &texco, &mapto))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7] and Texture");
- if ((texnum<0) || (texnum>=8))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7] and Texture");
-
- bltex = Texture_FromPyObject (pytex);
-
- if (!self->material->mtex[texnum]) {
+ int texco = TEXCO_ORCO, mapto = MAP_COL;
+
+ if( !PyArg_ParseTuple( args, "iO!|ii", &texnum, &Texture_Type, &pytex,
+ &texco, &mapto ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int in [0,7] and Texture" );
+ if( ( texnum < 0 ) || ( texnum >= 8 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int in [0,7] and Texture" );
+
+ bltex = Texture_FromPyObject( pytex );
+
+ if( !self->material->mtex[texnum] ) {
/* there isn't an mtex for this slot so we need to make one */
- self->material->mtex[texnum] = add_mtex ();
- }
- else {
+ self->material->mtex[texnum] = add_mtex( );
+ } else {
/* we already had a texture here so deal with the old one first */
self->material->mtex[texnum]->tex->id.us--;
}
-
+
self->material->mtex[texnum]->tex = bltex;
- id_us_plus (&bltex->id);
+ id_us_plus( &bltex->id );
self->material->mtex[texnum]->texco = texco;
self->material->mtex[texnum]->mapto = mapto;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Material_clearTexture(BPy_Material *self, PyObject *args)
+static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args )
{
int texnum;
struct MTex *mtex;
- if (!PyArg_ParseTuple(args, "i", &texnum))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7]");
- if ((texnum<0) || (texnum>=8))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,7]");
-
+ if( !PyArg_ParseTuple( args, "i", &texnum ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int in [0,7]" );
+ if( ( texnum < 0 ) || ( texnum >= 8 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int in [0,7]" );
+
mtex = self->material->mtex[texnum];
- if (mtex) {
- if (mtex->tex)
+ if( mtex ) {
+ if( mtex->tex )
mtex->tex->id.us--;
- MEM_freeN (mtex);
+ MEM_freeN( mtex );
self->material->mtex[texnum] = NULL;
}
-
- Py_INCREF(Py_None);
+
+ Py_INCREF( Py_None );
return Py_None;
}
/* mat.addScriptLink */
-static PyObject *Material_addScriptLink (BPy_Material *self, PyObject *args)
+static PyObject *Material_addScriptLink( BPy_Material * self, PyObject * args )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
- slink = &(mat)->scriptlink;
+ slink = &( mat )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 0))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 0 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* mat.clearScriptLinks */
-static PyObject *Material_clearScriptLinks (BPy_Material *self)
+static PyObject *Material_clearScriptLinks( BPy_Material * self )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
- slink = &(mat)->scriptlink;
+ slink = &( mat )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* mat.getScriptLinks */
-static PyObject *Material_getScriptLinks (BPy_Material *self, PyObject *args)
+static PyObject *Material_getScriptLinks( BPy_Material * self,
+ PyObject * args )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- slink = &(mat)->scriptlink;
+ slink = &( mat )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 0);
+ ret = EXPP_getScriptLinks( slink, args, 0 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
/*****************************************************************************/
-/* Function: Material_getAttr */
+/* Function: Material_getAttr */
/* Description: This is a callback function for the BPy_Material type. It is */
-/* the function that accesses BPy_Material "member variables" */
-/* and methods. */
+/* the function that accesses BPy_Material "member variables" */
+/* and methods. */
/*****************************************************************************/
-static PyObject *Material_getAttr (BPy_Material *self, char *name)
+static PyObject *Material_getAttr( BPy_Material * self, char *name )
{
PyObject *attr = Py_None;
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->material->id.name+2);
- else if (strcmp(name, "mode") == 0)
- attr = PyInt_FromLong(self->material->mode);
- else if (strcmp(name, "rgbCol") == 0)
- attr = Material_getRGBCol(self);
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->material->id.name + 2 );
+ else if( strcmp( name, "mode" ) == 0 )
+ attr = PyInt_FromLong( self->material->mode );
+ else if( strcmp( name, "rgbCol" ) == 0 )
+ attr = Material_getRGBCol( self );
/* else if (strcmp(name, "ambCol") == 0)
attr = Material_getAmbCol(self);*/
- else if (strcmp(name, "specCol") == 0)
- attr = Material_getSpecCol(self);
- else if (strcmp(name, "mirCol") == 0)
- attr = Material_getMirCol(self);
- else if (strcmp(name, "R") == 0)
- attr = PyFloat_FromDouble((double)self->material->r);
- else if (strcmp(name, "G") == 0)
- attr = PyFloat_FromDouble((double)self->material->g);
- else if (strcmp(name, "B") == 0)
- attr = PyFloat_FromDouble((double)self->material->b);
- else if (strcmp(name, "specR") == 0)
- attr = PyFloat_FromDouble((double)self->material->specr);
- else if (strcmp(name, "specG") == 0)
- attr = PyFloat_FromDouble((double)self->material->specg);
- else if (strcmp(name, "specB") == 0)
- attr = PyFloat_FromDouble((double)self->material->specb);
- else if (strcmp(name, "amb") == 0)
- attr = PyFloat_FromDouble((double)self->material->amb);
- else if (strcmp(name, "emit") == 0)
- attr = PyFloat_FromDouble((double)self->material->emit);
- else if (strcmp(name, "alpha") == 0)
- attr = PyFloat_FromDouble((double)self->material->alpha);
- else if (strcmp(name, "ref") == 0)
- attr = PyFloat_FromDouble((double)self->material->ref);
- else if (strcmp(name, "spec") == 0)
- attr = PyFloat_FromDouble((double)self->material->spec);
- else if (strcmp(name, "specTransp") == 0)
- attr = PyFloat_FromDouble((double)self->material->spectra);
- else if (strcmp(name, "add") == 0)
- attr = PyFloat_FromDouble((double)self->material->add);
- else if (strcmp(name, "zOffset") == 0)
- attr = PyFloat_FromDouble((double)self->material->zoffs);
- else if (strcmp(name, "haloSize") == 0)
- attr = PyFloat_FromDouble((double)self->material->hasize);
- else if (strcmp(name, "haloSeed") == 0)
- attr = PyInt_FromLong((double)self->material->seed1);
- else if (strcmp(name, "flareSize") == 0)
- attr = PyFloat_FromDouble((double)self->material->flaresize);
- else if (strcmp(name, "flareBoost") == 0)
- attr = PyFloat_FromDouble((double)self->material->flareboost);
- else if (strcmp(name, "flareSeed") == 0)
- attr = PyInt_FromLong((double)self->material->seed2);
- else if (strcmp(name, "subSize") == 0)
- attr = PyFloat_FromDouble((double)self->material->subsize);
- else if (strcmp(name, "hard") == 0)
- attr = PyInt_FromLong((long)self->material->har);
- else if (strcmp(name, "nFlares") == 0)
- attr = PyInt_FromLong((long)self->material->flarec);
- else if (strcmp(name, "nStars") == 0)
- attr = PyInt_FromLong((long)self->material->starc);
- else if (strcmp(name, "nLines") == 0)
- attr = PyInt_FromLong((long)self->material->linec);
- else if (strcmp(name, "nRings") == 0)
- attr = PyInt_FromLong((long)self->material->ringc);
- else if (strcmp (name, "rayMirr") == 0)
- attr = PyFloat_FromDouble((double)self->material->ray_mirror);
- else if (strcmp (name, "rayMirrDepth") == 0)
- attr = PyInt_FromLong((long)self->material->ray_depth);
- else if (strcmp (name, "fresnelDepth") == 0)
- attr = PyFloat_FromDouble((double)self->material->fresnel_mir);
- else if (strcmp (name, "fresnelDepthFac") == 0)
- attr = PyFloat_FromDouble((double)self->material->fresnel_mir_i);
- else if (strcmp (name, "IOR") == 0)
- attr = PyFloat_FromDouble((double)self->material->ang);
- else if (strcmp (name, "transDepth") == 0)
- attr = PyInt_FromLong((double)self->material->ray_depth_tra);
- else if (strcmp (name, "fresnelTrans") == 0)
- attr = PyFloat_FromDouble((double)self->material->fresnel_tra);
- else if (strcmp (name, "fresnelTransFac") == 0)
- attr = PyFloat_FromDouble((double)self->material->fresnel_tra_i);
-
- else if (strcmp(name, "__members__") == 0) {
- attr = /* 27 items */
- Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
- "name", "mode", "rgbCol", "specCol", "mirCol",
- "R", "G", "B", "alpha", "amb", "emit", "ref", "spec",
- "specTransp", "add", "zOffset", "haloSize", "haloSeed",
- "flareSize", "flareBoost", "flareSeed", "subSize", "hard",
- "nFlares", "nStars", "nLines", "nRings", "rayMirr", "rayMirrDepth",
- "fresnelDepth", "fresnelDepthFac", "IOR", "transDepth", "fresnelTrans",
- "fresnelTransFac");
+ else if( strcmp( name, "specCol" ) == 0 )
+ attr = Material_getSpecCol( self );
+ else if( strcmp( name, "mirCol" ) == 0 )
+ attr = Material_getMirCol( self );
+ else if( strcmp( name, "R" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->r );
+ else if( strcmp( name, "G" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->g );
+ else if( strcmp( name, "B" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->b );
+ else if( strcmp( name, "specR" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->specr );
+ else if( strcmp( name, "specG" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->specg );
+ else if( strcmp( name, "specB" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->specb );
+ else if( strcmp( name, "amb" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->amb );
+ else if( strcmp( name, "emit" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->emit );
+ else if( strcmp( name, "alpha" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->alpha );
+ else if( strcmp( name, "ref" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->ref );
+ else if( strcmp( name, "spec" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->spec );
+ else if( strcmp( name, "specTransp" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ spectra );
+ else if( strcmp( name, "add" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->add );
+ else if( strcmp( name, "zOffset" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->zoffs );
+ else if( strcmp( name, "haloSize" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->hasize );
+ else if( strcmp( name, "haloSeed" ) == 0 )
+ attr = PyInt_FromLong( ( double ) self->material->seed1 );
+ else if( strcmp( name, "flareSize" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ flaresize );
+ else if( strcmp( name, "flareBoost" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ flareboost );
+ else if( strcmp( name, "flareSeed" ) == 0 )
+ attr = PyInt_FromLong( ( double ) self->material->seed2 );
+ else if( strcmp( name, "subSize" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ subsize );
+ else if( strcmp( name, "hard" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->har );
+ else if( strcmp( name, "nFlares" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->flarec );
+ else if( strcmp( name, "nStars" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->starc );
+ else if( strcmp( name, "nLines" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->linec );
+ else if( strcmp( name, "nRings" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->ringc );
+ else if( strcmp( name, "rayMirr" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ ray_mirror );
+ else if( strcmp( name, "rayMirrDepth" ) == 0 )
+ attr = PyInt_FromLong( ( long ) self->material->ray_depth );
+ else if( strcmp( name, "fresnelDepth" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ fresnel_mir );
+ else if( strcmp( name, "fresnelDepthFac" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ fresnel_mir_i );
+ else if( strcmp( name, "IOR" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->ang );
+ else if( strcmp( name, "transDepth" ) == 0 )
+ attr = PyInt_FromLong( ( double ) self->material->
+ ray_depth_tra );
+ else if( strcmp( name, "fresnelTrans" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ fresnel_tra );
+ else if( strcmp( name, "fresnelTransFac" ) == 0 )
+ attr = PyFloat_FromDouble( ( double ) self->material->
+ fresnel_tra_i );
+
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ attr = /* 27 items */
+ Py_BuildValue
+ ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+ "name", "mode", "rgbCol", "specCol", "mirCol", "R",
+ "G", "B", "alpha", "amb", "emit", "ref", "spec",
+ "specTransp", "add", "zOffset", "haloSize",
+ "haloSeed", "flareSize", "flareBoost", "flareSeed",
+ "subSize", "hard", "nFlares", "nStars", "nLines",
+ "nRings", "rayMirr", "rayMirrDepth", "fresnelDepth",
+ "fresnelDepthFac", "IOR", "transDepth",
+ "fresnelTrans", "fresnelTransFac" );
}
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- if (attr != Py_None) return attr; /* member attribute found, return it */
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
/* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Material_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Material_methods, ( PyObject * ) self,
+ name );
}
/****************************************************************************/
-/* Function: Material_setAttr */
-/* Description: This is a callback function for the BPy_Material type. */
-/* It is the function that sets Material attributes (member */
-/* variables). */
+/* Function: Material_setAttr */
+/* Description: This is a callback function for the BPy_Material type. */
+/* It is the function that sets Material attributes (member */
+/* variables). */
/****************************************************************************/
-static int Material_setAttr (BPy_Material *self, char *name, PyObject *value)
+static int Material_setAttr( BPy_Material * self, char *name,
+ PyObject * value )
{
- PyObject *valtuple;
+ PyObject *valtuple;
PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
- * Material.member = val instead of Material.setMember(val), we end up using the
- * function anyway, since it already has error checking, clamps to the right
- * interval and updates the Blender Material structure when necessary. */
+ * Material.member = val instead of Material.setMember(val), we end up using
+ * the function anyway, since it already has error checking, clamps to the
+ * right interval and updates the Blender Material structure when necessary.
+ */
/* First we put "value" in a tuple, because we want to pass it to functions
* that only accept PyTuples. */
- valtuple = Py_BuildValue("(O)", value);
+ valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple) /* everything OK with our PyObject? */
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "MaterialSetAttr: couldn't create PyTuple");
+ if( !valtuple ) /* everything OK with our PyObject? */
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "MaterialSetAttr: couldn't create PyTuple" );
/* Now we just compare "name" with all possible BPy_Material member variables */
- if (strcmp (name, "name") == 0)
- error = Material_setName (self, valtuple);
- else if (strcmp (name, "mode") == 0)
- error = Material_setIntMode (self, valtuple); /* special case */
- else if (strcmp (name, "rgbCol") == 0)
- error = Material_setRGBCol (self, valtuple);
+ if( strcmp( name, "name" ) == 0 )
+ error = Material_setName( self, valtuple );
+ else if( strcmp( name, "mode" ) == 0 )
+ error = Material_setIntMode( self, valtuple ); /* special case */
+ else if( strcmp( name, "rgbCol" ) == 0 )
+ error = Material_setRGBCol( self, valtuple );
/* else if (strcmp (name, "ambCol") == 0)
error = Material_setAmbCol (self, valtuple);*/
- else if (strcmp (name, "specCol") == 0)
- error = Material_setSpecCol (self, valtuple);
- else if (strcmp (name, "mirCol") == 0)
- error = Material_setMirCol (self, valtuple);
- else if (strcmp (name, "R") == 0)
- error = Material_setColorComponent (self, "R", valtuple);
- else if (strcmp (name, "G") == 0)
- error = Material_setColorComponent (self, "G", valtuple);
- else if (strcmp (name, "B") == 0)
- error = Material_setColorComponent (self, "B", valtuple);
- else if (strcmp (name, "specR") == 0)
- error = Material_setColorComponent (self, "specR", valtuple);
- else if (strcmp (name, "specG") == 0)
- error = Material_setColorComponent (self, "specG", valtuple);
- else if (strcmp (name, "specB") == 0)
- error = Material_setColorComponent (self, "specB", valtuple);
- else if (strcmp (name, "amb") == 0)
- error = Material_setAmb (self, valtuple);
- else if (strcmp (name, "emit") == 0)
- error = Material_setEmit (self, valtuple);
- else if (strcmp (name, "alpha") == 0)
- error = Material_setAlpha (self, valtuple);
- else if (strcmp (name, "ref") == 0)
- error = Material_setRef (self, valtuple);
- else if (strcmp (name, "spec") == 0)
- error = Material_setSpec (self, valtuple);
- else if (strcmp (name, "specTransp") == 0)
- error = Material_setSpecTransp (self, valtuple);
- else if (strcmp (name, "add") == 0)
- error = Material_setAdd (self, valtuple);
- else if (strcmp (name, "zOffset") == 0)
- error = Material_setZOffset (self, valtuple);
- else if (strcmp (name, "haloSize") == 0)
- error = Material_setHaloSize (self, valtuple);
- else if (strcmp (name, "haloSeed") == 0)
- error = Material_setHaloSeed (self, valtuple);
- else if (strcmp (name, "flareSize") == 0)
- error = Material_setFlareSize (self, valtuple);
- else if (strcmp (name, "flareBoost") == 0)
- error = Material_setFlareBoost (self, valtuple);
- else if (strcmp (name, "flareSeed") == 0)
- error = Material_setFlareSeed (self, valtuple);
- else if (strcmp (name, "subSize") == 0)
- error = Material_setSubSize (self, valtuple);
- else if (strcmp (name, "hard") == 0)
- error = Material_setHardness (self, valtuple);
- else if (strcmp (name, "nFlares") == 0)
- error = Material_setNFlares (self, valtuple);
- else if (strcmp (name, "nStars") == 0)
- error = Material_setNStars (self, valtuple);
- else if (strcmp (name, "nLines") == 0)
- error = Material_setNLines (self, valtuple);
- else if (strcmp (name, "nRings") == 0)
- error = Material_setNRings (self, valtuple);
- else if (strcmp (name, "rayMirr") == 0)
- error = Material_setRayMirr(self, valtuple);
- else if (strcmp (name, "rayMirrDepth") == 0)
- error = Material_setMirrDepth(self, valtuple);
- else if (strcmp (name, "fresnelDepth") == 0)
- error = Material_setFresnelMirr(self, valtuple);
- else if (strcmp (name, "fresnelDepthFac") == 0)
- error = Material_setFresnelMirrFac(self, valtuple);
- else if (strcmp (name, "IOR") == 0)
- error = Material_setIOR(self, valtuple);
- else if (strcmp (name, "transDepth") == 0)
- error = Material_setTransDepth(self, valtuple);
- else if (strcmp (name, "fresnelTrans") == 0)
- error = Material_setFresnelTrans(self, valtuple);
- else if (strcmp (name, "fresnelTransFac") == 0)
- error = Material_setFresnelTransFac(self, valtuple);
-
- else { /* Error */
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_AttributeError, name));
+ else if( strcmp( name, "specCol" ) == 0 )
+ error = Material_setSpecCol( self, valtuple );
+ else if( strcmp( name, "mirCol" ) == 0 )
+ error = Material_setMirCol( self, valtuple );
+ else if( strcmp( name, "R" ) == 0 )
+ error = Material_setColorComponent( self, "R", valtuple );
+ else if( strcmp( name, "G" ) == 0 )
+ error = Material_setColorComponent( self, "G", valtuple );
+ else if( strcmp( name, "B" ) == 0 )
+ error = Material_setColorComponent( self, "B", valtuple );
+ else if( strcmp( name, "specR" ) == 0 )
+ error = Material_setColorComponent( self, "specR", valtuple );
+ else if( strcmp( name, "specG" ) == 0 )
+ error = Material_setColorComponent( self, "specG", valtuple );
+ else if( strcmp( name, "specB" ) == 0 )
+ error = Material_setColorComponent( self, "specB", valtuple );
+ else if( strcmp( name, "amb" ) == 0 )
+ error = Material_setAmb( self, valtuple );
+ else if( strcmp( name, "emit" ) == 0 )
+ error = Material_setEmit( self, valtuple );
+ else if( strcmp( name, "alpha" ) == 0 )
+ error = Material_setAlpha( self, valtuple );
+ else if( strcmp( name, "ref" ) == 0 )
+ error = Material_setRef( self, valtuple );
+ else if( strcmp( name, "spec" ) == 0 )
+ error = Material_setSpec( self, valtuple );
+ else if( strcmp( name, "specTransp" ) == 0 )
+ error = Material_setSpecTransp( self, valtuple );
+ else if( strcmp( name, "add" ) == 0 )
+ error = Material_setAdd( self, valtuple );
+ else if( strcmp( name, "zOffset" ) == 0 )
+ error = Material_setZOffset( self, valtuple );
+ else if( strcmp( name, "haloSize" ) == 0 )
+ error = Material_setHaloSize( self, valtuple );
+ else if( strcmp( name, "haloSeed" ) == 0 )
+ error = Material_setHaloSeed( self, valtuple );
+ else if( strcmp( name, "flareSize" ) == 0 )
+ error = Material_setFlareSize( self, valtuple );
+ else if( strcmp( name, "flareBoost" ) == 0 )
+ error = Material_setFlareBoost( self, valtuple );
+ else if( strcmp( name, "flareSeed" ) == 0 )
+ error = Material_setFlareSeed( self, valtuple );
+ else if( strcmp( name, "subSize" ) == 0 )
+ error = Material_setSubSize( self, valtuple );
+ else if( strcmp( name, "hard" ) == 0 )
+ error = Material_setHardness( self, valtuple );
+ else if( strcmp( name, "nFlares" ) == 0 )
+ error = Material_setNFlares( self, valtuple );
+ else if( strcmp( name, "nStars" ) == 0 )
+ error = Material_setNStars( self, valtuple );
+ else if( strcmp( name, "nLines" ) == 0 )
+ error = Material_setNLines( self, valtuple );
+ else if( strcmp( name, "nRings" ) == 0 )
+ error = Material_setNRings( self, valtuple );
+ else if( strcmp( name, "rayMirr" ) == 0 )
+ error = Material_setRayMirr( self, valtuple );
+ else if( strcmp( name, "rayMirrDepth" ) == 0 )
+ error = Material_setMirrDepth( self, valtuple );
+ else if( strcmp( name, "fresnelDepth" ) == 0 )
+ error = Material_setFresnelMirr( self, valtuple );
+ else if( strcmp( name, "fresnelDepthFac" ) == 0 )
+ error = Material_setFresnelMirrFac( self, valtuple );
+ else if( strcmp( name, "IOR" ) == 0 )
+ error = Material_setIOR( self, valtuple );
+ else if( strcmp( name, "transDepth" ) == 0 )
+ error = Material_setTransDepth( self, valtuple );
+ else if( strcmp( name, "fresnelTrans" ) == 0 )
+ error = Material_setFresnelTrans( self, valtuple );
+ else if( strcmp( name, "fresnelTransFac" ) == 0 )
+ error = Material_setFresnelTransFac( self, valtuple );
+
+ else { /* Error */
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_AttributeError, name ) );
}
/* valtuple won't be returned to the caller, so we need to DECREF it */
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
/* Py_None was incref'ed by the called Material_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 exit */
+ Py_DECREF( Py_None );
+ return 0; /* normal exit */
}
/*****************************************************************************/
-/* Function: Material_repr */
-/* Description: This is a callback function for the BPy_Material type. It */
-/* builds a meaninful string to represent material objects. */
+/* Function: Material_repr */
+/* Description: This is a callback function for the BPy_Material type. It */
+/* builds a meaninful string to represent material objects. */
/*****************************************************************************/
-static PyObject *Material_repr (BPy_Material *self)
+static PyObject *Material_repr( BPy_Material * self )
{
- return PyString_FromFormat ("[Material \"%s\"]", self->material->id.name+2);
+ return PyString_FromFormat( "[Material \"%s\"]",
+ self->material->id.name + 2 );
}
/*****************************************************************************/
-/* These functions are used in NMesh.c and Object.c */
+/* These functions are used in NMesh.c and Object.c */
/*****************************************************************************/
-PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len, int all)
+PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len, int all )
{
PyObject *list;
int i;
- list = PyList_New(0);
- if (!matlist) return list;
+ list = PyList_New( 0 );
+ if( !matlist )
+ return list;
- for (i = 0; i < len; i++) {
+ for( i = 0; i < len; i++ ) {
Material *mat = matlist[i];
PyObject *ob;
- if (mat) {
- ob = Material_CreatePyObject (mat);
- PyList_Append (list, ob);
- Py_DECREF (ob); /* because Append increfs */
+ if( mat ) {
+ ob = Material_CreatePyObject( mat );
+ PyList_Append( list, ob );
+ Py_DECREF( ob ); /* because Append increfs */
+ } else if( all ) { /* return NULL mats (empty slots) as Py_None */
+ PyList_Append( list, Py_None );
}
- else if (all) { /* return NULL mats (empty slots) as Py_None */
- PyList_Append (list, Py_None);
- }
}
return list;
}
-Material **EXPP_newMaterialList_fromPyList (PyObject *list)
+Material **EXPP_newMaterialList_fromPyList( PyObject * list )
{
int i, len;
BPy_Material *pymat = 0;
Material *mat;
Material **matlist;
- len = PySequence_Length (list);
- if (len > 16) len = 16;
+ len = PySequence_Length( list );
+ if( len > 16 )
+ len = 16;
- matlist = EXPP_newMaterialList (len);
+ matlist = EXPP_newMaterialList( len );
- for (i = 0; i < len; i++) {
+ for( i = 0; i < len; i++ ) {
- pymat = (BPy_Material *)PySequence_GetItem (list, i);
+ pymat = ( BPy_Material * ) PySequence_GetItem( list, i );
- if (Material_CheckPyObject ((PyObject *)pymat)) {
+ if( Material_CheckPyObject( ( PyObject * ) pymat ) ) {
mat = pymat->material;
matlist[i] = mat;
- }
- else if ((PyObject *)pymat == Py_None) {
+ } else if( ( PyObject * ) pymat == Py_None ) {
matlist[i] = NULL;
- }
- else { /* error; illegal type in material list */
- Py_DECREF(pymat);
- MEM_freeN(matlist);
+ } else { /* error; illegal type in material list */
+ Py_DECREF( pymat );
+ MEM_freeN( matlist );
return NULL;
}
- Py_DECREF(pymat);
+ Py_DECREF( pymat );
}
return matlist;
}
-Material **EXPP_newMaterialList(int len)
+Material **EXPP_newMaterialList( int len )
{
Material **matlist =
- (Material **)MEM_mallocN(len * sizeof(Material *), "MaterialList");
+ ( Material ** ) MEM_mallocN( len * sizeof( Material * ),
+ "MaterialList" );
return matlist;
}
-int EXPP_releaseMaterialList (Material **matlist, int len)
+int EXPP_releaseMaterialList( Material ** matlist, int len )
{
- int i;
+ int i;
Material *mat;
- if ((len < 0) || (len > MAXMAT)) {
- printf ("illegal matindex!\n");
- return 0;
- }
+ if( ( len < 0 ) || ( len > MAXMAT ) ) {
+ printf( "illegal matindex!\n" );
+ return 0;
+ }
- for (i=0 ; i<len ; i++) {
- mat = matlist[i];
- if (mat) {
- if (((ID *)mat)->us > 0)
- ((ID *)mat)->us--;
- else
- printf ("FATAL: material usage=0: %s", ((ID *)mat)->name);
- }
+ for( i = 0; i < len; i++ ) {
+ mat = matlist[i];
+ if( mat ) {
+ if( ( ( ID * ) mat )->us > 0 )
+ ( ( ID * ) mat )->us--;
+ else
+ printf( "FATAL: material usage=0: %s",
+ ( ( ID * ) mat )->name );
}
- MEM_freeN (matlist);
+ }
+ MEM_freeN( matlist );
return 1;
}
@@ -2150,60 +2259,58 @@ int EXPP_releaseMaterialList (Material **matlist, int len)
* 'newsize' is created.
*/
-static int expandPtrArray(void **p, int oldsize, int newsize)
+static int expandPtrArray( void **p, int oldsize, int newsize )
{
void *newarray;
- if (newsize < oldsize) {
+ if( newsize < oldsize ) {
return 0;
- }
- newarray = MEM_callocN(sizeof(void *)*newsize, "PtrArray");
- if (*p) {
- memcpy(newarray, *p, sizeof(void *)*oldsize);
- MEM_freeN(*p);
- }
+ }
+ newarray = MEM_callocN( sizeof( void * ) * newsize, "PtrArray" );
+ if( *p ) {
+ memcpy( newarray, *p, sizeof( void * ) * oldsize );
+ MEM_freeN( *p );
+ }
*p = newarray;
return 1;
}
-int EXPP_synchronizeMaterialLists (Object *object)
+int EXPP_synchronizeMaterialLists( Object * object )
{
- Material *** p_dataMaterials = give_matarar (object);
- short * nmaterials = give_totcolp (object);
- int result = 0;
+ Material ***p_dataMaterials = give_matarar( object );
+ short *nmaterials = give_totcolp( object );
+ int result = 0;
- if (object->totcol > *nmaterials) {
- /* More object mats than data mats */
- result = expandPtrArray ((void *) p_dataMaterials,
- *nmaterials,
- object->totcol);
- *nmaterials = object->totcol;
+ if( object->totcol > *nmaterials ) {
+ /* More object mats than data mats */
+ result = expandPtrArray( ( void * ) p_dataMaterials,
+ *nmaterials, object->totcol );
+ *nmaterials = object->totcol;
+ } else {
+ if( object->totcol < *nmaterials ) {
+ /* More data mats than object mats */
+ result = expandPtrArray( ( void * ) &object->mat,
+ object->totcol, *nmaterials );
+ object->totcol = *nmaterials;
}
- else {
- if (object->totcol < *nmaterials) {
- /* More data mats than object mats */
- result = expandPtrArray ((void *) &object->mat,
- object->totcol,
- *nmaterials);
- object->totcol = *nmaterials;
- }
- } /* else no synchronization needed, they are of equal length */
+ } /* else no synchronization needed, they are of equal length */
- return result; /* 1 if changed, 0 otherwise */
+ return result; /* 1 if changed, 0 otherwise */
}
-void EXPP_incr_mats_us (Material **matlist, int len)
+void EXPP_incr_mats_us( Material ** matlist, int len )
{
int i;
Material *mat;
- if (len <= 0) return;
+ if( len <= 0 )
+ return;
- for (i = 0; i < len; i++) {
+ for( i = 0; i < len; i++ ) {
mat = matlist[i];
- if (mat) mat->id.us++;
+ if( mat )
+ mat->id.us++;
}
return;
}
-
diff --git a/source/blender/python/api2_2x/Material.h b/source/blender/python/api2_2x/Material.h
index 5345cc0c90e..c9591c42271 100644
--- a/source/blender/python/api2_2x/Material.h
+++ b/source/blender/python/api2_2x/Material.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -39,31 +40,31 @@
#include "rgbTuple.h"
/*****************************************************************************/
-/* Python BPy_Material structure definition: */
+/* Python BPy_Material structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Material *material;
+ PyObject_HEAD Material * material;
BPy_rgbTuple *col, *amb, *spec, *mir;
} BPy_Material;
-extern PyTypeObject Material_Type; /* The Material PyType Object */
+extern PyTypeObject Material_Type; /* The Material PyType Object */
#define BPy_Material_Check(v) \
- ((v)->ob_type == &Material_Type) /* for type checking */
+ ((v)->ob_type == &Material_Type) /* for type checking */
/*****************************************************************************/
-/* Module Blender.Material - public functions */
+/* Module Blender.Material - public functions */
/*****************************************************************************/
-PyObject *M_Material_Init (void);
-PyObject *Material_CreatePyObject (Material *mat);
-Material *Material_FromPyObject (PyObject *pyobj);
-int Material_CheckPyObject (PyObject *pyobj);
+PyObject *M_Material_Init( void );
+PyObject *Material_CreatePyObject( Material * mat );
+Material *Material_FromPyObject( PyObject * pyobj );
+int Material_CheckPyObject( PyObject * pyobj );
/* Some functions needed by NMesh.c */
-PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len, int all);
-Material **EXPP_newMaterialList_fromPyList (PyObject *list);
-Material **EXPP_newMaterialList(int len);
+PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
+ int all );
+Material **EXPP_newMaterialList_fromPyList( PyObject * list );
+Material **EXPP_newMaterialList( int len );
-#endif /* EXPP_MATERIAL_H */
+#endif /* EXPP_MATERIAL_H */
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c
index b7e0796759f..5f5664bf706 100644
--- a/source/blender/python/api2_2x/Mathutils.c
+++ b/source/blender/python/api2_2x/Mathutils.c
@@ -33,9 +33,9 @@
#include "Mathutils.h"
//***************************************************************************
-// Function: M_Mathutils_Rand
+// Function: M_Mathutils_Rand
//***************************************************************************
-static PyObject *M_Mathutils_Rand(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Rand( PyObject * self, PyObject * args )
{
float high, low, range;
@@ -43,285 +43,298 @@ static PyObject *M_Mathutils_Rand(PyObject *self, PyObject *args)
high = 1.0;
low = 0.0;
- if (!PyArg_ParseTuple(args, "|ff", &low, &high))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected optional float & float\n"));
+ if( !PyArg_ParseTuple( args, "|ff", &low, &high ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected optional float & float\n" ) );
- if ( (high < low) ||(high < 0 && low > 0))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "high value should be larger than low value\n"));
+ if( ( high < low ) || ( high < 0 && low > 0 ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "high value should be larger than low value\n" ) );
//seed the generator
- BLI_srand((unsigned int) (PIL_check_seconds_timer()*0x7FFFFFFF));
+ BLI_srand( ( unsigned int ) ( PIL_check_seconds_timer( ) *
+ 0x7FFFFFFF ) );
//get the random number 0 - 1
- rand = BLI_drand();
+ rand = BLI_drand( );
//set it to range
range = high - low;
rand = rand * range;
rand = rand + low;
- return PyFloat_FromDouble((double)rand);
+ return PyFloat_FromDouble( ( double ) rand );
}
//***************************************************************************
-// Function: M_Mathutils_Vector
-// Python equivalent: Blender.Mathutils.Vector
+// Function: M_Mathutils_Vector
+// Python equivalent: Blender.Mathutils.Vector
// Supports 2D, 3D, and 4D vector objects both int and float values
-// accepted. Mixed float and int values accepted. Ints are parsed to float
+// accepted. Mixed float and int values accepted. Ints are parsed to float
//***************************************************************************
-static PyObject *M_Mathutils_Vector(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Vector( PyObject * self, PyObject * args )
{
PyObject *listObject = NULL;
PyObject *checkOb = NULL;
int x;
float *vec;
- if (!PyArg_ParseTuple(args, "|O!", &PyList_Type, &listObject))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "0 or 1 list expected"));
+ if( !PyArg_ParseTuple( args, "|O!", &PyList_Type, &listObject ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "0 or 1 list expected" ) );
- if(!listObject) return (PyObject *)newVectorObject(NULL, 3);
+ if( !listObject )
+ return ( PyObject * ) newVectorObject( NULL, 3 );
//2D 3D 4D supported
- if(PyList_Size(listObject) != 2 && PyList_Size(listObject) != 3
- && PyList_Size(listObject) != 4)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "2D, 3D and 4D vectors supported\n"));
-
- for (x = 0; x < PyList_Size(listObject); x++) {
- checkOb = PyList_GetItem(listObject, x);
- if(!PyInt_Check(checkOb) && !PyFloat_Check(checkOb))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected list of numbers\n"));
+ if( PyList_Size( listObject ) != 2 && PyList_Size( listObject ) != 3
+ && PyList_Size( listObject ) != 4 )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "2D, 3D and 4D vectors supported\n" ) );
+
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ checkOb = PyList_GetItem( listObject, x );
+ if( !PyInt_Check( checkOb ) && !PyFloat_Check( checkOb ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list of numbers\n" ) );
}
//allocate memory
- vec = PyMem_Malloc (PyList_Size(listObject)*sizeof (float));
+ vec = PyMem_Malloc( PyList_Size( listObject ) * sizeof( float ) );
//parse it all as floats
- for (x = 0; x < PyList_Size(listObject); x++) {
- if (!PyArg_Parse(PyList_GetItem(listObject, x), "f", &vec[x])){
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list not parseable\n");
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( listObject, x ), "f", &vec[x] ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list not parseable\n" );
}
}
- return (PyObject *)newVectorObject(vec, PyList_Size(listObject));
+ return ( PyObject * ) newVectorObject( vec,
+ PyList_Size( listObject ) );
}
//***************************************************************************
//Begin Vector Utils
-static PyObject *M_Mathutils_CopyVec(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CopyVec( PyObject * self, PyObject * args )
{
- VectorObject * vector;
+ VectorObject *vector;
float *vec;
int x;
- if (!PyArg_ParseTuple(args, "O!", &vector_Type, &vector))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected vector type\n"));
+ if( !PyArg_ParseTuple( args, "O!", &vector_Type, &vector ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected vector type\n" ) );
- vec = PyMem_Malloc(vector->size * sizeof(float));
- for(x = 0; x < vector->size; x++){
+ vec = PyMem_Malloc( vector->size * sizeof( float ) );
+ for( x = 0; x < vector->size; x++ ) {
vec[x] = vector->vec[x];
}
- return (PyObject *)newVectorObject(vec, vector->size);
+ return ( PyObject * ) newVectorObject( vec, vector->size );
}
//finds perpendicular vector - only 3D is supported
-static PyObject *M_Mathutils_CrossVecs(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CrossVecs( PyObject * self, PyObject * args )
{
- PyObject * vecCross;
- VectorObject * vec1;
- VectorObject * vec2;
+ PyObject *vecCross;
+ VectorObject *vec1;
+ VectorObject *vec2;
- if (!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 2 vector types\n"));
- if(vec1->size != 3 || vec2->size != 3)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "only 3D vectors are supported\n"));
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected 2 vector types\n" ) );
+ if( vec1->size != 3 || vec2->size != 3 )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "only 3D vectors are supported\n" ) );
- vecCross = newVectorObject(PyMem_Malloc (3*sizeof (float)), 3);
- Crossf(((VectorObject*)vecCross)->vec, vec1->vec, vec2->vec);
+ vecCross = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 );
+ Crossf( ( ( VectorObject * ) vecCross )->vec, vec1->vec, vec2->vec );
return vecCross;
}
-static PyObject *M_Mathutils_DotVecs(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_DotVecs( PyObject * self, PyObject * args )
{
- VectorObject * vec1;
- VectorObject * vec2;
+ VectorObject *vec1;
+ VectorObject *vec2;
float dot;
int x;
dot = 0;
- if (!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected vector types\n"));
- if(vec1->size != vec2->size)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "vectors must be of the same size\n"));
-
- for(x = 0; x < vec1->size; x++){
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected vector types\n" ) );
+ if( vec1->size != vec2->size )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "vectors must be of the same size\n" ) );
+
+ for( x = 0; x < vec1->size; x++ ) {
dot += vec1->vec[x] * vec2->vec[x];
}
- return PyFloat_FromDouble((double)dot);
+ return PyFloat_FromDouble( ( double ) dot );
}
-static PyObject *M_Mathutils_AngleBetweenVecs(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_AngleBetweenVecs( PyObject * self,
+ PyObject * args )
{
- VectorObject * vec1;
- VectorObject * vec2;
+ VectorObject *vec1;
+ VectorObject *vec2;
float dot, angleRads, norm;
int x;
dot = 0;
- if (!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 2 vector types\n"));
- if(vec1->size != vec2->size)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "vectors must be of the same size\n"));
- if(vec1->size > 3 || vec2->size > 3)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "only 2D,3D vectors are supported\n"));
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected 2 vector types\n" ) );
+ if( vec1->size != vec2->size )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "vectors must be of the same size\n" ) );
+ if( vec1->size > 3 || vec2->size > 3 )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "only 2D,3D vectors are supported\n" ) );
//normalize vec1
norm = 0.0f;
- for(x = 0; x < vec1->size; x++){
+ for( x = 0; x < vec1->size; x++ ) {
norm += vec1->vec[x] * vec1->vec[x];
}
- norm = (float)sqrt(norm);
- for(x = 0; x < vec1->size; x++){
+ norm = ( float ) sqrt( norm );
+ for( x = 0; x < vec1->size; x++ ) {
vec1->vec[x] /= norm;
}
//normalize vec2
norm = 0.0f;
- for(x = 0; x < vec2->size; x++){
+ for( x = 0; x < vec2->size; x++ ) {
norm += vec2->vec[x] * vec2->vec[x];
}
- norm = (float)sqrt(norm);
- for(x = 0; x < vec2->size; x++){
+ norm = ( float ) sqrt( norm );
+ for( x = 0; x < vec2->size; x++ ) {
vec2->vec[x] /= norm;
}
//dot product
- for(x = 0; x < vec1->size; x++){
+ for( x = 0; x < vec1->size; x++ ) {
dot += vec1->vec[x] * vec2->vec[x];
}
//I believe saacos checks to see if the vectors are normalized
- angleRads = saacos(dot);
+ angleRads = saacos( dot );
- return PyFloat_FromDouble((double)(angleRads*(180/Py_PI)));
+ return PyFloat_FromDouble( ( double )
+ ( angleRads * ( 180 / Py_PI ) ) );
}
-static PyObject *M_Mathutils_MidpointVecs(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_MidpointVecs( PyObject * self, PyObject * args )
{
-
- VectorObject * vec1;
- VectorObject * vec2;
- float * vec;
+
+ VectorObject *vec1;
+ VectorObject *vec2;
+ float *vec;
int x;
- if (!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected vector types\n"));
- if(vec1->size != vec2->size)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "vectors must be of the same size\n"));
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected vector types\n" ) );
+ if( vec1->size != vec2->size )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "vectors must be of the same size\n" ) );
- vec = PyMem_Malloc (vec1->size*sizeof (float));
+ vec = PyMem_Malloc( vec1->size * sizeof( float ) );
- for(x = 0; x < vec1->size; x++){
- vec[x]= 0.5f*(vec1->vec[x] + vec2->vec[x]);
+ for( x = 0; x < vec1->size; x++ ) {
+ vec[x] = 0.5f * ( vec1->vec[x] + vec2->vec[x] );
}
- return (PyObject *)newVectorObject(vec, vec1->size);
+ return ( PyObject * ) newVectorObject( vec, vec1->size );
}
//row vector multiplication
-static PyObject *M_Mathutils_VecMultMat(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_VecMultMat( PyObject * self, PyObject * args )
{
- PyObject * ob1 = NULL;
- PyObject * ob2 = NULL;
- MatrixObject * mat;
- VectorObject * vec;
- float * vecNew;
+ PyObject *ob1 = NULL;
+ PyObject *ob2 = NULL;
+ MatrixObject *mat;
+ VectorObject *vec;
+ float *vecNew;
int x, y;
int z = 0;
float dot = 0.0f;
//get pyObjects
- if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &ob1, &matrix_Type, &ob2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "vector and matrix object expected - in that order\n"));
-
- mat = (MatrixObject*)ob2;
- vec = (VectorObject*)ob1;
- if(mat->colSize != vec->size)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "matrix col size and vector size must be the same\n"));
-
- vecNew = PyMem_Malloc (vec->size*sizeof (float));
-
- for(x = 0; x < mat->colSize; x++){
- for(y = 0; y < mat->rowSize; y++){
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &ob1, &matrix_Type, &ob2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "vector and matrix object expected - in that order\n" ) );
+
+ mat = ( MatrixObject * ) ob2;
+ vec = ( VectorObject * ) ob1;
+ if( mat->colSize != vec->size )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "matrix col size and vector size must be the same\n" ) );
+
+ vecNew = PyMem_Malloc( vec->size * sizeof( float ) );
+
+ for( x = 0; x < mat->colSize; x++ ) {
+ for( y = 0; y < mat->rowSize; y++ ) {
dot += mat->matrix[y][x] * vec->vec[y];
}
- vecNew[z] = dot;
- z++; dot = 0;
+ vecNew[z] = dot;
+ z++;
+ dot = 0;
}
- return (PyObject *)newVectorObject(vecNew, vec->size);
+ return ( PyObject * ) newVectorObject( vecNew, vec->size );
}
-static PyObject *M_Mathutils_ProjectVecs(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_ProjectVecs( PyObject * self, PyObject * args )
{
- VectorObject * vec1;
- VectorObject * vec2;
+ VectorObject *vec1;
+ VectorObject *vec2;
float *vec;
float dot = 0.0f;
float dot2 = 0.0f;
int x;
- if (!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected vector types\n"));
- if(vec1->size != vec2->size)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "vectors must be of the same size\n"));
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected vector types\n" ) );
+ if( vec1->size != vec2->size )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "vectors must be of the same size\n" ) );
- vec = PyMem_Malloc (vec1->size * sizeof (float));
+ vec = PyMem_Malloc( vec1->size * sizeof( float ) );
//dot of vec1 & vec2
- for(x = 0; x < vec1->size; x++){
- dot += vec1->vec[x] * vec2->vec[x];
+ for( x = 0; x < vec1->size; x++ ) {
+ dot += vec1->vec[x] * vec2->vec[x];
}
//dot of vec2 & vec2
- for(x = 0; x < vec2->size; x++){
- dot2 += vec2->vec[x] * vec2->vec[x];
+ for( x = 0; x < vec2->size; x++ ) {
+ dot2 += vec2->vec[x] * vec2->vec[x];
}
- dot /= dot2;
- for(x = 0; x < vec1->size; x++){
+ dot /= dot2;
+ for( x = 0; x < vec1->size; x++ ) {
vec[x] = dot * vec2->vec[x];
}
- return (PyObject *)newVectorObject(vec, vec1->size);
+ return ( PyObject * ) newVectorObject( vec, vec1->size );
}
//End Vector Utils
//***************************************************************************
-// Function: M_Mathutils_Matrix
-// Python equivalent: Blender.Mathutils.Matrix
+// Function: M_Mathutils_Matrix // Python equivalent: Blender.Mathutils.Matrix
//***************************************************************************
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-static PyObject *M_Mathutils_Matrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Matrix( PyObject * self, PyObject * args )
{
PyObject *rowA = NULL;
@@ -330,277 +343,307 @@ static PyObject *M_Mathutils_Matrix(PyObject *self, PyObject *args)
PyObject *rowD = NULL;
PyObject *checkOb = NULL;
int x, rowSize, colSize;
- float * mat;
+ float *mat;
int OK;
- if (!PyArg_ParseTuple(args, "|O!O!O!O!", &PyList_Type, &rowA,
- &PyList_Type, &rowB,
- &PyList_Type, &rowC,
- &PyList_Type, &rowD)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 0, 2,3 or 4 lists\n"));
+ if( !PyArg_ParseTuple( args, "|O!O!O!O!", &PyList_Type, &rowA,
+ &PyList_Type, &rowB,
+ &PyList_Type, &rowC, &PyList_Type, &rowD ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 0, 2,3 or 4 lists\n" ) );
}
- if(!rowA)
- return newMatrixObject (NULL, 4, 4);
-
- if(!rowB)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 0, 2,3 or 4 lists\n"));
+ if( !rowA )
+ return newMatrixObject( NULL, 4, 4 );
+
+ if( !rowB )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 0, 2,3 or 4 lists\n" ) );
//get rowSize
- if(rowC){
- if(rowD){
+ if( rowC ) {
+ if( rowD ) {
rowSize = 4;
- }else{
+ } else {
rowSize = 3;
}
- }else{
+ } else {
rowSize = 2;
}
//check size and get colSize
OK = 0;
- if((PyList_Size(rowA) == PyList_Size(rowB))){
- if(rowC){
- if((PyList_Size(rowA) == PyList_Size(rowC))){
- if(rowD){
- if((PyList_Size(rowA) == PyList_Size(rowD))){
+ if( ( PyList_Size( rowA ) == PyList_Size( rowB ) ) ) {
+ if( rowC ) {
+ if( ( PyList_Size( rowA ) == PyList_Size( rowC ) ) ) {
+ if( rowD ) {
+ if( ( PyList_Size( rowA ) ==
+ PyList_Size( rowD ) ) ) {
OK = 1;
}
- } OK = 1;
+ }
+ OK = 1;
}
- }else OK = 1;
+ } else
+ OK = 1;
}
- if(!OK) return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "each row of vector must contain the same number of parameters\n");
- colSize = PyList_Size(rowA);
+ if( !OK )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "each row of vector must contain the same number of parameters\n" );
+ colSize = PyList_Size( rowA );
//check for numeric types
- for (x = 0; x < colSize; x++) {
- checkOb = PyList_GetItem(rowA, x);
- if(!PyInt_Check(checkOb) && !PyFloat_Check(checkOb))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "1st list - expected list of numbers\n"));
- checkOb = PyList_GetItem(rowB, x);
- if(!PyInt_Check(checkOb) && !PyFloat_Check(checkOb))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "2nd list - expected list of numbers\n"));
- if(rowC){
- checkOb = PyList_GetItem(rowC, x);
- if(!PyInt_Check(checkOb) && !PyFloat_Check(checkOb))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "3rd list - expected list of numbers\n"));
+ for( x = 0; x < colSize; x++ ) {
+ checkOb = PyList_GetItem( rowA, x );
+ if( !PyInt_Check( checkOb ) && !PyFloat_Check( checkOb ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "1st list - expected list of numbers\n" ) );
+ checkOb = PyList_GetItem( rowB, x );
+ if( !PyInt_Check( checkOb ) && !PyFloat_Check( checkOb ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "2nd list - expected list of numbers\n" ) );
+ if( rowC ) {
+ checkOb = PyList_GetItem( rowC, x );
+ if( !PyInt_Check( checkOb )
+ && !PyFloat_Check( checkOb ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "3rd list - expected list of numbers\n" ) );
}
- if(rowD){
- checkOb = PyList_GetItem(rowD, x);
- if(!PyInt_Check(checkOb) && !PyFloat_Check(checkOb))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "4th list - expected list of numbers\n"));
+ if( rowD ) {
+ checkOb = PyList_GetItem( rowD, x );
+ if( !PyInt_Check( checkOb )
+ && !PyFloat_Check( checkOb ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "4th list - expected list of numbers\n" ) );
}
}
//allocate space for 1D array
- mat = PyMem_Malloc (rowSize * colSize * sizeof (float));
+ mat = PyMem_Malloc( rowSize * colSize * sizeof( float ) );
//parse rows
- for (x = 0; x < colSize; x++) {
- if (!PyArg_Parse(PyList_GetItem(rowA, x), "f", &mat[x]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "rowA - python list not parseable\n");
+ for( x = 0; x < colSize; x++ ) {
+ if( !PyArg_Parse( PyList_GetItem( rowA, x ), "f", &mat[x] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "rowA - python list not parseable\n" );
}
- for (x = 0; x < colSize; x++) {
- if (!PyArg_Parse(PyList_GetItem(rowB, x), "f", &mat[(colSize + x)]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "rowB - python list not parseable\n");
+ for( x = 0; x < colSize; x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( rowB, x ), "f", &mat[( colSize + x )] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "rowB - python list not parseable\n" );
}
- if(rowC){
- for (x = 0; x < colSize; x++) {
- if (!PyArg_Parse(PyList_GetItem(rowC, x), "f", &mat[((2*colSize) + x)]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "rowC - python list not parseable\n");
+ if( rowC ) {
+ for( x = 0; x < colSize; x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( rowC, x ), "f",
+ &mat[( ( 2 * colSize ) + x )] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "rowC - python list not parseable\n" );
}
}
- if(rowD){
- for (x = 0; x < colSize; x++) {
- if (!PyArg_Parse(PyList_GetItem(rowD, x), "f", &mat[((3*colSize) + x)]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "rowD - python list not parseable\n");
+ if( rowD ) {
+ for( x = 0; x < colSize; x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( rowD, x ), "f",
+ &mat[( ( 3 * colSize ) + x )] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "rowD - python list not parseable\n" );
}
}
-
//pass to matrix creation
- return newMatrixObject (mat, rowSize, colSize);
+ return newMatrixObject( mat, rowSize, colSize );
}
//***************************************************************************
-// Function: M_Mathutils_RotationMatrix
-// Python equivalent: Blender.Mathutils.RotationMatrix
+// Function: M_Mathutils_RotationMatrix
+// Python equivalent: Blender.Mathutils.RotationMatrix
//***************************************************************************
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-static PyObject *M_Mathutils_RotationMatrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_RotationMatrix( PyObject * self, PyObject * args )
{
float *mat;
float angle = 0.0f;
char *axis = NULL;
- VectorObject * vec = NULL;
+ VectorObject *vec = NULL;
int matSize;
float norm = 0.0f;
float cosAngle = 0.0f;
float sinAngle = 0.0f;
- if (!PyArg_ParseTuple(args, "fi|sO!", &angle, &matSize, &axis, &vector_Type, &vec)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float int and optional string and vector\n"));
+ if( !PyArg_ParseTuple
+ ( args, "fi|sO!", &angle, &matSize, &axis, &vector_Type, &vec ) ) {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected float int and optional string and vector\n" ) );
}
- if(angle < -360.0f || angle > 360.0f)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "angle size not appropriate\n");
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "can only return a 2x2 3x3 or 4x4 matrix\n");
- if(matSize == 2 && (axis != NULL || vec != NULL))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "cannot create a 2x2 rotation matrix around arbitrary axis\n");
- if((matSize == 3 || matSize == 4) && axis == NULL)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "please choose an axis of rotation\n");
- if(axis){
- if(((strcmp (axis, "r") == 0) ||
- (strcmp (axis, "R") == 0)) && vec == NULL)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "please define the arbitrary axis of rotation\n");
+ if( angle < -360.0f || angle > 360.0f )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "angle size not appropriate\n" );
+ if( matSize != 2 && matSize != 3 && matSize != 4 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "can only return a 2x2 3x3 or 4x4 matrix\n" );
+ if( matSize == 2 && ( axis != NULL || vec != NULL ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "cannot create a 2x2 rotation matrix around arbitrary axis\n" );
+ if( ( matSize == 3 || matSize == 4 ) && axis == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "please choose an axis of rotation\n" );
+ if( axis ) {
+ if( ( ( strcmp( axis, "r" ) == 0 ) ||
+ ( strcmp( axis, "R" ) == 0 ) ) && vec == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "please define the arbitrary axis of rotation\n" );
}
- if(vec){
- if(vec->size != 3)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "the arbitrary axis must be a 3D vector\n");
+ if( vec ) {
+ if( vec->size != 3 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "the arbitrary axis must be a 3D vector\n" );
}
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
//convert to radians
- angle = angle * (float)(Py_PI/180);
+ angle = angle * ( float ) ( Py_PI / 180 );
- if(axis == NULL && matSize == 2){
+ if( axis == NULL && matSize == 2 ) {
//2D rotation matrix
- mat[0] = ((float)cos((double)(angle)));
- mat[1] = ((float)sin((double)(angle)));
- mat[2] = (-((float)sin((double)(angle))));
- mat[3] = ((float)cos((double)(angle)));
- }else if((strcmp(axis,"x") == 0) ||
- (strcmp(axis,"X") == 0)){
+ mat[0] = ( ( float ) cos( ( double ) ( angle ) ) );
+ mat[1] = ( ( float ) sin( ( double ) ( angle ) ) );
+ mat[2] = ( -( ( float ) sin( ( double ) ( angle ) ) ) );
+ mat[3] = ( ( float ) cos( ( double ) ( angle ) ) );
+ } else if( ( strcmp( axis, "x" ) == 0 ) ||
+ ( strcmp( axis, "X" ) == 0 ) ) {
//rotation around X
- mat[0] = 1.0f; mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
- mat[4] = ((float)cos((double)(angle)));
- mat[5] = ((float)sin((double)(angle)));
+ mat[0] = 1.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
+ mat[4] = ( ( float ) cos( ( double ) ( angle ) ) );
+ mat[5] = ( ( float ) sin( ( double ) ( angle ) ) );
mat[6] = 0.0f;
- mat[7] = (-((float)sin((double)(angle))));
- mat[8] = ((float)cos((double)(angle)));
- }else if ((strcmp(axis,"y") == 0) ||
- (strcmp(axis,"Y") == 0)){
+ mat[7] = ( -( ( float ) sin( ( double ) ( angle ) ) ) );
+ mat[8] = ( ( float ) cos( ( double ) ( angle ) ) );
+ } else if( ( strcmp( axis, "y" ) == 0 ) ||
+ ( strcmp( axis, "Y" ) == 0 ) ) {
//rotation around Y
- mat[0] = ((float)cos((double)(angle)));
+ mat[0] = ( ( float ) cos( ( double ) ( angle ) ) );
mat[1] = 0.0f;
- mat[2] = (-((float)sin((double)(angle))));
- mat[3] = 0.0f; mat[4] = 1.0f; mat[5] = 0.0f;
- mat[6] = ((float)sin((double)(angle)));
+ mat[2] = ( -( ( float ) sin( ( double ) ( angle ) ) ) );
+ mat[3] = 0.0f;
+ mat[4] = 1.0f;
+ mat[5] = 0.0f;
+ mat[6] = ( ( float ) sin( ( double ) ( angle ) ) );
mat[7] = 0.0f;
- mat[8] = ((float)cos((double)(angle)));
- }else if ((strcmp(axis,"z") == 0) ||
- (strcmp(axis,"Z") == 0)){
+ mat[8] = ( ( float ) cos( ( double ) ( angle ) ) );
+ } else if( ( strcmp( axis, "z" ) == 0 ) ||
+ ( strcmp( axis, "Z" ) == 0 ) ) {
//rotation around Z
- mat[0] = ((float)cos((double)(angle)));
- mat[1] = ((float)sin((double)(angle)));
+ mat[0] = ( ( float ) cos( ( double ) ( angle ) ) );
+ mat[1] = ( ( float ) sin( ( double ) ( angle ) ) );
mat[2] = 0.0f;
- mat[3] = (-((float)sin((double)(angle))));
- mat[4] = ((float)cos((double)(angle)));
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f; mat[8] = 1.0f;
- }else if ((strcmp(axis,"r") == 0) ||
- (strcmp(axis,"R") == 0)){
+ mat[3] = ( -( ( float ) sin( ( double ) ( angle ) ) ) );
+ mat[4] = ( ( float ) cos( ( double ) ( angle ) ) );
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
+ mat[8] = 1.0f;
+ } else if( ( strcmp( axis, "r" ) == 0 ) ||
+ ( strcmp( axis, "R" ) == 0 ) ) {
//arbitrary rotation
//normalize arbitrary axis
- norm = (float)sqrt(vec->vec[0] * vec->vec[0] + vec->vec[1] * vec->vec[1] +
- vec->vec[2] * vec->vec[2]);
- vec->vec[0] /= norm; vec->vec[1] /= norm; vec->vec[2] /= norm;
+ norm = ( float ) sqrt( vec->vec[0] * vec->vec[0] +
+ vec->vec[1] * vec->vec[1] +
+ vec->vec[2] * vec->vec[2] );
+ vec->vec[0] /= norm;
+ vec->vec[1] /= norm;
+ vec->vec[2] /= norm;
//create matrix
- cosAngle = ((float)cos((double)(angle)));
- sinAngle = ((float)sin((double)(angle)));
- mat[0] = ((vec->vec[0] * vec->vec[0]) * (1 - cosAngle)) +
- cosAngle;
- mat[1] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) +
- (vec->vec[2] * sinAngle);
- mat[2] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) -
- (vec->vec[1] * sinAngle);
- mat[3] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) -
- (vec->vec[2] * sinAngle);
- mat[4] = ((vec->vec[1] * vec->vec[1]) * (1 - cosAngle)) +
- cosAngle;
- mat[5] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) +
- (vec->vec[0] * sinAngle);
- mat[6] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) +
- (vec->vec[1] * sinAngle);
- mat[7] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) -
- (vec->vec[0] * sinAngle);
- mat[8] = ((vec->vec[2] * vec->vec[2]) * (1 - cosAngle)) +
- cosAngle;
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "unrecognizable axis of rotation type - expected x,y,z or r\n");
+ cosAngle = ( ( float ) cos( ( double ) ( angle ) ) );
+ sinAngle = ( ( float ) sin( ( double ) ( angle ) ) );
+ mat[0] = ( ( vec->vec[0] * vec->vec[0] ) * ( 1 - cosAngle ) ) +
+ cosAngle;
+ mat[1] = ( ( vec->vec[0] * vec->vec[1] ) * ( 1 - cosAngle ) ) +
+ ( vec->vec[2] * sinAngle );
+ mat[2] = ( ( vec->vec[0] * vec->vec[2] ) * ( 1 - cosAngle ) ) -
+ ( vec->vec[1] * sinAngle );
+ mat[3] = ( ( vec->vec[0] * vec->vec[1] ) * ( 1 - cosAngle ) ) -
+ ( vec->vec[2] * sinAngle );
+ mat[4] = ( ( vec->vec[1] * vec->vec[1] ) * ( 1 - cosAngle ) ) +
+ cosAngle;
+ mat[5] = ( ( vec->vec[1] * vec->vec[2] ) * ( 1 - cosAngle ) ) +
+ ( vec->vec[0] * sinAngle );
+ mat[6] = ( ( vec->vec[0] * vec->vec[2] ) * ( 1 - cosAngle ) ) +
+ ( vec->vec[1] * sinAngle );
+ mat[7] = ( ( vec->vec[1] * vec->vec[2] ) * ( 1 - cosAngle ) ) -
+ ( vec->vec[0] * sinAngle );
+ mat[8] = ( ( vec->vec[2] * vec->vec[2] ) * ( 1 - cosAngle ) ) +
+ cosAngle;
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unrecognizable axis of rotation type - expected x,y,z or r\n" );
}
- if(matSize == 4){
+ if( matSize == 4 ) {
//resize matrix
- mat[15] = 1.0f; mat[14] = 0.0f;
- mat[13] = 0.0f; mat[12] = 0.0f;
- mat[11] = 0.0f; mat[10] = mat[8];
- mat[9] = mat[7]; mat[8] = mat[6];
- mat[7] = 0.0f; mat[6] = mat[5];
- mat[5] = mat[4];mat[4] = mat[3];
+ mat[15] = 1.0f;
+ mat[14] = 0.0f;
+ mat[13] = 0.0f;
+ mat[12] = 0.0f;
+ mat[11] = 0.0f;
+ mat[10] = mat[8];
+ mat[9] = mat[7];
+ mat[8] = mat[6];
+ mat[7] = 0.0f;
+ mat[6] = mat[5];
+ mat[5] = mat[4];
+ mat[4] = mat[3];
mat[3] = 0.0f;
}
-
//pass to matrix creation
- return newMatrixObject (mat, matSize, matSize);
+ return newMatrixObject( mat, matSize, matSize );
}
//***************************************************************************
-// Function: M_Mathutils_TranslationMatrix
-// Python equivalent: Blender.Mathutils.TranslationMatrix
+// Function: M_Mathutils_TranslationMatrix
+// Python equivalent: Blender.Mathutils.TranslationMatrix
//***************************************************************************
-static PyObject *M_Mathutils_TranslationMatrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_TranslationMatrix( PyObject * self,
+ PyObject * args )
{
VectorObject *vec;
float *mat;
- if (!PyArg_ParseTuple(args, "O!", &vector_Type, &vec)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected vector\n"));
+ if( !PyArg_ParseTuple( args, "O!", &vector_Type, &vec ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected vector\n" ) );
}
- if(vec->size != 3 && vec->size != 4){
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "vector must be 3D or 4D\n");
+ if( vec->size != 3 && vec->size != 4 ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "vector must be 3D or 4D\n" );
}
- mat = PyMem_Malloc(4*4*sizeof(float));
- Mat4One((float(*)[4])mat);
+ mat = PyMem_Malloc( 4 * 4 * sizeof( float ) );
+ Mat4One( ( float ( * )[4] ) mat );
mat[12] = vec->vec[0];
mat[13] = vec->vec[1];
mat[14] = vec->vec[2];
- return newMatrixObject(mat, 4,4);
+ return newMatrixObject( mat, 4, 4 );
}
//***************************************************************************
-// Function: M_Mathutils_ScaleMatrix
-// Python equivalent: Blender.Mathutils.ScaleMatrix
+// Function: M_Mathutils_ScaleMatrix
+// Python equivalent: Blender.Mathutils.ScaleMatrix
//***************************************************************************
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-static PyObject *M_Mathutils_ScaleMatrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_ScaleMatrix( PyObject * self, PyObject * args )
{
float factor;
int matSize;
@@ -609,79 +652,111 @@ static PyObject *M_Mathutils_ScaleMatrix(PyObject *self, PyObject *args)
float norm = 0.0f;
int x;
- if (!PyArg_ParseTuple(args, "fi|O!", &factor, &matSize, &vector_Type, &vec)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float int and optional vector\n"));
+ if( !PyArg_ParseTuple
+ ( args, "fi|O!", &factor, &matSize, &vector_Type, &vec ) ) {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected float int and optional vector\n" ) );
}
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "can only return a 2x2 3x3 or 4x4 matrix\n");
- if(vec){
- if(vec->size > 2 && matSize == 2)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "please use 2D vectors when scaling in 2D\n");
+ if( matSize != 2 && matSize != 3 && matSize != 4 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "can only return a 2x2 3x3 or 4x4 matrix\n" );
+ if( vec ) {
+ if( vec->size > 2 && matSize == 2 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "please use 2D vectors when scaling in 2D\n" );
}
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
- if(vec == NULL){ //scaling along axis
- if(matSize == 2){
+ if( vec == NULL ) { //scaling along axis
+ if( matSize == 2 ) {
mat[0] = factor;
- mat[1] = 0.0f; mat[2] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
mat[3] = factor;
- }else {
+ } else {
mat[0] = factor;
- mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
mat[4] = factor;
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f;
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
mat[8] = factor;
}
- }else{ //scaling in arbitrary direction
+ } else { //scaling in arbitrary direction
//normalize arbitrary axis
- for(x = 0; x < vec->size; x++){
+ for( x = 0; x < vec->size; x++ ) {
norm += vec->vec[x] * vec->vec[x];
}
- norm = (float)sqrt(norm);
- for(x = 0; x < vec->size; x++){
+ norm = ( float ) sqrt( norm );
+ for( x = 0; x < vec->size; x++ ) {
vec->vec[x] /= norm;
}
- if(matSize ==2){
- mat[0] = 1 + ((factor - 1) * (vec->vec[0] * vec->vec[0]));
- mat[1] = ((factor - 1) * (vec->vec[0] * vec->vec[1]));
- mat[2] = ((factor - 1) * (vec->vec[0] * vec->vec[1]));
- mat[3] = 1 + ((factor - 1) * (vec->vec[1] * vec->vec[1]));
- }else{
- mat[0] = 1 + ((factor - 1) * (vec->vec[0] * vec->vec[0]));
- mat[1] = ((factor - 1) * (vec->vec[0] * vec->vec[1]));
- mat[2] = ((factor - 1) * (vec->vec[0] * vec->vec[2]));
- mat[3] = ((factor - 1) * (vec->vec[0] * vec->vec[1]));
- mat[4] = 1 + ((factor - 1) * (vec->vec[1] * vec->vec[1]));
- mat[5] = ((factor - 1) * (vec->vec[1] * vec->vec[2]));
- mat[6] = ((factor - 1) * (vec->vec[0] * vec->vec[2]));
- mat[7] = ((factor - 1) * (vec->vec[1] * vec->vec[2]));
- mat[8] = 1 + ((factor - 1) * (vec->vec[2] * vec->vec[2]));
+ if( matSize == 2 ) {
+ mat[0] = 1 +
+ ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[0] ) );
+ mat[1] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[1] ) );
+ mat[2] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[1] ) );
+ mat[3] = 1 +
+ ( ( factor -
+ 1 ) * ( vec->vec[1] * vec->vec[1] ) );
+ } else {
+ mat[0] = 1 +
+ ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[0] ) );
+ mat[1] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[1] ) );
+ mat[2] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[2] ) );
+ mat[3] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[1] ) );
+ mat[4] = 1 +
+ ( ( factor -
+ 1 ) * ( vec->vec[1] * vec->vec[1] ) );
+ mat[5] = ( ( factor -
+ 1 ) * ( vec->vec[1] * vec->vec[2] ) );
+ mat[6] = ( ( factor -
+ 1 ) * ( vec->vec[0] * vec->vec[2] ) );
+ mat[7] = ( ( factor -
+ 1 ) * ( vec->vec[1] * vec->vec[2] ) );
+ mat[8] = 1 +
+ ( ( factor -
+ 1 ) * ( vec->vec[2] * vec->vec[2] ) );
}
}
- if(matSize == 4){
+ if( matSize == 4 ) {
//resize matrix
- mat[15] = 1.0f; mat[14] = 0.0f; mat[13] = 0.0f;
- mat[12] = 0.0f; mat[11] = 0.0f;
- mat[10] = mat[8]; mat[9] = mat[7];
- mat[8] = mat[6]; mat[7] = 0.0f;
- mat[6] = mat[5]; mat[5] = mat[4];
- mat[4] = mat[3]; mat[3] = 0.0f;
+ mat[15] = 1.0f;
+ mat[14] = 0.0f;
+ mat[13] = 0.0f;
+ mat[12] = 0.0f;
+ mat[11] = 0.0f;
+ mat[10] = mat[8];
+ mat[9] = mat[7];
+ mat[8] = mat[6];
+ mat[7] = 0.0f;
+ mat[6] = mat[5];
+ mat[5] = mat[4];
+ mat[4] = mat[3];
+ mat[3] = 0.0f;
}
-
//pass to matrix creation
- return newMatrixObject (mat, matSize, matSize);
+ return newMatrixObject( mat, matSize, matSize );
}
//***************************************************************************
-// Function: M_Mathutils_OrthoProjectionMatrix
-// Python equivalent: Blender.Mathutils.OrthoProjectionMatrix
+// Function: M_Mathutils_OrthoProjectionMatrix
+// Python equivalent: Blender.Mathutils.OrthoProjectionMatrix
//***************************************************************************
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
-static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_OrthoProjectionMatrix( PyObject * self,
+ PyObject * args )
{
char *plane;
int matSize;
@@ -690,227 +765,295 @@ static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject *self, PyObject *arg
float norm = 0.0f;
int x;
- if (!PyArg_ParseTuple(args, "si|O!", &plane, &matSize, &vector_Type, &vec)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string and int and optional vector\n"));
+ if( !PyArg_ParseTuple
+ ( args, "si|O!", &plane, &matSize, &vector_Type, &vec ) ) {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected string and int and optional vector\n" ) );
}
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "can only return a 2x2 3x3 or 4x4 matrix\n");
- if(vec){
- if(vec->size > 2 && matSize == 2)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "please use 2D vectors when scaling in 2D\n");
+ if( matSize != 2 && matSize != 3 && matSize != 4 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "can only return a 2x2 3x3 or 4x4 matrix\n" );
+ if( vec ) {
+ if( vec->size > 2 && matSize == 2 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "please use 2D vectors when scaling in 2D\n" );
}
- if(vec == NULL){ //ortho projection onto cardinal plane
- if (((strcmp(plane, "x") == 0) || (strcmp(plane, "X") == 0)) &&
- matSize == 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
+ if( vec == NULL ) { //ortho projection onto cardinal plane
+ if( ( ( strcmp( plane, "x" ) == 0 )
+ || ( strcmp( plane, "X" ) == 0 ) ) && matSize == 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
mat[0] = 1.0f;
- mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
- }else if(((strcmp(plane, "y") == 0) || (strcmp(plane, "Y") == 0)) &&
- matSize == 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 0.0f; mat[1] = 0.0f; mat[2] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
+ } else if( ( ( strcmp( plane, "y" ) == 0 )
+ || ( strcmp( plane, "Y" ) == 0 ) )
+ && matSize == 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
+ mat[0] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
mat[3] = 1.0f;
- }else if(((strcmp(plane, "xy") == 0) || (strcmp(plane, "XY") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
+ } else if( ( ( strcmp( plane, "xy" ) == 0 )
+ || ( strcmp( plane, "XY" ) == 0 ) )
+ && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
mat[0] = 1.0f;
- mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
mat[4] = 1.0f;
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f; mat[8] = 0.0f;
- }else if(((strcmp(plane, "xz") == 0) || (strcmp(plane, "XZ") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
+ mat[8] = 0.0f;
+ } else if( ( ( strcmp( plane, "xz" ) == 0 )
+ || ( strcmp( plane, "XZ" ) == 0 ) )
+ && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
mat[0] = 1.0f;
- mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f; mat[4] = 0.0f;
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
+ mat[4] = 0.0f;
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
mat[8] = 1.0f;
- }else if(((strcmp(plane, "yz") == 0) || (strcmp(plane, "YZ") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 0.0f; mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
+ } else if( ( ( strcmp( plane, "yz" ) == 0 )
+ || ( strcmp( plane, "YZ" ) == 0 ) )
+ && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
+ mat[0] = 0.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
mat[4] = 1.0f;
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f;
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
mat[8] = 1.0f;
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "unknown plane - expected: x, y, xy, xz, yz\n");
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown plane - expected: x, y, xy, xz, yz\n" );
}
- }else{ //arbitrary plane
+ } else { //arbitrary plane
//normalize arbitrary axis
- for(x = 0; x < vec->size; x++){
+ for( x = 0; x < vec->size; x++ ) {
norm += vec->vec[x] * vec->vec[x];
}
- norm = (float)sqrt(norm);
+ norm = ( float ) sqrt( norm );
- for(x = 0; x < vec->size; x++){
+ for( x = 0; x < vec->size; x++ ) {
vec->vec[x] /= norm;
}
- if (((strcmp(plane, "r") == 0) || (strcmp(plane, "R") == 0)) &&
- matSize == 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
- mat[1] = - (vec->vec[0] * vec->vec[1]);
- mat[2] = - (vec->vec[0] * vec->vec[1]);
- mat[3] = 1 - (vec->vec[1] * vec->vec[1]);
- }else if (((strcmp(plane, "r") == 0) || (strcmp(plane, "R") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1 - (vec->vec[0] * vec->vec[0]);
- mat[1] = - (vec->vec[0] * vec->vec[1]);
- mat[2] = - (vec->vec[0] * vec->vec[2]);
- mat[3] = - (vec->vec[0] * vec->vec[1]);
- mat[4] = 1 - (vec->vec[1] * vec->vec[1]);
- mat[5] = - (vec->vec[1] * vec->vec[2]);
- mat[6] = - (vec->vec[0] * vec->vec[2]);
- mat[7] = - (vec->vec[1] * vec->vec[2]);
- mat[8] = 1 - (vec->vec[2] * vec->vec[2]);
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "unknown plane - expected: 'r' expected for axis designation\n");
+ if( ( ( strcmp( plane, "r" ) == 0 )
+ || ( strcmp( plane, "R" ) == 0 ) ) && matSize == 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
+ mat[0] = 1 - ( vec->vec[0] * vec->vec[0] );
+ mat[1] = -( vec->vec[0] * vec->vec[1] );
+ mat[2] = -( vec->vec[0] * vec->vec[1] );
+ mat[3] = 1 - ( vec->vec[1] * vec->vec[1] );
+ } else if( ( ( strcmp( plane, "r" ) == 0 )
+ || ( strcmp( plane, "R" ) == 0 ) )
+ && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize *
+ sizeof( float ) );
+ mat[0] = 1 - ( vec->vec[0] * vec->vec[0] );
+ mat[1] = -( vec->vec[0] * vec->vec[1] );
+ mat[2] = -( vec->vec[0] * vec->vec[2] );
+ mat[3] = -( vec->vec[0] * vec->vec[1] );
+ mat[4] = 1 - ( vec->vec[1] * vec->vec[1] );
+ mat[5] = -( vec->vec[1] * vec->vec[2] );
+ mat[6] = -( vec->vec[0] * vec->vec[2] );
+ mat[7] = -( vec->vec[1] * vec->vec[2] );
+ mat[8] = 1 - ( vec->vec[2] * vec->vec[2] );
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown plane - expected: 'r' expected for axis designation\n" );
}
}
- if(matSize == 4){
+ if( matSize == 4 ) {
//resize matrix
- mat[15] = 1.0f; mat[14] = 0.0f;
- mat[13] = 0.0f; mat[12] = 0.0f;
- mat[11] = 0.0f; mat[10] = mat[8];
- mat[9] = mat[7];mat[8] = mat[6];
- mat[7] = 0.0f; mat[6] = mat[5];
- mat[5] = mat[4];mat[4] = mat[3];
+ mat[15] = 1.0f;
+ mat[14] = 0.0f;
+ mat[13] = 0.0f;
+ mat[12] = 0.0f;
+ mat[11] = 0.0f;
+ mat[10] = mat[8];
+ mat[9] = mat[7];
+ mat[8] = mat[6];
+ mat[7] = 0.0f;
+ mat[6] = mat[5];
+ mat[5] = mat[4];
+ mat[4] = mat[3];
mat[3] = 0.0f;
}
-
//pass to matrix creation
- return newMatrixObject (mat, matSize, matSize);
+ return newMatrixObject( mat, matSize, matSize );
}
//***************************************************************************
-// Function: M_Mathutils_ShearMatrix
-// Python equivalent: Blender.Mathutils.ShearMatrix
+// Function: M_Mathutils_ShearMatrix
+// Python equivalent: Blender.Mathutils.ShearMatrix
//***************************************************************************
-static PyObject *M_Mathutils_ShearMatrix(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_ShearMatrix( PyObject * self, PyObject * args )
{
float factor;
int matSize;
char *plane;
float *mat;
- if (!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)){
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string float and int\n"));
+ if( !PyArg_ParseTuple( args, "sfi", &plane, &factor, &matSize ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string float and int\n" ) );
}
- if(matSize != 2 && matSize != 3 && matSize != 4)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "can only return a 2x2 3x3 or 4x4 matrix\n");
-
- if (((strcmp(plane, "x") == 0) || (strcmp(plane, "X") == 0)) &&
- matSize == 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1.0f; mat[1] = 0.0f;
- mat[2] = factor; mat[3] = 1.0f;
- }else if(((strcmp(plane, "y") == 0) || (strcmp(plane, "Y") == 0)) &&
- matSize == 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1.0f; mat[1] = factor;
- mat[2] = 0.0f; mat[3] = 1.0f;
- }else if(((strcmp(plane, "xy") == 0) || (strcmp(plane, "XY") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1.0f; mat[1] = 0.0f; mat[2] = 0.0f; mat[3] = 0.0f;
- mat[4] = 1.0f; mat[5] = 0.0f;
- mat[6] = factor; mat[7] = factor; mat[8] = 0.0f;
- }else if(((strcmp(plane, "xz") == 0) || (strcmp(plane, "XZ") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1.0f; mat[1] = 0.0f; mat[2] = 0.0f;
- mat[3] = factor; mat[4] = 1.0f; mat[5] = factor;
- mat[6] = 0.0f; mat[7] = 0.0f; mat[8] = 1.0f;
- }else if(((strcmp(plane, "yz") == 0) || (strcmp(plane, "YZ") == 0)) &&
- matSize > 2){
- mat = PyMem_Malloc(matSize * matSize * sizeof(float));
- mat[0] = 1.0f; mat[1] = factor; mat[2] = factor;
- mat[3] = 0.0f; mat[4] = 1.0f;
- mat[5] = 0.0f; mat[6] = 0.0f; mat[7] = 0.0f;
+ if( matSize != 2 && matSize != 3 && matSize != 4 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "can only return a 2x2 3x3 or 4x4 matrix\n" );
+
+ if( ( ( strcmp( plane, "x" ) == 0 ) || ( strcmp( plane, "X" ) == 0 ) )
+ && matSize == 2 ) {
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
+ mat[0] = 1.0f;
+ mat[1] = 0.0f;
+ mat[2] = factor;
+ mat[3] = 1.0f;
+ } else if( ( ( strcmp( plane, "y" ) == 0 )
+ || ( strcmp( plane, "Y" ) == 0 ) ) && matSize == 2 ) {
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
+ mat[0] = 1.0f;
+ mat[1] = factor;
+ mat[2] = 0.0f;
+ mat[3] = 1.0f;
+ } else if( ( ( strcmp( plane, "xy" ) == 0 )
+ || ( strcmp( plane, "XY" ) == 0 ) ) && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
+ mat[0] = 1.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = 0.0f;
+ mat[4] = 1.0f;
+ mat[5] = 0.0f;
+ mat[6] = factor;
+ mat[7] = factor;
+ mat[8] = 0.0f;
+ } else if( ( ( strcmp( plane, "xz" ) == 0 )
+ || ( strcmp( plane, "XZ" ) == 0 ) ) && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
+ mat[0] = 1.0f;
+ mat[1] = 0.0f;
+ mat[2] = 0.0f;
+ mat[3] = factor;
+ mat[4] = 1.0f;
+ mat[5] = factor;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
+ mat[8] = 1.0f;
+ } else if( ( ( strcmp( plane, "yz" ) == 0 )
+ || ( strcmp( plane, "YZ" ) == 0 ) ) && matSize > 2 ) {
+ mat = PyMem_Malloc( matSize * matSize * sizeof( float ) );
+ mat[0] = 1.0f;
+ mat[1] = factor;
+ mat[2] = factor;
+ mat[3] = 0.0f;
+ mat[4] = 1.0f;
+ mat[5] = 0.0f;
+ mat[6] = 0.0f;
+ mat[7] = 0.0f;
mat[8] = 1.0f;
- }else{
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n");
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n" );
}
- if(matSize == 4){
+ if( matSize == 4 ) {
//resize matrix
- mat[15] = 1.0f; mat[14] = 0.0f;
- mat[13] = 0.0f; mat[12] = 0.0f;
- mat[11] = 0.0f; mat[10] = mat[8];
- mat[9] = mat[7];mat[8] = mat[6];
- mat[7] = 0.0f; mat[6] = mat[5];
- mat[5] = mat[4];mat[4] = mat[3];
+ mat[15] = 1.0f;
+ mat[14] = 0.0f;
+ mat[13] = 0.0f;
+ mat[12] = 0.0f;
+ mat[11] = 0.0f;
+ mat[10] = mat[8];
+ mat[9] = mat[7];
+ mat[8] = mat[6];
+ mat[7] = 0.0f;
+ mat[6] = mat[5];
+ mat[5] = mat[4];
+ mat[4] = mat[3];
mat[3] = 0.0f;
}
-
//pass to matrix creation
- return newMatrixObject (mat, matSize, matSize);
+ return newMatrixObject( mat, matSize, matSize );
}
//***************************************************************************
//Begin Matrix Utils
-static PyObject *M_Mathutils_CopyMat(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CopyMat( PyObject * self, PyObject * args )
{
MatrixObject *matrix;
float *mat;
- int x,y,z;
+ int x, y, z;
- if(!PyArg_ParseTuple(args, "O!", &matrix_Type, &matrix))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected matrix\n"));
+ if( !PyArg_ParseTuple( args, "O!", &matrix_Type, &matrix ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected matrix\n" ) );
- mat = PyMem_Malloc(matrix->rowSize * matrix->colSize * sizeof(float));
+ mat = PyMem_Malloc( matrix->rowSize * matrix->colSize *
+ sizeof( float ) );
z = 0;
- for(x = 0; x < matrix->rowSize; x++){
- for(y = 0; y < matrix->colSize; y++){
+ for( x = 0; x < matrix->rowSize; x++ ) {
+ for( y = 0; y < matrix->colSize; y++ ) {
mat[z] = matrix->matrix[x][y];
z++;
}
}
- return (PyObject*)newMatrixObject (mat, matrix->rowSize, matrix->colSize);
+ return ( PyObject * ) newMatrixObject( mat, matrix->rowSize,
+ matrix->colSize );
}
-static PyObject *M_Mathutils_MatMultVec(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_MatMultVec( PyObject * self, PyObject * args )
{
- PyObject * ob1 = NULL;
- PyObject * ob2 = NULL;
- MatrixObject * mat;
- VectorObject * vec;
- float * vecNew;
+ PyObject *ob1 = NULL;
+ PyObject *ob2 = NULL;
+ MatrixObject *mat;
+ VectorObject *vec;
+ float *vecNew;
int x, y;
int z = 0;
float dot = 0.0f;
//get pyObjects
- if(!PyArg_ParseTuple(args, "O!O!", &matrix_Type, &ob1, &vector_Type, &ob2))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "matrix and vector object expected - in that order\n"));
+ if( !PyArg_ParseTuple
+ ( args, "O!O!", &matrix_Type, &ob1, &vector_Type, &ob2 ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "matrix and vector object expected - in that order\n" ) );
+
+ mat = ( MatrixObject * ) ob1;
+ vec = ( VectorObject * ) ob2;
- mat = (MatrixObject*)ob1;
- vec = (VectorObject*)ob2;
+ if( mat->rowSize != vec->size )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "matrix row size and vector size must be the same\n" ) );
- if(mat->rowSize != vec->size)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "matrix row size and vector size must be the same\n"));
+ vecNew = PyMem_Malloc( vec->size * sizeof( float ) );
- vecNew = PyMem_Malloc (vec->size*sizeof (float));
-
- for(x = 0; x < mat->rowSize; x++){
- for(y = 0; y < mat->colSize; y++){
+ for( x = 0; x < mat->rowSize; x++ ) {
+ for( y = 0; y < mat->colSize; y++ ) {
dot += mat->matrix[x][y] * vec->vec[y];
}
vecNew[z] = dot;
@@ -918,14 +1061,14 @@ static PyObject *M_Mathutils_MatMultVec(PyObject *self, PyObject *args)
dot = 0;
}
- return (PyObject *)newVectorObject(vecNew, vec->size);
+ return ( PyObject * ) newVectorObject( vecNew, vec->size );
}
//***************************************************************************
-// Function: M_Mathutils_Quaternion
-// Python equivalent: Blender.Mathutils.Quaternion
+// Function: M_Mathutils_Quaternion
+// Python equivalent: Blender.Mathutils.Quaternion
//***************************************************************************
-static PyObject *M_Mathutils_Quaternion(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Quaternion( PyObject * self, PyObject * args )
{
PyObject *listObject;
float *vec;
@@ -934,254 +1077,270 @@ static PyObject *M_Mathutils_Quaternion(PyObject *self, PyObject *args)
int x;
float norm;
- if (!PyArg_ParseTuple(args, "O!|f", &PyList_Type, &listObject, &angle))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected list and optional float\n"));
-
- if(PyList_Size(listObject) != 4 && PyList_Size(listObject) != 3)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "3 or 4 expected floats for the quaternion\n"));
-
- vec = PyMem_Malloc (PyList_Size(listObject)*sizeof (float));
- for (x = 0; x < PyList_Size(listObject); x++) {
- if (!PyArg_Parse(PyList_GetItem(listObject, x), "f", &vec[x]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list not parseable\n");
+ if( !PyArg_ParseTuple
+ ( args, "O!|f", &PyList_Type, &listObject, &angle ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected list and optional float\n" ) );
+
+ if( PyList_Size( listObject ) != 4 && PyList_Size( listObject ) != 3 )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "3 or 4 expected floats for the quaternion\n" ) );
+
+ vec = PyMem_Malloc( PyList_Size( listObject ) * sizeof( float ) );
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( listObject, x ), "f", &vec[x] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list not parseable\n" );
}
- if(PyList_Size(listObject) == 3){ //an axis of rotation
- norm = (float)sqrt(vec[0] * vec[0] + vec[1] * vec[1] +
- vec[2] * vec[2]);
-
- vec[0] /= norm; vec[1] /= norm; vec[2] /= norm;
-
- angle = angle * (float)(Py_PI/180);
- quat = PyMem_Malloc(4*sizeof(float));
- quat[0] = (float)(cos((double)(angle)/2));
- quat[1] = (float)(sin((double)(angle)/2)) * vec[0];
- quat[2] = (float)(sin((double)(angle)/2)) * vec[1];
- quat[3] = (float)(sin((double)(angle)/2)) * vec[2];
-
- PyMem_Free(vec);
-
- return newQuaternionObject(quat);
- }else
- return newQuaternionObject(vec);
+ if( PyList_Size( listObject ) == 3 ) { //an axis of rotation
+ norm = ( float ) sqrt( vec[0] * vec[0] + vec[1] * vec[1] +
+ vec[2] * vec[2] );
+
+ vec[0] /= norm;
+ vec[1] /= norm;
+ vec[2] /= norm;
+
+ angle = angle * ( float ) ( Py_PI / 180 );
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ quat[0] = ( float ) ( cos( ( double ) ( angle ) / 2 ) );
+ quat[1] =
+ ( float ) ( sin( ( double ) ( angle ) / 2 ) ) * vec[0];
+ quat[2] =
+ ( float ) ( sin( ( double ) ( angle ) / 2 ) ) * vec[1];
+ quat[3] =
+ ( float ) ( sin( ( double ) ( angle ) / 2 ) ) * vec[2];
+
+ PyMem_Free( vec );
+
+ return newQuaternionObject( quat );
+ } else
+ return newQuaternionObject( vec );
}
//***************************************************************************
//Begin Quaternion Utils
-static PyObject *M_Mathutils_CopyQuat(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CopyQuat( PyObject * self, PyObject * args )
{
- QuaternionObject * quatU;
- float * quat;
+ QuaternionObject *quatU;
+ float *quat;
- if (!PyArg_ParseTuple(args, "O!", &quaternion_Type, &quatU))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Quaternion type"));
+ if( !PyArg_ParseTuple( args, "O!", &quaternion_Type, &quatU ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Quaternion type" ) );
- quat = PyMem_Malloc (4*sizeof(float));
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
quat[0] = quatU->quat[0];
quat[1] = quatU->quat[1];
quat[2] = quatU->quat[2];
quat[3] = quatU->quat[3];
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-static PyObject *M_Mathutils_CrossQuats(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CrossQuats( PyObject * self, PyObject * args )
{
- QuaternionObject * quatU;
- QuaternionObject * quatV;
- float * quat;
-
- if (!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU,
- &quaternion_Type, &quatV))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Quaternion types"));
- quat = PyMem_Malloc (4*sizeof(float));
- QuatMul(quat, quatU->quat, quatV->quat);
-
- return (PyObject*)newQuaternionObject(quat);
+ QuaternionObject *quatU;
+ QuaternionObject *quatV;
+ float *quat;
+
+ if( !PyArg_ParseTuple( args, "O!O!", &quaternion_Type, &quatU,
+ &quaternion_Type, &quatV ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Quaternion types" ) );
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ QuatMul( quat, quatU->quat, quatV->quat );
+
+ return ( PyObject * ) newQuaternionObject( quat );
}
-static PyObject *M_Mathutils_DotQuats(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_DotQuats( PyObject * self, PyObject * args )
{
- QuaternionObject * quatU;
- QuaternionObject * quatV;
- float * quat;
+ QuaternionObject *quatU;
+ QuaternionObject *quatV;
+ float *quat;
int x;
float dot = 0.0f;
- if (!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU,
- &quaternion_Type, &quatV))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Quaternion types"));
+ if( !PyArg_ParseTuple( args, "O!O!", &quaternion_Type, &quatU,
+ &quaternion_Type, &quatV ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Quaternion types" ) );
- quat = PyMem_Malloc (4*sizeof(float));
- for(x = 0; x < 4; x++){
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
dot += quatU->quat[x] * quatV->quat[x];
}
- return PyFloat_FromDouble((double)(dot));
+ return PyFloat_FromDouble( ( double ) ( dot ) );
}
-static PyObject *M_Mathutils_DifferenceQuats(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_DifferenceQuats( PyObject * self,
+ PyObject * args )
{
- QuaternionObject * quatU;
- QuaternionObject * quatV;
- float * quat;
- float * tempQuat;
+ QuaternionObject *quatU;
+ QuaternionObject *quatV;
+ float *quat;
+ float *tempQuat;
int x;
float dot = 0.0f;
- if (!PyArg_ParseTuple(args, "O!O!", &quaternion_Type,
- &quatU, &quaternion_Type, &quatV))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Quaternion types"));
+ if( !PyArg_ParseTuple( args, "O!O!", &quaternion_Type,
+ &quatU, &quaternion_Type, &quatV ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Quaternion types" ) );
- quat = PyMem_Malloc (4*sizeof(float));
- tempQuat = PyMem_Malloc (4*sizeof(float));
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ tempQuat = PyMem_Malloc( 4 * sizeof( float ) );
tempQuat[0] = quatU->quat[0];
tempQuat[1] = -quatU->quat[1];
tempQuat[2] = -quatU->quat[2];
tempQuat[3] = -quatU->quat[3];
- dot= (float)sqrt((double)tempQuat[0] * (double)tempQuat[0] +
- (double)tempQuat[1] * (double)tempQuat[1] +
- (double)tempQuat[2] * (double)tempQuat[2] +
- (double)tempQuat[3] * (double)tempQuat[3]);
+ dot = ( float ) sqrt( ( double ) tempQuat[0] * ( double ) tempQuat[0] +
+ ( double ) tempQuat[1] * ( double ) tempQuat[1] +
+ ( double ) tempQuat[2] * ( double ) tempQuat[2] +
+ ( double ) tempQuat[3] *
+ ( double ) tempQuat[3] );
- for(x = 0; x < 4; x++){
- tempQuat[x] /= (dot * dot);
+ for( x = 0; x < 4; x++ ) {
+ tempQuat[x] /= ( dot * dot );
}
- QuatMul(quat, tempQuat, quatV->quat);
+ QuatMul( quat, tempQuat, quatV->quat );
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-static PyObject *M_Mathutils_Slerp(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Slerp( PyObject * self, PyObject * args )
{
- QuaternionObject * quatU;
- QuaternionObject * quatV;
- float * quat;
- float param, x,y, cosD, sinD, deltaD, IsinD, val;
+ QuaternionObject *quatU;
+ QuaternionObject *quatV;
+ float *quat;
+ float param, x, y, cosD, sinD, deltaD, IsinD, val;
int flag, z;
- if (!PyArg_ParseTuple(args, "O!O!f", &quaternion_Type,
- &quatU, &quaternion_Type, &quatV, &param))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Quaternion types and float"));
+ if( !PyArg_ParseTuple( args, "O!O!f", &quaternion_Type,
+ &quatU, &quaternion_Type, &quatV, &param ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Quaternion types and float" ) );
+
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
- quat = PyMem_Malloc (4*sizeof(float));
-
- cosD = quatU->quat[0] * quatV->quat[0] +
- quatU->quat[1] * quatV->quat[1] +
- quatU->quat[2] * quatV->quat[2] +
- quatU->quat[3] * quatV->quat[3];
+ cosD = quatU->quat[0] * quatV->quat[0] +
+ quatU->quat[1] * quatV->quat[1] +
+ quatU->quat[2] * quatV->quat[2] +
+ quatU->quat[3] * quatV->quat[3];
flag = 0;
- if(cosD< 0.0f){
+ if( cosD < 0.0f ) {
flag = 1;
cosD = -cosD;
}
- if(cosD > .99999f){
+ if( cosD > .99999f ) {
x = 1.0f - param;
y = param;
- }else{
- sinD = (float)sqrt(1.0f - cosD * cosD);
- deltaD = (float)atan2(sinD, cosD);
- IsinD = 1.0f/sinD;
- x = (float)sin((1.0f - param) * deltaD) * IsinD;
- y = (float)sin(param * deltaD) * IsinD;
+ } else {
+ sinD = ( float ) sqrt( 1.0f - cosD * cosD );
+ deltaD = ( float ) atan2( sinD, cosD );
+ IsinD = 1.0f / sinD;
+ x = ( float ) sin( ( 1.0f - param ) * deltaD ) * IsinD;
+ y = ( float ) sin( param * deltaD ) * IsinD;
}
- for(z = 0; z < 4; z++){
+ for( z = 0; z < 4; z++ ) {
val = quatV->quat[z];
- if(val) val = -val;
- quat[z] = (quatU->quat[z] * x) + (val * y);
+ if( val )
+ val = -val;
+ quat[z] = ( quatU->quat[z] * x ) + ( val * y );
}
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
//***************************************************************************
-// Function: M_Mathutils_Euler
-// Python equivalent: Blender.Mathutils.Euler
+// Function: M_Mathutils_Euler
+// Python equivalent: Blender.Mathutils.Euler
//***************************************************************************
-static PyObject *M_Mathutils_Euler(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_Euler( PyObject * self, PyObject * args )
{
PyObject *listObject;
float *vec;
int x;
- if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &listObject))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected list\n"));
+ if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &listObject ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list\n" ) );
- if(PyList_Size(listObject) != 3)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "only 3d eulers are supported\n");
+ if( PyList_Size( listObject ) != 3 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "only 3d eulers are supported\n" );
- vec = PyMem_Malloc (3*sizeof (float));
- for (x = 0; x < 3; x++) {
- if (!PyArg_Parse(PyList_GetItem(listObject, x), "f", &vec[x]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list not parseable\n");
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ ) {
+ if( !PyArg_Parse
+ ( PyList_GetItem( listObject, x ), "f", &vec[x] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list not parseable\n" );
}
- return (PyObject*)newEulerObject(vec);
+ return ( PyObject * ) newEulerObject( vec );
}
//***************************************************************************
//Begin Euler Util
- static PyObject *M_Mathutils_CopyEuler(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_CopyEuler( PyObject * self, PyObject * args )
{
- EulerObject * eulU;
- float * eul;
+ EulerObject *eulU;
+ float *eul;
- if (!PyArg_ParseTuple(args, "O!", &euler_Type, &eulU))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Euler types"));
+ if( !PyArg_ParseTuple( args, "O!", &euler_Type, &eulU ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Euler types" ) );
- eul = PyMem_Malloc (3*sizeof(float));
+ eul = PyMem_Malloc( 3 * sizeof( float ) );
eul[0] = eulU->eul[0];
eul[1] = eulU->eul[1];
eul[2] = eulU->eul[2];
- return (PyObject*)newEulerObject(eul);
+ return ( PyObject * ) newEulerObject( eul );
}
-static PyObject *M_Mathutils_RotateEuler(PyObject *self, PyObject *args)
+static PyObject *M_Mathutils_RotateEuler( PyObject * self, PyObject * args )
{
- EulerObject * Eul;
+ EulerObject *Eul;
float angle;
char *axis;
int x;
- if (!PyArg_ParseTuple(args, "O!fs", &euler_Type, &Eul, &angle, &axis))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected euler type & float & string"));
+ if( !PyArg_ParseTuple
+ ( args, "O!fs", &euler_Type, &Eul, &angle, &axis ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected euler type & float & string" ) );
- angle *= (float)(Py_PI/180);
- for(x = 0; x < 3; x++){
- Eul->eul[x] *= (float)(Py_PI/180);
+ angle *= ( float ) ( Py_PI / 180 );
+ for( x = 0; x < 3; x++ ) {
+ Eul->eul[x] *= ( float ) ( Py_PI / 180 );
}
- euler_rot(Eul->eul, angle, *axis);
- for(x = 0; x < 3; x++){
- Eul->eul[x] *= (float)(180/Py_PI);
+ euler_rot( Eul->eul, angle, *axis );
+ for( x = 0; x < 3; x++ ) {
+ Eul->eul[x] *= ( float ) ( 180 / Py_PI );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
//***************************************************************************
-// Function: Mathutils_Init
+// Function: Mathutils_Init
//***************************************************************************
-PyObject *Mathutils_Init (void)
+PyObject *Mathutils_Init( void )
{
- PyObject *mod= Py_InitModule3("Blender.Mathutils", M_Mathutils_methods, M_Mathutils_doc);
- return(mod);
+ PyObject *mod =
+ Py_InitModule3( "Blender.Mathutils", M_Mathutils_methods,
+ M_Mathutils_doc );
+ return ( mod );
}
diff --git a/source/blender/python/api2_2x/Mathutils.h b/source/blender/python/api2_2x/Mathutils.h
index 1d4dd544dea..9a0e30b2eaf 100644
--- a/source/blender/python/api2_2x/Mathutils.h
+++ b/source/blender/python/api2_2x/Mathutils.h
@@ -53,153 +53,159 @@
/*****************************************************************************/
-// Python API function prototypes for the Mathutils module.
+// Python API function prototypes for the Mathutils module.
/*****************************************************************************/
-static PyObject *M_Mathutils_Rand (PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_Vector(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CrossVecs(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_DotVecs (PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_AngleBetweenVecs(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_MidpointVecs(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_VecMultMat(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_ProjectVecs(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CopyVec(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_Matrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_RotationMatrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_ScaleMatrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_ShearMatrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_TranslationMatrix(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_MatMultVec(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CopyMat(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_Quaternion(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CrossQuats(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_DotQuats(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CopyQuat(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_DifferenceQuats(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_Slerp(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_Euler(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_CopyEuler(PyObject *self, PyObject *args);
-static PyObject *M_Mathutils_RotateEuler(PyObject *self, PyObject *args);
+static PyObject *M_Mathutils_Rand( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Vector( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CrossVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DotVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_AngleBetweenVecs( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_MidpointVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_VecMultMat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_ProjectVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyVec( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Matrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_RotationMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_ScaleMatrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_OrthoProjectionMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_ShearMatrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_TranslationMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_MatMultVec( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyMat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Quaternion( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CrossQuats( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DotQuats( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyQuat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DifferenceQuats( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_Slerp( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Euler( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyEuler( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_RotateEuler( PyObject * self, PyObject * args );
/*****************************************************************************/
-// The following string definitions are used for documentation strings.
-// In Python these will be written to the console when doing a
-// Blender.Mathutils.__doc__ Mathutils Module strings */
-/*****************************************************************************/
-static char M_Mathutils_doc[] =
-"The Blender Mathutils module\n\n";
+// The following string definitions are used for documentation strings.
+// In Python these will be written to the console when doing a
+// Blender.Mathutils.__doc__
+/* Mathutils Module strings */
+/****************************************************************************/
+static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n";
static char M_Mathutils_Vector_doc[] =
-"() - create a new vector object from a list of floats";
+ "() - create a new vector object from a list of floats";
static char M_Mathutils_Matrix_doc[] =
-"() - create a new matrix object from a list of floats";
+ "() - create a new matrix object from a list of floats";
static char M_Mathutils_Quaternion_doc[] =
-"() - create a quaternion from a list or an axis of rotation and an angle";
+ "() - create a quaternion from a list or an axis of rotation and an angle";
static char M_Mathutils_Euler_doc[] =
-"() - create and return a new euler object";
-static char M_Mathutils_Rand_doc[] =
-"() - return a random number";
+ "() - create and return a new euler object";
+static char M_Mathutils_Rand_doc[] = "() - return a random number";
static char M_Mathutils_CrossVecs_doc[] =
-"() - returns a vector perpedicular to the 2 vectors crossed";
-static char M_Mathutils_CopyVec_doc[] =
-"() - create a copy of vector";
+ "() - returns a vector perpedicular to the 2 vectors crossed";
+static char M_Mathutils_CopyVec_doc[] = "() - create a copy of vector";
static char M_Mathutils_DotVecs_doc[] =
-"() - return the dot product of two vectors";
+ "() - return the dot product of two vectors";
static char M_Mathutils_AngleBetweenVecs_doc[] =
-"() - returns the angle between two vectors in degrees";
+ "() - returns the angle between two vectors in degrees";
static char M_Mathutils_MidpointVecs_doc[] =
-"() - return the vector to the midpoint between two vectors";
+ "() - return the vector to the midpoint between two vectors";
static char M_Mathutils_MatMultVec_doc[] =
-"() - multiplies a matrix by a column vector";
+ "() - multiplies a matrix by a column vector";
static char M_Mathutils_VecMultMat_doc[] =
-"() - multiplies a row vector by a matrix";
+ "() - multiplies a row vector by a matrix";
static char M_Mathutils_ProjectVecs_doc[] =
-"() - returns the projection vector from the projection of vecA onto vecB";
+ "() - returns the projection vector from the projection of vecA onto vecB";
static char M_Mathutils_RotationMatrix_doc[] =
-"() - construct a rotation matrix from an angle and axis of rotation";
+ "() - construct a rotation matrix from an angle and axis of rotation";
static char M_Mathutils_ScaleMatrix_doc[] =
-"() - construct a scaling matrix from a scaling factor";
+ "() - construct a scaling matrix from a scaling factor";
static char M_Mathutils_OrthoProjectionMatrix_doc[] =
-"() - construct a orthographic projection matrix from a selected plane";
+ "() - construct a orthographic projection matrix from a selected plane";
static char M_Mathutils_ShearMatrix_doc[] =
-"() - construct a shearing matrix from a plane of shear and a shear factor";
-static char M_Mathutils_CopyMat_doc[] =
-"() - create a copy of a matrix";
+ "() - construct a shearing matrix from a plane of shear and a shear factor";
+static char M_Mathutils_CopyMat_doc[] = "() - create a copy of a matrix";
static char M_Mathutils_TranslationMatrix_doc[] =
-"() - create a translation matrix from a vector";
-static char M_Mathutils_CopyQuat_doc[] =
-"() - copy quatB to quatA";
-static char M_Mathutils_CopyEuler_doc[] =
-"() - copy eulB to eultA";
+ "() - create a translation matrix from a vector";
+static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA";
+static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA";
static char M_Mathutils_CrossQuats_doc[] =
-"() - return the mutliplication of two quaternions";
+ "() - return the mutliplication of two quaternions";
static char M_Mathutils_DotQuats_doc[] =
-"() - return the dot product of two quaternions";
+ "() - return the dot product of two quaternions";
static char M_Mathutils_Slerp_doc[] =
-"() - returns the interpolation between two quaternions";
+ "() - returns the interpolation between two quaternions";
static char M_Mathutils_DifferenceQuats_doc[] =
-"() - return the angular displacment difference between two quats";
+ "() - return the angular displacment difference between two quats";
static char M_Mathutils_RotateEuler_doc[] =
-"() - rotate euler by an axis and angle";
+ "() - rotate euler by an axis and angle";
-/*****************************************************************************/
-// Python method structure definition for Blender.Mathutils module:
-/*****************************************************************************/
+/****************************************************************************/
+// Python method structure definition for Blender.Mathutils module:
+/****************************************************************************/
struct PyMethodDef M_Mathutils_methods[] = {
- {"Rand",(PyCFunction)M_Mathutils_Rand, METH_VARARGS,
- M_Mathutils_Rand_doc},
- {"Vector",(PyCFunction)M_Mathutils_Vector, METH_VARARGS,
- M_Mathutils_Vector_doc},
- {"CrossVecs",(PyCFunction)M_Mathutils_CrossVecs, METH_VARARGS,
- M_Mathutils_CrossVecs_doc},
- {"DotVecs",(PyCFunction)M_Mathutils_DotVecs, METH_VARARGS,
- M_Mathutils_DotVecs_doc},
- {"AngleBetweenVecs",(PyCFunction)M_Mathutils_AngleBetweenVecs, METH_VARARGS,
- M_Mathutils_AngleBetweenVecs_doc},
- {"MidpointVecs",(PyCFunction)M_Mathutils_MidpointVecs, METH_VARARGS,
- M_Mathutils_MidpointVecs_doc},
- {"VecMultMat",(PyCFunction)M_Mathutils_VecMultMat, METH_VARARGS,
- M_Mathutils_VecMultMat_doc},
- {"ProjectVecs",(PyCFunction)M_Mathutils_ProjectVecs, METH_VARARGS,
- M_Mathutils_ProjectVecs_doc},
- {"CopyVec",(PyCFunction)M_Mathutils_CopyVec, METH_VARARGS,
- M_Mathutils_CopyVec_doc},
- {"Matrix",(PyCFunction)M_Mathutils_Matrix, METH_VARARGS,
- M_Mathutils_Matrix_doc},
- {"RotationMatrix",(PyCFunction)M_Mathutils_RotationMatrix, METH_VARARGS,
- M_Mathutils_RotationMatrix_doc},
- {"ScaleMatrix",(PyCFunction)M_Mathutils_ScaleMatrix, METH_VARARGS,
- M_Mathutils_ScaleMatrix_doc},
- {"ShearMatrix",(PyCFunction)M_Mathutils_ShearMatrix, METH_VARARGS,
- M_Mathutils_ShearMatrix_doc},
- {"TranslationMatrix",(PyCFunction)M_Mathutils_TranslationMatrix, METH_VARARGS,
- M_Mathutils_TranslationMatrix_doc},
- {"CopyMat",(PyCFunction)M_Mathutils_CopyMat, METH_VARARGS,
- M_Mathutils_CopyMat_doc},
- {"OrthoProjectionMatrix",(PyCFunction)M_Mathutils_OrthoProjectionMatrix, METH_VARARGS,
- M_Mathutils_OrthoProjectionMatrix_doc},
- {"MatMultVec",(PyCFunction)M_Mathutils_MatMultVec, METH_VARARGS,
- M_Mathutils_MatMultVec_doc},
- {"Quaternion",(PyCFunction)M_Mathutils_Quaternion, METH_VARARGS,
- M_Mathutils_Quaternion_doc},
- {"CopyQuat",(PyCFunction)M_Mathutils_CopyQuat, METH_VARARGS,
- M_Mathutils_CopyQuat_doc},
- {"CrossQuats",(PyCFunction)M_Mathutils_CrossQuats, METH_VARARGS,
- M_Mathutils_CrossQuats_doc},
- {"DotQuats",(PyCFunction)M_Mathutils_DotQuats, METH_VARARGS,
- M_Mathutils_DotQuats_doc},
- {"DifferenceQuats",(PyCFunction)M_Mathutils_DifferenceQuats, METH_VARARGS,
- M_Mathutils_DifferenceQuats_doc},
- {"Slerp",(PyCFunction)M_Mathutils_Slerp, METH_VARARGS,
- M_Mathutils_Slerp_doc},
- {"Euler",(PyCFunction)M_Mathutils_Euler, METH_VARARGS,
- M_Mathutils_Euler_doc},
- {"CopyEuler",(PyCFunction)M_Mathutils_CopyEuler, METH_VARARGS,
- M_Mathutils_CopyEuler_doc},
- {"RotateEuler",(PyCFunction)M_Mathutils_RotateEuler, METH_VARARGS,
- M_Mathutils_RotateEuler_doc},
+ {"Rand", ( PyCFunction ) M_Mathutils_Rand, METH_VARARGS,
+ M_Mathutils_Rand_doc},
+ {"Vector", ( PyCFunction ) M_Mathutils_Vector, METH_VARARGS,
+ M_Mathutils_Vector_doc},
+ {"CrossVecs", ( PyCFunction ) M_Mathutils_CrossVecs, METH_VARARGS,
+ M_Mathutils_CrossVecs_doc},
+ {"DotVecs", ( PyCFunction ) M_Mathutils_DotVecs, METH_VARARGS,
+ M_Mathutils_DotVecs_doc},
+ {"AngleBetweenVecs", ( PyCFunction ) M_Mathutils_AngleBetweenVecs,
+ METH_VARARGS,
+ M_Mathutils_AngleBetweenVecs_doc},
+ {"MidpointVecs", ( PyCFunction ) M_Mathutils_MidpointVecs,
+ METH_VARARGS,
+ M_Mathutils_MidpointVecs_doc},
+ {"VecMultMat", ( PyCFunction ) M_Mathutils_VecMultMat, METH_VARARGS,
+ M_Mathutils_VecMultMat_doc},
+ {"ProjectVecs", ( PyCFunction ) M_Mathutils_ProjectVecs, METH_VARARGS,
+ M_Mathutils_ProjectVecs_doc},
+ {"CopyVec", ( PyCFunction ) M_Mathutils_CopyVec, METH_VARARGS,
+ M_Mathutils_CopyVec_doc},
+ {"Matrix", ( PyCFunction ) M_Mathutils_Matrix, METH_VARARGS,
+ M_Mathutils_Matrix_doc},
+ {"RotationMatrix", ( PyCFunction ) M_Mathutils_RotationMatrix,
+ METH_VARARGS,
+ M_Mathutils_RotationMatrix_doc},
+ {"ScaleMatrix", ( PyCFunction ) M_Mathutils_ScaleMatrix, METH_VARARGS,
+ M_Mathutils_ScaleMatrix_doc},
+ {"ShearMatrix", ( PyCFunction ) M_Mathutils_ShearMatrix, METH_VARARGS,
+ M_Mathutils_ShearMatrix_doc},
+ {"TranslationMatrix", ( PyCFunction ) M_Mathutils_TranslationMatrix,
+ METH_VARARGS,
+ M_Mathutils_TranslationMatrix_doc},
+ {"CopyMat", ( PyCFunction ) M_Mathutils_CopyMat, METH_VARARGS,
+ M_Mathutils_CopyMat_doc},
+ {"OrthoProjectionMatrix",
+ ( PyCFunction ) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS,
+ M_Mathutils_OrthoProjectionMatrix_doc},
+ {"MatMultVec", ( PyCFunction ) M_Mathutils_MatMultVec, METH_VARARGS,
+ M_Mathutils_MatMultVec_doc},
+ {"Quaternion", ( PyCFunction ) M_Mathutils_Quaternion, METH_VARARGS,
+ M_Mathutils_Quaternion_doc},
+ {"CopyQuat", ( PyCFunction ) M_Mathutils_CopyQuat, METH_VARARGS,
+ M_Mathutils_CopyQuat_doc},
+ {"CrossQuats", ( PyCFunction ) M_Mathutils_CrossQuats, METH_VARARGS,
+ M_Mathutils_CrossQuats_doc},
+ {"DotQuats", ( PyCFunction ) M_Mathutils_DotQuats, METH_VARARGS,
+ M_Mathutils_DotQuats_doc},
+ {"DifferenceQuats", ( PyCFunction ) M_Mathutils_DifferenceQuats,
+ METH_VARARGS,
+ M_Mathutils_DifferenceQuats_doc},
+ {"Slerp", ( PyCFunction ) M_Mathutils_Slerp, METH_VARARGS,
+ M_Mathutils_Slerp_doc},
+ {"Euler", ( PyCFunction ) M_Mathutils_Euler, METH_VARARGS,
+ M_Mathutils_Euler_doc},
+ {"CopyEuler", ( PyCFunction ) M_Mathutils_CopyEuler, METH_VARARGS,
+ M_Mathutils_CopyEuler_doc},
+ {"RotateEuler", ( PyCFunction ) M_Mathutils_RotateEuler, METH_VARARGS,
+ M_Mathutils_RotateEuler_doc},
{NULL, NULL, 0, NULL}
};
-#endif /* EXPP_Mathutils_H */
+#endif /* EXPP_Mathutils_H */
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index 38daffcbb5f..6c55dddfc4d 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -32,265 +32,276 @@
#include "Metaball.h"
-PyObject * Metaball_Init (void);
-PyObject * Metaball_CreatePyObject (MetaBall *metaball);
-MetaBall * Metaball_FromPyObject (PyObject *py_obj);
-int Metaball_CheckPyObject (PyObject *py_obj);
+PyObject *Metaball_Init( void );
+PyObject *Metaball_CreatePyObject( MetaBall * metaball );
+MetaBall *Metaball_FromPyObject( PyObject * py_obj );
+int Metaball_CheckPyObject( PyObject * py_obj );
/*****************************************************************************/
-/* Python Metaball_Type structure definition: */
+/* Python Metaball_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Metaball_Type =
- {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Metaball", /* tp_name */
- sizeof (BPy_Metaball), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)MetaballDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)MetaballGetAttr, /* tp_getattr */
- (setattrfunc)MetaballSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)MetaballRepr, /* 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_Metaball_methods, /* tp_methods */
- 0, /* tp_members */
- };
-
-
-PyTypeObject Metaelem_Type =
- {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Metaelem", /* tp_name */
- sizeof (BPy_Metaelem), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)MetaelemDeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)MetaelemGetAttr, /* tp_getattr */
- (setattrfunc)MetaelemSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)MetaelemRepr, /* 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_Metaelem_methods, /* tp_methods */
- 0, /* tp_members */
- };
+PyTypeObject Metaball_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Metaball", /* tp_name */
+ sizeof( BPy_Metaball ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) MetaballDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) MetaballGetAttr, /* tp_getattr */
+ ( setattrfunc ) MetaballSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) MetaballRepr, /* 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_Metaball_methods, /* tp_methods */
+ 0, /* tp_members */
+};
+
+
+PyTypeObject Metaelem_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Metaelem", /* tp_name */
+ sizeof( BPy_Metaelem ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) MetaelemDeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) MetaelemGetAttr, /* tp_getattr */
+ ( setattrfunc ) MetaelemSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) MetaelemRepr, /* 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_Metaelem_methods, /* tp_methods */
+ 0, /* tp_members */
+};
/*****************************************************************************/
/* Function: M_Metaball_New */
/* Python equivalent: Blender.Metaball.New */
/*****************************************************************************/
-static PyObject *M_Metaball_New(PyObject *self, PyObject *args)
-{
- char*name = 0;
- BPy_Metaball *pymball; /* for Data object wrapper in Python */
- MetaBall *blmball; /* for actual Data we create in Blender */
- char buf[21];
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
-
- blmball = add_mball(); /* first create the MetaBall Data in Blender */
-
- if (blmball){
- /* return user count to zero since add_mball() incref'ed it */
- blmball->id.us = 0;
- /* now create the wrapper obj in Python */
- pymball = (BPy_Metaball *)PyObject_NEW(BPy_Metaball, &Metaball_Type);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create MetaBall Data in Blender"));
-
- if (pymball == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create MetaBall Data object"));
-
- pymball->metaball = blmball;
- /*link Python mballer wrapper to Blender MetaBall */
- if(name) { /* user gave us a name for the metaball, use it */
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&blmball->id, buf);
- }
- return (PyObject *)pymball;
+static PyObject *M_Metaball_New( PyObject * self, PyObject * args )
+{
+ char *name = 0;
+ BPy_Metaball *pymball; /* for Data object wrapper in Python */
+ MetaBall *blmball; /* for actual Data we create in Blender */
+ char buf[21];
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
+
+ blmball = add_mball( ); /* first create the MetaBall Data in Blender */
+
+ if( blmball ) {
+ /* return user count to zero since add_mball() incref'ed it */
+ blmball->id.us = 0;
+ /* now create the wrapper obj in Python */
+ pymball =
+ ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
+ &Metaball_Type );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create MetaBall Data in Blender" ) );
+
+ if( pymball == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create MetaBall Data object" ) );
+
+ pymball->metaball = blmball;
+ /*link Python mballer wrapper to Blender MetaBall */
+ if( name ) { /* user gave us a name for the metaball, use it */
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &blmball->id, buf );
+ }
+ return ( PyObject * ) pymball;
}
/*****************************************************************************/
-/* Function: M_Metaball_Get */
-/* Python equivalent: Blender.Metaball.Get */
-/* Description: Receives a string and returns the metaball data obj */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all metaball data names in the */
-/* current scene is returned. */
+/* Function: M_Metaball_Get */
+/* Python equivalent: Blender.Metaball.Get */
+/* Description: Receives a string and returns the metaball data obj */
+/* whose name matches the string. If no argument is */
+/* passed in, a list of all metaball data names in the */
+/* current scene is returned. */
/*****************************************************************************/
-static PyObject *M_Metaball_Get(PyObject *self, PyObject *args)
+static PyObject *M_Metaball_Get( PyObject * self, PyObject * args )
{
- char error_msg[64];
- char *name = NULL;
- MetaBall *mball_iter;
-
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
-
- mball_iter = G.main->mball.first;
-
- if (name) { /* (name) - Search mball by name */
-
- BPy_Metaball *wanted_mball = NULL;
-
- while ((mball_iter) && (wanted_mball == NULL)) {
- if (strcmp (name, mball_iter->id.name+2) == 0) {
- wanted_mball=(BPy_Metaball*)PyObject_NEW(BPy_Metaball,&Metaball_Type);
- if (wanted_mball)
- wanted_mball->metaball = mball_iter;
- }
- mball_iter = mball_iter->id.next;
- }
+ char error_msg[64];
+ char *name = NULL;
+ MetaBall *mball_iter;
+
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
+
+ mball_iter = G.main->mball.first;
+
+ if( name ) { /* (name) - Search mball by name */
+
+ BPy_Metaball *wanted_mball = NULL;
+
+ while( ( mball_iter ) && ( wanted_mball == NULL ) ) {
+ if( strcmp( name, mball_iter->id.name + 2 ) == 0 ) {
+ wanted_mball =
+ ( BPy_Metaball * )
+ PyObject_NEW( BPy_Metaball,
+ &Metaball_Type );
+ if( wanted_mball )
+ wanted_mball->metaball = mball_iter;
+ }
+ mball_iter = mball_iter->id.next;
+ }
- if (wanted_mball == NULL) { /* Requested mball doesn't exist */
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "MetaBall \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ if( wanted_mball == NULL ) { /* Requested mball doesn't exist */
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "MetaBall \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+ }
- return (PyObject *)wanted_mball;
- }
+ return ( PyObject * ) wanted_mball;
+ }
- else { /* () - return a list of all mballs in the scene */
- PyObject *mballlist;
+ else { /* () - return a list of all mballs in the scene */
+ PyObject *mballlist;
- mballlist = PyList_New (0);
+ mballlist = PyList_New( 0 );
- if (mballlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( mballlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (mball_iter) {
- BPy_Metaball *found_mball=(BPy_Metaball*)PyObject_NEW(BPy_Metaball,&Metaball_Type);
+ while( mball_iter ) {
+ BPy_Metaball *found_mball =
+ ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
+ &Metaball_Type );
found_mball->metaball = mball_iter;
- PyList_Append (mballlist, (PyObject *)found_mball);
- mball_iter = mball_iter->id.next;
- }
+ PyList_Append( mballlist, ( PyObject * ) found_mball );
+ mball_iter = mball_iter->id.next;
+ }
- return (mballlist);
- }
+ return ( mballlist );
+ }
}
-/******************************************************************************/
-/* Function: Metaball_Init */
-/******************************************************************************/
-PyObject *Metaball_Init (void)
+/****************************************************************************/
+/* Function: Metaball_Init */
+/****************************************************************************/
+PyObject *Metaball_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Metaball_Type.ob_type = &PyType_Type;
+ Metaball_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Metaball",
- M_Metaball_methods, M_Metaball_doc);
+ submodule = Py_InitModule3( "Blender.Metaball",
+ M_Metaball_methods, M_Metaball_doc );
- return (submodule);
+ return ( submodule );
}
-int
-Metaball_CheckPyObject (PyObject * pyobj)
+int Metaball_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Metaball_Type);
+ return ( pyobj->ob_type == &Metaball_Type );
}
-MetaBall * Metaball_FromPyObject (PyObject * pyobj)
+MetaBall *Metaball_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Metaball *) pyobj)->metaball;
+ return ( ( BPy_Metaball * ) pyobj )->metaball;
}
-/*******************************************************************************/
-/* Python BPy_Metaball methods: */
-/*******************************************************************************/
-void*MEM_callocN(unsigned int,char*);
-void allqueue(unsigned short,short);
+/***************************************************************************/
+/* Python BPy_Metaball methods: */
+/***************************************************************************/
+void *MEM_callocN( unsigned int, char * );
+void allqueue( unsigned short, short );
-static PyObject *Metaball_addMetaelem(BPy_Metaball *self,PyObject*args)
+static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args )
{
MetaElem *ml;
- PyObject *listargs=0;
- int type,lay;
- float x,y,z,rad,s,expx,expy,expz;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
-
-
- type = PyInt_AsLong( PyList_GetItem(listargs,0));
- x = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- y = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- z = PyFloat_AsDouble(PyList_GetItem(listargs,3));
- rad = PyFloat_AsDouble(PyList_GetItem(listargs,4));
- lay = PyInt_AsLong(PyList_GetItem(listargs,5));
- s = PyFloat_AsDouble(PyList_GetItem(listargs,6));
- expx = PyFloat_AsDouble(PyList_GetItem(listargs,7));
- expy = PyFloat_AsDouble(PyList_GetItem(listargs,8));
- expz = PyFloat_AsDouble(PyList_GetItem(listargs,9));
-
- ml= MEM_callocN(sizeof(MetaElem), "metaelem");
- BLI_addhead(&(self->metaball->elems), ml);
-
- ml->x= x;ml->y= y;ml->z= z;
- ml->rad= rad;
- ml->lay= lay;
- ml->s= s;
- ml->flag= SELECT;
+ PyObject *listargs = 0;
+ int type, lay;
+ float x, y, z, rad, s, expx, expy, expz;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+
+
+ type = PyInt_AsLong( PyList_GetItem( listargs, 0 ) );
+ x = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ y = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ z = PyFloat_AsDouble( PyList_GetItem( listargs, 3 ) );
+ rad = PyFloat_AsDouble( PyList_GetItem( listargs, 4 ) );
+ lay = PyInt_AsLong( PyList_GetItem( listargs, 5 ) );
+ s = PyFloat_AsDouble( PyList_GetItem( listargs, 6 ) );
+ expx = PyFloat_AsDouble( PyList_GetItem( listargs, 7 ) );
+ expy = PyFloat_AsDouble( PyList_GetItem( listargs, 8 ) );
+ expz = PyFloat_AsDouble( PyList_GetItem( listargs, 9 ) );
+
+ ml = MEM_callocN( sizeof( MetaElem ), "metaelem" );
+ BLI_addhead( &( self->metaball->elems ), ml );
+
+ ml->x = x;
+ ml->y = y;
+ ml->z = z;
+ ml->rad = rad;
+ ml->lay = lay;
+ ml->s = s;
+ ml->flag = SELECT;
ml->type = type;
- ml->expx= expx;ml->expy= expy;ml->expz= expz;
+ ml->expx = expx;
+ ml->expy = expy;
+ ml->expz = expz;
ml->type = type;
- allqueue(0X4013, 0);
- Py_INCREF(Py_None);
+ allqueue( 0X4013, 0 );
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Metaball_getName(BPy_Metaball *self)
+static PyObject *Metaball_getName( BPy_Metaball * self )
{
- PyObject *attr = PyString_FromString(self->metaball->id.name+2);
+ PyObject *attr = PyString_FromString( self->metaball->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Metaball.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Metaball.name attribute" ) );
}
-static PyObject *Metaball_setName(BPy_Metaball *self,PyObject*args)
+static PyObject *Metaball_setName( BPy_Metaball * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
char buf[20];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&self->metaball->id, buf);
- Py_INCREF(Py_None);
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &self->metaball->id, buf );
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -298,437 +309,523 @@ static PyObject *Metaball_setName(BPy_Metaball *self,PyObject*args)
-static PyObject *Metaball_getBbox(BPy_Metaball *self)
+static PyObject *Metaball_getBbox( BPy_Metaball * self )
{
- int i,j;
- PyObject* ll;
- PyObject* l = PyList_New(0);
- if (self->metaball->bb == NULL) {Py_INCREF(Py_None);return Py_None;}
- for(i = 0;i<8;i++)
- {
- ll = PyList_New(0);
- for(j = 0;j<3;j++)
- PyList_Append( ll, PyFloat_FromDouble(self->metaball->bb->vec[i][j]));
- PyList_Append( l, ll);
- }
+ int i, j;
+ PyObject *ll;
+ PyObject *l = PyList_New( 0 );
+ if( self->metaball->bb == NULL ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ for( i = 0; i < 8; i++ ) {
+ ll = PyList_New( 0 );
+ for( j = 0; j < 3; j++ )
+ PyList_Append( ll,
+ PyFloat_FromDouble( self->metaball->bb->
+ vec[i][j] ) );
+ PyList_Append( l, ll );
+ }
- return l;
+ return l;
}
-static PyObject *Metaball_getNMetaElems(BPy_Metaball *self)
+static PyObject *Metaball_getNMetaElems( BPy_Metaball * self )
{
- int i = 0;
- MetaElem*ptr = self->metaball->elems.first;
- if(!ptr) return (PyInt_FromLong(0) );
- while(ptr)
- {
- i++;
- ptr = ptr->next;
- }
- return (PyInt_FromLong(i) );
+ int i = 0;
+ MetaElem *ptr = self->metaball->elems.first;
+ if( !ptr )
+ return ( PyInt_FromLong( 0 ) );
+ while( ptr ) {
+ i++;
+ ptr = ptr->next;
+ }
+ return ( PyInt_FromLong( i ) );
}
-static PyObject *Metaball_getloc(BPy_Metaball *self)
+static PyObject *Metaball_getloc( BPy_Metaball * self )
{
- PyObject* l = PyList_New(0);
- PyList_Append( l, PyFloat_FromDouble(self->metaball->loc[0]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->loc[1]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->loc[2]));
- return l;
+ PyObject *l = PyList_New( 0 );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->loc[0] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->loc[1] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->loc[2] ) );
+ return l;
}
-static PyObject *Metaball_setloc(BPy_Metaball *self,PyObject*args)
-{
- PyObject *listargs=0;
+static PyObject *Metaball_setloc( BPy_Metaball * self, PyObject * args )
+{
+ PyObject *listargs = 0;
int i;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- for(i=0;i<3;i++){
- PyObject * xx = PyList_GetItem(listargs,i);
- self->metaball->loc[i] = PyFloat_AsDouble(xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->metaball->loc[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getrot(BPy_Metaball *self)
+static PyObject *Metaball_getrot( BPy_Metaball * self )
{
- PyObject* l = PyList_New(0);
- PyList_Append( l, PyFloat_FromDouble(self->metaball->rot[0]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->rot[1]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->rot[2]));
- return l;
+ PyObject *l = PyList_New( 0 );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->rot[0] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->rot[1] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->rot[2] ) );
+ return l;
}
-static PyObject *Metaball_setrot(BPy_Metaball *self,PyObject*args)
-{
- PyObject *listargs=0;
+static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args )
+{
+ PyObject *listargs = 0;
int i;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- for(i=0;i<3;i++){
- PyObject * xx = PyList_GetItem(listargs,i);
- self->metaball->rot[i] = PyFloat_AsDouble(xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->metaball->rot[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getsize(BPy_Metaball *self)
+static PyObject *Metaball_getsize( BPy_Metaball * self )
{
- PyObject* l = PyList_New(0);
+ PyObject *l = PyList_New( 0 );
- PyList_Append( l, PyFloat_FromDouble(self->metaball->size[0]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->size[1]));
- PyList_Append( l, PyFloat_FromDouble(self->metaball->size[2]));
- return l;
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->size[0] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->size[1] ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaball->size[2] ) );
+ return l;
}
-static PyObject *Metaball_getMetaElemList(BPy_Metaball *self)
-{
+static PyObject *Metaball_getMetaElemList( BPy_Metaball * self )
+{
MetaElem *ptr;
- PyObject* l = PyList_New(0);
- ptr = self->metaball->elems.first;
- if(!ptr) return l ;
- while(ptr)
- {
-BPy_Metaelem *found_melem=(BPy_Metaelem*)PyObject_NEW(BPy_Metaelem,&Metaelem_Type);
- found_melem->metaelem = ptr;
- PyList_Append (l, (PyObject *)found_melem);
- ptr = ptr->next;
- }
- return l;
+ PyObject *l = PyList_New( 0 );
+ ptr = self->metaball->elems.first;
+ if( !ptr )
+ return l;
+ while( ptr ) {
+ BPy_Metaelem *found_melem =
+ ( BPy_Metaelem * ) PyObject_NEW( BPy_Metaelem,
+ &Metaelem_Type );
+ found_melem->metaelem = ptr;
+ PyList_Append( l, ( PyObject * ) found_melem );
+ ptr = ptr->next;
+ }
+ return l;
}
-static PyObject *Metaball_setsize(BPy_Metaball *self,PyObject*args)
-{
- PyObject *listargs=0;
+static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args )
+{
+ PyObject *listargs = 0;
int i;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- for(i=0;i<3;i++){
- PyObject * xx = PyList_GetItem(listargs,i);
- self->metaball->size[i] = PyFloat_AsDouble(xx);
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ for( i = 0; i < 3; i++ ) {
+ PyObject *xx = PyList_GetItem( listargs, i );
+ self->metaball->size[i] = PyFloat_AsDouble( xx );
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getWiresize(BPy_Metaball *self)
+static PyObject *Metaball_getWiresize( BPy_Metaball * self )
{
- return PyFloat_FromDouble(self->metaball->wiresize);
+ return PyFloat_FromDouble( self->metaball->wiresize );
}
-static PyObject *Metaball_setWiresize(BPy_Metaball *self,PyObject*args)
-{
-
- float val;
- if (!PyArg_ParseTuple(args, "f", &val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected float args"));
-
- self->metaball->wiresize = val;
+static PyObject *Metaball_setWiresize( BPy_Metaball * self, PyObject * args )
+{
+
+ float val;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected float args" ) );
- Py_INCREF(Py_None);
- return Py_None;
+ self->metaball->wiresize = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getRendersize(BPy_Metaball *self)
+static PyObject *Metaball_getRendersize( BPy_Metaball * self )
{
- return PyFloat_FromDouble(self->metaball->rendersize);
+ return PyFloat_FromDouble( self->metaball->rendersize );
}
-static PyObject *Metaball_setRendersize(BPy_Metaball *self,PyObject*args)
-{
-
- float val;
- if (!PyArg_ParseTuple(args, "f", &val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected float args"));
-
- self->metaball->rendersize = val;
+static PyObject *Metaball_setRendersize( BPy_Metaball * self, PyObject * args )
+{
+
+ float val;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected float args" ) );
- Py_INCREF(Py_None);
- return Py_None;
+ self->metaball->rendersize = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getThresh(BPy_Metaball *self)
+static PyObject *Metaball_getThresh( BPy_Metaball * self )
{
- return PyFloat_FromDouble(self->metaball->thresh);
+ return PyFloat_FromDouble( self->metaball->thresh );
}
-static PyObject *Metaball_setThresh(BPy_Metaball *self,PyObject*args)
-{
-
- float val;
- if (!PyArg_ParseTuple(args, "f", &val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected float args"));
-
- self->metaball->thresh = val;
+static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args )
+{
+
+ float val;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected float args" ) );
- Py_INCREF(Py_None);
- return Py_None;
+ self->metaball->thresh = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-/*******************************************************************************/
-/* get/set metaelems data, */
-/*******************************************************************************/
+/**************************************************************************/
+/* get/set metaelems data, */
+/***************************************************************************/
-static PyObject *Metaball_getMetadata(BPy_Metaball *self,PyObject*args)
-{
- int num;
- int i = 0;
- char*name = NULL;
+static PyObject *Metaball_getMetadata( BPy_Metaball * self, PyObject * args )
+{
+ int num;
+ int i = 0;
+ char *name = NULL;
MetaElem *ptr;
- if (!PyArg_ParseTuple(args, "si", &name,&num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, \
- "expected (string int) argument"));
- /*jump to the num-th MetaElem*/
- ptr = self->metaball->elems.first;
- if(!ptr)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "no metaelem found"));
- for(i = 0;i<num;i++)
- {
- if(!ptr)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "metaelem not found"));
- ptr = ptr->next;
- }
- if(!strcmp(name,"type"))
- return (PyInt_FromLong(ptr->type));
- if(!strcmp(name,"x"))
- return (PyFloat_FromDouble(ptr->x));
- if(!strcmp(name,"y"))
- return (PyFloat_FromDouble(ptr->y));
- if(!strcmp(name,"z"))
- return (PyFloat_FromDouble(ptr->z));
- if(!strcmp(name,"expx"))
- return (PyFloat_FromDouble(ptr->expx));
- if(!strcmp(name,"expy"))
- return (PyFloat_FromDouble(ptr->expy));
- if(!strcmp(name,"expz"))
- return (PyFloat_FromDouble(ptr->expz));
- if(!strcmp(name,"rad"))
- return (PyFloat_FromDouble(ptr->rad));
- if(!strcmp(name,"rad2"))
- return (PyFloat_FromDouble(ptr->rad2));
- if(!strcmp(name,"s"))
- return (PyFloat_FromDouble(ptr->s));
- if(!strcmp(name,"len"))
- return (PyFloat_FromDouble(ptr->len));
-
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "unknown name "));
-}
-
-
-
-static PyObject *Metaball_setMetadata(BPy_Metaball *self,PyObject*args)
-{
- int num;
- int i = 0;
- char*name = NULL;
- int intval=-1;
- float floatval=0;
+ if( !PyArg_ParseTuple( args, "si", &name, &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected (string int) argument" ) );
+ /*jump to the num-th MetaElem */
+ ptr = self->metaball->elems.first;
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "no metaelem found" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "metaelem not found" ) );
+ ptr = ptr->next;
+ }
+ if( !strcmp( name, "type" ) )
+ return ( PyInt_FromLong( ptr->type ) );
+ if( !strcmp( name, "x" ) )
+ return ( PyFloat_FromDouble( ptr->x ) );
+ if( !strcmp( name, "y" ) )
+ return ( PyFloat_FromDouble( ptr->y ) );
+ if( !strcmp( name, "z" ) )
+ return ( PyFloat_FromDouble( ptr->z ) );
+ if( !strcmp( name, "expx" ) )
+ return ( PyFloat_FromDouble( ptr->expx ) );
+ if( !strcmp( name, "expy" ) )
+ return ( PyFloat_FromDouble( ptr->expy ) );
+ if( !strcmp( name, "expz" ) )
+ return ( PyFloat_FromDouble( ptr->expz ) );
+ if( !strcmp( name, "rad" ) )
+ return ( PyFloat_FromDouble( ptr->rad ) );
+ if( !strcmp( name, "rad2" ) )
+ return ( PyFloat_FromDouble( ptr->rad2 ) );
+ if( !strcmp( name, "s" ) )
+ return ( PyFloat_FromDouble( ptr->s ) );
+ if( !strcmp( name, "len" ) )
+ return ( PyFloat_FromDouble( ptr->len ) );
+
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError, "unknown name " ) );
+}
+
+
+
+static PyObject *Metaball_setMetadata( BPy_Metaball * self, PyObject * args )
+{
+ int num;
+ int i = 0;
+ char *name = NULL;
+ int intval = -1;
+ float floatval = 0;
MetaElem *ptr;
- if (!PyArg_ParseTuple(args, "sif", &name,&num,&floatval))
-return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string, int, float arguments"));
- intval = (int)floatval;
- printf("%f %d %s %d\n",floatval,intval,name,num);
- /*jump to the num-th MetaElem*/
- ptr = self->metaball->elems.first;
- if(!ptr)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "metaelem not found"));
- for(i = 0;i<num;i++)
- {
- if(!ptr)
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "metaelem not found"));
- ptr = ptr->next;
- }
- if(!strcmp(name,"type"))
- {ptr->type=intval;return (PyInt_FromLong(intval));}
- if(!strcmp(name,"x"))
- {ptr->x=floatval;printf("%p %f\n",ptr,floatval);return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"y"))
- {ptr->y=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"z"))
- {ptr->z=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"expx"))
- {ptr->expx=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"expy"))
- {ptr->expy=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"expz"))
- {ptr->expz=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"rad"))
- {ptr->rad=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"rad2"))
- {ptr->rad2=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"s"))
- {ptr->s=floatval;return (PyFloat_FromDouble(floatval));}
- if(!strcmp(name,"len"))
- {ptr->len=floatval;return (PyFloat_FromDouble(floatval));}
-
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "unknown field "));
-}
-
-static PyObject *Metaball_getMetatype(BPy_Metaball *self,PyObject*args)
-{
- int num;
- int i = 0;
- MetaElem*ptr = self->metaball->elems.first;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, \
- "expected int argument"));
- if(!ptr) return (PyInt_FromLong(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyInt_FromLong(ptr->type));
-}
-
-
-
-static PyObject *Metaball_setMetatype(BPy_Metaball *self,PyObject*args)
-{
- int num,val, i = 0;
- MetaElem*ptr = self->metaball->elems.first;
- if (!PyArg_ParseTuple(args, "ii", &num,&val))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected int int arguments"));
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->type = val;
-
- Py_INCREF(Py_None);
- return Py_None;
-
-}
-
-
-static PyObject *Metaball_getMetax(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num;
- int i = 0;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- if(!ptr) return (PyFloat_FromDouble(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyFloat_FromDouble(ptr->x));
-}
-
-
-
-static PyObject *Metaball_setMetax(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num, i = 0;
- float val;
- if (!PyArg_ParseTuple(args, "if", &num,&val))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected int float args"));
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->x = val;
-
- Py_INCREF(Py_None);
- return Py_None;
-
-}
-static PyObject *Metaball_getMetay(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num;
- int i = 0;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- if(!ptr) return (PyFloat_FromDouble(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyFloat_FromDouble(ptr->y));
+ if( !PyArg_ParseTuple( args, "sif", &name, &num, &floatval ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected string, int, float arguments" ) );
+ intval = ( int ) floatval;
+ printf( "%f %d %s %d\n", floatval, intval, name, num );
+ /*jump to the num-th MetaElem */
+ ptr = self->metaball->elems.first;
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "metaelem not found" ) );
+ for( i = 0; i < num; i++ ) {
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "metaelem not found" ) );
+ ptr = ptr->next;
+ }
+ if( !strcmp( name, "type" ) ) {
+ ptr->type = intval;
+ return ( PyInt_FromLong( intval ) );
+ }
+ if( !strcmp( name, "x" ) ) {
+ ptr->x = floatval;
+ printf( "%p %f\n", ptr, floatval );
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "y" ) ) {
+ ptr->y = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "z" ) ) {
+ ptr->z = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "expx" ) ) {
+ ptr->expx = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "expy" ) ) {
+ ptr->expy = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "expz" ) ) {
+ ptr->expz = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "rad" ) ) {
+ ptr->rad = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "rad2" ) ) {
+ ptr->rad2 = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "s" ) ) {
+ ptr->s = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+ if( !strcmp( name, "len" ) ) {
+ ptr->len = floatval;
+ return ( PyFloat_FromDouble( floatval ) );
+ }
+
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError, "unknown field " ) );
+}
+
+static PyObject *Metaball_getMetatype( BPy_Metaball * self, PyObject * args )
+{
+ int num;
+ int i = 0;
+ MetaElem *ptr = self->metaball->elems.first;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
+ if( !ptr )
+ return ( PyInt_FromLong( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyInt_FromLong( ptr->type ) );
+}
+
+
+
+static PyObject *Metaball_setMetatype( BPy_Metaball * self, PyObject * args )
+{
+ int num, val, i = 0;
+ MetaElem *ptr = self->metaball->elems.first;
+ if( !PyArg_ParseTuple( args, "ii", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int int arguments" ) );
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->type = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+
}
+static PyObject *Metaball_getMetax( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num;
+ int i = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ if( !ptr )
+ return ( PyFloat_FromDouble( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyFloat_FromDouble( ptr->x ) );
+}
-static PyObject *Metaball_setMetay(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num, i = 0;
- float val;
- if (!PyArg_ParseTuple(args, "if", &num,&val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int float args"));
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->y = val;
- Py_INCREF(Py_None);
- return Py_None;
+static PyObject *Metaball_setMetax( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num, i = 0;
+ float val;
+ if( !PyArg_ParseTuple( args, "if", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int float args" ) );
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->x = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+
+}
+static PyObject *Metaball_getMetay( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num;
+ int i = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ if( !ptr )
+ return ( PyFloat_FromDouble( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyFloat_FromDouble( ptr->y ) );
}
-static PyObject *Metaball_getMetaz(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num;
- int i = 0;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- if(!ptr) return (PyFloat_FromDouble(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyFloat_FromDouble(ptr->z));
+
+static PyObject *Metaball_setMetay( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num, i = 0;
+ float val;
+ if( !PyArg_ParseTuple( args, "if", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int float args" ) );
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->y = val;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+
+}
+
+
+static PyObject *Metaball_getMetaz( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num;
+ int i = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ if( !ptr )
+ return ( PyFloat_FromDouble( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyFloat_FromDouble( ptr->z ) );
}
-static PyObject *Metaball_setMetaz(BPy_Metaball *self,PyObject*args)
-{
- int num, i = 0;
- MetaElem*ptr = self->metaball->elems.first;
- float val;
- if (!PyArg_ParseTuple(args, "if", &num,&val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int float args"));
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->z = val;
+static PyObject *Metaball_setMetaz( BPy_Metaball * self, PyObject * args )
+{
+ int num, i = 0;
+ MetaElem *ptr = self->metaball->elems.first;
+ float val;
+ if( !PyArg_ParseTuple( args, "if", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int float args" ) );
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->z = val;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaball_getMetas(BPy_Metaball *self,PyObject*args)
-{
- MetaElem*ptr = self->metaball->elems.first;
- int num;
- int i = 0;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- if(!ptr) return (PyFloat_FromDouble(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyFloat_FromDouble(ptr->s));
+static PyObject *Metaball_getMetas( BPy_Metaball * self, PyObject * args )
+{
+ MetaElem *ptr = self->metaball->elems.first;
+ int num;
+ int i = 0;
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ if( !ptr )
+ return ( PyFloat_FromDouble( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyFloat_FromDouble( ptr->s ) );
}
-static PyObject *Metaball_setMetas(BPy_Metaball *self,PyObject*args)
-{
- int num, i = 0;
- MetaElem*ptr = self->metaball->elems.first;
- float val;
- if (!PyArg_ParseTuple(args, "if", &num,&val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int float args"));
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->s = val;
+static PyObject *Metaball_setMetas( BPy_Metaball * self, PyObject * args )
+{
+ int num, i = 0;
+ MetaElem *ptr = self->metaball->elems.first;
+ float val;
+ if( !PyArg_ParseTuple( args, "if", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int float args" ) );
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->s = val;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
@@ -737,58 +834,67 @@ static PyObject *Metaball_setMetas(BPy_Metaball *self,PyObject*args)
-static PyObject *Metaball_getMetalen(BPy_Metaball *self,PyObject*args)
-{
- int num;
- int i = 0;
+static PyObject *Metaball_getMetalen( BPy_Metaball * self, PyObject * args )
+{
+ int num;
+ int i = 0;
MetaElem *ptr;
- if (!PyArg_ParseTuple(args, "i", &num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
- ptr = self->metaball->elems.first;
- if(!ptr) return (PyFloat_FromDouble(0));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- return (PyFloat_FromDouble(ptr->len));
+ if( !PyArg_ParseTuple( args, "i", &num ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int argument" ) );
+ ptr = self->metaball->elems.first;
+ if( !ptr )
+ return ( PyFloat_FromDouble( 0 ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ return ( PyFloat_FromDouble( ptr->len ) );
}
-static PyObject *Metaball_setMetalen(BPy_Metaball *self,PyObject*args)
-{
- int num, i = 0;
- float val;
+static PyObject *Metaball_setMetalen( BPy_Metaball * self, PyObject * args )
+{
+ int num, i = 0;
+ float val;
MetaElem *ptr;
- if (!PyArg_ParseTuple(args, "if", &num,&val))
- return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int float args"));
- ptr = self->metaball->elems.first;
- if(!ptr) return (EXPP_ReturnPyObjError (PyExc_TypeError, "No MetaElem"));
- for(i = 0;i<num;i++){ptr = ptr->next;}
- ptr->len = val;
+ if( !PyArg_ParseTuple( args, "if", &num, &val ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected int float args" ) );
+ ptr = self->metaball->elems.first;
+ if( !ptr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "No MetaElem" ) );
+ for( i = 0; i < num; i++ ) {
+ ptr = ptr->next;
+ }
+ ptr->len = val;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: MetaballDeAlloc */
-/* Description: This is a callback function for the BPy_Metaball type. It is */
+/* Description: This is a callback function for the BPy_Metaball type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void MetaballDeAlloc (BPy_Metaball *self)
+static void MetaballDeAlloc( BPy_Metaball * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
/* Function: MetaelemDeAlloc */
-/* Description: This is a callback function for the BPy_Metaelem type. It is */
+/* Description: This is a callback function for the BPy_Metaelem type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void MetaelemDeAlloc (BPy_Metaelem *self)
+static void MetaelemDeAlloc( BPy_Metaelem * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
@@ -796,58 +902,60 @@ static void MetaelemDeAlloc (BPy_Metaelem *self)
/*****************************************************************************/
/* Function: MetaballGetAttr */
-/* Description: This is a callback function for the BPy_Metaball type. It is */
-/* the function that accesses BPy_Metaball "member variables" and */
-/* methods. */
+/* Description: This is a callback function for the BPy_Metaball type. It is */
+/* the function that accesses BPy_Metaball "member variables" */
+/* and methods. */
/*****************************************************************************/
-static PyObject *MetaballGetAttr (BPy_Metaball *self, char *name)
+static PyObject *MetaballGetAttr( BPy_Metaball * self, char *name )
{
-if (strcmp (name, "name") == 0)return Metaball_getName (self);
-if (strcmp (name, "rot") == 0)return Metaball_getrot (self);
-if (strcmp (name, "loc") == 0)return Metaball_getloc (self);
-if (strcmp (name, "size") == 0)return Metaball_getsize (self);
- return Py_FindMethod(BPy_Metaball_methods, (PyObject *)self, name);
+ if( strcmp( name, "name" ) == 0 )
+ return Metaball_getName( self );
+ if( strcmp( name, "rot" ) == 0 )
+ return Metaball_getrot( self );
+ if( strcmp( name, "loc" ) == 0 )
+ return Metaball_getloc( self );
+ if( strcmp( name, "size" ) == 0 )
+ return Metaball_getsize( self );
+ return Py_FindMethod( BPy_Metaball_methods, ( PyObject * ) self,
+ name );
}
-/*******************************************************************************/
-/* Function: MetaballSetAttr */
-/* Description: This is a callback function for the BPy_Metaball type. It is the */
-/* function that sets Metaball Data attributes (member variables).*/
-/*******************************************************************************/
-static int MetaballSetAttr (BPy_Metaball *self, char *name, PyObject *value)
+/****************************************************************************/
+/* Function: MetaballSetAttr */
+/* Description: This is a callback function for the BPy_Metaball type. */
+/* It sets Metaball Data attributes (member variables).*/
+/****************************************************************************/
+static int MetaballSetAttr( BPy_Metaball * self, char *name, PyObject * value )
{
- PyObject *valtuple = Py_BuildValue("(O)", value);
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "MetaballSetAttr: couldn't create PyTuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "MetaballSetAttr: couldn't create PyTuple" );
- if (strcmp (name, "name") == 0)
- {
- Metaball_setName (self, valtuple);
- return 0;
- }
+ if( strcmp( name, "name" ) == 0 ) {
+ Metaball_setName( self, valtuple );
+ return 0;
+ }
- if (strcmp (name, "rot") == 0)
- {
- Metaball_setrot (self, valtuple);
- return 0;
- }
- if (strcmp (name, "loc") == 0)
- {
- Metaball_setloc (self, valtuple);
- return 0;
- }
-
- if (strcmp (name, "size") == 0)
- {
- Metaball_setsize (self, valtuple);
- return 0;
- }
- return (EXPP_ReturnIntError (PyExc_KeyError,"attribute not found"));
+ if( strcmp( name, "rot" ) == 0 ) {
+ Metaball_setrot( self, valtuple );
+ return 0;
+ }
+ if( strcmp( name, "loc" ) == 0 ) {
+ Metaball_setloc( self, valtuple );
+ return 0;
+ }
+
+ if( strcmp( name, "size" ) == 0 ) {
+ Metaball_setsize( self, valtuple );
+ return 0;
+ }
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
}
@@ -857,133 +965,142 @@ static int MetaballSetAttr (BPy_Metaball *self, char *name, PyObject *value)
-static PyObject *Metaelem_getdims(BPy_Metaelem *self)
+static PyObject *Metaelem_getdims( BPy_Metaelem * self )
{
- PyObject* l = PyList_New(0);
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->expx));
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->expy));
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->expz));
- return l;
+ PyObject *l = PyList_New( 0 );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->expx ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->expy ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->expz ) );
+ return l;
}
-static PyObject *Metaelem_setdims(BPy_Metaelem *self,PyObject*args)
+static PyObject *Metaelem_setdims( BPy_Metaelem * self, PyObject * args )
{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- self->metaelem->expx = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->metaelem->expy = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->metaelem->expz = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- Py_INCREF(Py_None);
- return Py_None;
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ self->metaelem->expx =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->metaelem->expy =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->metaelem->expz =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Metaelem_getcoords(BPy_Metaelem *self)
+static PyObject *Metaelem_getcoords( BPy_Metaelem * self )
{
- PyObject* l = PyList_New(0);
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->x));
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->y));
- PyList_Append( l, PyFloat_FromDouble(self->metaelem->z));
- return l;
+ PyObject *l = PyList_New( 0 );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->x ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->y ) );
+ PyList_Append( l, PyFloat_FromDouble( self->metaelem->z ) );
+ return l;
}
-static PyObject *Metaelem_setcoords(BPy_Metaelem *self,PyObject*args)
+static PyObject *Metaelem_setcoords( BPy_Metaelem * self, PyObject * args )
{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list"));
- self->metaelem->x = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->metaelem->y = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->metaelem->z = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- Py_INCREF(Py_None);
- return Py_None;
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list" ) );
+ self->metaelem->x = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->metaelem->y = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->metaelem->z = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ Py_INCREF( Py_None );
+ return Py_None;
}
+/***************************************************************************/
+/* Function: MetaelemGetAttr */
+/* Description: This is a callback function for the BPy_Metaelem type. */
+/* It accesses BPy_Metaelem "member variables". */
/*****************************************************************************/
-/* Function: MetaelemGetAttr */
-/* Description: This is a callback function for the BPy_Metaelem type. It is */
-/* the function that accesses BPy_Metaelem "member variables" and */
-/* methods. */
-/*****************************************************************************/
-static PyObject *MetaelemGetAttr (BPy_Metaelem *self, char *name)
+static PyObject *MetaelemGetAttr( BPy_Metaelem * self, char *name )
{
-if (!strcmp (name, "dims") )return Metaelem_getdims (self);
-if (!strcmp (name, "coords") )return Metaelem_getcoords (self);
-if (!strcmp (name, "rad") )return PyFloat_FromDouble(self->metaelem->rad);
-if (!strcmp (name, "stif") )return PyFloat_FromDouble(self->metaelem->s);
- return Py_FindMethod(BPy_Metaelem_methods, (PyObject *)self, name);
+ if( !strcmp( name, "dims" ) )
+ return Metaelem_getdims( self );
+ if( !strcmp( name, "coords" ) )
+ return Metaelem_getcoords( self );
+ if( !strcmp( name, "rad" ) )
+ return PyFloat_FromDouble( self->metaelem->rad );
+ if( !strcmp( name, "stif" ) )
+ return PyFloat_FromDouble( self->metaelem->s );
+ return Py_FindMethod( BPy_Metaelem_methods, ( PyObject * ) self,
+ name );
}
-/*******************************************************************************/
-/* Function: MetaelemSetAttr */
-/* Description: This is a callback function for the BPy_Metaelem type. It is the */
-/* function that sets Metaelem Data attributes (member variables).*/
-/*******************************************************************************/
-static int MetaelemSetAttr (BPy_Metaelem *self, char *name, PyObject *value)
+/*****************************************************************************/
+/* Function: MetaelemSetAttr */
+/* Description: This is a callback function for the BPy_Metaelem type. */
+/* It sets Metaelem Data attributes (member variables). */
+/****************************************************************************/
+static int MetaelemSetAttr( BPy_Metaelem * self, char *name, PyObject * value )
{
-
- if (!strcmp (name, "coords"))
- {
-PyObject *valtuple = Py_BuildValue("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,"MetaelemSetAttr: couldn't create PyTuple");
- Metaelem_setcoords (self, valtuple);
- return 0;
- }
- if (!strcmp (name, "dims"))
- {
-PyObject *valtuple = Py_BuildValue("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,"MetaelemSetAttr: couldn't create PyTuple");
- Metaelem_setdims (self, valtuple);
- return 0;
- }
- if (!strcmp (name, "rad"))
- {
- self->metaelem->rad = PyFloat_AsDouble(value);
- return 0;
- }
- if (!strcmp (name, "stif"))
- {
- self->metaelem->s = PyFloat_AsDouble(value);
- return 0;
- }
- return (EXPP_ReturnIntError (PyExc_KeyError,"attribute not found"));
+
+ if( !strcmp( name, "coords" ) ) {
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "MetaelemSetAttr: couldn't create PyTuple" );
+ Metaelem_setcoords( self, valtuple );
+ return 0;
+ }
+ if( !strcmp( name, "dims" ) ) {
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "MetaelemSetAttr: couldn't create PyTuple" );
+ Metaelem_setdims( self, valtuple );
+ return 0;
+ }
+ if( !strcmp( name, "rad" ) ) {
+ self->metaelem->rad = PyFloat_AsDouble( value );
+ return 0;
+ }
+ if( !strcmp( name, "stif" ) ) {
+ self->metaelem->s = PyFloat_AsDouble( value );
+ return 0;
+ }
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
}
-/*****************************************************************************/
-/* Function: MetaballRepr */
-/* Description: This is a callback function for the BPy_Metaball type. It */
-/* builds a meaninful string to represent metaball objects. */
-/*****************************************************************************/
-static PyObject *MetaballRepr (BPy_Metaball *self)
+/****************************************************************************/
+/* Function: MetaballRepr */
+/* Description: This is a callback function for the BPy_Metaball type. It */
+/* builds a meaninful string to represent metaball objects. */
+/****************************************************************************/
+static PyObject *MetaballRepr( BPy_Metaball * self )
{
- return PyString_FromFormat("[Metaball \"%s\"]", self->metaball->id.name+2);
+ return PyString_FromFormat( "[Metaball \"%s\"]",
+ self->metaball->id.name + 2 );
}
+/****************************************************************************/
+/* Function: MetaelemRepr */
+/* Description: This is a callback function for the BPy_Metaelem type. It */
+/* builds a meaninful string to represent metaelem objects. */
/*****************************************************************************/
-/* Function: MetaelemRepr */
-/* Description: This is a callback function for the BPy_Metaelem type. It */
-/* builds a meaninful string to represent metaelem objects. */
-/*****************************************************************************/
-static PyObject *MetaelemRepr (BPy_Metaelem *self)
+static PyObject *MetaelemRepr( BPy_Metaelem * self )
{
- return PyString_FromString("Metaelem");
+ return PyString_FromString( "Metaelem" );
}
-
-
diff --git a/source/blender/python/api2_2x/Metaball.h b/source/blender/python/api2_2x/Metaball.h
index 65b33a96a68..2d91cdc2dd7 100644
--- a/source/blender/python/api2_2x/Metaball.h
+++ b/source/blender/python/api2_2x/Metaball.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -48,169 +49,170 @@
/*****************************************************************************/
-/* Python API function prototypes for the Metaball module. */
+/* Python API function prototypes for the Metaball module. */
/*****************************************************************************/
-static PyObject *M_Metaball_New (PyObject *self, PyObject *args);
-static PyObject *M_Metaball_Get (PyObject *self, PyObject *args);
+static PyObject *M_Metaball_New( PyObject * self, PyObject * args );
+static PyObject *M_Metaball_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
-/* Blender.Metaball.__doc__ */
+/* Blender.Metaball.__doc__ */
/*****************************************************************************/
static char M_Metaball_doc[] =
-"The Blender Metaball module\n\n\nMetaballs are spheres\
+ "The Blender Metaball module\n\n\nMetaballs are spheres\
that can join each other to create smooth,\
organic volumes\n. The spheres themseves are called\
'Metaelements' and can be accessed from the Metaball module.";
-static char M_Metaball_New_doc[] ="Creates a new metaball";
+static char M_Metaball_New_doc[] = "Creates a new metaball";
-static char M_Metaball_Get_doc[] ="Retreives an existing metaball";
+static char M_Metaball_Get_doc[] = "Retreives an existing metaball";
/*****************************************************************************/
-/* Python method structure definition for Blender.Metaball module: */
+/* Python method structure definition for Blender.Metaball module: */
/*****************************************************************************/
struct PyMethodDef M_Metaball_methods[] = {
- {"New",M_Metaball_New, METH_VARARGS,M_Metaball_New_doc},
- {"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
- {"get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", M_Metaball_New, METH_VARARGS, M_Metaball_New_doc},
+ {"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
+ {"get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BPy_Metaball methods declarations: */
-/*****************************************************************************/
-static PyObject *Metaball_getMetaElemList(BPy_Metaball *self);
-static PyObject *Metaball_addMetaelem(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getBbox(BPy_Metaball *self);
-static PyObject *Metaball_getName(BPy_Metaball *self);
-static PyObject *Metaball_setName(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getWiresize(BPy_Metaball *self);
-static PyObject *Metaball_setWiresize(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getRendersize(BPy_Metaball *self);
-static PyObject *Metaball_setRendersize(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getThresh(BPy_Metaball *self);
-static PyObject *Metaball_setThresh(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getNMetaElems(BPy_Metaball *self);
-static PyObject *Metaball_getMetatype(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetatype(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetadata(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetadata(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetax(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetax(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetay(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetay(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetaz(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetaz(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetas(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetas(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getMetalen(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_setMetalen(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getloc(BPy_Metaball *self);
-static PyObject *Metaball_setloc(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getrot(BPy_Metaball *self);
-static PyObject *Metaball_setrot(BPy_Metaball *self,PyObject*args);
-static PyObject *Metaball_getsize(BPy_Metaball *self);
-static PyObject *Metaball_setsize(BPy_Metaball *self,PyObject*args);
-
-/*****************************************************************************/
-/* Python BPy_Metaball methods table: */
+/* Python BPy_Metaball methods declarations: */
+/*****************************************************************************/
+static PyObject *Metaball_getMetaElemList( BPy_Metaball * self );
+static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getBbox( BPy_Metaball * self );
+static PyObject *Metaball_getName( BPy_Metaball * self );
+static PyObject *Metaball_setName( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getWiresize( BPy_Metaball * self );
+static PyObject *Metaball_setWiresize( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getRendersize( BPy_Metaball * self );
+static PyObject *Metaball_setRendersize( BPy_Metaball * self,
+ PyObject * args );
+static PyObject *Metaball_getThresh( BPy_Metaball * self );
+static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getNMetaElems( BPy_Metaball * self );
+static PyObject *Metaball_getMetatype( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetatype( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetadata( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetadata( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetax( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetax( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetay( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetay( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetaz( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetaz( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetas( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetas( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetalen( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetalen( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getloc( BPy_Metaball * self );
+static PyObject *Metaball_setloc( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getrot( BPy_Metaball * self );
+static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getsize( BPy_Metaball * self );
+static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args );
+
+/*****************************************************************************/
+/* Python BPy_Metaball methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Metaball_methods[] = {
/* name, method, flags, doc */
- {"getName", (PyCFunction)Metaball_getName,\
- METH_NOARGS, "() - Return Metaball name"},
+ {"getName", ( PyCFunction ) Metaball_getName,
+ METH_NOARGS, "() - Return Metaball name"},
- {"getMetaElemList", (PyCFunction)Metaball_getMetaElemList,\
- METH_NOARGS, "() - Return Metaelems list"},
+ {"getMetaElemList", ( PyCFunction ) Metaball_getMetaElemList,
+ METH_NOARGS, "() - Return Metaelems list"},
- {"addMetaelem", (PyCFunction)Metaball_addMetaelem,\
- METH_VARARGS, "() -Adds a metaelem to the metaball"},
- {"setName", (PyCFunction)Metaball_setName,\
+ {"addMetaelem", ( PyCFunction ) Metaball_addMetaelem,
+ METH_VARARGS, "() -Adds a metaelem to the metaball"},
+ {"setName", ( PyCFunction ) Metaball_setName,
METH_VARARGS, "() - Sets Metaball name"},
- {"getWiresize", (PyCFunction)Metaball_getWiresize,\
- METH_NOARGS, "() - Return Metaball wire size"},
- {"setWiresize", (PyCFunction)Metaball_setWiresize,\
+ {"getWiresize", ( PyCFunction ) Metaball_getWiresize,
+ METH_NOARGS, "() - Return Metaball wire size"},
+ {"setWiresize", ( PyCFunction ) Metaball_setWiresize,
METH_VARARGS, "() - Sets Metaball wire size"},
- {"getRendersize", (PyCFunction)Metaball_getRendersize,\
- METH_NOARGS, "() - Return Metaball render size"},
- {"setRendersize", (PyCFunction)Metaball_setRendersize,\
+ {"getRendersize", ( PyCFunction ) Metaball_getRendersize,
+ METH_NOARGS, "() - Return Metaball render size"},
+ {"setRendersize", ( PyCFunction ) Metaball_setRendersize,
METH_VARARGS, "() - Sets Metaball render size"},
- {"getThresh", (PyCFunction)Metaball_getThresh,\
- METH_NOARGS, "() - Return Metaball threshold"},
- {"setThresh", (PyCFunction)Metaball_setThresh,\
- METH_VARARGS, "() - Sets Metaball threshold"},
- {"getBbox", (PyCFunction)Metaball_getBbox,\
- METH_NOARGS, "() - Return Metaball bounding box"},
- {"getNMetaElems",(PyCFunction)Metaball_getNMetaElems,\
+ {"getThresh", ( PyCFunction ) Metaball_getThresh,
+ METH_NOARGS, "() - Return Metaball threshold"},
+ {"setThresh", ( PyCFunction ) Metaball_setThresh,
+ METH_VARARGS, "() - Sets Metaball threshold"},
+ {"getBbox", ( PyCFunction ) Metaball_getBbox,
+ METH_NOARGS, "() - Return Metaball bounding box"},
+ {"getNMetaElems", ( PyCFunction ) Metaball_getNMetaElems,
METH_NOARGS, "() Returns the number of Spheres "},
- {"getMetatype", (PyCFunction)Metaball_getMetatype , \
+ {"getMetatype", ( PyCFunction ) Metaball_getMetatype,
METH_VARARGS, "() - "},
- {"setMetatype", (PyCFunction)Metaball_setMetatype , \
+ {"setMetatype", ( PyCFunction ) Metaball_setMetatype,
METH_VARARGS, "() - "},
- {"getMetadata", (PyCFunction)Metaball_getMetadata , \
+ {"getMetadata", ( PyCFunction ) Metaball_getMetadata,
METH_VARARGS, "() - Gets Metaball MetaData "},
- {"setMetadata", (PyCFunction)Metaball_setMetadata , \
+ {"setMetadata", ( PyCFunction ) Metaball_setMetadata,
METH_VARARGS, "() - "},
- {"getMetax", (PyCFunction)Metaball_getMetax , \
+ {"getMetax", ( PyCFunction ) Metaball_getMetax,
METH_VARARGS, "() - gets the x coordinate of the metaelement "},
- {"setMetax", (PyCFunction)Metaball_setMetax , \
+ {"setMetax", ( PyCFunction ) Metaball_setMetax,
METH_VARARGS, "() -sets the x coordinate of the metaelement "},
- {"getMetay", (PyCFunction)Metaball_getMetay , \
+ {"getMetay", ( PyCFunction ) Metaball_getMetay,
METH_VARARGS, "() - gets the y coordinate of the metaelement"},
- {"setMetay", (PyCFunction)Metaball_setMetay , \
+ {"setMetay", ( PyCFunction ) Metaball_setMetay,
METH_VARARGS, "() - sets the y coordinate of the metaelement"},
- {"getMetaz", (PyCFunction)Metaball_getMetaz , \
+ {"getMetaz", ( PyCFunction ) Metaball_getMetaz,
METH_VARARGS, "() - gets the z coordinate of the metaelement"},
- {"setMetaz", (PyCFunction)Metaball_setMetaz , \
- METH_VARARGS, "() - sets the z coordinate of the metaelement"},
- {"getMetas", (PyCFunction)Metaball_getMetas , \
+ {"setMetaz", ( PyCFunction ) Metaball_setMetaz,
+ METH_VARARGS, "() - sets the z coordinate of the metaelement"},
+ {"getMetas", ( PyCFunction ) Metaball_getMetas,
METH_VARARGS, "() - gets the s coordinate of the metaelement"},
- {"setMetas", (PyCFunction)Metaball_setMetas , \
+ {"setMetas", ( PyCFunction ) Metaball_setMetas,
METH_VARARGS, "() - sets the s coordinate of the metaelement"},
- {"getMetalen", (PyCFunction)Metaball_getMetalen , \
+ {"getMetalen", ( PyCFunction ) Metaball_getMetalen,
METH_VARARGS, "() - gets the length of the metaelement."},
- {"setMetalen", (PyCFunction)Metaball_setMetalen , \
+ {"setMetalen", ( PyCFunction ) Metaball_setMetalen,
METH_VARARGS, "() - sets the length of the metaelement."},
- {"getloc", (PyCFunction)Metaball_getloc , \
+ {"getloc", ( PyCFunction ) Metaball_getloc,
METH_NOARGS, "() - Gets Metaball loc values"},
- {"setloc", (PyCFunction)Metaball_setloc , \
+ {"setloc", ( PyCFunction ) Metaball_setloc,
METH_VARARGS, "(f f f) - Sets Metaball loc values"},
- {"getrot", (PyCFunction)Metaball_getrot , \
+ {"getrot", ( PyCFunction ) Metaball_getrot,
METH_NOARGS, "() - Gets Metaball rot values"},
- {"setrot", (PyCFunction)Metaball_setrot , \
+ {"setrot", ( PyCFunction ) Metaball_setrot,
METH_VARARGS, "(f f f) - Sets Metaball rot values"},
- {"getsize", (PyCFunction)Metaball_getsize , \
+ {"getsize", ( PyCFunction ) Metaball_getsize,
METH_NOARGS, "() - Gets Metaball size values"},
- {"setsize", (PyCFunction)Metaball_setsize , \
+ {"setsize", ( PyCFunction ) Metaball_setsize,
METH_VARARGS, "(f f f) - Sets Metaball size values"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BPy_Metaelem methods table: */
+/* Python BPy_Metaelem methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Metaelem_methods[] = {
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Metaball_Type callback function prototypes: */
+/* Python Metaball_Type callback function prototypes: */
/*****************************************************************************/
-static void MetaballDeAlloc (BPy_Metaball *self);
-static int MetaballSetAttr (BPy_Metaball *self, char *name, PyObject *v);
-static PyObject *MetaballGetAttr (BPy_Metaball *self, char *name);
-static PyObject *MetaballRepr (BPy_Metaball *self);
+static void MetaballDeAlloc( BPy_Metaball * self );
+static int MetaballSetAttr( BPy_Metaball * self, char *name, PyObject * v );
+static PyObject *MetaballGetAttr( BPy_Metaball * self, char *name );
+static PyObject *MetaballRepr( BPy_Metaball * self );
/*****************************************************************************/
-/* Python Metaelem_Type callback function prototypes: */
+/* Python Metaelem_Type callback function prototypes: */
/*****************************************************************************/
-static void MetaelemDeAlloc (BPy_Metaelem *self);
-static int MetaelemSetAttr (BPy_Metaelem *self, char *name, PyObject *v);
-static PyObject *MetaelemGetAttr (BPy_Metaelem *self, char *name);
-static PyObject *MetaelemRepr (BPy_Metaelem *self);
+static void MetaelemDeAlloc( BPy_Metaelem * self );
+static int MetaelemSetAttr( BPy_Metaelem * self, char *name, PyObject * v );
+static PyObject *MetaelemGetAttr( BPy_Metaelem * self, char *name );
+static PyObject *MetaelemRepr( BPy_Metaelem * self );
-#endif /* EXPP_METABALL_H */
+#endif /* EXPP_METABALL_H */
diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c
index d10def75009..dce9db31a6e 100644
--- a/source/blender/python/api2_2x/NLA.c
+++ b/source/blender/python/api2_2x/NLA.c
@@ -40,430 +40,430 @@
/*****************************************************************************/
/* Python API function prototypes for the NLA module. */
/*****************************************************************************/
-static PyObject *M_NLA_NewAction (PyObject * self, PyObject * args);
-static PyObject *M_NLA_CopyAction (PyObject * self, PyObject * args);
-static PyObject *M_NLA_GetActions(PyObject* self);
+static PyObject *M_NLA_NewAction( PyObject * self, PyObject * args );
+static PyObject *M_NLA_CopyAction( PyObject * self, PyObject * args );
+static PyObject *M_NLA_GetActions( PyObject * self );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
+/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Armature.NLA.__doc__ */
/*****************************************************************************/
-char M_NLA_doc[] = "The Blender NLA module -This module provides control over Armature keyframing in Blender.";
-char M_NLA_NewAction_doc[] = "(name) - Create new action for linking to an object.";
+char M_NLA_doc[] =
+ "The Blender NLA module -This module provides control over Armature keyframing in Blender.";
+char M_NLA_NewAction_doc[] =
+ "(name) - Create new action for linking to an object.";
char M_NLA_CopyAction_doc[] = "(name) - Copy action and return copy.";
char M_NLA_GetActions_doc[] = "(name) - Returns a dictionary of actions.";
/*****************************************************************************/
-/* Python method structure definition for Blender.Armature.NLA module: */
+/* Python method structure definition for Blender.Armature.NLA module: */
/*****************************************************************************/
struct PyMethodDef M_NLA_methods[] = {
- {"NewAction", (PyCFunction) M_NLA_NewAction, METH_VARARGS,
- M_NLA_NewAction_doc},
- {"CopyAction", (PyCFunction) M_NLA_CopyAction, METH_VARARGS,
- M_NLA_CopyAction_doc},
- {"GetActions", (PyCFunction) M_NLA_GetActions, METH_NOARGS,
- M_NLA_GetActions_doc},
- {NULL, NULL, 0, NULL}
+ {"NewAction", ( PyCFunction ) M_NLA_NewAction, METH_VARARGS,
+ M_NLA_NewAction_doc},
+ {"CopyAction", ( PyCFunction ) M_NLA_CopyAction, METH_VARARGS,
+ M_NLA_CopyAction_doc},
+ {"GetActions", ( PyCFunction ) M_NLA_GetActions, METH_NOARGS,
+ M_NLA_GetActions_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BPy_Action methods declarations: */
+/* Python BPy_Action methods declarations: */
/*****************************************************************************/
-static PyObject *Action_getName (BPy_Action * self);
-static PyObject *Action_setName (BPy_Action * self, PyObject * args);
-static PyObject *Action_setActive (BPy_Action * self, PyObject * args);
-static PyObject *Action_getChannelIpo(BPy_Action * self, PyObject * args);
-static PyObject *Action_removeChannel(BPy_Action * self, PyObject * args);
-static PyObject *Action_getAllChannelIpos(BPy_Action*self);
+static PyObject *Action_getName( BPy_Action * self );
+static PyObject *Action_setName( BPy_Action * self, PyObject * args );
+static PyObject *Action_setActive( BPy_Action * self, PyObject * args );
+static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args );
+static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args );
+static PyObject *Action_getAllChannelIpos( BPy_Action * self );
/*****************************************************************************/
/* Python BPy_Action methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Action_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction) Action_getName, METH_NOARGS,
- "() - return Action name"},
- {"setName", (PyCFunction) Action_setName, METH_VARARGS,
- "(str) - rename Action"},
- {"setActive", (PyCFunction) Action_setActive, METH_VARARGS,
- "(str) -set this action as the active action for an object"},
- {"getChannelIpo", (PyCFunction) Action_getChannelIpo, METH_VARARGS,
- "(str) -get the Ipo from a named action channel in this action"},
- {"removeChannel", (PyCFunction) Action_removeChannel, METH_VARARGS,
- "(str) -remove the channel from the action"},
- {"getAllChannelIpos", (PyCFunction)Action_getAllChannelIpos, METH_NOARGS,
- "() - Return a dict of (name:ipo)-keys containing each channel in the object's action"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Action_getName, METH_NOARGS,
+ "() - return Action name"},
+ {"setName", ( PyCFunction ) Action_setName, METH_VARARGS,
+ "(str) - rename Action"},
+ {"setActive", ( PyCFunction ) Action_setActive, METH_VARARGS,
+ "(str) -set this action as the active action for an object"},
+ {"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_VARARGS,
+ "(str) -get the Ipo from a named action channel in this action"},
+ {"removeChannel", ( PyCFunction ) Action_removeChannel, METH_VARARGS,
+ "(str) -remove the channel from the action"},
+ {"getAllChannelIpos", ( PyCFunction ) Action_getAllChannelIpos,
+ METH_NOARGS,
+ "() - Return a dict of (name:ipo)-keys containing each channel in the object's action"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python TypeAction callback function prototypes: */
+/* Python TypeAction callback function prototypes: */
/*****************************************************************************/
-static void Action_dealloc (BPy_Action * bone);
-static PyObject *Action_getAttr (BPy_Action * bone, char *name);
-static int Action_setAttr (BPy_Action * bone, char *name, PyObject * v);
-static PyObject *Action_repr (BPy_Action * bone);
+static void Action_dealloc( BPy_Action * bone );
+static PyObject *Action_getAttr( BPy_Action * bone, char *name );
+static int Action_setAttr( BPy_Action * bone, char *name, PyObject * v );
+static PyObject *Action_repr( BPy_Action * bone );
/*****************************************************************************/
/* Python TypeAction structure definition: */
/*****************************************************************************/
PyTypeObject Action_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Action", /* tp_name */
- sizeof (BPy_Action), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) Action_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Action_getAttr, /* tp_getattr */
- (setattrfunc) Action_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) Action_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_Action_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Action", /* tp_name */
+ sizeof( BPy_Action ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Action_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Action_getAttr, /* tp_getattr */
+ ( setattrfunc ) Action_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) Action_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_Action_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//-------------------------------------------------------------------------------------------------------------------------------
-static PyObject *
-M_NLA_NewAction (PyObject * self, PyObject * args)
+//-------------------------------------------------------------------------
+static PyObject *M_NLA_NewAction( PyObject * self, PyObject * args )
{
- char *name_str = "DefaultAction";
- BPy_Action *py_action = NULL; /* for Action Data object wrapper in Python */
- bAction *bl_action = NULL; /* for actual Action Data we create in Blender */
-
- if (!PyArg_ParseTuple (args, "|s", &name_str)){
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string or nothing");
- return NULL;
- }
-
- //Create new action globally
- bl_action = alloc_libblock(&G.main->action, ID_AC, name_str);
- bl_action->id.flag |= LIB_FAKEUSER;
- bl_action->id.us++;
-
- // now create the wrapper obj in Python
- if (bl_action)
- py_action = (BPy_Action *) PyObject_NEW (BPy_Action, &Action_Type);
- else{
- EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Action Data in Blender");
- return NULL;
- }
-
- if (py_action == NULL){
- EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Action Data object");
- return NULL;
- }
-
- py_action->action = bl_action; // link Python action wrapper with Blender Action
-
- Py_INCREF(py_action);
- return (PyObject *) py_action;
+ char *name_str = "DefaultAction";
+ BPy_Action *py_action = NULL; /* for Action Data object wrapper in Python */
+ bAction *bl_action = NULL; /* for actual Action Data we create in Blender */
+
+ if( !PyArg_ParseTuple( args, "|s", &name_str ) ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string or nothing" );
+ return NULL;
+ }
+ //Create new action globally
+ bl_action = alloc_libblock( &G.main->action, ID_AC, name_str );
+ bl_action->id.flag |= LIB_FAKEUSER;
+ bl_action->id.us++;
+
+ // now create the wrapper obj in Python
+ if( bl_action )
+ py_action =
+ ( BPy_Action * ) PyObject_NEW( BPy_Action,
+ &Action_Type );
+ else {
+ EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Action Data in Blender" );
+ return NULL;
+ }
+
+ if( py_action == NULL ) {
+ EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Action Data object" );
+ return NULL;
+ }
+
+ py_action->action = bl_action; // link Python action wrapper with Blender Action
+
+ Py_INCREF( py_action );
+ return ( PyObject * ) py_action;
}
-static PyObject *
-M_NLA_CopyAction(PyObject* self, PyObject * args)
+static PyObject *M_NLA_CopyAction( PyObject * self, PyObject * args )
{
BPy_Action *py_action = NULL;
bAction *copyAction = NULL;
- if (!PyArg_ParseTuple (args, "O!", &Action_Type, &py_action)){
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected python action type");
+ if( !PyArg_ParseTuple( args, "O!", &Action_Type, &py_action ) ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected python action type" );
return NULL;
- }
- copyAction = copy_action(py_action->action);
- return Action_CreatePyObject (copyAction);
+ }
+ copyAction = copy_action( py_action->action );
+ return Action_CreatePyObject( copyAction );
}
-static PyObject *
-M_NLA_GetActions(PyObject* self)
+static PyObject *M_NLA_GetActions( PyObject * self )
{
- PyObject *dict=PyDict_New ();
+ PyObject *dict = PyDict_New( );
bAction *action = NULL;
- for(action = G.main->action.first; action; action = action->id.next){
- PyObject * py_action = Action_CreatePyObject (action);
- if (py_action) {
+ for( action = G.main->action.first; action; action = action->id.next ) {
+ PyObject *py_action = Action_CreatePyObject( action );
+ if( py_action ) {
// Insert dict entry using the bone name as key
- if (PyDict_SetItemString (dict, action->id.name + 2, py_action) !=0) {
- Py_DECREF (py_action);
- Py_DECREF ( dict );
-
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "NLA_GetActions: couldn't set dict item");
+ if( PyDict_SetItemString
+ ( dict, action->id.name + 2, py_action ) != 0 ) {
+ Py_DECREF( py_action );
+ Py_DECREF( dict );
+
+ return EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "NLA_GetActions: couldn't set dict item" );
}
- Py_DECREF (py_action);
+ Py_DECREF( py_action );
} else {
- Py_DECREF ( dict );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "NLA_GetActions: could not create Action object"));
+ Py_DECREF( dict );
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "NLA_GetActions: could not create Action object" ) );
}
- }
+ }
return dict;
}
/*****************************************************************************/
/* Function: NLA_Init */
/*****************************************************************************/
-PyObject *
-NLA_Init (void)
+PyObject *NLA_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Action_Type.ob_type = &PyType_Type;
+ Action_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Armature.NLA",
- M_NLA_methods, M_NLA_doc);
+ submodule = Py_InitModule3( "Blender.Armature.NLA",
+ M_NLA_methods, M_NLA_doc );
- return (submodule);
+ return ( submodule );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static PyObject *
-Action_getName (BPy_Action * self)
+//----------------------------------------------------------------------
+static PyObject *Action_getName( BPy_Action * self )
{
- PyObject *attr = NULL;
+ PyObject *attr = NULL;
- if (!self->action)
- (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get attribute from a NULL action"));
+ if( !self->action )
+ ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute from a NULL action" ) );
- attr = PyString_FromString (self->action->id.name+2);
+ attr = PyString_FromString( self->action->id.name + 2 );
- if (attr)
- return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Action.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Action.name attribute" ) );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static PyObject *
-Action_setName (BPy_Action * self, PyObject * args)
+
+//----------------------------------------------------------------------
+static PyObject *Action_setName( BPy_Action * self, PyObject * args )
{
- char *name;
+ char *name;
- if (!self->action)
- (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get attribute from a NULL action"));
+ if( !self->action )
+ ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute from a NULL action" ) );
- if (!PyArg_ParseTuple (args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
- //change name
- strcpy(self->action->id.name+2, name);
+ //change name
+ strcpy( self->action->id.name + 2, name );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Action_setActive(BPy_Action * self, PyObject * args)
+static PyObject *Action_setActive( BPy_Action * self, PyObject * args )
{
- BPy_Object *object;
+ BPy_Object *object;
- if (!self->action)
- (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get attribute from a NULL action"));
+ if( !self->action )
+ ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute from a NULL action" ) );
- if (!PyArg_ParseTuple (args, "O!", &Object_Type, &object))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected python object argument"));
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &object ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected python object argument" ) );
- if(object->object->type != OB_ARMATURE) {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "object not of type armature"));
- }
-
- //set the active action to object
- object->object->action = self->action;
+ if( object->object->type != OB_ARMATURE ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object not of type armature" ) );
+ }
+ //set the active action to object
+ object->object->action = self->action;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Action_getChannelIpo(BPy_Action * self, PyObject * args)
+static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args )
{
char *chanName;
bActionChannel *chan;
- if(!PyArg_ParseTuple(args, "s", &chanName)){
- EXPP_ReturnPyObjError(PyExc_AttributeError, "string expected");
+ if( !PyArg_ParseTuple( args, "s", &chanName ) ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "string expected" );
return NULL;
}
- chan = get_named_actionchannel(self->action,chanName);
- if(chan == NULL){
- EXPP_ReturnPyObjError(PyExc_AttributeError, "no channel with that name...");
+ chan = get_named_actionchannel( self->action, chanName );
+ if( chan == NULL ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no channel with that name..." );
return NULL;
}
-
//return IPO
- return Ipo_CreatePyObject (chan->ipo);
+ return Ipo_CreatePyObject( chan->ipo );
}
-static PyObject *
-Action_removeChannel(BPy_Action * self, PyObject * args)
+static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args )
{
char *chanName;
bActionChannel *chan;
- if(!PyArg_ParseTuple(args, "s", &chanName)){
- EXPP_ReturnPyObjError(PyExc_AttributeError, "string expected");
+ if( !PyArg_ParseTuple( args, "s", &chanName ) ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "string expected" );
return NULL;
}
- chan = get_named_actionchannel(self->action,chanName);
- if(chan == NULL){
- EXPP_ReturnPyObjError(PyExc_AttributeError, "no channel with that name...");
+ chan = get_named_actionchannel( self->action, chanName );
+ if( chan == NULL ) {
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no channel with that name..." );
return NULL;
}
-
//release ipo
- if(chan->ipo)
+ if( chan->ipo )
chan->ipo->id.us--;
//remove channel
- BLI_freelinkN (&self->action->chanbase, chan);
+ BLI_freelinkN( &self->action->chanbase, chan );
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Action_getAllChannelIpos (BPy_Action *self)
+static PyObject *Action_getAllChannelIpos( BPy_Action * self )
{
- PyObject *dict=PyDict_New ();
+ PyObject *dict = PyDict_New( );
bActionChannel *chan = NULL;
- for(chan = self->action->chanbase.first; chan; chan = chan->next){
- PyObject * ipo_attr = Ipo_CreatePyObject (chan->ipo);
- if (ipo_attr) {
+ for( chan = self->action->chanbase.first; chan; chan = chan->next ) {
+ PyObject *ipo_attr = Ipo_CreatePyObject( chan->ipo );
+ if( ipo_attr ) {
// Insert dict entry using the bone name as key
- if (PyDict_SetItemString (dict, chan->name, ipo_attr) !=0) {
- Py_DECREF ( ipo_attr );
- Py_DECREF ( dict );
-
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Action_getAllChannelIpos: couldn't set dict item");
+ if( PyDict_SetItemString( dict, chan->name, ipo_attr )
+ != 0 ) {
+ Py_DECREF( ipo_attr );
+ Py_DECREF( dict );
+
+ return EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "Action_getAllChannelIpos: couldn't set dict item" );
}
- Py_DECREF (ipo_attr);
+ Py_DECREF( ipo_attr );
} else {
- Py_DECREF ( dict );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Action_getAllChannelIpos: could not create Ipo object"));
+ Py_DECREF( dict );
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Action_getAllChannelIpos: could not create Ipo object" ) );
}
- }
+ }
return dict;
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static void
-Action_dealloc (BPy_Action * self)
+//----------------------------------------------------------------------
+static void Action_dealloc( BPy_Action * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static PyObject *
-Action_getAttr (BPy_Action * self, char *name)
+
+//----------------------------------------------------------------------
+static PyObject *Action_getAttr( BPy_Action * self, char *name )
{
- PyObject *attr = Py_None;
+ PyObject *attr = Py_None;
- if (strcmp (name, "name") == 0)
- attr = Action_getName (self);
- else if (strcmp (name, "__members__") == 0) {
- attr = Py_BuildValue ("[s]",
- "name");
- }
+ if( strcmp( name, "name" ) == 0 )
+ attr = Action_getName( self );
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ attr = Py_BuildValue( "[s]", "name" );
+ }
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- if (attr != Py_None)
- return attr; /* member attribute found, return it */
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
- /* not an attribute, search the methods table */
- return Py_FindMethod (BPy_Action_methods, (PyObject *) self, name);
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Action_methods, ( PyObject * ) self, name );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static int
-Action_setAttr (BPy_Action * self, char *name, PyObject * value)
+//----------------------------------------------------------------------
+static int Action_setAttr( BPy_Action * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
- valtuple = Py_BuildValue ("(O)", value); /* the set* functions expect a tuple */
+ valtuple = Py_BuildValue( "(O)", value ); /* the set* functions expect a tuple */
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "ActionSetAttr: couldn't create tuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "ActionSetAttr: couldn't create tuple" );
- if (strcmp (name, "name") == 0)
- error = Action_setName (self, valtuple);
- else
- { /* Error */
- Py_DECREF (valtuple);
+ if( strcmp( name, "name" ) == 0 )
+ error = Action_setName( self, valtuple );
+ else { /* Error */
+ Py_DECREF( valtuple );
- /* ... member with the given name was found */
- return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
- }
+ /* ... member with the given name was found */
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
+ }
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None)
- return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF (Py_None); /* was incref'ed by the called Action_set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* was incref'ed by the called Action_set* function */
+ return 0; /* normal exit */
}
-//-------------------------------------------------------------------------------------------------------------------------------
-static PyObject *
-Action_repr (BPy_Action * self)
+
+//----------------------------------------------------------------------
+static PyObject *Action_repr( BPy_Action * self )
{
- if (self->action)
- return PyString_FromFormat ("[Action \"%s\"]", self->action->id.name + 2);
- else
- return PyString_FromString ("NULL");
+ if( self->action )
+ return PyString_FromFormat( "[Action \"%s\"]",
+ self->action->id.name + 2 );
+ else
+ return PyString_FromString( "NULL" );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-PyObject *
-Action_CreatePyObject (struct bAction * act)
+
+//----------------------------------------------------------------------
+PyObject *Action_CreatePyObject( struct bAction * act )
{
- BPy_Action *blen_action;
+ BPy_Action *blen_action;
- blen_action = (BPy_Action *) PyObject_NEW (BPy_Action, &Action_Type);
+ blen_action =
+ ( BPy_Action * ) PyObject_NEW( BPy_Action, &Action_Type );
- if (blen_action == NULL)
- {
- return (NULL);
- }
- blen_action->action = act;
- return ((PyObject *) blen_action);
+ if( blen_action == NULL ) {
+ return ( NULL );
+ }
+ blen_action->action = act;
+ return ( ( PyObject * ) blen_action );
}
+
//-------------------------------------------------------------------------------------------------------------------------------
-int
-Action_CheckPyObject (PyObject * py_obj)
+int Action_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Action_Type);
+ return ( py_obj->ob_type == &Action_Type );
}
-//-------------------------------------------------------------------------------------------------------------------------------
-struct bAction *
-Action_FromPyObject (PyObject * py_obj)
+
+//----------------------------------------------------------------------
+struct bAction *Action_FromPyObject( PyObject * py_obj )
{
- BPy_Action *blen_obj;
+ BPy_Action *blen_obj;
- blen_obj = (BPy_Action *) py_obj;
- return (blen_obj->action);
+ blen_obj = ( BPy_Action * ) py_obj;
+ return ( blen_obj->action );
}
diff --git a/source/blender/python/api2_2x/NLA.h b/source/blender/python/api2_2x/NLA.h
index 1f19900f9a7..435cc201183 100644
--- a/source/blender/python/api2_2x/NLA.h
+++ b/source/blender/python/api2_2x/NLA.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -36,18 +37,15 @@
#include <DNA_action_types.h>
/** NLA module initialization function. */
-PyObject *NLA_Init (void);
+PyObject *NLA_Init( void );
/** Python BPy_NLA structure definition. */
-typedef struct
-{
- PyObject_HEAD
- bAction *action;
-}
-BPy_Action;
+typedef struct {
+ PyObject_HEAD bAction * action;
+} BPy_Action;
-PyObject *Action_CreatePyObject (struct bAction *action);
-int Action_CheckPyObject (PyObject * py_obj);
-bAction *Action_FromPyObject (PyObject * py_obj);
+PyObject *Action_CreatePyObject( struct bAction *action );
+int Action_CheckPyObject( PyObject * py_obj );
+bAction *Action_FromPyObject( PyObject * py_obj );
#endif
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index 62ec050dae1..e172c30c394 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -50,15 +50,15 @@
#define NMESH_SUBDIV_MAX 6
static char NMesh_addVertGroup_doc[] =
-"add a named and empty vertex(deform) Group to a mesh that has been linked\n\
+ "add a named and empty vertex(deform) Group to a mesh that has been linked\n\
to an object. ";
static char NMesh_removeVertGroup_doc[] =
-"remove a named vertex(deform) Group from a mesh that has been linked\n\
+ "remove a named vertex(deform) Group from a mesh that has been linked\n\
to an object. Will remove all verts assigned to group.";
static char NMesh_assignVertsToGroup_doc[] =
-"Adds an array (a python list) of vertex points (by index) to a named\n\
+ "Adds an array (a python list) of vertex points (by index) to a named\n\
vertex group. The list will have an associated wieght assigned to them.\n\
The weight represents the amount of influence this group has over these\n\
vertex points. Weights should be in the range of 0.0 - 1.0.\n\
@@ -73,41 +73,37 @@ else it does nothing. The mesh must have all it's vertex points set before\n\
attempting to assign any vertex points to a vertex group.";
static char NMesh_removeVertsFromGroup_doc[] =
-"Remove an array (a python list) of vertex points from a named group in a\n\
+ "Remove an array (a python list) of vertex points from a named group in a\n\
mesh that has been linked to an object. If no list is given this will remove\n\
all vertex point associations with the group passed";
static char NMesh_getVertsFromGroup_doc[] =
-"By passing a python list of vertex indices and a named group, this will\n\
+ "By passing a python list of vertex indices and a named group, this will\n\
return a python list representing the indeces that are a part of this vertex.\n\
group. If no association was found for the index passed nothing will be\n\
return for the index. An optional flag will also return the weights as well";
-static char NMesh_renameVertGroup_doc[] =
-"Renames a vertex group";
+static char NMesh_renameVertGroup_doc[] = "Renames a vertex group";
static char NMesh_getVertGroupNames_doc[] =
-"Returns a list of all the vertex group names";
+ "Returns a list of all the vertex group names";
-static char M_NMesh_doc[] =
-"The Blender.NMesh submodule";
+static char M_NMesh_doc[] = "The Blender.NMesh submodule";
-static char M_NMesh_Col_doc[]=
-"([r, g, b, a]) - Get a new mesh color\n\n\
+static char M_NMesh_Col_doc[] = "([r, g, b, a]) - Get a new mesh color\n\n\
[r=255, g=255, b=255, a=255] Specify the color components";
static char M_NMesh_Face_doc[] =
-"(vertexlist = None) - Get a new face, and pass optional vertex list";
+ "(vertexlist = None) - Get a new face, and pass optional vertex list";
static char NMFace_append_doc[] =
-"(vert) - appends Vertex 'vert' to face vertex list";
+ "(vert) - appends Vertex 'vert' to face vertex list";
-static char M_NMesh_Vert_doc[] =
-"([x, y, z]) - Get a new vertice\n\n\
+static char M_NMesh_Vert_doc[] = "([x, y, z]) - Get a new vertice\n\n\
[x, y, z] Specify new coordinates";
static char NMesh_getMaterials_doc[] =
-"(i = -1) - Get this mesh's list of materials.\n\
+ "(i = -1) - Get this mesh's list of materials.\n\
(i = -1) - int: determines the list's contents:\n\
-1: return the current list, possibly modified by the script (default);\n\
0: get a fresh list from the Blender mesh -- modifications not included,\n\
@@ -115,45 +111,45 @@ static char NMesh_getMaterials_doc[] =
1: like 0, but does not ignore empty slots, returns them as 'None'.";
static char NMesh_setMaterials_doc[] =
-"(matlist) - Set this mesh's list of materials. This method makes sure\n\
+ "(matlist) - Set this mesh's list of materials. This method makes sure\n\
the passed matlist is valid (can only include up to 16 materials and None's).";
static char NMesh_addMaterial_doc[] =
-"(material) - add a new Blender Material 'material' to this Mesh's materials\n\
+ "(material) - add a new Blender Material 'material' to this Mesh's materials\n\
list.";
static char NMesh_insertKey_doc[] =
-"(frame = None, type = 'relative') - inserts a Mesh key at the given frame\n\
+ "(frame = None, type = 'relative') - inserts a Mesh key at the given frame\n\
if called without arguments, it inserts the key at the current Scene frame.\n\
(type) - 'relative' or 'absolute'. Only relevant on the first call to this\n\
function for each nmesh.";
static char NMesh_removeAllKeys_doc[] =
-"() - removes all keys from this mesh\n\
+ "() - removes all keys from this mesh\n\
returns True if successful or False if this NMesh wasn't linked to a real\n\
Blender Mesh yet or the Mesh had no keys";
static char NMesh_getSelectedFaces_doc[] =
-"(flag = None) - returns list of selected Faces\n\
+ "(flag = None) - returns list of selected Faces\n\
If flag = 1, return indices instead";
static char NMesh_getActiveFace_doc[] =
-"returns the index of the active face ";
+ "returns the index of the active face ";
static char NMesh_hasVertexUV_doc[] =
-"(flag = None) - returns 1 if Mesh has per vertex UVs ('Sticky')\n\
+ "(flag = None) - returns 1 if Mesh has per vertex UVs ('Sticky')\n\
The optional argument sets the Sticky flag";
static char NMesh_hasFaceUV_doc[] =
-"(flag = None) - returns 1 if Mesh has textured faces\n\
+ "(flag = None) - returns 1 if Mesh has textured faces\n\
The optional argument sets the textured faces flag";
static char NMesh_hasVertexColours_doc[] =
-"(flag = None) - returns 1 if Mesh has vertex colours.\n\
+ "(flag = None) - returns 1 if Mesh has vertex colours.\n\
The optional argument sets the vertex colour flag";
static char NMesh_getVertexInfluences_doc[] =
-"Return a list of the influences of bones in the vertex \n\
+ "Return a list of the influences of bones in the vertex \n\
specified by index. The list contains pairs with the \n\
bone name and the weight.";
@@ -162,44 +158,43 @@ static char NMesh_update_doc[] = "(recalc_normals = 0) - updates the Mesh.\n\
if recalc_normals is given and is equal to 1, normal vectors are recalculated.";
static char NMesh_getMode_doc[] =
-"() - get the mode flags of this nmesh as an or'ed int value.";
+ "() - get the mode flags of this nmesh as an or'ed int value.";
static char NMesh_setMode_doc[] =
-"(none to 5 strings) - set the mode flags of this nmesh.\n\
+ "(none to 5 strings) - set the mode flags of this nmesh.\n\
() - unset all flags.";
static char NMesh_getMaxSmoothAngle_doc[] =
-"() - get the max smooth angle for mesh auto smoothing.";
+ "() - get the max smooth angle for mesh auto smoothing.";
static char NMesh_setMaxSmoothAngle_doc[] =
-"(int) - set the max smooth angle for mesh auto smoothing in the range\n\
+ "(int) - set the max smooth angle for mesh auto smoothing in the range\n\
[1,80] in degrees.";
static char NMesh_getSubDivLevels_doc[] =
-"() - get the subdivision levels for display and rendering: [display, render]";
+ "() - get the subdivision levels for display and rendering: [display, render]";
static char NMesh_setSubDivLevels_doc[] =
-"([int, int]) - set the subdivision levels for [display, render] -- they are\n\
+ "([int, int]) - set the subdivision levels for [display, render] -- they are\n\
clamped to the range [1,6].";
static char M_NMesh_New_doc[] =
-"() - returns a new, empty NMesh mesh object\n";
+ "() - returns a new, empty NMesh mesh object\n";
-static char M_NMesh_GetRaw_doc[] =
-"([name]) - Get a raw mesh from Blender\n\n\
+static char M_NMesh_GetRaw_doc[] = "([name]) - Get a raw mesh from Blender\n\n\
[name] Name of the mesh to be returned\n\n\
If name is not specified a new empty mesh is\n\
returned, otherwise Blender returns an existing\n\
mesh.";
static char M_NMesh_GetRawFromObject_doc[] =
-"(name) - Get the raw mesh used by a Blender object\n\n\
+ "(name) - Get the raw mesh used by a Blender object\n\n\
(name) Name of the object to get the mesh from\n\n\
This returns the mesh as used by the object, which\n\
means it contains all deformations and modifications.";
static char M_NMesh_PutRaw_doc[] =
-"(mesh, [name, renormal]) - Return a raw mesh to Blender\n\n\
+ "(mesh, [name, renormal]) - Return a raw mesh to Blender\n\n\
(mesh) The NMesh object to store\n\
[name] The mesh to replace\n\
[renormal=1] Flag to control vertex normal recalculation\n\n\
@@ -208,865 +203,892 @@ object is created and returned.";
-void mesh_update(Mesh *mesh)
+void mesh_update( Mesh * mesh )
{
- edge_drawflags_mesh(mesh);
- tex_space_mesh(mesh);
+ edge_drawflags_mesh( mesh );
+ tex_space_mesh( mesh );
}
/*****************************/
/* Mesh Color Object */
/*****************************/
-static void NMCol_dealloc(PyObject *self)
+static void NMCol_dealloc( PyObject * self )
{
- PyObject_DEL(self);
+ PyObject_DEL( self );
}
-static BPy_NMCol *newcol (char r, char g, char b, char a)
+static BPy_NMCol *newcol( char r, char g, char b, char a )
{
- BPy_NMCol *mc = (BPy_NMCol *) PyObject_NEW (BPy_NMCol, &NMCol_Type);
+ BPy_NMCol *mc = ( BPy_NMCol * ) PyObject_NEW( BPy_NMCol, &NMCol_Type );
- mc->r= r;
- mc->g= g;
- mc->b= b;
- mc->a= a;
+ mc->r = r;
+ mc->g = g;
+ mc->b = b;
+ mc->a = a;
- return mc;
+ return mc;
}
-static PyObject *M_NMesh_Col(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_Col( PyObject * self, PyObject * args )
{
short r = 255, g = 255, b = 255, a = 255;
- if(PyArg_ParseTuple(args, "|hhhh", &r, &g, &b, &a))
- return (PyObject *) newcol(r, g, b, a);
+ if( PyArg_ParseTuple( args, "|hhhh", &r, &g, &b, &a ) )
+ return ( PyObject * ) newcol( r, g, b, a );
- return NULL;
+ return NULL;
}
-static PyObject *NMCol_getattr(PyObject *self, char *name)
+static PyObject *NMCol_getattr( PyObject * self, char *name )
{
- BPy_NMCol *mc = (BPy_NMCol *)self;
+ BPy_NMCol *mc = ( BPy_NMCol * ) self;
- if (strcmp(name, "r") == 0) return Py_BuildValue("i", mc->r);
- else if (strcmp(name, "g") == 0) return Py_BuildValue("i", mc->g);
- else if (strcmp(name, "b") == 0) return Py_BuildValue("i", mc->b);
- else if (strcmp(name, "a") == 0) return Py_BuildValue("i", mc->a);
- else if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s,s]", "r", "g", "b", "a");
+ if( strcmp( name, "r" ) == 0 )
+ return Py_BuildValue( "i", mc->r );
+ else if( strcmp( name, "g" ) == 0 )
+ return Py_BuildValue( "i", mc->g );
+ else if( strcmp( name, "b" ) == 0 )
+ return Py_BuildValue( "i", mc->b );
+ else if( strcmp( name, "a" ) == 0 )
+ return Py_BuildValue( "i", mc->a );
+ else if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s,s]", "r", "g", "b", "a" );
- return EXPP_ReturnPyObjError(PyExc_AttributeError, name);
+ return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
}
-static int NMCol_setattr(PyObject *self, char *name, PyObject *v)
+static int NMCol_setattr( PyObject * self, char *name, PyObject * v )
{
- BPy_NMCol *mc = (BPy_NMCol *)self;
+ BPy_NMCol *mc = ( BPy_NMCol * ) self;
short ival;
- if(!PyArg_Parse(v, "h", &ival)) return -1;
+ if( !PyArg_Parse( v, "h", &ival ) )
+ return -1;
- ival = (short)EXPP_ClampInt(ival, 0, 255);
+ ival = ( short ) EXPP_ClampInt( ival, 0, 255 );
- if (strcmp(name, "r") == 0) mc->r = ival;
- else if (strcmp(name, "g") == 0) mc->g = ival;
- else if (strcmp(name, "b") == 0) mc->b = ival;
- else if (strcmp(name, "a")==0) mc->a = ival;
- else return -1;
+ if( strcmp( name, "r" ) == 0 )
+ mc->r = ival;
+ else if( strcmp( name, "g" ) == 0 )
+ mc->g = ival;
+ else if( strcmp( name, "b" ) == 0 )
+ mc->b = ival;
+ else if( strcmp( name, "a" ) == 0 )
+ mc->a = ival;
+ else
+ return -1;
return 0;
}
-PyObject *NMCol_repr(BPy_NMCol *self)
+PyObject *NMCol_repr( BPy_NMCol * self )
{
static char s[256];
- sprintf (s, "[NMCol - <%d, %d, %d, %d>]", self->r, self->g, self->b, self->a);
- return Py_BuildValue("s", s);
+ sprintf( s, "[NMCol - <%d, %d, %d, %d>]", self->r, self->g, self->b,
+ self->a );
+ return Py_BuildValue( "s", s );
}
-PyTypeObject NMCol_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender NMCol", /* tp_name */
- sizeof(BPy_NMCol), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject NMCol_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
+ "Blender NMCol", /* tp_name */
+ sizeof( BPy_NMCol ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor) NMCol_dealloc, /* tp_dealloc */
- (printfunc) 0, /* tp_print */
- (getattrfunc) NMCol_getattr, /* tp_getattr */
- (setattrfunc) NMCol_setattr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) NMCol_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
+ ( destructor ) NMCol_dealloc, /* tp_dealloc */
+ ( printfunc ) 0, /* tp_print */
+ ( getattrfunc ) NMCol_getattr, /* tp_getattr */
+ ( setattrfunc ) NMCol_setattr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) NMCol_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
};
/*****************************/
/* NMesh Python Object */
/*****************************/
-static void NMFace_dealloc (PyObject *self)
+static void NMFace_dealloc( PyObject * self )
{
- BPy_NMFace *mf = (BPy_NMFace *)self;
+ BPy_NMFace *mf = ( BPy_NMFace * ) self;
- Py_DECREF(mf->v);
- Py_DECREF(mf->uv);
- Py_DECREF(mf->col);
+ Py_DECREF( mf->v );
+ Py_DECREF( mf->uv );
+ Py_DECREF( mf->col );
- PyObject_DEL(self);
+ PyObject_DEL( self );
}
-static PyObject *new_NMFace(PyObject *vertexlist)
+static PyObject *new_NMFace( PyObject * vertexlist )
{
- BPy_NMFace *mf = PyObject_NEW (BPy_NMFace, &NMFace_Type);
+ BPy_NMFace *mf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
PyObject *vlcopy;
- if (vertexlist) { /* create a copy of the given vertex list */
+ if( vertexlist ) { /* create a copy of the given vertex list */
PyObject *item;
- int i, len = PyList_Size(vertexlist);
+ int i, len = PyList_Size( vertexlist );
- vlcopy = PyList_New(len);
+ vlcopy = PyList_New( len );
- if (!vlcopy)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create PyList");
+ if( !vlcopy )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- for (i = 0; i < len; i++) {
- item = PySequence_GetItem(vertexlist, i); /* PySequence increfs */
+ for( i = 0; i < len; i++ ) {
+ item = PySequence_GetItem( vertexlist, i ); /* PySequence increfs */
- if (item)
- PyList_SET_ITEM(vlcopy, i, item);
+ if( item )
+ PyList_SET_ITEM( vlcopy, i, item );
else
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "couldn't get vertex from a PyList");
+ return EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "couldn't get vertex from a PyList" );
}
- }
- else /* create an empty vertex list */
- vlcopy = PyList_New(0);
+ } else /* create an empty vertex list */
+ vlcopy = PyList_New( 0 );
mf->v = vlcopy;
- mf->uv = PyList_New(0);
+ mf->uv = PyList_New( 0 );
mf->image = NULL;
mf->mode = TF_DYNAMIC + TF_TEX;
mf->flag = TF_SELECT;
mf->transp = TF_SOLID;
- mf->col = PyList_New(0);
+ mf->col = PyList_New( 0 );
mf->smooth = 0;
mf->mat_nr = 0;
- return (PyObject *)mf;
+ return ( PyObject * ) mf;
}
-static PyObject *M_NMesh_Face(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_Face( PyObject * self, PyObject * args )
{
PyObject *vertlist = NULL;
- if (!PyArg_ParseTuple(args, "|O!", &PyList_Type, &vertlist))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a list of vertices or nothing as argument");
+ if( !PyArg_ParseTuple( args, "|O!", &PyList_Type, &vertlist ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of vertices or nothing as argument" );
/* if (!vertlist) vertlist = PyList_New(0); */
- return new_NMFace(vertlist);
+ return new_NMFace( vertlist );
}
-static PyObject *NMFace_append(PyObject *self, PyObject *args)
+static PyObject *NMFace_append( PyObject * self, PyObject * args )
{
PyObject *vert;
- BPy_NMFace *f = (BPy_NMFace *)self;
+ BPy_NMFace *f = ( BPy_NMFace * ) self;
- if (!PyArg_ParseTuple(args, "O!", &NMVert_Type, &vert))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an NMVert object");
+ if( !PyArg_ParseTuple( args, "O!", &NMVert_Type, &vert ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an NMVert object" );
- PyList_Append(f->v, vert);
+ PyList_Append( f->v, vert );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
#undef MethodDef
#define MethodDef(func) {#func, NMFace_##func, METH_VARARGS, NMFace_##func##_doc}
-static struct PyMethodDef NMFace_methods[] =
-{
- MethodDef(append),
+static struct PyMethodDef NMFace_methods[] = {
+ MethodDef( append ),
{NULL, NULL, 0, NULL}
};
-static PyObject *NMFace_getattr(PyObject *self, char *name)
-{
- BPy_NMFace *mf = (BPy_NMFace *)self;
-
- if(strcmp(name, "v") == 0)
- return Py_BuildValue("O", mf->v);
- else if (strcmp(name, "col") == 0)
- return Py_BuildValue("O", mf->col);
- else if (strcmp(name, "mat") == 0) // emulation XXX
- return Py_BuildValue("i", mf->mat_nr);
- else if (strcmp(name, "materialIndex") == 0)
- return Py_BuildValue("i", mf->mat_nr);
- else if (strcmp(name, "smooth") == 0)
- return Py_BuildValue("i", mf->smooth);
-
- else if (strcmp(name, "image") == 0) {
- if (mf->image)
- return Image_CreatePyObject (mf->image);
- else
- return EXPP_incr_ret(Py_None);
+static PyObject *NMFace_getattr( PyObject * self, char *name )
+{
+ BPy_NMFace *mf = ( BPy_NMFace * ) self;
+
+ if( strcmp( name, "v" ) == 0 )
+ return Py_BuildValue( "O", mf->v );
+ else if( strcmp( name, "col" ) == 0 )
+ return Py_BuildValue( "O", mf->col );
+ else if( strcmp( name, "mat" ) == 0 ) // emulation XXX
+ return Py_BuildValue( "i", mf->mat_nr );
+ else if( strcmp( name, "materialIndex" ) == 0 )
+ return Py_BuildValue( "i", mf->mat_nr );
+ else if( strcmp( name, "smooth" ) == 0 )
+ return Py_BuildValue( "i", mf->smooth );
+
+ else if( strcmp( name, "image" ) == 0 ) {
+ if( mf->image )
+ return Image_CreatePyObject( mf->image );
+ else
+ return EXPP_incr_ret( Py_None );
}
- else if (strcmp(name, "mode") == 0)
- return Py_BuildValue("i", mf->mode);
- else if (strcmp(name, "flag") == 0)
- return Py_BuildValue("i", mf->flag);
- else if (strcmp(name, "transp") == 0)
- return Py_BuildValue("i", mf->transp);
- else if (strcmp(name, "uv") == 0)
- return Py_BuildValue("O", mf->uv);
+ else if( strcmp( name, "mode" ) == 0 )
+ return Py_BuildValue( "i", mf->mode );
+ else if( strcmp( name, "flag" ) == 0 )
+ return Py_BuildValue( "i", mf->flag );
+ else if( strcmp( name, "transp" ) == 0 )
+ return Py_BuildValue( "i", mf->transp );
+ else if( strcmp( name, "uv" ) == 0 )
+ return Py_BuildValue( "O", mf->uv );
- else if ((strcmp(name, "normal") == 0) || (strcmp(name, "no") == 0)) {
+ else if( ( strcmp( name, "normal" ) == 0 )
+ || ( strcmp( name, "no" ) == 0 ) ) {
- if (EXPP_check_sequence_consistency(mf->v, &NMVert_Type) == 1) {
+ if( EXPP_check_sequence_consistency( mf->v, &NMVert_Type ) ==
+ 1 ) {
- float fNormal[3] = {0.0,0.0,0.0};
- float *vco[4] = {NULL, NULL, NULL, NULL};
- int nSize = PyList_Size(mf->v);
+ float fNormal[3] = { 0.0, 0.0, 0.0 };
+ float *vco[4] = { NULL, NULL, NULL, NULL };
+ int nSize = PyList_Size( mf->v );
int loop;
- if (nSize != 3 && nSize != 4)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "face must contain either 3 or 4 verts");
+ if( nSize != 3 && nSize != 4 )
+ return EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "face must contain either 3 or 4 verts" );
- for (loop = 0; loop < nSize; loop++) {
- BPy_NMVert *v = (BPy_NMVert *)PyList_GetItem(mf->v, loop);
- vco[loop] = (float *)v->co;
+ for( loop = 0; loop < nSize; loop++ ) {
+ BPy_NMVert *v =
+ ( BPy_NMVert * ) PyList_GetItem( mf->v,
+ loop );
+ vco[loop] = ( float * ) v->co;
}
- if (nSize == 4)
- CalcNormFloat4(vco[0], vco[1], vco[2], vco[3], fNormal);
+ if( nSize == 4 )
+ CalcNormFloat4( vco[0], vco[1], vco[2], vco[3],
+ fNormal );
else
- CalcNormFloat(vco[0], vco[1], vco[2], fNormal);
+ CalcNormFloat( vco[0], vco[1], vco[2],
+ fNormal );
- return Py_BuildValue("[f,f,f]",fNormal[0],fNormal[1],fNormal[2]);
- }
- else // EXPP_check_sequence_consistency failed
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "this face does not contain a series of NMVerts");
+ return Py_BuildValue( "[f,f,f]", fNormal[0],
+ fNormal[1], fNormal[2] );
+ } else // EXPP_check_sequence_consistency failed
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "this face does not contain a series of NMVerts" );
}
- else if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s]",
- "v", "col", "mat", "materialIndex", "smooth",
- "image", "mode", "flag", "transp", "uv", "normal");
- return Py_FindMethod(NMFace_methods, (PyObject*)self, name);
+ else if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s]",
+ "v", "col", "mat", "materialIndex",
+ "smooth", "image", "mode", "flag",
+ "transp", "uv", "normal" );
+ return Py_FindMethod( NMFace_methods, ( PyObject * ) self, name );
}
-static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
+static int NMFace_setattr( PyObject * self, char *name, PyObject * v )
{
- BPy_NMFace *mf = (BPy_NMFace *)self;
+ BPy_NMFace *mf = ( BPy_NMFace * ) self;
short ival;
- if (strcmp(name, "v") == 0) {
+ if( strcmp( name, "v" ) == 0 ) {
- if(PySequence_Check(v)) {
- Py_DECREF(mf->v);
- mf->v = EXPP_incr_ret(v);
+ if( PySequence_Check( v ) ) {
+ Py_DECREF( mf->v );
+ mf->v = EXPP_incr_ret( v );
return 0;
}
- }
- else if (strcmp(name, "col") == 0) {
+ } else if( strcmp( name, "col" ) == 0 ) {
- if(PySequence_Check(v)) {
- Py_DECREF(mf->col);
- mf->col = EXPP_incr_ret(v);
+ if( PySequence_Check( v ) ) {
+ Py_DECREF( mf->col );
+ mf->col = EXPP_incr_ret( v );
return 0;
}
- }
- else if (!strcmp(name, "mat") || !strcmp(name, "materialIndex")) {
- PyArg_Parse(v, "h", &ival);
- mf->mat_nr= ival;
-
+ } else if( !strcmp( name, "mat" ) || !strcmp( name, "materialIndex" ) ) {
+ PyArg_Parse( v, "h", &ival );
+ mf->mat_nr = ival;
+
return 0;
- }
- else if (strcmp(name, "smooth") == 0) {
- PyArg_Parse(v, "h", &ival);
- mf->smooth = ival?1:0;
+ } else if( strcmp( name, "smooth" ) == 0 ) {
+ PyArg_Parse( v, "h", &ival );
+ mf->smooth = ival ? 1 : 0;
return 0;
- }
- else if (strcmp(name, "uv") == 0) {
+ } else if( strcmp( name, "uv" ) == 0 ) {
- if(PySequence_Check(v)) {
- Py_DECREF(mf->uv);
- mf->uv = EXPP_incr_ret(v);
+ if( PySequence_Check( v ) ) {
+ Py_DECREF( mf->uv );
+ mf->uv = EXPP_incr_ret( v );
return 0;
}
- }
- else if (strcmp(name, "flag") == 0) {
- PyArg_Parse(v, "h", &ival);
- mf->flag = ival;
+ } else if( strcmp( name, "flag" ) == 0 ) {
+ PyArg_Parse( v, "h", &ival );
+ mf->flag = ival;
- return 0;
- }
- else if (strcmp(name, "mode") == 0) {
- PyArg_Parse(v, "h", &ival);
- mf->mode = ival;
+ return 0;
+ } else if( strcmp( name, "mode" ) == 0 ) {
+ PyArg_Parse( v, "h", &ival );
+ mf->mode = ival;
- return 0;
- }
- else if (strcmp(name, "transp") == 0) {
- PyArg_Parse(v, "h", &ival);
- mf->transp = ival;
+ return 0;
+ } else if( strcmp( name, "transp" ) == 0 ) {
+ PyArg_Parse( v, "h", &ival );
+ mf->transp = ival;
- return 0;
- }
- else if (strcmp(name, "image") == 0) {
+ return 0;
+ } else if( strcmp( name, "image" ) == 0 ) {
PyObject *pyimg;
- if (!PyArg_Parse(v, "O!", &Image_Type, &pyimg))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "expected image object");
+ if( !PyArg_Parse( v, "O!", &Image_Type, &pyimg ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected image object" );
- if (pyimg == Py_None) {
+ if( pyimg == Py_None ) {
mf->image = NULL;
return 0;
}
- mf->image = ((BPy_Image *)pyimg)->image;
+ mf->image = ( ( BPy_Image * ) pyimg )->image;
return 0;
}
- return EXPP_ReturnIntError (PyExc_AttributeError, name);
+ return EXPP_ReturnIntError( PyExc_AttributeError, name );
}
-static PyObject *NMFace_repr (PyObject *self)
+static PyObject *NMFace_repr( PyObject * self )
{
- return PyString_FromString("[NMFace]");
+ return PyString_FromString( "[NMFace]" );
}
-static int NMFace_len(BPy_NMFace *self)
+static int NMFace_len( BPy_NMFace * self )
{
- return PySequence_Length(self->v);
+ return PySequence_Length( self->v );
}
-static PyObject *NMFace_item(BPy_NMFace *self, int i)
+static PyObject *NMFace_item( BPy_NMFace * self, int i )
{
- return PySequence_GetItem(self->v, i); // new ref
+ return PySequence_GetItem( self->v, i ); // new ref
}
-static PyObject *NMFace_slice(BPy_NMFace *self, int begin, int end)
+static PyObject *NMFace_slice( BPy_NMFace * self, int begin, int end )
{
- return PyList_GetSlice(self->v, begin, end); // new ref
+ return PyList_GetSlice( self->v, begin, end ); // new ref
}
-static PySequenceMethods NMFace_SeqMethods =
-{
- (inquiry) NMFace_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) NMFace_item, /* sq_item */
- (intintargfunc) NMFace_slice, /* sq_slice */
- (intobjargproc) 0, /* sq_ass_item */
- (intintobjargproc) 0, /* sq_ass_slice */
+static PySequenceMethods NMFace_SeqMethods = {
+ ( inquiry ) NMFace_len, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) NMFace_item, /* sq_item */
+ ( intintargfunc ) NMFace_slice, /* sq_slice */
+ ( intobjargproc ) 0, /* sq_ass_item */
+ ( intintobjargproc ) 0, /* sq_ass_slice */
};
-PyTypeObject NMFace_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Blender NMFace", /*tp_name*/
- sizeof(BPy_NMFace), /*tp_basicsize*/
- 0, /*tp_itemsize*/
+PyTypeObject NMFace_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender NMFace", /*tp_name */
+ sizeof( BPy_NMFace ), /*tp_basicsize */
+ 0, /*tp_itemsize */
/* methods */
- (destructor) NMFace_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) NMFace_getattr, /*tp_getattr*/
- (setattrfunc) NMFace_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) NMFace_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &NMFace_SeqMethods, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
+ ( destructor ) NMFace_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) NMFace_getattr, /*tp_getattr */
+ ( setattrfunc ) NMFace_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) NMFace_repr, /*tp_repr */
+ 0, /*tp_as_number */
+ &NMFace_SeqMethods, /*tp_as_sequence */
+ 0, /*tp_as_mapping */
+ 0, /*tp_hash */
};
-static BPy_NMVert *newvert(float *co)
+static BPy_NMVert *newvert( float *co )
{
- BPy_NMVert *mv = PyObject_NEW(BPy_NMVert, &NMVert_Type);
+ BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
- mv->co[0] = co[0]; mv->co[1] = co[1]; mv->co[2] = co[2];
+ mv->co[0] = co[0];
+ mv->co[1] = co[1];
+ mv->co[2] = co[2];
mv->no[0] = mv->no[1] = mv->no[2] = 0.0;
mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
mv->flag = 0;
-
+
return mv;
}
-static PyObject *M_NMesh_Vert(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_Vert( PyObject * self, PyObject * args )
{
- float co[3]= {0.0, 0.0, 0.0};
-
- if (!PyArg_ParseTuple(args, "|fff", &co[0], &co[1], &co[2]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected three floats (or nothing) as arguments");
+ float co[3] = { 0.0, 0.0, 0.0 };
- return (PyObject *)newvert(co);
+ if( !PyArg_ParseTuple( args, "|fff", &co[0], &co[1], &co[2] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected three floats (or nothing) as arguments" );
+
+ return ( PyObject * ) newvert( co );
}
-static void NMVert_dealloc(PyObject *self)
+static void NMVert_dealloc( PyObject * self )
{
- PyObject_DEL(self);
+ PyObject_DEL( self );
}
-static PyObject *NMVert_getattr(PyObject *self, char *name)
+static PyObject *NMVert_getattr( PyObject * self, char *name )
{
- BPy_NMVert *mv = (BPy_NMVert *)self;
+ BPy_NMVert *mv = ( BPy_NMVert * ) self;
- if (!strcmp(name, "co") || !strcmp(name, "loc"))
- return newVectorObject(mv->co, 3);
+ if( !strcmp( name, "co" ) || !strcmp( name, "loc" ) )
+ return newVectorObject( mv->co, 3 );
- else if (strcmp(name, "no") == 0) return newVectorObject(mv->no, 3);
- else if (strcmp(name, "uvco") == 0) return newVectorObject(mv->uvco, 3);
- else if (strcmp(name, "index") == 0) return PyInt_FromLong(mv->index);
- else if (strcmp(name, "sel") == 0) return PyInt_FromLong(mv->flag & 1);
- else if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s,s,s]", "co", "no", "uvco", "index", "sel");
+ else if( strcmp( name, "no" ) == 0 )
+ return newVectorObject( mv->no, 3 );
+ else if( strcmp( name, "uvco" ) == 0 )
+ return newVectorObject( mv->uvco, 3 );
+ else if( strcmp( name, "index" ) == 0 )
+ return PyInt_FromLong( mv->index );
+ else if( strcmp( name, "sel" ) == 0 )
+ return PyInt_FromLong( mv->flag & 1 );
+ else if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s,s,s]", "co", "no", "uvco",
+ "index", "sel" );
- return EXPP_ReturnPyObjError (PyExc_AttributeError, name);
+ return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
}
-static int NMVert_setattr(PyObject *self, char *name, PyObject *v)
+static int NMVert_setattr( PyObject * self, char *name, PyObject * v )
{
- BPy_NMVert *mv = (BPy_NMVert *)self;
+ BPy_NMVert *mv = ( BPy_NMVert * ) self;
int i;
-
- if (strcmp(name,"index") == 0) {
- PyArg_Parse(v, "i", &i);
+
+ if( strcmp( name, "index" ) == 0 ) {
+ PyArg_Parse( v, "i", &i );
mv->index = i;
return 0;
- }
- else if (strcmp(name, "sel") == 0) {
- PyArg_Parse(v, "i", &i);
- mv->flag = i?1:0;
+ } else if( strcmp( name, "sel" ) == 0 ) {
+ PyArg_Parse( v, "i", &i );
+ mv->flag = i ? 1 : 0;
return 0;
- }
- else if (strcmp(name, "uvco") == 0) {
+ } else if( strcmp( name, "uvco" ) == 0 ) {
- if (!PyArg_ParseTuple(v, "ff|f",
- &(mv->uvco[0]), &(mv->uvco[1]), &(mv->uvco[2])))
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "Vector tuple or triple expected");
+ if( !PyArg_ParseTuple( v, "ff|f",
+ &( mv->uvco[0] ), &( mv->uvco[1] ),
+ &( mv->uvco[2] ) ) )
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "Vector tuple or triple expected" );
return 0;
- }
-
- return EXPP_ReturnIntError (PyExc_AttributeError, name);
+ }
+
+ return EXPP_ReturnIntError( PyExc_AttributeError, name );
}
-static int NMVert_len(BPy_NMVert *self)
+static int NMVert_len( BPy_NMVert * self )
{
return 3;
}
-static PyObject *NMVert_item(BPy_NMVert *self, int i)
+static PyObject *NMVert_item( BPy_NMVert * self, int i )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnPyObjError (PyExc_IndexError,
- "array index out of range");
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range" );
- return Py_BuildValue("f", self->co[i]);
+ return Py_BuildValue( "f", self->co[i] );
}
-static PyObject *NMVert_slice(BPy_NMVert *self, int begin, int end)
+static PyObject *NMVert_slice( BPy_NMVert * self, int begin, int end )
{
PyObject *list;
int count;
-
- if (begin < 0) begin = 0;
- if (end > 3) end = 3;
- if (begin > end) begin = end;
- list = PyList_New(end-begin);
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
+
+ list = PyList_New( end - begin );
- for (count = begin; count < end; count++)
- PyList_SetItem(list, count - begin, PyFloat_FromDouble(self->co[count]));
+ for( count = begin; count < end; count++ )
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( self->co[count] ) );
return list;
}
-static int NMVert_ass_item(BPy_NMVert *self, int i, PyObject *ob)
+static int NMVert_ass_item( BPy_NMVert * self, int i, PyObject * ob )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnIntError (PyExc_IndexError,
- "array assignment index out of range");
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range" );
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError (PyExc_IndexError,
- "NMVert member must be a number");
+ if( !PyNumber_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "NMVert member must be a number" );
- self->co[i]= PyFloat_AsDouble(ob);
+ self->co[i] = PyFloat_AsDouble( ob );
return 0;
}
-static int NMVert_ass_slice(BPy_NMVert *self, int begin, int end, PyObject *seq)
+static int NMVert_ass_slice( BPy_NMVert * self, int begin, int end,
+ PyObject * seq )
{
int count;
-
- if (begin < 0) begin = 0;
- if (end > 3) end = 3;
- if (begin > end) begin = end;
-
- if (!PySequence_Check(seq))
- EXPP_ReturnIntError (PyExc_TypeError,
- "illegal argument type for built-in operation");
-
- if (PySequence_Length(seq)!=(end-begin))
- EXPP_ReturnIntError (PyExc_TypeError,
- "size mismatch in slice assignment");
-
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, count);
-
- if (!PyArg_Parse(ob, "f", &self->co[count])) {
- Py_DECREF(ob);
+
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
+
+ if( !PySequence_Check( seq ) )
+ EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation" );
+
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment" );
+
+ for( count = begin; count < end; count++ ) {
+ PyObject *ob = PySequence_GetItem( seq, count );
+
+ if( !PyArg_Parse( ob, "f", &self->co[count] ) ) {
+ Py_DECREF( ob );
return -1;
}
- Py_DECREF(ob);
+ Py_DECREF( ob );
}
return 0;
}
-static PySequenceMethods NMVert_SeqMethods =
-{
- (inquiry) NMVert_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) NMVert_item, /* sq_item */
- (intintargfunc) NMVert_slice, /* sq_slice */
- (intobjargproc) NMVert_ass_item, /* sq_ass_item */
- (intintobjargproc) NMVert_ass_slice, /* sq_ass_slice */
+static PySequenceMethods NMVert_SeqMethods = {
+ ( inquiry ) NMVert_len, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) NMVert_item, /* sq_item */
+ ( intintargfunc ) NMVert_slice, /* sq_slice */
+ ( intobjargproc ) NMVert_ass_item, /* sq_ass_item */
+ ( intintobjargproc ) NMVert_ass_slice, /* sq_ass_slice */
};
-PyTypeObject NMVert_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Blender NMVert", /*tp_name*/
- sizeof(BPy_NMVert), /*tp_basicsize*/
- 0, /*tp_itemsize*/
+PyTypeObject NMVert_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /*ob_size */
+ "Blender NMVert", /*tp_name */
+ sizeof( BPy_NMVert ), /*tp_basicsize */
+ 0, /*tp_itemsize */
/* methods */
- (destructor) NMVert_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) NMVert_getattr, /*tp_getattr*/
- (setattrfunc) NMVert_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) 0, /*tp_repr*/
- 0, /*tp_as_number*/
- &NMVert_SeqMethods, /*tp_as_sequence*/
+ ( destructor ) NMVert_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) NMVert_getattr, /*tp_getattr */
+ ( setattrfunc ) NMVert_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) 0, /*tp_repr */
+ 0, /*tp_as_number */
+ &NMVert_SeqMethods, /*tp_as_sequence */
};
-static void NMesh_dealloc(PyObject *self)
+static void NMesh_dealloc( PyObject * self )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
- Py_DECREF(me->name);
- Py_DECREF(me->verts);
- Py_DECREF(me->faces);
- Py_DECREF(me->materials);
+ Py_DECREF( me->name );
+ Py_DECREF( me->verts );
+ Py_DECREF( me->faces );
+ Py_DECREF( me->materials );
- PyObject_DEL(self);
+ PyObject_DEL( self );
}
-static PyObject *NMesh_getMaterials (PyObject *self, PyObject *args)
+static PyObject *NMesh_getMaterials( PyObject * self, PyObject * args )
{
- BPy_NMesh *nm = (BPy_NMesh *)self;
+ BPy_NMesh *nm = ( BPy_NMesh * ) self;
PyObject *list = NULL;
Mesh *me = nm->mesh;
int all = -1;
- if (!PyArg_ParseTuple (args, "|i", &all))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or an int (bool) as argument");
+ if( !PyArg_ParseTuple( args, "|i", &all ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int (bool) as argument" );
- if (all >= 0) {
- list = EXPP_PyList_fromMaterialList (me->mat, me->totcol, all);
- Py_DECREF (nm->materials); /* update nmesh.materials attribute */
- nm->materials = EXPP_incr_ret(list);
- }
- else
- list = EXPP_incr_ret (nm->materials);
+ if( all >= 0 ) {
+ list = EXPP_PyList_fromMaterialList( me->mat, me->totcol,
+ all );
+ Py_DECREF( nm->materials ); /* update nmesh.materials attribute */
+ nm->materials = EXPP_incr_ret( list );
+ } else
+ list = EXPP_incr_ret( nm->materials );
return list;
}
-static PyObject *NMesh_setMaterials (PyObject *self, PyObject *args)
+static PyObject *NMesh_setMaterials( PyObject * self, PyObject * args )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
PyObject *pymats = NULL;
- if (!PyArg_ParseTuple (args, "O!", &PyList_Type, &pymats))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a list of materials (None's also accepted) as argument");
+ if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pymats ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of materials (None's also accepted) as argument" );
- if (!EXPP_check_sequence_consistency (pymats, &Material_Type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "list should only contain materials (None's also accepted)");
+ if( !EXPP_check_sequence_consistency( pymats, &Material_Type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "list should only contain materials (None's also accepted)" );
- if (PyList_Size(pymats) > 16)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "list can't have more than 16 materials");
+ if( PyList_Size( pymats ) > 16 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "list can't have more than 16 materials" );
- Py_DECREF (me->materials);
- me->materials = EXPP_incr_ret (pymats);
+ Py_DECREF( me->materials );
+ me->materials = EXPP_incr_ret( pymats );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_addMaterial (PyObject *self, PyObject *args)
+static PyObject *NMesh_addMaterial( PyObject * self, PyObject * args )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
BPy_Material *pymat;
Material *mat;
PyObject *iter;
int i, len = 0;
- if (!PyArg_ParseTuple (args, "O!", &Material_Type, &pymat))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Blender Material PyObject");
+ if( !PyArg_ParseTuple( args, "O!", &Material_Type, &pymat ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Blender Material PyObject" );
mat = pymat->material;
- len = PyList_Size(me->materials);
+ len = PyList_Size( me->materials );
- if (len >= 16)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object data material lists can't have more than 16 materials");
+ if( len >= 16 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "object data material lists can't have more than 16 materials" );
- for (i = 0; i < len; i++) {
- iter = PyList_GetItem(me->materials, i);
- if (mat == Material_FromPyObject(iter))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "material already in the list");
+ for( i = 0; i < len; i++ ) {
+ iter = PyList_GetItem( me->materials, i );
+ if( mat == Material_FromPyObject( iter ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "material already in the list" );
}
- PyList_Append(me->materials, (PyObject *)pymat);
+ PyList_Append( me->materials, ( PyObject * ) pymat );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_removeAllKeys (PyObject *self, PyObject *args)
+static PyObject *NMesh_removeAllKeys( PyObject * self, PyObject * args )
{
- BPy_NMesh *nm = (BPy_NMesh *)self;
+ BPy_NMesh *nm = ( BPy_NMesh * ) self;
Mesh *me = nm->mesh;
- if (!PyArg_ParseTuple (args, ""))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this function expects no arguments");
+ if( !PyArg_ParseTuple( args, "" ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this function expects no arguments" );
- if (!me || !me->key) return EXPP_incr_ret (Py_False);
+ if( !me || !me->key )
+ return EXPP_incr_ret( Py_False );
me->key->id.us--;
me->key = 0;
- return EXPP_incr_ret (Py_True);
+ return EXPP_incr_ret( Py_True );
}
-static PyObject *NMesh_insertKey(PyObject *self, PyObject *args)
+static PyObject *NMesh_insertKey( PyObject * self, PyObject * args )
{
int fra = -1, oldfra = -1;
char *type = NULL;
short typenum;
- BPy_NMesh *nm = (BPy_NMesh *)self;
+ BPy_NMesh *nm = ( BPy_NMesh * ) self;
Mesh *mesh = nm->mesh;
- if (!PyArg_ParseTuple(args, "|is", &fra, &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or an int and optionally a string as arguments");
+ if( !PyArg_ParseTuple( args, "|is", &fra, &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int and optionally a string as arguments" );
- if (!type || !strcmp(type, "relative"))
+ if( !type || !strcmp( type, "relative" ) )
typenum = 1;
- else if (!strcmp(type, "absolute"))
+ else if( !strcmp( type, "absolute" ) )
typenum = 2;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "if given, type should be 'relative' or 'absolute'");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "if given, type should be 'relative' or 'absolute'" );
- if (fra > 0) {
- fra = EXPP_ClampInt(fra, 1, NMESH_FRAME_MAX);
+ if( fra > 0 ) {
+ fra = EXPP_ClampInt( fra, 1, NMESH_FRAME_MAX );
oldfra = G.scene->r.cfra;
G.scene->r.cfra = fra;
}
- if (!mesh)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "update this NMesh first with its .update() method");
+ if( !mesh )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "update this NMesh first with its .update() method" );
- insert_meshkey(mesh, typenum);
+ insert_meshkey( mesh, typenum );
- if (fra > 0) G.scene->r.cfra = oldfra;
+ if( fra > 0 )
+ G.scene->r.cfra = oldfra;
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args)
+static PyObject *NMesh_getSelectedFaces( PyObject * self, PyObject * args )
{
- BPy_NMesh *nm = (BPy_NMesh *)self;
+ BPy_NMesh *nm = ( BPy_NMesh * ) self;
Mesh *me = nm->mesh;
int flag = 0;
TFace *tf;
int i;
- PyObject *l = PyList_New(0);
+ PyObject *l = PyList_New( 0 );
- if (me == NULL) return NULL;
+ if( me == NULL )
+ return NULL;
tf = me->tface;
- if (tf == 0) return l;
+ if( tf == 0 )
+ return l;
- if (!PyArg_ParseTuple(args, "|i", &flag))
+ if( !PyArg_ParseTuple( args, "|i", &flag ) )
return NULL;
- if (flag) {
- for (i = 0 ; i < me->totface; i++) {
- if (tf[i].flag & TF_SELECT )
- PyList_Append(l, PyInt_FromLong(i));
+ if( flag ) {
+ for( i = 0; i < me->totface; i++ ) {
+ if( tf[i].flag & TF_SELECT )
+ PyList_Append( l, PyInt_FromLong( i ) );
}
} else {
- for (i = 0 ; i < me->totface; i++) {
- if (tf[i].flag & TF_SELECT )
- PyList_Append(l, PyList_GetItem(nm->faces, i));
- }
+ for( i = 0; i < me->totface; i++ ) {
+ if( tf[i].flag & TF_SELECT )
+ PyList_Append( l,
+ PyList_GetItem( nm->faces,
+ i ) );
+ }
}
return l;
}
-static PyObject *NMesh_getActiveFace(PyObject *self, PyObject *args)
+static PyObject *NMesh_getActiveFace( PyObject * self, PyObject * args )
{
- if (((BPy_NMesh *)self)->sel_face < 0)
- return EXPP_incr_ret(Py_None);
+ if( ( ( BPy_NMesh * ) self )->sel_face < 0 )
+ return EXPP_incr_ret( Py_None );
- return Py_BuildValue("i", ((BPy_NMesh *)self)->sel_face);
+ return Py_BuildValue( "i", ( ( BPy_NMesh * ) self )->sel_face );
}
-static PyObject *NMesh_hasVertexUV(PyObject *self, PyObject *args)
+static PyObject *NMesh_hasVertexUV( PyObject * self, PyObject * args )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
int flag;
- if (args) {
- if (PyArg_ParseTuple(args, "i", &flag)) {
- if(flag) me->flags |= NMESH_HASVERTUV;
- else me->flags &= ~NMESH_HASVERTUV;
+ if( args ) {
+ if( PyArg_ParseTuple( args, "i", &flag ) ) {
+ if( flag )
+ me->flags |= NMESH_HASVERTUV;
+ else
+ me->flags &= ~NMESH_HASVERTUV;
}
}
- PyErr_Clear();
- if (me->flags & NMESH_HASVERTUV)
- return EXPP_incr_ret(Py_True);
+ PyErr_Clear( );
+ if( me->flags & NMESH_HASVERTUV )
+ return EXPP_incr_ret( Py_True );
else
- return EXPP_incr_ret(Py_False);
+ return EXPP_incr_ret( Py_False );
}
-static PyObject *NMesh_hasFaceUV(PyObject *self, PyObject *args)
+static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
int flag = -1;
- if (!PyArg_ParseTuple(args, "|i", &flag))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|i", &flag ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument (or nothing)" );
- switch (flag) {
+ switch ( flag ) {
case 0:
me->flags |= NMESH_HASFACEUV;
break;
- case 1:
+ case 1:
me->flags &= ~NMESH_HASFACEUV;
break;
default:
break;
}
- if (me->flags & NMESH_HASFACEUV)
- return EXPP_incr_ret(Py_True);
+ if( me->flags & NMESH_HASFACEUV )
+ return EXPP_incr_ret( Py_True );
else
- return EXPP_incr_ret(Py_False);
+ return EXPP_incr_ret( Py_False );
}
-static PyObject *NMesh_hasVertexColours(PyObject *self, PyObject *args)
+static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args )
{
- BPy_NMesh *me= (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
int flag = -1;
- if (!PyArg_ParseTuple(args, "|i", &flag))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|i", &flag ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument (or nothing)" );
- switch (flag) {
+ switch ( flag ) {
case 0:
me->flags &= ~NMESH_HASMCOL;
break;
- case 1:
+ case 1:
me->flags |= NMESH_HASMCOL;
break;
default:
break;
}
- if (me->flags & NMESH_HASMCOL)
- return EXPP_incr_ret(Py_True);
+ if( me->flags & NMESH_HASMCOL )
+ return EXPP_incr_ret( Py_True );
else
- return EXPP_incr_ret(Py_False);
+ return EXPP_incr_ret( Py_False );
}
-static PyObject *NMesh_update(PyObject *self, PyObject *args)
+static PyObject *NMesh_update( PyObject * self, PyObject * args )
{
int recalc_normals = 0;
- BPy_NMesh *nmesh = (BPy_NMesh *)self;
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
Mesh *mesh = nmesh->mesh;
- if (!PyArg_ParseTuple(args, "|i", &recalc_normals))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected nothing or an int (0 or 1) as argument");
+ if( !PyArg_ParseTuple( args, "|i", &recalc_normals ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected nothing or an int (0 or 1) as argument" );
- if (recalc_normals && recalc_normals != 1)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected 0 or 1 as argument");
+ if( recalc_normals && recalc_normals != 1 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "expected 0 or 1 as argument" );
- if (mesh) {
- unlink_existingMeshData(mesh);
- convert_NMeshToMesh(mesh, nmesh);
- } else {
- nmesh->mesh = Mesh_fromNMesh(nmesh);
+ if( mesh ) {
+ unlink_existingMeshData( mesh );
+ convert_NMeshToMesh( mesh, nmesh );
+ } else {
+ nmesh->mesh = Mesh_fromNMesh( nmesh );
mesh = nmesh->mesh;
}
- if (recalc_normals) vertexnormals_mesh(mesh, 0);
+ if( recalc_normals )
+ vertexnormals_mesh( mesh, 0 );
- mesh_update(mesh);
+ mesh_update( mesh );
- nmesh_updateMaterials(nmesh);
+ nmesh_updateMaterials( nmesh );
- if (nmesh->name && nmesh->name != Py_None)
- new_id(&(G.main->mesh), &mesh->id, PyString_AsString(nmesh->name));
+ if( nmesh->name && nmesh->name != Py_None )
+ new_id( &( G.main->mesh ), &mesh->id,
+ PyString_AsString( nmesh->name ) );
- if (!during_script())
- allqueue(REDRAWVIEW3D, 0);
+ if( !during_script( ) )
+ allqueue( REDRAWVIEW3D, 0 );
- return PyInt_FromLong(1);
+ return PyInt_FromLong( 1 );
}
/** Implementation of the python method getVertexInfluence for an NMesh object.
@@ -1074,460 +1096,488 @@ static PyObject *NMesh_update(PyObject *self, PyObject *args)
* influences that this vertex receives.
* @author Jordi Rovira i Bonet
*/
-static PyObject *NMesh_getVertexInfluences(PyObject *self, PyObject *args)
+static PyObject *NMesh_getVertexInfluences( PyObject * self, PyObject * args )
{
int index;
- PyObject* influence_list = NULL;
+ PyObject *influence_list = NULL;
/* Get a reference to the mesh object wrapped in here. */
- Mesh *me = ((BPy_NMesh*)self)->mesh;
+ Mesh *me = ( ( BPy_NMesh * ) self )->mesh;
- if (!me)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "unlinked nmesh: call its .update() method first");
+ if( !me )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "unlinked nmesh: call its .update() method first" );
/* Parse the parameters: only on integer (vertex index) */
- if (!PyArg_ParseTuple(args, "i", &index))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument (index of the vertex)");
+ if( !PyArg_ParseTuple( args, "i", &index ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument (index of the vertex)" );
- /* Proceed only if we have vertex deformation information and index is valid*/
- if (me->dvert) {
- if ((index >= 0) && (index < me->totvert)) {
+ /* Proceed only if we have vertex deformation information and index is valid */
+ if( me->dvert ) {
+ if( ( index >= 0 ) && ( index < me->totvert ) ) {
int i;
MDeformWeight *sweight = NULL;
-
- /* Number of bones influencing the vertex */
- int totinfluences=me->dvert[index].totweight;
-
- /* Build the list only with weights and names of the influent bones */
- /*influence_list = PyList_New(totinfluences);*/
- influence_list = PyList_New(0);
-
- /* Get the reference of the first weight structure */
- sweight = me->dvert[index].dw;
- for (i=0; i<totinfluences; i++) {
-
- /*Add the weight and the name of the bone, which is used to identify it*/
-
- if (sweight->data) /* valid bone: return its name */
-/* PyList_SetItem(influence_list, i,
- Py_BuildValue("[sf]", sweight->data->name, sweight->weight));
- else // NULL bone: return Py_None instead
- PyList_SetItem(influence_list, i,
- Py_BuildValue("[Of]", Py_None, sweight->weight));*/
- PyList_Append(influence_list,
- Py_BuildValue("[sf]", sweight->data->name, sweight->weight));
-
- /* Next weight */
+ /* Number of bones influencing the vertex */
+ int totinfluences = me->dvert[index].totweight;
+
+ /* Build the list only with weights and names of the influent bones */
+ /*influence_list = PyList_New(totinfluences); */
+ influence_list = PyList_New( 0 );
+
+ /* Get the reference of the first weight structure */
+ sweight = me->dvert[index].dw;
+
+ for( i = 0; i < totinfluences; i++ ) {
+
+ /*Add the weight and the name of the bone, which is used to identify it */
+
+ if( sweight->data )
+ /* valid bone: return its name */
+ /* PyList_SetItem(influence_list, i,
+ Py_BuildValue("[sf]", sweight->data->name, sweight->weight));
+ else // NULL bone: return Py_None instead
+ PyList_SetItem(influence_list, i,
+ Py_BuildValue("[Of]", Py_None, sweight->weight)); */
+ PyList_Append( influence_list,
+ Py_BuildValue( "[sf]",
+ sweight->
+ data->
+ name,
+ sweight->
+ weight ) );
+
+ /* Next weight */
sweight++;
}
- }
- else //influence_list = PyList_New(0);
- return EXPP_ReturnPyObjError (PyExc_IndexError,
- "vertex index out of range");
- }
- else influence_list = PyList_New(0);
+ } else //influence_list = PyList_New(0);
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "vertex index out of range" );
+ } else
+ influence_list = PyList_New( 0 );
return influence_list;
}
-Mesh *Mesh_fromNMesh(BPy_NMesh *nmesh)
+Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh )
{
Mesh *mesh = NULL;
- mesh = add_mesh();
+ mesh = add_mesh( );
- if (!mesh)
- EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "FATAL: could not create mesh object");
+ if( !mesh )
+ EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "FATAL: could not create mesh object" );
- mesh->id.us = 0; /* no user yet */
+ mesh->id.us = 0; /* no user yet */
G.totmesh++;
- convert_NMeshToMesh(mesh, nmesh);
+ convert_NMeshToMesh( mesh, nmesh );
return mesh;
}
-PyObject *NMesh_link(PyObject *self, PyObject *args)
-{/*
- BPy_Object *bl_obj;
+PyObject *NMesh_link( PyObject * self, PyObject * args )
+{ /*
+ BPy_Object *bl_obj;
- if (!PyArg_ParseTuple(args, "O!", &Object_Type, &bl_obj))
- return EXPP_ReturnPyErrorObj (PyExc_TypeError,
- "NMesh can only be linked to Objects");
+ if (!PyArg_ParseTuple(args, "O!", &Object_Type, &bl_obj))
+ return EXPP_ReturnPyErrorObj (PyExc_TypeError,
+ "NMesh can only be linked to Objects");
- bl_obj->data = (PyObject *)self;*/
+ bl_obj->data = (PyObject *)self; */
/* Better use object.link(nmesh), no need for this nmesh.link(object) */
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_getMaxSmoothAngle (BPy_NMesh *self)
+static PyObject *NMesh_getMaxSmoothAngle( BPy_NMesh * self )
{
- PyObject *attr = PyInt_FromLong (self->smoothresh);
+ PyObject *attr = PyInt_FromLong( self->smoothresh );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get NMesh.maxSmoothAngle attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get NMesh.maxSmoothAngle attribute" );
}
-static PyObject *NMesh_setMaxSmoothAngle (PyObject *self, PyObject *args)
+static PyObject *NMesh_setMaxSmoothAngle( PyObject * self, PyObject * args )
{
short value = 0;
- BPy_NMesh *nmesh = (BPy_NMesh *)self;
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
- if (!PyArg_ParseTuple(args, "h", &value))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an int in [1, 80] as argument");
+ if( !PyArg_ParseTuple( args, "h", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an int in [1, 80] as argument" );
nmesh->smoothresh =
- (short)EXPP_ClampInt (value, NMESH_SMOOTHRESH_MIN, NMESH_SMOOTHRESH_MAX);
+ ( short ) EXPP_ClampInt( value, NMESH_SMOOTHRESH_MIN,
+ NMESH_SMOOTHRESH_MAX );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *NMesh_getSubDivLevels (BPy_NMesh *self)
+static PyObject *NMesh_getSubDivLevels( BPy_NMesh * self )
{
- PyObject *attr = Py_BuildValue ("[h,h]", self->subdiv[0], self->subdiv[1]);
+ PyObject *attr =
+ Py_BuildValue( "[h,h]", self->subdiv[0], self->subdiv[1] );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get NMesh.subDivLevels attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get NMesh.subDivLevels attribute" );
}
-static PyObject *NMesh_setSubDivLevels (PyObject *self, PyObject *args)
+static PyObject *NMesh_setSubDivLevels( PyObject * self, PyObject * args )
{
short display = 0, render = 0;
- BPy_NMesh *nmesh = (BPy_NMesh *)self;
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
- if (!PyArg_ParseTuple(args, "(hh)", &display, &render))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a sequence [int, int] as argument");
+ if( !PyArg_ParseTuple( args, "(hh)", &display, &render ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a sequence [int, int] as argument" );
nmesh->subdiv[0] =
- (short)EXPP_ClampInt (display, NMESH_SUBDIV_MIN, NMESH_SUBDIV_MAX);
+ ( short ) EXPP_ClampInt( display, NMESH_SUBDIV_MIN,
+ NMESH_SUBDIV_MAX );
nmesh->subdiv[1] =
- (short)EXPP_ClampInt (render, NMESH_SUBDIV_MIN, NMESH_SUBDIV_MAX);
+ ( short ) EXPP_ClampInt( render, NMESH_SUBDIV_MIN,
+ NMESH_SUBDIV_MAX );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *NMesh_getMode (BPy_NMesh *self)
+static PyObject *NMesh_getMode( BPy_NMesh * self )
{
- PyObject *attr = PyInt_FromLong (self->mode);
+ PyObject *attr = PyInt_FromLong( self->mode );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get NMesh.mode attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get NMesh.mode attribute" );
}
-static PyObject *NMesh_setMode (PyObject *self, PyObject *args)
+static PyObject *NMesh_setMode( PyObject * self, PyObject * args )
{
- BPy_NMesh *nmesh = (BPy_NMesh *)self;
- char *m[5] = {NULL, NULL, NULL, NULL, NULL};
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) self;
+ char *m[5] = { NULL, NULL, NULL, NULL, NULL };
short i, mode = 0;
- if (!PyArg_ParseTuple(args, "|sssss", &m[0], &m[1], &m[2], &m[3], &m[4]))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected from none to 5 strings as argument(s)");
+ if( !PyArg_ParseTuple
+ ( args, "|sssss", &m[0], &m[1], &m[2], &m[3], &m[4] ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected from none to 5 strings as argument(s)" );
- for (i = 0; i < 5; i++) {
- if (!m[i]) break;
- if (strcmp(m[i], "NoVNormalsFlip") == 0)
+ for( i = 0; i < 5; i++ ) {
+ if( !m[i] )
+ break;
+ if( strcmp( m[i], "NoVNormalsFlip" ) == 0 )
mode |= EXPP_NMESH_MODE_NOPUNOFLIP;
- else if (strcmp(m[i], "TwoSided") == 0)
+ else if( strcmp( m[i], "TwoSided" ) == 0 )
mode |= EXPP_NMESH_MODE_TWOSIDED;
- else if (strcmp(m[i], "AutoSmooth") == 0)
+ else if( strcmp( m[i], "AutoSmooth" ) == 0 )
mode |= EXPP_NMESH_MODE_AUTOSMOOTH;
- else if (strcmp(m[i], "SubSurf") == 0)
+ else if( strcmp( m[i], "SubSurf" ) == 0 )
mode |= EXPP_NMESH_MODE_SUBSURF;
- else if (strcmp(m[i], "Optimal") == 0)
+ else if( strcmp( m[i], "Optimal" ) == 0 )
mode |= EXPP_NMESH_MODE_OPTIMAL;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown NMesh mode");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown NMesh mode" );
}
nmesh->mode = mode;
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
#undef MethodDef
#define MethodDef(func) {#func, NMesh_##func, METH_VARARGS, NMesh_##func##_doc}
-static struct PyMethodDef NMesh_methods[] =
-{
- MethodDef(addVertGroup),
- MethodDef(removeVertGroup),
- MethodDef(assignVertsToGroup),
- MethodDef(removeVertsFromGroup),
- MethodDef(getVertsFromGroup),
- MethodDef(renameVertGroup),
- MethodDef(getVertGroupNames),
- MethodDef(hasVertexColours),
- MethodDef(hasFaceUV),
- MethodDef(hasVertexUV),
- MethodDef(getActiveFace),
- MethodDef(getSelectedFaces),
- MethodDef(getVertexInfluences),
- MethodDef(getMaterials),
- MethodDef(setMaterials),
- MethodDef(addMaterial),
- MethodDef(insertKey),
- MethodDef(removeAllKeys),
- MethodDef(update),
- MethodDef(setMode),
- MethodDef(setMaxSmoothAngle),
- MethodDef(setSubDivLevels),
- {"getMode", (PyCFunction)NMesh_getMode, METH_NOARGS, NMesh_getMode_doc},
- {"getMaxSmoothAngle", (PyCFunction)NMesh_getMaxSmoothAngle, METH_NOARGS,
- NMesh_getMaxSmoothAngle_doc},
- {"getSubDivLevels", (PyCFunction)NMesh_getSubDivLevels, METH_NOARGS,
- NMesh_getSubDivLevels_doc},
+static struct PyMethodDef NMesh_methods[] = {
+ MethodDef( addVertGroup ),
+ MethodDef( removeVertGroup ),
+ MethodDef( assignVertsToGroup ),
+ MethodDef( removeVertsFromGroup ),
+ MethodDef( getVertsFromGroup ),
+ MethodDef( renameVertGroup ),
+ MethodDef( getVertGroupNames ),
+ MethodDef( hasVertexColours ),
+ MethodDef( hasFaceUV ),
+ MethodDef( hasVertexUV ),
+ MethodDef( getActiveFace ),
+ MethodDef( getSelectedFaces ),
+ MethodDef( getVertexInfluences ),
+ MethodDef( getMaterials ),
+ MethodDef( setMaterials ),
+ MethodDef( addMaterial ),
+ MethodDef( insertKey ),
+ MethodDef( removeAllKeys ),
+ MethodDef( update ),
+ MethodDef( setMode ),
+ MethodDef( setMaxSmoothAngle ),
+ MethodDef( setSubDivLevels ),
+ {"getMode", ( PyCFunction ) NMesh_getMode, METH_NOARGS,
+ NMesh_getMode_doc},
+ {"getMaxSmoothAngle", ( PyCFunction ) NMesh_getMaxSmoothAngle,
+ METH_NOARGS,
+ NMesh_getMaxSmoothAngle_doc},
+ {"getSubDivLevels", ( PyCFunction ) NMesh_getSubDivLevels, METH_NOARGS,
+ NMesh_getSubDivLevels_doc},
{NULL, NULL, 0, NULL}
};
-static PyObject *NMesh_getattr(PyObject *self, char *name)
+static PyObject *NMesh_getattr( PyObject * self, char *name )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
- if (strcmp(name, "name") == 0)
- return EXPP_incr_ret(me->name);
+ if( strcmp( name, "name" ) == 0 )
+ return EXPP_incr_ret( me->name );
- else if (strcmp(name, "mode") == 0)
- return PyInt_FromLong(me->mode);
+ else if( strcmp( name, "mode" ) == 0 )
+ return PyInt_FromLong( me->mode );
- else if (strcmp(name, "block_type") == 0) /* for compatibility */
- return PyString_FromString("NMesh");
+ else if( strcmp( name, "block_type" ) == 0 ) /* for compatibility */
+ return PyString_FromString( "NMesh" );
- else if (strcmp(name, "materials") == 0)
- return EXPP_incr_ret(me->materials);
+ else if( strcmp( name, "materials" ) == 0 )
+ return EXPP_incr_ret( me->materials );
- else if (strcmp(name, "verts") == 0)
- return EXPP_incr_ret(me->verts);
+ else if( strcmp( name, "verts" ) == 0 )
+ return EXPP_incr_ret( me->verts );
- else if (strcmp(name, "maxSmoothAngle") == 0)
- return PyInt_FromLong(me->smoothresh);
+ else if( strcmp( name, "maxSmoothAngle" ) == 0 )
+ return PyInt_FromLong( me->smoothresh );
- else if (strcmp(name, "subDivLevels") == 0)
- return Py_BuildValue("[h,h]", me->subdiv[0], me->subdiv[1]);
+ else if( strcmp( name, "subDivLevels" ) == 0 )
+ return Py_BuildValue( "[h,h]", me->subdiv[0], me->subdiv[1] );
- else if (strcmp(name, "users") == 0) {
- if (me->mesh) {
- return PyInt_FromLong(me->mesh->id.us);
- }
- else { /* it's a free mesh: */
- return Py_BuildValue("i", 0);
+ else if( strcmp( name, "users" ) == 0 ) {
+ if( me->mesh ) {
+ return PyInt_FromLong( me->mesh->id.us );
+ } else { /* it's a free mesh: */
+ return Py_BuildValue( "i", 0 );
}
}
- else if (strcmp(name, "faces") == 0)
- return EXPP_incr_ret(me->faces);
+ else if( strcmp( name, "faces" ) == 0 )
+ return EXPP_incr_ret( me->faces );
- else if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s,s,s,s,s]",
- "name", "materials", "verts", "users", "faces", "maxSmoothAngle",
- "subdivLevels");
+ else if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s,s,s,s,s]",
+ "name", "materials", "verts", "users",
+ "faces", "maxSmoothAngle",
+ "subdivLevels" );
- return Py_FindMethod(NMesh_methods, (PyObject*)self, name);
+ return Py_FindMethod( NMesh_methods, ( PyObject * ) self, name );
}
-static int NMesh_setattr(PyObject *self, char *name, PyObject *v)
+static int NMesh_setattr( PyObject * self, char *name, PyObject * v )
{
- BPy_NMesh *me = (BPy_NMesh *)self;
+ BPy_NMesh *me = ( BPy_NMesh * ) self;
- if (!strcmp(name, "name")) {
+ if( !strcmp( name, "name" ) ) {
- if (!PyString_Check(v))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected string argument");
+ if( !PyString_Check( v ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected string argument" );
- Py_DECREF (me->name);
- me->name = EXPP_incr_ret(v);
+ Py_DECREF( me->name );
+ me->name = EXPP_incr_ret( v );
}
- else if (!strcmp(name, "mode")) {
+ else if( !strcmp( name, "mode" ) ) {
short mode;
- if (!PyInt_Check(v))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected int argument");
+ if( !PyInt_Check( v ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int argument" );
- mode = (short)PyInt_AsLong(v);
- if (mode >= 0) me->mode = mode;
+ mode = ( short ) PyInt_AsLong( v );
+ if( mode >= 0 )
+ me->mode = mode;
else
- return EXPP_ReturnIntError (PyExc_ValueError,
- "expected positive int argument");
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "expected positive int argument" );
}
- else if (!strcmp(name, "verts") || !strcmp(name, "faces") ||
- !strcmp(name, "materials")) {
+ else if( !strcmp( name, "verts" ) || !strcmp( name, "faces" ) ||
+ !strcmp( name, "materials" ) ) {
- if(PySequence_Check(v)) {
+ if( PySequence_Check( v ) ) {
- if(strcmp(name, "materials") == 0) {
- Py_DECREF(me->materials);
- me->materials = EXPP_incr_ret(v);
- }
- else if (strcmp(name, "verts") == 0) {
- Py_DECREF(me->verts);
- me->verts = EXPP_incr_ret(v);
- }
- else {
- Py_DECREF(me->faces);
- me->faces = EXPP_incr_ret(v);
+ if( strcmp( name, "materials" ) == 0 ) {
+ Py_DECREF( me->materials );
+ me->materials = EXPP_incr_ret( v );
+ } else if( strcmp( name, "verts" ) == 0 ) {
+ Py_DECREF( me->verts );
+ me->verts = EXPP_incr_ret( v );
+ } else {
+ Py_DECREF( me->faces );
+ me->faces = EXPP_incr_ret( v );
}
}
else
- return EXPP_ReturnIntError (PyExc_TypeError, "expected a sequence");
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a sequence" );
}
- else if (!strcmp(name, "maxSmoothAngle")) {
+ else if( !strcmp( name, "maxSmoothAngle" ) ) {
short smoothresh = 0;
- if (!PyInt_Check(v))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected int argument");
+ if( !PyInt_Check( v ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int argument" );
- smoothresh = (short)PyInt_AsLong(v);
+ smoothresh = ( short ) PyInt_AsLong( v );
me->smoothresh =
- EXPP_ClampInt(smoothresh, NMESH_SMOOTHRESH_MIN, NMESH_SMOOTHRESH_MAX);
+ EXPP_ClampInt( smoothresh, NMESH_SMOOTHRESH_MIN,
+ NMESH_SMOOTHRESH_MAX );
}
- else if (!strcmp(name, "subDivLevels")) {
- int subdiv[2] = {0,0};
+ else if( !strcmp( name, "subDivLevels" ) ) {
+ int subdiv[2] = { 0, 0 };
int i;
PyObject *tmp;
- if (!PySequence_Check(v) || (PySequence_Length(v) != 2))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected a list [int, int] as argument");
-
- for (i = 0; i < 2; i++) {
- tmp = PySequence_GetItem(v, i);
- if (tmp) {
- if (!PyInt_Check(tmp)) {
- Py_DECREF (tmp);
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected a list [int, int] as argument");
+ if( !PySequence_Check( v ) || ( PySequence_Length( v ) != 2 ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a list [int, int] as argument" );
+
+ for( i = 0; i < 2; i++ ) {
+ tmp = PySequence_GetItem( v, i );
+ if( tmp ) {
+ if( !PyInt_Check( tmp ) ) {
+ Py_DECREF( tmp );
+ return EXPP_ReturnIntError
+ ( PyExc_TypeError,
+ "expected a list [int, int] as argument" );
}
- subdiv[i] = PyInt_AsLong (tmp);
+ subdiv[i] = PyInt_AsLong( tmp );
me->subdiv[i] =
- (short)EXPP_ClampInt(subdiv[i], NMESH_SUBDIV_MIN, NMESH_SUBDIV_MAX);
- Py_DECREF (tmp);
- }
- else return EXPP_ReturnIntError (PyExc_RuntimeError,
- "couldn't retrieve subdiv values from list");
+ ( short ) EXPP_ClampInt( subdiv[i],
+ NMESH_SUBDIV_MIN,
+ NMESH_SUBDIV_MAX );
+ Py_DECREF( tmp );
+ } else
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "couldn't retrieve subdiv values from list" );
}
}
else
- return EXPP_ReturnIntError (PyExc_AttributeError, name);
+ return EXPP_ReturnIntError( PyExc_AttributeError, name );
return 0;
}
-PyTypeObject NMesh_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Blender NMesh", /*tp_name*/
- sizeof(BPy_NMesh), /*tp_basicsize*/
- 0, /*tp_itemsize*/
+PyTypeObject NMesh_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender NMesh", /*tp_name */
+ sizeof( BPy_NMesh ), /*tp_basicsize */
+ 0, /*tp_itemsize */
/* methods */
- (destructor) NMesh_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) NMesh_getattr, /*tp_getattr*/
- (setattrfunc) NMesh_setattr, /*tp_setattr*/
+ ( destructor ) NMesh_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) NMesh_getattr, /*tp_getattr */
+ ( setattrfunc ) NMesh_setattr, /*tp_setattr */
};
-static BPy_NMFace *nmface_from_data(BPy_NMesh *mesh, int vidxs[4],
- char mat_nr, char flag, TFace *tface, MCol *col)
+static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4],
+ char mat_nr, char flag, TFace * tface,
+ MCol * col )
{
- BPy_NMFace *newf = PyObject_NEW (BPy_NMFace, &NMFace_Type);
+ BPy_NMFace *newf = PyObject_NEW( BPy_NMFace, &NMFace_Type );
int i, len;
- if (vidxs[3]) len = 4;
- else if (vidxs[2]) len = 3;
- else len = 2;
+ if( vidxs[3] )
+ len = 4;
+ else if( vidxs[2] )
+ len = 3;
+ else
+ len = 2;
- newf->v = PyList_New(len);
+ newf->v = PyList_New( len );
- for (i = 0; i < len; i++)
- PyList_SetItem(newf->v, i,
- EXPP_incr_ret(PyList_GetItem(mesh->verts, vidxs[i])));
+ for( i = 0; i < len; i++ )
+ PyList_SetItem( newf->v, i,
+ EXPP_incr_ret( PyList_GetItem
+ ( mesh->verts, vidxs[i] ) ) );
- if (tface) {
- newf->uv = PyList_New(len); // per-face UV coordinates
+ if( tface ) {
+ newf->uv = PyList_New( len ); // per-face UV coordinates
- for (i = 0; i < len; i++) {
- PyList_SetItem(newf->uv, i,
- Py_BuildValue("(ff)", tface->uv[i][0], tface->uv[i][1]));
+ for( i = 0; i < len; i++ ) {
+ PyList_SetItem( newf->uv, i,
+ Py_BuildValue( "(ff)", tface->uv[i][0],
+ tface->uv[i][1] ) );
}
- if (tface->tpage) /* pointer to image per face: */
- newf->image = (Image *)tface->tpage;
+ if( tface->tpage ) /* pointer to image per face: */
+ newf->image = ( Image * ) tface->tpage;
else
newf->image = NULL;
- newf->mode = tface->mode; /* draw mode */
- newf->flag = tface->flag; /* select flag */
- newf->transp = tface->transp; /* transparency flag */
- col = (MCol *) (tface->col); /* XXX weird, tface->col is uint[4] */
- }
- else {
- newf->mode = TF_DYNAMIC; /* just to initialize it to something meaninful,*/
+ newf->mode = tface->mode; /* draw mode */
+ newf->flag = tface->flag; /* select flag */
+ newf->transp = tface->transp; /* transparency flag */
+ col = ( MCol * ) ( tface->col ); /* XXX weird, tface->col is uint[4] */
+ } else {
+ newf->mode = TF_DYNAMIC; /* just to initialize it to something meaninful, */
/* since without tfaces there are no tface->mode's, obviously. */
newf->image = NULL;
- newf->uv = PyList_New(0);
- }
+ newf->uv = PyList_New( 0 );
+ }
newf->mat_nr = mat_nr;
newf->smooth = flag & ME_SMOOTH;
- if (col) {
- newf->col = PyList_New(4);
- for(i = 0; i < 4; i++, col++) {
- PyList_SetItem(newf->col, i,
- (PyObject *)newcol(col->b, col->g, col->r, col->a));
+ if( col ) {
+ newf->col = PyList_New( 4 );
+ for( i = 0; i < 4; i++, col++ ) {
+ PyList_SetItem( newf->col, i,
+ ( PyObject * ) newcol( col->b, col->g,
+ col->r,
+ col->a ) );
}
- }
- else newf->col = PyList_New(0);
+ } else
+ newf->col = PyList_New( 0 );
return newf;
}
-static BPy_NMVert *nmvert_from_data(BPy_NMesh *me,
- MVert *vert, MSticky *st, float *co, int idx, char flag)
+static BPy_NMVert *nmvert_from_data( BPy_NMesh * me,
+ MVert * vert, MSticky * st, float *co,
+ int idx, char flag )
{
- BPy_NMVert *mv = PyObject_NEW(BPy_NMVert, &NMVert_Type);
+ BPy_NMVert *mv = PyObject_NEW( BPy_NMVert, &NMVert_Type );
- mv->co[0] = co[0]; mv->co[1] = co[1]; mv->co[2] = co[2];
+ mv->co[0] = co[0];
+ mv->co[1] = co[1];
+ mv->co[2] = co[2];
- mv->no[0] = vert->no[0]/32767.0;
- mv->no[1] = vert->no[1]/32767.0;
- mv->no[2] = vert->no[2]/32767.0;
+ mv->no[0] = vert->no[0] / 32767.0;
+ mv->no[1] = vert->no[1] / 32767.0;
+ mv->no[2] = vert->no[2] / 32767.0;
- if (st) {
+ if( st ) {
mv->uvco[0] = st->co[0];
mv->uvco[1] = st->co[1];
mv->uvco[2] = 0.0;
- } else mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
+ } else
+ mv->uvco[0] = mv->uvco[1] = mv->uvco[2] = 0.0;
mv->index = idx;
mv->flag = flag & 1;
@@ -1535,42 +1585,44 @@ static BPy_NMVert *nmvert_from_data(BPy_NMesh *me,
return mv;
}
-static int get_active_faceindex(Mesh *me)
+static int get_active_faceindex( Mesh * me )
{
TFace *tf;
int i;
- if (me == NULL) return -1;
+ if( me == NULL )
+ return -1;
tf = me->tface;
- if (tf == 0) return -1;
+ if( tf == 0 )
+ return -1;
- for (i = 0 ; i < me->totface; i++)
- if (tf[i].flag & TF_ACTIVE ) return i;
+ for( i = 0; i < me->totface; i++ )
+ if( tf[i].flag & TF_ACTIVE )
+ return i;
return -1;
}
-static PyObject *new_NMesh_internal(Mesh *oldmesh,
- DispListMesh *dlm, float *extverts)
+static PyObject *new_NMesh_internal( Mesh * oldmesh,
+ DispListMesh * dlm, float *extverts )
{
- BPy_NMesh *me = PyObject_NEW (BPy_NMesh, &NMesh_Type);
+ BPy_NMesh *me = PyObject_NEW( BPy_NMesh, &NMesh_Type );
me->flags = 0;
- me->mode = EXPP_NMESH_MODE_TWOSIDED; /* default for new meshes */
+ me->mode = EXPP_NMESH_MODE_TWOSIDED; /* default for new meshes */
me->subdiv[0] = NMESH_SUBDIV;
me->subdiv[1] = NMESH_SUBDIV;
me->smoothresh = NMESH_SMOOTHRESH;
- me->object = NULL; /* not linked to any object yet */
+ me->object = NULL; /* not linked to any object yet */
- if (!oldmesh) {
- me->name = EXPP_incr_ret(Py_None);
- me->materials = PyList_New(0);
- me->verts = PyList_New(0);
- me->faces = PyList_New(0);
+ if( !oldmesh ) {
+ me->name = EXPP_incr_ret( Py_None );
+ me->materials = PyList_New( 0 );
+ me->verts = PyList_New( 0 );
+ me->faces = PyList_New( 0 );
me->mesh = 0;
- }
- else {
+ } else {
MVert *mverts;
MSticky *msticky;
MFace *mfaces;
@@ -1578,8 +1630,8 @@ static PyObject *new_NMesh_internal(Mesh *oldmesh,
MCol *mcols;
int i, totvert, totface;
- if (dlm) {
- me->name = EXPP_incr_ret(Py_None);
+ if( dlm ) {
+ me->name = EXPP_incr_ret( Py_None );
me->mesh = 0;
msticky = NULL;
@@ -1591,11 +1643,10 @@ static PyObject *new_NMesh_internal(Mesh *oldmesh,
totvert = dlm->totvert;
totface = dlm->totface;
- }
- else {
- me->name = PyString_FromString(oldmesh->id.name+2);
+ } else {
+ me->name = PyString_FromString( oldmesh->id.name + 2 );
me->mesh = oldmesh;
- me->mode = oldmesh->flag; /* yes, we save the mesh flags in nmesh->mode*/
+ me->mode = oldmesh->flag; /* yes, we save the mesh flags in nmesh->mode */
me->subdiv[0] = oldmesh->subdiv;
me->subdiv[1] = oldmesh->subdivr;
me->smoothresh = oldmesh->smoothresh;
@@ -1609,28 +1660,37 @@ static PyObject *new_NMesh_internal(Mesh *oldmesh,
totvert = oldmesh->totvert;
totface = oldmesh->totface;
- me->sel_face = get_active_faceindex(oldmesh);
+ me->sel_face = get_active_faceindex( oldmesh );
}
- if (msticky) me->flags |= NMESH_HASVERTUV;
- if (tfaces) me->flags |= NMESH_HASFACEUV;
- if (mcols) me->flags |= NMESH_HASMCOL;
+ if( msticky )
+ me->flags |= NMESH_HASVERTUV;
+ if( tfaces )
+ me->flags |= NMESH_HASFACEUV;
+ if( mcols )
+ me->flags |= NMESH_HASMCOL;
- me->verts = PyList_New(totvert);
+ me->verts = PyList_New( totvert );
- for (i = 0; i < totvert; i++) {
+ for( i = 0; i < totvert; i++ ) {
MVert *oldmv = &mverts[i];
- MSticky *oldst = msticky?&msticky[i]:NULL;
- float *vco = extverts?&extverts[i*3]:oldmv->co;
-
- PyList_SetItem(me->verts, i,
- (PyObject *)nmvert_from_data(me, oldmv, oldst, vco, i, oldmv->flag));
+ MSticky *oldst = msticky ? &msticky[i] : NULL;
+ float *vco = extverts ? &extverts[i * 3] : oldmv->co;
+
+ PyList_SetItem( me->verts, i,
+ ( PyObject * ) nmvert_from_data( me,
+ oldmv,
+ oldst,
+ vco,
+ i,
+ oldmv->
+ flag ) );
}
- me->faces = PyList_New(totface);
- for (i = 0; i < totface; i++) {
- TFace *oldtf = tfaces?&tfaces[i]:NULL;
- MCol *oldmc = mcols?&mcols[i*4]:NULL;
+ me->faces = PyList_New( totface );
+ for( i = 0; i < totface; i++ ) {
+ TFace *oldtf = tfaces ? &tfaces[i] : NULL;
+ MCol *oldmc = mcols ? &mcols[i * 4] : NULL;
MFace *oldmf = &mfaces[i];
int vidxs[4];
vidxs[0] = oldmf->v1;
@@ -1638,109 +1698,122 @@ static PyObject *new_NMesh_internal(Mesh *oldmesh,
vidxs[2] = oldmf->v3;
vidxs[3] = oldmf->v4;
- PyList_SetItem (me->faces, i,
- (PyObject *)nmface_from_data(me, vidxs, oldmf->mat_nr, oldmf->flag, oldtf, oldmc));
+ PyList_SetItem( me->faces, i,
+ ( PyObject * ) nmface_from_data( me,
+ vidxs,
+ oldmf->
+ mat_nr,
+ oldmf->
+ flag,
+ oldtf,
+ oldmc ) );
}
- me->materials = EXPP_PyList_fromMaterialList(oldmesh->mat, oldmesh->totcol, 0);
+ me->materials =
+ EXPP_PyList_fromMaterialList( oldmesh->mat,
+ oldmesh->totcol, 0 );
}
- return (PyObject *)me;
+ return ( PyObject * ) me;
}
-PyObject *new_NMesh(Mesh *oldmesh)
+PyObject *new_NMesh( Mesh * oldmesh )
{
- return new_NMesh_internal (oldmesh, NULL, NULL);
+ return new_NMesh_internal( oldmesh, NULL, NULL );
}
-static PyObject *M_NMesh_New(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_New( PyObject * self, PyObject * args )
{
char *name = NULL;
PyObject *ret = NULL;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or a string as argument");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or a string as argument" );
- ret = new_NMesh(NULL);
+ ret = new_NMesh( NULL );
- if (ret && name) {
- BPy_NMesh *nmesh = (BPy_NMesh *)ret;
- Py_DECREF (nmesh->name);
- nmesh->name = PyString_FromString(name);
+ if( ret && name ) {
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) ret;
+ Py_DECREF( nmesh->name );
+ nmesh->name = PyString_FromString( name );
}
return ret;
}
-static PyObject *M_NMesh_GetRaw(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_GetRaw( PyObject * self, PyObject * args )
{
char *name = NULL;
Mesh *oldmesh = NULL;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" );
- if (name) {
- oldmesh = (Mesh *)GetIdFromList(&(G.main->mesh), name);
+ if( name ) {
+ oldmesh = ( Mesh * ) GetIdFromList( &( G.main->mesh ), name );
- if (!oldmesh) return EXPP_incr_ret(Py_None);
+ if( !oldmesh )
+ return EXPP_incr_ret( Py_None );
}
- return new_NMesh(oldmesh);
+ return new_NMesh( oldmesh );
}
/* Note: NMesh.GetRawFromObject gets the display list mesh from Blender:
* the vertices are already transformed / deformed. */
-static PyObject *M_NMesh_GetRawFromObject(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_GetRawFromObject( PyObject * self, PyObject * args )
{
char *name;
Object *ob;
PyObject *nmesh;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- ob = (Object*)GetIdFromList(&(G.main->object), name);
+ ob = ( Object * ) GetIdFromList( &( G.main->object ), name );
- if (!ob)
- return EXPP_ReturnPyObjError (PyExc_AttributeError, name);
- else if (ob->type != OB_MESH)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Object does not have Mesh data");
+ if( !ob )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
+ else if( ob->type != OB_MESH )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Object does not have Mesh data" );
else {
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = ( Mesh * ) ob->data;
DispList *dl;
- if (mesh_uses_displist(me) && (dl = find_displist(&me->disp, DL_MESH)))
- nmesh = new_NMesh_internal(me, dl->mesh, NULL);
- else if ((dl= find_displist(&ob->disp, DL_VERTS)))
- nmesh = new_NMesh_internal(me, NULL, dl->verts);
+ if( mesh_uses_displist( me )
+ && ( dl = find_displist( &me->disp, DL_MESH ) ) )
+ nmesh = new_NMesh_internal( me, dl->mesh, NULL );
+ else if( ( dl = find_displist( &ob->disp, DL_VERTS ) ) )
+ nmesh = new_NMesh_internal( me, NULL, dl->verts );
else
- nmesh = new_NMesh(me);
+ nmesh = new_NMesh( me );
}
/* @hack: to mark that (deformed) mesh is readonly, so the update function
* will not try to write it. */
- ((BPy_NMesh *) nmesh)->mesh = 0;
+ ( ( BPy_NMesh * ) nmesh )->mesh = 0;
return nmesh;
}
-static void mvert_from_data(MVert *mv, MSticky *st, BPy_NMVert *from)
+static void mvert_from_data( MVert * mv, MSticky * st, BPy_NMVert * from )
{
- mv->co[0] = from->co[0]; mv->co[1] = from->co[1]; mv->co[2] = from->co[2];
+ mv->co[0] = from->co[0];
+ mv->co[1] = from->co[1];
+ mv->co[2] = from->co[2];
+
+ mv->no[0] = from->no[0] * 32767.0;
+ mv->no[1] = from->no[1] * 32767.0;
+ mv->no[2] = from->no[2] * 32767.0;
- mv->no[0] = from->no[0]*32767.0;
- mv->no[1] = from->no[1]*32767.0;
- mv->no[2] = from->no[2]*32767.0;
-
- mv->flag = (from->flag & 1);
+ mv->flag = ( from->flag & 1 );
mv->mat_nr = 0;
- if (st) {
+ if( st ) {
st->co[0] = from->uvco[0];
st->co[1] = from->uvco[1];
}
@@ -1750,22 +1823,25 @@ static void mvert_from_data(MVert *mv, MSticky *st, BPy_NMVert *from)
* RGBA/BRGA confusion, it just works, but will never work with
* a restructured Blender */
-static void assign_perFaceColors(TFace *tf, BPy_NMFace *from)
+static void assign_perFaceColors( TFace * tf, BPy_NMFace * from )
{
MCol *col;
int i;
- col = (MCol *)(tf->col);
-
- if (col) {
- int len = PySequence_Length(from->col);
-
- if(len > 4) len = 4;
-
- for (i = 0; i < len; i++, col++) {
- BPy_NMCol *mc = (BPy_NMCol *)PySequence_GetItem(from->col, i);
- if(!BPy_NMCol_Check(mc)) {
- Py_DECREF(mc);
+ col = ( MCol * ) ( tf->col );
+
+ if( col ) {
+ int len = PySequence_Length( from->col );
+
+ if( len > 4 )
+ len = 4;
+
+ for( i = 0; i < len; i++, col++ ) {
+ BPy_NMCol *mc =
+ ( BPy_NMCol * ) PySequence_GetItem( from->col,
+ i );
+ if( !BPy_NMCol_Check( mc ) ) {
+ Py_DECREF( mc );
continue;
}
@@ -1774,98 +1850,107 @@ static void assign_perFaceColors(TFace *tf, BPy_NMFace *from)
col->g = mc->g;
col->a = mc->a;
- Py_DECREF(mc);
+ Py_DECREF( mc );
}
}
}
-static int assignFaceUV(TFace *tf, BPy_NMFace *nmface)
+static int assignFaceUV( TFace * tf, BPy_NMFace * nmface )
{
PyObject *fuv, *tmp;
int i;
fuv = nmface->uv;
- if (PySequence_Length(fuv) == 0)
+ if( PySequence_Length( fuv ) == 0 )
return 0;
/* fuv = [(u_1, v_1), ... (u_n, v_n)] */
- for (i = 0; i < PySequence_Length(fuv); i++) {
- tmp = PyList_GetItem(fuv, i); /* stolen reference ! */
- if (!PyArg_ParseTuple(tmp, "ff", &(tf->uv[i][0]), &(tf->uv[i][1])))
+ for( i = 0; i < PySequence_Length( fuv ); i++ ) {
+ tmp = PyList_GetItem( fuv, i ); /* stolen reference ! */
+ if( !PyArg_ParseTuple
+ ( tmp, "ff", &( tf->uv[i][0] ), &( tf->uv[i][1] ) ) )
return 0;
}
- if (nmface->image) /* image assigned ? */
- {
- tf->tpage = (void *)nmface->image;
- }
- else
+ if( nmface->image ) { /* image assigned ? */
+ tf->tpage = ( void * ) nmface->image;
+ } else
tf->tpage = 0;
- tf->mode = nmface->mode; /* copy mode */
- tf->flag = nmface->flag; /* copy flag */
- tf->transp = nmface->transp; /* copy transp flag */
+ tf->mode = nmface->mode; /* copy mode */
+ tf->flag = nmface->flag; /* copy flag */
+ tf->transp = nmface->transp; /* copy transp flag */
/* assign vertex colours */
- assign_perFaceColors(tf, nmface);
+ assign_perFaceColors( tf, nmface );
return 1;
}
-static void mface_from_data(MFace *mf, TFace *tf, MCol *col, BPy_NMFace *from)
+static void mface_from_data( MFace * mf, TFace * tf, MCol * col,
+ BPy_NMFace * from )
{
BPy_NMVert *nmv;
- int i = PyList_Size(from->v);
- if (i >= 1) {
- nmv = (BPy_NMVert *)PyList_GetItem(from->v, 0);
- if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v1 = nmv->index;
- else mf->v1 = 0;
+ int i = PyList_Size( from->v );
+ if( i >= 1 ) {
+ nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 0 );
+ if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
+ mf->v1 = nmv->index;
+ else
+ mf->v1 = 0;
}
- if (i >= 2) {
- nmv = (BPy_NMVert *)PyList_GetItem(from->v, 1);
- if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v2 = nmv->index;
- else mf->v2 = 0;
+ if( i >= 2 ) {
+ nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 1 );
+ if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
+ mf->v2 = nmv->index;
+ else
+ mf->v2 = 0;
}
- if (i >= 3) {
- nmv = (BPy_NMVert *)PyList_GetItem(from->v, 2);
- if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v3 = nmv->index;
- else mf->v3= 0;
+ if( i >= 3 ) {
+ nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 2 );
+ if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
+ mf->v3 = nmv->index;
+ else
+ mf->v3 = 0;
}
- if(i >= 4) {
- nmv = (BPy_NMVert *)PyList_GetItem(from->v, 3);
- if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v4 = nmv->index;
- else mf->v4= 0;
+ if( i >= 4 ) {
+ nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 3 );
+ if( BPy_NMVert_Check( nmv ) && nmv->index != -1 )
+ mf->v4 = nmv->index;
+ else
+ mf->v4 = 0;
}
- if (tf) {
- assignFaceUV(tf, from);
- if (PyErr_Occurred())
- {
- PyErr_Print();
+ if( tf ) {
+ assignFaceUV( tf, from );
+ if( PyErr_Occurred( ) ) {
+ PyErr_Print( );
return;
}
- test_index_face(mf, tf, i);
- }
- else {
- test_index_mface(mf, i);
+ test_index_face( mf, tf, i );
+ } else {
+ test_index_mface( mf, i );
}
mf->puno = 0;
mf->mat_nr = from->mat_nr;
mf->edcode = 0;
- if (from->smooth)
+ if( from->smooth )
mf->flag = ME_SMOOTH;
else
mf->flag = 0;
- if (col) {
- int len = PySequence_Length(from->col);
+ if( col ) {
+ int len = PySequence_Length( from->col );
- if(len > 4) len = 4;
+ if( len > 4 )
+ len = 4;
- for (i = 0; i < len; i++, col++) {
- BPy_NMCol *mc = (BPy_NMCol *) PySequence_GetItem(from->col, i);
- if(!BPy_NMCol_Check(mc)) {
- Py_DECREF(mc);
+ for( i = 0; i < len; i++, col++ ) {
+ BPy_NMCol *mc =
+ ( BPy_NMCol * ) PySequence_GetItem( from->col,
+ i );
+ if( !BPy_NMCol_Check( mc ) ) {
+ Py_DECREF( mc );
continue;
}
@@ -1874,43 +1959,43 @@ static void mface_from_data(MFace *mf, TFace *tf, MCol *col, BPy_NMFace *from)
col->r = mc->b;
col->a = mc->a;
- Py_DECREF(mc);
+ Py_DECREF( mc );
}
}
}
/* check for a valid UV sequence */
-static int check_validFaceUV(BPy_NMesh *nmesh)
+static int check_validFaceUV( BPy_NMesh * nmesh )
{
PyObject *faces;
BPy_NMFace *nmface;
int i, n;
faces = nmesh->faces;
- for (i = 0; i < PySequence_Length(faces); i++) {
- nmface = (BPy_NMFace *)PyList_GetItem(faces, i);
- n = PySequence_Length(nmface->uv);
- if (n != PySequence_Length(nmface->v))
- {
- if (n > 0)
- printf("Warning: different length of vertex and UV coordinate "
- "list in face!\n");
+ for( i = 0; i < PySequence_Length( faces ); i++ ) {
+ nmface = ( BPy_NMFace * ) PyList_GetItem( faces, i );
+ n = PySequence_Length( nmface->uv );
+ if( n != PySequence_Length( nmface->v ) ) {
+ if( n > 0 )
+ printf( "Warning: different length of vertex and UV coordinate " "list in face!\n" );
return 0;
- }
+ }
}
return 1;
}
/* this is a copy of unlink_mesh in mesh.c, because ... */
-void EXPP_unlink_mesh(Mesh *me)
+void EXPP_unlink_mesh( Mesh * me )
{
int a;
- if(me==0) return;
+ if( me == 0 )
+ return;
- for(a=0; a<me->totcol; a++) {
- if(me->mat[a]) me->mat[a]->id.us--;
- me->mat[a]= 0;
+ for( a = 0; a < me->totcol; a++ ) {
+ if( me->mat[a] )
+ me->mat[a]->id.us--;
+ me->mat[a] = 0;
}
/* ... here we want to preserve mesh keys */
/* if users want to get rid of them, they can use mesh.removeAllKeys() */
@@ -1918,38 +2003,46 @@ void EXPP_unlink_mesh(Mesh *me)
if(me->key) me->key->id.us--;
me->key= 0;
*/
- if(me->texcomesh) me->texcomesh= 0;
-}
-
-static int unlink_existingMeshData(Mesh *mesh)
-{
- freedisplist(&mesh->disp);
- EXPP_unlink_mesh(mesh);
- if(mesh->mvert) MEM_freeN(mesh->mvert);
- if(mesh->mface) MEM_freeN(mesh->mface);
- if(mesh->mcol) MEM_freeN(mesh->mcol);
- if(mesh->msticky) MEM_freeN(mesh->msticky);
- if(mesh->mat) MEM_freeN(mesh->mat);
- if(mesh->tface) MEM_freeN(mesh->tface);
+ if( me->texcomesh )
+ me->texcomesh = 0;
+}
+
+static int unlink_existingMeshData( Mesh * mesh )
+{
+ freedisplist( &mesh->disp );
+ EXPP_unlink_mesh( mesh );
+ if( mesh->mvert )
+ MEM_freeN( mesh->mvert );
+ if( mesh->mface )
+ MEM_freeN( mesh->mface );
+ if( mesh->mcol )
+ MEM_freeN( mesh->mcol );
+ if( mesh->msticky )
+ MEM_freeN( mesh->msticky );
+ if( mesh->mat )
+ MEM_freeN( mesh->mat );
+ if( mesh->tface )
+ MEM_freeN( mesh->tface );
return 1;
}
-Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
+Material **nmesh_updateMaterials( BPy_NMesh * nmesh )
{
Material **matlist;
Mesh *mesh = nmesh->mesh;
- int len = PyList_Size(nmesh->materials);
+ int len = PyList_Size( nmesh->materials );
- if (!mesh) {
- printf("FATAL INTERNAL ERROR: illegal call to updateMaterials()\n");
+ if( !mesh ) {
+ printf( "FATAL INTERNAL ERROR: illegal call to updateMaterials()\n" );
return 0;
}
- if (len > 0) {
- matlist = EXPP_newMaterialList_fromPyList(nmesh->materials);
- EXPP_incr_mats_us(matlist, len);
+ if( len > 0 ) {
+ matlist = EXPP_newMaterialList_fromPyList( nmesh->materials );
+ EXPP_incr_mats_us( matlist, len );
- if (mesh->mat) MEM_freeN(mesh->mat);
+ if( mesh->mat )
+ MEM_freeN( mesh->mat );
mesh->mat = matlist;
@@ -1963,57 +2056,60 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
* according to their data material lists, otherwise blender crashes.
* It just stupidly runs through all objects...BAD BAD BAD.
*/
- test_object_materials((ID *)mesh);
+ test_object_materials( ( ID * ) mesh );
return matlist;
}
-PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob)
+PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob )
{
BPy_Material *pymat;
Material *ma;
int i;
short old_matmask;
Mesh *mesh = nmesh->mesh;
- int nmats; /* number of mats == len(nmesh->materials)*/
+ int nmats; /* number of mats == len(nmesh->materials) */
- old_matmask = ob->colbits; /*@ HACK: save previous colbits */
+ old_matmask = ob->colbits; /*@ HACK: save previous colbits */
ob->colbits = 0; /* make assign_material work on mesh linked material */
- nmats = PyList_Size(nmesh->materials);
+ nmats = PyList_Size( nmesh->materials );
- if (nmats > 0 && !mesh->mat) {
+ if( nmats > 0 && !mesh->mat ) {
ob->totcol = nmats;
mesh->totcol = nmats;
- mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats");
+ mesh->mat =
+ MEM_callocN( sizeof( void * ) * nmats, "bpy_memats" );
- if (ob->mat) MEM_freeN(ob->mat);
- ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats");
+ if( ob->mat )
+ MEM_freeN( ob->mat );
+ ob->mat =
+ MEM_callocN( sizeof( void * ) * nmats, "bpy_obmats" );
}
- for (i = 0; i < nmats; i++) {
- pymat = (BPy_Material *)PySequence_GetItem(nmesh->materials, i);
+ for( i = 0; i < nmats; i++ ) {
+ pymat = ( BPy_Material * ) PySequence_GetItem( nmesh->
+ materials, i );
- if (Material_CheckPyObject ((PyObject *)pymat)) {
+ if( Material_CheckPyObject( ( PyObject * ) pymat ) ) {
ma = pymat->material;
- assign_material(ob, ma, i+1);/*@ XXX don't use this function anymore*/
+ assign_material( ob, ma, i + 1 ); /*@ XXX don't use this function anymore */
+ } else {
+ Py_DECREF( pymat );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Material type in attribute list 'materials'!" );
}
- else {
- Py_DECREF (pymat);
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Material type in attribute list 'materials'!");
- }
- Py_DECREF (pymat);
+ Py_DECREF( pymat );
}
- ob->colbits = old_matmask; /*@ HACK */
+ ob->colbits = old_matmask; /*@ HACK */
ob->actcol = 1;
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh)
+static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh )
{
MFace *newmf;
TFace *newtf;
@@ -2038,20 +2134,24 @@ static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh)
mesh->subdivr = nmesh->subdiv[1];
/*@ material assignment moved to PutRaw */
- mesh->totvert = PySequence_Length(nmesh->verts);
- if (mesh->totvert) {
- if (nmesh->flags&NMESH_HASVERTUV)
- mesh->msticky = MEM_callocN(sizeof(MSticky)*mesh->totvert, "msticky");
+ mesh->totvert = PySequence_Length( nmesh->verts );
+ if( mesh->totvert ) {
+ if( nmesh->flags & NMESH_HASVERTUV )
+ mesh->msticky =
+ MEM_callocN( sizeof( MSticky ) * mesh->totvert,
+ "msticky" );
- mesh->mvert = MEM_callocN(sizeof(MVert)*mesh->totvert, "mverts");
+ mesh->mvert =
+ MEM_callocN( sizeof( MVert ) * mesh->totvert,
+ "mverts" );
}
- if (mesh->totvert)
- mesh->totface = PySequence_Length(nmesh->faces);
+ if( mesh->totvert )
+ mesh->totface = PySequence_Length( nmesh->faces );
else
mesh->totface = 0;
- if (mesh->totface) {
+ if( mesh->totface ) {
/*@ only create vertcol array if mesh has no texture faces */
/*@ TODO: get rid of double storage of vertex colours. In a mesh,
@@ -2061,10 +2161,15 @@ static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh)
* This is stupid, but will reside for the time being -- at least until
* a redesign of the internal Mesh structure */
- if (!(nmesh->flags & NMESH_HASFACEUV) && (nmesh->flags&NMESH_HASMCOL))
- mesh->mcol = MEM_callocN(4*sizeof(MCol)*mesh->totface, "mcol");
+ if( !( nmesh->flags & NMESH_HASFACEUV )
+ && ( nmesh->flags & NMESH_HASMCOL ) )
+ mesh->mcol =
+ MEM_callocN( 4 * sizeof( MCol ) *
+ mesh->totface, "mcol" );
- mesh->mface = MEM_callocN(sizeof(MFace)*mesh->totface, "mfaces");
+ mesh->mface =
+ MEM_callocN( sizeof( MFace ) * mesh->totface,
+ "mfaces" );
}
/*@ This stuff here is to tag all the vertices referenced
@@ -2074,76 +2179,86 @@ static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh)
* screwed up decision to not make faces only store the
* index. - Zr
*/
- for (i = 0; i < mesh->totface; i++) {
- BPy_NMFace *mf = (BPy_NMFace *)PySequence_GetItem(nmesh->faces, i);
-
- j = PySequence_Length(mf->v);
- while (j--) {
- BPy_NMVert *mv = (BPy_NMVert *)PySequence_GetItem(mf->v, j);
- if (BPy_NMVert_Check(mv)) mv->index = -1;
- Py_DECREF(mv);
+ for( i = 0; i < mesh->totface; i++ ) {
+ BPy_NMFace *mf =
+ ( BPy_NMFace * ) PySequence_GetItem( nmesh->faces, i );
+
+ j = PySequence_Length( mf->v );
+ while( j-- ) {
+ BPy_NMVert *mv =
+ ( BPy_NMVert * ) PySequence_GetItem( mf->v,
+ j );
+ if( BPy_NMVert_Check( mv ) )
+ mv->index = -1;
+ Py_DECREF( mv );
}
- Py_DECREF(mf);
+ Py_DECREF( mf );
}
- for (i = 0; i < mesh->totvert; i++) {
- BPy_NMVert *mv = (BPy_NMVert *)PySequence_GetItem(nmesh->verts, i);
+ for( i = 0; i < mesh->totvert; i++ ) {
+ BPy_NMVert *mv =
+ ( BPy_NMVert * ) PySequence_GetItem( nmesh->verts, i );
mv->index = i;
- Py_DECREF(mv);
+ Py_DECREF( mv );
}
newmv = mesh->mvert;
newst = mesh->msticky;
- for (i = 0; i < mesh->totvert; i++) {
- PyObject *mv = PySequence_GetItem (nmesh->verts, i);
- mvert_from_data(newmv, newst, (BPy_NMVert *)mv);
- Py_DECREF(mv);
+ for( i = 0; i < mesh->totvert; i++ ) {
+ PyObject *mv = PySequence_GetItem( nmesh->verts, i );
+ mvert_from_data( newmv, newst, ( BPy_NMVert * ) mv );
+ Py_DECREF( mv );
newmv++;
- if (newst) newst++;
+ if( newst )
+ newst++;
}
/* assign per face texture UVs */
/* check face UV flag, then check whether there was one
* UV coordinate assigned, if yes, make tfaces */
- if ((nmesh->flags & NMESH_HASFACEUV) || (check_validFaceUV(nmesh))) {
- make_tfaces(mesh); /* initialize TFaces */
+ if( ( nmesh->flags & NMESH_HASFACEUV )
+ || ( check_validFaceUV( nmesh ) ) ) {
+ make_tfaces( mesh ); /* initialize TFaces */
newmc = mesh->mcol;
newmf = mesh->mface;
newtf = mesh->tface;
- for (i = 0; i<mesh->totface; i++) {
- PyObject *mf = PySequence_GetItem(nmesh->faces, i);
- mface_from_data(newmf, newtf, newmc, (BPy_NMFace *) mf);
- Py_DECREF(mf);
+ for( i = 0; i < mesh->totface; i++ ) {
+ PyObject *mf = PySequence_GetItem( nmesh->faces, i );
+ mface_from_data( newmf, newtf, newmc,
+ ( BPy_NMFace * ) mf );
+ Py_DECREF( mf );
newtf++;
newmf++;
- if (newmc) newmc += 4;
+ if( newmc )
+ newmc += 4;
}
nmesh->flags |= NMESH_HASFACEUV;
- }
- else {
+ } else {
newmc = mesh->mcol;
newmf = mesh->mface;
- for (i = 0; i < mesh->totface; i++) {
- PyObject *mf = PySequence_GetItem(nmesh->faces, i);
- mface_from_data(newmf, 0, newmc, (BPy_NMFace *) mf);
- Py_DECREF(mf);
+ for( i = 0; i < mesh->totface; i++ ) {
+ PyObject *mf = PySequence_GetItem( nmesh->faces, i );
+ mface_from_data( newmf, 0, newmc,
+ ( BPy_NMFace * ) mf );
+ Py_DECREF( mf );
newmf++;
- if (newmc) newmc += 4; /* there are 4 MCol's per face */
+ if( newmc )
+ newmc += 4; /* there are 4 MCol's per face */
}
}
return 1;
}
-static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
+static PyObject *M_NMesh_PutRaw( PyObject * self, PyObject * args )
{
char *name = NULL;
Mesh *mesh = NULL;
@@ -2151,58 +2266,64 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
BPy_NMesh *nmesh;
int recalc_normals = 1;
- if (!PyArg_ParseTuple(args, "O!|si",
- &NMesh_Type, &nmesh, &name, &recalc_normals))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an NMesh object and optionally also a string and an int");
-
- if (!PySequence_Check(nmesh->verts))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "nmesh vertices are not a sequence");
- if (!PySequence_Check(nmesh->faces))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "nmesh faces are not a sequence");
- if (!PySequence_Check(nmesh->materials))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "nmesh materials are not a sequence");
-
- if (EXPP_check_sequence_consistency(nmesh->verts, &NMVert_Type) != 1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "nmesh vertices must be NMVerts");
- if (EXPP_check_sequence_consistency(nmesh->faces, &NMFace_Type) != 1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "nmesh faces must be NMFaces");
-
- if (name)
- mesh = (Mesh *)GetIdFromList(&(G.main->mesh), name);
-
- if (!mesh || mesh->id.us == 0) {
- ob = add_object(OB_MESH);
- if (!ob) {
- PyErr_SetString(PyExc_RuntimeError,
- "Fatal: could not create mesh object");
- return 0;
+ if( !PyArg_ParseTuple( args, "O!|si",
+ &NMesh_Type, &nmesh, &name, &recalc_normals ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an NMesh object and optionally also a string and an int" );
+
+ if( !PySequence_Check( nmesh->verts ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "nmesh vertices are not a sequence" );
+ if( !PySequence_Check( nmesh->faces ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "nmesh faces are not a sequence" );
+ if( !PySequence_Check( nmesh->materials ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "nmesh materials are not a sequence" );
+
+ if( EXPP_check_sequence_consistency( nmesh->verts, &NMVert_Type ) !=
+ 1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "nmesh vertices must be NMVerts" );
+ if( EXPP_check_sequence_consistency( nmesh->faces, &NMFace_Type ) !=
+ 1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "nmesh faces must be NMFaces" );
+
+ if( name )
+ mesh = ( Mesh * ) GetIdFromList( &( G.main->mesh ), name );
+
+ if( !mesh || mesh->id.us == 0 ) {
+ ob = add_object( OB_MESH );
+ if( !ob ) {
+ PyErr_SetString( PyExc_RuntimeError,
+ "Fatal: could not create mesh object" );
+ return 0;
}
- if (!mesh) mesh = (Mesh *)ob->data;
- else set_mesh(ob, mesh); // also does id.us++
+ if( !mesh )
+ mesh = ( Mesh * ) ob->data;
+ else
+ set_mesh( ob, mesh ); // also does id.us++
}
- if (name)
- new_id(&(G.main->mesh), &mesh->id, name);
- else if (nmesh->name && nmesh->name != Py_None)
- new_id(&(G.main->mesh), &mesh->id, PyString_AsString(nmesh->name));
+ if( name )
+ new_id( &( G.main->mesh ), &mesh->id, name );
+ else if( nmesh->name && nmesh->name != Py_None )
+ new_id( &( G.main->mesh ), &mesh->id,
+ PyString_AsString( nmesh->name ) );
- unlink_existingMeshData(mesh);
- convert_NMeshToMesh(mesh, nmesh);
+ unlink_existingMeshData( mesh );
+ convert_NMeshToMesh( mesh, nmesh );
nmesh->mesh = mesh;
- if (recalc_normals) vertexnormals_mesh(mesh, 0);
+ if( recalc_normals )
+ vertexnormals_mesh( mesh, 0 );
+
+ mesh_update( mesh );
- mesh_update(mesh);
-
- if (!during_script())
- allqueue(REDRAWVIEW3D, 0);
+ if( !during_script( ) )
+ allqueue( REDRAWVIEW3D, 0 );
// @OK...this requires some explanation:
// Materials can be assigned two ways:
@@ -2225,16 +2346,17 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
// The flags setting the material binding is found in ob->colbits, where
// each bit indicates the binding PER MATERIAL
- if (ob) { // we created a new object
- nmesh->object = ob; // linking so vgrouping methods know which obj to work on
- NMesh_assignMaterials_toObject(nmesh, ob);
- EXPP_synchronizeMaterialLists (ob);
- return Object_CreatePyObject(ob);
- }
- else {
- mesh->mat = EXPP_newMaterialList_fromPyList(nmesh->materials);
- EXPP_incr_mats_us (mesh->mat, PyList_Size (nmesh->materials));
- return EXPP_incr_ret (Py_None);
+ if( ob ) { // we created a new object
+ nmesh->object = ob; // linking so vgrouping methods know which obj to work on
+ NMesh_assignMaterials_toObject( nmesh, ob );
+ EXPP_synchronizeMaterialLists( ob );
+ return Object_CreatePyObject( ob );
+ } else {
+ mesh->mat =
+ EXPP_newMaterialList_fromPyList( nmesh->materials );
+ EXPP_incr_mats_us( mesh->mat,
+ PyList_Size( nmesh->materials ) );
+ return EXPP_incr_ret( Py_None );
}
}
@@ -2244,29 +2366,35 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
{#func, M_NMesh_##func, METH_VARARGS, M_NMesh_##func##_doc}
static struct PyMethodDef M_NMesh_methods[] = {
- MethodDef(Col),
- MethodDef(Vert),
- MethodDef(Face),
- MethodDef(New),
- MethodDef(GetRaw),
- MethodDef(GetRawFromObject),
- MethodDef(PutRaw),
+ MethodDef( Col ),
+ MethodDef( Vert ),
+ MethodDef( Face ),
+ MethodDef( New ),
+ MethodDef( GetRaw ),
+ MethodDef( GetRawFromObject ),
+ MethodDef( PutRaw ),
{NULL, NULL, 0, NULL}
};
-static PyObject *M_NMesh_Modes (void)
+static PyObject *M_NMesh_Modes( void )
{
- PyObject *Modes = M_constant_New();
+ PyObject *Modes = M_constant_New( );
- if (Modes) {
- BPy_constant *d = (BPy_constant *)Modes;
+ if( Modes ) {
+ BPy_constant *d = ( BPy_constant * ) Modes;
- constant_insert(d, "NOVNORMALSFLIP",
- PyInt_FromLong(EXPP_NMESH_MODE_NOPUNOFLIP));
- constant_insert(d, "TWOSIDED", PyInt_FromLong(EXPP_NMESH_MODE_TWOSIDED));
- constant_insert(d, "AUTOSMOOTH",PyInt_FromLong(EXPP_NMESH_MODE_AUTOSMOOTH));
- constant_insert(d, "SUBSURF", PyInt_FromLong(EXPP_NMESH_MODE_SUBSURF));
- constant_insert(d, "OPTIMAL", PyInt_FromLong(EXPP_NMESH_MODE_OPTIMAL));
+ constant_insert( d, "NOVNORMALSFLIP",
+ PyInt_FromLong
+ ( EXPP_NMESH_MODE_NOPUNOFLIP ) );
+ constant_insert( d, "TWOSIDED",
+ PyInt_FromLong( EXPP_NMESH_MODE_TWOSIDED ) );
+ constant_insert( d, "AUTOSMOOTH",
+ PyInt_FromLong
+ ( EXPP_NMESH_MODE_AUTOSMOOTH ) );
+ constant_insert( d, "SUBSURF",
+ PyInt_FromLong( EXPP_NMESH_MODE_SUBSURF ) );
+ constant_insert( d, "OPTIMAL",
+ PyInt_FromLong( EXPP_NMESH_MODE_OPTIMAL ) );
}
return Modes;
@@ -2277,83 +2405,90 @@ static PyObject *M_NMesh_Modes (void)
constant_insert(dict, #name, PyInt_FromLong(TF_##name))
/* Set constants for face drawing mode -- see drawmesh.c */
-static PyObject *M_NMesh_FaceModesDict (void)
-{
- PyObject *FM = M_constant_New();
-
- if (FM) {
- BPy_constant *d = (BPy_constant *)FM;
-
- constant_insert(d, "BILLBOARD", PyInt_FromLong(TF_BILLBOARD2));
- constant_insert(d, "ALL", PyInt_FromLong(0xffff));
- constant_insert(d, "HALO", PyInt_FromLong(TF_BILLBOARD));
- EXPP_ADDCONST(d, DYNAMIC);
- EXPP_ADDCONST(d, INVISIBLE);
- EXPP_ADDCONST(d, LIGHT);
- EXPP_ADDCONST(d, OBCOL);
- EXPP_ADDCONST(d, SHADOW);
- EXPP_ADDCONST(d, SHAREDVERT);
- EXPP_ADDCONST(d, SHAREDCOL);
- EXPP_ADDCONST(d, TEX);
- EXPP_ADDCONST(d, TILES);
- EXPP_ADDCONST(d, TWOSIDE);
+static PyObject *M_NMesh_FaceModesDict( void )
+{
+ PyObject *FM = M_constant_New( );
+
+ if( FM ) {
+ BPy_constant *d = ( BPy_constant * ) FM;
+
+ constant_insert( d, "BILLBOARD",
+ PyInt_FromLong( TF_BILLBOARD2 ) );
+ constant_insert( d, "ALL", PyInt_FromLong( 0xffff ) );
+ constant_insert( d, "HALO", PyInt_FromLong( TF_BILLBOARD ) );
+ EXPP_ADDCONST( d, DYNAMIC );
+ EXPP_ADDCONST( d, INVISIBLE );
+ EXPP_ADDCONST( d, LIGHT );
+ EXPP_ADDCONST( d, OBCOL );
+ EXPP_ADDCONST( d, SHADOW );
+ EXPP_ADDCONST( d, SHAREDVERT );
+ EXPP_ADDCONST( d, SHAREDCOL );
+ EXPP_ADDCONST( d, TEX );
+ EXPP_ADDCONST( d, TILES );
+ EXPP_ADDCONST( d, TWOSIDE );
}
return FM;
}
-static PyObject *M_NMesh_FaceFlagsDict (void)
+static PyObject *M_NMesh_FaceFlagsDict( void )
{
- PyObject *FF = M_constant_New();
+ PyObject *FF = M_constant_New( );
- if (FF) {
- BPy_constant *d = (BPy_constant *)FF;
+ if( FF ) {
+ BPy_constant *d = ( BPy_constant * ) FF;
- EXPP_ADDCONST(d, SELECT);
- EXPP_ADDCONST(d, HIDE);
- EXPP_ADDCONST(d, ACTIVE);
+ EXPP_ADDCONST( d, SELECT );
+ EXPP_ADDCONST( d, HIDE );
+ EXPP_ADDCONST( d, ACTIVE );
}
return FF;
}
-static PyObject *M_NMesh_FaceTranspModesDict (void)
+static PyObject *M_NMesh_FaceTranspModesDict( void )
{
- PyObject *FTM = M_constant_New();
+ PyObject *FTM = M_constant_New( );
- if (FTM) {
- BPy_constant *d = (BPy_constant *)FTM;
+ if( FTM ) {
+ BPy_constant *d = ( BPy_constant * ) FTM;
- EXPP_ADDCONST(d, SOLID);
- EXPP_ADDCONST(d, ADD);
- EXPP_ADDCONST(d, ALPHA);
- EXPP_ADDCONST(d, SUB);
+ EXPP_ADDCONST( d, SOLID );
+ EXPP_ADDCONST( d, ADD );
+ EXPP_ADDCONST( d, ALPHA );
+ EXPP_ADDCONST( d, SUB );
}
return FTM;
}
-PyObject *NMesh_Init (void)
+PyObject *NMesh_Init( void )
{
PyObject *submodule;
- PyObject *Modes = M_NMesh_Modes ();
- PyObject *FaceFlags = M_NMesh_FaceFlagsDict ();
- PyObject *FaceModes = M_NMesh_FaceModesDict ();
- PyObject *FaceTranspModes = M_NMesh_FaceTranspModesDict ();
+ PyObject *Modes = M_NMesh_Modes( );
+ PyObject *FaceFlags = M_NMesh_FaceFlagsDict( );
+ PyObject *FaceModes = M_NMesh_FaceModesDict( );
+ PyObject *FaceTranspModes = M_NMesh_FaceTranspModesDict( );
NMCol_Type.ob_type = &PyType_Type;
NMFace_Type.ob_type = &PyType_Type;
NMVert_Type.ob_type = &PyType_Type;
NMesh_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.NMesh", M_NMesh_methods, M_NMesh_doc);
+ submodule =
+ Py_InitModule3( "Blender.NMesh", M_NMesh_methods,
+ M_NMesh_doc );
- if (Modes) PyModule_AddObject (submodule, "Modes", Modes);
- if (FaceFlags) PyModule_AddObject (submodule, "FaceFlags", FaceFlags);
- if (FaceModes) PyModule_AddObject (submodule, "FaceModes", FaceModes);
- if (FaceTranspModes)
- PyModule_AddObject (submodule, "FaceTranspModes", FaceTranspModes);
+ if( Modes )
+ PyModule_AddObject( submodule, "Modes", Modes );
+ if( FaceFlags )
+ PyModule_AddObject( submodule, "FaceFlags", FaceFlags );
+ if( FaceModes )
+ PyModule_AddObject( submodule, "FaceModes", FaceModes );
+ if( FaceTranspModes )
+ PyModule_AddObject( submodule, "FaceTranspModes",
+ FaceTranspModes );
g_nmeshmodule = submodule;
return submodule;
@@ -2361,44 +2496,45 @@ PyObject *NMesh_Init (void)
/* These are needed by Object.c */
-PyObject *NMesh_CreatePyObject (Mesh *me, Object *ob)
+PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob )
{
- BPy_NMesh *nmesh = (BPy_NMesh *)new_NMesh (me);
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) new_NMesh( me );
- if (nmesh) nmesh->object = ob; /* linking nmesh and object for vgrouping methods */
+ if( nmesh )
+ nmesh->object = ob; /* linking nmesh and object for vgrouping methods */
- return (PyObject *)nmesh;
+ return ( PyObject * ) nmesh;
}
-int NMesh_CheckPyObject (PyObject *pyobj)
+int NMesh_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &NMesh_Type);
+ return ( pyobj->ob_type == &NMesh_Type );
}
-Mesh *Mesh_FromPyObject (PyObject *pyobj, Object *ob)
+Mesh *Mesh_FromPyObject( PyObject * pyobj, Object * ob )
{
- if (pyobj->ob_type == &NMesh_Type) {
+ if( pyobj->ob_type == &NMesh_Type ) {
Mesh *mesh;
- BPy_NMesh *nmesh = (BPy_NMesh *)pyobj;
+ BPy_NMesh *nmesh = ( BPy_NMesh * ) pyobj;
- if (nmesh->mesh) {
+ if( nmesh->mesh ) {
mesh = nmesh->mesh;
- unlink_existingMeshData(mesh);
- convert_NMeshToMesh(mesh, nmesh);
- }
- else {
- nmesh->mesh = Mesh_fromNMesh(nmesh);
+ unlink_existingMeshData( mesh );
+ convert_NMeshToMesh( mesh, nmesh );
+ } else {
+ nmesh->mesh = Mesh_fromNMesh( nmesh );
mesh = nmesh->mesh;
}
- nmesh->object = ob; /* linking for vgrouping methods */
+ nmesh->object = ob; /* linking for vgrouping methods */
- if (nmesh->name && nmesh->name != Py_None)
- new_id(&(G.main->mesh), &mesh->id, PyString_AsString(nmesh->name));
+ if( nmesh->name && nmesh->name != Py_None )
+ new_id( &( G.main->mesh ), &mesh->id,
+ PyString_AsString( nmesh->name ) );
- mesh_update(mesh);
+ mesh_update( mesh );
- nmesh_updateMaterials(nmesh);
+ nmesh_updateMaterials( nmesh );
return mesh;
}
@@ -2406,418 +2542,442 @@ Mesh *Mesh_FromPyObject (PyObject *pyobj, Object *ob)
return NULL;
}
-static PyObject *NMesh_addVertGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args )
{
- char* groupStr;
- struct Object* object;
+ char *groupStr;
+ struct Object *object;
PyObject *tempStr;
- if (!PyArg_ParseTuple(args, "s", &groupStr))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &groupStr ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if (( (BPy_NMesh*)self )->object == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "mesh must be linked to an object first...");
+ if( ( ( BPy_NMesh * ) self )->object == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "mesh must be linked to an object first..." );
- object = ((BPy_NMesh*)self)->object;
+ object = ( ( BPy_NMesh * ) self )->object;
//get clamped name
- tempStr = PyString_FromStringAndSize(groupStr, 32);
- groupStr = PyString_AsString(tempStr);
+ tempStr = PyString_FromStringAndSize( groupStr, 32 );
+ groupStr = PyString_AsString( tempStr );
- add_defgroup_name (object, groupStr);
+ add_defgroup_name( object, groupStr );
- allqueue (REDRAWBUTSALL, 1);
+ allqueue( REDRAWBUTSALL, 1 );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_removeVertGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args )
{
- char* groupStr;
- struct Object* object;
+ char *groupStr;
+ struct Object *object;
int nIndex;
- bDeformGroup* pGroup;
+ bDeformGroup *pGroup;
- if (!PyArg_ParseTuple(args, "s", &groupStr))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &groupStr ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if (( (BPy_NMesh*)self )->object == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "mesh must be linked to an object first...");
+ if( ( ( BPy_NMesh * ) self )->object == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "mesh must be linked to an object first..." );
- object = ((BPy_NMesh*)self)->object;
+ object = ( ( BPy_NMesh * ) self )->object;
- pGroup = get_named_vertexgroup(object, groupStr);
- if(pGroup == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "group does not exist!");
+ pGroup = get_named_vertexgroup( object, groupStr );
+ if( pGroup == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "group does not exist!" );
- nIndex = get_defgroup_num(object, pGroup);
- if(nIndex == -1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no deform groups assigned to mesh");
+ nIndex = get_defgroup_num( object, pGroup );
+ if( nIndex == -1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no deform groups assigned to mesh" );
nIndex++;
object->actdef = nIndex;
- del_defgroup(object);
+ del_defgroup( object );
- allqueue (REDRAWBUTSALL, 1);
+ allqueue( REDRAWBUTSALL, 1 );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_assignVertsToGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args )
{
//listObject is an integer list of vertex indices to add to group
//groupStr = group name
//weight is a float defining the weight this group has on this vertex
//assignmode = "replace", "add", "subtract"
- // replace weight - add addition weight to vertex for this group
- // - remove group influence from this vertex
+ // replace weight - add addition weight to vertex for this group
+ // - remove group influence from this vertex
//the function will not like it if your in editmode...
- char* groupStr;
- char* assignmodeStr = NULL;
- int nIndex;
+ char *groupStr;
+ char *assignmodeStr = NULL;
+ int nIndex;
int assignmode;
float weight = 1.0;
- struct Object* object;
- bDeformGroup* pGroup;
- PyObject* listObject;
+ struct Object *object;
+ bDeformGroup *pGroup;
+ PyObject *listObject;
int tempInt;
int x;
- if (( (BPy_NMesh*)self )->object == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "mesh must be linked to an object first...");
+ if( ( ( BPy_NMesh * ) self )->object == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "mesh must be linked to an object first..." );
- if (!PyArg_ParseTuple(args, "sO!fs", &groupStr, &PyList_Type, &listObject,
- &weight, &assignmodeStr)) {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string, list, float, string arguments");
+ if( !PyArg_ParseTuple
+ ( args, "sO!fs", &groupStr, &PyList_Type, &listObject, &weight,
+ &assignmodeStr ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string, list, float, string arguments" );
}
- object = ((BPy_NMesh*)self)->object;
-
- if (object->data == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "object contains no data...");
+ object = ( ( BPy_NMesh * ) self )->object;
+
+ if( object->data == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object contains no data..." );
- pGroup = get_named_vertexgroup(object, groupStr);
- if(pGroup == NULL)
- return EXPP_ReturnPyObjError(PyExc_AttributeError, "group does not exist!");
+ pGroup = get_named_vertexgroup( object, groupStr );
+ if( pGroup == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "group does not exist!" );
- nIndex = get_defgroup_num(object, pGroup);
- if(nIndex == -1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no deform groups assigned to mesh");
+ nIndex = get_defgroup_num( object, pGroup );
+ if( nIndex == -1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no deform groups assigned to mesh" );
- if(assignmodeStr == NULL)
- assignmode = 1; /* default */
- else if(STREQ(assignmodeStr, "replace"))
+ if( assignmodeStr == NULL )
+ assignmode = 1; /* default */
+ else if( STREQ( assignmodeStr, "replace" ) )
assignmode = 1;
- else if(STREQ(assignmodeStr, "add"))
+ else if( STREQ( assignmodeStr, "add" ) )
assignmode = 2;
- else if(STREQ(assignmodeStr, "subtract"))
+ else if( STREQ( assignmodeStr, "subtract" ) )
assignmode = 3;
else
- return EXPP_ReturnPyObjError (PyExc_ValueError, "bad assignment mode");
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad assignment mode" );
//makes a set of dVerts corresponding to the mVerts
- if (!((Mesh*)object->data)->dvert) {
- create_dverts((Mesh*)object->data);
+ if( !( ( Mesh * ) object->data )->dvert ) {
+ create_dverts( ( Mesh * ) object->data );
}
-
//loop list adding verts to group
- for (x = 0; x < PyList_Size(listObject); x++) {
- if (!(PyArg_Parse((PyList_GetItem(listObject, x)), "i", &tempInt)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list integer not parseable");
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !
+ ( PyArg_Parse
+ ( ( PyList_GetItem( listObject, x ) ), "i",
+ &tempInt ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list integer not parseable" );
- if (tempInt < 0 || tempInt >= ((Mesh*)object->data)->totvert)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad vertex index in list");
+ if( tempInt < 0
+ || tempInt >= ( ( Mesh * ) object->data )->totvert )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad vertex index in list" );
- add_vert_defnr(object, nIndex, tempInt, weight, assignmode);
+ add_vert_defnr( object, nIndex, tempInt, weight, assignmode );
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_removeVertsFromGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_removeVertsFromGroup( PyObject * self, PyObject * args )
{
//not passing a list will remove all verts from group
- char* groupStr;
- int nIndex;
- struct Object* object;
- bDeformGroup* pGroup;
- PyObject* listObject;
+ char *groupStr;
+ int nIndex;
+ struct Object *object;
+ bDeformGroup *pGroup;
+ PyObject *listObject;
int tempInt;
int x, argc;
/* argc is the number of parameters passed in: 1 (no list given) or 2: */
- argc = PyObject_Length(args);
+ argc = PyObject_Length( args );
- if (!PyArg_ParseTuple(args, "s|O!", &groupStr, &PyList_Type, &listObject))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string and optional list argument");
+ if( !PyArg_ParseTuple
+ ( args, "s|O!", &groupStr, &PyList_Type, &listObject ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string and optional list argument" );
- if (( (BPy_NMesh*)self )->object == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "mesh must be linked to an object first...");
+ if( ( ( BPy_NMesh * ) self )->object == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "mesh must be linked to an object first..." );
- object = ((BPy_NMesh*)self)->object;
+ object = ( ( BPy_NMesh * ) self )->object;
- if (object->data == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "object contains no data...");
+ if( object->data == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object contains no data..." );
- if ((!((Mesh*)object->data)->dvert))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "this mesh contains no deform vertices...'");
+ if( ( !( ( Mesh * ) object->data )->dvert ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "this mesh contains no deform vertices...'" );
- pGroup = get_named_vertexgroup(object, groupStr);
- if(pGroup == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "group does not exist!");
+ pGroup = get_named_vertexgroup( object, groupStr );
+ if( pGroup == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "group does not exist!" );
- nIndex = get_defgroup_num(object, pGroup);
- if(nIndex == -1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no deform groups assigned to mesh");
+ nIndex = get_defgroup_num( object, pGroup );
+ if( nIndex == -1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no deform groups assigned to mesh" );
- if (argc == 1) /* no list given */ {
+ if( argc == 1 ) { /* no list given */
//enter editmode
- if((G.obedit == 0))
- {
+ if( ( G.obedit == 0 ) ) {
//set current object
BASACT->object = object;
- G.obedit= BASACT->object;
+ G.obedit = BASACT->object;
}
//set current vertex group
nIndex++;
object->actdef = nIndex;
//clear all dVerts in active group
- remove_verts_defgroup (1);
+ remove_verts_defgroup( 1 );
//exit editmode
G.obedit = 0;
- }
- else
- {
- if(G.obedit != 0) //remove_vert_def_nr doesn't like it if your in editmode
- G.obedit = 0;
+ } else {
+ if( G.obedit != 0 ) //remove_vert_def_nr doesn't like it if your in editmode
+ G.obedit = 0;
//loop list adding verts to group
- for(x = 0; x < PyList_Size(listObject); x++) {
- if(!(PyArg_Parse((PyList_GetItem(listObject, x)), "i", &tempInt)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list integer not parseable");
-
- if(tempInt < 0 || tempInt >= ((Mesh*)object->data)->totvert)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad vertex index in list");
-
- remove_vert_def_nr (object, nIndex, tempInt);
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !
+ ( PyArg_Parse
+ ( ( PyList_GetItem( listObject, x ) ), "i",
+ &tempInt ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list integer not parseable" );
+
+ if( tempInt < 0
+ || tempInt >=
+ ( ( Mesh * ) object->data )->totvert )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad vertex index in list" );
+
+ remove_vert_def_nr( object, nIndex, tempInt );
}
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_getVertsFromGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args )
{
//not passing a list will return all verts from group
//passing indecies not part of the group will not return data in pyList
//can be used as a index/group check for a vertex
- char* groupStr;
- int nIndex;
+ char *groupStr;
+ int nIndex;
int weightRet;
- struct Object* object;
- bDeformGroup* pGroup;
+ struct Object *object;
+ bDeformGroup *pGroup;
MVert *mvert;
MDeformVert *dvert;
float weight;
int i, k, l1, l2, count;
int num = 0;
- PyObject* tempVertexList = NULL;
- PyObject* vertexList;
- PyObject* listObject;
+ PyObject *tempVertexList = NULL;
+ PyObject *vertexList;
+ PyObject *listObject;
int tempInt;
int x;
- listObject = (void*)-2054456; //can't use NULL macro because compiler thinks
- //it's a 0 and we need to check 0 index vertex pos
+ listObject = ( void * ) -2054456; //can't use NULL macro because compiler thinks
+ //it's a 0 and we need to check 0 index vertex pos
l1 = FALSE;
l2 = FALSE;
weightRet = 0;
- if (!PyArg_ParseTuple(args, "s|iO!", &groupStr, &weightRet,
- &PyList_Type, &listObject))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string and optional int and list arguments");
+ if( !PyArg_ParseTuple( args, "s|iO!", &groupStr, &weightRet,
+ &PyList_Type, &listObject ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string and optional int and list arguments" );
- if (weightRet < 0 || weightRet > 1)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "return weights flag must be 0 or 1...");
+ if( weightRet < 0 || weightRet > 1 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "return weights flag must be 0 or 1..." );
- if(((BPy_NMesh*)self)->object == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "mesh must be linked to an object first...");
+ if( ( ( BPy_NMesh * ) self )->object == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "mesh must be linked to an object first..." );
- object = ((BPy_NMesh*)self)->object;
+ object = ( ( BPy_NMesh * ) self )->object;
- if(object->data == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "object contains no data...");
+ if( object->data == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "object contains no data..." );
- if ((!((Mesh*)object->data)->dvert))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "this mesh contains no deform vertices...'");
+ if( ( !( ( Mesh * ) object->data )->dvert ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "this mesh contains no deform vertices...'" );
- pGroup = get_named_vertexgroup(object, groupStr);
- if(pGroup == NULL)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "group does not exist!");
+ pGroup = get_named_vertexgroup( object, groupStr );
+ if( pGroup == NULL )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "group does not exist!" );
- nIndex = get_defgroup_num(object, pGroup);
- if(nIndex == -1)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no deform groups assigned to mesh");
+ nIndex = get_defgroup_num( object, pGroup );
+ if( nIndex == -1 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no deform groups assigned to mesh" );
//temporary list
- tempVertexList = PyList_New(((Mesh*)object->data)->totvert);
- if (tempVertexList == NULL)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "getVertsFromGroup: can't create pylist!");
+ tempVertexList = PyList_New( ( ( Mesh * ) object->data )->totvert );
+ if( tempVertexList == NULL )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "getVertsFromGroup: can't create pylist!" );
count = 0;
- if (listObject == (void *)-2054456) //do entire group
- {
- for(k = 0; k < ((Mesh*)object->data)->totvert ; k++)
- {
- dvert = ((Mesh*)object->data)->dvert + k;
-
- for (i=0 ; i < dvert->totweight; i++)
- {
- if (dvert->dw[i].def_nr == nIndex)
- {
- mvert = ((Mesh*)object->data)->mvert + k;
+ if( listObject == ( void * ) -2054456 ) //do entire group
+ {
+ for( k = 0; k < ( ( Mesh * ) object->data )->totvert; k++ ) {
+ dvert = ( ( Mesh * ) object->data )->dvert + k;
+
+ for( i = 0; i < dvert->totweight; i++ ) {
+ if( dvert->dw[i].def_nr == nIndex ) {
+ mvert = ( ( Mesh * ) object->data )->
+ mvert + k;
weight = dvert->dw[i].weight;
//printf("index =%3d weight:%10f\n", k, weight);
-
- if(weightRet == 1)
- PyList_SetItem(tempVertexList, count,
- Py_BuildValue("(i,f)", k, weight));
- else if (weightRet == 0)
- PyList_SetItem(tempVertexList, count, Py_BuildValue("i", k));
+
+ if( weightRet == 1 )
+ PyList_SetItem( tempVertexList,
+ count,
+ Py_BuildValue
+ ( "(i,f)", k,
+ weight ) );
+ else if( weightRet == 0 )
+ PyList_SetItem( tempVertexList,
+ count,
+ Py_BuildValue
+ ( "i", k ) );
count++;
}
}
}
- }
- else //do single vertex
+ } else //do single vertex
{
//loop list adding verts to group
- for(x = 0; x < PyList_Size(listObject); x++)
- {
- if(!(PyArg_Parse((PyList_GetItem(listObject, x)), "i", &tempInt)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list integer not parseable");
-
- if(tempInt < 0 || tempInt >= ((Mesh*)object->data)->totvert)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "bad vertex index in list");
+ for( x = 0; x < PyList_Size( listObject ); x++ ) {
+ if( !
+ ( PyArg_Parse
+ ( ( PyList_GetItem( listObject, x ) ), "i",
+ &tempInt ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list integer not parseable" );
+
+ if( tempInt < 0
+ || tempInt >=
+ ( ( Mesh * ) object->data )->totvert )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "bad vertex index in list" );
num = tempInt;
- dvert = ((Mesh*)object->data)->dvert + num;
- for (i=0 ; i < dvert->totweight; i++)
- {
+ dvert = ( ( Mesh * ) object->data )->dvert + num;
+ for( i = 0; i < dvert->totweight; i++ ) {
l1 = TRUE;
- if (dvert->dw[i].def_nr == nIndex)
- {
+ if( dvert->dw[i].def_nr == nIndex ) {
l2 = TRUE;
- mvert = ((Mesh*)object->data)->mvert + num;
+ mvert = ( ( Mesh * ) object->data )->
+ mvert + num;
weight = dvert->dw[i].weight;
//printf("index =%3d weight:%10f\n", num, weight);
- if(weightRet == 1) {
- PyList_SetItem(tempVertexList, count,
- Py_BuildValue("(i,f)", num, weight));
- }
- else if (weightRet == 0)
- PyList_SetItem(tempVertexList, count, Py_BuildValue("i", num));
+ if( weightRet == 1 ) {
+ PyList_SetItem( tempVertexList,
+ count,
+ Py_BuildValue
+ ( "(i,f)", num,
+ weight ) );
+ } else if( weightRet == 0 )
+ PyList_SetItem( tempVertexList,
+ count,
+ Py_BuildValue
+ ( "i", num ) );
count++;
}
- if(l2 == FALSE)
- printf("vertex at index %d is not part of passed group...\n", tempInt);
+ if( l2 == FALSE )
+ printf( "vertex at index %d is not part of passed group...\n", tempInt );
}
- if(l1 == FALSE)
- printf("vertex at index %d is not assigned to a vertex group...\n", tempInt);
+ if( l1 == FALSE )
+ printf( "vertex at index %d is not assigned to a vertex group...\n", tempInt );
l1 = l2 = FALSE; //reset flags
}
}
//only return what we need
- vertexList = PyList_GetSlice(tempVertexList, 0, count);
+ vertexList = PyList_GetSlice( tempVertexList, 0, count );
- Py_DECREF(tempVertexList);
+ Py_DECREF( tempVertexList );
- return (vertexList);
+ return ( vertexList );
}
-static PyObject *NMesh_renameVertGroup (PyObject *self, PyObject *args)
+static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args )
{
- char * oldGr = NULL;
- char * newGr = NULL;
- bDeformGroup * defGroup = NULL;
- /*PyObject *tempStr;*/
+ char *oldGr = NULL;
+ char *newGr = NULL;
+ bDeformGroup *defGroup = NULL;
+ /*PyObject *tempStr; */
- if(!((BPy_NMesh*)self)->object)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "This mesh must be linked to an object");
+ if( !( ( BPy_NMesh * ) self )->object )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "This mesh must be linked to an object" );
- if (!PyArg_ParseTuple(args, "ss", &oldGr, &newGr))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "Expected string & string argument");
+ if( !PyArg_ParseTuple( args, "ss", &oldGr, &newGr ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Expected string & string argument" );
- defGroup = get_named_vertexgroup(((BPy_NMesh*)self)->object, oldGr);
- if(defGroup == NULL)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Couldn't find the expected vertex group");
+ defGroup =
+ get_named_vertexgroup( ( ( BPy_NMesh * ) self )->object,
+ oldGr );
+ if( defGroup == NULL )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Couldn't find the expected vertex group" );
//set name
- PyOS_snprintf(defGroup->name, 32, newGr);
- unique_vertexgroup_name(defGroup, ((BPy_NMesh*)self)->object);
+ PyOS_snprintf( defGroup->name, 32, newGr );
+ unique_vertexgroup_name( defGroup, ( ( BPy_NMesh * ) self )->object );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *NMesh_getVertGroupNames (PyObject *self, PyObject *args)
+static PyObject *NMesh_getVertGroupNames( PyObject * self, PyObject * args )
{
- bDeformGroup * defGroup;
+ bDeformGroup *defGroup;
PyObject *list;
- if(!((BPy_NMesh*)self)->object)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "This mesh must be linked to an object");
-
- list = PyList_New(0);
- for (defGroup = (((BPy_NMesh*)self)->object)->defbase.first; defGroup; defGroup=defGroup->next){
- if(PyList_Append(list,PyString_FromString(defGroup->name)) < 0)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Couldn't add item to list");
+ if( !( ( BPy_NMesh * ) self )->object )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "This mesh must be linked to an object" );
+
+ list = PyList_New( 0 );
+ for( defGroup = ( ( ( BPy_NMesh * ) self )->object )->defbase.first;
+ defGroup; defGroup = defGroup->next ) {
+ if( PyList_Append
+ ( list, PyString_FromString( defGroup->name ) ) < 0 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Couldn't add item to list" );
}
return list;
diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h
index 93c2031c17a..1d9b3386dc8 100644
--- a/source/blender/python/api2_2x/NMesh.h
+++ b/source/blender/python/api2_2x/NMesh.h
@@ -1,5 +1,5 @@
-/**
- *
+/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -49,10 +49,10 @@
#include "DNA_material_types.h"
#include "DNA_armature_types.h"
-#include "BDR_editface.h" /* make_tfaces */
+#include "BDR_editface.h" /* make_tfaces */
#include "BIF_editdeform.h"
-#include "BIF_editkey.h" /* insert_meshkey */
-#include "BIF_editmesh.h" /* vertexnormals_mesh() */
+#include "BIF_editkey.h" /* insert_meshkey */
+#include "BIF_editmesh.h" /* vertexnormals_mesh() */
#include "BIF_space.h"
#include "BKE_mesh.h"
#include "BKE_main.h"
@@ -87,10 +87,10 @@ struct BPy_Object;
/* These are from blender/src/editdeform.c, should be declared elsewhere,
* maybe in BIF_editdeform.h, after proper testing of vgrouping methods XXX */
-void create_dverts (Mesh *me);
-void add_vert_defnr (Object *ob, int def_nr, int vertnum, float weight,
- int assignmode);
-void remove_vert_def_nr (Object *ob, int def_nr, int vertnum);
+void create_dverts( Mesh * me );
+void add_vert_defnr( Object * ob, int def_nr, int vertnum, float weight,
+ int assignmode );
+void remove_vert_def_nr( Object * ob, int def_nr, int vertnum );
/* Globals */
static PyObject *g_nmeshmodule = NULL;
@@ -104,24 +104,21 @@ static PyObject *g_nmeshmodule = NULL;
/* Typedefs for the new types */
typedef struct {
- PyObject_HEAD
- unsigned char r, g, b, a;
+ PyObject_HEAD unsigned char r, g, b, a;
-} BPy_NMCol; /* an NMesh color: [r,g,b,a] */
+} BPy_NMCol; /* an NMesh color: [r,g,b,a] */
typedef struct {
- PyObject_VAR_HEAD
- float co[3];
+ PyObject_VAR_HEAD float co[3];
float no[3];
float uvco[3];
int index;
- char flag; /* see MVert flag in DNA_meshdata_types */
+ char flag; /* see MVert flag in DNA_meshdata_types */
-} BPy_NMVert; /* an NMesh vertex */
+} BPy_NMVert; /* an NMesh vertex */
typedef struct {
- PyObject_HEAD
- PyObject *v;
+ PyObject_HEAD PyObject * v;
PyObject *uv;
PyObject *col;
short mode;
@@ -130,20 +127,19 @@ typedef struct {
Image *image;
char mat_nr, smooth;
-} BPy_NMFace; /* an NMesh face */
+} BPy_NMFace; /* an NMesh face */
typedef struct {
- PyObject_HEAD
- Mesh *mesh;
- Object *object; /* for vertex grouping info, since it's stored on the object */
+ PyObject_HEAD Mesh * mesh;
+ Object *object; /* for vertex grouping info, since it's stored on the object */
PyObject *name;
PyObject *materials;
PyObject *verts;
PyObject *faces;
- int sel_face; /*@ XXX remove */
- short smoothresh; /* max AutoSmooth angle */
- short subdiv[2]; /* SubDiv Levels: display and rendering */
- short mode; /* see the EXPP_NMESH_* defines in the beginning of this file */
+ int sel_face; /*@ XXX remove */
+ short smoothresh; /* max AutoSmooth angle */
+ short subdiv[2]; /* SubDiv Levels: display and rendering */
+ short mode; /* see the EXPP_NMESH_* defines in the beginning of this file */
char flags;
#define NMESH_HASMCOL 1<<0
@@ -153,23 +149,24 @@ typedef struct {
} BPy_NMesh;
/* PROTOS */
-extern void test_object_materials(ID *id); /* declared in BKE_material.h */
-static int unlink_existingMeshData(Mesh *mesh);
-static int convert_NMeshToMesh(Mesh *mesh, BPy_NMesh *nmesh);
-void mesh_update(Mesh *mesh);
-PyObject *new_NMesh(Mesh *oldmesh);
-Mesh *Mesh_fromNMesh(BPy_NMesh *nmesh);
-PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob);
-Material **nmesh_updateMaterials(BPy_NMesh *nmesh);
-Material **newMaterialList_fromPyList (PyObject *list);
-void mesh_update(Mesh *mesh);
-static PyObject *NMesh_addVertGroup(PyObject *self, PyObject *args);
-static PyObject *NMesh_removeVertGroup(PyObject *self, PyObject *args);
-static PyObject *NMesh_assignVertsToGroup(PyObject *self, PyObject *args);
-static PyObject *NMesh_removeVertsFromGroup(PyObject *self, PyObject *args);
-static PyObject *NMesh_getVertsFromGroup(PyObject *self, PyObject *args);
-static PyObject *NMesh_renameVertGroup (PyObject *self, PyObject *args);
-static PyObject *NMesh_getVertGroupNames (PyObject *self, PyObject *args);
-
-
-#endif /* EXPP_NMESH_H */
+extern void test_object_materials( ID * id ); /* declared in BKE_material.h */
+static int unlink_existingMeshData( Mesh * mesh );
+static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh );
+void mesh_update( Mesh * mesh );
+PyObject *new_NMesh( Mesh * oldmesh );
+Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh );
+PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob );
+Material **nmesh_updateMaterials( BPy_NMesh * nmesh );
+Material **newMaterialList_fromPyList( PyObject * list );
+void mesh_update( Mesh * mesh );
+static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_removeVertsFromGroup( PyObject * self,
+ PyObject * args );
+static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_getVertGroupNames( PyObject * self, PyObject * args );
+
+
+#endif /* EXPP_NMESH_H */
diff --git a/source/blender/python/api2_2x/Noise.c b/source/blender/python/api2_2x/Noise.c
index c42b3487131..15e830ae580 100644
--- a/source/blender/python/api2_2x/Noise.c
+++ b/source/blender/python/api2_2x/Noise.c
@@ -43,317 +43,373 @@
#include <DNA_texture_types.h>
#include "constant.h"
-/*------------------------------------------------------------------------------------*/
+/*-----------------------------------------*/
/* 'mersenne twister' random number generator */
/* Period parameters */
#define N 624
#define M 397
-#define MATRIX_A 0x9908b0dfUL /* constant vector a */
-#define UMASK 0x80000000UL /* most significant w-r bits */
-#define LMASK 0x7fffffffUL /* least significant r bits */
+#define MATRIX_A 0x9908b0dfUL /* constant vector a */
+#define UMASK 0x80000000UL /* most significant w-r bits */
+#define LMASK 0x7fffffffUL /* least significant r bits */
#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) )
#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
-static unsigned long state[N]; /* the array for the state vector */
+static unsigned long state[N]; /* the array for the state vector */
static int left = 1;
static int initf = 0;
static unsigned long *next;
/* initializes state[N] with a seed */
-static void init_genrand(unsigned long s)
+static void init_genrand( unsigned long s )
{
int j;
- state[0]= s & 0xffffffffUL;
- for (j=1; j<N; j++) {
- state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j);
+ state[0] = s & 0xffffffffUL;
+ for( j = 1; j < N; j++ ) {
+ state[j] =
+ ( 1812433253UL *
+ ( state[j - 1] ^ ( state[j - 1] >> 30 ) ) + j );
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array state[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
- state[j] &= 0xffffffffUL; /* for >32 bit machines */
+ state[j] &= 0xffffffffUL; /* for >32 bit machines */
}
- left = 1; initf = 1;
+ left = 1;
+ initf = 1;
}
-static void next_state(void)
+static void next_state( void )
{
- unsigned long *p=state;
+ unsigned long *p = state;
int j;
/* if init_genrand() has not been called, */
/* a default initial seed is used */
- if (initf==0) init_genrand(5489UL);
+ if( initf == 0 )
+ init_genrand( 5489UL );
left = N;
next = state;
- for (j=N-M+1; --j; p++)
- *p = p[M] ^ TWIST(p[0], p[1]);
+ for( j = N - M + 1; --j; p++ )
+ *p = p[M] ^ TWIST( p[0], p[1] );
- for (j=M; --j; p++)
- *p = p[M-N] ^ TWIST(p[0], p[1]);
+ for( j = M; --j; p++ )
+ *p = p[M - N] ^ TWIST( p[0], p[1] );
- *p = p[M-N] ^ TWIST(p[0], state[0]);
+ *p = p[M - N] ^ TWIST( p[0], state[0] );
}
-/*------------------------------------------------------------------------------------*/
+/*------------------------------------------------------------*/
-static void setRndSeed(int seed)
+static void setRndSeed( int seed )
{
- if (seed==0)
- init_genrand(time(NULL));
+ if( seed == 0 )
+ init_genrand( time( NULL ) );
else
- init_genrand(seed);
+ init_genrand( seed );
}
/* float number in range [0, 1) */
-static float frand()
+static float frand( )
{
unsigned long y;
- if (--left == 0) next_state();
+ if( --left == 0 )
+ next_state( );
y = *next++;
/* Tempering */
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9d2c5680UL;
- y ^= (y << 15) & 0xefc60000UL;
- y ^= (y >> 18);
+ y ^= ( y >> 11 );
+ y ^= ( y << 7 ) & 0x9d2c5680UL;
+ y ^= ( y << 15 ) & 0xefc60000UL;
+ y ^= ( y >> 18 );
- return (float)y/4294967296.f;
+ return ( float ) y / 4294967296.f;
}
/* returns random unit vector */
-static void randuvec(float v[3])
+static void randuvec( float v[3] )
{
float r;
- v[2] = 2.f*frand()-1.f;
- if ((r = 1.f - v[2]*v[2])>0.f) {
- float a = 6.283185307f * frand();
- r = sqrt(r);
- v[0] = r * cos(a);
- v[1] = r * sin(a);
- }
- else v[2] = 1.f;
+ v[2] = 2.f * frand( ) - 1.f;
+ if( ( r = 1.f - v[2] * v[2] ) > 0.f ) {
+ float a = 6.283185307f * frand( );
+ r = sqrt( r );
+ v[0] = r * cos( a );
+ v[1] = r * sin( a );
+ } else
+ v[2] = 1.f;
}
-static PyObject *Noise_random(PyObject *self)
+static PyObject *Noise_random( PyObject * self )
{
- return Py_BuildValue("f", frand());
+ return Py_BuildValue( "f", frand( ) );
}
-static PyObject *Noise_randuvec(PyObject *self)
+static PyObject *Noise_randuvec( PyObject * self )
{
float v[3];
- randuvec(v);
- return Py_BuildValue("[fff]", v[0], v[1], v[2]);
+ randuvec( v );
+ return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
-/*------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------*/
/* Random seed init. Only used for MT random() & randuvec() */
-static PyObject *Noise_setRandomSeed(PyObject *self, PyObject *args)
+static PyObject *Noise_setRandomSeed( PyObject * self, PyObject * args )
{
int s;
- if (!PyArg_ParseTuple(args, "i", &s)) return NULL;
- setRndSeed(s);
- Py_INCREF(Py_None);
+ if( !PyArg_ParseTuple( args, "i", &s ) )
+ return NULL;
+ setRndSeed( s );
+ Py_INCREF( Py_None );
return Py_None;
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
/* General noise */
-static PyObject *Noise_noise(PyObject *self, PyObject *args)
+static PyObject *Noise_noise( PyObject * self, PyObject * args )
{
float x, y, z;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)|ii", &x ,&y, &z, &nb)) return NULL;
- return Py_BuildValue("f", 2.0*BLI_gNoise(1.0, x, y, z, 0, nb)-1.0);
+ if( !PyArg_ParseTuple( args, "(fff)|ii", &x, &y, &z, &nb ) )
+ return NULL;
+ return Py_BuildValue( "f",
+ 2.0 * BLI_gNoise( 1.0, x, y, z, 0, nb ) - 1.0 );
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
/* General Vector noise */
-static void vNoise(float x, float y ,float z, int nb, float v[3])
+static void vNoise( float x, float y, float z, int nb, float v[3] )
{
/* Simply evaluate noise at 3 different positions */
- v[0] = 2.0*BLI_gNoise(1.f, x+9.321f, y-1.531f, z-7.951f, 0, nb)-1.0;
- v[1] = 2.0*BLI_gNoise(1.f, x, y, z, 0, nb)-1.0;
- v[2] = 2.0*BLI_gNoise(1.f, x+6.327f, y+0.1671f, z-2.672f, 0, nb)-1.0;
+ v[0] = 2.0 * BLI_gNoise( 1.f, x + 9.321f, y - 1.531f, z - 7.951f, 0,
+ nb ) - 1.0;
+ v[1] = 2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0;
+ v[2] = 2.0 * BLI_gNoise( 1.f, x + 6.327f, y + 0.1671f, z - 2.672f, 0,
+ nb ) - 1.0;
}
-static PyObject *Noise_vNoise(PyObject *self, PyObject *args)
+static PyObject *Noise_vNoise( PyObject * self, PyObject * args )
{
float x, y, z, v[3];
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)", &x ,&y, &z, &nb)) return NULL;
- vNoise(x, y, z, nb, v);
- return Py_BuildValue("[fff]", v[0], v[1], v[2]);
+ if( !PyArg_ParseTuple( args, "(fff)", &x, &y, &z, &nb ) )
+ return NULL;
+ vNoise( x, y, z, nb, v );
+ return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
-/*------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
/* General turbulence */
-static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
+static float turb( float x, float y, float z, int oct, int hard, int nb,
+ float ampscale, float freqscale )
{
float amp, out, t;
int i;
amp = 1.f;
- out = 2.0*BLI_gNoise(1.f, x, y, z, 0, nb)-1.0;
- if (hard) out = fabs(out);
- for (i=1;i<oct;i++) {
- amp*=ampscale; x*=freqscale; y*=freqscale; z*=freqscale;
- t = amp * (2.0*BLI_gNoise(1.f, x, y, z, 0, nb)-1.0);
- if (hard) t = fabs(t);
+ out = 2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0;
+ if( hard )
+ out = fabs( out );
+ for( i = 1; i < oct; i++ ) {
+ amp *= ampscale;
+ x *= freqscale;
+ y *= freqscale;
+ z *= freqscale;
+ t = amp * ( 2.0 * BLI_gNoise( 1.f, x, y, z, 0, nb ) - 1.0 );
+ if( hard )
+ t = fabs( t );
out += t;
}
return out;
}
-static PyObject *Noise_turbulence(PyObject *self, PyObject *args)
+static PyObject *Noise_turbulence( PyObject * self, PyObject * args )
{
float x, y, z;
- int oct, hd, nb=1;
- float as=0.5, fs=2.0;
- if (!PyArg_ParseTuple(args, "(fff)ii|iff", &x ,&y, &z, &oct, &hd, &nb, &as, &fs)) return NULL;
- return Py_BuildValue("f", turb(x, y, z, oct, hd, nb, as, fs));
+ int oct, hd, nb = 1;
+ float as = 0.5, fs = 2.0;
+ if( !PyArg_ParseTuple
+ ( args, "(fff)ii|iff", &x, &y, &z, &oct, &hd, &nb, &as, &fs ) )
+ return NULL;
+ return Py_BuildValue( "f", turb( x, y, z, oct, hd, nb, as, fs ) );
}
-/*------------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
/* Turbulence Vector */
-static void vTurb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale, float v[3])
+static void vTurb( float x, float y, float z, int oct, int hard, int nb,
+ float ampscale, float freqscale, float v[3] )
{
float amp, t[3];
int i;
amp = 1.f;
- vNoise(x, y, z, nb, v);
- if (hard) { v[0]=fabs(v[0]); v[1]=fabs(v[1]); v[2]=fabs(v[2]); }
- for (i=1;i<oct;i++) {
- amp*=ampscale; x*=freqscale; y*=freqscale; z*=freqscale;
- vNoise(x, y, z, nb, t);
- if (hard) { t[0]=fabs(t[0]); t[1]=fabs(t[1]); t[2]=fabs(t[2]); }
+ vNoise( x, y, z, nb, v );
+ if( hard ) {
+ v[0] = fabs( v[0] );
+ v[1] = fabs( v[1] );
+ v[2] = fabs( v[2] );
+ }
+ for( i = 1; i < oct; i++ ) {
+ amp *= ampscale;
+ x *= freqscale;
+ y *= freqscale;
+ z *= freqscale;
+ vNoise( x, y, z, nb, t );
+ if( hard ) {
+ t[0] = fabs( t[0] );
+ t[1] = fabs( t[1] );
+ t[2] = fabs( t[2] );
+ }
v[0] += amp * t[0];
v[1] += amp * t[1];
v[2] += amp * t[2];
}
}
-static PyObject *Noise_vTurbulence(PyObject *self, PyObject *args)
+static PyObject *Noise_vTurbulence( PyObject * self, PyObject * args )
{
float x, y, z, v[3];
- int oct, hd, nb=1;
- float as=0.5, fs=2.0;
- if (!PyArg_ParseTuple(args, "(fff)ii|iff", &x ,&y, &z, &oct, &hd, &nb, &as, &fs)) return NULL;
- vTurb(x, y, z, oct, hd, nb, as, fs, v);
- return Py_BuildValue("[fff]", v[0], v[1], v[2]);
+ int oct, hd, nb = 1;
+ float as = 0.5, fs = 2.0;
+ if( !PyArg_ParseTuple
+ ( args, "(fff)ii|iff", &x, &y, &z, &oct, &hd, &nb, &as, &fs ) )
+ return NULL;
+ vTurb( x, y, z, oct, hd, nb, as, fs, v );
+ return Py_BuildValue( "[fff]", v[0], v[1], v[2] );
}
-/*------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------*/
/* F. Kenton Musgrave's fractal functions */
-static PyObject *Noise_fBm(PyObject *self, PyObject *args)
+static PyObject *Noise_fBm( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)fff|i", &x ,&y, &z, &H, &lac, &oct, &nb)) return NULL;
- return Py_BuildValue("f", mg_fBm(x, y, z, H, lac, oct, nb));
+ if( !PyArg_ParseTuple
+ ( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
+ return NULL;
+ return Py_BuildValue( "f", mg_fBm( x, y, z, H, lac, oct, nb ) );
}
-/*------------------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*/
-static PyObject *Noise_multiFractal(PyObject *self, PyObject *args)
+static PyObject *Noise_multiFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)fff|i", &x ,&y, &z, &H, &lac, &oct, &nb)) return NULL;
- return Py_BuildValue("f", mg_MultiFractal(x, y, z, H, lac, oct, nb));
+ if( !PyArg_ParseTuple
+ ( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
+ return NULL;
+ return Py_BuildValue( "f",
+ mg_MultiFractal( x, y, z, H, lac, oct, nb ) );
}
-/*------------------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*/
-static PyObject *Noise_vlNoise(PyObject *self, PyObject *args)
+static PyObject *Noise_vlNoise( PyObject * self, PyObject * args )
{
float x, y, z, d;
- int nt1=1, nt2=1;
- if (!PyArg_ParseTuple(args, "(fff)f|ii", &x ,&y, &z, &d, &nt1, &nt2)) return NULL;
- return Py_BuildValue("f", mg_VLNoise(x, y, z, d, nt1, nt2));
+ int nt1 = 1, nt2 = 1;
+ if( !PyArg_ParseTuple
+ ( args, "(fff)f|ii", &x, &y, &z, &d, &nt1, &nt2 ) )
+ return NULL;
+ return Py_BuildValue( "f", mg_VLNoise( x, y, z, d, nt1, nt2 ) );
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
-static PyObject *Noise_heteroTerrain(PyObject *self, PyObject *args)
+static PyObject *Noise_heteroTerrain( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)ffff|i", &x ,&y, &z, &H, &lac, &oct, &ofs, &nb)) return NULL;
- return Py_BuildValue("f", mg_HeteroTerrain(x, y, z, H, lac, oct, ofs, nb));
+ if( !PyArg_ParseTuple
+ ( args, "(fff)ffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &nb ) )
+ return NULL;
+ return Py_BuildValue( "f",
+ mg_HeteroTerrain( x, y, z, H, lac, oct, ofs,
+ nb ) );
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
-static PyObject *Noise_hybridMFractal(PyObject *self, PyObject *args)
+static PyObject *Noise_hybridMFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs, gn;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)fffff|i", &x ,&y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL;
- return Py_BuildValue("f", mg_HybridMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
+ if( !PyArg_ParseTuple
+ ( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
+ &nb ) )
+ return NULL;
+ return Py_BuildValue( "f",
+ mg_HybridMultiFractal( x, y, z, H, lac, oct, ofs,
+ gn, nb ) );
}
-/*------------------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*/
-static PyObject *Noise_ridgedMFractal(PyObject *self, PyObject *args)
+static PyObject *Noise_ridgedMFractal( PyObject * self, PyObject * args )
{
float x, y, z, H, lac, oct, ofs, gn;
int nb = 1;
- if (!PyArg_ParseTuple(args, "(fff)fffff|i", &x ,&y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL;
- return Py_BuildValue("f", mg_RidgedMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb));
+ if( !PyArg_ParseTuple
+ ( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
+ &nb ) )
+ return NULL;
+ return Py_BuildValue( "f",
+ mg_RidgedMultiFractal( x, y, z, H, lac, oct, ofs,
+ gn, nb ) );
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
-static PyObject *Noise_voronoi(PyObject *self, PyObject *args)
+static PyObject *Noise_voronoi( PyObject * self, PyObject * args )
{
float x, y, z, da[4], pa[12];
int dtype = 0;
- float me = 2.5; /* default minkovsky exponent */
- if (!PyArg_ParseTuple(args, "(fff)|if", &x ,&y, &z, &dtype, &me)) return NULL;
- voronoi(x, y, z, da, pa, me, dtype);
- return Py_BuildValue("[[ffff][[fff][fff][fff][fff]]]",
- da[0], da[1], da[2], da[3],
- pa[0], pa[1], pa[2],
- pa[3], pa[4], pa[5],
- pa[6], pa[7], pa[8],
- pa[9], pa[10], pa[12]);
+ float me = 2.5; /* default minkovsky exponent */
+ if( !PyArg_ParseTuple( args, "(fff)|if", &x, &y, &z, &dtype, &me ) )
+ return NULL;
+ voronoi( x, y, z, da, pa, me, dtype );
+ return Py_BuildValue( "[[ffff][[fff][fff][fff][fff]]]",
+ da[0], da[1], da[2], da[3],
+ pa[0], pa[1], pa[2],
+ pa[3], pa[4], pa[5],
+ pa[6], pa[7], pa[8], pa[9], pa[10], pa[12] );
}
-/*------------------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
-static PyObject *Noise_cellNoise(PyObject *self, PyObject *args)
+static PyObject *Noise_cellNoise( PyObject * self, PyObject * args )
{
float x, y, z;
- if (!PyArg_ParseTuple(args, "(fff)", &x ,&y, &z)) return NULL;
- return Py_BuildValue("f", cellNoise(x,y,z));
+ if( !PyArg_ParseTuple( args, "(fff)", &x, &y, &z ) )
+ return NULL;
+ return Py_BuildValue( "f", cellNoise( x, y, z ) );
}
-/*------------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
-static PyObject *Noise_cellNoiseV(PyObject *self, PyObject *args)
+static PyObject *Noise_cellNoiseV( PyObject * self, PyObject * args )
{
float x, y, z, ca[3];
- if (!PyArg_ParseTuple(args, "(fff)", &x ,&y, &z)) return NULL;
- cellNoiseV(x, y, z, ca);
- return Py_BuildValue("[fff]", ca[0], ca[1], ca[2]);
+ if( !PyArg_ParseTuple( args, "(fff)", &x, &y, &z ) )
+ return NULL;
+ cellNoiseV( x, y, z, ca );
+ return Py_BuildValue( "[fff]", ca[0], ca[1], ca[2] );
}
-/*------------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
/* For all other Blender modules, this stuff seems to be put in a header file.
This doesn't seem really appropriate to me, so I just put it here, feel free to change it.
In the original module I actually kept the docs stings with the functions themselves,
@@ -362,7 +418,8 @@ static PyObject *Noise_cellNoiseV(PyObject *self, PyObject *args)
static char random__doc__[] = "() No arguments.\n\n\
Returns a random floating point number in the range [0, 1)";
-static char randuvec__doc__[] = "() No arguments.\n\nReturns a random unit vector (3-float list).";
+static char randuvec__doc__[] =
+ "() No arguments.\n\nReturns a random unit vector (3-float list).";
static char setRandomSeed__doc__[] = "(seed value)\n\n\
Initializes random number generator.\n\
@@ -376,7 +433,8 @@ static char vNoise__doc__[] = "((x,y,z) tuple, [noisetype])\n\n\
Returns noise vector (3-float list) of the optional specified type.\
Optional argument noisetype determines the type of noise, STDPERLIN by default, see NoiseTypes.";
-static char turbulence__doc__[] = "((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
+static char turbulence__doc__[] =
+ "((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
Returns general turbulence value using the optional specified noisebasis function.\n\
octaves (integer) is the number of noise values added.\n\
hard (bool), when false (0) returns 'soft' noise, when true (1) returns 'hard' noise (returned value always positive).\n\
@@ -385,7 +443,8 @@ noisebasis determines the type of noise used for the turbulence, STDPERLIN by de
ampscale sets the amplitude scale value of the noise frequencies added, 0.5 by default.\n\
freqscale sets the frequency scale factor, 2.0 by default.";
-static char vTurbulence__doc__[] = "((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
+static char vTurbulence__doc__[] =
+ "((x,y,z) tuple, octaves, hard, [noisebasis], [ampscale], [freqscale])\n\n\
Returns general turbulence vector (3-float list) using the optional specified noisebasis function.\n\
octaves (integer) is the number of noise values added.\n\
hard (bool), when false (0) returns 'soft' noise, when true (1) returns 'hard' noise (returned vector always positive).\n\
@@ -394,27 +453,31 @@ noisebasis determines the type of noise used for the turbulence, STDPERLIN by de
ampscale sets the amplitude scale value of the noise frequencies added, 0.5 by default.\n\
freqscale sets the frequency scale factor, 2.0 by default.";
-static char fBm__doc__[] = "((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
+static char fBm__doc__[] =
+ "((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
Returns Fractal Brownian Motion noise value(fBm).\n\
H is the fractal increment parameter.\n\
lacunarity is the gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
-static char multiFractal__doc__[] = "((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
+static char multiFractal__doc__[] =
+ "((x,y,z) tuple, H, lacunarity, octaves, [noisebasis])\n\n\
Returns Multifractal noise value.\n\
H determines the highest fractal dimension.\n\
lacunarity is gap between successive frequencies.\n\
octaves is the number of frequencies in the fBm.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
-static char vlNoise__doc__[] = "((x,y,z) tuple, distortion, [noisetype1], [noisetype2])\n\n\
+static char vlNoise__doc__[] =
+ "((x,y,z) tuple, distortion, [noisetype1], [noisetype2])\n\n\
Returns Variable Lacunarity Noise value, a distorted variety of noise.\n\
distortion sets the amount of distortion.\n\
Optional arguments noisetype1 and noisetype2 set the noisetype to distort and the noisetype used for the distortion respectively.\n\
See NoiseTypes, both are STDPERLIN by default.";
-static char heteroTerrain__doc__[] = "((x,y,z) tuple, H, lacunarity, octaves, offset, [noisebasis])\n\n\
+static char heteroTerrain__doc__[] =
+ "((x,y,z) tuple, H, lacunarity, octaves, offset, [noisebasis])\n\n\
returns Heterogeneous Terrain value\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
@@ -422,7 +485,8 @@ octaves is the number of frequencies in the fBm.\n\
offset raises the terrain from 'sea level'.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
-static char hybridMFractal__doc__[] = "((x,y,z) tuple, H, lacunarity, octaves, offset, gain, [noisebasis])\n\n\
+static char hybridMFractal__doc__[] =
+ "((x,y,z) tuple, H, lacunarity, octaves, offset, gain, [noisebasis])\n\n\
returns Hybrid Multifractal value.\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
@@ -431,7 +495,8 @@ offset raises the terrain from 'sea level'.\n\
gain scales the values.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
-static char ridgedMFractal__doc__[] = "((x,y,z) tuple, H, lacunarity, octaves, offset, gain [noisebasis])\n\n\
+static char ridgedMFractal__doc__[] =
+ "((x,y,z) tuple, H, lacunarity, octaves, offset, gain [noisebasis])\n\n\
returns Ridged Multifractal value.\n\
H determines the fractal dimension of the roughest areas.\n\
lacunarity is the gap between successive frequencies.\n\
@@ -440,7 +505,8 @@ offset raises the terrain from 'sea level'.\n\
gain scales the values.\n\
Optional argument noisebasis determines the type of noise used for the turbulence, STDPERLIN by default, see NoiseTypes.";
-static char voronoi__doc__[] = "((x,y,z) tuple, distance_metric, [exponent])\n\n\
+static char voronoi__doc__[] =
+ "((x,y,z) tuple, distance_metric, [exponent])\n\n\
returns a list, containing a list of distances in order of closest feature,\n\
and a list containing the positions of the four closest features\n\
Optional arguments:\n\
@@ -504,63 +570,94 @@ static PyObject *Noise_cellNoiseV(PyObject *self, PyObject *args);
*/
static PyMethodDef NoiseMethods[] = {
- {"setRandomSeed", (PyCFunction)Noise_setRandomSeed, METH_VARARGS, setRandomSeed__doc__},
- {"random", (PyCFunction)Noise_random, METH_NOARGS, random__doc__},
- {"randuvec", (PyCFunction)Noise_randuvec, METH_NOARGS, randuvec__doc__},
- {"noise", (PyCFunction)Noise_noise, METH_VARARGS, noise__doc__},
- {"vNoise", (PyCFunction)Noise_vNoise, METH_VARARGS, vNoise__doc__},
- {"turbulence", (PyCFunction)Noise_turbulence, METH_VARARGS, turbulence__doc__},
- {"vTurbulence", (PyCFunction)Noise_vTurbulence, METH_VARARGS, vTurbulence__doc__},
- {"fBm", (PyCFunction)Noise_fBm, METH_VARARGS, fBm__doc__},
- {"multiFractal", (PyCFunction)Noise_multiFractal, METH_VARARGS, multiFractal__doc__},
- {"vlNoise", (PyCFunction)Noise_vlNoise, METH_VARARGS, vlNoise__doc__},
- {"heteroTerrain", (PyCFunction)Noise_heteroTerrain, METH_VARARGS, heteroTerrain__doc__},
- {"hybridMFractal", (PyCFunction)Noise_hybridMFractal, METH_VARARGS, hybridMFractal__doc__},
- {"ridgedMFractal", (PyCFunction)Noise_ridgedMFractal, METH_VARARGS, ridgedMFractal__doc__},
- {"voronoi", (PyCFunction)Noise_voronoi, METH_VARARGS, voronoi__doc__},
- {"cellNoise", (PyCFunction)Noise_cellNoise, METH_VARARGS, cellNoise__doc__},
- {"cellNoiseV", (PyCFunction)Noise_cellNoiseV, METH_VARARGS, cellNoiseV__doc__},
+ {"setRandomSeed", ( PyCFunction ) Noise_setRandomSeed, METH_VARARGS,
+ setRandomSeed__doc__},
+ {"random", ( PyCFunction ) Noise_random, METH_NOARGS, random__doc__},
+ {"randuvec", ( PyCFunction ) Noise_randuvec, METH_NOARGS,
+ randuvec__doc__},
+ {"noise", ( PyCFunction ) Noise_noise, METH_VARARGS, noise__doc__},
+ {"vNoise", ( PyCFunction ) Noise_vNoise, METH_VARARGS, vNoise__doc__},
+ {"turbulence", ( PyCFunction ) Noise_turbulence, METH_VARARGS,
+ turbulence__doc__},
+ {"vTurbulence", ( PyCFunction ) Noise_vTurbulence, METH_VARARGS,
+ vTurbulence__doc__},
+ {"fBm", ( PyCFunction ) Noise_fBm, METH_VARARGS, fBm__doc__},
+ {"multiFractal", ( PyCFunction ) Noise_multiFractal, METH_VARARGS,
+ multiFractal__doc__},
+ {"vlNoise", ( PyCFunction ) Noise_vlNoise, METH_VARARGS,
+ vlNoise__doc__},
+ {"heteroTerrain", ( PyCFunction ) Noise_heteroTerrain, METH_VARARGS,
+ heteroTerrain__doc__},
+ {"hybridMFractal", ( PyCFunction ) Noise_hybridMFractal, METH_VARARGS,
+ hybridMFractal__doc__},
+ {"ridgedMFractal", ( PyCFunction ) Noise_ridgedMFractal, METH_VARARGS,
+ ridgedMFractal__doc__},
+ {"voronoi", ( PyCFunction ) Noise_voronoi, METH_VARARGS,
+ voronoi__doc__},
+ {"cellNoise", ( PyCFunction ) Noise_cellNoise, METH_VARARGS,
+ cellNoise__doc__},
+ {"cellNoiseV", ( PyCFunction ) Noise_cellNoiseV, METH_VARARGS,
+ cellNoiseV__doc__},
{NULL, NULL, 0, NULL}
};
-/*------------------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------*/
-PyObject *Noise_Init()
+PyObject *Noise_Init( )
{
PyObject *NoiseTypes, *DistanceMetrics,
- *md = Py_InitModule3("Blender.Noise", NoiseMethods, Noise__doc__);
+ *md =
+ Py_InitModule3( "Blender.Noise", NoiseMethods, Noise__doc__ );
- setRndSeed(0); /* use current time as seed for random number generator by default */
+ /* use current time as seed for random number generator by default */
+ setRndSeed( 0 );
/* Constant noisetype dictionary */
- NoiseTypes = M_constant_New();
- if (NoiseTypes) {
- BPy_constant *nt = (BPy_constant *)NoiseTypes;
- constant_insert(nt, "BLENDER", PyInt_FromLong(TEX_BLENDER));
- constant_insert(nt, "STDPERLIN", PyInt_FromLong(TEX_STDPERLIN));
- constant_insert(nt, "NEWPERLIN", PyInt_FromLong(TEX_NEWPERLIN));
- constant_insert(nt, "VORONOI_F1", PyInt_FromLong(TEX_VORONOI_F1));
- constant_insert(nt, "VORONOI_F2", PyInt_FromLong(TEX_VORONOI_F2));
- constant_insert(nt, "VORONOI_F3", PyInt_FromLong(TEX_VORONOI_F3));
- constant_insert(nt, "VORONOI_F4", PyInt_FromLong(TEX_VORONOI_F4));
- constant_insert(nt, "VORONOI_F2F1", PyInt_FromLong(TEX_VORONOI_F2F1));
- constant_insert(nt, "VORONOI_CRACKLE", PyInt_FromLong(TEX_VORONOI_CRACKLE));
- constant_insert(nt, "CELLNOISE", PyInt_FromLong(TEX_CELLNOISE));
- PyModule_AddObject(md, "NoiseTypes", NoiseTypes);
+ NoiseTypes = M_constant_New( );
+ if( NoiseTypes ) {
+ BPy_constant *nt = ( BPy_constant * ) NoiseTypes;
+ constant_insert( nt, "BLENDER",
+ PyInt_FromLong( TEX_BLENDER ) );
+ constant_insert( nt, "STDPERLIN",
+ PyInt_FromLong( TEX_STDPERLIN ) );
+ constant_insert( nt, "NEWPERLIN",
+ PyInt_FromLong( TEX_NEWPERLIN ) );
+ constant_insert( nt, "VORONOI_F1",
+ PyInt_FromLong( TEX_VORONOI_F1 ) );
+ constant_insert( nt, "VORONOI_F2",
+ PyInt_FromLong( TEX_VORONOI_F2 ) );
+ constant_insert( nt, "VORONOI_F3",
+ PyInt_FromLong( TEX_VORONOI_F3 ) );
+ constant_insert( nt, "VORONOI_F4",
+ PyInt_FromLong( TEX_VORONOI_F4 ) );
+ constant_insert( nt, "VORONOI_F2F1",
+ PyInt_FromLong( TEX_VORONOI_F2F1 ) );
+ constant_insert( nt, "VORONOI_CRACKLE",
+ PyInt_FromLong( TEX_VORONOI_CRACKLE ) );
+ constant_insert( nt, "CELLNOISE",
+ PyInt_FromLong( TEX_CELLNOISE ) );
+ PyModule_AddObject( md, "NoiseTypes", NoiseTypes );
}
/* Constant distance metric dictionary for voronoi */
- DistanceMetrics = M_constant_New();
- if (DistanceMetrics) {
- BPy_constant *dm = (BPy_constant *)DistanceMetrics;
- constant_insert(dm, "DISTANCE", PyInt_FromLong(TEX_DISTANCE));
- constant_insert(dm, "DISTANCE_SQUARED", PyInt_FromLong(TEX_DISTANCE_SQUARED));
- constant_insert(dm, "MANHATTAN", PyInt_FromLong(TEX_MANHATTAN));
- constant_insert(dm, "CHEBYCHEV", PyInt_FromLong(TEX_CHEBYCHEV));
- constant_insert(dm, "MINKOVSKY_HALF", PyInt_FromLong(TEX_MINKOVSKY_HALF));
- constant_insert(dm, "MINKOVSKY_FOUR", PyInt_FromLong(TEX_MINKOVSKY_FOUR));
- constant_insert(dm, "MINKOVSKY", PyInt_FromLong(TEX_MINKOVSKY));
- PyModule_AddObject(md, "DistanceMetrics", DistanceMetrics);
+ DistanceMetrics = M_constant_New( );
+ if( DistanceMetrics ) {
+ BPy_constant *dm = ( BPy_constant * ) DistanceMetrics;
+ constant_insert( dm, "DISTANCE",
+ PyInt_FromLong( TEX_DISTANCE ) );
+ constant_insert( dm, "DISTANCE_SQUARED",
+ PyInt_FromLong( TEX_DISTANCE_SQUARED ) );
+ constant_insert( dm, "MANHATTAN",
+ PyInt_FromLong( TEX_MANHATTAN ) );
+ constant_insert( dm, "CHEBYCHEV",
+ PyInt_FromLong( TEX_CHEBYCHEV ) );
+ constant_insert( dm, "MINKOVSKY_HALF",
+ PyInt_FromLong( TEX_MINKOVSKY_HALF ) );
+ constant_insert( dm, "MINKOVSKY_FOUR",
+ PyInt_FromLong( TEX_MINKOVSKY_FOUR ) );
+ constant_insert( dm, "MINKOVSKY",
+ PyInt_FromLong( TEX_MINKOVSKY ) );
+ PyModule_AddObject( md, "DistanceMetrics", DistanceMetrics );
}
return md;
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 23153f51731..ba5a757a3c6 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -47,1779 +47,1768 @@
/*****************************************************************************/
-/* Python API function prototypes for the Blender module. */
+/* Python API function prototypes for the Blender module. */
/*****************************************************************************/
-static PyObject *M_Object_New(PyObject *self, PyObject *args);
-PyObject *M_Object_Get(PyObject *self, PyObject *args);
-PyObject *M_Object_get(PyObject *self, PyObject *args);
-static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args);
-static PyObject *M_Object_getSelected (PyObject *self, PyObject *args);
+static PyObject *M_Object_New( PyObject * self, PyObject * args );
+PyObject *M_Object_Get( PyObject * self, PyObject * args );
+PyObject *M_Object_get( PyObject * self, PyObject * args );
+static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args );
+static PyObject *M_Object_getSelected( PyObject * self, PyObject * args );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Object.__doc__ */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Object.__doc__ */
/*****************************************************************************/
-char M_Object_doc[] =
-"The Blender Object module\n\n\
+char M_Object_doc[] = "The Blender Object module\n\n\
This module provides access to **Object Data** in Blender.\n";
char M_Object_New_doc[] =
-"(type) - Add a new object of type 'type' in the current scene";
+ "(type) - Add a new object of type 'type' in the current scene";
char M_Object_Get_doc[] =
-"(name) - return the object with the name 'name', returns None if not\
+ "(name) - return the object with the name 'name', returns None if not\
found.\n\
If 'name' is not specified, it returns a list of all objects in the\n\
current scene.";
char M_Object_GetSelected_doc[] =
-"() - Returns a list of selected Objects in the active layer(s)\n\
+ "() - Returns a list of selected Objects in the active layer(s)\n\
The active object is the first in the list, if visible";
/*****************************************************************************/
-/* Python method structure definition for Blender.Object module: */
+/* Python method structure definition for Blender.Object module: */
/*****************************************************************************/
struct PyMethodDef M_Object_methods[] = {
- {"New", (PyCFunction)M_Object_New, METH_VARARGS,
- M_Object_New_doc},
- {"Get", (PyCFunction)M_Object_Get, METH_VARARGS,
- M_Object_Get_doc},
- {"get", (PyCFunction)M_Object_get, METH_VARARGS,
- M_Object_Get_doc},
- {"GetSelected", (PyCFunction)M_Object_GetSelected, METH_VARARGS,
- M_Object_GetSelected_doc},
- {"getSelected", (PyCFunction)M_Object_getSelected, METH_VARARGS,
- M_Object_GetSelected_doc},
+ {"New", ( PyCFunction ) M_Object_New, METH_VARARGS,
+ M_Object_New_doc},
+ {"Get", ( PyCFunction ) M_Object_Get, METH_VARARGS,
+ M_Object_Get_doc},
+ {"get", ( PyCFunction ) M_Object_get, METH_VARARGS,
+ M_Object_Get_doc},
+ {"GetSelected", ( PyCFunction ) M_Object_GetSelected, METH_VARARGS,
+ M_Object_GetSelected_doc},
+ {"getSelected", ( PyCFunction ) M_Object_getSelected, METH_VARARGS,
+ M_Object_GetSelected_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python BPy_Object methods declarations: */
+/* Python BPy_Object methods declarations: */
/*****************************************************************************/
-static PyObject *Object_buildParts (BPy_Object *self);
-static PyObject *Object_clearIpo (BPy_Object *self);
-static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
-static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args);
-static PyObject *Object_getData (BPy_Object *self);
-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);
-static PyObject *Object_getInverseMatrix (BPy_Object *self);
-static PyObject *Object_getIpo (BPy_Object *self);
-static PyObject *Object_getLocation (BPy_Object *self, PyObject *args);
-static PyObject *Object_getMaterials (BPy_Object *self, PyObject *args);
-static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args);
-static PyObject *Object_getName (BPy_Object *self);
-static PyObject *Object_getParent (BPy_Object *self);
-static PyObject *Object_getSize (BPy_Object *self, PyObject *args);
-static PyObject *Object_getTimeOffset (BPy_Object *self);
-static PyObject *Object_getTracked (BPy_Object *self);
-static PyObject *Object_getType (BPy_Object *self);
-static PyObject *Object_getBoundBox (BPy_Object *self);
-static PyObject *Object_getAction (BPy_Object *self);
-static PyObject *Object_isSelected (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);
-static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args);
-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_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_setSize (BPy_Object *self, PyObject *args);
-static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args);
-static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args);
-static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args);
-static PyObject *Object_Select (BPy_Object *self, PyObject *args);
-static PyObject *Object_getAllProperties (BPy_Object *self);
-static PyObject *Object_addProperty(BPy_Object *self, PyObject *args);
-static PyObject *Object_removeProperty(BPy_Object *self, PyObject *args);
-static PyObject *Object_getProperty(BPy_Object *self, PyObject *args);
-static PyObject *Object_removeAllProperties(BPy_Object *self);
-static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args);
-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);
+static PyObject *Object_buildParts( BPy_Object * self );
+static PyObject *Object_clearIpo( BPy_Object * self );
+static PyObject *Object_clrParent( BPy_Object * self, PyObject * args );
+static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args );
+static PyObject *Object_getData( BPy_Object * self );
+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 );
+static PyObject *Object_getInverseMatrix( BPy_Object * self );
+static PyObject *Object_getIpo( BPy_Object * self );
+static PyObject *Object_getLocation( BPy_Object * self, PyObject * args );
+static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args );
+static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args );
+static PyObject *Object_getName( BPy_Object * self );
+static PyObject *Object_getParent( BPy_Object * self );
+static PyObject *Object_getSize( BPy_Object * self, PyObject * args );
+static PyObject *Object_getTimeOffset( BPy_Object * self );
+static PyObject *Object_getTracked( BPy_Object * self );
+static PyObject *Object_getType( BPy_Object * self );
+static PyObject *Object_getBoundBox( BPy_Object * self );
+static PyObject *Object_getAction( BPy_Object * self );
+static PyObject *Object_isSelected( 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 );
+static PyObject *Object_materialUsage( BPy_Object * self, PyObject * args );
+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_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_setSize( BPy_Object * self, PyObject * args );
+static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args );
+static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args );
+static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args );
+static PyObject *Object_Select( BPy_Object * self, PyObject * args );
+static PyObject *Object_getAllProperties( BPy_Object * self );
+static PyObject *Object_addProperty( BPy_Object * self, PyObject * args );
+static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args );
+static PyObject *Object_getProperty( BPy_Object * self, PyObject * args );
+static PyObject *Object_removeAllProperties( BPy_Object * self );
+static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
+ PyObject * args );
+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 );
/*****************************************************************************/
-/* Python BPy_Object methods table: */
+/* Python BPy_Object methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Object_methods[] = {
/* name, method, flags, doc */
- {"buildParts", (PyCFunction)Object_buildParts, METH_NOARGS,
- "Recalcs particle system (if any) "},
- {"getIpo", (PyCFunction)Object_getIpo, METH_NOARGS,
- "Returns the ipo of this object (if any) "},
- {"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS,
- "Clears parent object. Optionally specify:\n\
+ {"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
+ "Recalcs particle system (if any) "},
+ {"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
+ "Returns the ipo of this object (if any) "},
+ {"clrParent", ( PyCFunction ) Object_clrParent, METH_VARARGS,
+ "Clears parent object. Optionally specify:\n\
mode\n\tnonzero: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"},
- {"clearTrack", (PyCFunction)Object_clearTrack, METH_VARARGS,
- "Make this object not track another anymore. Optionally specify:\n\
+ {"clearTrack", ( PyCFunction ) Object_clearTrack, METH_VARARGS,
+ "Make this object not track another anymore. Optionally specify:\n\
mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \
hierarchy (faster)"},
- {"getData", (PyCFunction)Object_getData, METH_NOARGS,
- "Returns the datablock object containing the object's data, e.g. Mesh"},
- {"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS,
- "Returns the object's delta location (x, y, z)"},
- {"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS,
- "Returns the object draw modes"},
- {"getDrawType", (PyCFunction)Object_getDrawType, METH_NOARGS,
- "Returns the object draw type"},
- {"getAction", (PyCFunction)Object_getAction, METH_NOARGS,
- "Returns the active action for this object"},
- {"isSelected", (PyCFunction)Object_isSelected, METH_NOARGS,
- "Return a 1 or 0 depending on whether the object is selected"},
- {"getEuler", (PyCFunction)Object_getEuler, METH_NOARGS,
- "Returns the object's rotation as Euler rotation vector\n\
+ {"getData", ( PyCFunction ) Object_getData, METH_NOARGS,
+ "Returns the datablock object containing the object's data, e.g. Mesh"},
+ {"getDeltaLocation", ( PyCFunction ) Object_getDeltaLocation,
+ METH_NOARGS,
+ "Returns the object's delta location (x, y, z)"},
+ {"getDrawMode", ( PyCFunction ) Object_getDrawMode, METH_NOARGS,
+ "Returns the object draw modes"},
+ {"getDrawType", ( PyCFunction ) Object_getDrawType, METH_NOARGS,
+ "Returns the object draw type"},
+ {"getAction", ( PyCFunction ) Object_getAction, METH_NOARGS,
+ "Returns the active action for this object"},
+ {"isSelected", ( PyCFunction ) Object_isSelected, METH_NOARGS,
+ "Return a 1 or 0 depending on whether the object is selected"},
+ {"getEuler", ( PyCFunction ) Object_getEuler, METH_NOARGS,
+ "Returns the object's rotation as Euler rotation vector\n\
(rotX, rotY, rotZ)"},
- {"getInverseMatrix", (PyCFunction)Object_getInverseMatrix, METH_NOARGS,
- "Returns the object's inverse matrix"},
- {"getLocation", (PyCFunction)Object_getLocation, METH_VARARGS,
- "Returns the object's location (x, y, z)"},
- {"getMaterials", (PyCFunction)Object_getMaterials, METH_VARARGS,
- "(i = 0) - Returns list of materials assigned to the object.\n\
+ {"getInverseMatrix", ( PyCFunction ) Object_getInverseMatrix,
+ METH_NOARGS,
+ "Returns the object's inverse matrix"},
+ {"getLocation", ( PyCFunction ) Object_getLocation, METH_VARARGS,
+ "Returns the object's location (x, y, z)"},
+ {"getMaterials", ( PyCFunction ) Object_getMaterials, METH_VARARGS,
+ "(i = 0) - Returns list of materials assigned to the object.\n\
if i is nonzero, empty slots are not ignored: they are returned as None's."},
- {"getMatrix", (PyCFunction)Object_getMatrix, METH_VARARGS,
- "(str = 'localspace') - Returns the object matrix.\n\
+ {"getMatrix", ( PyCFunction ) Object_getMatrix, METH_VARARGS,
+ "(str = 'localspace') - Returns the object matrix.\n\
(str = 'localspace') - the wanted matrix: worldspace, localspace (default)\n\
or oldlocal (not updated, it was the only choice before Blender 2.34)."},
- {"getName", (PyCFunction)Object_getName, METH_NOARGS,
- "Returns the name of the object"},
- {"getParent", (PyCFunction)Object_getParent, METH_NOARGS,
- "Returns the object's parent object"},
- {"getSize", (PyCFunction)Object_getSize, METH_VARARGS,
- "Returns the object's size (x, y, z)"},
- {"getTimeOffset", (PyCFunction)Object_getTimeOffset, METH_NOARGS,
- "Returns the object's time offset"},
- {"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS,
- "Returns the object's tracked object"},
- {"getType", (PyCFunction)Object_getType, METH_NOARGS,
- "Returns type of string of Object"},
- {"getBoundBox", (PyCFunction)Object_getBoundBox, METH_NOARGS,
- "Returns the object's bounding box"},
- {"makeDisplayList", (PyCFunction)Object_makeDisplayList, METH_NOARGS,
- "Update this object's Display List. Some changes like turning \n\
+ {"getName", ( PyCFunction ) Object_getName, METH_NOARGS,
+ "Returns the name of the object"},
+ {"getParent", ( PyCFunction ) Object_getParent, METH_NOARGS,
+ "Returns the object's parent object"},
+ {"getSize", ( PyCFunction ) Object_getSize, METH_VARARGS,
+ "Returns the object's size (x, y, z)"},
+ {"getTimeOffset", ( PyCFunction ) Object_getTimeOffset, METH_NOARGS,
+ "Returns the object's time offset"},
+ {"getTracked", ( PyCFunction ) Object_getTracked, METH_NOARGS,
+ "Returns the object's tracked object"},
+ {"getType", ( PyCFunction ) Object_getType, METH_NOARGS,
+ "Returns type of string of Object"},
+ {"getBoundBox", ( PyCFunction ) Object_getBoundBox, METH_NOARGS,
+ "Returns the object's bounding box"},
+ {"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\
+ {"link", ( PyCFunction ) Object_link, METH_VARARGS,
+ "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\
+ {"makeParent", ( PyCFunction ) Object_makeParent, METH_VARARGS,
+ "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."},
- {"materialUsage", (PyCFunction)Object_materialUsage, METH_VARARGS,
- "Determines the way the material is used and returns status.\n\
+ {"materialUsage", ( PyCFunction ) Object_materialUsage, METH_VARARGS,
+ "Determines the way the material is used and returns status.\n\
Possible arguments (provide as strings):\n\
\tData: Materials assigned to the object's data are shown. (default)\n\
\tObject: Materials assigned to the object are shown."},
- {"setDeltaLocation", (PyCFunction)Object_setDeltaLocation, METH_VARARGS,
- "Sets the object's delta location which must be a vector triple."},
- {"setDrawMode", (PyCFunction)Object_setDrawMode, METH_VARARGS,
- "Sets the object's drawing mode. The argument can be a sum of:\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,
+ "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,
- "Sets the object's drawing type. The argument must be one of:\n\
+ {"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,
- "Set the object's rotation according to the specified Euler\n\
+ {"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,
- "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\
+ {"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\
triple."},
- {"setMaterials", (PyCFunction)Object_setMaterials, METH_VARARGS,
- "Sets materials. The argument must be a list of valid material\n\
+ {"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,
- "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\
+ {"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\
triple."},
- {"setTimeOffset", (PyCFunction)Object_setTimeOffset, METH_VARARGS,
- "Set the object's time offset."},
- {"makeTrack", (PyCFunction)Object_makeTrack, METH_VARARGS,
- "(trackedobj, fast = 0) - Make this object track another.\n\
+ {"setTimeOffset", ( PyCFunction ) Object_setTimeOffset, METH_VARARGS,
+ "Set the object's time offset."},
+ {"makeTrack", ( PyCFunction ) Object_makeTrack, METH_VARARGS,
+ "(trackedobj, fast = 0) - Make this object track another.\n\
(trackedobj) - the object that will be tracked.\n\
(fast = 0) - if 0: update the scene hierarchy automatically. If you\n\
set 'fast' to a nonzero value, don't forget to update the scene yourself\n\
(see scene.update())."},
- {"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS,
- "Link data of self with object specified in the argument. This\n\
+ {"shareFrom", ( PyCFunction ) Object_shareFrom, METH_VARARGS,
+ "Link data of self with object specified in the argument. This\n\
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\
+ {"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,
- "(Blender Ipo) - Sets the object's ipo"},
- {"clearIpo", (PyCFunction)Object_clearIpo, METH_NOARGS,
- "() - Unlink ipo from this object"},
- {"getAllProperties", (PyCFunction)Object_getAllProperties, METH_NOARGS,
- "() - Get all the properties from this object"},
- {"addProperty", (PyCFunction)Object_addProperty, METH_VARARGS,
- "() - Add a property to this object"},
- {"removeProperty", (PyCFunction)Object_removeProperty, METH_VARARGS,
- "() - Remove a property from this object"},
- {"getProperty", (PyCFunction)Object_getProperty, METH_VARARGS,
- "() - Get a property from this object by name"},
- {"removeAllProperties", (PyCFunction)Object_removeAllProperties, METH_NOARGS,
- "() - removeAll a properties from this object"},
- {"copyAllPropertiesTo", (PyCFunction)Object_copyAllPropertiesTo, METH_VARARGS,
- "() - copy all properties from this object to another object"},
- {"getScriptLinks", (PyCFunction)Object_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this object's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", (PyCFunction)Object_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new object scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", (PyCFunction)Object_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this object."},
- {NULL, NULL, 0, NULL}
+ {"setIpo", ( PyCFunction ) Object_setIpo, METH_VARARGS,
+ "(Blender Ipo) - Sets the object's ipo"},
+ {"clearIpo", ( PyCFunction ) Object_clearIpo, METH_NOARGS,
+ "() - Unlink ipo from this object"},
+ {"getAllProperties", ( PyCFunction ) Object_getAllProperties,
+ METH_NOARGS,
+ "() - Get all the properties from this object"},
+ {"addProperty", ( PyCFunction ) Object_addProperty, METH_VARARGS,
+ "() - Add a property to this object"},
+ {"removeProperty", ( PyCFunction ) Object_removeProperty, METH_VARARGS,
+ "() - Remove a property from this object"},
+ {"getProperty", ( PyCFunction ) Object_getProperty, METH_VARARGS,
+ "() - Get a property from this object by name"},
+ {"removeAllProperties", ( PyCFunction ) Object_removeAllProperties,
+ METH_NOARGS,
+ "() - removeAll a properties from this object"},
+ {"copyAllPropertiesTo", ( PyCFunction ) Object_copyAllPropertiesTo,
+ METH_VARARGS,
+ "() - copy all properties from this object to another object"},
+ {"getScriptLinks", ( PyCFunction ) Object_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this object's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) Object_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new object scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) Object_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this object."},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* PythonTypeObject callback function prototypes */
+/* 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);
+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. */
+/* Python TypeObject structure definition. */
/*****************************************************************************/
-PyTypeObject Object_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 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 */
+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 */
};
/*****************************************************************************/
-/* Function: M_Object_New */
-/* Python equivalent: Blender.Object.New */
+/* Function: M_Object_New */
+/* Python equivalent: Blender.Object.New */
/*****************************************************************************/
-PyObject *M_Object_New(PyObject *self, PyObject *args)
-{
- struct Object * object;
- BPy_Object * blen_object;
- int type;
- char * str_type;
- char * name = NULL;
-
- if (!PyArg_ParseTuple(args, "s|s", &str_type, &name))
- {
- EXPP_ReturnPyObjError (PyExc_TypeError, "string expected as argument");
- return (NULL);
- }
-
- if (strcmp (str_type, "Armature") == 0) type = OB_ARMATURE;
- else if (strcmp (str_type, "Camera") == 0) type = OB_CAMERA;
- else if (strcmp (str_type, "Curve") == 0) type = OB_CURVE;
+PyObject *M_Object_New( PyObject * self, PyObject * args )
+{
+ struct Object *object;
+ BPy_Object *blen_object;
+ int type;
+ char *str_type;
+ char *name = NULL;
+
+ if( !PyArg_ParseTuple( args, "s|s", &str_type, &name ) ) {
+ EXPP_ReturnPyObjError( PyExc_TypeError,
+ "string expected as argument" );
+ return ( NULL );
+ }
+
+ if( strcmp( str_type, "Armature" ) == 0 )
+ type = OB_ARMATURE;
+ else if( strcmp( str_type, "Camera" ) == 0 )
+ type = OB_CAMERA;
+ else if( strcmp( str_type, "Curve" ) == 0 )
+ type = OB_CURVE;
/* else if (strcmp (str_type, "Text") == 0) type = OB_FONT; */
/* else if (strcmp (str_type, "Ika") == 0) type = OB_IKA; */
- else if (strcmp (str_type, "Lamp") == 0) type = OB_LAMP;
- else if (strcmp (str_type, "Lattice") == 0) type = OB_LATTICE;
- else if (strcmp (str_type, "Mball") == 0) type = OB_MBALL;
- else if (strcmp (str_type, "Mesh") == 0) type = OB_MESH;
- else if (strcmp (str_type, "Surf") == 0) type = OB_SURF;
+ else if( strcmp( str_type, "Lamp" ) == 0 )
+ type = OB_LAMP;
+ else if( strcmp( str_type, "Lattice" ) == 0 )
+ type = OB_LATTICE;
+ else if( strcmp( str_type, "Mball" ) == 0 )
+ type = OB_MBALL;
+ else if( strcmp( str_type, "Mesh" ) == 0 )
+ type = OB_MESH;
+ else if( strcmp( str_type, "Surf" ) == 0 )
+ type = OB_SURF;
/* 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"));
- }
-
- /* Create a new object. */
- if (name == NULL)
- {
- /* No name is specified, set the name to the type of the object. */
+ else if( strcmp( str_type, "Empty" ) == 0 )
+ type = OB_EMPTY;
+ else {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unknown type specified" ) );
+ }
+
+ /* Create a new object. */
+ if( name == NULL ) {
+ /* No name is specified, set the name to the type of the object. */
name = str_type;
- }
- object = alloc_libblock (&(G.main->object), ID_OB, name);
+ }
+ object = alloc_libblock( &( G.main->object ), ID_OB, name );
- object->id.us = 0;
- object->flag = 0;
- object->type = type;
-
+ object->id.us = 0;
+ object->flag = 0;
+ object->type = type;
- /* transforms */
- QuatOne(object->quat);
- QuatOne(object->dquat);
- object->col[3]= 1.0; // alpha
+ /* transforms */
+ QuatOne( object->quat );
+ QuatOne( object->dquat );
- object->size[0] = object->size[1] = object->size[2] = 1.0;
- object->loc[0] = object->loc[1] = object->loc[2] = 0.0;
- Mat4One(object->parentinv);
- Mat4One(object->obmat);
- object->dt = OB_SHADED; // drawtype
+ object->col[3] = 1.0; // alpha
- if (U.flag & USER_MAT_ON_OB)
- {
+ object->size[0] = object->size[1] = object->size[2] = 1.0;
+ object->loc[0] = object->loc[1] = object->loc[2] = 0.0;
+ Mat4One( object->parentinv );
+ Mat4One( object->obmat );
+ object->dt = OB_SHADED; // drawtype
+
+ if( U.flag & USER_MAT_ON_OB ) {
object->colbits = -1;
- }
- switch (object->type)
- {
- case OB_CAMERA: /* fall through. */
- case OB_LAMP:
- object->trackflag = OB_NEGZ;
- object->upflag = OB_POSY;
- break;
- default:
- object->trackflag = OB_POSY;
- object->upflag = OB_POSZ;
- }
- object->ipoflag = OB_OFFS_OB + OB_OFFS_PARENT;
+ }
+ switch ( object->type ) {
+ case OB_CAMERA: /* fall through. */
+ case OB_LAMP:
+ object->trackflag = OB_NEGZ;
+ object->upflag = OB_POSY;
+ break;
+ default:
+ object->trackflag = OB_POSY;
+ object->upflag = OB_POSZ;
+ }
+ object->ipoflag = OB_OFFS_OB + OB_OFFS_PARENT;
- /* duplivert settings */
- object->dupon = 1;
- object->dupoff = 0;
- object->dupsta = 1;
- object->dupend = 100;
+ /* duplivert settings */
+ object->dupon = 1;
+ object->dupoff = 0;
+ object->dupsta = 1;
+ object->dupend = 100;
- /* Gameengine defaults*/
- object->mass = 1.0;
- object->inertia = 1.0;
- object->formfactor = 0.4;
- object->damping = 0.04;
- object->rdamping = 0.1;
- object->anisotropicFriction[0] = 1.0;
- object->anisotropicFriction[1] = 1.0;
- object->anisotropicFriction[2] = 1.0;
- object->gameflag = OB_PROP;
+ /* Gameengine defaults */
+ object->mass = 1.0;
+ object->inertia = 1.0;
+ object->formfactor = 0.4;
+ object->damping = 0.04;
+ object->rdamping = 0.1;
+ object->anisotropicFriction[0] = 1.0;
+ object->anisotropicFriction[1] = 1.0;
+ object->anisotropicFriction[2] = 1.0;
+ object->gameflag = OB_PROP;
- object->lay = 1; // Layer, by default visible
- G.totobj++;
+ object->lay = 1; // Layer, by default visible
+ G.totobj++;
- object->data = NULL;
+ object->data = NULL;
- /* Create a Python object from it. */
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
- blen_object->object = object;
+ /* Create a Python object from it. */
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object, &Object_Type );
+ blen_object->object = object;
- return ((PyObject*)blen_object);
+ return ( ( PyObject * ) blen_object );
}
/*****************************************************************************/
-/* Function: M_Object_Get */
-/* Python equivalent: Blender.Object.Get */
+/* Function: M_Object_Get */
+/* Python equivalent: Blender.Object.Get */
/*****************************************************************************/
-PyObject *M_Object_Get(PyObject *self, PyObject *args)
+PyObject *M_Object_Get( PyObject * self, PyObject * args )
{
- struct Object * object;
- BPy_Object * blen_object;
- char * name = NULL;
+ struct Object *object;
+ BPy_Object *blen_object;
+ char *name = NULL;
- PyArg_ParseTuple(args, "|s", &name);
+ PyArg_ParseTuple( args, "|s", &name );
- if (name != NULL)
- {
- object = GetObjectByName (name);
+ if( name != NULL ) {
+ object = GetObjectByName( name );
- if (object == NULL)
- {
+ if( object == NULL ) {
/* No object exists with the name specified in the argument name. */
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Unknown object specified."));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unknown object specified." ) );
}
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object,
+ &Object_Type );
blen_object->object = object;
- return ((PyObject*)blen_object);
- }
- else
- {
+ return ( ( PyObject * ) blen_object );
+ } else {
/* No argument has been given. Return a list of all objects. */
- PyObject * obj_list;
- Link * link;
- int index;
+ PyObject *obj_list;
+ Link *link;
+ int index;
- obj_list = PyList_New (BLI_countlist (&(G.main->object)));
+ obj_list = PyList_New( BLI_countlist( &( G.main->object ) ) );
- if (obj_list == NULL)
- {
- return (EXPP_ReturnPyObjError (PyExc_SystemError,
- "List creation failed."));
+ if( obj_list == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_SystemError,
+ "List creation failed." ) );
}
link = G.main->object.first;
index = 0;
- while (link)
- {
- object = (Object*)link;
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
+ while( link ) {
+ object = ( Object * ) link;
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object,
+ &Object_Type );
blen_object->object = object;
- PyList_SetItem (obj_list, index, (PyObject*)blen_object);
+ PyList_SetItem( obj_list, index,
+ ( PyObject * ) blen_object );
index++;
link = link->next;
}
- return (obj_list);
+ return ( obj_list );
}
}
/*****************************************************************************/
-/* Function: M_Object_get */
-/* Python equivalent: Blender.Object.get */
+/* Function: M_Object_get */
+/* Python equivalent: Blender.Object.get */
/*****************************************************************************/
-PyObject *M_Object_get(PyObject *self, PyObject *args)
+PyObject *M_Object_get( PyObject * self, PyObject * args )
{
- PyErr_Warn (PyExc_DeprecationWarning,
- "The Object.get() function will be removed in Blender 2.29\n" \
- "Please update the script to use Object.Get");
- return (M_Object_Get (self, args));
+ PyErr_Warn( PyExc_DeprecationWarning,
+ "The Object.get() function will be removed in Blender 2.29\n"
+ "Please update the script to use Object.Get" );
+ return ( M_Object_Get( self, args ) );
}
/*****************************************************************************/
-/* Function: M_Object_GetSelected */
-/* Python equivalent: Blender.Object.getSelected */
+/* Function: M_Object_GetSelected */
+/* Python equivalent: Blender.Object.getSelected */
/*****************************************************************************/
-static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
-{
- BPy_Object * blen_object;
- PyObject * list;
- Base * base_iter;
-
- if (G.vd == NULL)
- {
- // No 3d view has been initialized yet, simply return None
- Py_INCREF (Py_None);
- return Py_None;
- }
- list = PyList_New (0);
- if ((G.scene->basact) &&
- ((G.scene->basact->flag & SELECT) &&
- (G.scene->basact->lay & G.vd->lay)))
- {
+static PyObject *M_Object_GetSelected( PyObject * self, PyObject * args )
+{
+ BPy_Object *blen_object;
+ PyObject *list;
+ Base *base_iter;
+
+ if( G.vd == NULL ) {
+ // No 3d view has been initialized yet, simply return None
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ list = PyList_New( 0 );
+ if( ( G.scene->basact ) &&
+ ( ( G.scene->basact->flag & SELECT ) &&
+ ( G.scene->basact->lay & G.vd->lay ) ) ) {
/* Active object is first in the list. */
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
- if (blen_object == NULL)
- {
- Py_DECREF (list);
- Py_INCREF (Py_None);
- return (Py_None);
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object,
+ &Object_Type );
+ if( blen_object == NULL ) {
+ Py_DECREF( list );
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
blen_object->object = G.scene->basact->object;
- PyList_Append (list, (PyObject*)blen_object);
+ PyList_Append( list, ( PyObject * ) blen_object );
}
base_iter = G.scene->base.first;
- while (base_iter)
- {
- if (((base_iter->flag & SELECT) &&
- (base_iter->lay & G.vd->lay)) &&
- (base_iter != G.scene->basact))
- {
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
- if (blen_object == NULL)
- {
- Py_DECREF (list);
- Py_INCREF (Py_None);
- return (Py_None);
+ while( base_iter ) {
+ if( ( ( base_iter->flag & SELECT ) &&
+ ( base_iter->lay & G.vd->lay ) ) &&
+ ( base_iter != G.scene->basact ) ) {
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object,
+ &Object_Type );
+ if( blen_object == NULL ) {
+ Py_DECREF( list );
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
blen_object->object = base_iter->object;
- PyList_Append (list, (PyObject*)blen_object);
+ PyList_Append( list, ( PyObject * ) blen_object );
}
base_iter = base_iter->next;
}
- return (list);
+ return ( list );
}
/*****************************************************************************/
-/* Function: M_Object_getSelected */
-/* Python equivalent: Blender.Object.getSelected */
+/* Function: M_Object_getSelected */
+/* Python equivalent: Blender.Object.getSelected */
/*****************************************************************************/
-static PyObject *M_Object_getSelected (PyObject *self, PyObject *args)
+static PyObject *M_Object_getSelected( PyObject * self, PyObject * args )
{
- PyErr_Warn (PyExc_DeprecationWarning,
- "The Object.getSelected() function will be removed in "\
- "Blender 2.29\n" \
- "Please update the script to use Object.GetSelected");
- return (M_Object_GetSelected (self, args));
+ PyErr_Warn( PyExc_DeprecationWarning,
+ "The Object.getSelected() function will be removed in "
+ "Blender 2.29\n"
+ "Please update the script to use Object.GetSelected" );
+ return ( M_Object_GetSelected( self, args ) );
}
/*****************************************************************************/
-/* Function: initObject */
+/* Function: initObject */
/*****************************************************************************/
-PyObject *Object_Init (void)
+PyObject *Object_Init( void )
{
- PyObject * module;
+ PyObject *module;
Object_Type.ob_type = &PyType_Type;
- module = Py_InitModule3("Blender.Object", M_Object_methods, M_Object_doc);
+ module = Py_InitModule3( "Blender.Object", M_Object_methods,
+ M_Object_doc );
- return (module);
+ return ( module );
}
/*****************************************************************************/
-/* Python BPy_Object methods: */
+/* Python BPy_Object methods: */
/*****************************************************************************/
-static PyObject *Object_buildParts (BPy_Object *self)
+static PyObject *Object_buildParts( BPy_Object * self )
{
- void build_particle_system(Object *ob);
- struct Object *obj = self->object;
+ void build_particle_system( Object * ob );
+ struct Object *obj = self->object;
- build_particle_system(obj);
+ build_particle_system( obj );
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_clearIpo(BPy_Object *self)
+static PyObject *Object_clearIpo( BPy_Object * self )
{
Object *ob = self->object;
- Ipo *ipo = (Ipo *)ob->ipo;
+ Ipo *ipo = ( Ipo * ) ob->ipo;
- if (ipo) {
+ if( ipo ) {
ID *id = &ipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
ob->ipo = NULL;
- Py_INCREF (Py_True);
+ Py_INCREF( Py_True );
return Py_True;
}
- Py_INCREF (Py_False); /* no ipo found */
+ Py_INCREF( Py_False ); /* no ipo found */
return Py_False;
}
-static PyObject *Object_clrParent (BPy_Object *self, PyObject *args)
+static PyObject *Object_clrParent( BPy_Object * self, PyObject * args )
{
- int mode=0;
- int fast=0;
+ 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_AttributeError,
+ "expected one or two integers as arguments" ) );
+ }
- /* Remove the link only, the object is still in the scene. */
- self->object->parent = NULL;
+ /* Remove the link only, the object is still in the scene. */
+ self->object->parent = NULL;
- if (mode == 2)
- {
+ if( mode == 2 ) {
/* Keep transform */
- apply_obmat (self->object);
- }
+ apply_obmat( self->object );
+ }
- if (!fast)
- {
- sort_baselist (G.scene);
- }
+ if( !fast ) {
+ sort_baselist( G.scene );
+ }
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args)
+static PyObject *Object_clearTrack( BPy_Object * self, PyObject * args )
{
- int mode=0;
- int fast=0;
+ 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_AttributeError,
+ "expected one or two integers as arguments" ) );
+ }
- /* Remove the link only, the object is still in the scene. */
- self->object->track = NULL;
+ /* Remove the link only, the object is still in the scene. */
+ self->object->track = NULL;
- if (mode)
- {
+ if( mode ) {
/* Keep transform */
- apply_obmat (self->object);
- }
+ apply_obmat( self->object );
+ }
- if (!fast)
- {
- sort_baselist (G.scene);
- }
+ if( !fast ) {
+ sort_baselist( G.scene );
+ }
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
/* adds object data to a Blender object, if object->data = NULL */
-int EXPP_add_obdata(struct Object *object)
+int EXPP_add_obdata( struct Object *object )
{
- if (object->data != NULL) return -1;
+ if( object->data != NULL )
+ return -1;
- switch(object->type)
- {
+ switch ( object->type ) {
case OB_ARMATURE:
- /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
- object->data = add_armature();
- break;
+ /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
+ object->data = add_armature( );
+ break;
case OB_CAMERA:
- /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
- object->data = add_camera();
- break;
+ /* TODO: Do we need to add something to G? (see the OB_LAMP case) */
+ object->data = add_camera( );
+ break;
case OB_CURVE:
- object->data = add_curve(OB_CURVE);
- G.totcurve++;
- break;
+ object->data = add_curve( OB_CURVE );
+ G.totcurve++;
+ break;
case OB_LAMP:
- object->data = add_lamp();
- G.totlamp++;
- break;
+ object->data = add_lamp( );
+ G.totlamp++;
+ break;
case OB_MESH:
- object->data = add_mesh();
- G.totmesh++;
- break;
+ object->data = add_mesh( );
+ G.totmesh++;
+ break;
case OB_LATTICE:
- object->data = (void *)add_lattice();
- object->dt = OB_WIRE;
- break;
+ object->data = ( void * ) add_lattice( );
+ object->dt = OB_WIRE;
+ break;
case OB_MBALL:
- object->data = add_mball();
- break;
+ object->data = add_mball( );
+ break;
- /* TODO the following types will be supported later
- case OB_SURF:
- object->data = add_curve(OB_SURF);
- G.totcurve++;
- break;
- case OB_FONT:
- object->data = add_curve(OB_FONT);
- break;
- case OB_IKA:
- object->data = add_ika();
- object->dt = OB_WIRE;
- break;
- case OB_WAVE:
- object->data = add_wave();
- break;
- */
+ /* TODO the following types will be supported later
+ case OB_SURF:
+ object->data = add_curve(OB_SURF);
+ G.totcurve++;
+ break;
+ case OB_FONT:
+ object->data = add_curve(OB_FONT);
+ break;
+ case OB_IKA:
+ object->data = add_ika();
+ object->dt = OB_WIRE;
+ break;
+ case OB_WAVE:
+ object->data = add_wave();
+ break;
+ */
default:
- break;
- }
+ break;
+ }
- if (!object->data) return -1;
+ if( !object->data )
+ return -1;
- return 0;
+ return 0;
}
-static PyObject *Object_getData (BPy_Object *self)
+static PyObject *Object_getData( BPy_Object * self )
{
- PyObject * data_object;
- Object * object = self->object;
+ PyObject *data_object;
+ Object *object = self->object;
/* 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);
- }
+ if( object->data == NULL ) {
+ if( EXPP_add_obdata( object ) != 0 ) { /* couldn't create obdata */
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ }
}
data_object = NULL;
- switch (object->type)
- {
- case OB_ARMATURE:
- data_object = Armature_CreatePyObject (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:
- data_object = NMesh_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 ID_WO:
- break;
- default:
- break;
- }
- if (data_object == NULL)
- {
- Py_INCREF (Py_None);
- return (Py_None);
+ switch ( object->type ) {
+ case OB_ARMATURE:
+ data_object = Armature_CreatePyObject( 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:
+ data_object = NMesh_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 ID_WO:
+ break;
+ default:
+ break;
}
- else
- {
- return (data_object);
+ if( data_object == NULL ) {
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ } else {
+ return ( data_object );
}
}
-static PyObject *Object_getDeltaLocation (BPy_Object *self)
+static PyObject *Object_getDeltaLocation( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue ("fff",
- self->object->dloc[0],
- self->object->dloc[1],
- self->object->dloc[2]);
+ PyObject *attr = Py_BuildValue( "fff",
+ self->object->dloc[0],
+ self->object->dloc[1],
+ self->object->dloc[2] );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.dloc attributes"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.dloc attributes" ) );
}
-static PyObject *Object_getDrawMode (BPy_Object *self)
+static PyObject *Object_getDrawMode( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue ("b", self->object->dtx);
+ PyObject *attr = Py_BuildValue( "b", self->object->dtx );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.drawMode attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.drawMode attribute" ) );
}
-static PyObject *Object_getAction (BPy_Object *self)
+static PyObject *Object_getAction( BPy_Object * self )
{
- /*BPy_Action *py_action = NULL;*/
+ /*BPy_Action *py_action = NULL; */
- if(!self->object->action){
- Py_INCREF (Py_None);
- return (Py_None);
- }else{
- return Action_CreatePyObject (self->object->action);
+ if( !self->object->action ) {
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ } else {
+ return Action_CreatePyObject( self->object->action );
}
}
-static PyObject *Object_isSelected (BPy_Object *self)
+static PyObject *Object_isSelected( BPy_Object * self )
{
Base *base;
-
- base= FIRSTBASE;
- while (base) {
- if (base->object == self->object) {
- if (base->flag & SELECT) {
- Py_INCREF (Py_True);
+
+ base = FIRSTBASE;
+ while( base ) {
+ if( base->object == self->object ) {
+ if( base->flag & SELECT ) {
+ Py_INCREF( Py_True );
return Py_True;
} else {
- Py_INCREF (Py_False);
+ Py_INCREF( Py_False );
return Py_False;
}
}
- base= base->next;
+ base = base->next;
}
- return ( EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Internal error: could not find objects selection state"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Internal error: could not find objects selection state" ) );
}
-static PyObject *Object_getDrawType (BPy_Object *self)
+static PyObject *Object_getDrawType( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue ("b", self->object->dt);
+ PyObject *attr = Py_BuildValue( "b", self->object->dt );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.drawType attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.drawType attribute" ) );
}
-static PyObject *Object_getEuler (BPy_Object *self)
-{
+static PyObject *Object_getEuler( BPy_Object * self )
+{
EulerObject *eul;
- eul = (EulerObject*)newEulerObject(NULL);
+ eul = ( EulerObject * ) newEulerObject( NULL );
eul->eul[0] = self->object->rot[0];
eul->eul[1] = self->object->rot[1];
eul->eul[2] = self->object->rot[2];
- return (PyObject*)eul;
+ return ( PyObject * ) eul;
}
-static PyObject *Object_getInverseMatrix (BPy_Object *self)
+static PyObject *Object_getInverseMatrix( BPy_Object * self )
{
- MatrixObject *inverse = (MatrixObject *)newMatrixObject(NULL, 4, 4);
- Mat4Invert (*inverse->matrix, self->object->obmat);
+ MatrixObject *inverse =
+ ( MatrixObject * ) newMatrixObject( NULL, 4, 4 );
+ Mat4Invert( *inverse->matrix, self->object->obmat );
- return ((PyObject *)inverse);
+ return ( ( PyObject * ) inverse );
}
-static PyObject *Object_getIpo(BPy_Object *self)
+static PyObject *Object_getIpo( BPy_Object * self )
{
- struct Ipo *ipo = self->object->ipo;
+ struct Ipo *ipo = self->object->ipo;
- if (!ipo)
- {
- Py_INCREF (Py_None);
+ if( !ipo ) {
+ Py_INCREF( Py_None );
return Py_None;
- }
+ }
- return Ipo_CreatePyObject (ipo);
+ return Ipo_CreatePyObject( ipo );
}
-static PyObject *Object_getLocation (BPy_Object *self, PyObject *args)
+static PyObject *Object_getLocation( BPy_Object * self, PyObject * args )
{
- PyObject *attr = Py_BuildValue ("fff",
- self->object->loc[0],
- self->object->loc[1],
- self->object->loc[2]);
+ PyObject *attr = Py_BuildValue( "fff",
+ self->object->loc[0],
+ self->object->loc[1],
+ self->object->loc[2] );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.loc attributes"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.loc attributes" ) );
}
-static PyObject *Object_getMaterials (BPy_Object *self, PyObject *args)
+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"));
+ 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));
+ return ( EXPP_PyList_fromMaterialList( self->object->mat,
+ self->object->totcol, all ) );
}
-static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args)
+static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args )
{
- PyObject *matrix;
- char *space = "localspace"; /* default to local */
+ PyObject *matrix;
+ 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_AttributeError,
+ "expected a string or nothing" ) );
}
//new matrix
- matrix = newMatrixObject(NULL, 4, 4);
-
- if (BLI_streq(space, "worldspace")){ /* Worldspace matrix */
- disable_where_script(1);
- where_is_object(self->object);
- disable_where_script(0);
- Mat4CpyMat4(*((MatrixObject*)matrix)->matrix, self->object->obmat);
- } else if (BLI_streq(space, "localspace")) { /* Localspace matrix*/
- object_to_mat4(self->object, *((MatrixObject*)matrix)->matrix);
- } else if (BLI_streq(space, "oldlocal")) { /* old behavior, prior to 2.34 */
- Mat4CpyMat4(*((MatrixObject *)matrix)->matrix, self->object->obmat);
+ matrix = newMatrixObject( NULL, 4, 4 );
+
+ if( BLI_streq( space, "worldspace" ) ) { /* Worldspace matrix */
+ disable_where_script( 1 );
+ where_is_object( self->object );
+ disable_where_script( 0 );
+ Mat4CpyMat4( *( ( MatrixObject * ) matrix )->matrix,
+ self->object->obmat );
+ } else if( BLI_streq( space, "localspace" ) ) { /* Localspace matrix */
+ object_to_mat4( self->object,
+ *( ( MatrixObject * ) matrix )->matrix );
+ } else if( BLI_streq( space, "oldlocal" ) ) { /* old behavior, prior to 2.34 */
+ Mat4CpyMat4( *( ( MatrixObject * ) matrix )->matrix,
+ self->object->obmat );
} else {
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "wrong parameter, expected nothing or either 'localspace' (default),\n\
-'worldspace' or 'oldlocal'"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "wrong parameter, expected nothing or either 'localspace' (default),\n\
+'worldspace' or 'oldlocal'" ) );
}
return matrix;
}
-static PyObject *Object_getName (BPy_Object *self)
+static PyObject *Object_getName( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue ("s", self->object->id.name+2);
+ PyObject *attr = Py_BuildValue( "s", self->object->id.name + 2 );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get the name of the Object"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get the name of the Object" ) );
}
-static PyObject *Object_getParent (BPy_Object *self)
+static PyObject *Object_getParent( BPy_Object * self )
{
PyObject *attr;
- if (self->object->parent == NULL)
- return EXPP_incr_ret (Py_None);
+ if( self->object->parent == NULL )
+ return EXPP_incr_ret( Py_None );
- attr = Object_CreatePyObject (self->object->parent);
+ attr = Object_CreatePyObject( self->object->parent );
- if (attr)
- {
- return (attr);
+ if( attr ) {
+ return ( attr );
}
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.parent attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.parent attribute" ) );
}
-static PyObject *Object_getSize (BPy_Object *self, PyObject *args)
+static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
{
- PyObject *attr = Py_BuildValue ("fff",
- self->object->size[0],
- self->object->size[1],
- self->object->size[2]);
+ PyObject *attr = Py_BuildValue( "fff",
+ self->object->size[0],
+ self->object->size[1],
+ self->object->size[2] );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.size attributes"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.size attributes" ) );
}
-static PyObject *Object_getTimeOffset (BPy_Object *self)
+static PyObject *Object_getTimeOffset( BPy_Object * self )
{
- PyObject *attr = Py_BuildValue ("f", self->object->sf);
+ PyObject *attr = Py_BuildValue( "f", self->object->sf );
- if (attr) return (attr);
+ if( attr )
+ return ( attr );
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.sf attributes"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.sf attributes" ) );
}
-static PyObject *Object_getTracked (BPy_Object *self)
+static PyObject *Object_getTracked( BPy_Object * self )
{
- PyObject *attr;
+ PyObject *attr;
- if (self->object->track == NULL)
- return EXPP_incr_ret (Py_None);
-
- attr = Object_CreatePyObject (self->object->track);
+ if( self->object->track == NULL )
+ return EXPP_incr_ret( Py_None );
- if (attr)
- {
- return (attr);
+ attr = Object_CreatePyObject( self->object->track );
+
+ if( attr ) {
+ return ( attr );
}
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Object.track attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Object.track attribute" ) );
}
-static PyObject *Object_getType (BPy_Object *self)
+static PyObject *Object_getType( BPy_Object * self )
{
- switch (self->object->type)
- {
- case OB_ARMATURE: return (Py_BuildValue ("s", "Armature"));
- case OB_CAMERA: return (Py_BuildValue ("s", "Camera"));
- case OB_CURVE: return (Py_BuildValue ("s", "Curve"));
- case OB_EMPTY: return (Py_BuildValue ("s", "Empty"));
- case OB_FONT: return (Py_BuildValue ("s", "Text"));
- case OB_IKA: return (Py_BuildValue ("s", "Ika"));
- case OB_LAMP: return (Py_BuildValue ("s", "Lamp"));
- case OB_LATTICE: return (Py_BuildValue ("s", "Lattice"));
- case OB_MBALL: return (Py_BuildValue ("s", "MBall"));
- case OB_MESH: return (Py_BuildValue ("s", "Mesh"));
- case OB_SURF: return (Py_BuildValue ("s", "Surf"));
- case OB_WAVE: return (Py_BuildValue ("s", "Wave"));
- default: return (Py_BuildValue ("s", "unknown"));
+ switch ( self->object->type ) {
+ case OB_ARMATURE:
+ return ( Py_BuildValue( "s", "Armature" ) );
+ case OB_CAMERA:
+ return ( Py_BuildValue( "s", "Camera" ) );
+ case OB_CURVE:
+ return ( Py_BuildValue( "s", "Curve" ) );
+ case OB_EMPTY:
+ return ( Py_BuildValue( "s", "Empty" ) );
+ case OB_FONT:
+ return ( Py_BuildValue( "s", "Text" ) );
+ case OB_IKA:
+ return ( Py_BuildValue( "s", "Ika" ) );
+ case OB_LAMP:
+ return ( Py_BuildValue( "s", "Lamp" ) );
+ case OB_LATTICE:
+ return ( Py_BuildValue( "s", "Lattice" ) );
+ case OB_MBALL:
+ return ( Py_BuildValue( "s", "MBall" ) );
+ case OB_MESH:
+ return ( Py_BuildValue( "s", "Mesh" ) );
+ case OB_SURF:
+ return ( Py_BuildValue( "s", "Surf" ) );
+ case OB_WAVE:
+ return ( Py_BuildValue( "s", "Wave" ) );
+ default:
+ return ( Py_BuildValue( "s", "unknown" ) );
}
}
-static PyObject *Object_getBoundBox (BPy_Object *self)
+static PyObject *Object_getBoundBox( BPy_Object * self )
{
- int i;
- float *vec = NULL;
- PyObject *vector, *bbox;
+ int i;
+ float *vec = NULL;
+ PyObject *vector, *bbox;
- if (!self->object->data)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "This object isn't linked to any object data (mesh, curve, etc) yet");
+ if( !self->object->data )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "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;
- Curve *curve;
- switch (self->object->type) {
- case OB_MESH:
- me = self->object->data;
- if (!me->bb) tex_space_mesh(me);
- vec = (float *)me->bb->vec;
- break;
- case OB_CURVE:
- case OB_FONT:
- case OB_SURF:
- curve = self->object->data;
- if (!curve->bb) tex_space_curve(curve);
- vec = (float *)curve->bb->vec;
- break;
- default:
- Py_INCREF (Py_None);
- return Py_None;
- }
+ if( !self->object->bb ) { /* if no ob bbox, we look in obdata */
+ Mesh *me;
+ Curve *curve;
+ switch ( self->object->type ) {
+ case OB_MESH:
+ me = self->object->data;
+ if( !me->bb )
+ tex_space_mesh( me );
+ vec = ( float * ) me->bb->vec;
+ break;
+ case OB_CURVE:
+ case OB_FONT:
+ case OB_SURF:
+ curve = self->object->data;
+ if( !curve->bb )
+ tex_space_curve( curve );
+ vec = ( float * ) curve->bb->vec;
+ break;
+ default:
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
- { /* transform our obdata bbox by the obmat.
- the obmat is 4x4 homogeneous coords matrix.
- each bbox coord is xyz, so we make it homogenous
- by padding it with w=1.0 and doing the matrix mult.
- afterwards we divide by w to get back to xyz.
- */
- /* printmatrix4( "obmat", self->object->obmat); */
-
- float tmpvec[4]; /* tmp vector for homogenous coords math */
- int i;
- float *from;
-
- bbox = PyList_New(8);
- if (!bbox)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create pylist");
- for( i = 0, from = vec;
- i < 8;
- i++, from += 3 ) {
- memcpy( tmpvec, from, 3*sizeof(float));
- tmpvec[3]=1.0f; /* set w coord */
- Mat4MulVec4fl( self->object->obmat, tmpvec );
- /* divide x,y,z by w */
- tmpvec[0] /= tmpvec[3];
- tmpvec[1] /= tmpvec[3];
- tmpvec[2] /= tmpvec[3];
+ { /* transform our obdata bbox by the obmat.
+ the obmat is 4x4 homogeneous coords matrix.
+ each bbox coord is xyz, so we make it homogenous
+ by padding it with w=1.0 and doing the matrix mult.
+ afterwards we divide by w to get back to xyz.
+ */
+ /* printmatrix4( "obmat", self->object->obmat); */
+
+ float tmpvec[4]; /* tmp vector for homogenous coords math */
+ int i;
+ float *from;
+
+ bbox = PyList_New( 8 );
+ if( !bbox )
+ return EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create pylist" );
+ for( i = 0, from = vec; i < 8; i++, from += 3 ) {
+ memcpy( tmpvec, from, 3 * sizeof( float ) );
+ tmpvec[3] = 1.0f; /* set w coord */
+ Mat4MulVec4fl( self->object->obmat, tmpvec );
+ /* divide x,y,z by w */
+ tmpvec[0] /= tmpvec[3];
+ tmpvec[1] /= tmpvec[3];
+ tmpvec[2] /= tmpvec[3];
#if 0
- { /* debug print stuff */
- int i;
+ { /* debug print stuff */
+ int i;
- printf("\nobj bbox transformed\n");
- for( i=0; i<4; ++i)
- printf( "%f ", tmpvec[i]);
+ printf( "\nobj bbox transformed\n" );
+ for( i = 0; i < 4; ++i )
+ printf( "%f ", tmpvec[i] );
- printf("\n");
- }
+ printf( "\n" );
+ }
#endif
-
- /* because our bounding box is calculated and
- does not have its own memory,
- we must create vectors that allocate space */
-
- vector = newVectorObject( NULL, 3);
- memcpy( ((VectorObject*)vector)->vec,
- tmpvec,
- 3*sizeof(float));
- PyList_SET_ITEM(bbox, i, vector);
+
+ /* because our bounding box is calculated and
+ does not have its own memory,
+ we must create vectors that allocate space */
+
+ vector = newVectorObject( NULL, 3 );
+ memcpy( ( ( VectorObject * ) vector )->vec,
+ tmpvec, 3 * sizeof( float ) );
+ PyList_SET_ITEM( bbox, i, vector );
+ }
}
- }
- }
- else{ /* the ob bbox exists */
- vec = (float *)self->object->bb->vec;
+ } else { /* the ob bbox exists */
+ vec = ( float * ) self->object->bb->vec;
- if (!vec)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't retrieve bounding box data");
+ if( !vec )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't retrieve bounding box data" );
- bbox = PyList_New(8);
+ bbox = PyList_New( 8 );
- if (!bbox)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create pylist");
+ if( !bbox )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create pylist" );
- /* create vectors referencing object bounding box coords */
- for (i = 0; i < 8; i++) {
- vector = newVectorObject(vec, 3);
- PyList_SET_ITEM(bbox, i, vector);
- vec += 3;
- }
- }
+ /* create vectors referencing object bounding box coords */
+ for( i = 0; i < 8; i++ ) {
+ vector = newVectorObject( vec, 3 );
+ PyList_SET_ITEM( bbox, i, vector );
+ vec += 3;
+ }
+ }
- return bbox;
+ return bbox;
}
-static PyObject *Object_makeDisplayList (BPy_Object *self)
+static PyObject *Object_makeDisplayList( BPy_Object * self )
{
- Object *ob = self->object;
+ Object *ob = self->object;
- if (ob->type == OB_FONT) text_to_curve(ob, 0);
+ if( ob->type == OB_FONT )
+ text_to_curve( ob, 0 );
- makeDispList(ob);
+ makeDispList( ob );
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Object_link (BPy_Object *self, PyObject *args)
-{
- PyObject * py_data;
- ID * id;
- ID * oldid;
- int obj_id;
- void * data = NULL;
+static PyObject *Object_link( BPy_Object * self, PyObject * args )
+{
+ PyObject *py_data;
+ ID *id;
+ ID *oldid;
+ int obj_id;
+ void *data = NULL;
+
+ if( !PyArg_ParseTuple( args, "O", &py_data ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an object as argument" ) );
+ }
+ if( Armature_CheckPyObject( py_data ) )
+ data = ( void * ) Armature_FromPyObject( py_data );
+ if( Camera_CheckPyObject( py_data ) )
+ data = ( void * ) Camera_FromPyObject( py_data );
+ if( Lamp_CheckPyObject( py_data ) )
+ data = ( void * ) Lamp_FromPyObject( py_data );
+ if( Curve_CheckPyObject( py_data ) )
+ data = ( void * ) Curve_FromPyObject( py_data );
+ if( NMesh_CheckPyObject( py_data ) )
+ data = ( void * ) Mesh_FromPyObject( py_data, self->object );
+ if( Lattice_CheckPyObject( py_data ) )
+ data = ( void * ) Lattice_FromPyObject( py_data );
+ if( Metaball_CheckPyObject( py_data ) )
+ data = ( void * ) Metaball_FromPyObject( py_data );
- if (!PyArg_ParseTuple (args, "O", &py_data))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an object as argument"));
+ /* have we set data to something good? */
+ if( !data ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "link argument type is not supported " ) );
}
- if (Armature_CheckPyObject (py_data))
- data = (void *)Armature_FromPyObject (py_data);
- if (Camera_CheckPyObject (py_data))
- data = (void *)Camera_FromPyObject (py_data);
- if (Lamp_CheckPyObject (py_data))
- data = (void *)Lamp_FromPyObject (py_data);
- if (Curve_CheckPyObject (py_data))
- data = (void *)Curve_FromPyObject (py_data);
- if (NMesh_CheckPyObject (py_data))
- data = (void *)Mesh_FromPyObject (py_data, self->object);
- if (Lattice_CheckPyObject (py_data))
- data = (void *)Lattice_FromPyObject (py_data);
- if (Metaball_CheckPyObject (py_data))
- data = (void *)Metaball_FromPyObject (py_data);
- /* have we set data to something good? */
- 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]);
-
- 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"));
- }
- break;
- case ID_CA:
- if (self->object->type != OB_CAMERA)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- case ID_LA:
- if (self->object->type != OB_LAMP)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- case ID_ME:
- if (self->object->type != OB_MESH)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- case ID_CU:
- if (self->object->type != OB_CURVE)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- case ID_LT:
- if (self->object->type != OB_LATTICE)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- case ID_MB:
- if (self->object->type != OB_MBALL)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "The 'link' object is incompatible with the base object"));
- }
- break;
- default:
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Linking this object type is not supported"));
+ oldid = ( ID * ) self->object->data;
+ id = ( ID * ) data;
+ obj_id = MAKE_ID2( id->name[0], id->name[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" ) );
+ }
+ break;
+ case ID_CA:
+ if( self->object->type != OB_CAMERA ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ case ID_LA:
+ if( self->object->type != OB_LAMP ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ case ID_ME:
+ if( self->object->type != OB_MESH ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ case ID_CU:
+ if( self->object->type != OB_CURVE ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ case ID_LT:
+ if( self->object->type != OB_LATTICE ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ case ID_MB:
+ if( self->object->type != OB_MBALL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "The 'link' object is incompatible with the base object" ) );
+ }
+ break;
+ default:
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Linking this object type is not supported" ) );
}
self->object->data = data;
- if ( self->object->type == OB_MESH)
- {
+ if( self->object->type == OB_MESH ) {
self->object->totcol = 0;
- EXPP_synchronizeMaterialLists(self->object);
+ EXPP_synchronizeMaterialLists( self->object );
}
- id_us_plus (id);
- if (oldid)
- {
- if (oldid->us > 0)
- {
+ id_us_plus( id );
+ if( oldid ) {
+ if( oldid->us > 0 ) {
oldid->us--;
- }
- else
- {
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "old object reference count below 0"));
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "old object reference count below 0" ) );
}
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_makeParent (BPy_Object *self, PyObject *args)
+static PyObject *Object_makeParent( BPy_Object * self, PyObject * args )
{
- PyObject * list;
- PyObject * py_child;
- //BPy_Object * py_obj_child; unused
- Object * child;
- Object * parent;
- int noninverse = 0;
- int fast = 0;
- int i;
+ PyObject *list;
+ PyObject *py_child;
+ //BPy_Object * py_obj_child; unused
+ Object *child;
+ Object *parent;
+ int noninverse = 0;
+ int fast = 0;
+ 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( !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( !PySequence_Check( list ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a list of objects" ) );
}
/* Check if the PyObject passed in list is a Blender object. */
- for (i=0 ; i<PySequence_Length (list) ; i++)
- {
+ for( i = 0; i < PySequence_Length( list ); i++ ) {
child = NULL;
- py_child = PySequence_GetItem (list, i);
- if (Object_CheckPyObject (py_child))
- child = (Object*) Object_FromPyObject (py_child);
-
- if (child == NULL)
- {
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "Object Type expected"));
+ py_child = PySequence_GetItem( list, i );
+ if( Object_CheckPyObject( py_child ) )
+ child = ( Object * ) Object_FromPyObject( py_child );
+
+ if( child == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Object Type expected" ) );
}
- parent = (Object*)self->object;
- if (test_parent_loop (parent, child))
- {
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "parenting loop detected - parenting failed"));
+ parent = ( Object * ) self->object;
+ if( test_parent_loop( parent, child ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "parenting loop detected - parenting failed" ) );
}
child->partype = PAROBJECT;
child->parent = parent;
//py_obj_child = (BPy_Object *) py_child;
- if (noninverse == 1)
- {
+ if( noninverse == 1 ) {
/* Parent inverse = unity */
child->loc[0] = 0.0;
child->loc[1] = 0.0;
child->loc[2] = 0.0;
- }
- else
- {
- what_does_parent (child);
- Mat4Invert (child->parentinv, parent->obmat);
+ } else {
+ what_does_parent( child );
+ Mat4Invert( child->parentinv, parent->obmat );
}
- if (!fast)
- {
- sort_baselist (G.scene);
+ if( !fast ) {
+ sort_baselist( G.scene );
}
-
// We don't need the child object anymore.
//Py_DECREF ((PyObject *) child);
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args)
+static PyObject *Object_materialUsage( BPy_Object * self, PyObject * args )
{
- return (EXPP_ReturnPyObjError (PyExc_NotImplementedError,
- "materialUsage: not yet implemented"));
+ return ( EXPP_ReturnPyObjError( PyExc_NotImplementedError,
+ "materialUsage: not yet implemented" ) );
}
-static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args)
+static PyObject *Object_setDeltaLocation( BPy_Object * self, PyObject * args )
{
- float dloc1;
- float dloc2;
- float dloc3;
- int status;
+ float dloc1;
+ float dloc2;
+ float dloc3;
+ int status;
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &dloc1, &dloc2, &dloc3);
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &dloc1, &dloc2,
+ &dloc3 );
else
- status = PyArg_ParseTuple (args, "(fff)", &dloc1, &dloc2, &dloc3);
+ status = PyArg_ParseTuple( args, "(fff)", &dloc1, &dloc2,
+ &dloc3 );
- if (!status)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument of 3 floats");
+ if( !status )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument of 3 floats" );
self->object->dloc[0] = dloc1;
self->object->dloc[1] = dloc2;
self->object->dloc[2] = dloc3;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args)
+static PyObject *Object_setDrawMode( BPy_Object * self, PyObject * args )
{
- char dtx;
+ char dtx;
- if (!PyArg_ParseTuple (args, "b", &dtx))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an integer as argument"));
+ if( !PyArg_ParseTuple( args, "b", &dtx ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an integer as argument" ) );
}
self->object->dtx = dtx;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args)
-{
- char dt;
+static PyObject *Object_setDrawType( BPy_Object * self, PyObject * args )
+{
+ char dt;
- if (!PyArg_ParseTuple (args, "b", &dt))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an integer as argument"));
+ if( !PyArg_ParseTuple( args, "b", &dt ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an integer as argument" ) );
}
self->object->dt = dt;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setEuler (BPy_Object *self, PyObject *args)
+static PyObject *Object_setEuler( BPy_Object * self, PyObject * args )
{
- float rot1;
- float rot2;
- float rot3;
- int status = 0; /* failure */
- PyObject* ob;
+ float rot1;
+ float rot2;
+ float 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) {
- 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 */
+ if( PyObject_Length( args ) == 3 ) {
+ 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 */
+
+ status = 0; /* false */
}
- }
- else{ /* arg parsing failed */
+ } else { /* arg parsing failed */
status = 0;
}
}
-
- if( !status) /* parsing args failed */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected euler or list/tuple of 3 floats "));
+
+ if( !status ) /* parsing args failed */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected euler or list/tuple of 3 floats " ) );
self->object->rot[0] = rot1;
self->object->rot[1] = rot2;
self->object->rot[2] = rot3;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setMatrix (BPy_Object *self, PyObject *args)
+static PyObject *Object_setMatrix( BPy_Object * self, PyObject * args )
{
- MatrixObject* mat;
- int x,y;
+ MatrixObject *mat;
+ int x, y;
- if (!PyArg_ParseTuple(args, "O!", &matrix_Type, &mat))
- return EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected matrix object as argument");
+ if( !PyArg_ParseTuple( args, "O!", &matrix_Type, &mat ) )
+ return EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected matrix object as argument" );
- for(x = 0; x < 4; x++){
- for(y = 0; y < 4; y++){
+ for( x = 0; x < 4; x++ ) {
+ for( y = 0; y < 4; y++ ) {
self->object->obmat[x][y] = mat->matrix[x][y];
}
}
- apply_obmat(self->object);
+ apply_obmat( self->object );
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setIpo(BPy_Object *self, PyObject *args)
+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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject(pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ 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");
+ if( ipo->blocktype != ID_OB )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not an object ipo" );
oldipo = self->object->ipo;
- if (oldipo) {
+ if( oldipo ) {
ID *id = &oldipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
}
- ((ID *)&ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
self->object->ipo = ipo;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Object_setLocation (BPy_Object *self, PyObject *args)
+static PyObject *Object_setLocation( BPy_Object * self, PyObject * args )
{
- float loc1;
- float loc2;
- float loc3;
- int status;
+ float loc1;
+ float loc2;
+ float loc3;
+ int status;
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &loc1, &loc2, &loc3);
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &loc1, &loc2, &loc3 );
else
- status = PyArg_ParseTuple (args, "(fff)", &loc1, &loc2, &loc3);
+ status = PyArg_ParseTuple( args, "(fff)", &loc1, &loc2,
+ &loc3 );
- if (!status)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument of 3 floats");
+ if( !status )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument of 3 floats" );
self->object->loc[0] = loc1;
self->object->loc[1] = loc2;
self->object->loc[2] = loc3;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
+static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
{
- PyObject * list;
- int len;
- int i;
- Material ** matlist;
+ PyObject *list;
+ int len;
+ int i;
+ Material **matlist;
- if (!PyArg_ParseTuple (args, "O", &list))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a list of materials as argument"));
+ if( !PyArg_ParseTuple( args, "O", &list ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a list of materials as argument" ) );
}
- len = PySequence_Length (list);
- if (len > 0)
- {
- matlist = EXPP_newMaterialList_fromPyList (list);
- if (!matlist)
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "material list must be a list of valid materials!"));
+ len = PySequence_Length( list );
+ if( len > 0 ) {
+ matlist = EXPP_newMaterialList_fromPyList( list );
+ if( !matlist ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "material list must be a list of valid materials!" ) );
}
- if ((len < 0) || (len > MAXMAT))
- {
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "material list should have at least 1, at most 16 entries"));
+ if( ( len < 0 ) || ( len > MAXMAT ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "material list should have at least 1, at most 16 entries" ) );
}
- if (self->object->mat)
- {
- EXPP_releaseMaterialList (self->object->mat, self->object->totcol);
+ if( self->object->mat ) {
+ EXPP_releaseMaterialList( self->object->mat,
+ self->object->totcol );
}
/* Increase the user count on all materials */
- for (i=0 ; i<len ; i++)
- {
- if (matlist[i]) id_us_plus ((ID *) matlist[i]);
+ for( i = 0; i < len; i++ ) {
+ if( matlist[i] )
+ id_us_plus( ( ID * ) matlist[i] );
}
self->object->mat = matlist;
self->object->totcol = len;
self->object->actcol = len;
- switch (self->object->type)
- {
- case OB_CURVE: /* fall through */
- case OB_FONT: /* fall through */
- case OB_MESH: /* fall through */
- case OB_MBALL: /* fall through */
- case OB_SURF:
- EXPP_synchronizeMaterialLists (self->object);
- break;
- default:
- break;
+ switch ( self->object->type ) {
+ case OB_CURVE: /* fall through */
+ case OB_FONT: /* fall through */
+ case OB_MESH: /* fall through */
+ case OB_MBALL: /* fall through */
+ case OB_SURF:
+ EXPP_synchronizeMaterialLists( self->object );
+ break;
+ default:
+ break;
}
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_setName (BPy_Object *self, PyObject *args)
+static PyObject *Object_setName( BPy_Object * self, PyObject * args )
{
- char * name;
- char buf[21];
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple (args, "s", &name))
- {
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a String as argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a String as argument" ) );
}
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id(&self->object->id, buf);
+ rename_id( &self->object->id, buf );
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setSize (BPy_Object *self, PyObject *args)
+static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
{
- float sizex;
- float sizey;
- float sizez;
- int status;
+ float sizex;
+ float sizey;
+ float sizez;
+ int status;
- if (PyObject_Length (args) == 3)
- status = PyArg_ParseTuple (args, "fff", &sizex, &sizey, &sizez);
+ if( PyObject_Length( args ) == 3 )
+ status = PyArg_ParseTuple( args, "fff", &sizex, &sizey,
+ &sizez );
else
- status = PyArg_ParseTuple (args, "(fff)", &sizex, &sizey, &sizez);
+ status = PyArg_ParseTuple( args, "(fff)", &sizex, &sizey,
+ &sizez );
- if (!status)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected list argument of 3 floats");
+ if( !status )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected list argument of 3 floats" );
self->object->size[0] = sizex;
self->object->size[1] = sizey;
self->object->size[2] = sizez;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args)
+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"));
+ if( !PyArg_ParseTuple( args, "f", &newTimeOffset ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a float as argument" ) );
}
- self->object->sf=newTimeOffset;
+ self->object->sf = newTimeOffset;
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args)
+static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args )
{
- BPy_Object *tracked = NULL;
+ BPy_Object *tracked = NULL;
Object *ob = self->object;
int fast = 0;
-
- 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.");
+
+ 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." );
ob->track = tracked->object;
- if (!fast) sort_baselist(G.scene);
+ if( !fast )
+ sort_baselist( G.scene );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
+static PyObject *Object_shareFrom( BPy_Object * self, PyObject * args )
{
- BPy_Object * object;
- ID * id;
- ID * oldid;
+ BPy_Object *object;
+ ID *id;
+ ID *oldid;
- if (!PyArg_ParseTuple (args, "O", &object))
- {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an object argument");
+ if( !PyArg_ParseTuple( args, "O", &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( !Object_CheckPyObject( ( PyObject * ) object ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "first argument is not of type 'Object'" );
}
- if (self->object->type != object->object->type)
- {
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "objects are not of same data 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:
- case OB_CAMERA: /* we can probably add the other types, too */
- case OB_ARMATURE:
- case OB_CURVE:
- case OB_SURF:
- case OB_LATTICE:
- oldid = (ID*) self->object->data;
- id = (ID*) object->object->data;
- self->object->data = object->object->data;
-
- if ( self->object->type == OB_MESH && id ){
- self->object->totcol = 0;
- EXPP_synchronizeMaterialLists(self->object);
- }
+ switch ( self->object->type ) {
+ case OB_MESH:
+ case OB_LAMP:
+ case OB_CAMERA: /* we can probably add the other types, too */
+ case OB_ARMATURE:
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_LATTICE:
+ oldid = ( ID * ) self->object->data;
+ id = ( ID * ) object->object->data;
+ self->object->data = object->object->data;
- id_us_plus (id);
- if (oldid)
- {
- if (oldid->us > 0)
- {
- oldid->us--;
- }
- else
- {
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "old object reference count below 0"));
- }
+ if( self->object->type == OB_MESH && id ) {
+ self->object->totcol = 0;
+ EXPP_synchronizeMaterialLists( self->object );
+ }
+
+ id_us_plus( id );
+ if( oldid ) {
+ if( oldid->us > 0 ) {
+ oldid->us--;
+ } else {
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "old object reference count below 0" ) );
}
- Py_INCREF (Py_None);
- return (Py_None);
- default:
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "type not supported");
+ }
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ default:
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "type not supported" );
}
- Py_INCREF (Py_None);
- return (Py_None);
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_Select (BPy_Object *self, PyObject *args)
+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 = 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= base->flag;
+ self->object->flag = base->flag;
set_active_base( base );
- } else {
+ } else {
base->flag &= ~SELECT;
- self->object->flag= base->flag;
+ self->object->flag = base->flag;
}
break;
}
- base= base->next;
+ base = base->next;
}
-
- countall();
-
- Py_INCREF (Py_None);
- return (Py_None);
+
+ countall( );
+
+ Py_INCREF( Py_None );
+ return ( Py_None );
}
-static PyObject *Object_getAllProperties(BPy_Object *self)
+static PyObject *Object_getAllProperties( BPy_Object * self )
{
PyObject *prop_list;
- bProperty *prop= NULL;
+ bProperty *prop = NULL;
- prop_list = PyList_New(0);
+ prop_list = PyList_New( 0 );
prop = self->object->prop.first;
- while(prop){
- PyList_Append(prop_list, Property_CreatePyObject(prop));
+ while( prop ) {
+ PyList_Append( prop_list, Property_CreatePyObject( prop ) );
prop = prop->next;
}
return prop_list;
}
-static PyObject *Object_getProperty(BPy_Object *self, PyObject *args)
+static PyObject *Object_getProperty( BPy_Object * self, PyObject * args )
{
char *prop_name = NULL;
- bProperty *prop= 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_AttributeError,
+ "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...."));
+ 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;
}
-static PyObject *Object_addProperty(BPy_Object *self, PyObject *args)
+static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
{
bProperty *prop = NULL;
char *prop_name = NULL;
@@ -1828,621 +1817,627 @@ static PyObject *Object_addProperty(BPy_Object *self, PyObject *args)
short type = -1;
BPy_Property *py_prop = NULL;
- if (PyObject_Length (args) == 3 || PyObject_Length (args) == 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( PyObject_Length( args ) == 3 || PyObject_Length( args ) == 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" ) );
}
- }else if (PyObject_Length (args) == 1){
- if (!PyArg_ParseTuple (args, "O!", &property_Type, &py_prop)){
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unable to get Property"));
+ } else if( PyObject_Length( args ) == 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( py_prop->property != NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Property is already added to an object" ) );
}
- }else{
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 1,2 or 3 arguments"));
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 1,2 or 3 arguments" ) );
}
//parse property type
- if(!py_prop){
- if(prop_type){
- if(BLI_streq(prop_type, "BOOL")) type = PROP_BOOL;
- else if (BLI_streq(prop_type, "INT")) type = PROP_INT;
- else if (BLI_streq(prop_type, "FLOAT")) type = PROP_FLOAT;
- else if (BLI_streq(prop_type, "TIME")) type = PROP_TIME;
- else if (BLI_streq(prop_type, "STRING")) type = PROP_STRING;
- else return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "BOOL, INT, FLOAT, TIME or STRING expected"));
- }else{
+ if( !py_prop ) {
+ if( prop_type ) {
+ if( BLI_streq( prop_type, "BOOL" ) )
+ type = PROP_BOOL;
+ else if( BLI_streq( prop_type, "INT" ) )
+ type = PROP_INT;
+ else if( BLI_streq( prop_type, "FLOAT" ) )
+ type = PROP_FLOAT;
+ else if( BLI_streq( prop_type, "TIME" ) )
+ type = PROP_TIME;
+ else if( BLI_streq( prop_type, "STRING" ) )
+ type = PROP_STRING;
+ else
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "BOOL, INT, FLOAT, TIME or STRING expected" ) );
+ } else {
//use the default
- if(PyInt_Check(prop_data)) type = PROP_INT;
- else if (PyFloat_Check(prop_data)) type = PROP_FLOAT;
- else if (PyString_Check(prop_data)) type = PROP_STRING;
+ if( PyInt_Check( prop_data ) )
+ type = PROP_INT;
+ else if( PyFloat_Check( prop_data ) )
+ type = PROP_FLOAT;
+ else if( PyString_Check( prop_data ) )
+ type = PROP_STRING;
}
- }else{
+ } else {
type = py_prop->type;
}
//initialize a new bProperty of the specified type
- prop = new_property(type);
+ prop = new_property( type );
//parse data
- if(!py_prop){
- BLI_strncpy(prop->name, prop_name, 32);
- if(PyInt_Check(prop_data)){
- *((int*)&prop->data) = (int)PyInt_AsLong(prop_data);
- }else if (PyFloat_Check(prop_data)){
- *((float *)&prop->data) = (float)PyFloat_AsDouble(prop_data);
- }else if (PyString_Check(prop_data)){
- BLI_strncpy(prop->poin, PyString_AsString(prop_data), MAX_PROPSTRING);
+ if( !py_prop ) {
+ BLI_strncpy( prop->name, prop_name, 32 );
+ if( PyInt_Check( prop_data ) ) {
+ *( ( int * ) &prop->data ) =
+ ( int ) PyInt_AsLong( prop_data );
+ } else if( PyFloat_Check( prop_data ) ) {
+ *( ( float * ) &prop->data ) =
+ ( float ) PyFloat_AsDouble( prop_data );
+ } else if( PyString_Check( prop_data ) ) {
+ BLI_strncpy( prop->poin,
+ PyString_AsString( prop_data ),
+ MAX_PROPSTRING );
}
- }else{
+ } else {
py_prop->property = prop;
- if(!updateProperyData(py_prop)){
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Could not update property data - error"));
+ if( !updateProperyData( py_prop ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Could not update property data - error" ) );
}
}
//add to property listbase for the object
- BLI_addtail(&self->object->prop, prop);
+ BLI_addtail( &self->object->prop, prop );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_removeProperty(BPy_Object *self, PyObject *args)
+static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
{
char *prop_name = NULL;
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"));
+ 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" ) );
}
}
-
//remove the link, free the data, and update the py struct
- if(py_prop){
- BLI_remlink(&self->object->prop, py_prop->property);
- if(updatePyProperty(py_prop)){
- free_property(py_prop->property);
+ if( py_prop ) {
+ BLI_remlink( &self->object->prop, py_prop->property );
+ if( updatePyProperty( py_prop ) ) {
+ free_property( py_prop->property );
py_prop->property = NULL;
}
- }else{
- prop = get_property(self->object, prop_name);
- if(prop){
- BLI_remlink(&self->object->prop, prop);
- free_property(prop);
+ } else {
+ prop = get_property( self->object, prop_name );
+ if( prop ) {
+ BLI_remlink( &self->object->prop, prop );
+ free_property( prop );
}
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_removeAllProperties(BPy_Object *self)
+static PyObject *Object_removeAllProperties( BPy_Object * self )
{
- free_properties(&self->object->prop);
- return EXPP_incr_ret (Py_None);
+ free_properties( &self->object->prop );
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args)
+static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
+ PyObject * args )
{
PyObject *dest = Py_None;
bProperty *prop = NULL;
bProperty *propn = NULL;
- if (!PyArg_ParseTuple (args, "O!", &Object_Type, &dest)){
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected an Object"));
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &dest ) ) {
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected an Object" ) );
}
-
//make a copy of all it's properties
prop = self->object->prop.first;
- while(prop) {
- propn= copy_property(prop);
- BLI_addtail(&((BPy_Object*)dest)->object->prop, propn);
- prop= prop->next;
+ while( prop ) {
+ propn = copy_property( prop );
+ BLI_addtail( &( ( BPy_Object * ) dest )->object->prop, propn );
+ prop = prop->next;
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/* obj.addScriptLink */
-static PyObject *Object_addScriptLink (BPy_Object *self, PyObject *args)
+static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args )
{
Object *obj = self->object;
ScriptLink *slink = NULL;
- slink = &(obj)->scriptlink;
+ slink = &( obj )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 0))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 0 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* obj.clearScriptLinks */
-static PyObject *Object_clearScriptLinks (BPy_Object *self)
+static PyObject *Object_clearScriptLinks( BPy_Object * self )
{
Object *obj = self->object;
ScriptLink *slink = NULL;
- slink = &(obj)->scriptlink;
+ slink = &( obj )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* obj.getScriptLinks */
-static PyObject *Object_getScriptLinks (BPy_Object *self, PyObject *args)
+static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * args )
{
Object *obj = self->object;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- slink = &(obj)->scriptlink;
+ slink = &( obj )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 0);
+ ret = EXPP_getScriptLinks( slink, args, 0 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
/*****************************************************************************/
-/* Function: Object_CreatePyObject */
+/* Function: Object_CreatePyObject */
/* Description: This function will create a new BlenObject from an existing */
-/* Object structure. */
+/* Object structure. */
/*****************************************************************************/
-PyObject* Object_CreatePyObject (struct Object *obj)
+PyObject *Object_CreatePyObject( struct Object * obj )
{
- BPy_Object * blen_object;
+ BPy_Object *blen_object;
- if (!obj) return EXPP_incr_ret (Py_None);
+ if( !obj )
+ return EXPP_incr_ret( Py_None );
- blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
+ blen_object =
+ ( BPy_Object * ) PyObject_NEW( BPy_Object, &Object_Type );
- if (blen_object == NULL)
- {
- return (NULL);
+ if( blen_object == NULL ) {
+ return ( NULL );
}
blen_object->object = obj;
- return ((PyObject*)blen_object);
+ return ( ( PyObject * ) blen_object );
}
/*****************************************************************************/
-/* Function: Object_CheckPyObject */
+/* Function: Object_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type Object. Otherwise it will return false. */
+/* type Object. Otherwise it will return false. */
/*****************************************************************************/
-int Object_CheckPyObject (PyObject *py_obj)
+int Object_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Object_Type);
+ return ( py_obj->ob_type == &Object_Type );
}
/*****************************************************************************/
-/* Function: Object_FromPyObject */
-/* Description: This function returns the Blender object from the given */
-/* PyObject. */
+/* Function: Object_FromPyObject */
+/* Description: This function returns the Blender object from the given */
+/* PyObject. */
/*****************************************************************************/
-struct Object* Object_FromPyObject (PyObject *py_obj)
+struct Object *Object_FromPyObject( PyObject * py_obj )
{
- BPy_Object * blen_obj;
+ BPy_Object *blen_obj;
- blen_obj = (BPy_Object*)py_obj;
- return (blen_obj->object);
+ blen_obj = ( BPy_Object * ) py_obj;
+ return ( blen_obj->object );
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
-Object * GetObjectByName (char * name)
+Object *GetObjectByName( char *name )
{
- Object * obj_iter;
+ Object *obj_iter;
- obj_iter = G.main->object.first;
- while (obj_iter)
- {
- if (StringEqual (name, GetIdName (&(obj_iter->id))))
- {
- return (obj_iter);
+ obj_iter = G.main->object.first;
+ while( obj_iter ) {
+ if( StringEqual( name, GetIdName( &( obj_iter->id ) ) ) ) {
+ return ( obj_iter );
+ }
+ obj_iter = obj_iter->id.next;
}
- obj_iter = obj_iter->id.next;
- }
- /* There is no object with the given name */
- return (NULL);
+ /* There is no object with the given name */
+ return ( NULL );
}
/*****************************************************************************/
-/* Function: Object_dealloc */
-/* Description: This is a callback function for the BlenObject type. It is */
-/* the destructor function. */
+/* Function: Object_dealloc */
+/* Description: This is a callback function for the BlenObject type. It is */
+/* the destructor function. */
/*****************************************************************************/
-static void Object_dealloc (BPy_Object *obj)
+static void Object_dealloc( BPy_Object * obj )
{
- PyObject_DEL (obj);
+ PyObject_DEL( 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_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. */
/*****************************************************************************/
-static PyObject* Object_getAttr (BPy_Object *obj, char *name)
+static PyObject *Object_getAttr( BPy_Object * obj, char *name )
{
- struct Object * object;
- struct Ika * ika;
+ struct Object *object;
+ struct Ika *ika;
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]));
- if (strncmp (name,"Eff", 3) == 0)
- {
- if ( (object->type == OB_IKA) && (object->data != NULL) )
- {
+ 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] ) );
+ if( strncmp( name, "Eff", 3 ) == 0 ) {
+ if( ( object->type == OB_IKA ) && ( object->data != NULL ) ) {
ika = object->data;
- switch (name[3])
- {
- case 'X':
- return (PyFloat_FromDouble (ika->effg[0]));
- case 'Y':
- return (PyFloat_FromDouble (ika->effg[1]));
- case 'Z':
- return (PyFloat_FromDouble (ika->effg[2]));
- default:
+ switch ( name[3] ) {
+ case 'X':
+ return ( PyFloat_FromDouble( ika->effg[0] ) );
+ case 'Y':
+ return ( PyFloat_FromDouble( ika->effg[1] ) );
+ case 'Z':
+ return ( PyFloat_FromDouble( ika->effg[2] ) );
+ default:
/* Do we need to display a sensible error message here? */
- return (NULL);
+ return ( NULL );
}
}
- return (NULL);
- }
- if (StringEqual (name, "Layer"))
- return (PyInt_FromLong(object->lay));
- if (StringEqual (name, "parent"))
- {
- if (object->parent)
- return (Object_CreatePyObject (object->parent));
- else
- {
- Py_INCREF (Py_None);
- return (Py_None);
- }
- }
-
- if (StringEqual (name, "track"))
- return (Object_CreatePyObject (object->track));
- if (StringEqual (name, "data"))
- return (Object_getData (obj));
- if (StringEqual (name, "ipo"))
- {
- if (object->ipo == NULL)
- {
+ return ( NULL );
+ }
+ if( StringEqual( name, "Layer" ) )
+ return ( PyInt_FromLong( object->lay ) );
+ if( StringEqual( name, "parent" ) ) {
+ if( object->parent )
+ return ( Object_CreatePyObject( object->parent ) );
+ else {
+ Py_INCREF( Py_None );
+ return ( Py_None );
+ }
+ }
+
+ if( StringEqual( name, "track" ) )
+ return ( Object_CreatePyObject( object->track ) );
+ if( StringEqual( name, "data" ) )
+ return ( Object_getData( obj ) );
+ 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);
+ 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)","localspace")));
- 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));
-
+ return ( Ipo_CreatePyObject( object->ipo ) );
+ }
+ if( StringEqual( name, "mat" ) || StringEqual( name, "matrix" ) )
+ return ( Object_getMatrix
+ ( obj, Py_BuildValue( "(s)", "localspace" ) ) );
+ 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 ) );
+
/* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Object_methods, (PyObject *)obj, name);
+ return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
}
/*****************************************************************************/
-/* 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. */
+/* 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_setAttr( BPy_Object * obj, char *name, PyObject * value )
{
- PyObject * valtuple;
- struct Object * object;
- struct Ika * ika;
+ PyObject *valtuple;
+ struct Object *object;
+ struct Ika *ika;
/* First 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");
+ valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple ) {
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "Object_setAttr: couldn't create PyTuple" );
}
object = obj->object;
- 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, "loc"))
- {
- if (Object_setLocation (obj, valtuple) != Py_None)
- return (-1);
+ 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, "loc" ) ) {
+ if( Object_setLocation( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
- }
- 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, "dloc"))
- {
- if (Object_setDeltaLocation (obj, valtuple) != Py_None)
- return (-1);
+ return ( 0 );
+ }
+ 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, "dloc" ) ) {
+ if( Object_setDeltaLocation( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
- }
- 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, "rot"))
- {
- if (Object_setEuler (obj, valtuple) != Py_None)
- return (-1);
+ return ( 0 );
+ }
+ 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, "rot" ) ) {
+ if( Object_setEuler( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
- }
- 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 (strncmp (name,"Eff", 3) == 0)
- {
- if ( (object->type == OB_IKA) && (object->data != NULL) )
- {
+ return ( 0 );
+ }
+ 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( strncmp( name, "Eff", 3 ) == 0 ) {
+ if( ( object->type == OB_IKA ) && ( object->data != NULL ) ) {
ika = object->data;
- switch (name[3])
- {
- case 'X':
- return (!PyArg_Parse (value, "f", &(ika->effg[0])));
- case 'Y':
- return (!PyArg_Parse (value, "f", &(ika->effg[1])));
- case 'Z':
- return (!PyArg_Parse (value, "f", &(ika->effg[2])));
- default:
- /* Do we need to display a sensible error message here? */
- return (0);
+ switch ( name[3] ) {
+ case 'X':
+ return ( !PyArg_Parse
+ ( value, "f", &( ika->effg[0] ) ) );
+ case 'Y':
+ return ( !PyArg_Parse
+ ( value, "f", &( ika->effg[1] ) ) );
+ case 'Z':
+ return ( !PyArg_Parse
+ ( value, "f", &( ika->effg[2] ) ) );
+ default:
+ /* Do we need to display a sensible error message here? */
+ return ( 0 );
}
}
- return (0);
+ return ( 0 );
}
- if (StringEqual (name, "Layer"))
- {
- /* usage note: caller of this func needs to do a
- Blender.Redraw(-1) to update and redraw the interface */
+ if( StringEqual( name, "Layer" ) ) {
+ /* usage note: caller of this func needs to do a
+ Blender.Redraw(-1) to update and redraw the interface */
Base *base;
int newLayer;
int local;
- if(PyArg_Parse (value, "i", &newLayer)){
+ if( PyArg_Parse( value, "i", &newLayer ) ) {
/* uppper 2 bytes are for local view */
- newLayer &= 0x00FFFFFF;
- if( newLayer == 0 ) /* bail if nothing to do */
- return( 0 );
+ newLayer &= 0x00FFFFFF;
+ if( newLayer == 0 ) /* bail if nothing to do */
+ return ( 0 );
/* update any bases pointing to our object */
base = FIRSTBASE;
- if( base->object == obj->object ){
+ if( base->object == obj->object ) {
local = base->lay &= 0xFF000000;
base->lay = local | newLayer;
object->lay = base->lay;
}
- countall();
- }
- else{
- return EXPP_ReturnIntError(PyExc_AttributeError,
- "expected int as bitmask");
+ countall( );
+ } else {
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "expected int as bitmask" );
}
-
- return( 0 );
+
+ return ( 0 );
}
- if (StringEqual (name, "parent"))
- {
+ if( StringEqual( name, "parent" ) ) {
/* This is not allowed. */
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Setting the parent is not allowed.");
- return (0);
- }
- if (StringEqual (name, "track"))
- {
- if (Object_makeTrack (obj, valtuple) != Py_None)
- return (-1);
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Setting the parent is not allowed." );
+ return ( 0 );
+ }
+ if( StringEqual( name, "track" ) ) {
+ if( Object_makeTrack( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
+ return ( 0 );
}
- if (StringEqual (name, "data"))
- {
+ if( StringEqual( name, "data" ) ) {
/* This is not allowed. */
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Setting the data is not allowed.");
- return (0);
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Setting the data is not allowed." );
+ return ( 0 );
}
- if (StringEqual (name, "ipo"))
- {
+ if( StringEqual( name, "ipo" ) ) {
/* This is not allowed. */
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Setting the ipo is not allowed.");
- return (0);
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Setting the ipo is not allowed." );
+ return ( 0 );
}
- if (StringEqual (name, "mat"))
- {
+ if( StringEqual( name, "mat" ) ) {
/* This is not allowed. */
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Setting the matrix is not allowed.");
- return (0);
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Setting the matrix is not allowed." );
+ return ( 0 );
}
- if (StringEqual (name, "matrix"))
- {
+ if( StringEqual( name, "matrix" ) ) {
/* This is not allowed. */
- EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Please use .setMatrix(matrix)");
- return (0);
- }
- if (StringEqual (name, "colbits"))
- return (!PyArg_Parse (value, "h", &(object->colbits)));
- if (StringEqual (name, "drawType"))
- {
- if (Object_setDrawType (obj, valtuple) != Py_None)
- return (-1);
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Please use .setMatrix(matrix)" );
+ return ( 0 );
+ }
+ if( StringEqual( name, "colbits" ) )
+ return ( !PyArg_Parse( value, "h", &( object->colbits ) ) );
+ if( StringEqual( name, "drawType" ) ) {
+ if( Object_setDrawType( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
+ return ( 0 );
}
- if (StringEqual (name, "drawMode"))
- {
- if (Object_setDrawMode (obj, valtuple) != Py_None)
- return (-1);
+ if( StringEqual( name, "drawMode" ) ) {
+ if( Object_setDrawMode( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
+ return ( 0 );
}
- if (StringEqual (name, "name"))
- {
- if (Object_setName (obj, valtuple) != Py_None)
- return (-1);
+ if( StringEqual( name, "name" ) ) {
+ if( Object_setName( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
+ return ( 0 );
}
-
- if (StringEqual (name, "sel"))
- {
- if (Object_Select (obj, valtuple) != Py_None)
- return (-1);
+
+ if( StringEqual( name, "sel" ) ) {
+ if( Object_Select( obj, valtuple ) != Py_None )
+ return ( -1 );
else
- return (0);
+ return ( 0 );
}
-
- printf ("Unknown variable.\n");
- return (0);
+
+ printf( "Unknown variable.\n" );
+ 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. */
+/* 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)
+static int Object_compare( BPy_Object * a, BPy_Object * b )
{
- Object *pa = a->object, *pb = b->object;
- return (pa == pb) ? 0:-1;
+ Object *pa = a->object, *pb = b->object;
+ return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
-/* Function: Object_repr */
-/* Description: This is a callback function for the BPy_Object type. It */
-/* builds a meaninful string to represent object objects. */
+/* 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 PyObject *Object_repr( BPy_Object * self )
{
- return PyString_FromFormat("[Object \"%s\"]", self->object->id.name+2);
+ return PyString_FromFormat( "[Object \"%s\"]",
+ self->object->id.name + 2 );
}
diff --git a/source/blender/python/api2_2x/Object.h b/source/blender/python/api2_2x/Object.h
index aad0af8ba77..e96ecca241e 100644
--- a/source/blender/python/api2_2x/Object.h
+++ b/source/blender/python/api2_2x/Object.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -44,8 +45,8 @@
#include <BKE_mesh.h>
#include <BKE_object.h>
#include <BKE_scene.h>
-#include <BKE_displist.h> /* for makeDispList */
-#include <BKE_font.h> /* for text_to_font */
+#include <BKE_displist.h> /* for makeDispList */
+#include <BKE_font.h> /* for text_to_font */
#include <BLI_arithb.h>
#include <BLI_blenlib.h>
#include <DNA_armature_types.h>
@@ -70,16 +71,15 @@
extern PyTypeObject Object_Type;
#define BPy_Object_Check(v) \
- ((v)->ob_type == &Object_Type) /* for type checking */
+ ((v)->ob_type == &Object_Type) /* for type checking */
/*****************************************************************************/
-/* Python BPy_Object structure definition. */
+/* Python BPy_Object structure definition. */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- struct Object * object;
+ PyObject_HEAD struct Object *object;
} BPy_Object;
-int EXPP_add_obdata(struct Object *object);
+int EXPP_add_obdata( struct Object *object );
-#endif /* EXPP_OBJECT_H */
+#endif /* EXPP_OBJECT_H */
diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c
index 7488fc8c56c..c080bc5df93 100644
--- a/source/blender/python/api2_2x/Particle.c
+++ b/source/blender/python/api2_2x/Particle.c
@@ -34,92 +34,92 @@
#include "Effect.h"
/*****************************************************************************/
-/* Python BPy_Particle methods table: */
+/* Python BPy_Particle methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Particle_methods[] = {
- {"getType", (PyCFunction)Effect_getType,
- METH_NOARGS,"() - Return Effect type"},
- {"setType", (PyCFunction)Effect_setType,
- METH_VARARGS,"() - Set Effect type"},
- {"getFlag", (PyCFunction)Effect_getFlag,
- METH_NOARGS,"() - Return Effect flag"},
- {"setFlag", (PyCFunction)Effect_setFlag,
- METH_VARARGS,"() - Set Effect flag"},
- {"getStartTime",(PyCFunction)Particle_getSta,
- METH_NOARGS,"()-Return particle start time"},
- {"setStartTime",(PyCFunction)Particle_setSta, METH_VARARGS,
+ {"getType", ( PyCFunction ) Effect_getType,
+ METH_NOARGS, "() - Return Effect type"},
+ {"setType", ( PyCFunction ) Effect_setType,
+ METH_VARARGS, "() - Set Effect type"},
+ {"getFlag", ( PyCFunction ) Effect_getFlag,
+ METH_NOARGS, "() - Return Effect flag"},
+ {"setFlag", ( PyCFunction ) Effect_setFlag,
+ METH_VARARGS, "() - Set Effect flag"},
+ {"getStartTime", ( PyCFunction ) Particle_getSta,
+ METH_NOARGS, "()-Return particle start time"},
+ {"setStartTime", ( PyCFunction ) Particle_setSta, METH_VARARGS,
"()- Sets particle start time"},
- {"getEndTime",(PyCFunction)Particle_getEnd,
- METH_NOARGS,"()-Return particle end time"},
- {"setEndTime",(PyCFunction)Particle_setEnd, METH_VARARGS,
+ {"getEndTime", ( PyCFunction ) Particle_getEnd,
+ METH_NOARGS, "()-Return particle end time"},
+ {"setEndTime", ( PyCFunction ) Particle_setEnd, METH_VARARGS,
"()- Sets particle end time"},
- {"getLifetime",(PyCFunction)Particle_getLifetime,
- METH_NOARGS,"()-Return particle life time"},
- {"setLifetime",(PyCFunction)Particle_setLifetime, METH_VARARGS,
+ {"getLifetime", ( PyCFunction ) Particle_getLifetime,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setLifetime", ( PyCFunction ) Particle_setLifetime, METH_VARARGS,
"()- Sets particle life time "},
- {"getNormfac",(PyCFunction)Particle_getNormfac,
- METH_NOARGS,"()-Return particle life time"},
- {"setNormfac",(PyCFunction)Particle_setNormfac, METH_VARARGS,
+ {"getNormfac", ( PyCFunction ) Particle_getNormfac,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setNormfac", ( PyCFunction ) Particle_setNormfac, METH_VARARGS,
"()- Sets particle life time "},
- {"getObfac",(PyCFunction)Particle_getObfac,
- METH_NOARGS,"()-Return particle life time"},
- {"setObfac",(PyCFunction)Particle_setObfac, METH_VARARGS,
+ {"getObfac", ( PyCFunction ) Particle_getObfac,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setObfac", ( PyCFunction ) Particle_setObfac, METH_VARARGS,
"()- Sets particle life time "},
- {"getRandfac",(PyCFunction)Particle_getRandfac,
- METH_NOARGS,"()-Return particle life time"},
- {"setRandfac",(PyCFunction)Particle_setRandfac, METH_VARARGS,
+ {"getRandfac", ( PyCFunction ) Particle_getRandfac,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setRandfac", ( PyCFunction ) Particle_setRandfac, METH_VARARGS,
"()- Sets particle life time "},
- {"getTexfac",(PyCFunction)Particle_getTexfac,
- METH_NOARGS,"()-Return particle life time"},
- {"setTexfac",(PyCFunction)Particle_setTexfac, METH_VARARGS,
+ {"getTexfac", ( PyCFunction ) Particle_getTexfac,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setTexfac", ( PyCFunction ) Particle_setTexfac, METH_VARARGS,
"()- Sets particle life time "},
- {"getRandlife",(PyCFunction)Particle_getRandlife,
- METH_NOARGS,"()-Return particle life time"},
- {"setRandlife",(PyCFunction)Particle_setRandlife, METH_VARARGS,
+ {"getRandlife", ( PyCFunction ) Particle_getRandlife,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setRandlife", ( PyCFunction ) Particle_setRandlife, METH_VARARGS,
"()- Sets particle life time "},
- {"getNabla",(PyCFunction)Particle_getNabla,
- METH_NOARGS,"()-Return particle life time"},
- {"setNabla",(PyCFunction)Particle_setNabla, METH_VARARGS,
+ {"getNabla", ( PyCFunction ) Particle_getNabla,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setNabla", ( PyCFunction ) Particle_setNabla, METH_VARARGS,
"()- Sets particle life time "},
- {"getVectsize",(PyCFunction)Particle_getVectsize,
- METH_NOARGS,"()-Return particle life time"},
- {"setVectsize",(PyCFunction)Particle_setVectsize, METH_VARARGS,
+ {"getVectsize", ( PyCFunction ) Particle_getVectsize,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setVectsize", ( PyCFunction ) Particle_setVectsize, METH_VARARGS,
"()- Sets particle life time "},
- {"getTotpart",(PyCFunction)Particle_getTotpart,
- METH_NOARGS,"()-Return particle life time"},
- {"setTotpart",(PyCFunction)Particle_setTotpart, METH_VARARGS,
+ {"getTotpart", ( PyCFunction ) Particle_getTotpart,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setTotpart", ( PyCFunction ) Particle_setTotpart, METH_VARARGS,
"()- Sets particle life time "},
- {"getTotkey",(PyCFunction)Particle_getTotkey,
- METH_NOARGS,"()-Return particle life time"},
- {"setTotkey",(PyCFunction)Particle_setTotkey, METH_VARARGS,
+ {"getTotkey", ( PyCFunction ) Particle_getTotkey,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setTotkey", ( PyCFunction ) Particle_setTotkey, METH_VARARGS,
"()- Sets particle life time "},
- {"getSeed",(PyCFunction)Particle_getSeed,
- METH_NOARGS,"()-Return particle life time"},
- {"setSeed",(PyCFunction)Particle_setSeed, METH_VARARGS,
+ {"getSeed", ( PyCFunction ) Particle_getSeed,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setSeed", ( PyCFunction ) Particle_setSeed, METH_VARARGS,
"()- Sets particle life time "},
- {"getForce",(PyCFunction)Particle_getForce,
- METH_NOARGS,"()-Return particle life time"},
- {"setForce",(PyCFunction)Particle_setForce, METH_VARARGS,
+ {"getForce", ( PyCFunction ) Particle_getForce,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setForce", ( PyCFunction ) Particle_setForce, METH_VARARGS,
"()- Sets particle life time "},
- {"getMult",(PyCFunction)Particle_getMult,
- METH_NOARGS,"()-Return particle life time"},
- {"setMult",(PyCFunction)Particle_setMult, METH_VARARGS,
+ {"getMult", ( PyCFunction ) Particle_getMult,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setMult", ( PyCFunction ) Particle_setMult, METH_VARARGS,
"()- Sets particle life time "},
- {"getLife",(PyCFunction)Particle_getLife,
- METH_NOARGS,"()-Return particle life time"},
- {"setLife",(PyCFunction)Particle_setLife, METH_VARARGS,
+ {"getLife", ( PyCFunction ) Particle_getLife,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setLife", ( PyCFunction ) Particle_setLife, METH_VARARGS,
"()- Sets particle life time "},
- {"getMat",(PyCFunction)Particle_getMat,
- METH_NOARGS,"()-Return particle life time"},
- {"setMat",(PyCFunction)Particle_setMat, METH_VARARGS,
+ {"getMat", ( PyCFunction ) Particle_getMat,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setMat", ( PyCFunction ) Particle_setMat, METH_VARARGS,
"()- Sets particle life time "},
- {"getChild",(PyCFunction)Particle_getChild,
- METH_NOARGS,"()-Return particle life time"},
- {"setChild",(PyCFunction)Particle_setChild, METH_VARARGS,
+ {"getChild", ( PyCFunction ) Particle_getChild,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setChild", ( PyCFunction ) Particle_setChild, METH_VARARGS,
"()- Sets particle life time "},
- {"getDefvec",(PyCFunction)Particle_getDefvec,
- METH_NOARGS,"()-Return particle life time"},
- {"setDefvec",(PyCFunction)Particle_setDefvec, METH_VARARGS,
+ {"getDefvec", ( PyCFunction ) Particle_getDefvec,
+ METH_NOARGS, "()-Return particle life time"},
+ {"setDefvec", ( PyCFunction ) Particle_setDefvec, METH_VARARGS,
"()- Sets particle life time "},
{NULL, NULL, 0, NULL}
};
@@ -129,29 +129,28 @@ static PyMethodDef BPy_Particle_methods[] = {
/* Python Particle_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Particle_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0,
- "Particle",
- sizeof (BPy_Particle),
- 0,
-
- (destructor)ParticleDeAlloc,
- 0,
- (getattrfunc)ParticleGetAttr,
- (setattrfunc)ParticleSetAttr,
- 0,
- (reprfunc)ParticleRepr,
- 0,
- 0,
- 0,
- 0,
- 0,0,0,0,0,0,
- 0,
- 0,0,0,0,0,0,
- BPy_Particle_methods,
- 0,
+PyTypeObject Particle_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0,
+ "Particle",
+ sizeof( BPy_Particle ),
+ 0,
+
+ ( destructor ) ParticleDeAlloc,
+ 0,
+ ( getattrfunc ) ParticleGetAttr,
+ ( setattrfunc ) ParticleSetAttr,
+ 0,
+ ( reprfunc ) ParticleRepr,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, 0, 0, 0, 0, 0,
+ 0,
+ 0, 0, 0, 0, 0, 0,
+ BPy_Particle_methods,
+ 0,
};
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -164,550 +163,580 @@ Functions :\n\
New(opt name) : creates a new part object with the given name (optional)\n\
Get(name) : retreives a particle with the given name (mandatory)\n\
get(name) : same as Get. Kept for compatibility reasons";
-char M_Particle_New_doc[] ="";
-char M_Particle_Get_doc[] ="xxx";
+char M_Particle_New_doc[] = "";
+char M_Particle_Get_doc[] = "xxx";
/*****************************************************************************/
/* Python method structure definition for Blender.Particle module: */
/*****************************************************************************/
struct PyMethodDef M_Particle_methods[] = {
- {"New",(PyCFunction)M_Particle_New, METH_VARARGS,M_Particle_New_doc},
- {"Get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
- {"get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Particle_New, METH_VARARGS,
+ M_Particle_New_doc},
+ {"Get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
+ {"get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Function: M_Particle_New */
/* Python equivalent: Blender.Effect.Particle.New */
/*****************************************************************************/
-PyObject *M_Particle_New(PyObject *self, PyObject *args)
+PyObject *M_Particle_New( PyObject * self, PyObject * args )
{
- int type = EFF_PARTICLE;
- BPy_Effect *pyeffect;
- Effect *bleffect = 0;
-
+ int type = EFF_PARTICLE;
+ BPy_Effect *pyeffect;
+ Effect *bleffect = 0;
- bleffect = add_effect(type);
- if (bleffect == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Effect Data in Blender"));
- pyeffect = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
+ bleffect = add_effect( type );
+ if( bleffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Effect Data in Blender" ) );
-
- if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Effect Data object"));
+ pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
- pyeffect->effect = bleffect;
- return (PyObject *)pyeffect;
- return 0;
+ if( pyeffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Effect Data object" ) );
+
+ pyeffect->effect = bleffect;
+
+ return ( PyObject * ) pyeffect;
+ return 0;
}
/*****************************************************************************/
/* Function: M_Particle_Get */
/* Python equivalent: Blender.Effect.Particle.Get */
/*****************************************************************************/
-PyObject *M_Particle_Get(PyObject *self, PyObject *args)
-{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = 0;
- Object *object_iter;
- Effect *eff;
- BPy_Particle *wanted_eff;
- int num,i;
- if (!PyArg_ParseTuple(args, "si", &name, &num ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected string int argument"));
-
- object_iter = G.main->object.first;
- if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "Scene contains no object"));
-
- while (object_iter)
- {
- if (strcmp(name,object_iter->id.name+2))
- {
- object_iter = object_iter->id.next;
+PyObject *M_Particle_Get( PyObject * self, PyObject * args )
+{
+ /*arguments : string object name
+ int : position of effect in the obj's effect list */
+ char *name = 0;
+ Object *object_iter;
+ Effect *eff;
+ BPy_Particle *wanted_eff;
+ int num, i;
+ if( !PyArg_ParseTuple( args, "si", &name, &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string int argument" ) );
+
+ object_iter = G.main->object.first;
+ if( !object_iter )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Scene contains no object" ) );
+
+ while( object_iter ) {
+ if( strcmp( name, object_iter->id.name + 2 ) ) {
+ object_iter = object_iter->id.next;
+ continue;
+ }
+
+
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ for( i = 0; i < num; i++ ) {
+ if( eff->type != EFF_PARTICLE )
continue;
- }
-
-
- if (object_iter->effect.first != NULL)
- {
- eff = object_iter->effect.first;
- for(i = 0;i<num;i++)
- {
- if (eff->type != EFF_PARTICLE)continue;
- eff = eff->next;
- if (!eff)
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,"bject"));
- }
- wanted_eff = (BPy_Particle *)PyObject_NEW(BPy_Particle, &Particle_Type);
- wanted_eff->particle = eff;
- return (PyObject*)wanted_eff;
- }
- object_iter = object_iter->id.next;
- }
- Py_INCREF(Py_None);
- return Py_None;
+ eff = eff->next;
+ if( !eff )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "bject" ) );
+ }
+ wanted_eff =
+ ( BPy_Particle * ) PyObject_NEW( BPy_Particle,
+ &Particle_Type );
+ wanted_eff->particle = eff;
+ return ( PyObject * ) wanted_eff;
+ }
+ object_iter = object_iter->id.next;
+ }
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: Particle_Init */
/*****************************************************************************/
-PyObject *Particle_Init (void)
+PyObject *Particle_Init( void )
{
- PyObject *submodule;
- Particle_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Particle",M_Particle_methods, M_Particle_doc);
- return (submodule);
+ PyObject *submodule;
+ Particle_Type.ob_type = &PyType_Type;
+ submodule =
+ Py_InitModule3( "Blender.Particle", M_Particle_methods,
+ M_Particle_doc );
+ return ( submodule );
}
/*****************************************************************************/
/* Python BPy_Particle methods: */
/*****************************************************************************/
-PyObject *Particle_getSta(BPy_Particle *self)
+PyObject *Particle_getSta( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->sta);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->sta );
}
-PyObject *Particle_setSta(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setSta( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->sta = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->sta = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getEnd(BPy_Particle *self)
+
+PyObject *Particle_getEnd( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->end);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->end );
}
-PyObject *Particle_setEnd(BPy_Particle *self,PyObject *args)
-{
+PyObject *Particle_setEnd( BPy_Particle * self, PyObject * args )
+{
float val = 0;
- PartEff*ptr = (PartEff*)self->particle;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->end = val;
- Py_INCREF(Py_None);
- return Py_None;
+ PartEff *ptr = ( PartEff * ) self->particle;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->end = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getLifetime(BPy_Particle *self)
+PyObject *Particle_getLifetime( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->lifetime);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->lifetime );
}
-PyObject *Particle_setLifetime(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setLifetime( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->lifetime = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->lifetime = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getNormfac(BPy_Particle *self)
+PyObject *Particle_getNormfac( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->normfac);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->normfac );
}
-PyObject *Particle_setNormfac(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setNormfac( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->normfac = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->normfac = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getObfac(BPy_Particle *self)
+PyObject *Particle_getObfac( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->obfac);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->obfac );
}
-PyObject *Particle_setObfac(BPy_Particle *self,PyObject *args)
-{
+PyObject *Particle_setObfac( BPy_Particle * self, PyObject * args )
+{
float val = 0;
- PartEff*ptr = (PartEff*)self->particle;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->obfac = val;
- Py_INCREF(Py_None);
- return Py_None;
+ PartEff *ptr = ( PartEff * ) self->particle;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->obfac = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getRandfac(BPy_Particle *self)
+PyObject *Particle_getRandfac( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->randfac);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->randfac );
}
-PyObject *Particle_setRandfac(BPy_Particle *self,PyObject *args)
-{
+PyObject *Particle_setRandfac( BPy_Particle * self, PyObject * args )
+{
float val = 0;
- PartEff*ptr = (PartEff*)self->particle;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->randfac = val;
- Py_INCREF(Py_None);
- return Py_None;
+ PartEff *ptr = ( PartEff * ) self->particle;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->randfac = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getTexfac(BPy_Particle *self)
+PyObject *Particle_getTexfac( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->texfac);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->texfac );
}
-PyObject *Particle_setTexfac(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setTexfac( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->texfac = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->texfac = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getRandlife(BPy_Particle *self)
+PyObject *Particle_getRandlife( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->randlife);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->randlife );
}
-PyObject *Particle_setRandlife(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setRandlife( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->randlife = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->randlife = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getNabla(BPy_Particle *self)
+PyObject *Particle_getNabla( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->nabla);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->nabla );
}
-PyObject *Particle_setNabla(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setNabla( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->nabla = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->nabla = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getVectsize(BPy_Particle *self)
+PyObject *Particle_getVectsize( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyFloat_FromDouble(ptr->vectsize);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyFloat_FromDouble( ptr->vectsize );
}
-PyObject *Particle_setVectsize(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setVectsize( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val = 0;
- if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->vectsize = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->vectsize = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getTotpart(BPy_Particle *self)
+PyObject *Particle_getTotpart( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyInt_FromLong(ptr->totpart);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyInt_FromLong( ptr->totpart );
}
-PyObject *Particle_setTotpart(BPy_Particle *self,PyObject *args)
-{
+PyObject *Particle_setTotpart( BPy_Particle * self, PyObject * args )
+{
int val = 0;
- PartEff*ptr = (PartEff*)self->particle;
- if (!PyArg_ParseTuple(args, "i", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected int argument"));
- ptr->totpart = val;
- Py_INCREF(Py_None);
- return Py_None;
+ PartEff *ptr = ( PartEff * ) self->particle;
+ if( !PyArg_ParseTuple( args, "i", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
+ ptr->totpart = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getTotkey(BPy_Particle *self)
+PyObject *Particle_getTotkey( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyInt_FromLong(ptr->totkey);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyInt_FromLong( ptr->totkey );
}
-PyObject *Particle_setTotkey(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setTotkey( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
int val = 0;
- if (!PyArg_ParseTuple(args, "i", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected int argument"));
- ptr->totkey = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "i", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
+ ptr->totkey = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getSeed(BPy_Particle *self)
+PyObject *Particle_getSeed( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return PyInt_FromLong(ptr->seed);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return PyInt_FromLong( ptr->seed );
}
-PyObject *Particle_setSeed(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setSeed( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
int val = 0;
- if (!PyArg_ParseTuple(args, "i", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected int argument"));
- ptr->seed = val;
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "i", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument" ) );
+ ptr->seed = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getForce(BPy_Particle *self)
+PyObject *Particle_getForce( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f)",ptr->force[0],ptr->force[1],ptr->force[2]);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f)", ptr->force[0], ptr->force[1],
+ ptr->force[2] );
}
-PyObject *Particle_setForce(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
+PyObject *Particle_setForce( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
float val[3];
- if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
/*
- if (!PyArg_ParseTuple(args, "fff", val,val+1,val+2 ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected three float arguments"));
- */
- ptr->force[0] = val[0];ptr->force[1] = val[1];ptr->force[2] = val[2];
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-PyObject *Particle_getMult(BPy_Particle *self)
+ if (!PyArg_ParseTuple(args, "fff", val,val+1,val+2 ))
+ return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
+ "expected three float arguments"));
+ */
+ ptr->force[0] = val[0];
+ ptr->force[1] = val[1];
+ ptr->force[2] = val[2];
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+PyObject *Particle_getMult( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f,f)",
- ptr->mult[0],ptr->mult[1],ptr->mult[2],ptr->mult[3]);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f,f)",
+ ptr->mult[0], ptr->mult[1], ptr->mult[2],
+ ptr->mult[3] );
}
-PyObject *Particle_setMult(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
- float val[4];
-if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
- val[3] = PyFloat_AsDouble(PyTuple_GetItem(args,3));
- ptr->mult[0] = val[0];ptr->mult[1] = val[1];
- ptr->mult[2] = val[2];ptr->mult[3] = val[3];
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Particle_setMult( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
+ float val[4];
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
+ val[3] = PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
+ ptr->mult[0] = val[0];
+ ptr->mult[1] = val[1];
+ ptr->mult[2] = val[2];
+ ptr->mult[3] = val[3];
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getLife(BPy_Particle *self)
+PyObject *Particle_getLife( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f,f)",
- ptr->life[0],ptr->life[1],ptr->life[2],ptr->life[3]);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f,f)",
+ ptr->life[0], ptr->life[1], ptr->life[2],
+ ptr->life[3] );
}
-PyObject *Particle_setLife(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
- float val[4];
-if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
- val[3] = PyFloat_AsDouble(PyTuple_GetItem(args,3));
- ptr->life[0] = val[0];ptr->life[1] = val[1];
- ptr->life[2] = val[2];ptr->life[3] = val[3];
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Particle_setLife( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
+ float val[4];
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
+ val[3] = PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
+ ptr->life[0] = val[0];
+ ptr->life[1] = val[1];
+ ptr->life[2] = val[2];
+ ptr->life[3] = val[3];
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getChild(BPy_Particle *self)
+PyObject *Particle_getChild( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f,f)",
- ptr->child[0],ptr->child[1],ptr->child[2],ptr->child[3]);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f,f)",
+ ptr->child[0], ptr->child[1], ptr->child[2],
+ ptr->child[3] );
}
-PyObject *Particle_setChild(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
- float val[4];
-if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
- val[3] = PyFloat_AsDouble(PyTuple_GetItem(args,3));
- ptr->child[0] = val[0];ptr->child[1] = val[1];
- ptr->child[2] = val[2];ptr->child[3] = val[3];
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Particle_setChild( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
+ float val[4];
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
+ val[3] = PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
+ ptr->child[0] = val[0];
+ ptr->child[1] = val[1];
+ ptr->child[2] = val[2];
+ ptr->child[3] = val[3];
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Particle_getMat(BPy_Particle *self)
+PyObject *Particle_getMat( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f,f)",
- ptr->mat[0],ptr->mat[1],ptr->mat[2],ptr->mat[3]);
-}
-
-
-PyObject *Particle_setMat(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
- float val[4];
-if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
- val[3] = PyFloat_AsDouble(PyTuple_GetItem(args,3));
- ptr->mat[0] = val[0];ptr->mat[1] = val[1];
- ptr->mat[2] = val[2];ptr->mat[3] = val[3];
- Py_INCREF(Py_None);
- return Py_None;
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f,f)",
+ ptr->mat[0], ptr->mat[1], ptr->mat[2],
+ ptr->mat[3] );
}
-PyObject *Particle_getDefvec(BPy_Particle *self)
+PyObject *Particle_setMat( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
+ float val[4];
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
+ val[3] = PyFloat_AsDouble( PyTuple_GetItem( args, 3 ) );
+ ptr->mat[0] = val[0];
+ ptr->mat[1] = val[1];
+ ptr->mat[2] = val[2];
+ ptr->mat[3] = val[3];
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+
+PyObject *Particle_getDefvec( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self->particle;
- return Py_BuildValue("(f,f,f)",
- ptr->defvec[0],ptr->defvec[1],ptr->defvec[2]);
+ PartEff *ptr = ( PartEff * ) self->particle;
+ return Py_BuildValue( "(f,f,f)",
+ ptr->defvec[0], ptr->defvec[1], ptr->defvec[2] );
}
-PyObject *Particle_setDefvec(BPy_Particle *self,PyObject *args)
-{
- PartEff*ptr = (PartEff*)self->particle;
- float val[3];
-if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
- val[0] = PyFloat_AsDouble(PyTuple_GetItem(args,0));
- val[1] = PyFloat_AsDouble(PyTuple_GetItem(args,1));
- val[2] = PyFloat_AsDouble(PyTuple_GetItem(args,2));
- ptr->defvec[0] = val[0];ptr->defvec[1] = val[1]; ptr->defvec[2] = val[2];
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Particle_setDefvec( BPy_Particle * self, PyObject * args )
+{
+ PartEff *ptr = ( PartEff * ) self->particle;
+ float val[3];
+ if( PyTuple_Size( args ) == 1 )
+ args = PyTuple_GetItem( args, 0 );
+ val[0] = PyFloat_AsDouble( PyTuple_GetItem( args, 0 ) );
+ val[1] = PyFloat_AsDouble( PyTuple_GetItem( args, 1 ) );
+ val[2] = PyFloat_AsDouble( PyTuple_GetItem( args, 2 ) );
+ ptr->defvec[0] = val[0];
+ ptr->defvec[1] = val[1];
+ ptr->defvec[2] = val[2];
+ Py_INCREF( Py_None );
+ return Py_None;
}
@@ -717,145 +746,148 @@ if (PyTuple_Size(args) == 1)args = PyTuple_GetItem(args,0);
/* Description: This is a callback function for the BPy_Particle type. It is */
/* the destructor function. */
/*****************************************************************************/
-void ParticleDeAlloc (BPy_Particle *self)
+void ParticleDeAlloc( BPy_Particle * self )
{
- PartEff*ptr = (PartEff*)self;
- PyObject_DEL (ptr);
+ PartEff *ptr = ( PartEff * ) self;
+ PyObject_DEL( ptr );
}
/*****************************************************************************/
/* Function: ParticleGetAttr */
-/* Description: This is a callback function for the BPy_Particle type. It is */
-/* the function that accesses BPy_Particle "member variables" and */
-/* methods. */
+/* Description: This is a callback function for the BPy_Particle type. It is */
+/* the function that accesses BPy_Particle "member variables" */
+/* and methods. */
/*****************************************************************************/
-PyObject *ParticleGetAttr (BPy_Particle *self, char *name)
-{
-
- if (strcmp (name, "seed") == 0)
- return Particle_getSeed (self);
- else if (strcmp (name, "nabla") == 0)
- return Particle_getNabla (self);
- else if (strcmp (name, "sta") == 0)
- return Particle_getSta (self);
- else if (strcmp (name, "end") == 0)
- return Particle_getEnd (self);
- else if (strcmp (name, "lifetime") == 0)
- return Particle_getLifetime (self);
- else if (strcmp (name, "normfac") == 0)
- return Particle_getNormfac (self);
- else if (strcmp (name, "obfac") == 0)
- return Particle_getObfac (self);
- else if (strcmp (name, "randfac") == 0)
- return Particle_getRandfac (self);
- else if (strcmp (name, "texfac") == 0)
- return Particle_getTexfac (self);
- else if (strcmp (name, "randlife") == 0)
- return Particle_getRandlife (self);
- else if (strcmp (name, "vectsize") == 0)
- return Particle_getVectsize (self);
- else if (strcmp (name, "totpart") == 0)
- return Particle_getTotpart (self);
- else if (strcmp (name, "force") == 0)
- return Particle_getForce (self);
- else if (strcmp (name, "mult") == 0)
- return Particle_getMult (self);
- else if (strcmp (name, "life") == 0)
- return Particle_getLife (self);
- else if (strcmp (name, "child") == 0)
- return Particle_getChild (self);
- else if (strcmp (name, "mat") == 0)
- return Particle_getMat (self);
- else if (strcmp (name, "defvec") == 0)
- return Particle_getDefvec (self);
-
-
- return Py_FindMethod(BPy_Particle_methods, (PyObject *)self, name);
+PyObject *ParticleGetAttr( BPy_Particle * self, char *name )
+{
+
+ if( strcmp( name, "seed" ) == 0 )
+ return Particle_getSeed( self );
+ else if( strcmp( name, "nabla" ) == 0 )
+ return Particle_getNabla( self );
+ else if( strcmp( name, "sta" ) == 0 )
+ return Particle_getSta( self );
+ else if( strcmp( name, "end" ) == 0 )
+ return Particle_getEnd( self );
+ else if( strcmp( name, "lifetime" ) == 0 )
+ return Particle_getLifetime( self );
+ else if( strcmp( name, "normfac" ) == 0 )
+ return Particle_getNormfac( self );
+ else if( strcmp( name, "obfac" ) == 0 )
+ return Particle_getObfac( self );
+ else if( strcmp( name, "randfac" ) == 0 )
+ return Particle_getRandfac( self );
+ else if( strcmp( name, "texfac" ) == 0 )
+ return Particle_getTexfac( self );
+ else if( strcmp( name, "randlife" ) == 0 )
+ return Particle_getRandlife( self );
+ else if( strcmp( name, "vectsize" ) == 0 )
+ return Particle_getVectsize( self );
+ else if( strcmp( name, "totpart" ) == 0 )
+ return Particle_getTotpart( self );
+ else if( strcmp( name, "force" ) == 0 )
+ return Particle_getForce( self );
+ else if( strcmp( name, "mult" ) == 0 )
+ return Particle_getMult( self );
+ else if( strcmp( name, "life" ) == 0 )
+ return Particle_getLife( self );
+ else if( strcmp( name, "child" ) == 0 )
+ return Particle_getChild( self );
+ else if( strcmp( name, "mat" ) == 0 )
+ return Particle_getMat( self );
+ else if( strcmp( name, "defvec" ) == 0 )
+ return Particle_getDefvec( self );
+
+
+ return Py_FindMethod( BPy_Particle_methods, ( PyObject * ) self,
+ name );
}
/*****************************************************************************/
/* Function: ParticleSetAttr */
-/* Description: This is a callback function for the BPy_Particle type. It is th*/
-/* function that sets Particle Data attributes (member vars) */
+/* Description: This is a callback function for the BPy_Particle type. */
+/* It is the function that sets Particle Data attributes */
+/* (member vars) */
/*****************************************************************************/
-int ParticleSetAttr (BPy_Particle *self, char *name, PyObject *value)
-{
-
- PyObject *valtuple;
- PyObject *error = NULL;
-
- valtuple = Py_BuildValue("(N)", value);
-
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "ParticleSetAttr: couldn't create PyTuple");
-
- if (strcmp (name, "seed") == 0)
- error = Particle_setSeed (self, valtuple);
- else if (strcmp (name, "nabla") == 0)
- error = Particle_setNabla (self, valtuple);
- else if (strcmp (name, "sta") == 0)
- error = Particle_setSta (self, valtuple);
- else if (strcmp (name, "end") == 0)
- error = Particle_setEnd (self, valtuple);
- else if (strcmp (name, "lifetime") == 0)
- error = Particle_setLifetime (self, valtuple);
- else if (strcmp (name, "normfac") == 0)
- error = Particle_setNormfac (self, valtuple);
- else if (strcmp (name, "obfac") == 0)
- error = Particle_setObfac (self, valtuple);
- else if (strcmp (name, "randfac") == 0)
- error = Particle_setRandfac (self, valtuple);
- else if (strcmp (name, "texfac") == 0)
- error = Particle_setTexfac (self, valtuple);
- else if (strcmp (name, "randlife") == 0)
- error = Particle_setRandlife (self, valtuple);
- else if (strcmp (name, "nabla") == 0)
- error = Particle_setNabla (self, valtuple);
- else if (strcmp (name, "vectsize") == 0)
- error = Particle_setVectsize (self, valtuple);
- else if (strcmp (name, "totpart") == 0)
- error = Particle_setTotpart (self, valtuple);
- else if (strcmp (name, "seed") == 0)
- error = Particle_setSeed (self, valtuple);
- else if (strcmp (name, "force") == 0)
- error = Particle_setForce (self, valtuple);
- else if (strcmp (name, "mult") == 0)
- error = Particle_setMult (self, valtuple);
- else if (strcmp (name, "life") == 0)
- error = Particle_setLife (self, valtuple);
- else if (strcmp (name, "child") == 0)
- error = Particle_setChild (self, valtuple);
- else if (strcmp (name, "mat") == 0)
- error = Particle_setMat (self, valtuple);
- else if (strcmp (name, "defvec") == 0)
- error = Particle_setDefvec (self, valtuple);
-
- else {
- Py_DECREF(valtuple);
-
- if ((strcmp (name, "Types") == 0) ||
- (strcmp (name, "Modes") == 0))
- return (EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed"));
-
- else
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found"));
- }
-
- /*Py_DECREF(valtuple);*/
- if (error != Py_None) return -1;
-
- Py_DECREF(Py_None);
- return 0;
+int ParticleSetAttr( BPy_Particle * self, char *name, PyObject * value )
+{
+
+ PyObject *valtuple;
+ PyObject *error = NULL;
+
+ valtuple = Py_BuildValue( "(N)", value );
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "ParticleSetAttr: couldn't create PyTuple" );
+
+ if( strcmp( name, "seed" ) == 0 )
+ error = Particle_setSeed( self, valtuple );
+ else if( strcmp( name, "nabla" ) == 0 )
+ error = Particle_setNabla( self, valtuple );
+ else if( strcmp( name, "sta" ) == 0 )
+ error = Particle_setSta( self, valtuple );
+ else if( strcmp( name, "end" ) == 0 )
+ error = Particle_setEnd( self, valtuple );
+ else if( strcmp( name, "lifetime" ) == 0 )
+ error = Particle_setLifetime( self, valtuple );
+ else if( strcmp( name, "normfac" ) == 0 )
+ error = Particle_setNormfac( self, valtuple );
+ else if( strcmp( name, "obfac" ) == 0 )
+ error = Particle_setObfac( self, valtuple );
+ else if( strcmp( name, "randfac" ) == 0 )
+ error = Particle_setRandfac( self, valtuple );
+ else if( strcmp( name, "texfac" ) == 0 )
+ error = Particle_setTexfac( self, valtuple );
+ else if( strcmp( name, "randlife" ) == 0 )
+ error = Particle_setRandlife( self, valtuple );
+ else if( strcmp( name, "nabla" ) == 0 )
+ error = Particle_setNabla( self, valtuple );
+ else if( strcmp( name, "vectsize" ) == 0 )
+ error = Particle_setVectsize( self, valtuple );
+ else if( strcmp( name, "totpart" ) == 0 )
+ error = Particle_setTotpart( self, valtuple );
+ else if( strcmp( name, "seed" ) == 0 )
+ error = Particle_setSeed( self, valtuple );
+ else if( strcmp( name, "force" ) == 0 )
+ error = Particle_setForce( self, valtuple );
+ else if( strcmp( name, "mult" ) == 0 )
+ error = Particle_setMult( self, valtuple );
+ else if( strcmp( name, "life" ) == 0 )
+ error = Particle_setLife( self, valtuple );
+ else if( strcmp( name, "child" ) == 0 )
+ error = Particle_setChild( self, valtuple );
+ else if( strcmp( name, "mat" ) == 0 )
+ error = Particle_setMat( self, valtuple );
+ else if( strcmp( name, "defvec" ) == 0 )
+ error = Particle_setDefvec( self, valtuple );
+
+ else {
+ Py_DECREF( valtuple );
+
+ if( ( strcmp( name, "Types" ) == 0 ) ||
+ ( strcmp( name, "Modes" ) == 0 ) )
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" ) );
+
+ else
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" ) );
+ }
+
+ /*Py_DECREF(valtuple); */
+ if( error != Py_None )
+ return -1;
+
+ Py_DECREF( Py_None );
+ return 0;
}
/*****************************************************************************/
/* Function: ParticlePrint */
-/* Description: This is a callback function for the BPy_Particle type. It */
+/* Description: This is a callback function for the BPy_Particle type. It */
/* particles a meaninful string to 'print' particle objects. */
/*****************************************************************************/
/*
@@ -867,42 +899,42 @@ int ParticlePrint(BPy_Particle *self, FILE *fp, int flags)
*/
/*****************************************************************************/
/* Function: ParticleRepr */
-/* Description: This is a callback function for the BPy_Particle type. It */
+/* Description: This is a callback function for the BPy_Particle type. It */
/* particles a meaninful string to represent particle objects. */
/*****************************************************************************/
-PyObject *ParticleRepr (BPy_Particle *self)
+PyObject *ParticleRepr( BPy_Particle * self )
{
- return PyString_FromString("Particle");
+ return PyString_FromString( "Particle" );
}
-PyObject* ParticleCreatePyObject (struct Effect *particle)
+PyObject *ParticleCreatePyObject( struct Effect * particle )
{
- BPy_Particle * blen_object;
+ BPy_Particle *blen_object;
- blen_object = (BPy_Particle*)PyObject_NEW (BPy_Particle, &Particle_Type);
+ blen_object =
+ ( BPy_Particle * ) PyObject_NEW( BPy_Particle,
+ &Particle_Type );
- if (blen_object == NULL)
- {
- return (NULL);
- }
+ if( blen_object == NULL ) {
+ return ( NULL );
+ }
blen_object->particle = particle;
- return ((PyObject*)blen_object);
+ return ( ( PyObject * ) blen_object );
}
-int ParticleCheckPyObject (PyObject *py_obj)
+int ParticleCheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &Particle_Type);
+ return ( py_obj->ob_type == &Particle_Type );
}
-struct Particle* ParticleFromPyObject (PyObject *py_obj)
+struct Particle *ParticleFromPyObject( PyObject * py_obj )
{
- BPy_Particle * blen_obj;
+ BPy_Particle *blen_obj;
- blen_obj = (BPy_Particle*)py_obj;
- return ((struct Particle*)blen_obj->particle);
+ blen_obj = ( BPy_Particle * ) py_obj;
+ return ( ( struct Particle * ) blen_obj->particle );
}
-
diff --git a/source/blender/python/api2_2x/Particle.h b/source/blender/python/api2_2x/Particle.h
index 04dc9abbaa4..8a91f4ef9af 100644
--- a/source/blender/python/api2_2x/Particle.h
+++ b/source/blender/python/api2_2x/Particle.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -49,8 +50,8 @@
/*****************************************************************************/
/* Python API function prototypes for the Particle module. */
/*****************************************************************************/
-PyObject *M_Particle_New (PyObject *self, PyObject *args);
-PyObject *M_Particle_Get (PyObject *self, PyObject *args);
+PyObject *M_Particle_New( PyObject * self, PyObject * args );
+PyObject *M_Particle_Get( PyObject * self, PyObject * args );
@@ -58,63 +59,63 @@ PyObject *M_Particle_Get (PyObject *self, PyObject *args);
/*****************************************************************************/
/* Python BPy_Particle methods declarations: */
/*****************************************************************************/
-PyObject *Effect_getType(BPy_Effect *self);
-PyObject *Effect_setType(BPy_Effect *self, PyObject *args);
-PyObject *Effect_getFlag(BPy_Effect *self);
-PyObject *Effect_setFlag(BPy_Effect *self, PyObject *args);
-PyObject *Particle_getSta(BPy_Particle *self);
-PyObject *Particle_setSta(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getEnd(BPy_Particle *self);
-PyObject *Particle_setEnd(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getLifetime(BPy_Particle *self);
-PyObject *Particle_setLifetime(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getNormfac(BPy_Particle *self);
-PyObject *Particle_setNormfac(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getObfac(BPy_Particle *self);
-PyObject *Particle_setObfac(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getRandfac(BPy_Particle *self);
-PyObject *Particle_setRandfac(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getTexfac(BPy_Particle *self);
-PyObject *Particle_setTexfac(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getRandlife(BPy_Particle *self);
-PyObject *Particle_setRandlife(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getNabla(BPy_Particle *self);
-PyObject *Particle_setNabla(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getVectsize(BPy_Particle *self);
-PyObject *Particle_setVectsize(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getTotpart(BPy_Particle *self);
-PyObject *Particle_setTotpart(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getTotkey(BPy_Particle *self);
-PyObject *Particle_setTotkey(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getSeed(BPy_Particle *self);
-PyObject *Particle_setSeed(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getForce(BPy_Particle *self);
-PyObject *Particle_setForce(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getMult(BPy_Particle *self);
-PyObject *Particle_setMult(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getLife(BPy_Particle *self);
-PyObject *Particle_setLife(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getMat(BPy_Particle *self);
-PyObject *Particle_setMat(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getChild(BPy_Particle *self);
-PyObject *Particle_setChild(BPy_Particle *self,PyObject*a);
-PyObject *Particle_getDefvec(BPy_Particle *self);
-PyObject *Particle_setDefvec(BPy_Particle *self,PyObject*a);
+PyObject *Effect_getType( BPy_Effect * self );
+PyObject *Effect_setType( BPy_Effect * self, PyObject * args );
+PyObject *Effect_getFlag( BPy_Effect * self );
+PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args );
+PyObject *Particle_getSta( BPy_Particle * self );
+PyObject *Particle_setSta( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getEnd( BPy_Particle * self );
+PyObject *Particle_setEnd( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getLifetime( BPy_Particle * self );
+PyObject *Particle_setLifetime( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getNormfac( BPy_Particle * self );
+PyObject *Particle_setNormfac( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getObfac( BPy_Particle * self );
+PyObject *Particle_setObfac( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getRandfac( BPy_Particle * self );
+PyObject *Particle_setRandfac( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getTexfac( BPy_Particle * self );
+PyObject *Particle_setTexfac( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getRandlife( BPy_Particle * self );
+PyObject *Particle_setRandlife( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getNabla( BPy_Particle * self );
+PyObject *Particle_setNabla( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getVectsize( BPy_Particle * self );
+PyObject *Particle_setVectsize( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getTotpart( BPy_Particle * self );
+PyObject *Particle_setTotpart( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getTotkey( BPy_Particle * self );
+PyObject *Particle_setTotkey( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getSeed( BPy_Particle * self );
+PyObject *Particle_setSeed( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getForce( BPy_Particle * self );
+PyObject *Particle_setForce( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getMult( BPy_Particle * self );
+PyObject *Particle_setMult( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getLife( BPy_Particle * self );
+PyObject *Particle_setLife( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getMat( BPy_Particle * self );
+PyObject *Particle_setMat( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getChild( BPy_Particle * self );
+PyObject *Particle_setChild( BPy_Particle * self, PyObject * a );
+PyObject *Particle_getDefvec( BPy_Particle * self );
+PyObject *Particle_setDefvec( BPy_Particle * self, PyObject * a );
/*****************************************************************************/
/* Python Particle_Type callback function prototypes: */
/*****************************************************************************/
-void ParticleDeAlloc (BPy_Particle *msh);
+void ParticleDeAlloc( BPy_Particle * msh );
//int ParticlePrint (BPy_Particle *msh, FILE *fp, int flags);
-int ParticleSetAttr (BPy_Particle *msh, char *name, PyObject *v);
-PyObject *ParticleGetAttr (BPy_Particle *msh, char *name);
-PyObject *ParticleRepr (BPy_Particle *msh);
-PyObject* ParticleCreatePyObject (struct Effect *particle);
-int ParticleCheckPyObject (PyObject *py_obj);
-struct Particle* ParticleFromPyObject (PyObject *py_obj);
+int ParticleSetAttr( BPy_Particle * msh, char *name, PyObject * v );
+PyObject *ParticleGetAttr( BPy_Particle * msh, char *name );
+PyObject *ParticleRepr( BPy_Particle * msh );
+PyObject *ParticleCreatePyObject( struct Effect *particle );
+int ParticleCheckPyObject( PyObject * py_obj );
+struct Particle *ParticleFromPyObject( PyObject * py_obj );
-#endif /* EXPP_PARTICLE_H */
+#endif /* EXPP_PARTICLE_H */
diff --git a/source/blender/python/api2_2x/Registry.c b/source/blender/python/api2_2x/Registry.c
index 4fe8baf9387..c4de504451e 100644
--- a/source/blender/python/api2_2x/Registry.c
+++ b/source/blender/python/api2_2x/Registry.c
@@ -36,111 +36,112 @@
/* Function: M_Registry_Keys */
/* Python equivalent: Blender.Registry.Keys */
/*****************************************************************************/
-PyObject *M_Registry_Keys (PyObject *self)
+PyObject *M_Registry_Keys( PyObject * self )
{
- PyObject *pydict = NULL;
+ PyObject *pydict = NULL;
- if (!bpy_registryDict)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "No Registry dictionary found!");
+ if( !bpy_registryDict )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "No Registry dictionary found!" );
- pydict = PyDict_Keys (bpy_registryDict);
+ pydict = PyDict_Keys( bpy_registryDict );
- if (!pydict)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Registry_Keys: couldn't get keys");
+ if( !pydict )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Registry_Keys: couldn't get keys" );
- return pydict;
+ return pydict;
}
/*****************************************************************************/
/* Function: M_Registry_GetKey */
/* Python equivalent: Blender.Registry.GetKey */
/*****************************************************************************/
-static PyObject *M_Registry_GetKey (PyObject *self, PyObject *args)
+static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args )
{
- PyObject *pyentry = NULL;
- PyObject *pydict = NULL;
+ PyObject *pyentry = NULL;
+ PyObject *pydict = NULL;
- if (!bpy_registryDict)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "No Registry dictionary found!");
+ if( !bpy_registryDict )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "No Registry dictionary found!" );
- if (!PyArg_ParseTuple (args, "O!", &PyString_Type, &pyentry))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string");
+ if( !PyArg_ParseTuple( args, "O!", &PyString_Type, &pyentry ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string" );
- pydict = PyDict_GetItem (bpy_registryDict, pyentry); /* borrowed ... */
+ pydict = PyDict_GetItem( bpy_registryDict, pyentry ); /* borrowed ... */
- if (!pydict)
+ if( !pydict )
/* return EXPP_ReturnPyObjError (PyExc_KeyError,
"no such key in the Registry"); */
- pydict = Py_None; /* better to return None than an error */
+ pydict = Py_None; /* better to return None than an error */
- Py_INCREF (pydict); /* ... so we incref it */
- /* should we copy the dict instead? */
- return pydict;
+ Py_INCREF( pydict ); /* ... so we incref it */
+ /* should we copy the dict instead? */
+ return pydict;
}
/*****************************************************************************/
/* Function: M_Registry_SetKey */
/* Python equivalent: Blender.Registry.SetKey */
/*****************************************************************************/
-static PyObject *M_Registry_SetKey (PyObject *self, PyObject *args)
+static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args )
{
- PyObject *pystr = NULL;
- PyObject *pydict = NULL;
+ PyObject *pystr = NULL;
+ PyObject *pydict = NULL;
- if (!bpy_registryDict)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "No Registry dictionary found!");
+ if( !bpy_registryDict )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "No Registry dictionary found!" );
- if (!PyArg_ParseTuple (args, "O!O!",
- &PyString_Type, &pystr, &PyDict_Type, &pydict))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string and a dictionary");
+ if( !PyArg_ParseTuple( args, "O!O!",
+ &PyString_Type, &pystr, &PyDict_Type,
+ &pydict ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string and a dictionary" );
- if (PyDict_SetItem (bpy_registryDict, pystr, pydict)) /* 0 on success */
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Registry_SetKey: couldn't update the Registry dict");
+ if( PyDict_SetItem( bpy_registryDict, pystr, pydict ) ) /* 0 on success */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Registry_SetKey: couldn't update the Registry dict" );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: M_Registry_RemoveKey */
/* Python equivalent: Blender.Registry.RemoveKey */
/*****************************************************************************/
-static PyObject *M_Registry_RemoveKey (PyObject *self, PyObject *args)
+static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args )
{
- PyObject *pystr = NULL;
+ PyObject *pystr = NULL;
- if (!bpy_registryDict)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "No Registry dictionary found!");
+ if( !bpy_registryDict )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "No Registry dictionary found!" );
- if (!PyArg_ParseTuple (args, "O!", &PyString_Type, &pystr))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string");
+ if( !PyArg_ParseTuple( args, "O!", &PyString_Type, &pystr ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string" );
- if (PyDict_DelItem (bpy_registryDict, pystr)) /* returns 0 on success */
- return EXPP_ReturnPyObjError (PyExc_KeyError,
- "no such key in the Registry");
+ if( PyDict_DelItem( bpy_registryDict, pystr ) ) /* returns 0 on success */
+ return EXPP_ReturnPyObjError( PyExc_KeyError,
+ "no such key in the Registry" );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
/* Function: Registry_Init */
/*****************************************************************************/
-PyObject *Registry_Init (void)
+PyObject *Registry_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- submodule = Py_InitModule3("Blender.Registry", M_Registry_methods,
- M_Registry_doc);
+ submodule = Py_InitModule3( "Blender.Registry", M_Registry_methods,
+ M_Registry_doc );
- return submodule;
+ return submodule;
}
diff --git a/source/blender/python/api2_2x/Registry.h b/source/blender/python/api2_2x/Registry.h
index 4436b8cc7e9..1853b957413 100644
--- a/source/blender/python/api2_2x/Registry.h
+++ b/source/blender/python/api2_2x/Registry.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -53,10 +54,10 @@ PyObject *bpy_registryDict = NULL;
/*****************************************************************************/
/* Python API function prototypes for the Registry module. */
/*****************************************************************************/
-static PyObject *M_Registry_Keys (PyObject *self);
-static PyObject *M_Registry_GetKey (PyObject *self, PyObject *args);
-static PyObject *M_Registry_SetKey (PyObject *self, PyObject *args);
-static PyObject *M_Registry_RemoveKey (PyObject *self, PyObject *args);
+static PyObject *M_Registry_Keys( PyObject * self );
+static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args );
+static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args );
+static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -64,36 +65,38 @@ static PyObject *M_Registry_RemoveKey (PyObject *self, PyObject *args);
/* Blender.Registry.__doc__ */
/*****************************************************************************/
char M_Registry_doc[] =
-"The Blender Registry module (persistent data cache)\n\n\
+ "The Blender Registry module (persistent data cache)\n\n\
Use this module to store configuration data that a script can reload\n\
when it is executed again.\n";
char M_Registry_Keys_doc[] =
-"() - Get all keys in the Registry dictionary.\n\n\
+ "() - Get all keys in the Registry dictionary.\n\n\
Each key references another dict with saved data from a specific script.\n";
char M_Registry_GetKey_doc[] =
-"(name) - Get a specific entry (dict) from the Registry dictionary\n\
+ "(name) - Get a specific entry (dict) from the Registry dictionary\n\
(name) - a string that references a specific script.\n";
char M_Registry_SetKey_doc[] =
-"(key, dict) - Store an entry in the Registry dictionary.\n\
+ "(key, dict) - Store an entry in the Registry dictionary.\n\
If an entry with the same 'key' already exists, it is substituted.\n\
(key) - the string to use as a key for the dict being saved.\n\
(dict) - a dictionary with the data to be stored.\n";
char M_Registry_RemoveKey_doc[] =
-"(key) - Remove the dict with key 'key' from the Registry.\n";
+ "(key) - Remove the dict with key 'key' from the Registry.\n";
/*****************************************************************************/
/* Python method structure definition for Blender.Registry module: */
/*****************************************************************************/
struct PyMethodDef M_Registry_methods[] = {
- {"Keys", (PyCFunction)M_Registry_Keys, METH_VARARGS, M_Registry_Keys_doc},
- {"GetKey", M_Registry_GetKey, METH_VARARGS, M_Registry_GetKey_doc},
- {"SetKey", M_Registry_SetKey, METH_VARARGS, M_Registry_SetKey_doc},
- {"RemoveKey", M_Registry_RemoveKey, METH_VARARGS, M_Registry_RemoveKey_doc},
- {NULL, NULL, 0, NULL}
+ {"Keys", ( PyCFunction ) M_Registry_Keys, METH_VARARGS,
+ M_Registry_Keys_doc},
+ {"GetKey", M_Registry_GetKey, METH_VARARGS, M_Registry_GetKey_doc},
+ {"SetKey", M_Registry_SetKey, METH_VARARGS, M_Registry_SetKey_doc},
+ {"RemoveKey", M_Registry_RemoveKey, METH_VARARGS,
+ M_Registry_RemoveKey_doc},
+ {NULL, NULL, 0, NULL}
};
-#endif /* EXPP_REGISTRY_H */
+#endif /* EXPP_REGISTRY_H */
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index a730a92f9ff..b6d7a5fe358 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -35,15 +35,15 @@
#include <BKE_scene.h>
#include <BKE_library.h>
#include <BLI_blenlib.h>
-#include <BSE_drawview.h> /* for play_anim */
-#include <BSE_headerbuttons.h> /* for copy_scene */
-#include <BIF_drawscene.h> /* for set_scene */
-#include <BIF_space.h> /* for copy_view3d_lock() */
-#include <BIF_screen.h> /* curarea */
-#include <DNA_screen_types.h> /* SPACE_VIEW3D, SPACE_SEQ */
+#include <BSE_drawview.h> /* for play_anim */
+#include <BSE_headerbuttons.h> /* for copy_scene */
+#include <BIF_drawscene.h> /* for set_scene */
+#include <BIF_space.h> /* for copy_view3d_lock() */
+#include <BIF_screen.h> /* curarea */
+#include <DNA_screen_types.h> /* SPACE_VIEW3D, SPACE_SEQ */
#include <DNA_scriptlink_types.h>
-#include <MEM_guardedalloc.h> /* for MEM_callocN */
-#include <mydevice.h> /* for #define REDRAW */
+#include <MEM_guardedalloc.h> /* for MEM_callocN */
+#include <mydevice.h> /* for #define REDRAW */
#include "Object.h"
#include "bpy_types.h"
@@ -54,227 +54,237 @@
#include "Scene.h"
-static Base *EXPP_Scene_getObjectBase (Scene *scene, Object *object);
-PyObject *M_Object_Get (PyObject *self, PyObject *args); /* from Object.c */
+static Base *EXPP_Scene_getObjectBase( Scene * scene, Object * object );
+PyObject *M_Object_Get( PyObject * self, PyObject * args ); /* from Object.c */
-//----------------------------------- Python BPy_Scene defaults----------------------------------------------------------
+//----------------------------------- Python BPy_Scene defaults------------
#define EXPP_SCENE_FRAME_MAX 18000
#define EXPP_SCENE_RENDER_WINRESOLUTION_MIN 4
#define EXPP_SCENE_RENDER_WINRESOLUTION_MAX 10000
-//-----------------------Python API function prototypes for the Scene module------------------------------------
-static PyObject *M_Scene_New (PyObject *self, PyObject *args, PyObject *keywords);
-static PyObject *M_Scene_Get (PyObject *self, PyObject *args);
-static PyObject *M_Scene_GetCurrent (PyObject *self);
-static PyObject *M_Scene_Unlink (PyObject *self, PyObject *arg);
-//-----------------------Scene module doc strings---------------------------------------------------------------------------
-static char M_Scene_doc[] =
-"The Blender.Scene submodule";
+//-----------------------Python API function prototypes for the Scene module--
+static PyObject *M_Scene_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Scene_Get( PyObject * self, PyObject * args );
+static PyObject *M_Scene_GetCurrent( PyObject * self );
+static PyObject *M_Scene_Unlink( PyObject * self, PyObject * arg );
+//-----------------------Scene module doc strings-----------------------------
+static char M_Scene_doc[] = "The Blender.Scene submodule";
static char M_Scene_New_doc[] =
-"(name = 'Scene') - Create a new Scene called 'name' in Blender.";
+ "(name = 'Scene') - Create a new Scene called 'name' in Blender.";
static char M_Scene_Get_doc[] =
-"(name = None) - Return the scene called 'name'. If 'name' is None, return a list with all Scenes.";
+ "(name = None) - Return the scene called 'name'. If 'name' is None, return a list with all Scenes.";
static char M_Scene_GetCurrent_doc[] =
-"() - Return the currently active Scene in Blender.";
+ "() - Return the currently active Scene in Blender.";
static char M_Scene_Unlink_doc[] =
-"(scene) - Unlink (delete) scene 'Scene' from Blender. (scene) is of type Blender scene.";
-//----------------------Scene module method def---------------------------------------------------------------------------
+ "(scene) - Unlink (delete) scene 'Scene' from Blender. (scene) is of type Blender scene.";
+//----------------------Scene module method def----------------------------
struct PyMethodDef M_Scene_methods[] = {
- {"New",(PyCFunction)M_Scene_New, METH_VARARGS|METH_KEYWORDS,
- M_Scene_New_doc},
- {"Get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
- {"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
- {"GetCurrent",(PyCFunction)M_Scene_GetCurrent,
- METH_NOARGS, M_Scene_GetCurrent_doc},
- {"getCurrent",(PyCFunction)M_Scene_GetCurrent,
- METH_NOARGS, M_Scene_GetCurrent_doc},
- {"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
- {"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
+ {"New", ( PyCFunction ) M_Scene_New, METH_VARARGS | METH_KEYWORDS,
+ M_Scene_New_doc},
+ {"Get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
+ {"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc},
+ {"GetCurrent", ( PyCFunction ) M_Scene_GetCurrent,
+ METH_NOARGS, M_Scene_GetCurrent_doc},
+ {"getCurrent", ( PyCFunction ) M_Scene_GetCurrent,
+ METH_NOARGS, M_Scene_GetCurrent_doc},
+ {"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
+ {"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc},
{NULL, NULL, 0, NULL}
};
-//-----------------------BPy_Scene method declarations-----------------------------------------------------------------
-static PyObject *Scene_getName(BPy_Scene *self);
-static PyObject *Scene_setName(BPy_Scene *self, PyObject *arg);
-static PyObject *Scene_copy(BPy_Scene *self, PyObject *arg);
-static PyObject *Scene_makeCurrent(BPy_Scene *self);
-static PyObject *Scene_update(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_link(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_unlink(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_getChildren(BPy_Scene *self);
-static PyObject *Scene_getCurrentCamera(BPy_Scene *self);
-static PyObject *Scene_setCurrentCamera(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_getRenderingContext(BPy_Scene *self);
-static PyObject *Scene_getRadiosityContext(BPy_Scene *self);
-static PyObject *Scene_getScriptLinks(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_addScriptLink(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_clearScriptLinks(BPy_Scene *self);
-static PyObject *Scene_play(BPy_Scene *self, PyObject *args);
+//-----------------------BPy_Scene method declarations--------------------
+static PyObject *Scene_getName( BPy_Scene * self );
+static PyObject *Scene_setName( BPy_Scene * self, PyObject * arg );
+static PyObject *Scene_copy( BPy_Scene * self, PyObject * arg );
+static PyObject *Scene_makeCurrent( BPy_Scene * self );
+static PyObject *Scene_update( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_link( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_getChildren( BPy_Scene * self );
+static PyObject *Scene_getCurrentCamera( BPy_Scene * self );
+static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_getRenderingContext( BPy_Scene * self );
+static PyObject *Scene_getRadiosityContext( BPy_Scene * self );
+static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_clearScriptLinks( BPy_Scene * self );
+static PyObject *Scene_play( BPy_Scene * self, PyObject * args );
//deprecated methods
-static PyObject *Scene_currentFrame(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_getWinSize(BPy_Scene *self);
-static PyObject *Scene_setWinSize(BPy_Scene *self, PyObject *arg);
-static PyObject *Scene_startFrame(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_endFrame(BPy_Scene *self, PyObject *args);
-static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args);
-static PyObject *Scene_getRenderdir(BPy_Scene *self);
-static PyObject *Scene_getBackbufdir(BPy_Scene *self);
+static PyObject *Scene_currentFrame( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_getWinSize( BPy_Scene * self );
+static PyObject *Scene_setWinSize( BPy_Scene * self, PyObject * arg );
+static PyObject *Scene_startFrame( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_endFrame( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_frameSettings( BPy_Scene * self, PyObject * args );
+static PyObject *Scene_getRenderdir( BPy_Scene * self );
+static PyObject *Scene_getBackbufdir( BPy_Scene * self );
//internal
-static void Scene_dealloc (BPy_Scene *self);
-static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *v);
-static int Scene_compare (BPy_Scene *a, BPy_Scene *b);
-static PyObject *Scene_getAttr (BPy_Scene *self, char *name);
-static PyObject *Scene_repr (BPy_Scene *self);
-//-----------------------BPy_Scene method def-------------------------------------------------------------------------------
+static void Scene_dealloc( BPy_Scene * self );
+static int Scene_setAttr( BPy_Scene * self, char *name, PyObject * v );
+static int Scene_compare( BPy_Scene * a, BPy_Scene * b );
+static PyObject *Scene_getAttr( BPy_Scene * self, char *name );
+static PyObject *Scene_repr( BPy_Scene * self );
+//-----------------------BPy_Scene method def------------------------------
static PyMethodDef BPy_Scene_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Scene_getName, METH_NOARGS,
- "() - Return Scene name"},
- {"setName", (PyCFunction)Scene_setName, METH_VARARGS,
- "(str) - Change Scene name"},
- {"copy", (PyCFunction)Scene_copy, METH_VARARGS,
- "(duplicate_objects = 1) - Return a copy of this scene\n"
- "The optional argument duplicate_objects defines how the scene\n"
- "children are duplicated:\n\t0: Link Objects\n\t1: Link Object Data"
- "\n\t2: Full copy\n"},
- {"makeCurrent", (PyCFunction)Scene_makeCurrent, METH_NOARGS,
- "() - Make self the current scene"},
- {"update", (PyCFunction)Scene_update, METH_VARARGS,
- "(full = 0) - Update scene self.\n"
- "full = 0: sort the base list of objects."
- "full = 1: full update -- also regroups, does ipos, ikas, keys"},
- {"link", (PyCFunction)Scene_link, METH_VARARGS,
- "(obj) - Link Object obj to this scene"},
- {"unlink", (PyCFunction)Scene_unlink, METH_VARARGS,
- "(obj) - Unlink Object obj from this scene"},
- {"getChildren", (PyCFunction)Scene_getChildren, METH_NOARGS,
- "() - Return list of all objects linked to scene self"},
- {"getCurrentCamera", (PyCFunction)Scene_getCurrentCamera, METH_NOARGS,
- "() - Return current active Camera"},
- {"getScriptLinks", (PyCFunction)Scene_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this scene's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged, OnLoad or Redraw."},
- {"addScriptLink", (PyCFunction)Scene_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new scene scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged, OnLoad or Redraw."},
- {"clearScriptLinks", (PyCFunction)Scene_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this scene."},
- {"setCurrentCamera", (PyCFunction)Scene_setCurrentCamera, METH_VARARGS,
- "() - Set the currently active Camera"},
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Scene_getName, METH_NOARGS,
+ "() - Return Scene name"},
+ {"setName", ( PyCFunction ) Scene_setName, METH_VARARGS,
+ "(str) - Change Scene name"},
+ {"copy", ( PyCFunction ) Scene_copy, METH_VARARGS,
+ "(duplicate_objects = 1) - Return a copy of this scene\n"
+ "The optional argument duplicate_objects defines how the scene\n"
+ "children are duplicated:\n\t0: Link Objects\n\t1: Link Object Data"
+ "\n\t2: Full copy\n"},
+ {"makeCurrent", ( PyCFunction ) Scene_makeCurrent, METH_NOARGS,
+ "() - Make self the current scene"},
+ {"update", ( PyCFunction ) Scene_update, METH_VARARGS,
+ "(full = 0) - Update scene self.\n"
+ "full = 0: sort the base list of objects."
+ "full = 1: full update -- also regroups, does ipos, ikas, keys"},
+ {"link", ( PyCFunction ) Scene_link, METH_VARARGS,
+ "(obj) - Link Object obj to this scene"},
+ {"unlink", ( PyCFunction ) Scene_unlink, METH_VARARGS,
+ "(obj) - Unlink Object obj from this scene"},
+ {"getChildren", ( PyCFunction ) Scene_getChildren, METH_NOARGS,
+ "() - Return list of all objects linked to scene self"},
+ {"getCurrentCamera", ( PyCFunction ) Scene_getCurrentCamera,
+ METH_NOARGS,
+ "() - Return current active Camera"},
+ {"getScriptLinks", ( PyCFunction ) Scene_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this scene's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged, OnLoad or Redraw."},
+ {"addScriptLink", ( PyCFunction ) Scene_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new scene scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged, OnLoad or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) Scene_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this scene."},
+ {"setCurrentCamera", ( PyCFunction ) Scene_setCurrentCamera,
+ METH_VARARGS,
+ "() - Set the currently active Camera"},
//DEPRECATED
- {"getWinSize", (PyCFunction)Scene_getWinSize, METH_NOARGS,
- "() - Return Render window [x,y] dimensions"},
- {"setWinSize", (PyCFunction)Scene_setWinSize, METH_VARARGS,
- "(str) - Change Render window [x,y] dimensions"},
- {"startFrame", (PyCFunction)Scene_startFrame, METH_VARARGS,
- "(frame) - If frame is given, the start frame is set and"
- "\nreturned in any case"},
- {"endFrame", (PyCFunction)Scene_endFrame, METH_VARARGS,
- "(frame) - If frame is given, the end frame is set and"
- "\nreturned in any case"},
- {"frameSettings", (PyCFunction)Scene_frameSettings, METH_VARARGS,
- "(start, end, current) - Sets or retrieves the Scene's frame"
- " settings.\nIf the frame arguments are specified, they are set. "
- "A tuple (start, end, current) is returned in any case."},
- {"getRenderdir", (PyCFunction)Scene_getRenderdir, METH_NOARGS,
- "() - Return directory where rendered images are saved to"},
- {"getBackbufdir", (PyCFunction)Scene_getBackbufdir, METH_NOARGS,
- "() - Return location of the backbuffer image"},
- {"getRenderingContext", (PyCFunction)Scene_getRenderingContext, METH_NOARGS,
- "() - Get the rendering context for the scene and return it as a BPy_RenderData"},
- {"getRadiosityContext", (PyCFunction)Scene_getRadiosityContext, METH_NOARGS,
- "() - Get the radiosity context for this scene."},
- {"currentFrame", (PyCFunction)Scene_currentFrame, METH_VARARGS,
- "(frame) - If frame is given, the current frame is set and"
- "\nreturned in any case"},
- {"play", (PyCFunction)Scene_play, METH_VARARGS,
- "(mode = 0, win = VIEW3D) - Play realtime animation in Blender"
- " (not rendered).\n"
- "(mode) - int:\n"
- "\t0 - keep playing in biggest given 'win';\n"
- "\t1 - keep playing in all 'win', VIEW3D and SEQ windows;\n"
- "\t2 - play once in biggest given 'win';\n"
- "\t3 - play once in all 'win', VIEW3D and SEQ windows.\n"
- "(win) - int: see Blender.Window.Types. Only these are meaningful here:"
- "VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But others are also accepted, "
- "since they can be used just as an interruptible timer. If 'win' is not"
- "available or invalid, VIEW3D is tried, then any bigger window."
- "Returns 0 for normal exit or 1 when canceled by user input."},
+ {"getWinSize", ( PyCFunction ) Scene_getWinSize, METH_NOARGS,
+ "() - Return Render window [x,y] dimensions"},
+ {"setWinSize", ( PyCFunction ) Scene_setWinSize, METH_VARARGS,
+ "(str) - Change Render window [x,y] dimensions"},
+ {"startFrame", ( PyCFunction ) Scene_startFrame, METH_VARARGS,
+ "(frame) - If frame is given, the start frame is set and"
+ "\nreturned in any case"},
+ {"endFrame", ( PyCFunction ) Scene_endFrame, METH_VARARGS,
+ "(frame) - If frame is given, the end frame is set and"
+ "\nreturned in any case"},
+ {"frameSettings", ( PyCFunction ) Scene_frameSettings, METH_VARARGS,
+ "(start, end, current) - Sets or retrieves the Scene's frame"
+ " settings.\nIf the frame arguments are specified, they are set. "
+ "A tuple (start, end, current) is returned in any case."},
+ {"getRenderdir", ( PyCFunction ) Scene_getRenderdir, METH_NOARGS,
+ "() - Return directory where rendered images are saved to"},
+ {"getBackbufdir", ( PyCFunction ) Scene_getBackbufdir, METH_NOARGS,
+ "() - Return location of the backbuffer image"},
+ {"getRenderingContext", ( PyCFunction ) Scene_getRenderingContext,
+ METH_NOARGS,
+ "() - Get the rendering context for the scene and return it as a BPy_RenderData"},
+ {"getRadiosityContext", ( PyCFunction ) Scene_getRadiosityContext,
+ METH_NOARGS,
+ "() - Get the radiosity context for this scene."},
+ {"currentFrame", ( PyCFunction ) Scene_currentFrame, METH_VARARGS,
+ "(frame) - If frame is given, the current frame is set and"
+ "\nreturned in any case"},
+ {"play", ( PyCFunction ) Scene_play, METH_VARARGS,
+ "(mode = 0, win = VIEW3D) - Play realtime animation in Blender"
+ " (not rendered).\n"
+ "(mode) - int:\n"
+ "\t0 - keep playing in biggest given 'win';\n"
+ "\t1 - keep playing in all 'win', VIEW3D and SEQ windows;\n"
+ "\t2 - play once in biggest given 'win';\n"
+ "\t3 - play once in all 'win', VIEW3D and SEQ windows.\n"
+ "(win) - int: see Blender.Window.Types. Only these are meaningful here:"
+ "VIEW3D, SEQ, IPO, ACTION, NLA, SOUND. But others are also accepted, "
+ "since they can be used just as an interruptible timer. If 'win' is not"
+ "available or invalid, VIEW3D is tried, then any bigger window."
+ "Returns 0 for normal exit or 1 when canceled by user input."},
{NULL, NULL, 0, NULL}
};
-//-----------------------BPy_Scene method def-------------------------------------------------------------------------
-PyTypeObject Scene_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Scene", /* tp_name */
- sizeof (BPy_Scene), /* tp_basicsize */
- 0, /* tp_itemsize */
+//-----------------------BPy_Scene method def------------------------------
+PyTypeObject Scene_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Scene", /* tp_name */
+ sizeof( BPy_Scene ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Scene_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Scene_getAttr, /* tp_getattr */
- (setattrfunc)Scene_setAttr, /* tp_setattr */
- (cmpfunc)Scene_compare, /* tp_compare */
- (reprfunc)Scene_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_Scene_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) Scene_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Scene_getAttr, /* tp_getattr */
+ ( setattrfunc ) Scene_setAttr, /* tp_setattr */
+ ( cmpfunc ) Scene_compare, /* tp_compare */
+ ( reprfunc ) Scene_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_Scene_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//-----------------------Scene module Init())--------------------------------------------------------------------------------
-PyObject *Scene_Init (void)
+//-----------------------Scene module Init())-----------------------------
+PyObject *Scene_Init( void )
{
- PyObject *submodule;
- PyObject *dict;
+ PyObject *submodule;
+ PyObject *dict;
Scene_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Scene", M_Scene_methods, M_Scene_doc);
+ submodule =
+ Py_InitModule3( "Blender.Scene", M_Scene_methods,
+ M_Scene_doc );
- dict = PyModule_GetDict (submodule);
- PyDict_SetItemString (dict, "Render", Render_Init ());
- PyDict_SetItemString (dict, "Radio", Radio_Init ());
+ dict = PyModule_GetDict( submodule );
+ PyDict_SetItemString( dict, "Render", Render_Init( ) );
+ PyDict_SetItemString( dict, "Radio", Radio_Init( ) );
return submodule;
}
-//-----------------------Scene module internal callbacks------------------------------------------------------------
-//-----------------------dealloc-----------------------------------------------------------------------------------------------------
-static void Scene_dealloc (BPy_Scene *self)
+
+//-----------------------Scene module internal callbacks------------------
+//-----------------------dealloc------------------------------------------
+static void Scene_dealloc( BPy_Scene * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-//-----------------------getAttr-----------------------------------------------------------------------------------------------------
-static PyObject *Scene_getAttr (BPy_Scene *self, char *name)
+
+//-----------------------getAttr----------------------------------------
+static PyObject *Scene_getAttr( BPy_Scene * self, char *name )
{
PyObject *attr = Py_None;
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->scene->id.name+2);
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->scene->id.name + 2 );
- else if (strcmp(name, "__members__") == 0)
- attr = Py_BuildValue("[s]", "name");
+ else if( strcmp( name, "__members__" ) == 0 )
+ attr = Py_BuildValue( "[s]", "name" );
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- if (attr != Py_None) return attr; /* member attribute found, return it */
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
/* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Scene_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Scene_methods, ( PyObject * ) self, name );
}
-//-----------------------setAttr-----------------------------------------------------------------------------------------------------
-static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *value)
+
+//-----------------------setAttr----------------------------------------
+static int Scene_setAttr( BPy_Scene * self, char *name, PyObject * value )
{
- PyObject *valtuple;
+ PyObject *valtuple;
PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
@@ -284,191 +294,204 @@ static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *value)
/* First we put "value" in a tuple, because we want to pass it to functions
* that only accept PyTuples. Using "N" doesn't increment value's ref count */
- valtuple = Py_BuildValue("(O)", value);
+ valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple) /* everything OK with our PyObject? */
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "SceneSetAttr: couldn't create PyTuple");
+ if( !valtuple ) /* everything OK with our PyObject? */
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "SceneSetAttr: couldn't create PyTuple" );
/* Now we just compare "name" with all possible BPy_Scene member variables */
- if (strcmp (name, "name") == 0)
- error = Scene_setName (self, valtuple);
+ if( strcmp( name, "name" ) == 0 )
+ error = Scene_setName( self, valtuple );
- else { /* Error: no member with the given name was found */
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_AttributeError, name));
+ else { /* Error: no member with the given name was found */
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_AttributeError, name ) );
}
/* valtuple won't be returned to the caller, so we need to DECREF it */
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
/* 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 exit */
+ Py_DECREF( Py_None );
+ return 0; /* normal exit */
}
-//-----------------------compare-----------------------------------------------------------------------------------------------------
-static int Scene_compare (BPy_Scene *a, BPy_Scene *b)
+
+//-----------------------compare----------------------------------------
+static int Scene_compare( BPy_Scene * a, BPy_Scene * b )
{
Scene *pa = a->scene, *pb = b->scene;
- return (pa == pb) ? 0:-1;
+ return ( pa == pb ) ? 0 : -1;
}
-//----------------------repr--------------------------------------------------------------------------------------------------------------
-static PyObject *Scene_repr (BPy_Scene *self)
+
+//----------------------repr--------------------------------------------
+static PyObject *Scene_repr( BPy_Scene * self )
{
- return PyString_FromFormat("[Scene \"%s\"]", self->scene->id.name+2);
+ return PyString_FromFormat( "[Scene \"%s\"]",
+ self->scene->id.name + 2 );
}
-//-----------------------CreatePyObject----------------------------------------------------------------------------------
-PyObject *Scene_CreatePyObject (Scene *scene)
+
+//-----------------------CreatePyObject---------------------------------
+PyObject *Scene_CreatePyObject( Scene * scene )
{
BPy_Scene *pyscene;
- pyscene = (BPy_Scene *)PyObject_NEW (BPy_Scene, &Scene_Type);
+ pyscene = ( BPy_Scene * ) PyObject_NEW( BPy_Scene, &Scene_Type );
- if (!pyscene)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Scene object");
+ if( !pyscene )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Scene object" );
pyscene->scene = scene;
- return (PyObject *)pyscene;
+ return ( PyObject * ) pyscene;
}
-//-----------------------CheckPyObject----------------------------------------------------------------------------------
-int Scene_CheckPyObject (PyObject *pyobj)
+
+//-----------------------CheckPyObject----------------------------------
+int Scene_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Scene_Type);
+ return ( pyobj->ob_type == &Scene_Type );
}
-//-----------------------FromPyObject----------------------------------------------------------------------------------
-Scene *Scene_FromPyObject (PyObject *pyobj)
+
+//-----------------------FromPyObject-----------------------------------
+Scene *Scene_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Scene *)pyobj)->scene;
+ return ( ( BPy_Scene * ) pyobj )->scene;
}
-//-----------------------GetSceneByName()--------------------------------------------------------------------------------------------
+
+//-----------------------GetSceneByName()-------------------------------
/* Description: Returns the object with the name specified by the argument name.
Note that the calling function has to remove the first two characters of the object name.
These two characters specify the type of the object (OB, ME, WO, ...)The function
will return NULL when no object with the given name is found. */
-Scene * GetSceneByName (char * name)
+Scene *GetSceneByName( char *name )
{
- Scene * scene_iter;
+ Scene *scene_iter;
scene_iter = G.main->scene.first;
- while (scene_iter)
- {
- if (StringEqual (name, GetIdName (&(scene_iter->id))))
- {
- return (scene_iter);
+ while( scene_iter ) {
+ if( StringEqual( name, GetIdName( &( scene_iter->id ) ) ) ) {
+ return ( scene_iter );
}
scene_iter = scene_iter->id.next;
}
/* There is no object with the given name */
- return (NULL);
+ return ( NULL );
}
-//-----------------------EXPP_Scene_getObjectBase()--------------------------------------------------------------------------------------------
-Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
+
+//-----------------------EXPP_Scene_getObjectBase()---------------------
+Base *EXPP_Scene_getObjectBase( Scene * scene, Object * object )
{
Base *base = scene->base.first;
- while (base) {
+ while( base ) {
- if (object == base->object) return base; /* found it? */
+ if( object == base->object )
+ return base; /* found it? */
base = base->next;
}
- return NULL; /* object isn't linked to this scene */
+ return NULL; /* object isn't linked to this scene */
}
-//-----------------------Scene module function defintions----------------------------------------------------------------------
-//-----------------------Scene.New()--------------------------------------------------------------------------------------------------
-static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
+
+//-----------------------Scene module function defintions---------------
+//-----------------------Scene.New()------------------------------------
+static PyObject *M_Scene_New( PyObject * self, PyObject * args,
+ PyObject * kword )
{
- char *name = "Scene";
- char *kw[] = {"name", NULL};
- PyObject *pyscene; /* for the Scene object wrapper in Python */
- Scene *blscene; /* for the actual Scene we create in Blender */
+ char *name = "Scene";
+ char *kw[] = { "name", NULL };
+ PyObject *pyscene; /* for the Scene object wrapper in Python */
+ Scene *blscene; /* for the actual Scene we create in Blender */
- if (!PyArg_ParseTupleAndKeywords(args, kword, "|s", kw, &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string or an empty argument list"));
+ if( !PyArg_ParseTupleAndKeywords( args, kword, "|s", kw, &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string or an empty argument list" ) );
- blscene = add_scene(name); /* first create the Scene in Blender */
+ blscene = add_scene( name ); /* first create the Scene in Blender */
- if (blscene){
- /* normally, for most objects, we set the user count to zero here.
- * Scene is different than most objs since it is the container
- * for all the others. Since add_scene() has already set
- * the user count to one, we leave it alone.
- */
+ if( blscene ) {
+ /* normally, for most objects, we set the user count to zero here.
+ * Scene is different than most objs since it is the container
+ * for all the others. Since add_scene() has already set
+ * the user count to one, we leave it alone.
+ */
- /* now create the wrapper obj in Python */
- pyscene = Scene_CreatePyObject (blscene);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Scene obj in Blender"));
+ /* now create the wrapper obj in Python */
+ pyscene = Scene_CreatePyObject( blscene );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Scene obj in Blender" ) );
- if (pyscene == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Scene PyObject"));
+ if( pyscene == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Scene PyObject" ) );
return pyscene;
}
-//-----------------------Scene.Get()--------------------------------------------------------------------------------------------------
-static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
+
+//-----------------------Scene.Get()------------------------------------
+static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
Scene *scene_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
scene_iter = G.main->scene.first;
- if (name) { /* (name) - Search scene by name */
+ if( name ) { /* (name) - Search scene by name */
PyObject *wanted_scene = NULL;
- while ((scene_iter) && (wanted_scene == NULL)) {
+ while( ( scene_iter ) && ( wanted_scene == NULL ) ) {
- if (strcmp (name, scene_iter->id.name+2) == 0)
- wanted_scene = Scene_CreatePyObject (scene_iter);
+ if( strcmp( name, scene_iter->id.name + 2 ) == 0 )
+ wanted_scene =
+ Scene_CreatePyObject( scene_iter );
scene_iter = scene_iter->id.next;
}
- if (wanted_scene == NULL) { /* Requested scene doesn't exist */
+ if( wanted_scene == NULL ) { /* Requested scene doesn't exist */
char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Scene \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Scene \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
return wanted_scene;
}
- else { /* () - return a list with wrappers for all scenes in Blender */
+ else { /* () - return a list with wrappers for all scenes in Blender */
int index = 0;
PyObject *sce_pylist, *pyobj;
- sce_pylist = PyList_New (BLI_countlist (&(G.main->scene)));
+ sce_pylist = PyList_New( BLI_countlist( &( G.main->scene ) ) );
- if (sce_pylist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( sce_pylist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (scene_iter) {
- pyobj = Scene_CreatePyObject (scene_iter);
+ while( scene_iter ) {
+ pyobj = Scene_CreatePyObject( scene_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- PyList_SET_ITEM (sce_pylist, index, pyobj);
+ PyList_SET_ITEM( sce_pylist, index, pyobj );
scene_iter = scene_iter->id.next;
index++;
@@ -477,456 +500,489 @@ static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
return sce_pylist;
}
}
-//-----------------------Scene.GetCurrent()---------------------------------------------------------------------------------------
-static PyObject *M_Scene_GetCurrent (PyObject *self)
+
+//-----------------------Scene.GetCurrent()------------------------------
+static PyObject *M_Scene_GetCurrent( PyObject * self )
{
- return Scene_CreatePyObject ((Scene *)G.scene);
+ return Scene_CreatePyObject( ( Scene * ) G.scene );
}
-//-----------------------Scene.Unlink()--------------------------------------------------------------------------------------------
-static PyObject *M_Scene_Unlink (PyObject *self, PyObject *args)
-{
+
+//-----------------------Scene.Unlink()----------------------------------
+static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
+{
PyObject *pyobj;
- Scene *scene;
+ Scene *scene;
- if (!PyArg_ParseTuple (args, "O!", &Scene_Type, &pyobj))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Scene PyType object");
+ if( !PyArg_ParseTuple( args, "O!", &Scene_Type, &pyobj ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Scene PyType object" );
- scene = ((BPy_Scene *)pyobj)->scene;
+ scene = ( ( BPy_Scene * ) pyobj )->scene;
- if (scene == G.scene)
- return EXPP_ReturnPyObjError (PyExc_SystemError,
- "current Scene cannot be removed!");
+ if( scene == G.scene )
+ return EXPP_ReturnPyObjError( PyExc_SystemError,
+ "current Scene cannot be removed!" );
- free_libblock(&G.main->scene, scene);
+ free_libblock( &G.main->scene, scene );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------BPy_Scene function defintions-----------------------------------------------------------------------
-//-----------------------Scene.getName()-----------------------------------------------------------------------------------------
-static PyObject *Scene_getName(BPy_Scene *self)
+
+//-----------------------BPy_Scene function defintions-------------------
+//-----------------------Scene.getName()---------------------------------
+static PyObject *Scene_getName( BPy_Scene * self )
{
- PyObject *attr = PyString_FromString(self->scene->id.name+2);
+ PyObject *attr = PyString_FromString( self->scene->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Scene.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Scene.name attribute" ) );
}
-//-----------------------Scene.setName()-----------------------------------------------------------------------------------------
-static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.setName()---------------------------------
+static PyObject *Scene_setName( BPy_Scene * self, PyObject * args )
{
char *name;
char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
- rename_id(&self->scene->id, buf);
+ rename_id( &self->scene->id, buf );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------Scene.copy()-----------------------------------------------------------------------------------------
-static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.copy()------------------------------------
+static PyObject *Scene_copy( BPy_Scene * self, PyObject * args )
{
short dup_objs = 1;
Scene *scene = self->scene;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- if (!PyArg_ParseTuple (args, "|h", &dup_objs))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int in [0,2] or nothing as argument");
+ if( !PyArg_ParseTuple( args, "|h", &dup_objs ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int in [0,2] or nothing as argument" );
- return Scene_CreatePyObject (copy_scene (scene, dup_objs));
+ return Scene_CreatePyObject( copy_scene( scene, dup_objs ) );
}
-//-----------------------Scene.makeCurrent()-----------------------------------------------------------------------------------------
-static PyObject *Scene_makeCurrent (BPy_Scene *self)
+
+//-----------------------Scene.makeCurrent()-----------------------------
+static PyObject *Scene_makeCurrent( BPy_Scene * self )
{
Scene *scene = self->scene;
- if (scene) set_scene (scene);
+ if( scene )
+ set_scene( scene );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------Scene.update()-----------------------------------------------------------------------------------------
-static PyObject *Scene_update (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.update()----------------------------------
+static PyObject *Scene_update( BPy_Scene * self, PyObject * args )
{
Scene *scene = self->scene;
int full = 0;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- if (!PyArg_ParseTuple (args, "|i", &full))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or int (0 or 1) argument");
+ if( !PyArg_ParseTuple( args, "|i", &full ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or int (0 or 1) argument" );
/* Under certain circunstances, sort_baselist *here* can crash Blender.
* A "RuntimeError: max recursion limit" happens when a scriptlink
* on frame change has scene.update(1).
* Investigate better how to avoid this. */
- if (!full)
- sort_baselist (scene);
+ if( !full )
+ sort_baselist( scene );
- else if (full == 1)
- set_scene_bg (scene);
+ else if( full == 1 )
+ set_scene_bg( scene );
else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "in method scene.update(full), full should be:\n"
- "0: to only sort scene elements (old behavior); or\n"
- "1: for a full update (regroups, does ipos, ikas, keys, etc.)");
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "in method scene.update(full), full should be:\n"
+ "0: to only sort scene elements (old behavior); or\n"
+ "1: for a full update (regroups, does ipos, ikas, keys, etc.)" );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------Scene.link()-----------------------------------------------------------------------------------------------------
-static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.link()------------------------------------
+static PyObject *Scene_link( BPy_Scene * self, PyObject * args )
{
Scene *scene = self->scene;
BPy_Object *bpy_obj;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- if (!PyArg_ParseTuple (args, "O!", &Object_Type, &bpy_obj))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Object argument");
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Object argument" );
- else { /* Ok, all is fine, let's try to link it */
+ else { /* Ok, all is fine, let's try to link it */
Object *object = bpy_obj->object;
Base *base;
/* We need to link the object to a 'Base', then link this base
- * to the scene. See DNA_scene_types.h ... */
+ * to the scene. See DNA_scene_types.h ... */
/* First, check if the object isn't already in the scene */
- base = EXPP_Scene_getObjectBase (scene, object);
+ base = EXPP_Scene_getObjectBase( scene, object );
/* if base is not NULL ... */
- if (base) /* ... the object is already in one of the Scene Bases */
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "object already in scene!");
+ if( base ) /* ... the object is already in one of the Scene Bases */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "object already in scene!" );
/* not linked, go get mem for a new base object */
- base = MEM_callocN(sizeof(Base), "newbase");
-
- if (!base)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't allocate new Base for object");
+ base = MEM_callocN( sizeof( Base ), "newbase" );
+
+ if( !base )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't allocate new Base for object" );
/* check if this object has obdata, case not, try to create it */
- if (!object->data && (object->type != OB_EMPTY))
- EXPP_add_obdata(object); /* returns -1 on error, defined in Object.c */
+ if( !object->data && ( object->type != OB_EMPTY ) )
+ EXPP_add_obdata( object ); /* returns -1 on error, defined in Object.c */
- base->object = object; /* link object to the new base */
+ base->object = object; /* link object to the new base */
base->lay = object->lay;
base->flag = object->flag;
- object->id.us += 1; /* incref the object user count in Blender */
+ object->id.us += 1; /* incref the object user count in Blender */
- BLI_addhead(&scene->base, base); /* finally, link new base to scene */
+ BLI_addhead( &scene->base, base ); /* finally, link new base to scene */
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------Scene.unlink()-----------------------------------------------------------------------------------------------------
-static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
-{
+
+//-----------------------Scene.unlink()----------------------------------
+static PyObject *Scene_unlink( BPy_Scene * self, PyObject * args )
+{
BPy_Object *bpy_obj = NULL;
Object *object;
Scene *scene = self->scene;
Base *base;
short retval = 0;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender scene was deleted!" );
- if (!PyArg_ParseTuple(args, "O!", &Object_Type, &bpy_obj))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Object as argument");
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &bpy_obj ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Object as argument" );
object = bpy_obj->object;
/* is the object really in the scene? */
- base = EXPP_Scene_getObjectBase(scene, object);
-
- if (base) { /* if it is, remove it: */
- BLI_remlink(&scene->base, base);
+ base = EXPP_Scene_getObjectBase( scene, object );
+
+ if( base ) { /* if it is, remove it: */
+ BLI_remlink( &scene->base, base );
object->id.us -= 1;
- MEM_freeN (base);
- scene->basact = 0; /* in case the object was selected */
+ MEM_freeN( base );
+ scene->basact = 0; /* in case the object was selected */
retval = 1;
}
- return Py_BuildValue ("i", PyInt_FromLong (retval));
+ return Py_BuildValue( "i", PyInt_FromLong( retval ) );
}
-//-----------------------Scene.getChildren()-----------------------------------------------------------------------------------------------------
-static PyObject *Scene_getChildren (BPy_Scene *self)
-{
+
+//-----------------------Scene.getChildren()-----------------------------
+static PyObject *Scene_getChildren( BPy_Scene * self )
+{
Scene *scene = self->scene;
- PyObject *pylist= PyList_New(0);
+ PyObject *pylist = PyList_New( 0 );
PyObject *bpy_obj;
Object *object;
Base *base;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
base = scene->base.first;
- while (base) {
+ while( base ) {
object = base->object;
- bpy_obj = M_Object_Get(Py_None,
- Py_BuildValue ("(s)", object->id.name+2));
+ bpy_obj = M_Object_Get( Py_None,
+ Py_BuildValue( "(s)",
+ object->id.name + 2 ) );
- if (!bpy_obj)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create new object wrapper");
+ if( !bpy_obj )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create new object wrapper" );
- PyList_Append (pylist, bpy_obj);
- Py_XDECREF (bpy_obj); /* PyList_Append incref'ed it */
+ PyList_Append( pylist, bpy_obj );
+ Py_XDECREF( bpy_obj ); /* PyList_Append incref'ed it */
base = base->next;
}
return pylist;
}
-//-----------------------Scene.getCurrentCamera()---------------------------------------------------------------------------------------
-static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
-{
+
+//-----------------------Scene.getCurrentCamera()------------------------
+static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
+{
Object *cam_obj;
Scene *scene = self->scene;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
cam_obj = scene->camera;
- if (cam_obj) /* if found, return a wrapper for it */
- return M_Object_Get (Py_None, Py_BuildValue ("(s)", cam_obj->id.name+2));
+ if( cam_obj ) /* if found, return a wrapper for it */
+ return M_Object_Get( Py_None,
+ Py_BuildValue( "(s)",
+ cam_obj->id.name + 2 ) );
- Py_INCREF(Py_None); /* none found */
+ Py_INCREF( Py_None ); /* none found */
return Py_None;
}
-//-----------------------Scene.setCurrentCamera()---------------------------------------------------------------------------------------
-static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.setCurrentCamera()------------------------
+static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args )
{
Object *object;
BPy_Object *cam_obj;
Scene *scene = self->scene;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- if (!PyArg_ParseTuple(args, "O!", &Object_Type, &cam_obj))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected Camera Object as argument");
+ if( !PyArg_ParseTuple( args, "O!", &Object_Type, &cam_obj ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Camera Object as argument" );
object = cam_obj->object;
- scene->camera = object; /* set the current Camera */
+ scene->camera = object; /* set the current Camera */
/* if this is the current scene, update its window now */
- if (scene == G.scene) copy_view3d_lock(REDRAW);
+ if( scene == G.scene )
+ copy_view3d_lock( REDRAW );
/* XXX copy_view3d_lock(REDRAW) prints "bad call to addqueue: 0 (18, 1)".
* The same happens in bpython. */
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-//-----------------------Scene.getRenderingContext()----------------------------------------------------------------------
-static PyObject *Scene_getRenderingContext (BPy_Scene *self)
-{
- if (!self->scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
- return RenderData_CreatePyObject(self->scene);
+//-----------------------Scene.getRenderingContext()---------------------
+static PyObject *Scene_getRenderingContext( BPy_Scene * self )
+{
+ if( !self->scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
+
+ return RenderData_CreatePyObject( self->scene );
}
-static PyObject *Scene_getRadiosityContext (BPy_Scene *self)
+static PyObject *Scene_getRadiosityContext( BPy_Scene * self )
{
- if (!self->scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !self->scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- return Radio_CreatePyObject(self->scene);
+ return Radio_CreatePyObject( self->scene );
}
/* scene.addScriptLink */
-static PyObject *Scene_addScriptLink (BPy_Scene *self, PyObject *args)
+static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args )
{
Scene *scene = self->scene;
ScriptLink *slink = NULL;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- slink = &(scene)->scriptlink;
+ slink = &( scene )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 1))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 1 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* scene.clearScriptLinks */
-static PyObject *Scene_clearScriptLinks (BPy_Scene *self)
+static PyObject *Scene_clearScriptLinks( BPy_Scene * self )
{
Scene *scene = self->scene;
ScriptLink *slink = NULL;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- slink = &(scene)->scriptlink;
+ slink = &( scene )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* scene.getScriptLinks */
-static PyObject *Scene_getScriptLinks (BPy_Scene *self, PyObject *args)
+static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args )
{
Scene *scene = self->scene;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
- slink = &(scene)->scriptlink;
+ slink = &( scene )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 1);
+ ret = EXPP_getScriptLinks( slink, args, 1 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
-static PyObject *Scene_play (BPy_Scene *self, PyObject *args)
+static PyObject *Scene_play( BPy_Scene * self, PyObject * args )
{
Scene *scene = self->scene;
int mode = 0, win = SPACE_VIEW3D;
PyObject *ret = NULL;
ScrArea *sa = NULL, *oldsa = curarea;
- if (!scene)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Blender Scene was deleted!");
-
- if (!PyArg_ParseTuple(args, "|ii", &mode, &win))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing, or or two ints as arguments.");
-
- if (mode < 0 || mode > 3)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "mode should be in range [0, 3].");
-
- switch (win) {
- case SPACE_VIEW3D:
- case SPACE_SEQ:
- case SPACE_IPO:
- case SPACE_ACTION:
- case SPACE_NLA:
- case SPACE_SOUND:
- case SPACE_BUTS: /* from here they don't 'play', but ...*/
- case SPACE_TEXT: /* ... might be used as a timer. */
- case SPACE_SCRIPT:
- case SPACE_OOPS:
- case SPACE_IMAGE:
- case SPACE_IMASEL:
- case SPACE_INFO:
- case SPACE_FILE:
- break;
- default:
- win = SPACE_VIEW3D;
+ if( !scene )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Blender Scene was deleted!" );
+
+ if( !PyArg_ParseTuple( args, "|ii", &mode, &win ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing, or or two ints as arguments." );
+
+ if( mode < 0 || mode > 3 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "mode should be in range [0, 3]." );
+
+ switch ( win ) {
+ case SPACE_VIEW3D:
+ case SPACE_SEQ:
+ case SPACE_IPO:
+ case SPACE_ACTION:
+ case SPACE_NLA:
+ case SPACE_SOUND:
+ case SPACE_BUTS: /* from here they don't 'play', but ... */
+ case SPACE_TEXT: /* ... might be used as a timer. */
+ case SPACE_SCRIPT:
+ case SPACE_OOPS:
+ case SPACE_IMAGE:
+ case SPACE_IMASEL:
+ case SPACE_INFO:
+ case SPACE_FILE:
+ break;
+ default:
+ win = SPACE_VIEW3D;
}
/* we have to move to a proper win */
- sa = find_biggest_area_of_type(win);
- if (!sa && win != SPACE_VIEW3D)
- sa = find_biggest_area_of_type(SPACE_VIEW3D);
+ sa = find_biggest_area_of_type( win );
+ if( !sa && win != SPACE_VIEW3D )
+ sa = find_biggest_area_of_type( SPACE_VIEW3D );
- if (!sa) sa = find_biggest_area();
+ if( !sa )
+ sa = find_biggest_area( );
- if (sa) areawinset(sa->win);
+ if( sa )
+ areawinset( sa->win );
/* play_anim returns 0 for normal exit or 1 if user canceled it */
- ret = Py_BuildValue("i", play_anim(mode));
+ ret = Py_BuildValue( "i", play_anim( mode ) );
- if (sa) areawinset(oldsa->win);
+ if( sa )
+ areawinset( oldsa->win );
return ret;
}
/*****************************************************************************/
-// DEPRECATED
+// DEPRECATED
/*****************************************************************************/
-//-----------------------Scene.getRenderdir ()----------------------------------------------------------------------
-static PyObject *Scene_getRenderdir (BPy_Scene *self)
+//-----------------------Scene.getRenderdir ()---------------------------
+static PyObject *Scene_getRenderdir( BPy_Scene * self )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.getRenderPath()");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.getRenderPath()" );
}
-//-----------------------Scene.getBackbufdir ()----------------------------------------------------------------------
-static PyObject *Scene_getBackbufdir (BPy_Scene *self)
+
+//-----------------------Scene.getBackbufdir ()--------------------------
+static PyObject *Scene_getBackbufdir( BPy_Scene * self )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.getBackbufPath()");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.getBackbufPath()" );
}
-//-----------------------Scene.startFrame ()----------------------------------------------------------------------
-static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.startFrame ()-----------------------------
+static PyObject *Scene_startFrame( BPy_Scene * self, PyObject * args )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.startFrame()");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.startFrame()" );
}
-//-----------------------Scene.endFrame ()----------------------------------------------------------------------
-static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.endFrame ()-------------------------------
+static PyObject *Scene_endFrame( BPy_Scene * self, PyObject * args )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.endFrame()");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.endFrame()" );
}
-//-----------------------Scene.getWinSize ()----------------------------------------------------------------------
-static PyObject *Scene_getWinSize(BPy_Scene *self)
+
+//-----------------------Scene.getWinSize ()-----------------------------
+static PyObject *Scene_getWinSize( BPy_Scene * self )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY" );
}
-//-----------------------Scene.setWinSize()----------------------------------------------------------------------
-static PyObject *Scene_setWinSize(BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.setWinSize()------------------------------
+static PyObject *Scene_setWinSize( BPy_Scene * self, PyObject * args )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.imageSizeX() and RenderData.imageSizeY" );
}
-//-----------------------Scene.frameSettings()----------------------------------------------------------------------
-static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
-{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame");
+
+//-----------------------Scene.frameSettings()---------------------------
+static PyObject *Scene_frameSettings( BPy_Scene * self, PyObject * args )
+{
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.startFrame(), RenderData.endFrame, RenderData.currentFrame" );
}
-//-----------------------Scene.currentFrame()-----------------------------------------------------------------------------------------
-static PyObject *Scene_currentFrame (BPy_Scene *self, PyObject *args)
+
+//-----------------------Scene.currentFrame()----------------------------
+static PyObject *Scene_currentFrame( BPy_Scene * self, PyObject * args )
{
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Deprecated:use RenderData.currentFrame");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Deprecated:use RenderData.currentFrame" );
}
diff --git a/source/blender/python/api2_2x/Scene.h b/source/blender/python/api2_2x/Scene.h
index ef2664f8ad0..ca0775dc6f8 100644
--- a/source/blender/python/api2_2x/Scene.h
+++ b/source/blender/python/api2_2x/Scene.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -39,18 +40,17 @@
PyTypeObject Scene_Type;
#define BPy_Scene_Check(v) \
- ((v)->ob_type == &Scene_Type)
+ ((v)->ob_type == &Scene_Type)
-//---------------------------Python BPy_Scene structure definition------------------------------------------------------
+//---------------------------Python BPy_Scene structure definition----------
typedef struct {
- PyObject_HEAD
- Scene *scene;
+ PyObject_HEAD Scene * scene;
} BPy_Scene;
-//---------------------------Python BPy_Scene visible prototypes------------------------------------------------------
+//---------------------------Python BPy_Scene visible prototypes-----------
// Python Scene_Type helper functions needed by Blender (the Init function) and Object modules.
-PyObject *Scene_Init (void);
-PyObject *Scene_CreatePyObject (Scene *cam);
-Scene *Scene_FromPyObject (PyObject *pyobj);
-int Scene_CheckPyObject (PyObject *pyobj);
+PyObject *Scene_Init( void );
+PyObject *Scene_CreatePyObject( Scene * cam );
+Scene *Scene_FromPyObject( PyObject * pyobj );
+int Scene_CheckPyObject( PyObject * pyobj );
-#endif /* EXPP_SCENE_H */
+#endif /* EXPP_SCENE_H */
diff --git a/source/blender/python/api2_2x/Sound.c b/source/blender/python/api2_2x/Sound.c
index 338f940eb6b..ca5b24c8a3d 100644
--- a/source/blender/python/api2_2x/Sound.c
+++ b/source/blender/python/api2_2x/Sound.c
@@ -36,66 +36,65 @@
#include <BKE_sound.h>
#include <BLI_blenlib.h>
#include <BIF_editsound.h>
-#include <BIF_space.h> /* allqueue() */
+#include <BIF_space.h> /* allqueue() */
-#include "mydevice.h" /* redraw defines */
+#include "mydevice.h" /* redraw defines */
#include "gen_utils.h"
#include "Sound.h"
/*****************************************************************************/
-/* Python BPy_Sound defaults: */
+/* Python BPy_Sound defaults: */
/*****************************************************************************/
/*****************************************************************************/
/* Python API function prototypes for the Sound module. */
/*****************************************************************************/
-static PyObject *M_Sound_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Sound_Get (PyObject *self, PyObject *args);
-static PyObject *M_Sound_Load (PyObject *self, PyObject *args);
+static PyObject *M_Sound_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Sound_Get( PyObject * self, PyObject * args );
+static PyObject *M_Sound_Load( PyObject * self, PyObject * args );
/************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Sound.__doc__ */
/************************************************************************/
-static char M_Sound_doc[] =
-"The Blender Sound module\n\n";
+static char M_Sound_doc[] = "The Blender Sound module\n\n";
static char M_Sound_New_doc[] =
-"() - return a new Sound object -- unimplemented";
+ "() - return a new Sound object -- unimplemented";
static char M_Sound_Get_doc[] =
-"(name) - return the sound with the name 'name', \
+ "(name) - return the sound with the name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all sounds in the\ncurrent scene.";
static char M_Sound_Load_doc[] =
-"(filename, redraw = 0) - return sound from file filename as Sound Object,\n\
+ "(filename, redraw = 0) - return sound from file filename as Sound Object,\n\
returns None if not found.";
/*****************************************************************************/
/* Python method structure definition for Blender.Sound module: */
/*****************************************************************************/
struct PyMethodDef M_Sound_methods[] = {
- {"New",(PyCFunction)M_Sound_New, METH_VARARGS|METH_KEYWORDS,
- M_Sound_New_doc},
- {"Get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
- {"get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
- {"Load", M_Sound_Load, METH_VARARGS, M_Sound_Load_doc},
+ {"New", ( PyCFunction ) M_Sound_New, METH_VARARGS | METH_KEYWORDS,
+ M_Sound_New_doc},
+ {"Get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
+ {"get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
+ {"Load", M_Sound_Load, METH_VARARGS, M_Sound_Load_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Sound_Type callback function prototypes: */
+/* Python Sound_Type callback function prototypes: */
/*****************************************************************************/
-static void Sound_dealloc (BPy_Sound *self);
-static int Sound_setAttr (BPy_Sound *self, char *name, PyObject *v);
-static int Sound_compare (BPy_Sound *a, BPy_Sound *b);
-static PyObject *Sound_getAttr (BPy_Sound *self, char *name);
-static PyObject *Sound_repr (BPy_Sound *self);
+static void Sound_dealloc( BPy_Sound * self );
+static int Sound_setAttr( BPy_Sound * self, char *name, PyObject * v );
+static int Sound_compare( BPy_Sound * a, BPy_Sound * b );
+static PyObject *Sound_getAttr( BPy_Sound * self, char *name );
+static PyObject *Sound_repr( BPy_Sound * self );
#define SOUND_FLOAT_METHODS(funcname, varname) \
static PyObject *Sound_get ## funcname(BPy_Sound *self) { \
@@ -123,113 +122,114 @@ static PyObject *Sound_set ## funcname(BPy_Sound *self, PyObject *args) { \
/*****************************************************************************/
-/* Python BPy_Sound methods declarations: */
+/* Python BPy_Sound methods declarations: */
/*****************************************************************************/
-static PyObject *Sound_getName(BPy_Sound *self);
-static PyObject *Sound_getFilename(BPy_Sound *self);
-static PyObject *Sound_play(BPy_Sound *self);
-static PyObject *Sound_makeActive(BPy_Sound *self);
-SOUND_FLOAT_METHODS(Volume, volume)
-SOUND_FLOAT_METHODS(Panning, panning)
-SOUND_FLOAT_METHODS(Attenuation, attenuation)
-SOUND_FLOAT_METHODS(Pitch, pitch)
-SOUND_FLOAT_METHODS(MinGain, min_gain)
-SOUND_FLOAT_METHODS(MaxGain, max_gain)
-SOUND_FLOAT_METHODS(Distance, distance)
+static PyObject *Sound_getName( BPy_Sound * self );
+static PyObject *Sound_getFilename( BPy_Sound * self );
+static PyObject *Sound_play( BPy_Sound * self );
+static PyObject *Sound_makeActive( BPy_Sound * self );
+SOUND_FLOAT_METHODS( Volume, volume )
+ SOUND_FLOAT_METHODS( Panning, panning )
+ SOUND_FLOAT_METHODS( Attenuation, attenuation )
+ SOUND_FLOAT_METHODS( Pitch, pitch )
+ SOUND_FLOAT_METHODS( MinGain, min_gain )
+ SOUND_FLOAT_METHODS( MaxGain, max_gain )
+ SOUND_FLOAT_METHODS( Distance, distance )
/*****************************************************************************/
-/* Python BPy_Sound methods table: */
+/* Python BPy_Sound methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Sound_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Sound_getName, METH_NOARGS,
- "() - Return Sound object name"},
- {"getFilename", (PyCFunction)Sound_getFilename, METH_NOARGS,
- "() - Return Sound object filename"},
- {"play", (PyCFunction)Sound_play, METH_NOARGS,
- "() - play this sound"},
- {"makeActive", (PyCFunction)Sound_makeActive, METH_NOARGS,
- "() - make this the active sound in the sound buttons win (also redraws)"},
- SOUND_FLOAT_METHOD_FUNCS(Volume)
- SOUND_FLOAT_METHOD_FUNCS(Panning)
- SOUND_FLOAT_METHOD_FUNCS(Attenuation)
- SOUND_FLOAT_METHOD_FUNCS(Pitch)
- SOUND_FLOAT_METHOD_FUNCS(MinGain)
- SOUND_FLOAT_METHOD_FUNCS(MaxGain)
- SOUND_FLOAT_METHOD_FUNCS(Distance)
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Sound_getName, METH_NOARGS,
+ "() - Return Sound object name"},
+ {"getFilename", ( PyCFunction ) Sound_getFilename, METH_NOARGS,
+ "() - Return Sound object filename"},
+ {"play", ( PyCFunction ) Sound_play, METH_NOARGS,
+ "() - play this sound"},
+ {"makeActive", ( PyCFunction ) Sound_makeActive, METH_NOARGS,
+ "() - make this the active sound in the sound buttons win (also redraws)"},
+ SOUND_FLOAT_METHOD_FUNCS( Volume )
+ SOUND_FLOAT_METHOD_FUNCS( Panning )
+ SOUND_FLOAT_METHOD_FUNCS( Attenuation )
+ SOUND_FLOAT_METHOD_FUNCS( Pitch )
+ SOUND_FLOAT_METHOD_FUNCS( MinGain )
+ SOUND_FLOAT_METHOD_FUNCS( MaxGain )
+ SOUND_FLOAT_METHOD_FUNCS( Distance ) {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Sound_Type structure definition: */
+/* Python Sound_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Sound_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Sound", /* tp_name */
- sizeof (BPy_Sound), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject Sound_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Sound", /* tp_name */
+ sizeof( BPy_Sound ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Sound_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Sound_getAttr, /* tp_getattr */
- (setattrfunc)Sound_setAttr, /* tp_setattr */
- (cmpfunc)Sound_compare, /* tp_compare */
- (reprfunc)Sound_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_Sound_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) Sound_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Sound_getAttr, /* tp_getattr */
+ ( setattrfunc ) Sound_setAttr, /* tp_setattr */
+ ( cmpfunc ) Sound_compare, /* tp_compare */
+ ( reprfunc ) Sound_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_Sound_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
-/* Function: M_Sound_New */
-/* Python equivalent: Blender.Sound.New */
+/* Function: M_Sound_New */
+/* Python equivalent: Blender.Sound.New */
/*****************************************************************************/
-static PyObject *M_Sound_New(PyObject *self, PyObject *args, PyObject *keywords)
+static PyObject *M_Sound_New( PyObject * self, PyObject * args,
+ PyObject * keywords )
{
- printf ("In Sound_New() - unimplemented in 2.34\n");
+ printf( "In Sound_New() - unimplemented in 2.34\n" );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/* NOTE: these were copied and modified from image.h. To Be Done TBD:
* macro-ize them, or C++ templates eventually?
*/
-/********************************************************************************/
-/* Function: M_Sound_Get */
-/* Python equivalent: Blender.Sound.Get */
-/* Description: Receives a string and returns the Sound object */
-/* whose name matches the string. If no argument is */
-/* passed in, a list of all Sound names in the */
-/* current scene is returned. */
-/*********************************************************************************/
-static PyObject *M_Sound_Get(PyObject *self, PyObject *args)
+/****************************************************************************/
+/* Function: M_Sound_Get */
+/* Python equivalent: Blender.Sound.Get */
+/* Description: Receives a string and returns the Sound object */
+/* whose name matches the string. If no argument is */
+/* passed in, a list of all Sound names in the */
+/* current scene is returned. */
+/****************************************************************************/
+static PyObject *M_Sound_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
bSound *snd_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
snd_iter = G.main->sound.first;
- if (name) { /* (name) - Search Sound by name */
+ if( name ) { /* (name) - Search Sound by name */
BPy_Sound *wanted_Sound = NULL;
- while ((snd_iter) && (wanted_Sound == NULL)) {
- if (strcmp (name, snd_iter->id.name+2) == 0) {
- wanted_Sound = (BPy_Sound *)PyObject_NEW(BPy_Sound, &Sound_Type);
- if (wanted_Sound) {
+ while( ( snd_iter ) && ( wanted_Sound == NULL ) ) {
+ if( strcmp( name, snd_iter->id.name + 2 ) == 0 ) {
+ wanted_Sound =
+ ( BPy_Sound * )
+ PyObject_NEW( BPy_Sound, &Sound_Type );
+ if( wanted_Sound ) {
wanted_Sound->sound = snd_iter;
break;
}
@@ -237,94 +237,98 @@ static PyObject *M_Sound_Get(PyObject *self, PyObject *args)
snd_iter = snd_iter->id.next;
}
- if (wanted_Sound == NULL) { /* Requested Sound doesn't exist */
+ if( wanted_Sound == NULL ) { /* Requested Sound doesn't exist */
char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Sound \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Sound \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
- return (PyObject *)wanted_Sound;
+ return ( PyObject * ) wanted_Sound;
}
- else { /* () - return a list of all Sounds in the scene */
+ else { /* () - return a list of all Sounds in the scene */
int index = 0;
PyObject *snd_list, *pyobj;
- snd_list = PyList_New (BLI_countlist (&(G.main->sound)));
+ snd_list = PyList_New( BLI_countlist( &( G.main->sound ) ) );
- if (snd_list == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( snd_list == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (snd_iter) {
- pyobj = Sound_CreatePyObject (snd_iter);
+ while( snd_iter ) {
+ pyobj = Sound_CreatePyObject( snd_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- PyList_SET_ITEM (snd_list, index, pyobj);
+ PyList_SET_ITEM( snd_list, index, pyobj );
snd_iter = snd_iter->id.next;
index++;
}
- return (snd_list);
+ return ( snd_list );
}
}
/*****************************************************************************/
-/* Function: M_Sound_Load */
-/* Python equivalent: Blender.Sound.Load */
-/* Description: Receives a string and returns the Sound object */
-/* whose filename matches the string. */
+/* Function: M_Sound_Load */
+/* Python equivalent: Blender.Sound.Load */
+/* Description: Receives a string and returns the Sound object */
+/* whose filename matches the string. */
/*****************************************************************************/
-static PyObject *M_Sound_Load(PyObject *self, PyObject *args)
+static PyObject *M_Sound_Load( PyObject * self, PyObject * args )
{
- char *fname;
- bSound *snd_ptr;
+ char *fname;
+ bSound *snd_ptr;
BPy_Sound *snd;
- if (!PyArg_ParseTuple(args, "s", &fname))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &fname ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- snd = (BPy_Sound *)PyObject_NEW(BPy_Sound, &Sound_Type);
+ snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
- if (!snd)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject Sound_Type"));
+ if( !snd )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject Sound_Type" ) );
- snd_ptr = sound_new_sound(fname);
+ snd_ptr = sound_new_sound( fname );
- if (snd_ptr) {
- if (G.ssound) {
- G.ssound->sound= snd_ptr;
+ if( snd_ptr ) {
+ if( G.ssound ) {
+ G.ssound->sound = snd_ptr;
}
}
- if (!snd_ptr)
- return (EXPP_ReturnPyObjError (PyExc_IOError,
- "not a valid sound sample"));
+ if( !snd_ptr )
+ return ( EXPP_ReturnPyObjError( PyExc_IOError,
+ "not a valid sound sample" ) );
snd->sound = snd_ptr;
- return (PyObject *)snd;
+ return ( PyObject * ) snd;
}
/*****************************************************************************/
-/* Function: Sound_Init */
+/* Function: Sound_Init */
/*****************************************************************************/
-PyObject *Sound_Init (void)
+PyObject *Sound_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
Sound_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Sound", M_Sound_methods, M_Sound_doc);
+ submodule =
+ Py_InitModule3( "Blender.Sound", M_Sound_methods,
+ M_Sound_doc );
- return (submodule);
+ return ( submodule );
}
/************************/
@@ -332,140 +336,142 @@ PyObject *Sound_Init (void)
/************************/
/*****************************************************************************/
-/* Function: Sound_dealloc */
-/* Description: This is a callback function for the BPy_Sound type. It is */
-/* the destructor function. */
+/* Function: Sound_dealloc */
+/* Description: This is a callback function for the BPy_Sound type. It is */
+/* the destructor function. */
/*****************************************************************************/
-static void Sound_dealloc (BPy_Sound *self)
+static void Sound_dealloc( BPy_Sound * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
-/* Function: Sound_CreatePyObject */
-/* Description: This function will create a new BPy_Sound from an existing */
-/* Blender Sound structure. */
+/* Function: Sound_CreatePyObject */
+/* Description: This function will create a new BPy_Sound from an existing */
+/* Blender Sound structure. */
/*****************************************************************************/
-PyObject *Sound_CreatePyObject (bSound *snd)
+PyObject *Sound_CreatePyObject( bSound * snd )
{
BPy_Sound *py_snd;
- py_snd = (BPy_Sound *)PyObject_NEW (BPy_Sound, &Sound_Type);
+ py_snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
- if (!py_snd)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Sound object");
+ if( !py_snd )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Sound object" );
py_snd->sound = snd;
- return (PyObject *)py_snd;
+ return ( PyObject * ) py_snd;
}
/*****************************************************************************/
-/* Function: Sound_CheckPyObject */
+/* Function: Sound_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
-/* type Sound. Otherwise it will return false. */
+/* type Sound. Otherwise it will return false. */
/*****************************************************************************/
-int Sound_CheckPyObject (PyObject *pyobj)
+int Sound_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Sound_Type);
+ return ( pyobj->ob_type == &Sound_Type );
}
/*****************************************************************************/
-/* Function: Sound_FromPyObject */
-/* Description: Returns the Blender Sound associated with this object */
+/* Function: Sound_FromPyObject */
+/* Description: Returns the Blender Sound associated with this object */
/*****************************************************************************/
-bSound *Sound_FromPyObject (PyObject *pyobj)
+bSound *Sound_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Sound *)pyobj)->sound;
+ return ( ( BPy_Sound * ) pyobj )->sound;
}
/*****************************************************************************/
-/* Python BPy_Sound methods: */
+/* Python BPy_Sound methods: */
/*****************************************************************************/
-static PyObject *Sound_getName(BPy_Sound *self)
+static PyObject *Sound_getName( BPy_Sound * self )
{
- PyObject *attr = PyString_FromString(self->sound->id.name+2);
+ PyObject *attr = PyString_FromString( self->sound->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Sound.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Sound.name attribute" ) );
}
-static PyObject *Sound_getFilename(BPy_Sound *self)
+static PyObject *Sound_getFilename( BPy_Sound * self )
{
- PyObject *attr = PyString_FromString(self->sound->name);
+ PyObject *attr = PyString_FromString( self->sound->name );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Sound.filename attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Sound.filename attribute" ) );
}
-static PyObject *Sound_play(BPy_Sound *self)
+static PyObject *Sound_play( BPy_Sound * self )
{
- sound_play_sound(self->sound);
+ sound_play_sound( self->sound );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Sound_makeActive(BPy_Sound *self)
+static PyObject *Sound_makeActive( BPy_Sound * self )
{
bSound *snd_ptr = self->sound;
- if (snd_ptr) {
- if (G.ssound) {
+ if( snd_ptr ) {
+ if( G.ssound ) {
G.ssound->sound = snd_ptr;
}
}
- allqueue(REDRAWSOUND, 0);
- allqueue(REDRAWBUTSLOGIC, 0);
+ allqueue( REDRAWSOUND, 0 );
+ allqueue( REDRAWBUTSLOGIC, 0 );
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: Sound_getAttr */
-/* Description: This is a callback function for the BPy_Sound type. It is */
-/* the function that accesses BPy_Sound member variables and */
-/* methods. */
+/* Function: Sound_getAttr */
+/* Description: This is a callback function for the BPy_Sound type. It is */
+/* the function that accesses BPy_Sound member variables and */
+/* methods. */
/*****************************************************************************/
-static PyObject *Sound_getAttr (BPy_Sound *self, char *name)
+static PyObject *Sound_getAttr( BPy_Sound * self, char *name )
{
PyObject *attr = Py_None;
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->sound->id.name+2);
- else if (strcmp(name, "filename") == 0)
- attr = PyString_FromString(self->sound->name);
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->sound->id.name + 2 );
+ else if( strcmp( name, "filename" ) == 0 )
+ attr = PyString_FromString( self->sound->name );
- else if (strcmp(name, "__members__") == 0)
- attr = Py_BuildValue("[s,s]",
- "name", "filename");
+ else if( strcmp( name, "__members__" ) == 0 )
+ attr = Py_BuildValue( "[s,s]", "name", "filename" );
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
- if (attr != Py_None) return attr; /* attribute found, return its value */
+ if( attr != Py_None )
+ return attr; /* attribute found, return its value */
/* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Sound_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Sound_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
-/* Function: Sound_setAttr */
+/* Function: Sound_setAttr */
/* Description: This is a callback function for the BPy_Sound type. It is the*/
-/* function that changes Sound object members values. If this */
-/* data is linked to a Blender Sound, it also gets updated. */
+/* function that changes Sound object members values. If this */
+/* data is linked to a Blender Sound, it also gets updated. */
/*****************************************************************************/
-static int Sound_setAttr (BPy_Sound *self, char *name, PyObject *value)
+static int Sound_setAttr( BPy_Sound * self, char *name, PyObject * value )
{
- PyObject *valtuple;
+ PyObject *valtuple;
PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
@@ -473,50 +479,52 @@ static int Sound_setAttr (BPy_Sound *self, char *name, PyObject *value)
* function anyway, since it already has error checking, clamps to the right
* interval and updates the Blender Sound structure when necessary. */
- valtuple = Py_BuildValue("(O)", value); /*the set* functions expect a tuple*/
+ valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "SoundSetAttr: couldn't create PyTuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "SoundSetAttr: couldn't create PyTuple" );
/* if (strcmp (name, "name") == 0)
error = Sound_setName (self, valtuple);
- else */ {
- /* Error: no such member in the Sound object structure */
- Py_DECREF(value);
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found or immutable"));
+ else */ {
+ /* Error: no such member in the Sound object structure */
+ Py_DECREF( value );
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found or immutable" ) );
}
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF(Py_None); /* incref'ed by the called set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* incref'ed by the called set* function */
+ return 0; /* normal exit */
}
/*****************************************************************************/
-/* Function: Sound_compare */
-/* Description: This is a callback function for the BPy_Sound type. It */
-/* compares two Sound_Type objects. Only the "==" and "!=" */
-/* comparisons are meaninful. Returns 0 for equality and -1 if */
-/* they don't point to the same Blender Sound struct. */
-/* In Python it becomes 1 if they are equal, 0 otherwise. */
+/* Function: Sound_compare */
+/* Description: This is a callback function for the BPy_Sound type. It */
+/* compares two Sound_Type objects. Only the "==" and "!=" */
+/* comparisons are meaninful. Returns 0 for equality and -1 if */
+/* they don't point to the same Blender Sound struct. */
+/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static int Sound_compare (BPy_Sound *a, BPy_Sound *b)
+static int Sound_compare( BPy_Sound * a, BPy_Sound * b )
{
bSound *pa = a->sound, *pb = b->sound;
- return (pa == pb) ? 0:-1;
+ return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
-/* Function: Sound_repr */
-/* Description: This is a callback function for the BPy_Sound type. It */
-/* builds a meaninful string to represent Sound objects. */
+/* Function: Sound_repr */
+/* Description: This is a callback function for the BPy_Sound type. It */
+/* builds a meaninful string to represent Sound objects. */
/*****************************************************************************/
-static PyObject *Sound_repr (BPy_Sound *self)
+static PyObject *Sound_repr( BPy_Sound * self )
{
- return PyString_FromFormat("[Sound \"%s\"]", self->sound->id.name+2);
+ return PyString_FromFormat( "[Sound \"%s\"]",
+ self->sound->id.name + 2 );
}
diff --git a/source/blender/python/api2_2x/Sound.h b/source/blender/python/api2_2x/Sound.h
index 1f6f82b6672..22872cec363 100644
--- a/source/blender/python/api2_2x/Sound.h
+++ b/source/blender/python/api2_2x/Sound.h
@@ -40,18 +40,15 @@
/* Python BPy_Sound structure definition */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- bSound *sound;
+ PyObject_HEAD bSound * sound;
} BPy_Sound;
/*****************************************************************************/
/* Module Blender.Sound - public functions */
/*****************************************************************************/
-PyObject *Sound_Init (void);
-PyObject *Sound_CreatePyObject (bSound *sound);
-bSound *Sound_FromPyObject (PyObject *pyobj);
-int Sound_CheckPyObject (PyObject *pyobj);
-
-#endif /* EXPP_SOUND_H */
-
+PyObject *Sound_Init( void );
+PyObject *Sound_CreatePyObject( bSound * sound );
+bSound *Sound_FromPyObject( PyObject * pyobj );
+int Sound_CheckPyObject( PyObject * pyobj );
+#endif /* EXPP_SOUND_H */
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
index b0f4f169f46..56b80f7b79e 100644
--- a/source/blender/python/api2_2x/Sys.c
+++ b/source/blender/python/api2_2x/Sys.c
@@ -41,45 +41,45 @@
/*****************************************************************************/
/* Python API function prototypes for the sys module. */
/*****************************************************************************/
-static PyObject *M_sys_basename (PyObject *self, PyObject *args);
-static PyObject *M_sys_dirname (PyObject *self, PyObject *args);
-static PyObject *M_sys_join (PyObject *self, PyObject *args);
-static PyObject *M_sys_splitext (PyObject *self, PyObject *args);
-static PyObject *M_sys_makename (PyObject *self, PyObject *args, PyObject *kw);
-static PyObject *M_sys_exists (PyObject *self, PyObject *args);
-static PyObject *M_sys_time (PyObject *self);
-static PyObject *M_sys_sleep (PyObject *self, PyObject *args);
+static PyObject *M_sys_basename( PyObject * self, PyObject * args );
+static PyObject *M_sys_dirname( PyObject * self, PyObject * args );
+static PyObject *M_sys_join( PyObject * self, PyObject * args );
+static PyObject *M_sys_splitext( PyObject * self, PyObject * args );
+static PyObject *M_sys_makename( PyObject * self, PyObject * args,
+ PyObject * kw );
+static PyObject *M_sys_exists( PyObject * self, PyObject * args );
+static PyObject *M_sys_time( PyObject * self );
+static PyObject *M_sys_sleep( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.sys.__doc__ */
/*****************************************************************************/
-static char M_sys_doc[] =
-"The Blender.sys submodule\n\
+static char M_sys_doc[] = "The Blender.sys submodule\n\
\n\
This is a minimal system module to supply simple functionality available\n\
in the default Python module os.";
static char M_sys_basename_doc[] =
-"(path) - Split 'path' in dir and filename.\n\
+ "(path) - Split 'path' in dir and filename.\n\
Return the filename.";
static char M_sys_dirname_doc[] =
-"(path) - Split 'path' in dir and filename.\n\
+ "(path) - Split 'path' in dir and filename.\n\
Return the dir.";
static char M_sys_join_doc[] =
-"(dir, file) - Join dir and file to form a full filename.\n\
+ "(dir, file) - Join dir and file to form a full filename.\n\
Return the filename.";
static char M_sys_splitext_doc[] =
-"(path) - Split 'path' in root and extension:\n\
+ "(path) - Split 'path' in root and extension:\n\
/this/that/file.ext -> ('/this/that/file','.ext').\n\
Return the pair (root, extension).";
static char M_sys_makename_doc[] =
-"(path = Blender.Get('filename'), ext = \"\", strip = 0) -\n\
+ "(path = Blender.Get('filename'), ext = \"\", strip = 0) -\n\
Strip dir and extension from path, leaving only a name, then append 'ext'\n\
to it (if given) and return the resulting string.\n\n\
(path) - string: a pathname -- Blender.Get('filename') if 'path' isn't given;\n\
@@ -90,17 +90,17 @@ Ex: makename(ext='.txt') returns 'untitled.txt' if Blender.Get('filename')\n\
returns a path to the file 'untitled.blend'";
static char M_sys_time_doc[] =
-"() - Return a float representing time elapsed in seconds.\n\
+ "() - Return a float representing time elapsed in seconds.\n\
Each successive call is garanteed to return values greater than or\n\
equal to the previous call.";
static char M_sys_sleep_doc[] =
-"(milliseconds = 10) - Sleep for the specified time.\n\
+ "(milliseconds = 10) - Sleep for the specified time.\n\
(milliseconds = 10) - the amount of time in milliseconds to sleep.\n\
This function can be necessary in tight 'get event' loops.";
static char M_sys_exists_doc[] =
-"(path) - Check if the given pathname exists.\n\
+ "(path) - Check if the given pathname exists.\n\
The return value is as follows:\n\
\t 0: path doesn't exist;\n\
\t 1: path is an existing filename;\n\
@@ -111,48 +111,49 @@ The return value is as follows:\n\
/* Python method structure definition for Blender.sys module: */
/*****************************************************************************/
struct PyMethodDef M_sys_methods[] = {
- {"basename", M_sys_basename, METH_VARARGS, M_sys_basename_doc},
- {"dirname", M_sys_dirname, METH_VARARGS, M_sys_dirname_doc},
- {"join", M_sys_join, METH_VARARGS, M_sys_join_doc},
- {"splitext", M_sys_splitext, METH_VARARGS, M_sys_splitext_doc},
- {"makename", (PyCFunction)M_sys_makename, METH_VARARGS|METH_KEYWORDS,
- M_sys_makename_doc},
- {"exists", M_sys_exists, METH_VARARGS, M_sys_exists_doc},
- {"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc},
- {"time", (PyCFunction)M_sys_time, METH_NOARGS, M_sys_time_doc},
- {NULL, NULL, 0, NULL}
+ {"basename", M_sys_basename, METH_VARARGS, M_sys_basename_doc},
+ {"dirname", M_sys_dirname, METH_VARARGS, M_sys_dirname_doc},
+ {"join", M_sys_join, METH_VARARGS, M_sys_join_doc},
+ {"splitext", M_sys_splitext, METH_VARARGS, M_sys_splitext_doc},
+ {"makename", ( PyCFunction ) M_sys_makename,
+ METH_VARARGS | METH_KEYWORDS,
+ M_sys_makename_doc},
+ {"exists", M_sys_exists, METH_VARARGS, M_sys_exists_doc},
+ {"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc},
+ {"time", ( PyCFunction ) M_sys_time, METH_NOARGS, M_sys_time_doc},
+ {NULL, NULL, 0, NULL}
};
/* Module Functions */
-static PyObject *g_sysmodule = NULL; /* pointer to Blender.sys module */
+static PyObject *g_sysmodule = NULL; /* pointer to Blender.sys module */
-PyObject *sys_Init (void)
+PyObject *sys_Init( void )
{
- PyObject *submodule, *dict, *sep;
+ PyObject *submodule, *dict, *sep;
- submodule = Py_InitModule3("Blender.sys", M_sys_methods, M_sys_doc);
+ submodule = Py_InitModule3( "Blender.sys", M_sys_methods, M_sys_doc );
g_sysmodule = submodule;
- dict = PyModule_GetDict(submodule);
+ dict = PyModule_GetDict( submodule );
#ifdef WIN32
- sep = Py_BuildValue("s", "\\");
+ sep = Py_BuildValue( "s", "\\" );
#else
- sep = Py_BuildValue("s", "/");
+ sep = Py_BuildValue( "s", "/" );
#endif
- if (sep) {
- Py_INCREF(sep);
- PyDict_SetItemString(dict, "dirsep" , sep);
- PyDict_SetItemString(dict, "sep" , sep);
+ if( sep ) {
+ Py_INCREF( sep );
+ PyDict_SetItemString( dict, "dirsep", sep );
+ PyDict_SetItemString( dict, "sep", sep );
}
return submodule;
}
-static PyObject *M_sys_basename (PyObject *self, PyObject *args)
+static PyObject *M_sys_basename( PyObject * self, PyObject * args )
{
PyObject *c;
@@ -160,32 +161,33 @@ static PyObject *M_sys_basename (PyObject *self, PyObject *args)
char sep;
int n, len;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- len = strlen(name);
+ len = strlen( name );
- c = PyObject_GetAttrString (g_sysmodule, "dirsep");
- sep = PyString_AsString(c)[0];
- Py_DECREF(c);
+ c = PyObject_GetAttrString( g_sysmodule, "dirsep" );
+ sep = PyString_AsString( c )[0];
+ Py_DECREF( c );
- p = strrchr(name, sep);
+ p = strrchr( name, sep );
- if (p) {
- n = name + len - p - 1; /* - 1 because we don't want the sep */
+ if( p ) {
+ n = name + len - p - 1; /* - 1 because we don't want the sep */
- if (n > FILE_MAXFILE)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError, "path too long");
+ if( n > FILE_MAXFILE )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "path too long" );
- BLI_strncpy(basename, p + 1, n + 1);
- return Py_BuildValue("s", basename);
+ BLI_strncpy( basename, p + 1, n + 1 );
+ return Py_BuildValue( "s", basename );
}
- return Py_BuildValue("s", name);
+ return Py_BuildValue( "s", name );
}
-static PyObject *M_sys_dirname (PyObject *self, PyObject *args)
+static PyObject *M_sys_dirname( PyObject * self, PyObject * args )
{
PyObject *c;
@@ -193,64 +195,66 @@ static PyObject *M_sys_dirname (PyObject *self, PyObject *args)
char sep;
int n;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- c = PyObject_GetAttrString (g_sysmodule, "dirsep");
- sep = PyString_AsString(c)[0];
- Py_DECREF(c);
+ c = PyObject_GetAttrString( g_sysmodule, "dirsep" );
+ sep = PyString_AsString( c )[0];
+ Py_DECREF( c );
- p = strrchr(name, sep);
+ p = strrchr( name, sep );
- if (p) {
+ if( p ) {
n = p - name;
- if (n > FILE_MAXDIR)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError, "path too long");
+ if( n > FILE_MAXDIR )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "path too long" );
- BLI_strncpy(dirname, name, n + 1);
- return Py_BuildValue("s", dirname);
+ BLI_strncpy( dirname, name, n + 1 );
+ return Py_BuildValue( "s", dirname );
}
- return Py_BuildValue("s", ".");
+ return Py_BuildValue( "s", "." );
}
-static PyObject *M_sys_join (PyObject *self, PyObject *args)
+static PyObject *M_sys_join( PyObject * self, PyObject * args )
{
PyObject *c = NULL;
char *name = NULL, *path = NULL;
- char filename[FILE_MAXDIR+FILE_MAXFILE];
+ char filename[FILE_MAXDIR + FILE_MAXFILE];
char sep;
int pathlen = 0, namelen = 0;
- if (!PyArg_ParseTuple(args, "ss", &path, &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "ss", &path, &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- pathlen = strlen(path) + 1;
- namelen = strlen(name) + 1; /* + 1 to account for '\0' for BLI_strncpy */
+ pathlen = strlen( path ) + 1;
+ namelen = strlen( name ) + 1; /* + 1 to account for '\0' for BLI_strncpy */
- if (pathlen + namelen > FILE_MAXDIR+FILE_MAXFILE - 1)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError, "filename is too long.");
+ if( pathlen + namelen > FILE_MAXDIR + FILE_MAXFILE - 1 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "filename is too long." );
- c = PyObject_GetAttrString (g_sysmodule, "dirsep");
- sep = PyString_AsString(c)[0];
- Py_DECREF(c);
-
- BLI_strncpy(filename, path, pathlen);
+ c = PyObject_GetAttrString( g_sysmodule, "dirsep" );
+ sep = PyString_AsString( c )[0];
+ Py_DECREF( c );
- if (filename[pathlen - 2] != sep) {
+ BLI_strncpy( filename, path, pathlen );
+
+ if( filename[pathlen - 2] != sep ) {
filename[pathlen - 1] = sep;
pathlen += 1;
}
- BLI_strncpy(filename + pathlen - 1, name, namelen);
+ BLI_strncpy( filename + pathlen - 1, name, namelen );
- return Py_BuildValue("s", filename);
+ return Py_BuildValue( "s", filename );
}
-static PyObject *M_sys_splitext (PyObject *self, PyObject *args)
+static PyObject *M_sys_splitext( PyObject * self, PyObject * args )
{
PyObject *c;
@@ -258,126 +262,135 @@ static PyObject *M_sys_splitext (PyObject *self, PyObject *args)
char sep;
int n, len;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- len = strlen(name);
+ len = strlen( name );
- c = PyObject_GetAttrString (g_sysmodule, "dirsep");
- sep = PyString_AsString(c)[0];
- Py_DECREF(c);
+ c = PyObject_GetAttrString( g_sysmodule, "dirsep" );
+ sep = PyString_AsString( c )[0];
+ Py_DECREF( c );
- dot = strrchr(name, '.');
+ dot = strrchr( name, '.' );
- if (!dot) return Py_BuildValue("ss", name, "");
+ if( !dot )
+ return Py_BuildValue( "ss", name, "" );
- p = strrchr(name, sep);
+ p = strrchr( name, sep );
- if (p) {
- if (p > dot) return Py_BuildValue("ss", name, "");
+ if( p ) {
+ if( p > dot )
+ return Py_BuildValue( "ss", name, "" );
}
n = name + len - dot;
/* loong extensions are supported -- foolish, but Python's os.path.splitext
* supports them, so ... */
- if (n > FILE_MAXFILE || (len - n ) > FILE_MAXFILE)
- EXPP_ReturnPyObjError(PyExc_RuntimeError, "path too long");
+ if( n > FILE_MAXFILE || ( len - n ) > FILE_MAXFILE )
+ EXPP_ReturnPyObjError( PyExc_RuntimeError, "path too long" );
- BLI_strncpy(ext, dot, n + 1);
- BLI_strncpy(path, name, dot - name + 1);
+ BLI_strncpy( ext, dot, n + 1 );
+ BLI_strncpy( path, name, dot - name + 1 );
- return Py_BuildValue("ss", path, ext);
+ return Py_BuildValue( "ss", path, ext );
}
-static PyObject *M_sys_makename(PyObject *self, PyObject *args, PyObject *kw)
+static PyObject *M_sys_makename( PyObject * self, PyObject * args,
+ PyObject * kw )
{
char *path = G.sce, *ext = NULL;
int strip = 0;
- static char *kwlist[] = {"path", "ext", "strip", NULL};
+ static char *kwlist[] = { "path", "ext", "strip", NULL };
char *dot = NULL, *p = NULL, basename[FILE_MAXFILE];
char sep;
int n, len, lenext = 0;
PyObject *c;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|ssi", kwlist,
- &path, &ext, &strip))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected one or two strings and an int (or nothing) as arguments");
+ if( !PyArg_ParseTupleAndKeywords( args, kw, "|ssi", kwlist,
+ &path, &ext, &strip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected one or two strings and an int (or nothing) as arguments" );
- len = strlen(path) + 1; /* + 1 to consider ending '\0' */
- if (ext) lenext = strlen(ext) + 1;
+ len = strlen( path ) + 1; /* + 1 to consider ending '\0' */
+ if( ext )
+ lenext = strlen( ext ) + 1;
- if ((len + lenext) > FILE_MAXFILE)
- return EXPP_ReturnPyObjError(PyExc_RuntimeError, "path too long");
+ if( ( len + lenext ) > FILE_MAXFILE )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "path too long" );
- c = PyObject_GetAttrString (g_sysmodule, "dirsep");
- sep = PyString_AsString(c)[0];
- Py_DECREF(c);
+ c = PyObject_GetAttrString( g_sysmodule, "dirsep" );
+ sep = PyString_AsString( c )[0];
+ Py_DECREF( c );
- p = strrchr(path, sep);
+ p = strrchr( path, sep );
- if (p && strip) {
+ if( p && strip ) {
n = path + len - p;
- BLI_strncpy(basename, p + 1, n); /* + 1 to skip the sep */
- }
- else
- BLI_strncpy(basename, path, len);
+ BLI_strncpy( basename, p + 1, n ); /* + 1 to skip the sep */
+ } else
+ BLI_strncpy( basename, path, len );
- dot = strrchr(basename, '.');
+ dot = strrchr( basename, '.' );
/* now the extension: always remove the one in basename */
- if (dot || ext) {
- if (!ext)
+ if( dot || ext ) {
+ if( !ext )
basename[dot - basename] = '\0';
- else { /* if user gave an ext, append it */
+ else { /* if user gave an ext, append it */
- if (dot) n = dot - basename;
- else n = strlen(basename);
+ if( dot )
+ n = dot - basename;
+ else
+ n = strlen( basename );
- BLI_strncpy(basename + n, ext, lenext);
+ BLI_strncpy( basename + n, ext, lenext );
}
}
- return PyString_FromString(basename);
+ return PyString_FromString( basename );
}
-static PyObject *M_sys_time (PyObject *self)
+static PyObject *M_sys_time( PyObject * self )
{
- double t = PIL_check_seconds_timer();
- return Py_BuildValue("d", t);
+ double t = PIL_check_seconds_timer( );
+ return Py_BuildValue( "d", t );
}
-static PyObject *M_sys_sleep (PyObject *self, PyObject *args)
+static PyObject *M_sys_sleep( PyObject * self, PyObject * args )
{
int millisecs = 10;
- if (!PyArg_ParseTuple(args, "|i", &millisecs))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
+ if( !PyArg_ParseTuple( args, "|i", &millisecs ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
- PIL_sleep_ms(millisecs);
+ PIL_sleep_ms( millisecs );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_sys_exists (PyObject *self, PyObject *args)
+static PyObject *M_sys_exists( PyObject * self, PyObject * args )
{
struct stat st;
char *fname = NULL;
int res = 0, i = -1;
- if (!PyArg_ParseTuple(args, "s", &fname))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string (pathname) argument");
+ if( !PyArg_ParseTuple( args, "s", &fname ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string (pathname) argument" );
- res = stat(fname, &st);
+ res = stat( fname, &st );
- if (res == -1) i = 0;
- else if (S_ISREG(st.st_mode)) i = 1;
- else if (S_ISDIR(st.st_mode)) i = 2;
+ if( res == -1 )
+ i = 0;
+ else if( S_ISREG( st.st_mode ) )
+ i = 1;
+ else if( S_ISDIR( st.st_mode ) )
+ i = 2;
/* i stays as -1 if path exists but is neither a regular file nor a dir */
- return Py_BuildValue("i", i);
+ return Py_BuildValue( "i", i );
}
diff --git a/source/blender/python/api2_2x/Sys.h b/source/blender/python/api2_2x/Sys.h
index f50eba8135f..7817fff1fdc 100644
--- a/source/blender/python/api2_2x/Sys.h
+++ b/source/blender/python/api2_2x/Sys.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -32,4 +33,4 @@
#ifndef EXPP_sys_H
#define EXPP_sys_H
-#endif /* EXPP_sys_H */
+#endif /* EXPP_sys_H */
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index cb26fa394b1..029b53f2664 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -51,171 +51,167 @@
/*****************************************************************************/
/* Python API function prototypes for the Text module. */
/*****************************************************************************/
-static PyObject *M_Text_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Text_Get (PyObject *self, PyObject *args);
-static PyObject *M_Text_Load (PyObject *self, PyObject *args);
-static PyObject *M_Text_unlink (PyObject *self, PyObject *args);
+static PyObject *M_Text_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Text_Get( PyObject * self, PyObject * args );
+static PyObject *M_Text_Load( PyObject * self, PyObject * args );
+static PyObject *M_Text_unlink( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Text.__doc__ */
/*****************************************************************************/
-static char M_Text_doc[] =
-"The Blender Text module\n\n";
+static char M_Text_doc[] = "The Blender Text module\n\n";
-static char M_Text_New_doc[] =
-"() - return a new Text object";
+static char M_Text_New_doc[] = "() - return a new Text object";
-static char M_Text_Get_doc[] =
-"(name) - return the Text with name 'name', \
+static char M_Text_Get_doc[] = "(name) - return the Text with name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all Texts in the\ncurrent scene.";
static char M_Text_Load_doc[] =
-"(filename) - return text from file filename as a Text Object, \
+ "(filename) - return text from file filename as a Text Object, \
returns None if not found.\n";
static char M_Text_unlink_doc[] =
-"(text) - remove Text object 'text' from Blender";
+ "(text) - remove Text object 'text' from Blender";
/*****************************************************************************/
/* Python method structure definition for Blender.Text module: */
/*****************************************************************************/
struct PyMethodDef M_Text_methods[] = {
- {"New",(PyCFunction)M_Text_New, METH_VARARGS|METH_KEYWORDS,
- M_Text_New_doc},
- {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
- {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
- {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc},
- {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Text_New, METH_VARARGS | METH_KEYWORDS,
+ M_Text_New_doc},
+ {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
+ {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
+ {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc},
+ {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_Text structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Text *text;
+ PyObject_HEAD Text * text;
} BPy_Text;
-static int Text_IsLinked(BPy_Text *self);
+static int Text_IsLinked( BPy_Text * self );
/*****************************************************************************/
/* Python BPy_Text methods declarations: */
/*****************************************************************************/
-static PyObject *Text_getName(BPy_Text *self);
-static PyObject *Text_getFilename(BPy_Text *self);
-static PyObject *Text_getNLines(BPy_Text *self);
-static PyObject *Text_setName(BPy_Text *self, PyObject *args);
-static PyObject *Text_clear(BPy_Text *self, PyObject *args);
-static PyObject *Text_write(BPy_Text *self, PyObject *args);
-static PyObject *Text_set(BPy_Text *self, PyObject *args);
-static PyObject *Text_asLines(BPy_Text *self, PyObject *args);
+static PyObject *Text_getName( BPy_Text * self );
+static PyObject *Text_getFilename( BPy_Text * self );
+static PyObject *Text_getNLines( BPy_Text * self );
+static PyObject *Text_setName( BPy_Text * self, PyObject * args );
+static PyObject *Text_clear( BPy_Text * self, PyObject * args );
+static PyObject *Text_write( BPy_Text * self, PyObject * args );
+static PyObject *Text_set( BPy_Text * self, PyObject * args );
+static PyObject *Text_asLines( BPy_Text * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Text methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Text_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Text_getName, METH_NOARGS,
- "() - Return Text Object name"},
- {"getFilename", (PyCFunction)Text_getFilename, METH_VARARGS,
- "() - Return Text Object filename"},
- {"getNLines", (PyCFunction)Text_getNLines, METH_VARARGS,
- "() - Return number of lines in text buffer"},
- {"setName", (PyCFunction)Text_setName, METH_VARARGS,
- "(str) - Change Text Object name"},
- {"clear", (PyCFunction)Text_clear, METH_VARARGS,
- "() - Clear Text buffer"},
- {"write", (PyCFunction)Text_write, METH_VARARGS,
- "(line) - Append string 'str' to Text buffer"},
- {"set", (PyCFunction)Text_set, METH_VARARGS,
- "(name, val) - Set attribute 'name' to value 'val'"},
- {"asLines", (PyCFunction)Text_asLines, METH_VARARGS,
- "() - Return text buffer as a list of lines"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Text_getName, METH_NOARGS,
+ "() - Return Text Object name"},
+ {"getFilename", ( PyCFunction ) Text_getFilename, METH_VARARGS,
+ "() - Return Text Object filename"},
+ {"getNLines", ( PyCFunction ) Text_getNLines, METH_VARARGS,
+ "() - Return number of lines in text buffer"},
+ {"setName", ( PyCFunction ) Text_setName, METH_VARARGS,
+ "(str) - Change Text Object name"},
+ {"clear", ( PyCFunction ) Text_clear, METH_VARARGS,
+ "() - Clear Text buffer"},
+ {"write", ( PyCFunction ) Text_write, METH_VARARGS,
+ "(line) - Append string 'str' to Text buffer"},
+ {"set", ( PyCFunction ) Text_set, METH_VARARGS,
+ "(name, val) - Set attribute 'name' to value 'val'"},
+ {"asLines", ( PyCFunction ) Text_asLines, METH_VARARGS,
+ "() - Return text buffer as a list of lines"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python Text_Type callback function prototypes: */
/*****************************************************************************/
-static void Text_dealloc (BPy_Text *self);
-static int Text_setAttr (BPy_Text *self, char *name, PyObject *v);
-static PyObject *Text_getAttr (BPy_Text *self, char *name);
-static int Text_compare (BPy_Text *a, BPy_Text *b);
-static PyObject *Text_repr (BPy_Text *self);
+static void Text_dealloc( BPy_Text * self );
+static int Text_setAttr( BPy_Text * self, char *name, PyObject * v );
+static PyObject *Text_getAttr( BPy_Text * self, char *name );
+static int Text_compare( BPy_Text * a, BPy_Text * b );
+static PyObject *Text_repr( BPy_Text * self );
/*****************************************************************************/
/* Python Text_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Text_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Text", /* tp_name */
- sizeof (BPy_Text), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Text_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Text_getAttr, /* tp_getattr */
- (setattrfunc)Text_setAttr, /* tp_setattr */
- (cmpfunc)Text_compare, /* tp_compare */
- (reprfunc)Text_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_Text_methods, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject Text_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Text", /* tp_name */
+ sizeof( BPy_Text ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Text_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Text_getAttr, /* tp_getattr */
+ ( setattrfunc ) Text_setAttr, /* tp_setattr */
+ ( cmpfunc ) Text_compare, /* tp_compare */
+ ( reprfunc ) Text_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_Text_methods, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
/* Function: M_Text_New */
/* Python equivalent: Blender.Text.New */
/*****************************************************************************/
-static PyObject *M_Text_New(PyObject *self, PyObject *args, PyObject *keywords)
+static PyObject *M_Text_New( PyObject * self, PyObject * args,
+ PyObject * keywords )
{
- char *name = NULL;
- char buf[21];
- int follow = 0;
- Text *bl_text; /* blender text object */
- PyObject *py_text; /* python wrapper */
-
- if (!PyArg_ParseTuple(args, "|si", &name, &follow))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string and int arguments (or nothing)");
-
- bl_text = add_empty_text();
-
- if (bl_text) {
- /* do not set user count because Text is already linked */
-
- /* create python wrapper obj */
- py_text = Text_CreatePyObject (bl_text);
- }
- else
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Text Object in Blender");
- if (!py_text)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Text Object wrapper");
-
- if (follow) bl_text->flags |= EXPP_TEXT_MODE_FOLLOW;
-
- if (name) {
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&bl_text->id, buf);
- }
-
- return py_text;
+ char *name = NULL;
+ char buf[21];
+ int follow = 0;
+ Text *bl_text; /* blender text object */
+ PyObject *py_text; /* python wrapper */
+
+ if( !PyArg_ParseTuple( args, "|si", &name, &follow ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string and int arguments (or nothing)" );
+
+ bl_text = add_empty_text( );
+
+ if( bl_text ) {
+ /* do not set user count because Text is already linked */
+
+ /* create python wrapper obj */
+ py_text = Text_CreatePyObject( bl_text );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Text Object in Blender" );
+ if( !py_text )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Text Object wrapper" );
+
+ if( follow )
+ bl_text->flags |= EXPP_TEXT_MODE_FOLLOW;
+
+ if( name ) {
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &bl_text->id, buf );
+ }
+
+ return py_text;
}
/*****************************************************************************/
@@ -226,65 +222,67 @@ static PyObject *M_Text_New(PyObject *self, PyObject *args, PyObject *keywords)
/* passed in, a list of all text names in the current */
/* scene is returned. */
/*****************************************************************************/
-static PyObject *M_Text_Get(PyObject *self, PyObject *args)
+static PyObject *M_Text_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
- Text *txt_iter;
+ char *name = NULL;
+ Text *txt_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
- txt_iter = G.main->text.first;
+ txt_iter = G.main->text.first;
- if (name) { /* (name) - Search text by name */
+ if( name ) { /* (name) - Search text by name */
- PyObject *wanted_txt = NULL;
+ PyObject *wanted_txt = NULL;
- while ((txt_iter) && (wanted_txt == NULL)) {
+ while( ( txt_iter ) && ( wanted_txt == NULL ) ) {
- if (strcmp (name, txt_iter->id.name+2) == 0) {
- wanted_txt = Text_CreatePyObject (txt_iter);
- }
+ if( strcmp( name, txt_iter->id.name + 2 ) == 0 ) {
+ wanted_txt = Text_CreatePyObject( txt_iter );
+ }
- txt_iter = txt_iter->id.next;
- }
+ txt_iter = txt_iter->id.next;
+ }
- if (wanted_txt == NULL) { /* Requested text doesn't exist */
- char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Text \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ if( wanted_txt == NULL ) { /* Requested text doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Text \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
+ }
- return wanted_txt;
- }
+ return wanted_txt;
+ }
- else { /* () - return a list of all texts in the scene */
- int index = 0;
- PyObject *txtlist, *pyobj;
+ else { /* () - return a list of all texts in the scene */
+ int index = 0;
+ PyObject *txtlist, *pyobj;
- txtlist = PyList_New (BLI_countlist (&(G.main->text)));
+ txtlist = PyList_New( BLI_countlist( &( G.main->text ) ) );
- if (txtlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ if( txtlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (txt_iter) {
- pyobj = Text_CreatePyObject(txt_iter);
+ while( txt_iter ) {
+ pyobj = Text_CreatePyObject( txt_iter );
- if (!pyobj)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString"));
+ if( !pyobj )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create PyString" ) );
- PyList_SET_ITEM (txtlist, index, pyobj);
+ PyList_SET_ITEM( txtlist, index, pyobj );
- txt_iter = txt_iter->id.next;
- index++;
- }
+ txt_iter = txt_iter->id.next;
+ index++;
+ }
- return (txtlist);
- }
+ return ( txtlist );
+ }
}
/*****************************************************************************/
@@ -293,30 +291,30 @@ static PyObject *M_Text_Get(PyObject *self, PyObject *args)
/* Description: Receives a filename and returns the text object */
/* created from the corresponding file. */
/*****************************************************************************/
-static PyObject *M_Text_Load(PyObject *self, PyObject *args)
+static PyObject *M_Text_Load( PyObject * self, PyObject * args )
{
- char *fname;
- Text *txt_ptr;
- BPy_Text *txt;
+ char *fname;
+ Text *txt_ptr;
+ BPy_Text *txt;
+
+ if( !PyArg_ParseTuple( args, "s", &fname ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
- if (!PyArg_ParseTuple(args, "s", &fname))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
-
- txt = (BPy_Text *)PyObject_NEW(BPy_Text, &Text_Type);
+ txt = ( BPy_Text * ) PyObject_NEW( BPy_Text, &Text_Type );
- if (!txt)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject Text_Type");
+ if( !txt )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject Text_Type" );
- txt_ptr = add_text(fname);
- if (!txt_ptr)
- return EXPP_ReturnPyObjError (PyExc_IOError,
- "couldn't load text");
+ txt_ptr = add_text( fname );
+ if( !txt_ptr )
+ return EXPP_ReturnPyObjError( PyExc_IOError,
+ "couldn't load text" );
- txt->text = txt_ptr;
+ txt->text = txt_ptr;
- return (PyObject *)txt;
+ return ( PyObject * ) txt;
}
/*****************************************************************************/
@@ -324,216 +322,221 @@ static PyObject *M_Text_Load(PyObject *self, PyObject *args)
/* Python equivalent: Blender.Text.unlink */
/* Description: Removes the given Text object from Blender */
/*****************************************************************************/
-static PyObject *M_Text_unlink(PyObject *self, PyObject *args)
+static PyObject *M_Text_unlink( PyObject * self, PyObject * args )
{
- BPy_Text *textobj;
- Text *text;
+ BPy_Text *textobj;
+ Text *text;
- if (!PyArg_ParseTuple(args, "O!", &Text_Type, &textobj))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a Text object as argument");
+ if( !PyArg_ParseTuple( args, "O!", &Text_Type, &textobj ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a Text object as argument" );
- text = ((BPy_Text *)textobj)->text;
+ text = ( ( BPy_Text * ) textobj )->text;
- if (!text)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "this text was already unlinked!");
+ if( !text )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "this text was already unlinked!" );
- BPY_clear_bad_scriptlinks(text);
- free_text_controllers(text);
- unlink_text(text);
+ BPY_clear_bad_scriptlinks( text );
+ free_text_controllers( text );
+ unlink_text( text );
- free_libblock(&G.main->text, text);
+ free_libblock( &G.main->text, text );
- ((BPy_Text *)textobj)->text = NULL;
+ ( ( BPy_Text * ) textobj )->text = NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: Text_Init */
/*****************************************************************************/
-PyObject *Text_Init (void)
+PyObject *Text_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Text_Type.ob_type = &PyType_Type;
+ Text_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Text", M_Text_methods, M_Text_doc);
+ submodule =
+ Py_InitModule3( "Blender.Text", M_Text_methods, M_Text_doc );
- return (submodule);
+ return ( submodule );
}
/*****************************************************************************/
/* Function: Text_CreatePyObject */
/*****************************************************************************/
-PyObject *Text_CreatePyObject (Text *txt)
+PyObject *Text_CreatePyObject( Text * txt )
{
- BPy_Text *pytxt;
+ BPy_Text *pytxt;
- pytxt = (BPy_Text *)PyObject_NEW (BPy_Text, &Text_Type);
+ pytxt = ( BPy_Text * ) PyObject_NEW( BPy_Text, &Text_Type );
- if (!pytxt)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Text PyObject");
+ if( !pytxt )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Text PyObject" );
- pytxt->text = txt;
+ pytxt->text = txt;
- return (PyObject *)pytxt;
+ return ( PyObject * ) pytxt;
}
/*****************************************************************************/
/* Python BPy_Text methods: */
/*****************************************************************************/
-static PyObject *Text_getName(BPy_Text *self)
+static PyObject *Text_getName( BPy_Text * self )
{
- PyObject *attr = PyString_FromString(self->text->id.name+2);
+ PyObject *attr = PyString_FromString( self->text->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Text.name attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Text.name attribute" );
}
-static PyObject *Text_getFilename(BPy_Text *self)
+static PyObject *Text_getFilename( BPy_Text * self )
{
- PyObject *attr;
+ PyObject *attr;
char *name = self->text->name;
-
- if (name) attr = PyString_FromString(self->text->name);
+
+ if( name )
+ attr = PyString_FromString( self->text->name );
else
attr = Py_None;
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Text.filename attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Text.filename attribute" );
}
-static PyObject *Text_getNLines(BPy_Text *self)
-{ /* text->nlines isn't updated in Blender (?) */
- int nlines = 0;
- TextLine *line;
- PyObject *attr;
+static PyObject *Text_getNLines( BPy_Text * self )
+{ /* text->nlines isn't updated in Blender (?) */
+ int nlines = 0;
+ TextLine *line;
+ PyObject *attr;
- line = self->text->lines.first;
+ line = self->text->lines.first;
- while (line) { /* so we have to count them ourselves */
- line = line->next;
- nlines++;
- }
+ while( line ) { /* so we have to count them ourselves */
+ line = line->next;
+ nlines++;
+ }
- self->text->nlines = nlines; /* and update Blender, too (should we?) */
+ self->text->nlines = nlines; /* and update Blender, too (should we?) */
- attr = PyInt_FromLong(nlines);
+ attr = PyInt_FromLong( nlines );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Text.nlines attribute");
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Text.nlines attribute" );
}
-static PyObject *Text_setName(BPy_Text *self, PyObject *args)
+static PyObject *Text_setName( BPy_Text * self, PyObject * args )
{
- char *name;
- char buf[21];
-
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument"));
-
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
-
- rename_id(&self->text->id, buf);
-
- Py_INCREF(Py_None);
- return Py_None;
+ char *name;
+ char buf[21];
+
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" ) );
+
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+
+ rename_id( &self->text->id, buf );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Text_clear(BPy_Text *self, PyObject *args)
+static PyObject *Text_clear( BPy_Text * self, PyObject * args )
{
- int oldstate;
+ int oldstate;
- if (!self->text)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "This object isn't linked to a Blender Text Object");
+ if( !self->text )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "This object isn't linked to a Blender Text Object" );
- oldstate = txt_get_undostate();
- txt_set_undostate(1);
- txt_sel_all(self->text);
- txt_cut_sel(self->text);
- txt_set_undostate(oldstate);
+ oldstate = txt_get_undostate( );
+ txt_set_undostate( 1 );
+ txt_sel_all( self->text );
+ txt_cut_sel( self->text );
+ txt_set_undostate( oldstate );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Text_set(BPy_Text *self, PyObject *args)
+static PyObject *Text_set( BPy_Text * self, PyObject * args )
{
- int ival;
- char *attr;
-
- if (!PyArg_ParseTuple(args, "si", &attr, &ival))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a string and an int as arguments");
-
- if (strcmp("follow_cursor", attr) == 0) {
- if (ival)
- self->text->flags |= EXPP_TEXT_MODE_FOLLOW;
- else
- self->text->flags &= EXPP_TEXT_MODE_FOLLOW;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
+ int ival;
+ char *attr;
+
+ if( !PyArg_ParseTuple( args, "si", &attr, &ival ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string and an int as arguments" );
+
+ if( strcmp( "follow_cursor", attr ) == 0 ) {
+ if( ival )
+ self->text->flags |= EXPP_TEXT_MODE_FOLLOW;
+ else
+ self->text->flags &= EXPP_TEXT_MODE_FOLLOW;
+ }
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Text_write(BPy_Text *self, PyObject *args)
+static PyObject *Text_write( BPy_Text * self, PyObject * args )
{
- char *str;
- int oldstate;
+ char *str;
+ int oldstate;
- if (!self->text)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "This object isn't linked to a Blender Text Object");
+ if( !self->text )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "This object isn't linked to a Blender Text Object" );
- if (!PyArg_ParseTuple(args, "s", &str))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &str ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- oldstate = txt_get_undostate();
- txt_insert_buf(self->text, str);
- txt_move_eof(self->text, 0);
- txt_set_undostate(oldstate);
+ oldstate = txt_get_undostate( );
+ txt_insert_buf( self->text, str );
+ txt_move_eof( self->text, 0 );
+ txt_set_undostate( oldstate );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Text_asLines(BPy_Text *self, PyObject *args)
+static PyObject *Text_asLines( BPy_Text * self, PyObject * args )
{
- TextLine *line;
- PyObject *list, *ob;
+ TextLine *line;
+ PyObject *list, *ob;
- if (!self->text)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "This object isn't linked to a Blender Text Object");
+ if( !self->text )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "This object isn't linked to a Blender Text Object" );
- line = self->text->lines.first;
- list= PyList_New(0);
+ line = self->text->lines.first;
+ list = PyList_New( 0 );
- if (!list)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList");
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- while (line) {
- ob = Py_BuildValue("s", line->line);
- PyList_Append(list, ob);
- line = line->next;
- }
+ while( line ) {
+ ob = Py_BuildValue( "s", line->line );
+ PyList_Append( list, ob );
+ line = line->next;
+ }
- return list;
+ return list;
}
/*****************************************************************************/
@@ -541,9 +544,9 @@ static PyObject *Text_asLines(BPy_Text *self, PyObject *args)
/* Description: This is a callback function for the BPy_Text type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void Text_dealloc (BPy_Text *self)
+static void Text_dealloc( BPy_Text * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
@@ -552,35 +555,36 @@ static void Text_dealloc (BPy_Text *self)
/* the function that accesses BPy_Text member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject *Text_getAttr (BPy_Text *self, char *name)
+static PyObject *Text_getAttr( BPy_Text * self, char *name )
{
- PyObject *attr = Py_None;
-
- if (!self->text || !Text_IsLinked(self))
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "Text was already deleted!");
-
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->text->id.name+2);
- else if (strcmp(name, "filename") == 0)
- return Text_getFilename(self); /* special: can be null */
- else if (strcmp(name, "mode") == 0)
- attr = PyInt_FromLong(self->text->flags);
- else if (strcmp(name, "nlines") == 0)
- attr = Text_getNLines(self);
-
- else if (strcmp(name, "__members__") == 0)
- attr = Py_BuildValue("[s,s,s,s]",
- "name", "filename", "mode", "nlines");
-
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject"));
-
- if (attr != Py_None) return attr; /* attribute found, return its value */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Text_methods, (PyObject *)self, name);
+ PyObject *attr = Py_None;
+
+ if( !self->text || !Text_IsLinked( self ) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Text was already deleted!" );
+
+ if( strcmp( name, "name" ) == 0 )
+ attr = PyString_FromString( self->text->id.name + 2 );
+ else if( strcmp( name, "filename" ) == 0 )
+ return Text_getFilename( self ); /* special: can be null */
+ else if( strcmp( name, "mode" ) == 0 )
+ attr = PyInt_FromLong( self->text->flags );
+ else if( strcmp( name, "nlines" ) == 0 )
+ attr = Text_getNLines( self );
+
+ else if( strcmp( name, "__members__" ) == 0 )
+ attr = Py_BuildValue( "[s,s,s,s]",
+ "name", "filename", "mode", "nlines" );
+
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" ) );
+
+ if( attr != Py_None )
+ return attr; /* attribute found, return its value */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Text_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
@@ -589,41 +593,42 @@ static PyObject *Text_getAttr (BPy_Text *self, char *name)
/* function that changes Text Data members values. If this */
/* data is linked to a Blender Text, it also gets updated. */
/*****************************************************************************/
-static int Text_setAttr (BPy_Text *self, char *name, PyObject *value)
+static int Text_setAttr( BPy_Text * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
- if (!self->text || !Text_IsLinked(self))
- return EXPP_ReturnIntError (PyExc_RuntimeError,
- "Text was already deleted!");
+ if( !self->text || !Text_IsLinked( self ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "Text was already deleted!" );
/* We're playing a trick on the Python API users here. Even if they use
* Text.member = val instead of Text.setMember(value), we end up using the
* function anyway, since it already has error checking, clamps to the right
* interval and updates the Blender Text structure when necessary. */
- valtuple = Py_BuildValue("(O)", value);/* the set* functions expect a tuple */
+ valtuple = Py_BuildValue( "(O)", value ); /* the set* functions expect a tuple */
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "TextSetAttr: couldn't create PyTuple");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "TextSetAttr: couldn't create PyTuple" );
- if (strcmp (name, "name") == 0)
- error = Text_setName (self, valtuple);
- else { /* Error: no such member in the Text Data structure */
- Py_DECREF(value);
- Py_DECREF(valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found or immutable"));
- }
+ if( strcmp( name, "name" ) == 0 )
+ error = Text_setName( self, valtuple );
+ else { /* Error: no such member in the Text Data structure */
+ Py_DECREF( value );
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found or immutable" ) );
+ }
- Py_DECREF(valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF(Py_None); /* incref'ed by the called set* function */
- return 0; /* normal exit */
+ Py_DECREF( Py_None ); /* incref'ed by the called set* function */
+ return 0; /* normal exit */
}
/*****************************************************************************/
@@ -634,10 +639,10 @@ static int Text_setAttr (BPy_Text *self, char *name, PyObject *value)
/* they don't point to the same Blender Text struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static int Text_compare (BPy_Text *a, BPy_Text *b)
+static int Text_compare( BPy_Text * a, BPy_Text * b )
{
- Text *pa = a->text, *pb = b->text;
- return (pa == pb) ? 0:-1;
+ Text *pa = a->text, *pb = b->text;
+ return ( pa == pb ) ? 0 : -1;
}
/*****************************************************************************/
@@ -645,27 +650,29 @@ static int Text_compare (BPy_Text *a, BPy_Text *b)
/* Description: This is a callback function for the BPy_Text type. It */
/* builds a meaninful string to represent text objects. */
/*****************************************************************************/
-static PyObject *Text_repr (BPy_Text *self)
+static PyObject *Text_repr( BPy_Text * self )
{
- if (self->text && Text_IsLinked(self))
- return PyString_FromFormat("[Text \"%s\"]", self->text->id.name+2);
- else
- return PyString_FromString("[Text <deleted>]");
+ if( self->text && Text_IsLinked( self ) )
+ return PyString_FromFormat( "[Text \"%s\"]",
+ self->text->id.name + 2 );
+ else
+ return PyString_FromString( "[Text <deleted>]" );
}
/* Internal function to confirm if a Text wasn't unlinked.
* This is necessary because without it, if a script writer
- * referenced an already unlinked Text obj, Blender would crash. */
-static int Text_IsLinked(BPy_Text *self)
+ * referenced an already unlinked Text obj, Blender would crash. */
+static int Text_IsLinked( BPy_Text * self )
{
- Text *txt_iter = G.main->text.first;
+ Text *txt_iter = G.main->text.first;
- while (txt_iter) {
- if (self->text == txt_iter) return 1; /* ok, still linked */
+ while( txt_iter ) {
+ if( self->text == txt_iter )
+ return 1; /* ok, still linked */
- txt_iter = txt_iter->id.next;
- }
+ txt_iter = txt_iter->id.next;
+ }
/* uh-oh, it was already deleted */
- self->text = NULL; /* so we invalidate the pointer */
- return 0;
+ self->text = NULL; /* so we invalidate the pointer */
+ return 0;
}
diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h
index 27c2de86cf2..01203ba1246 100644
--- a/source/blender/python/api2_2x/Text.h
+++ b/source/blender/python/api2_2x/Text.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -31,4 +32,4 @@
#ifndef EXPP_TEXT_H
#define EXPP_TEXT_H
-#endif /* EXPP_TEXT_H */
+#endif /* EXPP_TEXT_H */
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index a136077f7e8..839a804017f 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -152,21 +152,21 @@
#define EXPP_TEX_MAPTO_TRANSLU MAP_TRANSLU
#define EXPP_TEX_MAPTO_AMB MAP_AMB
-#define EXPP_TEX_STYPE_DN_BLENDER TEX_BLENDER
-#define EXPP_TEX_STYPE_DN_PERLIN TEX_STDPERLIN
-#define EXPP_TEX_STYPE_DN_IMPROVEPERLIN TEX_NEWPERLIN
-#define EXPP_TEX_STYPE_DN_VORONOIF1 TEX_VORONOI_F1
-#define EXPP_TEX_STYPE_DN_VORONOIF2 TEX_VORONOI_F2
-#define EXPP_TEX_STYPE_DN_VORONOIF3 TEX_VORONOI_F3
-#define EXPP_TEX_STYPE_DN_VORONOIF4 TEX_VORONOI_F4
-#define EXPP_TEX_STYPE_DN_VORONOIF2F1 TEX_VORONOI_F2F1
-#define EXPP_TEX_STYPE_DN_VORONOICRACKLE TEX_VORONOI_CRACKLE
-#define EXPP_TEX_STYPE_DN_CELLNOISE TEX_CELLNOISE
-
-#define EXPP_TEX_STYPE_VN_TEX_DISTANCE TEX_DISTANCE
-#define EXPP_TEX_STYPE_VN_TEX_DISTANCE_SQUARED TEX_DISTANCE_SQUARED
-#define EXPP_TEX_STYPE_VN_TEX_MANHATTAN TEX_MANHATTAN
-#define EXPP_TEX_STYPE_VN_TEX_CHEBYCHEV TEX_CHEBYCHEV
+#define EXPP_TEX_STYPE_DN_BLENDER TEX_BLENDER
+#define EXPP_TEX_STYPE_DN_PERLIN TEX_STDPERLIN
+#define EXPP_TEX_STYPE_DN_IMPROVEPERLIN TEX_NEWPERLIN
+#define EXPP_TEX_STYPE_DN_VORONOIF1 TEX_VORONOI_F1
+#define EXPP_TEX_STYPE_DN_VORONOIF2 TEX_VORONOI_F2
+#define EXPP_TEX_STYPE_DN_VORONOIF3 TEX_VORONOI_F3
+#define EXPP_TEX_STYPE_DN_VORONOIF4 TEX_VORONOI_F4
+#define EXPP_TEX_STYPE_DN_VORONOIF2F1 TEX_VORONOI_F2F1
+#define EXPP_TEX_STYPE_DN_VORONOICRACKLE TEX_VORONOI_CRACKLE
+#define EXPP_TEX_STYPE_DN_CELLNOISE TEX_CELLNOISE
+
+#define EXPP_TEX_STYPE_VN_TEX_DISTANCE TEX_DISTANCE
+#define EXPP_TEX_STYPE_VN_TEX_DISTANCE_SQUARED TEX_DISTANCE_SQUARED
+#define EXPP_TEX_STYPE_VN_TEX_MANHATTAN TEX_MANHATTAN
+#define EXPP_TEX_STYPE_VN_TEX_CHEBYCHEV TEX_CHEBYCHEV
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_HALF TEX_MINKOVSKY_HALF
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_FOUR TEX_MINKOVSKY_FOUR
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY TEX_MINKOVSKY
@@ -176,192 +176,189 @@
/****************************************************************************/
static const EXPP_map_pair tex_type_map[] = {
- { "None", EXPP_TEX_TYPE_NONE },
- { "Clouds", EXPP_TEX_TYPE_CLOUDS },
- { "Wood", EXPP_TEX_TYPE_WOOD },
- { "Marble", EXPP_TEX_TYPE_MARBLE },
- { "Magic", EXPP_TEX_TYPE_MAGIC },
- { "Blend", EXPP_TEX_TYPE_BLEND },
- { "Stucci", EXPP_TEX_TYPE_STUCCI },
- { "Noise", EXPP_TEX_TYPE_NOISE },
- { "Image", EXPP_TEX_TYPE_IMAGE },
- { "Plugin", EXPP_TEX_TYPE_PLUGIN },
- { "EnvMap", EXPP_TEX_TYPE_ENVMAP },
- { "Musgrave", EXPP_TEX_TYPE_MUSGRAVE },
- { "Voronoi", EXPP_TEX_TYPE_VORONOI },
- { "DistortedNoise", EXPP_TEX_TYPE_DISTNOISE },
- { NULL, 0 }
+ {"None", EXPP_TEX_TYPE_NONE},
+ {"Clouds", EXPP_TEX_TYPE_CLOUDS},
+ {"Wood", EXPP_TEX_TYPE_WOOD},
+ {"Marble", EXPP_TEX_TYPE_MARBLE},
+ {"Magic", EXPP_TEX_TYPE_MAGIC},
+ {"Blend", EXPP_TEX_TYPE_BLEND},
+ {"Stucci", EXPP_TEX_TYPE_STUCCI},
+ {"Noise", EXPP_TEX_TYPE_NOISE},
+ {"Image", EXPP_TEX_TYPE_IMAGE},
+ {"Plugin", EXPP_TEX_TYPE_PLUGIN},
+ {"EnvMap", EXPP_TEX_TYPE_ENVMAP},
+ {"Musgrave", EXPP_TEX_TYPE_MUSGRAVE},
+ {"Voronoi", EXPP_TEX_TYPE_VORONOI},
+ {"DistortedNoise", EXPP_TEX_TYPE_DISTNOISE},
+ {NULL, 0}
};
static const EXPP_map_pair tex_flag_map[] = {
- /* we don't support this yet! */
+ /* we don't support this yet! */
/* { "ColorBand", EXPP_TEX_FLAG_COLORBAND }, */
- { "FlipBlend", EXPP_TEX_FLAG_FLIPBLEND },
- { "NegAlpha", EXPP_TEX_FLAG_NEGALPHA },
- { NULL, 0 }
+ {"FlipBlend", EXPP_TEX_FLAG_FLIPBLEND},
+ {"NegAlpha", EXPP_TEX_FLAG_NEGALPHA},
+ {NULL, 0}
};
static const EXPP_map_pair tex_imageflag_map[] = {
- { "InterPol", EXPP_TEX_IMAGEFLAG_INTERPOL },
- { "UseAlpha", EXPP_TEX_IMAGEFLAG_USEALPHA },
- { "MipMap", EXPP_TEX_IMAGEFLAG_MIPMAP },
- { "Fields", EXPP_TEX_IMAGEFLAG_FIELDS },
- { "Rot90", EXPP_TEX_IMAGEFLAG_ROT90 },
- { "CalcAlpha", EXPP_TEX_IMAGEFLAG_CALCALPHA },
- { "Cyclic", EXPP_TEX_IMAGEFLAG_CYCLIC },
- { "Movie", EXPP_TEX_IMAGEFLAG_MOVIE },
- { "StField", EXPP_TEX_IMAGEFLAG_STFIELD },
- { "Anti", EXPP_TEX_IMAGEFLAG_ANTI },
- { NULL, 0 }
+ {"InterPol", EXPP_TEX_IMAGEFLAG_INTERPOL},
+ {"UseAlpha", EXPP_TEX_IMAGEFLAG_USEALPHA},
+ {"MipMap", EXPP_TEX_IMAGEFLAG_MIPMAP},
+ {"Fields", EXPP_TEX_IMAGEFLAG_FIELDS},
+ {"Rot90", EXPP_TEX_IMAGEFLAG_ROT90},
+ {"CalcAlpha", EXPP_TEX_IMAGEFLAG_CALCALPHA},
+ {"Cyclic", EXPP_TEX_IMAGEFLAG_CYCLIC},
+ {"Movie", EXPP_TEX_IMAGEFLAG_MOVIE},
+ {"StField", EXPP_TEX_IMAGEFLAG_STFIELD},
+ {"Anti", EXPP_TEX_IMAGEFLAG_ANTI},
+ {NULL, 0}
};
static const EXPP_map_pair tex_extend_map[] = {
- { "Extend", EXPP_TEX_EXTEND_EXTEND },
- { "Clip", EXPP_TEX_EXTEND_CLIP },
- { "ClipCube", EXPP_TEX_EXTEND_CLIPCUBE },
- { "Repeat", EXPP_TEX_EXTEND_REPEAT },
- { NULL, 0 }
+ {"Extend", EXPP_TEX_EXTEND_EXTEND},
+ {"Clip", EXPP_TEX_EXTEND_CLIP},
+ {"ClipCube", EXPP_TEX_EXTEND_CLIPCUBE},
+ {"Repeat", EXPP_TEX_EXTEND_REPEAT},
+ {NULL, 0}
};
/* array of maps for stype */
-static const EXPP_map_pair tex_stype_default_map[] = {
- { "Default", 0 },
- { NULL, 0 }
+static const EXPP_map_pair tex_stype_default_map[] = {
+ {"Default", 0},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_clouds_map[] = {
- { "Default", 0 },
- { "CloudDefault", EXPP_TEX_STYPE_CLD_DEFAULT },
- { "CloudColor", EXPP_TEX_STYPE_CLD_COLOR },
- { NULL, 0 }
+ {"Default", 0},
+ {"CloudDefault", EXPP_TEX_STYPE_CLD_DEFAULT},
+ {"CloudColor", EXPP_TEX_STYPE_CLD_COLOR},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_wood_map[] = {
- { "Default", 0 },
- { "WoodBands", EXPP_TEX_STYPE_WOD_BANDS },
- { "WoodRings", EXPP_TEX_STYPE_WOD_RINGS },
- { "WoodBandNoise", EXPP_TEX_STYPE_WOD_BANDNOISE },
- { "WoodRingNoise", EXPP_TEX_STYPE_WOD_RINGNOISE },
- { NULL, 0 }
+ {"Default", 0},
+ {"WoodBands", EXPP_TEX_STYPE_WOD_BANDS},
+ {"WoodRings", EXPP_TEX_STYPE_WOD_RINGS},
+ {"WoodBandNoise", EXPP_TEX_STYPE_WOD_BANDNOISE},
+ {"WoodRingNoise", EXPP_TEX_STYPE_WOD_RINGNOISE},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_marble_map[] = {
- { "Default", 0 },
- { "MarbleSoft", EXPP_TEX_STYPE_MBL_SOFT },
- { "MarbleSharp", EXPP_TEX_STYPE_MBL_SHARP },
- { "MarbleSharper", EXPP_TEX_STYPE_MBL_SHARPER },
- { NULL , 0 }
+ {"Default", 0},
+ {"MarbleSoft", EXPP_TEX_STYPE_MBL_SOFT},
+ {"MarbleSharp", EXPP_TEX_STYPE_MBL_SHARP},
+ {"MarbleSharper", EXPP_TEX_STYPE_MBL_SHARPER},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_blend_map[] = {
- { "Default", 0 },
- { "BlendLin", EXPP_TEX_STYPE_BLN_LIN },
- { "BlendQuad", EXPP_TEX_STYPE_BLN_QUAD },
- { "BlendEase", EXPP_TEX_STYPE_BLN_EASE },
- { "BlendDiag", EXPP_TEX_STYPE_BLN_DIAG },
- { "BlendSphere", EXPP_TEX_STYPE_BLN_SPHERE },
- { "BlendHalo", EXPP_TEX_STYPE_BLN_HALO },
- { NULL , 0 }
+ {"Default", 0},
+ {"BlendLin", EXPP_TEX_STYPE_BLN_LIN},
+ {"BlendQuad", EXPP_TEX_STYPE_BLN_QUAD},
+ {"BlendEase", EXPP_TEX_STYPE_BLN_EASE},
+ {"BlendDiag", EXPP_TEX_STYPE_BLN_DIAG},
+ {"BlendSphere", EXPP_TEX_STYPE_BLN_SPHERE},
+ {"BlendHalo", EXPP_TEX_STYPE_BLN_HALO},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_stucci_map[] = {
- { "Default", 0 },
- { "StucciPlastic", EXPP_TEX_STYPE_STC_PLASTIC },
- { "StucciWallIn", EXPP_TEX_STYPE_STC_WALLIN },
- { "StucciWallOut", EXPP_TEX_STYPE_STC_WALLOUT },
- { NULL , 0 }
+ {"Default", 0},
+ {"StucciPlastic", EXPP_TEX_STYPE_STC_PLASTIC},
+ {"StucciWallIn", EXPP_TEX_STYPE_STC_WALLIN},
+ {"StucciWallOut", EXPP_TEX_STYPE_STC_WALLOUT},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_envmap_map[] = {
- { "Default", 0 },
- { "EnvmapStatic", EXPP_TEX_STYPE_ENV_STATIC },
- { "EnvmapAnim", EXPP_TEX_STYPE_ENV_ANIM },
- { "EnvmapLoad", EXPP_TEX_STYPE_ENV_LOAD },
- { NULL , 0 }
+ {"Default", 0},
+ {"EnvmapStatic", EXPP_TEX_STYPE_ENV_STATIC},
+ {"EnvmapAnim", EXPP_TEX_STYPE_ENV_ANIM},
+ {"EnvmapLoad", EXPP_TEX_STYPE_ENV_LOAD},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_musg_map[] = {
- { "Default", 0 },
- { "MultiFractal", EXPP_TEX_STYPE_MUS_MFRACTAL },
- { "HeteroTerrain", EXPP_TEX_STYPE_MUS_HTERRAIN },
- { "RidgedMultiFractal", EXPP_TEX_STYPE_MUS_RIDGEDMF },
- { "HybridMultiFractal", EXPP_TEX_STYPE_MUS_HYBRIDMF },
- { "fBM", EXPP_TEX_STYPE_MUS_FBM },
- { NULL , 0 }
+ {"Default", 0},
+ {"MultiFractal", EXPP_TEX_STYPE_MUS_MFRACTAL},
+ {"HeteroTerrain", EXPP_TEX_STYPE_MUS_HTERRAIN},
+ {"RidgedMultiFractal", EXPP_TEX_STYPE_MUS_RIDGEDMF},
+ {"HybridMultiFractal", EXPP_TEX_STYPE_MUS_HYBRIDMF},
+ {"fBM", EXPP_TEX_STYPE_MUS_FBM},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_distortednoise_map[] = {
- { "Default", 0 },
- { "BlenderOriginal", EXPP_TEX_STYPE_DN_BLENDER },
- { "OriginalPerlin", EXPP_TEX_STYPE_DN_PERLIN },
- { "ImprovedPerlin", EXPP_TEX_STYPE_DN_IMPROVEPERLIN },
- { "VoronoiF1", EXPP_TEX_STYPE_DN_VORONOIF1 },
- { "VoronoiF2", EXPP_TEX_STYPE_DN_VORONOIF2 },
- { "VoronoiF3", EXPP_TEX_STYPE_DN_VORONOIF3 },
- { "VoronoiF4", EXPP_TEX_STYPE_DN_VORONOIF4 },
- { "VoronoiF2-F1", EXPP_TEX_STYPE_DN_VORONOIF2F1 },
- { "VoronoiCrackle", EXPP_TEX_STYPE_DN_VORONOICRACKLE },
- { "CellNoise", EXPP_TEX_STYPE_DN_CELLNOISE },
- { NULL , 0 }
+ {"Default", 0},
+ {"BlenderOriginal", EXPP_TEX_STYPE_DN_BLENDER},
+ {"OriginalPerlin", EXPP_TEX_STYPE_DN_PERLIN},
+ {"ImprovedPerlin", EXPP_TEX_STYPE_DN_IMPROVEPERLIN},
+ {"VoronoiF1", EXPP_TEX_STYPE_DN_VORONOIF1},
+ {"VoronoiF2", EXPP_TEX_STYPE_DN_VORONOIF2},
+ {"VoronoiF3", EXPP_TEX_STYPE_DN_VORONOIF3},
+ {"VoronoiF4", EXPP_TEX_STYPE_DN_VORONOIF4},
+ {"VoronoiF2-F1", EXPP_TEX_STYPE_DN_VORONOIF2F1},
+ {"VoronoiCrackle", EXPP_TEX_STYPE_DN_VORONOICRACKLE},
+ {"CellNoise", EXPP_TEX_STYPE_DN_CELLNOISE},
+ {NULL, 0}
};
static const EXPP_map_pair tex_stype_voronoi_map[] = {
- { "Default", 0 },
- { "Int", EXPP_TEX_STYPE_VN_INT },
- { "Col1", EXPP_TEX_STYPE_VN_COL1 },
- { "Col2", EXPP_TEX_STYPE_VN_COL2 },
- { "Col3", EXPP_TEX_STYPE_VN_COL3 },
- { NULL , 0 }
+ {"Default", 0},
+ {"Int", EXPP_TEX_STYPE_VN_INT},
+ {"Col1", EXPP_TEX_STYPE_VN_COL1},
+ {"Col2", EXPP_TEX_STYPE_VN_COL2},
+ {"Col3", EXPP_TEX_STYPE_VN_COL3},
+ {NULL, 0}
};
static const EXPP_map_pair tex_distance_voronoi_map[] = {
- { "Default", 0 },
- { "Distance", EXPP_TEX_STYPE_VN_TEX_DISTANCE },
- { "DistanceSquared", EXPP_TEX_STYPE_VN_TEX_DISTANCE_SQUARED },
- { "Manhattan", EXPP_TEX_STYPE_VN_TEX_MANHATTAN },
- { "Chebychev", EXPP_TEX_STYPE_VN_TEX_CHEBYCHEV },
- { "MinkovskyHalf", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_HALF },
- { "MinkovskyFour", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_FOUR },
- { "Minkovsky", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY },
- { NULL , 0 }
+ {"Default", 0},
+ {"Distance", EXPP_TEX_STYPE_VN_TEX_DISTANCE},
+ {"DistanceSquared", EXPP_TEX_STYPE_VN_TEX_DISTANCE_SQUARED},
+ {"Manhattan", EXPP_TEX_STYPE_VN_TEX_MANHATTAN},
+ {"Chebychev", EXPP_TEX_STYPE_VN_TEX_CHEBYCHEV},
+ {"MinkovskyHalf", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_HALF},
+ {"MinkovskyFour", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_FOUR},
+ {"Minkovsky", EXPP_TEX_STYPE_VN_TEX_MINKOVSKY},
+ {NULL, 0}
};
static const EXPP_map_pair *tex_stype_map[] = {
- tex_stype_default_map, /* none */
- tex_stype_clouds_map,
- tex_stype_wood_map,
- tex_stype_marble_map,
- tex_stype_default_map, /* magic */
- tex_stype_blend_map,
- tex_stype_stucci_map,
- tex_stype_default_map, /* noise */
- tex_stype_default_map, /* image */
- tex_stype_default_map, /* plugin */
- tex_stype_envmap_map,
- tex_stype_musg_map, /* musgrave */
- tex_stype_voronoi_map, /* voronoi */
- tex_stype_distortednoise_map, /* distorted noise */
- tex_distance_voronoi_map
+ tex_stype_default_map, /* none */
+ tex_stype_clouds_map,
+ tex_stype_wood_map,
+ tex_stype_marble_map,
+ tex_stype_default_map, /* magic */
+ tex_stype_blend_map,
+ tex_stype_stucci_map,
+ tex_stype_default_map, /* noise */
+ tex_stype_default_map, /* image */
+ tex_stype_default_map, /* plugin */
+ tex_stype_envmap_map,
+ tex_stype_musg_map, /* musgrave */
+ tex_stype_voronoi_map, /* voronoi */
+ tex_stype_distortednoise_map, /* distorted noise */
+ tex_distance_voronoi_map
};
/*****************************************************************************/
/* Python API function prototypes for the Texture module. */
/*****************************************************************************/
-static PyObject *M_Texture_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Texture_Get (PyObject *self, PyObject *args);
+static PyObject *M_Texture_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_Texture_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
/* In Python these will be written to the console when doing a */
/* Blender.Texture.__doc__ */
/*****************************************************************************/
-static char M_Texture_doc[] =
-"The Blender Texture module\n\
+static char M_Texture_doc[] = "The Blender Texture module\n\
\n\
This module provides access to **Texture** objects in Blender\n";
-static char M_Texture_New_doc[] =
-"Texture.New (name = 'Tex'):\n\
+static char M_Texture_New_doc[] = "Texture.New (name = 'Tex'):\n\
Return a new Texture object with the given type and name.";
-static char M_Texture_Get_doc[] =
-"Texture.Get (name = None):\n\
+static char M_Texture_Get_doc[] = "Texture.Get (name = None):\n\
Return the texture with the given 'name', None if not found, or\n\
Return a list with all texture objects in the current scene,\n\
if no argument was given.";
@@ -370,10 +367,10 @@ static char M_Texture_Get_doc[] =
/* Python method structure definition for Blender.Texture module: */
/*****************************************************************************/
struct PyMethodDef M_Texture_methods[] = {
- {"New", (PyCFunction) M_Texture_New, METH_VARARGS|METH_KEYWORDS,
- M_Texture_New_doc},
- {"Get", M_Texture_Get, METH_VARARGS, M_Texture_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Texture_New, METH_VARARGS | METH_KEYWORDS,
+ M_Texture_New_doc},
+ {"Get", M_Texture_Get, METH_VARARGS, M_Texture_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
@@ -383,488 +380,491 @@ struct PyMethodDef M_Texture_methods[] = {
#define SETFUNC(name) static PyObject *Texture_##name(BPy_Texture *self, \
PyObject *args)
-GETFUNC (getExtend);
-GETFUNC (getImage);
-GETFUNC (getName);
-GETFUNC (getType);
-GETFUNC (getSType);
-GETFUNC (getIpo);
-GETFUNC (clearIpo);
-SETFUNC (setIpo);
-SETFUNC (setAnimFrames);
-SETFUNC (setAnimLength);
-SETFUNC (setAnimMontage);
-SETFUNC (setAnimOffset);
-SETFUNC (setAnimStart);
-SETFUNC (setBrightness);
-SETFUNC (setContrast);
-SETFUNC (setCrop);
-SETFUNC (setExtend);
-SETFUNC (setIntExtend); /* special case used for ".extend = ..." */
-SETFUNC (setFieldsPerImage);
-SETFUNC (setFilterSize);
-SETFUNC (setFlags);
-SETFUNC (setIntFlags); /* special case used for ".flags = ..." */
-SETFUNC (setImage);
-SETFUNC (setImageFlags);
-SETFUNC (setIntImageFlags); /* special case used for ".imageFlags = ..." */
-SETFUNC (setName);
-SETFUNC (setNoiseDepth);
-SETFUNC (setNoiseSize);
-SETFUNC (setNoiseType);
-SETFUNC (setNoiseBasis); /* special case used for ".noisebasis or noisebasis2 = ... */
-SETFUNC (setDistNoise); /* special case used for ".noisebasis = ... */
-SETFUNC (setRepeat);
-SETFUNC (setRGBCol);
-SETFUNC (setSType);
-SETFUNC (setIntSType); /* special case used for ".stype = ..." */
-SETFUNC (setType);
-SETFUNC (setIntType); /* special case used for ".type = ..." */
-SETFUNC (setTurbulence);
-SETFUNC (setDistMetric);
-SETFUNC (setDistAmnt);
+GETFUNC( getExtend );
+GETFUNC( getImage );
+GETFUNC( getName );
+GETFUNC( getType );
+GETFUNC( getSType );
+GETFUNC( getIpo );
+GETFUNC( clearIpo );
+SETFUNC( setIpo );
+SETFUNC( setAnimFrames );
+SETFUNC( setAnimLength );
+SETFUNC( setAnimMontage );
+SETFUNC( setAnimOffset );
+SETFUNC( setAnimStart );
+SETFUNC( setBrightness );
+SETFUNC( setContrast );
+SETFUNC( setCrop );
+SETFUNC( setExtend );
+SETFUNC( setIntExtend ); /* special case used for ".extend = ..." */
+SETFUNC( setFieldsPerImage );
+SETFUNC( setFilterSize );
+SETFUNC( setFlags );
+SETFUNC( setIntFlags ); /* special case used for ".flags = ..." */
+SETFUNC( setImage );
+SETFUNC( setImageFlags );
+SETFUNC( setIntImageFlags ); /* special case used for ".imageFlags = ..." */
+SETFUNC( setName );
+SETFUNC( setNoiseDepth );
+SETFUNC( setNoiseSize );
+SETFUNC( setNoiseType );
+SETFUNC( setNoiseBasis ); /* special case used for ".noisebasis or noisebasis2 = ... */
+SETFUNC( setDistNoise ); /* special case used for ".noisebasis = ... */
+SETFUNC( setRepeat );
+SETFUNC( setRGBCol );
+SETFUNC( setSType );
+SETFUNC( setIntSType ); /* special case used for ".stype = ..." */
+SETFUNC( setType );
+SETFUNC( setIntType ); /* special case used for ".type = ..." */
+SETFUNC( setTurbulence );
+SETFUNC( setDistMetric );
+SETFUNC( setDistAmnt );
/*****************************************************************************/
/* Python BPy_Texture methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Texture_methods[] = {
- /* name, method, flags, doc */
- {"getExtend", (PyCFunction)Texture_getExtend, METH_NOARGS,
- "() - Return Texture extend mode"},
- {"getImage", (PyCFunction)Texture_getImage, METH_NOARGS,
- "() - Return Texture Image"},
- {"getName", (PyCFunction)Texture_getName, METH_NOARGS,
- "() - Return Texture name"},
- {"getSType", (PyCFunction)Texture_getSType, METH_NOARGS,
- "() - Return Texture stype as string"},
- {"getType", (PyCFunction)Texture_getType, METH_NOARGS,
- "() - Return Texture type as string"},
- {"getIpo", (PyCFunction)Texture_getIpo, METH_NOARGS,
- "() - Return Texture Ipo"},
- {"setIpo", (PyCFunction)Texture_setIpo, METH_VARARGS,
- "(Blender Ipo) - Set Texture Ipo"},
- {"clearIpo", (PyCFunction) Texture_clearIpo, METH_NOARGS,
- "() - Unlink Ipo from this Texture."},
- {"setExtend", (PyCFunction)Texture_setExtend, METH_VARARGS,
- "(s) - Set Texture extend mode"},
- {"setFlags", (PyCFunction)Texture_setFlags, METH_VARARGS,
- "(f1,f2,f3) - Set Texture flags"},
- {"setImage", (PyCFunction)Texture_setImage, METH_VARARGS,
- "(Blender Image) - Set Texture Image"},
- {"setImageFlags", (PyCFunction)Texture_setImageFlags, METH_VARARGS,
- "(s,s,s,s,...) - Set Texture image flags"},
- {"setName", (PyCFunction)Texture_setName, METH_VARARGS,
- "(s) - Set Texture name"},
- {"setSType", (PyCFunction)Texture_setSType, METH_VARARGS,
- "(s) - Set Texture stype"},
- {"setType", (PyCFunction)Texture_setType, METH_VARARGS,
- "(s) - Set Texture type"},
- {"setNoiseBasis", (PyCFunction)Texture_setNoiseBasis, METH_VARARGS,
- "(s) - Set Noise basis"},
- {"setDistNoise", (PyCFunction)Texture_setDistNoise, METH_VARARGS,
- "(s) - Set Dist Noise"},
- {"setDistMetric", (PyCFunction)Texture_setDistMetric, METH_VARARGS,
- "(s) - Set Dist Metric"},
- {NULL, NULL, 0, NULL}
+ /* name, method, flags, doc */
+ {"getExtend", ( PyCFunction ) Texture_getExtend, METH_NOARGS,
+ "() - Return Texture extend mode"},
+ {"getImage", ( PyCFunction ) Texture_getImage, METH_NOARGS,
+ "() - Return Texture Image"},
+ {"getName", ( PyCFunction ) Texture_getName, METH_NOARGS,
+ "() - Return Texture name"},
+ {"getSType", ( PyCFunction ) Texture_getSType, METH_NOARGS,
+ "() - Return Texture stype as string"},
+ {"getType", ( PyCFunction ) Texture_getType, METH_NOARGS,
+ "() - Return Texture type as string"},
+ {"getIpo", ( PyCFunction ) Texture_getIpo, METH_NOARGS,
+ "() - Return Texture Ipo"},
+ {"setIpo", ( PyCFunction ) Texture_setIpo, METH_VARARGS,
+ "(Blender Ipo) - Set Texture Ipo"},
+ {"clearIpo", ( PyCFunction ) Texture_clearIpo, METH_NOARGS,
+ "() - Unlink Ipo from this Texture."},
+ {"setExtend", ( PyCFunction ) Texture_setExtend, METH_VARARGS,
+ "(s) - Set Texture extend mode"},
+ {"setFlags", ( PyCFunction ) Texture_setFlags, METH_VARARGS,
+ "(f1,f2,f3) - Set Texture flags"},
+ {"setImage", ( PyCFunction ) Texture_setImage, METH_VARARGS,
+ "(Blender Image) - Set Texture Image"},
+ {"setImageFlags", ( PyCFunction ) Texture_setImageFlags, METH_VARARGS,
+ "(s,s,s,s,...) - Set Texture image flags"},
+ {"setName", ( PyCFunction ) Texture_setName, METH_VARARGS,
+ "(s) - Set Texture name"},
+ {"setSType", ( PyCFunction ) Texture_setSType, METH_VARARGS,
+ "(s) - Set Texture stype"},
+ {"setType", ( PyCFunction ) Texture_setType, METH_VARARGS,
+ "(s) - Set Texture type"},
+ {"setNoiseBasis", ( PyCFunction ) Texture_setNoiseBasis, METH_VARARGS,
+ "(s) - Set Noise basis"},
+ {"setDistNoise", ( PyCFunction ) Texture_setDistNoise, METH_VARARGS,
+ "(s) - Set Dist Noise"},
+ {"setDistMetric", ( PyCFunction ) Texture_setDistMetric, METH_VARARGS,
+ "(s) - Set Dist Metric"},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Python Texture_Type callback function prototypes: */
+/* Python Texture_Type callback function prototypes: */
/*****************************************************************************/
-static void Texture_dealloc (BPy_Texture *self);
-static int Texture_setAttr (BPy_Texture *self, char *name, PyObject *v);
-static int Texture_compare (BPy_Texture *a, BPy_Texture *b);
-static PyObject *Texture_getAttr (BPy_Texture *self, char *name);
-static PyObject *Texture_repr (BPy_Texture *self);
+static void Texture_dealloc( BPy_Texture * self );
+static int Texture_setAttr( BPy_Texture * self, char *name, PyObject * v );
+static int Texture_compare( BPy_Texture * a, BPy_Texture * b );
+static PyObject *Texture_getAttr( BPy_Texture * self, char *name );
+static PyObject *Texture_repr( BPy_Texture * self );
/*****************************************************************************/
/* Python Texture_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Texture_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Texture", /* tp_name */
- sizeof (BPy_Texture), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Texture_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Texture_getAttr, /* tp_getattr */
- (setattrfunc)Texture_setAttr, /* tp_setattr */
- (cmpfunc)Texture_compare, /* tp_compare */
- (reprfunc)Texture_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_Texture_methods, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject Texture_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
+ "Blender Texture", /* tp_name */
+ sizeof( BPy_Texture ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Texture_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Texture_getAttr, /* tp_getattr */
+ ( setattrfunc ) Texture_setAttr, /* tp_setattr */
+ ( cmpfunc ) Texture_compare, /* tp_compare */
+ ( reprfunc ) Texture_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_Texture_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static PyObject *M_Texture_New(PyObject *self, PyObject *args, PyObject *kwords)
+static PyObject *M_Texture_New( PyObject * self, PyObject * args,
+ PyObject * kwords )
{
- char *name_str = "Tex";
- static char *kwlist[] = {"name_str", NULL};
- PyObject *pytex; /* for Texture object wrapper in Python */
- Tex *bltex; /* for actual Tex we create in Blender */
+ char *name_str = "Tex";
+ static char *kwlist[] = { "name_str", NULL };
+ PyObject *pytex; /* for Texture object wrapper in Python */
+ Tex *bltex; /* for actual Tex we create in Blender */
- /* Parse the arguments passed in by the Python interpreter */
- if (!PyArg_ParseTupleAndKeywords(args, kwords, "|s", kwlist, &name_str))
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "expected zero, one or two strings as arguments");
+ /* Parse the arguments passed in by the Python interpreter */
+ if( !PyArg_ParseTupleAndKeywords
+ ( args, kwords, "|s", kwlist, &name_str ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected zero, one or two strings as arguments" );
- bltex = add_texture(name_str); /* first create the texture in Blender */
+ bltex = add_texture( name_str ); /* first create the texture in Blender */
- if (bltex) /* now create the wrapper obj in Python */
- pytex = Texture_CreatePyObject(bltex);
- else
- return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "couldn't create Texture in Blender");
+ if( bltex ) /* now create the wrapper obj in Python */
+ pytex = Texture_CreatePyObject( bltex );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Texture in Blender" );
- /* let's return user count to zero, because add_texture() incref'd it */
- bltex->id.us = 0;
+ /* let's return user count to zero, because add_texture() incref'd it */
+ bltex->id.us = 0;
- if (pytex == NULL)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Tex PyObject");
+ if( pytex == NULL )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Tex PyObject" );
- return pytex;
+ return pytex;
}
-static PyObject *M_Texture_Get(PyObject *self, PyObject *args)
+static PyObject *M_Texture_Get( PyObject * self, PyObject * args )
{
- char * name = NULL;
- Tex * tex_iter;
+ char *name = NULL;
+ Tex *tex_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" );
- tex_iter = G.main->tex.first;
+ tex_iter = G.main->tex.first;
- if (name) { /* (name) - Search for texture by name */
-
- PyObject *wanted_tex = NULL;
+ if( name ) { /* (name) - Search for texture by name */
- while (tex_iter) {
- if (STREQ(name, tex_iter->id.name+2)) {
- wanted_tex = Texture_CreatePyObject (tex_iter);
- break;
- }
+ PyObject *wanted_tex = NULL;
- tex_iter = tex_iter->id.next;
- }
+ while( tex_iter ) {
+ if( STREQ( name, tex_iter->id.name + 2 ) ) {
+ wanted_tex =
+ Texture_CreatePyObject( tex_iter );
+ break;
+ }
- if (!wanted_tex) { /* Requested texture doesn't exist */
- char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Texture \"%s\" not found", name);
- return EXPP_ReturnPyObjError (PyExc_NameError, error_msg);
- }
+ tex_iter = tex_iter->id.next;
+ }
- return wanted_tex;
- }
+ if( !wanted_tex ) { /* Requested texture doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "Texture \"%s\" not found", name );
+ return EXPP_ReturnPyObjError( PyExc_NameError,
+ error_msg );
+ }
- else { /* () - return a list of wrappers for all textures in the scene */
- int index = 0;
- PyObject *tex_pylist, *pyobj;
+ return wanted_tex;
+ }
- tex_pylist = PyList_New (BLI_countlist (&(G.main->tex)));
- if (!tex_pylist)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create PyList");
+ else { /* () - return a list of wrappers for all textures in the scene */
+ int index = 0;
+ PyObject *tex_pylist, *pyobj;
- while (tex_iter) {
- pyobj = Texture_CreatePyObject(tex_iter);
- if (!pyobj)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,
- "couldn't create Texture PyObject");
+ tex_pylist = PyList_New( BLI_countlist( &( G.main->tex ) ) );
+ if( !tex_pylist )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- PyList_SET_ITEM(tex_pylist, index, pyobj);
+ while( tex_iter ) {
+ pyobj = Texture_CreatePyObject( tex_iter );
+ if( !pyobj )
+ return EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create Texture PyObject" );
- tex_iter = tex_iter->id.next;
- index++;
- }
+ PyList_SET_ITEM( tex_pylist, index, pyobj );
- return tex_pylist;
- }
+ tex_iter = tex_iter->id.next;
+ index++;
+ }
+
+ return tex_pylist;
+ }
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_TYPE_##name))
-
-static PyObject *M_Texture_TypesDict (void)
-{
- PyObject *Types = M_constant_New();
- if (Types) {
- BPy_constant *d = (BPy_constant*) Types;
-
- EXPP_ADDCONST (NONE);
- EXPP_ADDCONST (CLOUDS);
- EXPP_ADDCONST (WOOD);
- EXPP_ADDCONST (MARBLE);
- EXPP_ADDCONST (MAGIC);
- EXPP_ADDCONST (BLEND);
- EXPP_ADDCONST (STUCCI);
- EXPP_ADDCONST (NOISE);
- EXPP_ADDCONST (IMAGE);
- EXPP_ADDCONST (PLUGIN);
- EXPP_ADDCONST (ENVMAP);
- EXPP_ADDCONST (MUSGRAVE);
- EXPP_ADDCONST (VORONOI);
- EXPP_ADDCONST (DISTNOISE);
- }
- return Types;
+
+static PyObject *M_Texture_TypesDict( void )
+{
+ PyObject *Types = M_constant_New( );
+ if( Types ) {
+ BPy_constant *d = ( BPy_constant * ) Types;
+
+ EXPP_ADDCONST( NONE );
+ EXPP_ADDCONST( CLOUDS );
+ EXPP_ADDCONST( WOOD );
+ EXPP_ADDCONST( MARBLE );
+ EXPP_ADDCONST( MAGIC );
+ EXPP_ADDCONST( BLEND );
+ EXPP_ADDCONST( STUCCI );
+ EXPP_ADDCONST( NOISE );
+ EXPP_ADDCONST( IMAGE );
+ EXPP_ADDCONST( PLUGIN );
+ EXPP_ADDCONST( ENVMAP );
+ EXPP_ADDCONST( MUSGRAVE );
+ EXPP_ADDCONST( VORONOI );
+ EXPP_ADDCONST( DISTNOISE );
+ }
+ return Types;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_STYPE_##name))
-
-static PyObject *M_Texture_STypesDict (void)
-{
- PyObject *STypes = M_constant_New();
- if (STypes) {
- BPy_constant *d = (BPy_constant*) STypes;
-
- EXPP_ADDCONST(CLD_DEFAULT);
- EXPP_ADDCONST(CLD_COLOR);
- EXPP_ADDCONST(WOD_BANDS);
- EXPP_ADDCONST(WOD_RINGS);
- EXPP_ADDCONST(WOD_BANDNOISE);
- EXPP_ADDCONST(WOD_RINGNOISE);
- EXPP_ADDCONST(MAG_DEFAULT);
- EXPP_ADDCONST(MBL_SOFT);
- EXPP_ADDCONST(MBL_SHARP);
- EXPP_ADDCONST(MBL_SHARPER);
- EXPP_ADDCONST(BLN_LIN);
- EXPP_ADDCONST(BLN_QUAD);
- EXPP_ADDCONST(BLN_EASE);
- EXPP_ADDCONST(BLN_DIAG);
- EXPP_ADDCONST(BLN_SPHERE);
- EXPP_ADDCONST(BLN_HALO);
- EXPP_ADDCONST(STC_PLASTIC);
- EXPP_ADDCONST(STC_WALLIN);
- EXPP_ADDCONST(STC_WALLOUT);
- EXPP_ADDCONST(NSE_DEFAULT);
- EXPP_ADDCONST(IMG_DEFAULT);
- EXPP_ADDCONST(PLG_DEFAULT);
- EXPP_ADDCONST(ENV_STATIC);
- EXPP_ADDCONST(ENV_ANIM);
- EXPP_ADDCONST(ENV_LOAD);
- EXPP_ADDCONST(MUS_MFRACTAL);
- EXPP_ADDCONST(MUS_RIDGEDMF);
- EXPP_ADDCONST(MUS_HYBRIDMF);
- EXPP_ADDCONST(MUS_FBM);
- EXPP_ADDCONST(MUS_HTERRAIN);
- EXPP_ADDCONST(DN_BLENDER);
- EXPP_ADDCONST(DN_PERLIN);
- EXPP_ADDCONST(DN_IMPROVEPERLIN);
- EXPP_ADDCONST(DN_VORONOIF1);
- EXPP_ADDCONST(DN_VORONOIF2);
- EXPP_ADDCONST(DN_VORONOIF3);
- EXPP_ADDCONST(DN_VORONOIF4);
- EXPP_ADDCONST(DN_VORONOIF2F1);
- EXPP_ADDCONST(DN_VORONOICRACKLE);
- EXPP_ADDCONST(DN_CELLNOISE);
- EXPP_ADDCONST(VN_INT);
- EXPP_ADDCONST(VN_COL1);
- EXPP_ADDCONST(VN_COL2);
- EXPP_ADDCONST(VN_COL3);
- EXPP_ADDCONST(VN_TEX_DISTANCE);
- EXPP_ADDCONST(VN_TEX_DISTANCE_SQUARED);
- EXPP_ADDCONST(VN_TEX_MANHATTAN);
- EXPP_ADDCONST(VN_TEX_CHEBYCHEV);
- EXPP_ADDCONST(VN_TEX_MINKOVSKY_HALF);
- EXPP_ADDCONST(VN_TEX_MINKOVSKY_FOUR);
- EXPP_ADDCONST(VN_TEX_MINKOVSKY);
- }
- return STypes;
+
+static PyObject *M_Texture_STypesDict( void )
+{
+ PyObject *STypes = M_constant_New( );
+ if( STypes ) {
+ BPy_constant *d = ( BPy_constant * ) STypes;
+
+ EXPP_ADDCONST( CLD_DEFAULT );
+ EXPP_ADDCONST( CLD_COLOR );
+ EXPP_ADDCONST( WOD_BANDS );
+ EXPP_ADDCONST( WOD_RINGS );
+ EXPP_ADDCONST( WOD_BANDNOISE );
+ EXPP_ADDCONST( WOD_RINGNOISE );
+ EXPP_ADDCONST( MAG_DEFAULT );
+ EXPP_ADDCONST( MBL_SOFT );
+ EXPP_ADDCONST( MBL_SHARP );
+ EXPP_ADDCONST( MBL_SHARPER );
+ EXPP_ADDCONST( BLN_LIN );
+ EXPP_ADDCONST( BLN_QUAD );
+ EXPP_ADDCONST( BLN_EASE );
+ EXPP_ADDCONST( BLN_DIAG );
+ EXPP_ADDCONST( BLN_SPHERE );
+ EXPP_ADDCONST( BLN_HALO );
+ EXPP_ADDCONST( STC_PLASTIC );
+ EXPP_ADDCONST( STC_WALLIN );
+ EXPP_ADDCONST( STC_WALLOUT );
+ EXPP_ADDCONST( NSE_DEFAULT );
+ EXPP_ADDCONST( IMG_DEFAULT );
+ EXPP_ADDCONST( PLG_DEFAULT );
+ EXPP_ADDCONST( ENV_STATIC );
+ EXPP_ADDCONST( ENV_ANIM );
+ EXPP_ADDCONST( ENV_LOAD );
+ EXPP_ADDCONST( MUS_MFRACTAL );
+ EXPP_ADDCONST( MUS_RIDGEDMF );
+ EXPP_ADDCONST( MUS_HYBRIDMF );
+ EXPP_ADDCONST( MUS_FBM );
+ EXPP_ADDCONST( MUS_HTERRAIN );
+ EXPP_ADDCONST( DN_BLENDER );
+ EXPP_ADDCONST( DN_PERLIN );
+ EXPP_ADDCONST( DN_IMPROVEPERLIN );
+ EXPP_ADDCONST( DN_VORONOIF1 );
+ EXPP_ADDCONST( DN_VORONOIF2 );
+ EXPP_ADDCONST( DN_VORONOIF3 );
+ EXPP_ADDCONST( DN_VORONOIF4 );
+ EXPP_ADDCONST( DN_VORONOIF2F1 );
+ EXPP_ADDCONST( DN_VORONOICRACKLE );
+ EXPP_ADDCONST( DN_CELLNOISE );
+ EXPP_ADDCONST( VN_INT );
+ EXPP_ADDCONST( VN_COL1 );
+ EXPP_ADDCONST( VN_COL2 );
+ EXPP_ADDCONST( VN_COL3 );
+ EXPP_ADDCONST( VN_TEX_DISTANCE );
+ EXPP_ADDCONST( VN_TEX_DISTANCE_SQUARED );
+ EXPP_ADDCONST( VN_TEX_MANHATTAN );
+ EXPP_ADDCONST( VN_TEX_CHEBYCHEV );
+ EXPP_ADDCONST( VN_TEX_MINKOVSKY_HALF );
+ EXPP_ADDCONST( VN_TEX_MINKOVSKY_FOUR );
+ EXPP_ADDCONST( VN_TEX_MINKOVSKY );
+ }
+ return STypes;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_TEXCO_##name))
-
-static PyObject *M_Texture_TexCoDict (void)
+
+static PyObject *M_Texture_TexCoDict( void )
{
- PyObject *TexCo = M_constant_New();
- if (TexCo) {
- BPy_constant *d = (BPy_constant*) TexCo;
+ PyObject *TexCo = M_constant_New( );
+ if( TexCo ) {
+ BPy_constant *d = ( BPy_constant * ) TexCo;
- EXPP_ADDCONST(ORCO);
- EXPP_ADDCONST(REFL);
- EXPP_ADDCONST(NOR);
- EXPP_ADDCONST(GLOB);
- EXPP_ADDCONST(UV);
- EXPP_ADDCONST(OBJECT);
- EXPP_ADDCONST(WIN);
- EXPP_ADDCONST(VIEW);
- EXPP_ADDCONST(STICK);
- }
- return TexCo;
+ EXPP_ADDCONST( ORCO );
+ EXPP_ADDCONST( REFL );
+ EXPP_ADDCONST( NOR );
+ EXPP_ADDCONST( GLOB );
+ EXPP_ADDCONST( UV );
+ EXPP_ADDCONST( OBJECT );
+ EXPP_ADDCONST( WIN );
+ EXPP_ADDCONST( VIEW );
+ EXPP_ADDCONST( STICK );
+ }
+ return TexCo;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_MAPTO_##name))
-
-static PyObject *M_Texture_MapToDict (void)
-{
- PyObject *MapTo = M_constant_New();
- if (MapTo) {
- BPy_constant *d = (BPy_constant*) MapTo;
-
- EXPP_ADDCONST(COL);
- EXPP_ADDCONST(NOR);
- EXPP_ADDCONST(CSP);
- EXPP_ADDCONST(CMIR);
- EXPP_ADDCONST(REF);
- EXPP_ADDCONST(SPEC);
- EXPP_ADDCONST(HARD);
- EXPP_ADDCONST(ALPHA);
- EXPP_ADDCONST(EMIT);
- EXPP_ADDCONST(RAYMIR);
- EXPP_ADDCONST(AMB);
- EXPP_ADDCONST(TRANSLU);
- EXPP_ADDCONST(DISP);
- }
- return MapTo;
+
+static PyObject *M_Texture_MapToDict( void )
+{
+ PyObject *MapTo = M_constant_New( );
+ if( MapTo ) {
+ BPy_constant *d = ( BPy_constant * ) MapTo;
+
+ EXPP_ADDCONST( COL );
+ EXPP_ADDCONST( NOR );
+ EXPP_ADDCONST( CSP );
+ EXPP_ADDCONST( CMIR );
+ EXPP_ADDCONST( REF );
+ EXPP_ADDCONST( SPEC );
+ EXPP_ADDCONST( HARD );
+ EXPP_ADDCONST( ALPHA );
+ EXPP_ADDCONST( EMIT );
+ EXPP_ADDCONST( RAYMIR );
+ EXPP_ADDCONST( AMB );
+ EXPP_ADDCONST( TRANSLU );
+ EXPP_ADDCONST( DISP );
+ }
+ return MapTo;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_FLAG_##name))
-
-static PyObject *M_Texture_FlagsDict (void)
+
+static PyObject *M_Texture_FlagsDict( void )
{
- PyObject *Flags = M_constant_New();
- if (Flags) {
- BPy_constant *d = (BPy_constant*) Flags;
+ PyObject *Flags = M_constant_New( );
+ if( Flags ) {
+ BPy_constant *d = ( BPy_constant * ) Flags;
- EXPP_ADDCONST(COLORBAND);
- EXPP_ADDCONST(FLIPBLEND);
- EXPP_ADDCONST(NEGALPHA);
- }
- return Flags;
+ EXPP_ADDCONST( COLORBAND );
+ EXPP_ADDCONST( FLIPBLEND );
+ EXPP_ADDCONST( NEGALPHA );
+ }
+ return Flags;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_EXTEND_##name))
-
-static PyObject *M_Texture_ExtendModesDict (void)
+
+static PyObject *M_Texture_ExtendModesDict( void )
{
- PyObject *ExtendModes = M_constant_New();
- if (ExtendModes) {
- BPy_constant *d = (BPy_constant*) ExtendModes;
+ PyObject *ExtendModes = M_constant_New( );
+ if( ExtendModes ) {
+ BPy_constant *d = ( BPy_constant * ) ExtendModes;
- EXPP_ADDCONST(EXTEND);
- EXPP_ADDCONST(CLIP);
- EXPP_ADDCONST(CLIPCUBE);
- EXPP_ADDCONST(REPEAT);
- }
- return ExtendModes;
+ EXPP_ADDCONST( EXTEND );
+ EXPP_ADDCONST( CLIP );
+ EXPP_ADDCONST( CLIPCUBE );
+ EXPP_ADDCONST( REPEAT );
+ }
+ return ExtendModes;
}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_IMAGEFLAG_##name))
-
-static PyObject *M_Texture_ImageFlagsDict (void)
+
+static PyObject *M_Texture_ImageFlagsDict( void )
{
- PyObject *ImageFlags = M_constant_New();
- if (ImageFlags) {
- BPy_constant *d = (BPy_constant*) ImageFlags;
+ PyObject *ImageFlags = M_constant_New( );
+ if( ImageFlags ) {
+ BPy_constant *d = ( BPy_constant * ) ImageFlags;
- EXPP_ADDCONST(INTERPOL);
- EXPP_ADDCONST(USEALPHA);
- EXPP_ADDCONST(MIPMAP);
- EXPP_ADDCONST(FIELDS);
- EXPP_ADDCONST(ROT90);
- EXPP_ADDCONST(CALCALPHA);
- EXPP_ADDCONST(STFIELD);
- EXPP_ADDCONST(MOVIE);
- EXPP_ADDCONST(CYCLIC);
- }
- return ImageFlags;
+ EXPP_ADDCONST( INTERPOL );
+ EXPP_ADDCONST( USEALPHA );
+ EXPP_ADDCONST( MIPMAP );
+ EXPP_ADDCONST( FIELDS );
+ EXPP_ADDCONST( ROT90 );
+ EXPP_ADDCONST( CALCALPHA );
+ EXPP_ADDCONST( STFIELD );
+ EXPP_ADDCONST( MOVIE );
+ EXPP_ADDCONST( CYCLIC );
+ }
+ return ImageFlags;
}
-PyObject *Texture_Init (void)
+PyObject *Texture_Init( void )
{
- PyObject *submodule;
- PyObject *dict;
-
- /* constants */
- PyObject *Types = M_Texture_TypesDict();
- PyObject *STypes = M_Texture_STypesDict();
- PyObject *TexCo = M_Texture_TexCoDict();
- PyObject *MapTo = M_Texture_MapToDict();
- PyObject *Flags = M_Texture_FlagsDict();
- PyObject *ExtendModes = M_Texture_ExtendModesDict();
- PyObject *ImageFlags = M_Texture_ImageFlagsDict();
-
- Texture_Type.ob_type = &PyType_Type;
+ PyObject *submodule;
+ PyObject *dict;
+
+ /* constants */
+ PyObject *Types = M_Texture_TypesDict( );
+ PyObject *STypes = M_Texture_STypesDict( );
+ PyObject *TexCo = M_Texture_TexCoDict( );
+ PyObject *MapTo = M_Texture_MapToDict( );
+ PyObject *Flags = M_Texture_FlagsDict( );
+ PyObject *ExtendModes = M_Texture_ExtendModesDict( );
+ PyObject *ImageFlags = M_Texture_ImageFlagsDict( );
+
+ Texture_Type.ob_type = &PyType_Type;
+
+ submodule = Py_InitModule3( "Blender.Texture",
+ M_Texture_methods, M_Texture_doc );
+
+ if( Types )
+ PyModule_AddObject( submodule, "Types", Types );
+ if( STypes )
+ PyModule_AddObject( submodule, "STypes", STypes );
+ if( TexCo )
+ PyModule_AddObject( submodule, "TexCo", TexCo );
+ if( MapTo )
+ PyModule_AddObject( submodule, "MapTo", MapTo );
+ if( Flags )
+ PyModule_AddObject( submodule, "Flags", Flags );
+ if( ExtendModes )
+ PyModule_AddObject( submodule, "ExtendModes", ExtendModes );
+ if( ImageFlags )
+ PyModule_AddObject( submodule, "ImageFlags", ImageFlags );
- submodule = Py_InitModule3("Blender.Texture",
- M_Texture_methods, M_Texture_doc);
+ /* Add the MTex submodule to this module */
+ dict = PyModule_GetDict( submodule );
+ PyDict_SetItemString( dict, "MTex", MTex_Init( ) );
- if (Types)
- PyModule_AddObject(submodule, "Types", Types);
- if (STypes)
- PyModule_AddObject(submodule, "STypes", STypes);
- if (TexCo)
- PyModule_AddObject(submodule, "TexCo", TexCo);
- if (MapTo)
- PyModule_AddObject(submodule, "MapTo", MapTo);
- if (Flags)
- PyModule_AddObject(submodule, "Flags", Flags);
- if (ExtendModes)
- PyModule_AddObject(submodule, "ExtendModes", ExtendModes);
- if (ImageFlags)
- PyModule_AddObject(submodule, "ImageFlags", ImageFlags);
-
- /* Add the MTex submodule to this module */
- dict = PyModule_GetDict (submodule);
- PyDict_SetItemString (dict, "MTex", MTex_Init());
-
- return submodule;
+ return submodule;
}
-PyObject *Texture_CreatePyObject (Tex *tex)
+PyObject *Texture_CreatePyObject( Tex * tex )
{
- BPy_Texture *pytex;
+ BPy_Texture *pytex;
- pytex = (BPy_Texture *) PyObject_NEW (BPy_Texture, &Texture_Type);
- if (!pytex)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Texture PyObject");
+ pytex = ( BPy_Texture * ) PyObject_NEW( BPy_Texture, &Texture_Type );
+ if( !pytex )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create BPy_Texture PyObject" );
- pytex->texture = tex;
- return (PyObject *) pytex;
+ pytex->texture = tex;
+ return ( PyObject * ) pytex;
}
-Tex *Texture_FromPyObject (PyObject *pyobj)
+Tex *Texture_FromPyObject( PyObject * pyobj )
{
- return ((BPy_Texture *)pyobj)->texture;
+ return ( ( BPy_Texture * ) pyobj )->texture;
}
-int Texture_CheckPyObject (PyObject *pyobj)
+int Texture_CheckPyObject( PyObject * pyobj )
{
- return (pyobj->ob_type == &Texture_Type);
+ return ( pyobj->ob_type == &Texture_Type );
}
@@ -872,1130 +872,1136 @@ int Texture_CheckPyObject (PyObject *pyobj)
/* Python BPy_Texture methods: */
/*****************************************************************************/
-static PyObject *Texture_getExtend(BPy_Texture *self)
+static PyObject *Texture_getExtend( BPy_Texture * self )
{
- PyObject *attr = NULL;
- const char *extend = NULL;
+ PyObject *attr = NULL;
+ const char *extend = NULL;
- if (EXPP_map_getStrVal (tex_extend_map, self->texture->extend, &extend))
- attr = PyString_FromString (extend);
-
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "invalid internal extend mode");
-
- return attr;
+ if( EXPP_map_getStrVal
+ ( tex_extend_map, self->texture->extend, &extend ) )
+ attr = PyString_FromString( extend );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "invalid internal extend mode" );
+
+ return attr;
}
-static PyObject *Texture_getImage(BPy_Texture *self)
+static PyObject *Texture_getImage( BPy_Texture * self )
{
- /* we need this to be an IMAGE texture, and we must have an image */
- if ((self->texture->type != TEX_IMAGE) || !self->texture->ima)
- {
- Py_INCREF (Py_None);
- return Py_None;
- }
-
- return Image_CreatePyObject (self->texture->ima);
+ /* we need this to be an IMAGE texture, and we must have an image */
+ if( ( self->texture->type != TEX_IMAGE ) || !self->texture->ima ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
+ return Image_CreatePyObject( self->texture->ima );
}
-static PyObject *Texture_getName(BPy_Texture *self)
+static PyObject *Texture_getName( BPy_Texture * self )
{
- PyObject *attr = PyString_FromString(self->texture->id.name+2);
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Texture.name attribute");
-
- return attr;
+ PyObject *attr = PyString_FromString( self->texture->id.name + 2 );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Texture.name attribute" );
+
+ return attr;
}
-static PyObject *Texture_getSType(BPy_Texture *self)
+static PyObject *Texture_getSType( BPy_Texture * self )
{
- PyObject *attr = NULL;
- const char *stype = NULL;
+ PyObject *attr = NULL;
+ const char *stype = NULL;
- if (EXPP_map_getStrVal (tex_stype_map[self->texture->type],
- self->texture->stype, &stype))
- attr = PyString_FromString (stype);
-
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "invalid texture stype internally");
-
- return attr;
+ if( EXPP_map_getStrVal( tex_stype_map[self->texture->type],
+ self->texture->stype, &stype ) )
+ attr = PyString_FromString( stype );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "invalid texture stype internally" );
+
+ return attr;
}
-static PyObject *Texture_getType(BPy_Texture *self)
+static PyObject *Texture_getType( BPy_Texture * self )
{
- PyObject *attr = NULL;
- const char *type = NULL;
+ PyObject *attr = NULL;
+ const char *type = NULL;
+
+ if( EXPP_map_getStrVal( tex_type_map, self->texture->type, &type ) )
+ attr = PyString_FromString( type );
- if (EXPP_map_getStrVal (tex_type_map, self->texture->type, &type))
- attr = PyString_FromString (type);
-
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "invalid texture type internally");
-
- return attr;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "invalid texture type internally" );
+
+ return attr;
}
-static PyObject *Texture_setAnimFrames(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setAnimFrames( BPy_Texture * self, PyObject * args )
{
- int frames;
- if (!PyArg_ParseTuple(args, "i", &frames))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int frames;
+ if( !PyArg_ParseTuple( args, "i", &frames ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
+
+ if( frames < 0 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "frames cannot be negative" );
- if (frames < 0)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "frames cannot be negative");
+ self->texture->frames = frames;
- self->texture->frames = frames;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setAnimLength(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setAnimLength( BPy_Texture * self, PyObject * args )
{
- int length;
- if (!PyArg_ParseTuple(args, "i", &length))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int length;
+ if( !PyArg_ParseTuple( args, "i", &length ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
- if (length < 0)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "length cannot be negative");
+ if( length < 0 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "length cannot be negative" );
- self->texture->len = length;
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->len = length;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setAnimMontage(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setAnimMontage( BPy_Texture * self, PyObject * args )
{
- int fradur[4][2];
- int i, j;
- if (!PyArg_ParseTuple(args, "((ii)(ii)(ii)(ii))",
- &fradur[0][0], &fradur[0][1],
- &fradur[1][0], &fradur[1][1],
- &fradur[2][0], &fradur[2][1],
- &fradur[3][0], &fradur[3][1]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a tuple of tuples");
+ int fradur[4][2];
+ int i, j;
+ if( !PyArg_ParseTuple( args, "((ii)(ii)(ii)(ii))",
+ &fradur[0][0], &fradur[0][1],
+ &fradur[1][0], &fradur[1][1],
+ &fradur[2][0], &fradur[2][1],
+ &fradur[3][0], &fradur[3][1] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a tuple of tuples" );
+
+ for( i = 0; i < 4; ++i )
+ for( j = 0; j < 2; ++j )
+ if( fradur[i][j] < 0 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "values must be greater than zero" );
- for (i=0; i<4; ++i)
- for (j=0; j<2; ++j)
- if (fradur[i][j] < 0)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "values must be greater than zero");
+ for( i = 0; i < 4; ++i )
+ for( j = 0; j < 2; ++j )
+ self->texture->fradur[i][j] = fradur[i][j];
- for (i=0; i<4; ++i)
- for (j=0; j<2; ++j)
- self->texture->fradur[i][j] = fradur[i][j];
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setAnimOffset(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setAnimOffset( BPy_Texture * self, PyObject * args )
{
- int offset;
- if (!PyArg_ParseTuple(args, "i", &offset))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int offset;
+ if( !PyArg_ParseTuple( args, "i", &offset ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
- self->texture->offset = offset;
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->offset = offset;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setAnimStart(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setAnimStart( BPy_Texture * self, PyObject * args )
{
- int sfra;
- if (!PyArg_ParseTuple(args, "i", &sfra))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int sfra;
+ if( !PyArg_ParseTuple( args, "i", &sfra ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
+
+ if( sfra < 1 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "start must be greater than zero" );
- if (sfra < 1)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "start must be greater than zero");
+ self->texture->sfra = sfra;
- self->texture->sfra = sfra;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setBrightness(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setBrightness( BPy_Texture * self, PyObject * args )
{
- float bright;
- if (!PyArg_ParseTuple(args, "f", &bright))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float bright;
+ if( !PyArg_ParseTuple( args, "f", &bright ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (bright<0 || bright>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "brightness must be in range [0,2]");
+ if( bright < 0 || bright > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "brightness must be in range [0,2]" );
- self->texture->bright = bright;
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->bright = bright;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setContrast(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setContrast( BPy_Texture * self, PyObject * args )
{
- float contrast;
- if (!PyArg_ParseTuple(args, "f", &contrast))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float contrast;
+ if( !PyArg_ParseTuple( args, "f", &contrast ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
+
+ if( contrast < 0 || contrast > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "contrast must be in range [0,2]" );
- if (contrast<0 || contrast>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "contrast must be in range [0,2]");
+ self->texture->contrast = contrast;
- self->texture->contrast = contrast;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setCrop(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setCrop( BPy_Texture * self, PyObject * args )
{
- float crop[4];
- int i;
- if (!PyArg_ParseTuple(args, "(ffff)",
- &crop[0], &crop[1], &crop[2], &crop[3]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected tuple of 4 floats");
-
- for (i=0; i<4; ++i)
- if (crop[i]<-10 || crop[i]>10)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "values must be in range [-10,10]");
+ float crop[4];
+ int i;
+ if( !PyArg_ParseTuple( args, "(ffff)",
+ &crop[0], &crop[1], &crop[2], &crop[3] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected tuple of 4 floats" );
+
+ for( i = 0; i < 4; ++i )
+ if( crop[i] < -10 || crop[i] > 10 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "values must be in range [-10,10]" );
- self->texture->cropxmin = crop[0];
- self->texture->cropymin = crop[1];
- self->texture->cropxmax = crop[2];
- self->texture->cropymax = crop[3];
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->cropxmin = crop[0];
+ self->texture->cropymin = crop[1];
+ self->texture->cropxmax = crop[2];
+ self->texture->cropymax = crop[3];
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setExtend(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setExtend( BPy_Texture * self, PyObject * args )
{
- char *extend = NULL;
- if (!PyArg_ParseTuple(args, "s", &extend))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ char *extend = NULL;
+ if( !PyArg_ParseTuple( args, "s", &extend ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if (!EXPP_map_getShortVal (tex_extend_map, extend, &self->texture->extend))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid extend mode");
+ if( !EXPP_map_getShortVal
+ ( tex_extend_map, extend, &self->texture->extend ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid extend mode" );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setIntExtend(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setIntExtend( BPy_Texture * self, PyObject * args )
{
- int extend = 0;
- if (!PyArg_ParseTuple(args, "i", &extend))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
-
- if (extend<EXPP_TEX_EXTEND_MIN || extend>EXPP_TEX_EXTEND_MAX)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid extend mode");
-
- self->texture->extend = extend;
-
- Py_INCREF(Py_None);
- return Py_None;
+ int extend = 0;
+ if( !PyArg_ParseTuple( args, "i", &extend ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
+ if( extend < EXPP_TEX_EXTEND_MIN || extend > EXPP_TEX_EXTEND_MAX )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid extend mode" );
+
+ self->texture->extend = extend;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setFieldsPerImage(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setFieldsPerImage( BPy_Texture * self,
+ PyObject * args )
{
- int fie_ima;
- if (!PyArg_ParseTuple(args, "i", &fie_ima))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int fie_ima;
+ if( !PyArg_ParseTuple( args, "i", &fie_ima ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
- if (fie_ima<1 || fie_ima>200)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "value must be in range [1,200]");
+ if( fie_ima < 1 || fie_ima > 200 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "value must be in range [1,200]" );
- self->texture->fie_ima = fie_ima;
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->fie_ima = fie_ima;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setFilterSize(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setFilterSize( BPy_Texture * self, PyObject * args )
{
- float size;
- if (!PyArg_ParseTuple(args, "f", &size))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float size;
+ if( !PyArg_ParseTuple( args, "f", &size ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
+
+ if( size < 0.1 || size > 25 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "filter size must be in range [0.1,25]" );
- if (size<0.1 || size>25)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "filter size must be in range [0.1,25]");
+ self->texture->filtersize = size;
- self->texture->filtersize = size;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setFlags(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setFlags( BPy_Texture * self, PyObject * args )
{
- char *sf[3] = { NULL, NULL, NULL };
- int i;
- short flags = 0;
- short thisflag;
- if (!PyArg_ParseTuple(args, "|sss", &sf[0], &sf[1], &sf[2]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 0-3 string arguments");
+ char *sf[3] = { NULL, NULL, NULL };
+ int i;
+ short flags = 0;
+ short thisflag;
+ if( !PyArg_ParseTuple( args, "|sss", &sf[0], &sf[1], &sf[2] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 0-3 string arguments" );
- for (i=0; i<3; ++i)
- {
- if (!sf[i]) break;
+ for( i = 0; i < 3; ++i ) {
+ if( !sf[i] )
+ break;
- if (!EXPP_map_getShortVal(tex_flag_map, sf[i], &thisflag))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid texture flag name");
+ if( !EXPP_map_getShortVal( tex_flag_map, sf[i], &thisflag ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture flag name" );
- flags |= thisflag;
- }
+ flags |= thisflag;
+ }
- self->texture->flag = flags;
+ self->texture->flag = flags;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setIntFlags(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setIntFlags( BPy_Texture * self, PyObject * args )
{
- int flags = 0;
- if (!PyArg_ParseTuple(args, "i", &flags))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
-
- self->texture->flag = flags;
-
- Py_INCREF(Py_None);
- return Py_None;
+ int flags = 0;
+ if( !PyArg_ParseTuple( args, "i", &flags ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
+ self->texture->flag = flags;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setImage(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setImage( BPy_Texture * self, PyObject * args )
{
- PyObject *pyimg;
- Image *blimg = NULL;
+ PyObject *pyimg;
+ Image *blimg = NULL;
- if (!PyArg_ParseTuple(args, "O!", &Image_Type, &pyimg))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an Image");
- blimg = Image_FromPyObject (pyimg);
+ if( !PyArg_ParseTuple( args, "O!", &Image_Type, &pyimg ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an Image" );
+ blimg = Image_FromPyObject( pyimg );
- if (self->texture->ima) {
- self->texture->ima->id.us--;
- }
+ if( self->texture->ima ) {
+ self->texture->ima->id.us--;
+ }
- self->texture->ima = blimg;
- id_us_plus(&blimg->id);
+ self->texture->ima = blimg;
+ id_us_plus( &blimg->id );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setImageFlags(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setImageFlags( BPy_Texture * self, PyObject * args )
{
- char *sf[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
- int i;
- short flags = 0;
- short thisflag;
- if (!PyArg_ParseTuple(args, "|sssssssss", &sf[0], &sf[1], &sf[2], &sf[3],
- &sf[4], &sf[5], &sf[6], &sf[7], &sf[8]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 0-9 string arguments");
+ char *sf[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ int i;
+ short flags = 0;
+ short thisflag;
+ if( !PyArg_ParseTuple
+ ( args, "|sssssssss", &sf[0], &sf[1], &sf[2], &sf[3], &sf[4],
+ &sf[5], &sf[6], &sf[7], &sf[8] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 0-9 string arguments" );
+
+ for( i = 0; i < 9; ++i ) {
+ if( !sf[i] )
+ break;
- for (i=0; i<9; ++i)
- {
- if (!sf[i]) break;
+ if( !EXPP_map_getShortVal
+ ( tex_imageflag_map, sf[i], &thisflag ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture image flag name" );
- if (!EXPP_map_getShortVal(tex_imageflag_map, sf[i], &thisflag))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid texture image flag name");
+ flags |= thisflag;
+ }
- flags |= thisflag;
- }
+ /* MIPMAP and FIELDS can't be used together */
+ if( ( flags & EXPP_TEX_IMAGEFLAG_MIPMAP ) &&
+ ( flags & EXPP_TEX_IMAGEFLAG_FIELDS ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "image flags MIPMAP and FIELDS cannot be used together" );
- /* MIPMAP and FIELDS can't be used together */
- if ((flags & EXPP_TEX_IMAGEFLAG_MIPMAP) &&
- (flags & EXPP_TEX_IMAGEFLAG_FIELDS))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "image flags MIPMAP and FIELDS cannot be used together");
-
- self->texture->imaflag = flags;
+ self->texture->imaflag = flags;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setIntImageFlags(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setIntImageFlags( BPy_Texture * self,
+ PyObject * args )
{
- int flags = 0;
- if (!PyArg_ParseTuple(args, "i", &flags))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
-
- /* MIPMAP and FIELDS can't be used together */
- if ((flags & EXPP_TEX_IMAGEFLAG_MIPMAP) &&
- (flags & EXPP_TEX_IMAGEFLAG_FIELDS))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "image flags MIPMAP and FIELDS cannot be used together");
-
- self->texture->imaflag = flags;
-
- Py_INCREF(Py_None);
- return Py_None;
+ int flags = 0;
+ if( !PyArg_ParseTuple( args, "i", &flags ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
+ /* MIPMAP and FIELDS can't be used together */
+ if( ( flags & EXPP_TEX_IMAGEFLAG_MIPMAP ) &&
+ ( flags & EXPP_TEX_IMAGEFLAG_FIELDS ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "image flags MIPMAP and FIELDS cannot be used together" );
+
+ self->texture->imaflag = flags;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setName(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setName( BPy_Texture * self, PyObject * args )
{
- char *name;
- char buf[21];
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&self->texture->id, buf);
+ PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &self->texture->id, buf );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setNoiseDepth(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setNoiseDepth( BPy_Texture * self, PyObject * args )
{
- int depth;
- if (!PyArg_ParseTuple(args, "i", &depth))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int");
+ int depth;
+ if( !PyArg_ParseTuple( args, "i", &depth ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
+
+ if( depth < 0 || depth > 6 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "value must be in range [0,6]" );
- if (depth<0 || depth>6)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "value must be in range [0,6]");
+ self->texture->noisedepth = depth;
- self->texture->noisedepth = depth;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setNoiseSize(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setNoiseSize( BPy_Texture * self, PyObject * args )
{
- float size;
- if (!PyArg_ParseTuple(args, "f", &size))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float size;
+ if( !PyArg_ParseTuple( args, "f", &size ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (size<0 || size>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "noise size must be in range [0,2]");
+ if( size < 0 || size > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "noise size must be in range [0,2]" );
- self->texture->noisesize = size;
-
- Py_INCREF (Py_None);
- return Py_None;
+ self->texture->noisesize = size;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setNoiseType(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setNoiseType( BPy_Texture * self, PyObject * args )
{
- char *type;
+ char *type;
+
+ if( !PyArg_ParseTuple( args, "s", &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if (!PyArg_ParseTuple(args, "s", &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( STREQ( type, "soft" ) )
+ self->texture->noisetype = TEX_NOISESOFT;
+ else if( STREQ( type, "hard" ) )
+ self->texture->noisetype = TEX_NOISEPERL;
- if (STREQ(type, "soft"))
- self->texture->noisetype = TEX_NOISESOFT;
- else if (STREQ(type, "hard"))
- self->texture->noisetype = TEX_NOISEPERL;
-
- else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "noise type must be 'soft' or 'hard'");
+ else
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "noise type must be 'soft' or 'hard'" );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setNoiseBasis(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setNoiseBasis( BPy_Texture * self, PyObject * args )
{
- char *nbasis;
+ char *nbasis;
- if (!PyArg_ParseTuple(args, "s", &nbasis))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
- if ( self->texture->type==EXPP_TEX_TYPE_MUSGRAVE &&
- EXPP_map_getShortVal (tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis));
- else if(self->texture->type==EXPP_TEX_TYPE_DISTNOISE &&
- !EXPP_map_getShortVal (tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis2))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid noise basis");
+ if( !PyArg_ParseTuple( args, "s", &nbasis ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+ if( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE &&
+ EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
+ nbasis, &self->texture->noisebasis ) );
+ else if( self->texture->type == EXPP_TEX_TYPE_DISTNOISE &&
+ !EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
+ nbasis, &self->texture->noisebasis2 ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid noise basis" );
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/* Distorted Noise */
-static PyObject *Texture_setDistNoise(BPy_Texture *self, PyObject *args)
-{
- char *nbasis;
-
- if (!PyArg_ParseTuple(args, "s", &nbasis))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
- if ( self->texture->type==EXPP_TEX_TYPE_DISTNOISE &&
- !EXPP_map_getShortVal (tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid noise basis");
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *Texture_setRepeat(BPy_Texture *self, PyObject *args)
-{
- int repeat[2];
- int i;
- if (!PyArg_ParseTuple(args, "(ii)", &repeat[0], &repeat[1]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected tuple of 2 ints");
-
- for (i=0; i<2; ++i)
- if (repeat[i]<1 || repeat[i]>512)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "values must be in range [1,512]");
-
- self->texture->xrepeat = repeat[0];
- self->texture->yrepeat = repeat[1];
-
- Py_INCREF (Py_None);
- return Py_None;
-}
-
-static PyObject *Texture_setRGBCol(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setDistNoise( BPy_Texture * self, PyObject * args )
{
- float rgb[3];
- int i;
- if (!PyArg_ParseTuple(args, "(fff)", &rgb[0], &rgb[1], &rgb[2]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected tuple of 3 floats");
-
- for (i=0; i<3; ++i)
- if (rgb[i]<0 || rgb[i]>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "values must be in range [0,2]");
+ char *nbasis;
- self->texture->rfac = rgb[0];
- self->texture->gfac = rgb[1];
- self->texture->bfac = rgb[2];
-
- Py_INCREF (Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "s", &nbasis ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+ if( self->texture->type == EXPP_TEX_TYPE_DISTNOISE &&
+ !EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
+ nbasis, &self->texture->noisebasis ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid noise basis" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
+static PyObject *Texture_setRepeat( BPy_Texture * self, PyObject * args )
+{
+ int repeat[2];
+ int i;
+ if( !PyArg_ParseTuple( args, "(ii)", &repeat[0], &repeat[1] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected tuple of 2 ints" );
+
+ for( i = 0; i < 2; ++i )
+ if( repeat[i] < 1 || repeat[i] > 512 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "values must be in range [1,512]" );
-static PyObject *Texture_setSType(BPy_Texture *self, PyObject *args)
+ self->texture->xrepeat = repeat[0];
+ self->texture->yrepeat = repeat[1];
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_setRGBCol( BPy_Texture * self, PyObject * args )
{
- char *stype = NULL;
- if (!PyArg_ParseTuple(args, "s", &stype))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ float rgb[3];
+ int i;
+ if( !PyArg_ParseTuple( args, "(fff)", &rgb[0], &rgb[1], &rgb[2] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( rgb[i] < 0 || rgb[i] > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "values must be in range [0,2]" );
- /* can we really trust texture->type? */
- if((self->texture->type==EXPP_TEX_TYPE_VORONOI &&
- EXPP_map_getShortVal (tex_stype_map[self->texture->type],
- stype, &self->texture->vn_coltype)));
- else if((self->texture->type==EXPP_TEX_TYPE_MUSGRAVE &&
- EXPP_map_getShortVal (tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- stype, &self->texture->noisebasis)));
- else if (!EXPP_map_getShortVal (tex_stype_map[self->texture->type],
- stype, &self->texture->stype))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid texture stype");
+ self->texture->rfac = rgb[0];
+ self->texture->gfac = rgb[1];
+ self->texture->bfac = rgb[2];
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setIntSType(BPy_Texture *self, PyObject *args)
+
+static PyObject *Texture_setSType( BPy_Texture * self, PyObject * args )
{
- int stype = 0;
- const char *dummy = NULL;
- if (!PyArg_ParseTuple(args, "i", &stype))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
-
- /* use the stype map to find out if this is a valid stype for this type *
- * note that this will allow CLD_COLOR when type is ENVMAP. there's not *
- * much that we can do about this though. */
- if (!EXPP_map_getStrVal (tex_stype_map[self->texture->type], stype, &dummy))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid stype (for this type)");
-
- self->texture->stype = stype;
-
- Py_INCREF(Py_None);
- return Py_None;
+ char *stype = NULL;
+ if( !PyArg_ParseTuple( args, "s", &stype ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+
+ /* can we really trust texture->type? */
+ if( ( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
+ EXPP_map_getShortVal( tex_stype_map[self->texture->type],
+ stype, &self->texture->vn_coltype ) ) );
+ else if( ( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE &&
+ EXPP_map_getShortVal( tex_stype_map
+ [EXPP_TEX_TYPE_DISTNOISE], stype,
+ &self->texture->noisebasis ) ) );
+ else if( !EXPP_map_getShortVal
+ ( tex_stype_map[self->texture->type], stype,
+ &self->texture->stype ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture stype" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setTurbulence(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setIntSType( BPy_Texture * self, PyObject * args )
{
- float turb;
- if (!PyArg_ParseTuple(args, "f", &turb))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ int stype = 0;
+ const char *dummy = NULL;
+ if( !PyArg_ParseTuple( args, "i", &stype ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
+ /* use the stype map to find out if this is a valid stype for this type *
+ * note that this will allow CLD_COLOR when type is ENVMAP. there's not *
+ * much that we can do about this though. */
+ if( !EXPP_map_getStrVal
+ ( tex_stype_map[self->texture->type], stype, &dummy ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid stype (for this type)" );
- if (turb<0 || turb>200)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "turbulence must be in range [0,200]");
+ self->texture->stype = stype;
- self->texture->turbul = turb;
-
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setType(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setTurbulence( BPy_Texture * self, PyObject * args )
{
- char *type = NULL;
- if (!PyArg_ParseTuple(args, "s", &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ float turb;
+ if( !PyArg_ParseTuple( args, "f", &turb ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
+
+ if( turb < 0 || turb > 200 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "turbulence must be in range [0,200]" );
- if (!EXPP_map_getShortVal (tex_type_map, type, &self->texture->type))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid texture type");
+ self->texture->turbul = turb;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
+static PyObject *Texture_setType( BPy_Texture * self, PyObject * args )
+{
+ char *type = NULL;
+ if( !PyArg_ParseTuple( args, "s", &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+
+ if( !EXPP_map_getShortVal( tex_type_map, type, &self->texture->type ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture type" );
-static PyObject *Texture_setHFrac(BPy_Texture *self, PyObject *args)
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+
+static PyObject *Texture_setHFrac( BPy_Texture * self, PyObject * args )
{
- float mg_H;
- if (!PyArg_ParseTuple(args, "f", &mg_H))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float mg_H;
+ if( !PyArg_ParseTuple( args, "f", &mg_H ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (mg_H<0 || mg_H>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "turbulence must be in range [0,2]");
+ if( mg_H < 0 || mg_H > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "turbulence must be in range [0,2]" );
- self->texture->mg_H = mg_H;
+ self->texture->mg_H = mg_H;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setLacunarity(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setLacunarity( BPy_Texture * self, PyObject * args )
{
- float mg_lac;
- if (!PyArg_ParseTuple(args, "f", &mg_lac))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float mg_lac;
+ if( !PyArg_ParseTuple( args, "f", &mg_lac ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (mg_lac<0 || mg_lac>6)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "lacunarity must be in range [0,6]");
+ if( mg_lac < 0 || mg_lac > 6 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "lacunarity must be in range [0,6]" );
- self->texture->mg_lacunarity = mg_lac;
+ self->texture->mg_lacunarity = mg_lac;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setOcts(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setOcts( BPy_Texture * self, PyObject * args )
{
- float mg_oct;
- if (!PyArg_ParseTuple(args, "f", &mg_oct))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float mg_oct;
+ if( !PyArg_ParseTuple( args, "f", &mg_oct ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (mg_oct<0 || mg_oct>8)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "turbulence must be in range [0,8]");
+ if( mg_oct < 0 || mg_oct > 8 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "turbulence must be in range [0,8]" );
- self->texture->mg_octaves = mg_oct;
+ self->texture->mg_octaves = mg_oct;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setiScale(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setiScale( BPy_Texture * self, PyObject * args )
{
- float ns_osc;
- if (!PyArg_ParseTuple(args, "f", &ns_osc))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float ns_osc;
+ if( !PyArg_ParseTuple( args, "f", &ns_osc ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (ns_osc<0 || ns_osc>10)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "turbulence must be in range [0,10]");
+ if( ns_osc < 0 || ns_osc > 10 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "turbulence must be in range [0,10]" );
- self->texture->ns_outscale = ns_osc;
+ self->texture->ns_outscale = ns_osc;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setIntType(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setIntType( BPy_Texture * self, PyObject * args )
{
- int type = 0;
- if (!PyArg_ParseTuple(args, "i", &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
-
- if (type<EXPP_TEX_TYPE_MIN || type>EXPP_TEX_TYPE_MAX)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid type number");
-
- self->texture->type = type;
-
- Py_INCREF(Py_None);
- return Py_None;
+ int type = 0;
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
+
+ if( type < EXPP_TEX_TYPE_MIN || type > EXPP_TEX_TYPE_MAX )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid type number" );
+
+ self->texture->type = type;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setDistMetric(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setDistMetric( BPy_Texture * self, PyObject * args )
{
- char *dist = NULL;
+ char *dist = NULL;
- if (!PyArg_ParseTuple(args, "s", &dist))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
- /* can we really trust texture->type? */
- if(self->texture->type==EXPP_TEX_TYPE_VORONOI &&
- !EXPP_map_getShortVal (tex_stype_map[self->texture->type+2],
- dist, &self->texture->vn_distm))
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "invalid dist metric type");
-
- Py_INCREF(Py_None);
- return Py_None;
+ if( !PyArg_ParseTuple( args, "s", &dist ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+ /* can we really trust texture->type? */
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
+ !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
+ dist, &self->texture->vn_distm ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid dist metric type" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setExp(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setExp( BPy_Texture * self, PyObject * args )
{
- float vn_mexp;
- if (!PyArg_ParseTuple(args, "f", &vn_mexp))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float vn_mexp;
+ if( !PyArg_ParseTuple( args, "f", &vn_mexp ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (vn_mexp<0 || vn_mexp>10)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
+ if( vn_mexp < 0 || vn_mexp > 10 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
- self->texture->vn_mexp = vn_mexp;
+ self->texture->vn_mexp = vn_mexp;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setW1(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setW1( BPy_Texture * self, PyObject * args )
{
- float vn_w1;
- if (!PyArg_ParseTuple(args, "f", &vn_w1))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float vn_w1;
+ if( !PyArg_ParseTuple( args, "f", &vn_w1 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (vn_w1<-2 || vn_w1>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
+ if( vn_w1 < -2 || vn_w1 > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
- self->texture->vn_w1= vn_w1;
+ self->texture->vn_w1 = vn_w1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setW2(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setW2( BPy_Texture * self, PyObject * args )
{
- float vn_w2;
- if (!PyArg_ParseTuple(args, "f", &vn_w2))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float vn_w2;
+ if( !PyArg_ParseTuple( args, "f", &vn_w2 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- if (vn_w2<-2 || vn_w2>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
+ if( vn_w2 < -2 || vn_w2 > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
- self->texture->vn_w2= vn_w2;
+ self->texture->vn_w2 = vn_w2;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *Texture_setW3(BPy_Texture *self, PyObject *args)
+static PyObject *Texture_setW3( BPy_Texture * self, PyObject * args )
{
- float vn_w3;
- if (!PyArg_ParseTuple(args, "f", &vn_w3))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
+ float vn_w3;
+ if( !PyArg_ParseTuple( args, "f", &vn_w3 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
+
+ if( vn_w3 < -2 || vn_w3 > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
- if (vn_w3<-2 || vn_w3>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
+ self->texture->vn_w3 = vn_w3;
- self->texture->vn_w3= vn_w3;
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_setW4( BPy_Texture * self, PyObject * args )
+{
+ float vn_w4;
+ if( !PyArg_ParseTuple( args, "f", &vn_w4 ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *Texture_setW4(BPy_Texture *self, PyObject *args)
-{
- float vn_w4;
- if (!PyArg_ParseTuple(args, "f", &vn_w4))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
-
- if (vn_w4<-2 || vn_w4>2)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
-
- self->texture->vn_w4= vn_w4;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *Texture_setDistAmnt(BPy_Texture *self, PyObject *args)
-{
- float dist_amount;
- if (!PyArg_ParseTuple(args, "f", &dist_amount))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float");
-
- if (dist_amount<0 || dist_amount>10)
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "Exp must be in range [0,10]");
-
- self->texture->dist_amount= dist_amount;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static void Texture_dealloc (BPy_Texture *self)
-{
- PyObject_DEL (self);
-}
-
-static PyObject *Texture_getAttr (BPy_Texture *self, char *name)
-{
- PyObject *attr = Py_None;
- Tex *tex = self->texture;
-
- if (STREQ(name, "animFrames"))
- attr = PyInt_FromLong (tex->frames);
- else if (STREQ(name, "animLength"))
- attr = PyInt_FromLong (tex->len);
- else if (STREQ(name, "animMontage"))
- attr = Py_BuildValue("((i,i),(i,i),(i,i),(i,i))",
- tex->fradur[0][0], tex->fradur[0][1],
- tex->fradur[1][0], tex->fradur[1][1],
- tex->fradur[2][0], tex->fradur[2][1],
- tex->fradur[3][0], tex->fradur[3][1] );
- else if (STREQ(name, "animOffset"))
- attr = PyInt_FromLong (tex->offset);
- else if (STREQ(name, "animStart"))
- attr = PyInt_FromLong (tex->sfra);
- else if (STREQ(name, "brightness"))
- attr = PyFloat_FromDouble (tex->bright);
- else if (STREQ(name, "contrast"))
- attr = PyFloat_FromDouble (tex->contrast);
- else if (STREQ(name, "crop"))
- attr = Py_BuildValue("(f,f,f,f)", tex->cropxmin, tex->cropymin,
- tex->cropxmax, tex->cropymax);
- else if (STREQ(name, "extend"))
- attr = PyInt_FromLong (tex->extend);
- else if (STREQ(name, "fieldsPerImage"))
- attr = PyInt_FromLong (tex->fie_ima);
- else if (STREQ(name, "filterSize"))
- attr = PyFloat_FromDouble (tex->filtersize);
- else if (STREQ(name, "flags"))
- attr = PyInt_FromLong (tex->flag);
- else if (STREQ(name, "image"))
- attr = Texture_getImage (self);
- else if (STREQ(name, "imageFlags"))
- attr = PyInt_FromLong (tex->imaflag);
- else if (STREQ(name, "name"))
- attr = PyString_FromString(tex->id.name+2);
- else if (STREQ(name, "noiseDepth"))
- attr = PyInt_FromLong (tex->noisedepth);
- else if (STREQ(name, "noiseSize"))
- attr = PyFloat_FromDouble (tex->noisesize);
- else if (STREQ(name, "noiseType"))
- {
- if (tex->noisetype == TEX_NOISESOFT)
- attr = PyString_FromString ("soft");
- else
- attr = PyString_FromString ("hard");
- }
- else if (STREQ(name, "repeat"))
- attr = Py_BuildValue ("(i,i)", tex->xrepeat, tex->yrepeat);
- else if (STREQ(name, "rgbCol"))
- attr = Py_BuildValue ("(f,f,f)", tex->rfac, tex->gfac, tex->gfac);
- else if (STREQ(name, "stype"))
- attr = PyInt_FromLong (tex->stype);
- else if (STREQ(name, "turbulence"))
- attr = PyFloat_FromDouble (tex->turbul);
- else if (STREQ(name, "type"))
- attr = PyInt_FromLong (tex->type);
- else if (STREQ(name, "hFracDim"))
- attr = PyInt_FromLong (tex->mg_H);
- else if (STREQ(name, "lacunarity"))
- attr = PyFloat_FromDouble(tex->mg_lacunarity);
- else if (STREQ(name, "octs"))
- attr = PyFloat_FromDouble(tex->mg_octaves);
- else if (STREQ(name, "iSacale"))
- attr = PyFloat_FromDouble(tex->ns_outscale);
- else if (STREQ(name, "exp"))
- attr = PyFloat_FromDouble(tex->vn_mexp);
- else if (STREQ(name, "weight1"))
- attr = PyFloat_FromDouble(tex->vn_w1);
- else if (STREQ(name, "weight2"))
- attr = PyFloat_FromDouble(tex->vn_w2);
- else if (STREQ(name, "weight3"))
- attr = PyFloat_FromDouble(tex->vn_w3);
- else if (STREQ(name, "weight4"))
- attr = PyFloat_FromDouble(tex->vn_w4);
- else if (STREQ(name, "distAmnt"))
- attr = PyFloat_FromDouble(tex->vn_w4);
-
- else if (STREQ(name, "__members__"))
- attr = Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
- "animFrames", "animLength", "animMontage", "animOffset",
- "animStart", "brightness", "contrast", "crop", "extend",
- "fieldsPerImage", "filterSize", "flags", "image",
- "imageFlags", "name", "noiseDepth", "noiseSize", "noiseType",
- "repeat", "rgbCol", "stype", "turbulence", "type", "hFracDim",
- "lacunarity", "octs", "iScale","exp", "weight1", "weight2",
- "weight3", "weight4", "distAmnt");
-
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject");
-
- if (attr != Py_None)
- return attr; /* member attribute found, return it */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Texture_methods, (PyObject *)self, name);
-}
-
-
-static int Texture_setAttr (BPy_Texture *self, char *name, PyObject *value)
-{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- /* Put "value" in a tuple, because we want to pass it to functions *
- * that only accept PyTuples. */
- valtuple = Py_BuildValue("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "Texture_setAttr: couldn't create PyTuple");
-
- if (STREQ(name, "animFrames"))
- error = Texture_setAnimFrames (self, valtuple);
- else if (STREQ(name, "animLength"))
- error = Texture_setAnimLength(self, valtuple);
- else if (STREQ(name, "animMontage"))
- error = Texture_setAnimMontage(self, valtuple);
- else if (STREQ(name, "animOffset"))
- error = Texture_setAnimOffset(self, valtuple);
- else if (STREQ(name, "animStart"))
- error = Texture_setAnimStart(self, valtuple);
- else if (STREQ(name, "brightness"))
- error = Texture_setBrightness(self, valtuple);
- else if (STREQ(name, "contrast"))
- error = Texture_setContrast(self, valtuple);
- else if (STREQ(name, "crop"))
- error = Texture_setCrop(self, valtuple);
- else if (STREQ(name, "extend"))
- error = Texture_setIntExtend(self, valtuple);
- else if (STREQ(name, "fieldsPerImage"))
- error = Texture_setFieldsPerImage(self, valtuple);
- else if (STREQ(name, "filterSize"))
- error = Texture_setFilterSize(self, valtuple);
- else if (STREQ(name, "flags"))
- error = Texture_setIntFlags(self, valtuple);
- else if (STREQ(name, "image"))
- error = Texture_setImage (self, valtuple);
- else if (STREQ(name, "imageFlags"))
- error = Texture_setIntImageFlags(self, valtuple);
- else if (STREQ(name, "name"))
- error = Texture_setName(self, valtuple);
- else if (STREQ(name, "noiseDepth"))
- error = Texture_setNoiseDepth(self, valtuple);
- else if (STREQ(name, "noiseSize"))
- error = Texture_setNoiseSize(self, valtuple);
- else if (STREQ(name, "noiseType"))
- error = Texture_setNoiseType(self, valtuple);
- else if (STREQ(name, "repeat"))
- error = Texture_setRepeat(self, valtuple);
- else if (STREQ(name, "rgbCol"))
- error = Texture_setRGBCol(self, valtuple);
- else if (STREQ(name, "stype"))
- error = Texture_setIntSType(self, valtuple);
- else if (STREQ(name, "turbulence"))
- error = Texture_setTurbulence(self, valtuple);
- else if (STREQ(name, "type"))
- error = Texture_setIntType(self, valtuple);
- else if (STREQ(name, "hFracDim"))
- error = Texture_setHFrac(self, valtuple);
- else if (STREQ(name, "lacunarity"))
- error = Texture_setLacunarity (self, valtuple);
- else if (STREQ(name, "octs"))
- error = Texture_setOcts (self, valtuple);
- else if (STREQ(name, "iScale"))
- error = Texture_setiScale(self, valtuple);
- else if (STREQ(name, "exp"))
- error = Texture_setExp(self, valtuple);
- else if (STREQ(name, "weight1"))
- error = Texture_setW1(self, valtuple);
- else if (STREQ(name, "weight2"))
- error = Texture_setW2(self, valtuple);
- else if (STREQ(name, "weight3"))
- error = Texture_setW3(self, valtuple);
- else if (STREQ(name, "weight4"))
- error = Texture_setW4(self, valtuple);
- else if (STREQ(name, "distAmnt"))
- error = Texture_setDistAmnt(self, valtuple);
-
-
- else {
- /* Error */
- Py_DECREF(valtuple);
- return EXPP_ReturnIntError (PyExc_KeyError, "attribute not found");
- }
-
- Py_DECREF (valtuple);
-
- if (error != Py_None)
- return -1;
-
- /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
- Py_DECREF (Py_None);
-
- return 0;
-}
-
-static int Texture_compare (BPy_Texture *a, BPy_Texture *b)
-{
- return (a->texture == b->texture) ? 0 : -1;
-}
-
-static PyObject *Texture_repr (BPy_Texture *self)
-{
- return PyString_FromFormat("[Texture \"%s\"]", self->texture->id.name+2);
-}
-
-static PyObject *
-Texture_getIpo (BPy_Texture * self)
-{
- struct Ipo *ipo = self->texture->ipo;
-
- if (!ipo)
- {
- Py_INCREF (Py_None);
- return Py_None;
- }
-
- return Ipo_CreatePyObject (ipo);
+ if( vn_w4 < -2 || vn_w4 > 2 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
+
+ self->texture->vn_w4 = vn_w4;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_setDistAmnt( BPy_Texture * self, PyObject * args )
+{
+ float dist_amount;
+ if( !PyArg_ParseTuple( args, "f", &dist_amount ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a float" );
+
+ if( dist_amount < 0 || dist_amount > 10 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "Exp must be in range [0,10]" );
+
+ self->texture->dist_amount = dist_amount;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static void Texture_dealloc( BPy_Texture * self )
+{
+ PyObject_DEL( self );
+}
+
+static PyObject *Texture_getAttr( BPy_Texture * self, char *name )
+{
+ PyObject *attr = Py_None;
+ Tex *tex = self->texture;
+
+ if( STREQ( name, "animFrames" ) )
+ attr = PyInt_FromLong( tex->frames );
+ else if( STREQ( name, "animLength" ) )
+ attr = PyInt_FromLong( tex->len );
+ else if( STREQ( name, "animMontage" ) )
+ attr = Py_BuildValue( "((i,i),(i,i),(i,i),(i,i))",
+ tex->fradur[0][0], tex->fradur[0][1],
+ tex->fradur[1][0], tex->fradur[1][1],
+ tex->fradur[2][0], tex->fradur[2][1],
+ tex->fradur[3][0], tex->fradur[3][1] );
+ else if( STREQ( name, "animOffset" ) )
+ attr = PyInt_FromLong( tex->offset );
+ else if( STREQ( name, "animStart" ) )
+ attr = PyInt_FromLong( tex->sfra );
+ else if( STREQ( name, "brightness" ) )
+ attr = PyFloat_FromDouble( tex->bright );
+ else if( STREQ( name, "contrast" ) )
+ attr = PyFloat_FromDouble( tex->contrast );
+ else if( STREQ( name, "crop" ) )
+ attr = Py_BuildValue( "(f,f,f,f)", tex->cropxmin,
+ tex->cropymin, tex->cropxmax,
+ tex->cropymax );
+ else if( STREQ( name, "extend" ) )
+ attr = PyInt_FromLong( tex->extend );
+ else if( STREQ( name, "fieldsPerImage" ) )
+ attr = PyInt_FromLong( tex->fie_ima );
+ else if( STREQ( name, "filterSize" ) )
+ attr = PyFloat_FromDouble( tex->filtersize );
+ else if( STREQ( name, "flags" ) )
+ attr = PyInt_FromLong( tex->flag );
+ else if( STREQ( name, "image" ) )
+ attr = Texture_getImage( self );
+ else if( STREQ( name, "imageFlags" ) )
+ attr = PyInt_FromLong( tex->imaflag );
+ else if( STREQ( name, "name" ) )
+ attr = PyString_FromString( tex->id.name + 2 );
+ else if( STREQ( name, "noiseDepth" ) )
+ attr = PyInt_FromLong( tex->noisedepth );
+ else if( STREQ( name, "noiseSize" ) )
+ attr = PyFloat_FromDouble( tex->noisesize );
+ else if( STREQ( name, "noiseType" ) ) {
+ if( tex->noisetype == TEX_NOISESOFT )
+ attr = PyString_FromString( "soft" );
+ else
+ attr = PyString_FromString( "hard" );
+ } else if( STREQ( name, "repeat" ) )
+ attr = Py_BuildValue( "(i,i)", tex->xrepeat, tex->yrepeat );
+ else if( STREQ( name, "rgbCol" ) )
+ attr = Py_BuildValue( "(f,f,f)", tex->rfac, tex->gfac,
+ tex->gfac );
+ else if( STREQ( name, "stype" ) )
+ attr = PyInt_FromLong( tex->stype );
+ else if( STREQ( name, "turbulence" ) )
+ attr = PyFloat_FromDouble( tex->turbul );
+ else if( STREQ( name, "type" ) )
+ attr = PyInt_FromLong( tex->type );
+ else if( STREQ( name, "hFracDim" ) )
+ attr = PyInt_FromLong( tex->mg_H );
+ else if( STREQ( name, "lacunarity" ) )
+ attr = PyFloat_FromDouble( tex->mg_lacunarity );
+ else if( STREQ( name, "octs" ) )
+ attr = PyFloat_FromDouble( tex->mg_octaves );
+ else if( STREQ( name, "iSacale" ) )
+ attr = PyFloat_FromDouble( tex->ns_outscale );
+ else if( STREQ( name, "exp" ) )
+ attr = PyFloat_FromDouble( tex->vn_mexp );
+ else if( STREQ( name, "weight1" ) )
+ attr = PyFloat_FromDouble( tex->vn_w1 );
+ else if( STREQ( name, "weight2" ) )
+ attr = PyFloat_FromDouble( tex->vn_w2 );
+ else if( STREQ( name, "weight3" ) )
+ attr = PyFloat_FromDouble( tex->vn_w3 );
+ else if( STREQ( name, "weight4" ) )
+ attr = PyFloat_FromDouble( tex->vn_w4 );
+ else if( STREQ( name, "distAmnt" ) )
+ attr = PyFloat_FromDouble( tex->vn_w4 );
+
+ else if( STREQ( name, "__members__" ) )
+ attr = Py_BuildValue
+ ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+ "animFrames", "animLength", "animMontage",
+ "animOffset", "animStart", "brightness", "contrast",
+ "crop", "extend", "fieldsPerImage", "filterSize",
+ "flags", "image", "imageFlags", "name", "noiseDepth",
+ "noiseSize", "noiseType", "repeat", "rgbCol",
+ "stype", "turbulence", "type", "hFracDim",
+ "lacunarity", "octs", "iScale", "exp", "weight1",
+ "weight2", "weight3", "weight4", "distAmnt" );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyObject" );
+
+ if( attr != Py_None )
+ return attr; /* member attribute found, return it */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod( BPy_Texture_methods, ( PyObject * ) self, name );
+}
+
+
+static int Texture_setAttr( BPy_Texture * self, char *name, PyObject * value )
+{
+ PyObject *valtuple;
+ PyObject *error = NULL;
+
+ /* Put "value" in a tuple, because we want to pass it to functions *
+ * that only accept PyTuples. */
+ valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "Texture_setAttr: couldn't create PyTuple" );
+
+ if( STREQ( name, "animFrames" ) )
+ error = Texture_setAnimFrames( self, valtuple );
+ else if( STREQ( name, "animLength" ) )
+ error = Texture_setAnimLength( self, valtuple );
+ else if( STREQ( name, "animMontage" ) )
+ error = Texture_setAnimMontage( self, valtuple );
+ else if( STREQ( name, "animOffset" ) )
+ error = Texture_setAnimOffset( self, valtuple );
+ else if( STREQ( name, "animStart" ) )
+ error = Texture_setAnimStart( self, valtuple );
+ else if( STREQ( name, "brightness" ) )
+ error = Texture_setBrightness( self, valtuple );
+ else if( STREQ( name, "contrast" ) )
+ error = Texture_setContrast( self, valtuple );
+ else if( STREQ( name, "crop" ) )
+ error = Texture_setCrop( self, valtuple );
+ else if( STREQ( name, "extend" ) )
+ error = Texture_setIntExtend( self, valtuple );
+ else if( STREQ( name, "fieldsPerImage" ) )
+ error = Texture_setFieldsPerImage( self, valtuple );
+ else if( STREQ( name, "filterSize" ) )
+ error = Texture_setFilterSize( self, valtuple );
+ else if( STREQ( name, "flags" ) )
+ error = Texture_setIntFlags( self, valtuple );
+ else if( STREQ( name, "image" ) )
+ error = Texture_setImage( self, valtuple );
+ else if( STREQ( name, "imageFlags" ) )
+ error = Texture_setIntImageFlags( self, valtuple );
+ else if( STREQ( name, "name" ) )
+ error = Texture_setName( self, valtuple );
+ else if( STREQ( name, "noiseDepth" ) )
+ error = Texture_setNoiseDepth( self, valtuple );
+ else if( STREQ( name, "noiseSize" ) )
+ error = Texture_setNoiseSize( self, valtuple );
+ else if( STREQ( name, "noiseType" ) )
+ error = Texture_setNoiseType( self, valtuple );
+ else if( STREQ( name, "repeat" ) )
+ error = Texture_setRepeat( self, valtuple );
+ else if( STREQ( name, "rgbCol" ) )
+ error = Texture_setRGBCol( self, valtuple );
+ else if( STREQ( name, "stype" ) )
+ error = Texture_setIntSType( self, valtuple );
+ else if( STREQ( name, "turbulence" ) )
+ error = Texture_setTurbulence( self, valtuple );
+ else if( STREQ( name, "type" ) )
+ error = Texture_setIntType( self, valtuple );
+ else if( STREQ( name, "hFracDim" ) )
+ error = Texture_setHFrac( self, valtuple );
+ else if( STREQ( name, "lacunarity" ) )
+ error = Texture_setLacunarity( self, valtuple );
+ else if( STREQ( name, "octs" ) )
+ error = Texture_setOcts( self, valtuple );
+ else if( STREQ( name, "iScale" ) )
+ error = Texture_setiScale( self, valtuple );
+ else if( STREQ( name, "exp" ) )
+ error = Texture_setExp( self, valtuple );
+ else if( STREQ( name, "weight1" ) )
+ error = Texture_setW1( self, valtuple );
+ else if( STREQ( name, "weight2" ) )
+ error = Texture_setW2( self, valtuple );
+ else if( STREQ( name, "weight3" ) )
+ error = Texture_setW3( self, valtuple );
+ else if( STREQ( name, "weight4" ) )
+ error = Texture_setW4( self, valtuple );
+ else if( STREQ( name, "distAmnt" ) )
+ error = Texture_setDistAmnt( self, valtuple );
+
+
+ else {
+ /* Error */
+ Py_DECREF( valtuple );
+ return EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" );
+ }
+
+ Py_DECREF( valtuple );
+
+ if( error != Py_None )
+ return -1;
+
+ /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
+ Py_DECREF( Py_None );
+
+ return 0;
+}
+
+static int Texture_compare( BPy_Texture * a, BPy_Texture * b )
+{
+ return ( a->texture == b->texture ) ? 0 : -1;
+}
+
+static PyObject *Texture_repr( BPy_Texture * self )
+{
+ return PyString_FromFormat( "[Texture \"%s\"]",
+ self->texture->id.name + 2 );
+}
+
+static PyObject *Texture_getIpo( BPy_Texture * self )
+{
+ struct Ipo *ipo = self->texture->ipo;
+
+ if( !ipo ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
+ return Ipo_CreatePyObject( ipo );
}
extern PyTypeObject Ipo_Type;
-static PyObject *
-Texture_setIpo (BPy_Texture * self, PyObject * args)
+static PyObject *Texture_setIpo( BPy_Texture * self, PyObject * args )
{
- PyObject *pyipo = 0;
- Ipo *ipo = NULL;
- Ipo *oldipo;
+ 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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject (pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ if( !ipo )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "null ipo!" );
- if (ipo->blocktype != ID_TE)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this ipo is not a texture data ipo");
+ if( ipo->blocktype != ID_TE )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not a texture data ipo" );
- oldipo = self->texture->ipo;
- if (oldipo)
- {
- ID *id = &oldipo->id;
- if (id->us > 0)
- id->us--;
- }
+ oldipo = self->texture->ipo;
+ if( oldipo ) {
+ ID *id = &oldipo->id;
+ if( id->us > 0 )
+ id->us--;
+ }
- ((ID *) & ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
- self->texture->ipo = ipo;
+ self->texture->ipo = ipo;
- Py_INCREF (Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *
-Texture_clearIpo (BPy_Texture * self)
+static PyObject *Texture_clearIpo( BPy_Texture * self )
{
- Tex *tex = self->texture;
- Ipo *ipo = (Ipo *) tex->ipo;
+ Tex *tex = self->texture;
+ Ipo *ipo = ( Ipo * ) tex->ipo;
- if (ipo)
- {
- ID *id = &ipo->id;
- if (id->us > 0)
- id->us--;
- tex->ipo = NULL;
+ if( ipo ) {
+ ID *id = &ipo->id;
+ if( id->us > 0 )
+ id->us--;
+ tex->ipo = NULL;
- Py_INCREF (Py_True);
- return Py_True;
- }
+ Py_INCREF( Py_True );
+ return Py_True;
+ }
- Py_INCREF (Py_False); /* no ipo found */
- return Py_False;
+ Py_INCREF( Py_False ); /* no ipo found */
+ return Py_False;
}
-
diff --git a/source/blender/python/api2_2x/Texture.h b/source/blender/python/api2_2x/Texture.h
index 9afa837a809..19788e54c5a 100644
--- a/source/blender/python/api2_2x/Texture.h
+++ b/source/blender/python/api2_2x/Texture.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -44,11 +45,10 @@
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Tex *texture;
+ PyObject_HEAD Tex * texture;
} BPy_Texture;
-extern PyTypeObject Texture_Type;
+extern PyTypeObject Texture_Type;
#define BPy_Texture_Check(v) ((v)->ob_type == &Texture_Type)
@@ -57,11 +57,10 @@ extern PyTypeObject Texture_Type;
/* Module Blender.Texture - public functions */
/*****************************************************************************/
-PyObject * Texture_Init(void);
-PyObject * Texture_CreatePyObject(struct Tex *tex);
-int Texture_CheckPyObject(PyObject *pyobj);
-Tex * Texture_FromPyObject (PyObject *pyobj);
+PyObject *Texture_Init( void );
+PyObject *Texture_CreatePyObject( struct Tex *tex );
+int Texture_CheckPyObject( PyObject * pyobj );
+Tex *Texture_FromPyObject( PyObject * pyobj );
-#endif /* EXPP_TEXTURE_H */
-
+#endif /* EXPP_TEXTURE_H */
diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c
index 3aa425101fb..6647071013f 100644
--- a/source/blender/python/api2_2x/Types.c
+++ b/source/blender/python/api2_2x/Types.c
@@ -31,19 +31,18 @@
#include "Types.h"
-char M_Types_doc[] =
-"The Blender Types module\n\n\
+char M_Types_doc[] = "The Blender Types module\n\n\
This module is a dictionary of all Blender Python types";
-struct PyMethodDef Null_methods[] = {{NULL, NULL, 0, NULL}};
+struct PyMethodDef Null_methods[] = { {NULL, NULL, 0, NULL} };
-void types_InitAll(void)
+void types_InitAll( void )
{
- /* The internal types (lowercase first letter, like constant_Type) are only
- * set when some object initializes them. But unless we do it early, we get
- * some easy and unpredictable (varies with platform, even distro) ways to
- * crash Blender. Some modules also need this early up, so let's generalize
- * and init all our pytypes here. */
+ /* The internal types (lowercase first letter, like constant_Type) are only
+ * set when some object initializes them. But unless we do it early, we get
+ * some easy and unpredictable (varies with platform, even distro) ways to
+ * crash Blender. Some modules also need this early up, so let's generalize
+ * and init all our pytypes here. */
Action_Type.ob_type = &PyType_Type;
Armature_Type.ob_type = &PyType_Type;
@@ -86,64 +85,86 @@ void types_InitAll(void)
}
/*****************************************************************************/
-/* Function: Types_Init */
+/* Function: Types_Init */
/*****************************************************************************/
-PyObject *Types_Init (void)
+PyObject *Types_Init( void )
{
- PyObject *submodule, *dict;
+ PyObject *submodule, *dict;
- submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc);
+ submodule =
+ Py_InitModule3( "Blender.Types", Null_methods, M_Types_doc );
- dict = PyModule_GetDict(submodule);
+ dict = PyModule_GetDict( submodule );
/* The Blender Object Type */
- PyDict_SetItemString(dict, "ObjectType", (PyObject *)&Object_Type);
+ PyDict_SetItemString( dict, "ObjectType",
+ ( PyObject * ) & Object_Type );
/* Blender Object Data Types */
- PyDict_SetItemString(dict, "SceneType", (PyObject *)&Scene_Type);
- PyDict_SetItemString(dict, "RenderDataType", (PyObject *)&RenderData_Type);
+ PyDict_SetItemString( dict, "SceneType", ( PyObject * ) & Scene_Type );
+ PyDict_SetItemString( dict, "RenderDataType",
+ ( PyObject * ) & RenderData_Type );
- PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type);
- PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type);
- PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type);
- PyDict_SetItemString(dict, "NMColType", (PyObject *)&NMCol_Type);
+ PyDict_SetItemString( dict, "NMeshType", ( PyObject * ) & NMesh_Type );
+ PyDict_SetItemString( dict, "NMFaceType",
+ ( PyObject * ) & NMFace_Type );
+ PyDict_SetItemString( dict, "NMVertType",
+ ( PyObject * ) & NMVert_Type );
+ PyDict_SetItemString( dict, "NMColType", ( PyObject * ) & NMCol_Type );
- PyDict_SetItemString(dict, "ArmatureType", (PyObject *)&Armature_Type);
- PyDict_SetItemString(dict, "BoneType", (PyObject *)&Bone_Type);
+ PyDict_SetItemString( dict, "ArmatureType",
+ ( PyObject * ) & Armature_Type );
+ PyDict_SetItemString( dict, "BoneType", ( PyObject * ) & Bone_Type );
- PyDict_SetItemString(dict, "CurNurb_Type", (PyObject *)&CurNurb_Type);
- PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type);
+ PyDict_SetItemString( dict, "CurNurb_Type",
+ ( PyObject * ) & CurNurb_Type );
+ PyDict_SetItemString( dict, "CurveType", ( PyObject * ) & Curve_Type );
- PyDict_SetItemString(dict, "IpoType", (PyObject *)&Ipo_Type);
- PyDict_SetItemString(dict, "MetaballType", (PyObject *)&Metaball_Type);
+ PyDict_SetItemString( dict, "IpoType", ( PyObject * ) & Ipo_Type );
+ PyDict_SetItemString( dict, "MetaballType",
+ ( PyObject * ) & Metaball_Type );
- PyDict_SetItemString(dict, "CameraType", (PyObject *)&Camera_Type);
- PyDict_SetItemString(dict, "ImageType", (PyObject *)&Image_Type);
- PyDict_SetItemString(dict, "LampType", (PyObject *)&Lamp_Type);
- PyDict_SetItemString(dict, "TextType", (PyObject *)&Text_Type);
- PyDict_SetItemString(dict, "MaterialType", (PyObject *)&Material_Type);
+ PyDict_SetItemString( dict, "CameraType",
+ ( PyObject * ) & Camera_Type );
+ PyDict_SetItemString( dict, "ImageType", ( PyObject * ) & Image_Type );
+ PyDict_SetItemString( dict, "LampType", ( PyObject * ) & Lamp_Type );
+ PyDict_SetItemString( dict, "TextType", ( PyObject * ) & Text_Type );
+ PyDict_SetItemString( dict, "MaterialType",
+ ( PyObject * ) & Material_Type );
- PyDict_SetItemString(dict, "ButtonType", (PyObject *)&Button_Type);
+ PyDict_SetItemString( dict, "ButtonType",
+ ( PyObject * ) & Button_Type );
- PyDict_SetItemString(dict, "LatticeType", (PyObject *)&Lattice_Type);
+ PyDict_SetItemString( dict, "LatticeType",
+ ( PyObject * ) & Lattice_Type );
- PyDict_SetItemString(dict, "TextureType", (PyObject *)&Texture_Type);
- PyDict_SetItemString(dict, "MTexType", (PyObject *)&MTex_Type);
+ PyDict_SetItemString( dict, "TextureType",
+ ( PyObject * ) & Texture_Type );
+ PyDict_SetItemString( dict, "MTexType", ( PyObject * ) & MTex_Type );
/* External helper Types available to the main ones above */
- PyDict_SetItemString(dict, "vectorType", (PyObject *)&vector_Type);
- PyDict_SetItemString(dict, "bufferType", (PyObject *)&buffer_Type);
- PyDict_SetItemString(dict, "constantType", (PyObject *)&constant_Type);
- PyDict_SetItemString(dict, "rgbTupleType", (PyObject *)&rgbTuple_Type);
- PyDict_SetItemString(dict, "matrix_Type", (PyObject *)&matrix_Type);
- PyDict_SetItemString(dict, "eulerType", (PyObject *)&euler_Type);
- PyDict_SetItemString(dict, "quaternionType", (PyObject *)&quaternion_Type);
- PyDict_SetItemString(dict, "BezTripleType", (PyObject *)&BezTriple_Type);
- PyDict_SetItemString(dict, "ActionType", (PyObject *)&Action_Type);
- PyDict_SetItemString(dict, "propertyType", (PyObject *)&property_Type);
+ PyDict_SetItemString( dict, "vectorType",
+ ( PyObject * ) & vector_Type );
+ PyDict_SetItemString( dict, "bufferType",
+ ( PyObject * ) & buffer_Type );
+ PyDict_SetItemString( dict, "constantType",
+ ( PyObject * ) & constant_Type );
+ PyDict_SetItemString( dict, "rgbTupleType",
+ ( PyObject * ) & rgbTuple_Type );
+ PyDict_SetItemString( dict, "matrix_Type",
+ ( PyObject * ) & matrix_Type );
+ PyDict_SetItemString( dict, "eulerType", ( PyObject * ) & euler_Type );
+ PyDict_SetItemString( dict, "quaternionType",
+ ( PyObject * ) & quaternion_Type );
+ PyDict_SetItemString( dict, "BezTripleType",
+ ( PyObject * ) & BezTriple_Type );
+ PyDict_SetItemString( dict, "ActionType",
+ ( PyObject * ) & Action_Type );
+ PyDict_SetItemString( dict, "propertyType",
+ ( PyObject * ) & property_Type );
return submodule;
}
diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h
index 032bd05d215..73b7209e4f9 100644
--- a/source/blender/python/api2_2x/Types.h
+++ b/source/blender/python/api2_2x/Types.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -53,4 +54,4 @@ extern PyTypeObject property_Type;
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
-#endif /* EXPP_TYPES_H */
+#endif /* EXPP_TYPES_H */
diff --git a/source/blender/python/api2_2x/Wave.c b/source/blender/python/api2_2x/Wave.c
index 22a88e14bf0..2b73c025251 100644
--- a/source/blender/python/api2_2x/Wave.c
+++ b/source/blender/python/api2_2x/Wave.c
@@ -35,56 +35,56 @@
/*****************************************************************************/
-/* Python BPy_Wave methods table: */
+/* Python BPy_Wave methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Wave_methods[] = {
- {"getType", (PyCFunction)Effect_getType,
- METH_NOARGS,"() - Return Effect type"},
- {"setType", (PyCFunction)Effect_setType,
- METH_VARARGS,"() - Set Effect type"},
- {"getFlag", (PyCFunction)Effect_getFlag,
- METH_NOARGS,"() - Return Effect flag"},
- {"setFlag", (PyCFunction)Effect_setFlag,
- METH_VARARGS,"() - Set Effect flag"},
- {"getStartx",(PyCFunction)Wave_getStartx,
- METH_NOARGS,"()-Return Wave startx"},
- {"setStartx",(PyCFunction)Wave_setStartx, METH_VARARGS,
+ {"getType", ( PyCFunction ) Effect_getType,
+ METH_NOARGS, "() - Return Effect type"},
+ {"setType", ( PyCFunction ) Effect_setType,
+ METH_VARARGS, "() - Set Effect type"},
+ {"getFlag", ( PyCFunction ) Effect_getFlag,
+ METH_NOARGS, "() - Return Effect flag"},
+ {"setFlag", ( PyCFunction ) Effect_setFlag,
+ METH_VARARGS, "() - Set Effect flag"},
+ {"getStartx", ( PyCFunction ) Wave_getStartx,
+ METH_NOARGS, "()-Return Wave startx"},
+ {"setStartx", ( PyCFunction ) Wave_setStartx, METH_VARARGS,
"()- Sets Wave startx"},
- {"getStarty",(PyCFunction)Wave_getStarty,
- METH_NOARGS,"()-Return Wave starty"},
- {"setStarty",(PyCFunction)Wave_setStarty, METH_VARARGS,
+ {"getStarty", ( PyCFunction ) Wave_getStarty,
+ METH_NOARGS, "()-Return Wave starty"},
+ {"setStarty", ( PyCFunction ) Wave_setStarty, METH_VARARGS,
"()- Sets Wave starty"},
- {"getHeight",(PyCFunction)Wave_getHeight,
- METH_NOARGS,"()-Return Wave height"},
- {"setHeight",(PyCFunction)Wave_setHeight, METH_VARARGS,
+ {"getHeight", ( PyCFunction ) Wave_getHeight,
+ METH_NOARGS, "()-Return Wave height"},
+ {"setHeight", ( PyCFunction ) Wave_setHeight, METH_VARARGS,
"()- Sets Wave height"},
- {"getWidth",(PyCFunction)Wave_getWidth,
- METH_NOARGS,"()-Return Wave width"},
- {"setWidth",(PyCFunction)Wave_setWidth, METH_VARARGS,
+ {"getWidth", ( PyCFunction ) Wave_getWidth,
+ METH_NOARGS, "()-Return Wave width"},
+ {"setWidth", ( PyCFunction ) Wave_setWidth, METH_VARARGS,
"()- Sets Wave width"},
- {"getNarrow",(PyCFunction)Wave_getNarrow,
- METH_NOARGS,"()-Return Wave narrow"},
- {"setNarrow",(PyCFunction)Wave_setNarrow, METH_VARARGS,
+ {"getNarrow", ( PyCFunction ) Wave_getNarrow,
+ METH_NOARGS, "()-Return Wave narrow"},
+ {"setNarrow", ( PyCFunction ) Wave_setNarrow, METH_VARARGS,
"()- Sets Wave narrow"},
- {"getSpeed",(PyCFunction)Wave_getSpeed,
- METH_NOARGS,"()-Return Wave speed"},
- {"setSpeed",(PyCFunction)Wave_setSpeed, METH_VARARGS,
+ {"getSpeed", ( PyCFunction ) Wave_getSpeed,
+ METH_NOARGS, "()-Return Wave speed"},
+ {"setSpeed", ( PyCFunction ) Wave_setSpeed, METH_VARARGS,
"()- Sets Wave speed"},
- {"getMinfac",(PyCFunction)Wave_getMinfac,
- METH_NOARGS,"()-Return Wave minfac"},
- {"setMinfac",(PyCFunction)Wave_setMinfac, METH_VARARGS,
+ {"getMinfac", ( PyCFunction ) Wave_getMinfac,
+ METH_NOARGS, "()-Return Wave minfac"},
+ {"setMinfac", ( PyCFunction ) Wave_setMinfac, METH_VARARGS,
"()- Sets Wave minfac"},
- {"getDamp",(PyCFunction)Wave_getDamp,
- METH_NOARGS,"()-Return Wave damp"},
- {"setDamp",(PyCFunction)Wave_setDamp, METH_VARARGS,
+ {"getDamp", ( PyCFunction ) Wave_getDamp,
+ METH_NOARGS, "()-Return Wave damp"},
+ {"setDamp", ( PyCFunction ) Wave_setDamp, METH_VARARGS,
"()- Sets Wave damp"},
- {"getTimeoffs",(PyCFunction)Wave_getTimeoffs,
- METH_NOARGS,"()-Return Wave timeoffs"},
- {"setTimeoffs",(PyCFunction)Wave_setTimeoffs, METH_VARARGS,
+ {"getTimeoffs", ( PyCFunction ) Wave_getTimeoffs,
+ METH_NOARGS, "()-Return Wave timeoffs"},
+ {"setTimeoffs", ( PyCFunction ) Wave_setTimeoffs, METH_VARARGS,
"()- Sets Wave timeoffs"},
- {"getLifetime",(PyCFunction)Wave_getLifetime,
- METH_NOARGS,"()-Return Wave lifetime"},
- {"setLifetime",(PyCFunction)Wave_setLifetime, METH_VARARGS,
+ {"getLifetime", ( PyCFunction ) Wave_getLifetime,
+ METH_NOARGS, "()-Return Wave lifetime"},
+ {"setLifetime", ( PyCFunction ) Wave_setLifetime, METH_VARARGS,
"()- Sets Wave lifetime"},
{NULL, NULL, 0, NULL}
};
@@ -95,29 +95,28 @@ static PyMethodDef BPy_Wave_methods[] = {
/*****************************************************************************/
/* Python Wave_Type structure definition: */
/*****************************************************************************/
-PyTypeObject Wave_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0,
- "Wave",
- sizeof (BPy_Wave),
- 0,
- /* methods */
- (destructor)WaveDeAlloc, /* tp_dealloc */
- (printfunc)WavePrint, /* tp_print */
- (getattrfunc)WaveGetAttr, /* tp_getattr */
- (setattrfunc)WaveSetAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)WaveRepr, /* 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_Wave_methods, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject Wave_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0,
+ "Wave",
+ sizeof( BPy_Wave ),
+ 0,
+ /* methods */
+ ( destructor ) WaveDeAlloc, /* tp_dealloc */
+ ( printfunc ) WavePrint, /* tp_print */
+ ( getattrfunc ) WaveGetAttr, /* tp_getattr */
+ ( setattrfunc ) WaveSetAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) WaveRepr, /* 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_Wave_methods, /* tp_methods */
+ 0, /* tp_members */
};
@@ -132,16 +131,16 @@ Functions :\n\
New(opt name) : creates a new wave object with the given name (optional)\n\
Get(name) : retreives a wave with the given name (mandatory)\n\
get(name) : same as Get. Kept for compatibility reasons";
-static char M_Wave_New_doc[] ="";
-static char M_Wave_Get_doc[] ="xxx";
+static char M_Wave_New_doc[] = "";
+static char M_Wave_Get_doc[] = "xxx";
/*****************************************************************************/
/* Python method structure definition for Blender.Wave module: */
/*****************************************************************************/
struct PyMethodDef M_Wave_methods[] = {
- {"New",(PyCFunction)M_Wave_New, METH_VARARGS,M_Wave_New_doc},
- {"Get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
- {"get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_Wave_New, METH_VARARGS, M_Wave_New_doc},
+ {"Get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
+ {"get", M_Wave_Get, METH_VARARGS, M_Wave_Get_doc},
+ {NULL, NULL, 0, NULL}
};
@@ -161,416 +160,440 @@ struct PyMethodDef M_Wave_methods[] = {
/* Function: M_Wave_New */
/* Python equivalent: Blender.Effect.Wave.New */
/*****************************************************************************/
-PyObject *M_Wave_New(PyObject *self, PyObject *args)
+PyObject *M_Wave_New( PyObject * self, PyObject * args )
{
-int type = EFF_WAVE;
- BPy_Effect *pyeffect;
- Effect *bleffect = 0;
-
- bleffect = add_effect(type);
- if (bleffect == NULL)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Effect Data in Blender"));
+ int type = EFF_WAVE;
+ BPy_Effect *pyeffect;
+ Effect *bleffect = 0;
+
+ bleffect = add_effect( type );
+ if( bleffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Effect Data in Blender" ) );
+
+ pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
- pyeffect = (BPy_Effect *)PyObject_NEW(BPy_Effect, &Effect_Type);
-
- if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Effect Data object"));
+ if( pyeffect == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Effect Data object" ) );
- pyeffect->effect = bleffect;
+ pyeffect->effect = bleffect;
- return (PyObject *)pyeffect;
- return 0;
+ return ( PyObject * ) pyeffect;
+ return 0;
}
/*****************************************************************************/
/* Function: M_Wave_Get */
/* Python equivalent: Blender.Effect.Wave.Get */
/*****************************************************************************/
-PyObject *M_Wave_Get(PyObject *self, PyObject *args)
+PyObject *M_Wave_Get( PyObject * self, PyObject * args )
{
- /*arguments : string object name
- int : position of effect in the obj's effect list */
- char *name = 0;
- Object *object_iter;
- Effect *eff;
- BPy_Wave *wanted_eff;
- int num,i;
-
- if (!PyArg_ParseTuple(args, "si", &name, &num ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected string int argument"));
-
- object_iter = G.main->object.first;
- if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "Scene contains no object"));
-
- while (object_iter)
- {
- if (strcmp(name,object_iter->id.name+2))
- {
- object_iter = object_iter->id.next;
- continue;
+ /*arguments : string object name
+ int : position of effect in the obj's effect list */
+ char *name = 0;
+ Object *object_iter;
+ Effect *eff;
+ BPy_Wave *wanted_eff;
+ int num, i;
+
+ if( !PyArg_ParseTuple( args, "si", &name, &num ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string int argument" ) );
+
+ object_iter = G.main->object.first;
+ if( !object_iter )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Scene contains no object" ) );
+
+ while( object_iter ) {
+ if( strcmp( name, object_iter->id.name + 2 ) ) {
+ object_iter = object_iter->id.next;
+ continue;
+ }
+
+
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ for( i = 0; i < num; i++ ) {
+ if( eff->type != EFF_WAVE )
+ continue;
+ eff = eff->next;
+ if( !eff )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "bject" ) );
+ }
+ wanted_eff =
+ ( BPy_Wave * ) PyObject_NEW( BPy_Wave,
+ &Wave_Type );
+ wanted_eff->wave = eff;
+ return ( PyObject * ) wanted_eff;
+ }
+ object_iter = object_iter->id.next;
}
-
-
- if (object_iter->effect.first != NULL)
- {
- eff = object_iter->effect.first;
- for(i = 0;i<num;i++)
- {
- if (eff->type != EFF_WAVE)continue;
- eff = eff->next;
- if (!eff)
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,"bject"));
- }
- wanted_eff = (BPy_Wave *)PyObject_NEW(BPy_Wave, &Wave_Type);
- wanted_eff->wave = eff;
- return (PyObject*)wanted_eff;
- }
- object_iter = object_iter->id.next;
- }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF( Py_None );
+ return Py_None;
}
/*****************************************************************************/
/* Function: Wave_Init */
/*****************************************************************************/
-PyObject *Wave_Init (void)
+PyObject *Wave_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
- Wave_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Wave",M_Wave_methods, M_Wave_doc);
- return (submodule);
+ Wave_Type.ob_type = &PyType_Type;
+ submodule =
+ Py_InitModule3( "Blender.Wave", M_Wave_methods, M_Wave_doc );
+ return ( submodule );
}
/*****************************************************************************/
-/* Python BPy_Wave methods: */
+/* Python BPy_Wave methods: */
/*****************************************************************************/
-PyObject *Wave_getStartx(BPy_Wave *self)
+PyObject *Wave_getStartx( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->startx);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->startx );
}
-PyObject *Wave_setStartx(BPy_Wave *self,PyObject *args)
-{
- WaveEff*ptr = (WaveEff*)self->wave;
- float val = 0;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->startx = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setStartx( BPy_Wave * self, PyObject * args )
+{
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->startx = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getStarty(BPy_Wave *self)
+PyObject *Wave_getStarty( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->starty);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->starty );
}
-PyObject *Wave_setStarty(BPy_Wave *self,PyObject *args)
-{
- WaveEff*ptr = (WaveEff*)self->wave;
- float val = 0;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->starty = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setStarty( BPy_Wave * self, PyObject * args )
+{
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->starty = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getHeight(BPy_Wave *self)
+PyObject *Wave_getHeight( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->height);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->height );
}
-PyObject *Wave_setHeight(BPy_Wave *self,PyObject *args)
-{
- WaveEff*ptr = (WaveEff*)self->wave;
- float val = 0;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr->height = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setHeight( BPy_Wave * self, PyObject * args )
+{
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr->height = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getWidth(BPy_Wave *self)
+PyObject *Wave_getWidth( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->width);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->width );
}
-PyObject *Wave_setWidth(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->width = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setWidth( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->width = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getNarrow(BPy_Wave *self)
+PyObject *Wave_getNarrow( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->narrow);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->narrow );
}
-PyObject *Wave_setNarrow(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->narrow = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setNarrow( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->narrow = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getSpeed(BPy_Wave *self)
+PyObject *Wave_getSpeed( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->speed);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->speed );
}
-PyObject *Wave_setSpeed(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->speed = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setSpeed( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->speed = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getMinfac(BPy_Wave *self)
+PyObject *Wave_getMinfac( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->minfac);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->minfac );
}
-PyObject *Wave_setMinfac(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->minfac = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setMinfac( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->minfac = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getDamp(BPy_Wave *self)
+PyObject *Wave_getDamp( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->damp);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->damp );
}
-PyObject *Wave_setDamp(BPy_Wave *self,PyObject *args)
-{
- WaveEff*ptr;
- float val = 0;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->damp = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setDamp( BPy_Wave * self, PyObject * args )
+{
+ WaveEff *ptr;
+ float val = 0;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->damp = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getTimeoffs(BPy_Wave *self)
+PyObject *Wave_getTimeoffs( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->timeoffs);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->timeoffs );
}
-PyObject *Wave_setTimeoffs(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->timeoffs = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setTimeoffs( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->timeoffs = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-PyObject *Wave_getLifetime(BPy_Wave *self)
+PyObject *Wave_getLifetime( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- return PyFloat_FromDouble(ptr->lifetime);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ return PyFloat_FromDouble( ptr->lifetime );
}
-PyObject *Wave_setLifetime(BPy_Wave *self,PyObject *args)
-{
- float val = 0;
- WaveEff*ptr;
-if (!PyArg_ParseTuple(args, "f", &val ))
- return(EXPP_ReturnPyObjError(PyExc_AttributeError,\
- "expected float argument"));
- ptr = (WaveEff*)self->wave;
- ptr->lifetime = val;
- Py_INCREF(Py_None);
- return Py_None;
+PyObject *Wave_setLifetime( BPy_Wave * self, PyObject * args )
+{
+ float val = 0;
+ WaveEff *ptr;
+ if( !PyArg_ParseTuple( args, "f", &val ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected float argument" ) );
+ ptr = ( WaveEff * ) self->wave;
+ ptr->lifetime = val;
+ Py_INCREF( Py_None );
+ return Py_None;
}
+
/*****************************************************************************/
/* Function: WaveDeAlloc */
-/* Description: This is a callback function for the BPy_Wave type. It is */
+/* Description: This is a callback function for the BPy_Wave type. It is */
/* the destructor function. */
/*****************************************************************************/
-void WaveDeAlloc (BPy_Wave *self)
+void WaveDeAlloc( BPy_Wave * self )
{
- WaveEff*ptr = (WaveEff*)self->wave;
- PyObject_DEL (ptr);
+ WaveEff *ptr = ( WaveEff * ) self->wave;
+ PyObject_DEL( ptr );
}
/*****************************************************************************/
/* Function: WaveGetAttr */
-/* Description: This is a callback function for the BPy_Wave type. It is */
-/* the function that accesses BPy_Wave "member variables" and */
+/* Description: This is a callback function for the BPy_Wave type. It is */
+/* the function that accesses BPy_Wave "member variables" and */
/* methods. */
/*****************************************************************************/
-PyObject *WaveGetAttr (BPy_Wave *self, char *name)
+PyObject *WaveGetAttr( BPy_Wave * self, char *name )
{
- if (!strcmp(name,"lifetime"))return Wave_getLifetime( self);
- else if (!strcmp(name,"timeoffs"))return Wave_getTimeoffs( self);
- else if (!strcmp(name,"damp"))return Wave_getDamp( self);
- else if (!strcmp(name,"minfac"))return Wave_getMinfac( self);
- else if (!strcmp(name,"speed"))return Wave_getSpeed( self);
- else if (!strcmp(name,"narrow"))return Wave_getNarrow( self);
- else if (!strcmp(name,"width"))return Wave_getWidth( self);
- else if (!strcmp(name,"height"))return Wave_getHeight( self);
- else if (!strcmp(name,"startx"))return Wave_getStartx( self);
- else if (!strcmp(name,"starty"))return Wave_getStarty( self);
- return Py_FindMethod(BPy_Wave_methods, (PyObject *)self, name);
+ if( !strcmp( name, "lifetime" ) )
+ return Wave_getLifetime( self );
+ else if( !strcmp( name, "timeoffs" ) )
+ return Wave_getTimeoffs( self );
+ else if( !strcmp( name, "damp" ) )
+ return Wave_getDamp( self );
+ else if( !strcmp( name, "minfac" ) )
+ return Wave_getMinfac( self );
+ else if( !strcmp( name, "speed" ) )
+ return Wave_getSpeed( self );
+ else if( !strcmp( name, "narrow" ) )
+ return Wave_getNarrow( self );
+ else if( !strcmp( name, "width" ) )
+ return Wave_getWidth( self );
+ else if( !strcmp( name, "height" ) )
+ return Wave_getHeight( self );
+ else if( !strcmp( name, "startx" ) )
+ return Wave_getStartx( self );
+ else if( !strcmp( name, "starty" ) )
+ return Wave_getStarty( self );
+ return Py_FindMethod( BPy_Wave_methods, ( PyObject * ) self, name );
}
/*****************************************************************************/
/* Function: WaveSetAttr */
-/* Description: This is a callback function for the BPy_Wave type. It is the */
+/* Description: This is a callback function for the BPy_Wave type. It is the */
/* function that sets Wave Data attributes (member variables). */
/*****************************************************************************/
-int WaveSetAttr (BPy_Wave *self, char *name, PyObject *value)
+int WaveSetAttr( BPy_Wave * self, char *name, PyObject * value )
{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- valtuple = Py_BuildValue("(N)", value);
-
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "ParticleSetAttr: couldn't create PyTuple");
-
- if (!strcmp(name,"lifetime"))error = Wave_setLifetime( self,valtuple);
- else if (!strcmp(name,"timeoffs"))error = Wave_setTimeoffs( self,valtuple);
- else if (!strcmp(name,"damp")) error = Wave_setDamp( self,valtuple);
- else if (!strcmp(name,"minfac")) error = Wave_setMinfac( self,valtuple);
- else if (!strcmp(name,"speed")) error = Wave_setSpeed( self,valtuple);
- else if (!strcmp(name,"narrow")) error = Wave_setNarrow( self,valtuple);
- else if (!strcmp(name,"width")) error = Wave_setWidth( self,valtuple);
- else if (!strcmp(name,"height")) error = Wave_setHeight( self,valtuple);
- else if (!strcmp(name,"startx")) error = Wave_setStartx( self,valtuple);
- else if (!strcmp(name,"starty")) error = Wave_setStarty( self,valtuple);
-
-
- else {
- Py_DECREF(valtuple);
-
- if ((strcmp (name, "Types") == 0) ||
- (strcmp (name, "Modes") == 0))
- return (EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed"));
-
- else
- return (EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found"));
- }
+ PyObject *valtuple;
+ PyObject *error = NULL;
+
+ valtuple = Py_BuildValue( "(N)", value );
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "ParticleSetAttr: couldn't create PyTuple" );
+
+ if( !strcmp( name, "lifetime" ) )
+ error = Wave_setLifetime( self, valtuple );
+ else if( !strcmp( name, "timeoffs" ) )
+ error = Wave_setTimeoffs( self, valtuple );
+ else if( !strcmp( name, "damp" ) )
+ error = Wave_setDamp( self, valtuple );
+ else if( !strcmp( name, "minfac" ) )
+ error = Wave_setMinfac( self, valtuple );
+ else if( !strcmp( name, "speed" ) )
+ error = Wave_setSpeed( self, valtuple );
+ else if( !strcmp( name, "narrow" ) )
+ error = Wave_setNarrow( self, valtuple );
+ else if( !strcmp( name, "width" ) )
+ error = Wave_setWidth( self, valtuple );
+ else if( !strcmp( name, "height" ) )
+ error = Wave_setHeight( self, valtuple );
+ else if( !strcmp( name, "startx" ) )
+ error = Wave_setStartx( self, valtuple );
+ else if( !strcmp( name, "starty" ) )
+ error = Wave_setStarty( self, valtuple );
+
+
+ else {
+ Py_DECREF( valtuple );
+
+ if( ( strcmp( name, "Types" ) == 0 ) ||
+ ( strcmp( name, "Modes" ) == 0 ) )
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "constant dictionary -- cannot be changed" ) );
+
+ else
+ return ( EXPP_ReturnIntError( PyExc_KeyError,
+ "attribute not found" ) );
+ }
- /*Py_DECREF(valtuple);*/
+ /*Py_DECREF(valtuple); */
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF(Py_None);
- return 0;
+ Py_DECREF( Py_None );
+ return 0;
}
/*****************************************************************************/
/* Function: WavePrint */
-/* Description: This is a callback function for the BPy_Wave type. It */
+/* Description: This is a callback function for the BPy_Wave type. It */
/* builds a meaninful string to 'print' wave objects. */
/*****************************************************************************/
-int WavePrint(BPy_Wave *self, FILE *fp, int flags)
-{
+int WavePrint( BPy_Wave * self, FILE * fp, int flags )
+{
- printf("I'm a wave...Cool, no?");
- return 0;
+ printf( "I'm a wave...Cool, no?" );
+ return 0;
}
/*****************************************************************************/
/* Function: WaveRepr */
-/* Description: This is a callback function for the BPy_Wave type. It */
+/* Description: This is a callback function for the BPy_Wave type. It */
/* builds a meaninful string to represent wave objects. */
/*****************************************************************************/
-PyObject *WaveRepr (BPy_Wave *self)
+PyObject *WaveRepr( BPy_Wave * self )
{
- return 0;
+ return 0;
}
-PyObject* WaveCreatePyObject (struct Effect *wave)
+PyObject *WaveCreatePyObject( struct Effect * wave )
{
- BPy_Wave * blen_object;
+ BPy_Wave *blen_object;
- blen_object = (BPy_Wave*)PyObject_NEW (BPy_Wave, &Wave_Type);
+ blen_object = ( BPy_Wave * ) PyObject_NEW( BPy_Wave, &Wave_Type );
- if (blen_object == NULL)
- {
- return (NULL);
- }
- blen_object->wave = wave;
- return ((PyObject*)blen_object);
+ if( blen_object == NULL ) {
+ return ( NULL );
+ }
+ blen_object->wave = wave;
+ return ( ( PyObject * ) blen_object );
}
-int WaveCheckPyObject (PyObject *py_obj)
+int WaveCheckPyObject( PyObject * py_obj )
{
-return (py_obj->ob_type == &Wave_Type);
+ return ( py_obj->ob_type == &Wave_Type );
}
-struct Wave* WaveFromPyObject (PyObject *py_obj)
+struct Wave *WaveFromPyObject( PyObject * py_obj )
{
- BPy_Wave * blen_obj;
+ BPy_Wave *blen_obj;
- blen_obj = (BPy_Wave*)py_obj;
- return ((struct Wave*)blen_obj->wave);
+ blen_obj = ( BPy_Wave * ) py_obj;
+ return ( ( struct Wave * ) blen_obj->wave );
}
-
diff --git a/source/blender/python/api2_2x/Wave.h b/source/blender/python/api2_2x/Wave.h
index 1544088535d..2fb5810ba47 100644
--- a/source/blender/python/api2_2x/Wave.h
+++ b/source/blender/python/api2_2x/Wave.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -48,50 +49,50 @@
/*****************************************************************************/
/* Python API function prototypes for the Wave module. */
/*****************************************************************************/
-PyObject *M_Wave_New (PyObject *self, PyObject *args);
-PyObject *M_Wave_Get (PyObject *self, PyObject *args);
+PyObject *M_Wave_New( PyObject * self, PyObject * args );
+PyObject *M_Wave_Get( PyObject * self, PyObject * args );
#include"Effect.h"
/*****************************************************************************/
-/* Python BPy_Wave methods declarations: */
+/* Python BPy_Wave methods declarations: */
/*****************************************************************************/
-PyObject *Effect_getType(BPy_Effect *self);
-PyObject *Effect_setType(BPy_Effect *self, PyObject *args);
-PyObject *Effect_getFlag(BPy_Effect *self);
-PyObject *Effect_setFlag(BPy_Effect *self, PyObject *args);
-PyObject *Wave_getStartx(BPy_Wave *self);
-PyObject *Wave_setStartx(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getStarty(BPy_Wave *self);
-PyObject *Wave_setStarty(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getHeight(BPy_Wave *self);
-PyObject *Wave_setHeight(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getWidth(BPy_Wave *self);
-PyObject *Wave_setWidth(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getNarrow(BPy_Wave *self);
-PyObject *Wave_setNarrow(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getSpeed(BPy_Wave *self);
-PyObject *Wave_setSpeed(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getMinfac(BPy_Wave *self);
-PyObject *Wave_setMinfac(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getDamp(BPy_Wave *self);
-PyObject *Wave_setDamp(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getTimeoffs(BPy_Wave *self);
-PyObject *Wave_setTimeoffs(BPy_Wave *self,PyObject*a);
-PyObject *Wave_getLifetime(BPy_Wave *self);
-PyObject *Wave_setLifetime(BPy_Wave *self,PyObject*a);
+PyObject *Effect_getType( BPy_Effect * self );
+PyObject *Effect_setType( BPy_Effect * self, PyObject * args );
+PyObject *Effect_getFlag( BPy_Effect * self );
+PyObject *Effect_setFlag( BPy_Effect * self, PyObject * args );
+PyObject *Wave_getStartx( BPy_Wave * self );
+PyObject *Wave_setStartx( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getStarty( BPy_Wave * self );
+PyObject *Wave_setStarty( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getHeight( BPy_Wave * self );
+PyObject *Wave_setHeight( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getWidth( BPy_Wave * self );
+PyObject *Wave_setWidth( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getNarrow( BPy_Wave * self );
+PyObject *Wave_setNarrow( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getSpeed( BPy_Wave * self );
+PyObject *Wave_setSpeed( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getMinfac( BPy_Wave * self );
+PyObject *Wave_setMinfac( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getDamp( BPy_Wave * self );
+PyObject *Wave_setDamp( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getTimeoffs( BPy_Wave * self );
+PyObject *Wave_setTimeoffs( BPy_Wave * self, PyObject * a );
+PyObject *Wave_getLifetime( BPy_Wave * self );
+PyObject *Wave_setLifetime( BPy_Wave * self, PyObject * a );
/*****************************************************************************/
/* Python Wave_Type callback function prototypes: */
/*****************************************************************************/
-void WaveDeAlloc (BPy_Wave *msh);
-int WavePrint (BPy_Wave *msh, FILE *fp, int flags);
-int WaveSetAttr (BPy_Wave *msh, char *name, PyObject *v);
-PyObject *WaveGetAttr (BPy_Wave *msh, char *name);
-PyObject *WaveRepr (BPy_Wave *msh);
-PyObject* WaveCreatePyObject (struct Effect *wave);
-int WaveCheckPyObject (PyObject *py_obj);
-struct Wave* WaveFromPyObject (PyObject *py_obj);
+void WaveDeAlloc( BPy_Wave * msh );
+int WavePrint( BPy_Wave * msh, FILE * fp, int flags );
+int WaveSetAttr( BPy_Wave * msh, char *name, PyObject * v );
+PyObject *WaveGetAttr( BPy_Wave * msh, char *name );
+PyObject *WaveRepr( BPy_Wave * msh );
+PyObject *WaveCreatePyObject( struct Effect *wave );
+int WaveCheckPyObject( PyObject * py_obj );
+struct Wave *WaveFromPyObject( PyObject * py_obj );
-#endif /* EXPP_WAVE_H */
+#endif /* EXPP_WAVE_H */
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
index 90ac7ecec41..85dbbadcebd 100644
--- a/source/blender/python/api2_2x/Window.c
+++ b/source/blender/python/api2_2x/Window.c
@@ -33,17 +33,17 @@
#include <Python.h>
#include <stdio.h>
-#include <blendef.h> /* OBACT */
-#include <BDR_editobject.h> /* enter / leave editmode */
+#include <blendef.h> /* OBACT */
+#include <BDR_editobject.h> /* enter / leave editmode */
#include <BKE_global.h>
#include <BKE_library.h>
-#include <BKE_object.h> /* for during_script() */
-#include <BKE_scene.h> /* scene_find_camera() */
+#include <BKE_object.h> /* for during_script() */
+#include <BKE_scene.h> /* scene_find_camera() */
#include <BIF_usiblender.h>
#include <BIF_mywindow.h>
#include <BSE_headerbuttons.h>
#include <BSE_filesel.h>
-#include <BIF_editmesh.h> /* for undo_push_mesh() */
+#include <BIF_editmesh.h> /* for undo_push_mesh() */
#include <BIF_screen.h>
#include <BIF_space.h>
#include <BIF_drawtext.h>
@@ -53,7 +53,7 @@
#include <DNA_screen_types.h>
#include <DNA_space_types.h>
#include <DNA_text_types.h>
-#include <DNA_vec_types.h> /* for rcti struct */
+#include <DNA_vec_types.h> /* for rcti struct */
#include "gen_utils.h"
#include "modules.h"
@@ -66,65 +66,63 @@
extern int EXPP_disable_force_draw;
/* Callback used by the file and image selector access functions */
-static PyObject *(*EXPP_FS_PyCallback)(PyObject *arg) = NULL;
+static PyObject *( *EXPP_FS_PyCallback ) ( PyObject * arg ) = NULL;
/*****************************************************************************/
-/* Python API function prototypes for the Window module. */
+/* Python API function prototypes for the Window module. */
/*****************************************************************************/
-PyObject *M_Window_Redraw (PyObject *self, PyObject *args);
-static PyObject *M_Window_RedrawAll (PyObject *self, PyObject *args);
-static PyObject *M_Window_QRedrawAll (PyObject *self, PyObject *args);
-static PyObject *M_Window_DrawProgressBar (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetCursorPos (PyObject *self);
-static PyObject *M_Window_SetCursorPos (PyObject *self, PyObject *args);
-static PyObject *M_Window_WaitCursor (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetViewVector (PyObject *self);
-static PyObject *M_Window_GetViewQuat (PyObject *self);
-static PyObject *M_Window_SetViewQuat (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetViewOffset (PyObject *self);
-static PyObject *M_Window_SetViewOffset (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetViewMatrix (PyObject *self);
-static PyObject *M_Window_FileSelector (PyObject *self, PyObject *args);
-static PyObject *M_Window_ImageSelector (PyObject *self, PyObject *args);
-static PyObject *M_Window_EditMode (PyObject *self, PyObject *args);
-static PyObject *M_Window_ViewLayer (PyObject *self, PyObject *args);
-static PyObject *M_Window_CameraView (PyObject *self, PyObject *args);
-static PyObject *M_Window_QTest (PyObject *self);
-static PyObject *M_Window_QRead (PyObject *self);
-static PyObject *M_Window_QAdd (PyObject *self, PyObject *args);
-static PyObject *M_Window_QHandle (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetMouseCoords (PyObject *self);
-static PyObject *M_Window_SetMouseCoords (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetMouseButtons (PyObject *self);
-static PyObject *M_Window_GetKeyQualifiers (PyObject *self);
-static PyObject *M_Window_SetKeyQualifiers (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetAreaSize (PyObject *self);
-static PyObject *M_Window_GetAreaID (PyObject *self);
-static PyObject *M_Window_GetScreenSize (PyObject *self);
-static PyObject *M_Window_GetScreens (PyObject *self);
-static PyObject *M_Window_SetScreen (PyObject *self, PyObject *args);
-static PyObject *M_Window_GetScreenInfo (PyObject *self, PyObject *args,
- PyObject *kwords);
+PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
+static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args );
+static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args );
+static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetCursorPos( PyObject * self );
+static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args );
+static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetViewVector( PyObject * self );
+static PyObject *M_Window_GetViewQuat( PyObject * self );
+static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetViewOffset( PyObject * self );
+static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetViewMatrix( PyObject * self );
+static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args );
+static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args );
+static PyObject *M_Window_EditMode( PyObject * self, PyObject * args );
+static PyObject *M_Window_ViewLayer( PyObject * self, PyObject * args );
+static PyObject *M_Window_CameraView( PyObject * self, PyObject * args );
+static PyObject *M_Window_QTest( PyObject * self );
+static PyObject *M_Window_QRead( PyObject * self );
+static PyObject *M_Window_QAdd( PyObject * self, PyObject * args );
+static PyObject *M_Window_QHandle( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetMouseCoords( PyObject * self );
+static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetMouseButtons( PyObject * self );
+static PyObject *M_Window_GetKeyQualifiers( PyObject * self );
+static PyObject *M_Window_SetKeyQualifiers( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetAreaSize( PyObject * self );
+static PyObject *M_Window_GetAreaID( PyObject * self );
+static PyObject *M_Window_GetScreenSize( PyObject * self );
+static PyObject *M_Window_GetScreens( PyObject * self );
+static PyObject *M_Window_SetScreen( PyObject * self, PyObject * args );
+static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args,
+ PyObject * kwords );
/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Window.__doc__ */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Window.__doc__ */
/*****************************************************************************/
-static char M_Window_doc[] =
-"The Blender Window module\n\n";
+static char M_Window_doc[] = "The Blender Window module\n\n";
static char M_Window_Redraw_doc[] =
-"() - Force a redraw of a specific Window Type (see Window.Types)";
+ "() - Force a redraw of a specific Window Type (see Window.Types)";
-static char M_Window_RedrawAll_doc[] =
-"() - Redraw all windows";
+static char M_Window_RedrawAll_doc[] = "() - Redraw all windows";
static char M_Window_QRedrawAll_doc[] =
-"() - Redraw all windows by queue event";
+ "() - Redraw all windows by queue event";
static char M_Window_FileSelector_doc[] =
-"(callback [, title, filename]) - Open a file selector window.\n\
+ "(callback [, title, filename]) - Open a file selector window.\n\
The selected file name is used as argument to a function callback f(name)\n\
that you must provide. 'title' is optional and defaults to 'SELECT FILE'.\n\
'filename' is optional and defaults to Blender.Get('filename').\n\n\
@@ -135,7 +133,7 @@ def my_function(filename):\n\
Blender.Window.FileSelector(my_function, 'SAVE FILE')\n";
static char M_Window_ImageSelector_doc[] =
-"(callback [, title, filename]) - Open an image selector window.\n\
+ "(callback [, title, filename]) - Open an image selector window.\n\
The selected file name is used as argument to a function callback f(name)\n\
that you must provide. 'title' is optional and defaults to 'SELECT IMAGE'.\n\
'filename' is optional and defaults to Blender.Get('filename').\n\n\
@@ -146,117 +144,117 @@ def my_function(filename):\n\
Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
static char M_Window_DrawProgressBar_doc[] =
-"(done, text) - Draw a progress bar.\n\
+ "(done, text) - Draw a progress bar.\n\
'done' is a float value <= 1.0, 'text' contains info about what is\n\
currently being done.";
static char M_Window_GetCursorPos_doc[] =
-"() - Get the current 3d cursor position as a list of three floats.";
+ "() - Get the current 3d cursor position as a list of three floats.";
static char M_Window_SetCursorPos_doc[] =
-"([f,f,f]) - Set the current 3d cursor position from a list of three floats.";
+ "([f,f,f]) - Set the current 3d cursor position from a list of three floats.";
static char M_Window_WaitCursor_doc[] =
-"(bool) - Set cursor to wait mode (nonzero bool) or normal mode (0).";
+ "(bool) - Set cursor to wait mode (nonzero bool) or normal mode (0).";
static char M_Window_GetViewVector_doc[] =
-"() - Get the current 3d view vector as a list of three floats [x,y,z].";
+ "() - Get the current 3d view vector as a list of three floats [x,y,z].";
static char M_Window_GetViewMatrix_doc[] =
-"() - Get the current 3d view matrix.";
+ "() - Get the current 3d view matrix.";
static char M_Window_EditMode_doc[] =
-"() - Get the current status -- 0: not in edit mode; 1: in edit mode.\n\
+ "() - Get the current status -- 0: not in edit mode; 1: in edit mode.\n\
(status) - if 1: enter edit mode; if 0: leave edit mode.\n\
Returns the current status. This function is mostly useful to leave\n\
edit mode before applying changes to a mesh (otherwise the changes will\n\
be lost) and then returning to it upon leaving.";
static char M_Window_ViewLayer_doc[] =
-"(layers = []) - Get/set active layers in all 3d View windows.\n\
+ "(layers = []) - Get/set active layers in all 3d View windows.\n\
() - Make no changes, only return currently visible layers.\n\
(layers = []) - a list of integers, each in the range [1, 20].\n\
This function returns the currently visible layers as a list of ints.";
static char M_Window_GetViewQuat_doc[] =
-"() - Get the current VIEW3D view quaternion values.";
+ "() - Get the current VIEW3D view quaternion values.";
static char M_Window_SetViewQuat_doc[] =
-"(quat) - Set the current VIEW3D view quaternion values.\n\
+ "(quat) - Set the current VIEW3D view quaternion values.\n\
(quat) - [f,f,f,f] or f,f,f,f: the new float values.";
static char M_Window_GetViewOffset_doc[] =
-"() - Get the current VIEW3D view offset values.";
+ "() - Get the current VIEW3D view offset values.";
static char M_Window_SetViewOffset_doc[] =
-"(ofs) - Set the current VIEW3D view offset values.\n\
+ "(ofs) - Set the current VIEW3D view offset values.\n\
(ofs) - [f,f,f] or f,f,f: the new float values.";
static char M_Window_CameraView_doc[] =
-"(camtov3d = 0) - Set the current VIEW3D view to the active camera's view.\n\
+ "(camtov3d = 0) - Set the current VIEW3D view to the active camera's view.\n\
(camtov3d = 0) - bool: if nonzero it's the camera that gets positioned at the\n\
current view, instead of the view being changed to that of the camera.\n\n\
If no camera is the active object, the active camera for the current scene\n\
is used.";
static char M_Window_QTest_doc[] =
-"() - Check if there are pending events in the event queue.";
+ "() - Check if there are pending events in the event queue.";
static char M_Window_QRead_doc[] =
-"() - Get the next pending event from the event queue.\n\
+ "() - Get the next pending event from the event queue.\n\
This function returns a list [event, val], where:\n\
event - int: the key or mouse event (see Blender.Draw module);\n\
val - int: if 1 it's a key or mouse button press, if 0 a release. For\n\
mouse movement events 'val' returns the new coordinates in x or y.";
static char M_Window_QAdd_doc[] =
-"(win, evt, val, after = 0) - Add an event to some window's event queue.\n\
+ "(win, evt, val, after = 0) - Add an event to some window's event queue.\n\
(win) - int: the win id, see Blender.Window.GetScreenInfo();\n\
(evt) - int: the event number, see events in Blender.Draw;\n\
(val) - bool: 1 for a key press, 0 for a release;\n\
(after) - bool: if 1 the event is put after the current queue and added later.";
static char M_Window_QHandle_doc[] =
-"(win) - Process all events for the given window (area) now.\n\
+ "(win) - Process all events for the given window (area) now.\n\
(win) - int: the window id, see Blender.Window.GetScreenInfo().\n\n\
See Blender.Window.QAdd() for how to send events to a particular window.";
static char M_Window_GetMouseCoords_doc[] =
-"() - Get mouse pointer's current screen coordinates.";
+ "() - Get mouse pointer's current screen coordinates.";
static char M_Window_SetMouseCoords_doc[] =
-"(x, y) - Set mouse pointer's current screen coordinates.\n\
+ "(x, y) - Set mouse pointer's current screen coordinates.\n\
(x,y) - ints ([x, y] also accepted): the new x, y coordinates.";
static char M_Window_GetMouseButtons_doc[] =
-"() - Get the current mouse button state (see Blender.Draw.LEFTMOUSE, etc).";
+ "() - Get the current mouse button state (see Blender.Draw.LEFTMOUSE, etc).";
static char M_Window_GetKeyQualifiers_doc[] =
-"() - Get the current qualifier keys state.\n\
+ "() - Get the current qualifier keys state.\n\
An int is returned: or'ed combination of values in Blender.Window.Qual's dict.";
static char M_Window_SetKeyQualifiers_doc[] =
-"(qual) - Fake qualifier keys state.\n\
+ "(qual) - Fake qualifier keys state.\n\
(qual) - int: an or'ed combination of the values in Blender.Window.Qual dict.\n\
Note: remember to reset to 0 after handling the related event (see QAdd()).";
static char M_Window_GetAreaID_doc[] =
-"() - Get the current window's (area) ID.";
+ "() - Get the current window's (area) ID.";
static char M_Window_GetAreaSize_doc[] =
-"() - Get the current window's (area) size as [width, height].";
+ "() - Get the current window's (area) size as [width, height].";
static char M_Window_GetScreenSize_doc[] =
-"() - Get the screen's size as [width, height].";
+ "() - Get the screen's size as [width, height].";
static char M_Window_GetScreens_doc[] =
-"() - Get a list with the names of all available screens.";
+ "() - Get a list with the names of all available screens.";
static char M_Window_SetScreen_doc[] =
-"(name) - Set current screen to the one with the given 'name'.";
+ "(name) - Set current screen to the one with the given 'name'.";
static char M_Window_GetScreenInfo_doc[] =
-"(type = -1, rect = 'win', screen = None)\n\
+ "(type = -1, rect = 'win', screen = None)\n\
- Get info about the the areas in the current screen setup.\n\
(type = -1) - int: the space type (Blender.Window.Types) to restrict the\n\
results to, all if -1;\n\
@@ -273,180 +271,190 @@ Each dictionary has keys:\n\
'id': area's id.";
/*****************************************************************************/
-/* Python method structure definition for Blender.Window module: */
+/* Python method structure definition for Blender.Window module: */
/*****************************************************************************/
struct PyMethodDef M_Window_methods[] = {
- {"Redraw", M_Window_Redraw, METH_VARARGS, M_Window_Redraw_doc},
- {"RedrawAll", M_Window_RedrawAll, METH_VARARGS, M_Window_RedrawAll_doc},
- {"QRedrawAll", M_Window_QRedrawAll, METH_VARARGS, M_Window_QRedrawAll_doc},
+ {"Redraw", M_Window_Redraw, METH_VARARGS, M_Window_Redraw_doc},
+ {"RedrawAll", M_Window_RedrawAll, METH_VARARGS,
+ M_Window_RedrawAll_doc},
+ {"QRedrawAll", M_Window_QRedrawAll, METH_VARARGS,
+ M_Window_QRedrawAll_doc},
{"FileSelector", M_Window_FileSelector, METH_VARARGS,
- M_Window_FileSelector_doc},
- {"ImageSelector", (PyCFunction)M_Window_ImageSelector, METH_VARARGS,
- M_Window_ImageSelector_doc},
- {"DrawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
- M_Window_DrawProgressBar_doc},
- {"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
- M_Window_DrawProgressBar_doc},
- {"GetCursorPos", (PyCFunction)M_Window_GetCursorPos, METH_NOARGS,
- M_Window_GetCursorPos_doc},
- {"SetCursorPos", M_Window_SetCursorPos, METH_VARARGS,
- M_Window_SetCursorPos_doc},
- {"WaitCursor", M_Window_WaitCursor, METH_VARARGS,
- M_Window_WaitCursor_doc},
- {"GetViewVector", (PyCFunction)M_Window_GetViewVector, METH_NOARGS,
- M_Window_GetViewVector_doc},
- {"GetViewQuat", (PyCFunction)M_Window_GetViewQuat, METH_NOARGS,
- M_Window_GetViewQuat_doc},
- {"SetViewQuat", (PyCFunction)M_Window_SetViewQuat, METH_VARARGS,
- M_Window_SetViewQuat_doc},
- {"GetViewOffset", (PyCFunction)M_Window_GetViewOffset, METH_NOARGS,
- M_Window_GetViewOffset_doc},
- {"SetViewOffset", (PyCFunction)M_Window_SetViewOffset, METH_VARARGS,
- M_Window_SetViewOffset_doc},
- {"GetViewMatrix", (PyCFunction)M_Window_GetViewMatrix, METH_NOARGS,
- M_Window_GetViewMatrix_doc},
- {"EditMode", (PyCFunction)M_Window_EditMode, METH_VARARGS,
- M_Window_EditMode_doc},
- {"ViewLayer", (PyCFunction)M_Window_ViewLayer, METH_VARARGS,
- M_Window_ViewLayer_doc},
- {"CameraView", (PyCFunction)M_Window_CameraView, METH_VARARGS,
- M_Window_CameraView_doc},
- {"QTest", (PyCFunction)M_Window_QTest, METH_NOARGS,
- M_Window_QTest_doc},
- {"QRead", (PyCFunction)M_Window_QRead, METH_NOARGS,
- M_Window_QRead_doc},
- {"QAdd", (PyCFunction)M_Window_QAdd, METH_VARARGS,
- M_Window_QAdd_doc},
- {"QHandle", (PyCFunction)M_Window_QHandle, METH_VARARGS,
- M_Window_QHandle_doc},
- {"GetMouseCoords", (PyCFunction)M_Window_GetMouseCoords, METH_NOARGS,
- M_Window_GetMouseCoords_doc},
- {"SetMouseCoords", (PyCFunction)M_Window_SetMouseCoords, METH_VARARGS,
- M_Window_SetMouseCoords_doc},
- {"GetMouseButtons", (PyCFunction)M_Window_GetMouseButtons, METH_NOARGS,
- M_Window_GetMouseButtons_doc},
- {"GetKeyQualifiers", (PyCFunction)M_Window_GetKeyQualifiers, METH_NOARGS,
- M_Window_GetKeyQualifiers_doc},
- {"SetKeyQualifiers", (PyCFunction)M_Window_SetKeyQualifiers, METH_VARARGS,
- M_Window_SetKeyQualifiers_doc},
- {"GetAreaSize", (PyCFunction)M_Window_GetAreaSize, METH_NOARGS,
- M_Window_GetAreaSize_doc},
- {"GetAreaID", (PyCFunction)M_Window_GetAreaID, METH_NOARGS,
- M_Window_GetAreaID_doc},
- {"GetScreenSize", (PyCFunction)M_Window_GetScreenSize, METH_NOARGS,
- M_Window_GetScreenSize_doc},
- {"GetScreens", (PyCFunction)M_Window_GetScreens, METH_NOARGS,
- M_Window_GetScreens_doc},
- {"SetScreen", (PyCFunction)M_Window_SetScreen, METH_VARARGS,
- M_Window_SetScreen_doc},
- {"GetScreenInfo", (PyCFunction)M_Window_GetScreenInfo,
- METH_VARARGS | METH_KEYWORDS, M_Window_GetScreenInfo_doc},
+ M_Window_FileSelector_doc},
+ {"ImageSelector", ( PyCFunction ) M_Window_ImageSelector, METH_VARARGS,
+ M_Window_ImageSelector_doc},
+ {"DrawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
+ M_Window_DrawProgressBar_doc},
+ {"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
+ M_Window_DrawProgressBar_doc},
+ {"GetCursorPos", ( PyCFunction ) M_Window_GetCursorPos, METH_NOARGS,
+ M_Window_GetCursorPos_doc},
+ {"SetCursorPos", M_Window_SetCursorPos, METH_VARARGS,
+ M_Window_SetCursorPos_doc},
+ {"WaitCursor", M_Window_WaitCursor, METH_VARARGS,
+ M_Window_WaitCursor_doc},
+ {"GetViewVector", ( PyCFunction ) M_Window_GetViewVector, METH_NOARGS,
+ M_Window_GetViewVector_doc},
+ {"GetViewQuat", ( PyCFunction ) M_Window_GetViewQuat, METH_NOARGS,
+ M_Window_GetViewQuat_doc},
+ {"SetViewQuat", ( PyCFunction ) M_Window_SetViewQuat, METH_VARARGS,
+ M_Window_SetViewQuat_doc},
+ {"GetViewOffset", ( PyCFunction ) M_Window_GetViewOffset, METH_NOARGS,
+ M_Window_GetViewOffset_doc},
+ {"SetViewOffset", ( PyCFunction ) M_Window_SetViewOffset, METH_VARARGS,
+ M_Window_SetViewOffset_doc},
+ {"GetViewMatrix", ( PyCFunction ) M_Window_GetViewMatrix, METH_NOARGS,
+ M_Window_GetViewMatrix_doc},
+ {"EditMode", ( PyCFunction ) M_Window_EditMode, METH_VARARGS,
+ M_Window_EditMode_doc},
+ {"ViewLayer", ( PyCFunction ) M_Window_ViewLayer, METH_VARARGS,
+ M_Window_ViewLayer_doc},
+ {"CameraView", ( PyCFunction ) M_Window_CameraView, METH_VARARGS,
+ M_Window_CameraView_doc},
+ {"QTest", ( PyCFunction ) M_Window_QTest, METH_NOARGS,
+ M_Window_QTest_doc},
+ {"QRead", ( PyCFunction ) M_Window_QRead, METH_NOARGS,
+ M_Window_QRead_doc},
+ {"QAdd", ( PyCFunction ) M_Window_QAdd, METH_VARARGS,
+ M_Window_QAdd_doc},
+ {"QHandle", ( PyCFunction ) M_Window_QHandle, METH_VARARGS,
+ M_Window_QHandle_doc},
+ {"GetMouseCoords", ( PyCFunction ) M_Window_GetMouseCoords,
+ METH_NOARGS,
+ M_Window_GetMouseCoords_doc},
+ {"SetMouseCoords", ( PyCFunction ) M_Window_SetMouseCoords,
+ METH_VARARGS,
+ M_Window_SetMouseCoords_doc},
+ {"GetMouseButtons", ( PyCFunction ) M_Window_GetMouseButtons,
+ METH_NOARGS,
+ M_Window_GetMouseButtons_doc},
+ {"GetKeyQualifiers", ( PyCFunction ) M_Window_GetKeyQualifiers,
+ METH_NOARGS,
+ M_Window_GetKeyQualifiers_doc},
+ {"SetKeyQualifiers", ( PyCFunction ) M_Window_SetKeyQualifiers,
+ METH_VARARGS,
+ M_Window_SetKeyQualifiers_doc},
+ {"GetAreaSize", ( PyCFunction ) M_Window_GetAreaSize, METH_NOARGS,
+ M_Window_GetAreaSize_doc},
+ {"GetAreaID", ( PyCFunction ) M_Window_GetAreaID, METH_NOARGS,
+ M_Window_GetAreaID_doc},
+ {"GetScreenSize", ( PyCFunction ) M_Window_GetScreenSize, METH_NOARGS,
+ M_Window_GetScreenSize_doc},
+ {"GetScreens", ( PyCFunction ) M_Window_GetScreens, METH_NOARGS,
+ M_Window_GetScreens_doc},
+ {"SetScreen", ( PyCFunction ) M_Window_SetScreen, METH_VARARGS,
+ M_Window_SetScreen_doc},
+ {"GetScreenInfo", ( PyCFunction ) M_Window_GetScreenInfo,
+ METH_VARARGS | METH_KEYWORDS, M_Window_GetScreenInfo_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
-/* Function: M_Window_Redraw */
-/* Python equivalent: Blender.Window.Redraw */
+/* Function: M_Window_Redraw */
+/* Python equivalent: Blender.Window.Redraw */
/*****************************************************************************/
/* not static so py_slider_update in Draw.[ch] can use it */
-PyObject *M_Window_Redraw(PyObject *self, PyObject *args)
-{
+PyObject *M_Window_Redraw( PyObject * self, PyObject * args )
+{
ScrArea *tempsa, *sa;
SpaceText *st;
int wintype = SPACE_VIEW3D;
short redraw_all = 0;
- if (!PyArg_ParseTuple(args, "|i", &wintype))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|i", &wintype ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int argument (or nothing)" ) );
- if (wintype < 0)
+ if( wintype < 0 )
redraw_all = 1;
- if (!during_script()) {
- tempsa= curarea;
+ if( !during_script( ) ) {
+ tempsa = curarea;
sa = G.curscreen->areabase.first;
- while (sa) {
+ while( sa ) {
- if (sa->spacetype == wintype || redraw_all) {
- if (sa->spacetype == SPACE_TEXT) {
+ if( sa->spacetype == wintype || redraw_all ) {
+ if( sa->spacetype == SPACE_TEXT ) {
st = sa->spacedata.first;
- if(st->text) {
- if (st->text->flags & TXT_FOLLOW) /* follow cursor display */
- pop_space_text(st);
-
+ if( st->text ) {
+ if( st->text->flags & TXT_FOLLOW ) /* follow cursor display */
+ pop_space_text( st );
+
// XXX making a test: Jul 07, 2004.
// we don't need to prevent text win redraws anymore,
// since now there's a scripts space instead.
//if (EXPP_disable_force_draw) { /* defined in Draw.[ch] ... */
- // scrarea_queue_redraw(sa);
- }
+ // scrarea_queue_redraw(sa);
}
-
+ }
//} else {
- scrarea_do_windraw(sa);
- if (sa->headwin) scrarea_do_headdraw(sa);
+ scrarea_do_windraw( sa );
+ if( sa->headwin )
+ scrarea_do_headdraw( sa );
//}
}
- sa= sa->next;
+ sa = sa->next;
}
- if (curarea != tempsa) areawinset (tempsa->win);
+ if( curarea != tempsa )
+ areawinset( tempsa->win );
- if (curarea) { /* is null if Blender is in bg mode */
- if (curarea->headwin) scrarea_do_headdraw (curarea);
- screen_swapbuffers();
+ if( curarea ) { /* is null if Blender is in bg mode */
+ if( curarea->headwin )
+ scrarea_do_headdraw( curarea );
+ screen_swapbuffers( );
}
}
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: M_Window_RedrawAll */
-/* Python equivalent: Blender.Window.RedrawAll */
+/* Function: M_Window_RedrawAll */
+/* Python equivalent: Blender.Window.RedrawAll */
/*****************************************************************************/
-static PyObject *M_Window_RedrawAll(PyObject *self, PyObject *args)
+static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args )
{
- return M_Window_Redraw(self, Py_BuildValue("(i)", -1));
+ return M_Window_Redraw( self, Py_BuildValue( "(i)", -1 ) );
}
/*****************************************************************************/
-/* Function: M_Window_QRedrawAll */
-/* Python equivalent: Blender.Window.QRedrawAll */
+/* Function: M_Window_QRedrawAll */
+/* Python equivalent: Blender.Window.QRedrawAll */
/*****************************************************************************/
-static PyObject *M_Window_QRedrawAll(PyObject *self, PyObject *args)
+static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args )
{
- allqueue(REDRAWALL, 0);
+ allqueue( REDRAWALL, 0 );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: M_Window_FileSelector */
-/* Python equivalent: Blender.Window.FileSelector */
+/* Function: M_Window_FileSelector */
+/* Python equivalent: Blender.Window.FileSelector */
/*****************************************************************************/
/* This is the callback to "activate_fileselect" below. It receives the
* selected filename and (using it as argument) calls the Python callback
* provided by the script writer and stored in EXPP_FS_PyCallback. */
-static void getSelectedFile(char *name)
+static void getSelectedFile( char *name )
{
- if (!EXPP_FS_PyCallback) return;
+ if( !EXPP_FS_PyCallback )
+ return;
- PyObject_CallFunction((PyObject *)EXPP_FS_PyCallback, "s", name);
+ PyObject_CallFunction( ( PyObject * ) EXPP_FS_PyCallback, "s", name );
EXPP_FS_PyCallback = NULL;
return;
}
-static PyObject *M_Window_FileSelector(PyObject *self, PyObject *args)
+static PyObject *M_Window_FileSelector( PyObject * self, PyObject * args )
{
char *title = "SELECT FILE";
char *filename = G.sce;
@@ -454,11 +462,12 @@ static PyObject *M_Window_FileSelector(PyObject *self, PyObject *args)
Script *script = G.main->script.last;
int startspace = 0;
- if (!PyArg_ParseTuple(args, "O!|ss",
- &PyFunction_Type, &EXPP_FS_PyCallback, &title, &filename))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "\nexpected a callback function (and optionally one or two strings) "
- "as argument(s)");
+ if( !PyArg_ParseTuple( args, "O!|ss",
+ &PyFunction_Type, &EXPP_FS_PyCallback, &title,
+ &filename ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "\nexpected a callback function (and optionally one or two strings) "
+ "as argument(s)" );
/* trick: we move to a spacescript because then the fileselector will properly
* unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
@@ -466,30 +475,30 @@ static PyObject *M_Window_FileSelector(PyObject *self, PyObject *args)
* getSelectedFile function above doesn't get called and so couldn't unset the
* flag. */
startspace = curarea->spacetype;
- if (startspace != SPACE_SCRIPT) newspace (curarea, SPACE_SCRIPT);
+ if( startspace != SPACE_SCRIPT )
+ newspace( curarea, SPACE_SCRIPT );
sc = curarea->spacedata.first;
/* did we get the right script? */
- if (!(script->flags & SCRIPT_RUNNING)) {
+ if( !( script->flags & SCRIPT_RUNNING ) ) {
/* if not running, then we were already on a SpaceScript space, executing
* a registered callback -- aka: this script has a gui */
- script = sc->script; /* this is the right script */
- }
- else { /* still running, use the trick */
+ script = sc->script; /* this is the right script */
+ } else { /* still running, use the trick */
script->lastspace = startspace;
sc->script = script;
}
script->flags |= SCRIPT_FILESEL;
- activate_fileselect(FILE_BLENDER, title, filename, getSelectedFile);
+ activate_fileselect( FILE_BLENDER, title, filename, getSelectedFile );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
+static PyObject *M_Window_ImageSelector( PyObject * self, PyObject * args )
{
char *title = "SELECT IMAGE";
char *filename = G.sce;
@@ -497,11 +506,13 @@ static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
Script *script = G.main->script.last;
int startspace = 0;
- if (!PyArg_ParseTuple(args, "O!|ss",
- &PyFunction_Type, &EXPP_FS_PyCallback, &title, &filename))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "\nexpected a callback function (and optionally one or two strings) "
- "as argument(s)"));
+ if( !PyArg_ParseTuple( args, "O!|ss",
+ &PyFunction_Type, &EXPP_FS_PyCallback, &title,
+ &filename ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "\nexpected a callback function (and optionally one or two strings) "
+ "as argument(s)" ) );
/* trick: we move to a spacescript because then the fileselector will properly
* unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
@@ -509,334 +520,347 @@ static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
* getSelectedFile function above doesn't get called and so couldn't unset the
* flag. */
startspace = curarea->spacetype;
- if (startspace != SPACE_SCRIPT) newspace (curarea, SPACE_SCRIPT);
+ if( startspace != SPACE_SCRIPT )
+ newspace( curarea, SPACE_SCRIPT );
sc = curarea->spacedata.first;
/* did we get the right script? */
- if (!(script->flags & SCRIPT_RUNNING)) {
+ if( !( script->flags & SCRIPT_RUNNING ) ) {
/* if not running, then we're on a SpaceScript space, executing a
* registered callback -- aka: this script has a gui */
SpaceScript *sc = curarea->spacedata.first;
- script = sc->script; /* this is the right script */
- }
- else { /* still running, use the trick */
+ script = sc->script; /* this is the right script */
+ } else { /* still running, use the trick */
script->lastspace = startspace;
sc->script = script;
}
- script->flags |= SCRIPT_FILESEL; /* same flag as filesel */
+ script->flags |= SCRIPT_FILESEL; /* same flag as filesel */
- activate_imageselect(FILE_BLENDER, title, filename, getSelectedFile);
+ activate_imageselect( FILE_BLENDER, title, filename, getSelectedFile );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************/
-/* Function: M_Window_DrawProgressBar */
-/* Python equivalent: Blender.Window.DrawProgressBar */
+/* Function: M_Window_DrawProgressBar */
+/* Python equivalent: Blender.Window.DrawProgressBar */
/*****************************************************************************/
-static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
+static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args )
{
float done;
char *info = NULL;
int retval = 0;
- if(!PyArg_ParseTuple(args, "fs", &done, &info))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a float and a string as arguments"));
+ if( !PyArg_ParseTuple( args, "fs", &done, &info ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a float and a string as arguments" ) );
- if (!G.background) retval = progress_bar(done, info);
+ if( !G.background )
+ retval = progress_bar( done, info );
- return Py_BuildValue("i", retval);
+ return Py_BuildValue( "i", retval );
}
/*****************************************************************************/
-/* Function: M_Window_GetCursorPos */
-/* Python equivalent: Blender.Window.GetCursorPos */
+/* Function: M_Window_GetCursorPos */
+/* Python equivalent: Blender.Window.GetCursorPos */
/*****************************************************************************/
-static PyObject *M_Window_GetCursorPos(PyObject *self)
+static PyObject *M_Window_GetCursorPos( PyObject * self )
{
float *cursor = NULL;
PyObject *pylist;
- if (G.vd && G.vd->localview)
+ if( G.vd && G.vd->localview )
cursor = G.vd->cursor;
- else cursor = G.scene->cursor;
+ else
+ cursor = G.scene->cursor;
- pylist = Py_BuildValue("[fff]", cursor[0], cursor[1], cursor[2]);
+ pylist = Py_BuildValue( "[fff]", cursor[0], cursor[1], cursor[2] );
- if (!pylist)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "GetCursorPos: couldn't create pylist"));
+ if( !pylist )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "GetCursorPos: couldn't create pylist" ) );
return pylist;
}
/*****************************************************************************/
-/* Function: M_Window_SetCursorPos */
-/* Python equivalent: Blender.Window.SetCursorPos */
+/* Function: M_Window_SetCursorPos */
+/* Python equivalent: Blender.Window.SetCursorPos */
/*****************************************************************************/
-static PyObject *M_Window_SetCursorPos(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args )
{
int ok = 0;
float val[3];
- if (PyObject_Length (args) == 3)
- ok = PyArg_ParseTuple (args, "fff", &val[0], &val[1], &val[2]);
+ if( PyObject_Length( args ) == 3 )
+ ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
+ &val[2] );
else
- ok = PyArg_ParseTuple(args, "(fff)", &val[0], &val[1], &val[2]);
+ ok = PyArg_ParseTuple( args, "(fff)", &val[0], &val[1],
+ &val[2] );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected [f,f,f] or f,f,f as arguments" );
- if (G.vd && G.vd->localview) {
+ if( G.vd && G.vd->localview ) {
G.vd->cursor[0] = val[0];
G.vd->cursor[1] = val[1];
G.vd->cursor[2] = val[2];
- }
- else {
+ } else {
G.scene->cursor[0] = val[0];
G.scene->cursor[1] = val[1];
G.scene->cursor[2] = val[2];
}
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *M_Window_WaitCursor(PyObject *self, PyObject *args)
+static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
{
int bool;
- if (!PyArg_ParseTuple(args, "i", &bool))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected bool (0 or 1) or nothing as argument");
+ if( !PyArg_ParseTuple( args, "i", &bool ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected bool (0 or 1) or nothing as argument" );
- waitcursor(bool); /* nonzero bool sets, zero unsets */
+ waitcursor( bool ); /* nonzero bool sets, zero unsets */
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
/*****************************************************************************/
-/* Function: M_Window_GetViewVector */
-/* Python equivalent: Blender.Window.GetViewVector */
+/* Function: M_Window_GetViewVector */
+/* Python equivalent: Blender.Window.GetViewVector */
/*****************************************************************************/
-static PyObject *M_Window_GetViewVector(PyObject *self)
+static PyObject *M_Window_GetViewVector( PyObject * self )
{
float *vec = NULL;
PyObject *pylist;
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
vec = G.vd->viewinv[2];
- pylist = Py_BuildValue("[fff]", vec[0], vec[1], vec[2]);
+ pylist = Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
- if (!pylist)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "GetViewVector: couldn't create pylist"));
+ if( !pylist )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "GetViewVector: couldn't create pylist" ) );
return pylist;
}
-static PyObject *M_Window_GetViewQuat(PyObject *self)
+static PyObject *M_Window_GetViewQuat( PyObject * self )
{
float *vec = NULL;
PyObject *pylist;
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
vec = G.vd->viewquat;
- pylist = Py_BuildValue("[ffff]", vec[0], vec[1], vec[2], vec[3]);
+ pylist = Py_BuildValue( "[ffff]", vec[0], vec[1], vec[2], vec[3] );
- if (!pylist)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "GetViewQuat: couldn't create pylist"));
+ if( !pylist )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "GetViewQuat: couldn't create pylist" ) );
return pylist;
}
-static PyObject *M_Window_SetViewQuat(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
{
int ok = 0;
float val[4];
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- if (PyObject_Length (args) == 4)
- ok = PyArg_ParseTuple (args, "ffff", &val[0], &val[1], &val[2], &val[3]);
+ if( PyObject_Length( args ) == 4 )
+ ok = PyArg_ParseTuple( args, "ffff", &val[0], &val[1], &val[2],
+ &val[3] );
else
- ok = PyArg_ParseTuple(args, "(ffff)", &val[0], &val[1], &val[2], &val[3]);
+ ok = PyArg_ParseTuple( args, "(ffff)", &val[0], &val[1],
+ &val[2], &val[3] );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected [f,f,f,f] or f,f,f,f as arguments");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected [f,f,f,f] or f,f,f,f as arguments" );
G.vd->viewquat[0] = val[0];
G.vd->viewquat[1] = val[1];
G.vd->viewquat[2] = val[2];
G.vd->viewquat[3] = val[3];
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_GetViewOffset(PyObject *self)
+static PyObject *M_Window_GetViewOffset( PyObject * self )
{
float *vec = NULL;
PyObject *pylist;
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
vec = G.vd->ofs;
- pylist = Py_BuildValue("[fff]", vec[0], vec[1], vec[2]);
+ pylist = Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
- if (!pylist)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "GetViewQuat: couldn't create pylist"));
+ if( !pylist )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "GetViewQuat: couldn't create pylist" ) );
return pylist;
}
-static PyObject *M_Window_SetViewOffset(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
{
int ok = 0;
float val[3];
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- if (PyObject_Length (args) == 3)
- ok = PyArg_ParseTuple (args, "fff", &val[0], &val[1], &val[2]);
+ if( PyObject_Length( args ) == 3 )
+ ok = PyArg_ParseTuple( args, "fff", &val[0], &val[1],
+ &val[2] );
else
- ok = PyArg_ParseTuple(args, "(fff)", &val[0], &val[1], &val[2]);
+ ok = PyArg_ParseTuple( args, "(fff)", &val[0], &val[1],
+ &val[2] );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected [f,f,f] or f,f,f as arguments" );
G.vd->ofs[0] = val[0];
G.vd->ofs[1] = val[1];
G.vd->ofs[2] = val[2];
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/*****************************************************************************/
-/* Function: M_Window_GetViewMatrix */
-/* Python equivalent: Blender.Window.GetViewMatrix */
+/* Function: M_Window_GetViewMatrix */
+/* Python equivalent: Blender.Window.GetViewMatrix */
/*****************************************************************************/
-static PyObject *M_Window_GetViewMatrix(PyObject *self)
+static PyObject *M_Window_GetViewMatrix( PyObject * self )
{
PyObject *viewmat;
- if (!G.vd) {
- Py_INCREF (Py_None);
+ if( !G.vd ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- viewmat = (PyObject*)newMatrixObject((float*)G.vd->viewmat, 4, 4);
+ viewmat =
+ ( PyObject * ) newMatrixObject( ( float * ) G.vd->viewmat, 4,
+ 4 );
- if (!viewmat)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "GetViewMatrix: couldn't create matrix pyobject");
+ if( !viewmat )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "GetViewMatrix: couldn't create matrix pyobject" );
return viewmat;
}
-static PyObject *M_Window_EditMode(PyObject *self, PyObject *args)
+static PyObject *M_Window_EditMode( PyObject * self, PyObject * args )
{
short status = -1;
char *undo_str = "From script";
int undo_str_len = 11;
- if (!PyArg_ParseTuple(args, "|hs#", &status, &undo_str, &undo_str_len))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or an int (bool) and a string as arguments");
-
- if (status >= 0) {
- if (status) {
- if (!G.obedit) enter_editmode();
- }
- else if (G.obedit) {
- if (undo_str_len > 63) undo_str[63] = '\0'; /* 64 is max */
- undo_push_mesh(undo_str); /* use better solution after 2.34 */
- exit_editmode(1);
+ if( !PyArg_ParseTuple
+ ( args, "|hs#", &status, &undo_str, &undo_str_len ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int (bool) and a string as arguments" );
+
+ if( status >= 0 ) {
+ if( status ) {
+ if( !G.obedit )
+ enter_editmode( );
+ } else if( G.obedit ) {
+ if( undo_str_len > 63 )
+ undo_str[63] = '\0'; /* 64 is max */
+ undo_push_mesh( undo_str ); /* use better solution after 2.34 */
+ exit_editmode( 1 );
}
}
- return Py_BuildValue("h", G.obedit?1:0);
+ return Py_BuildValue( "h", G.obedit ? 1 : 0 );
}
-static PyObject *M_Window_ViewLayer(PyObject *self, PyObject *args)
+static PyObject *M_Window_ViewLayer( PyObject * self, PyObject * args )
{
PyObject *item = NULL;
PyObject *list = NULL, *resl = NULL;
int val, i, bit = 0, layer = 0;
- if (!PyArg_ParseTuple(args, "|O!", &PyList_Type, &list))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or a list of ints as argument");
-
- if (list) {
- for (i = 0; i < PyList_Size(list); i++) {
- item = PyList_GetItem(list, i);
- if (!PyInt_Check(item))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "list must contain only integer numbers");
-
- val = (int)PyInt_AsLong(item);
- if (val < 1 || val > 20)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "layer values must be in the range [1, 20]");
-
- layer |= 1<<(val-1);
+ if( !PyArg_ParseTuple( args, "|O!", &PyList_Type, &list ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or a list of ints as argument" );
+
+ if( list ) {
+ for( i = 0; i < PyList_Size( list ); i++ ) {
+ item = PyList_GetItem( list, i );
+ if( !PyInt_Check( item ) )
+ return EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "list must contain only integer numbers" );
+
+ val = ( int ) PyInt_AsLong( item );
+ if( val < 1 || val > 20 )
+ return EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "layer values must be in the range [1, 20]" );
+
+ layer |= 1 << ( val - 1 );
}
G.vd->lay = layer;
- while (bit < 20) {
- val = 1<<bit;
- if (layer & val) {
+ while( bit < 20 ) {
+ val = 1 << bit;
+ if( layer & val ) {
G.vd->layact = val;
break;
}
bit++;
}
}
-
- resl = PyList_New(0);
- if (!resl)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create pylist!"));
+
+ resl = PyList_New( 0 );
+ if( !resl )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create pylist!" ) );
layer = G.vd->lay;
bit = 0;
- while (bit < 20) {
- val = 1<<bit;
- if (layer & val) {
- item = Py_BuildValue("i", bit + 1);
- PyList_Append(resl, item);
- Py_DECREF(item);
+ while( bit < 20 ) {
+ val = 1 << bit;
+ if( layer & val ) {
+ item = Py_BuildValue( "i", bit + 1 );
+ PyList_Append( resl, item );
+ Py_DECREF( item );
}
bit++;
}
@@ -844,263 +868,270 @@ static PyObject *M_Window_ViewLayer(PyObject *self, PyObject *args)
return resl;
}
-static PyObject *M_Window_CameraView(PyObject *self, PyObject *args)
+static PyObject *M_Window_CameraView( PyObject * self, PyObject * args )
{
short camtov3d = 0;
- void setcameratoview3d(void); /* view.c, used in toets.c */
-
- if (!PyArg_ParseTuple(args, "|i", &camtov3d))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int (from Window.Views) as argument");
-
- if (!G.vd)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "View3d not available!");
-
- if (!G.vd->camera) {
- if (BASACT && OBACT->type == OB_CAMERA) G.vd->camera = OBACT;
- else G.vd->camera = scene_find_camera(G.scene);
- handle_view3d_lock();
+ void setcameratoview3d( void ); /* view.c, used in toets.c */
+
+ if( !PyArg_ParseTuple( args, "|i", &camtov3d ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int (from Window.Views) as argument" );
+
+ if( !G.vd )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "View3d not available!" );
+
+ if( !G.vd->camera ) {
+ if( BASACT && OBACT->type == OB_CAMERA )
+ G.vd->camera = OBACT;
+ else
+ G.vd->camera = scene_find_camera( G.scene );
+ handle_view3d_lock( );
}
G.vd->persp = 2;
G.vd->view = 0;
- if (camtov3d) setcameratoview3d();
+ if( camtov3d )
+ setcameratoview3d( );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_QTest(PyObject *self)
+static PyObject *M_Window_QTest( PyObject * self )
{
- return Py_BuildValue("h", qtest());
+ return Py_BuildValue( "h", qtest( ) );
}
-static PyObject *M_Window_QRead(PyObject *self)
+static PyObject *M_Window_QRead( PyObject * self )
{
short val = 0;
unsigned short event;
- event = extern_qread(&val);
+ event = extern_qread( &val );
- return Py_BuildValue("ii", event, val);
+ return Py_BuildValue( "ii", event, val );
}
-static PyObject *M_Window_QAdd(PyObject *self, PyObject *args)
+static PyObject *M_Window_QAdd( PyObject * self, PyObject * args )
{
short win;
- short evt; /* unsigned, we check below */
+ short evt; /* unsigned, we check below */
short val;
short after = 0;
- if (!PyArg_ParseTuple(args, "hhh|h", &win, &evt, &val, &after))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected three or four ints as arguments");
+ if( !PyArg_ParseTuple( args, "hhh|h", &win, &evt, &val, &after ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected three or four ints as arguments" );
- if (evt < 0) /* evt is unsigned short */
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "event value must be a positive int, check events in Blender.Draw");
+ if( evt < 0 ) /* evt is unsigned short */
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "event value must be a positive int, check events in Blender.Draw" );
- if (after) addafterqueue(win, evt, val);
- else addqueue(win, evt, val);
+ if( after )
+ addafterqueue( win, evt, val );
+ else
+ addqueue( win, evt, val );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_QHandle(PyObject *self, PyObject *args)
+static PyObject *M_Window_QHandle( PyObject * self, PyObject * args )
{
short win;
ScrArea *sa = curarea;
ScrArea *oldsa = NULL;
- if (!PyArg_ParseTuple(args, "h", &win))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected an int as argument");
+ if( !PyArg_ParseTuple( args, "h", &win ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int as argument" );
- while (sa) {
- if (sa->win == win) break;
+ while( sa ) {
+ if( sa->win == win )
+ break;
sa = sa->next;
}
- if (sa) {
+ if( sa ) {
BWinEvent evt;
short do_redraw = 0, do_change = 0;
- if(sa != curarea || sa->win != mywinget()) {
+ if( sa != curarea || sa->win != mywinget( ) ) {
oldsa = curarea;
- areawinset(sa->win);
- set_g_activearea(sa);
+ areawinset( sa->win );
+ set_g_activearea( sa );
}
- while(bwin_qread(sa->win, &evt)) {
- if(evt.event == REDRAW) {
+ while( bwin_qread( sa->win, &evt ) ) {
+ if( evt.event == REDRAW ) {
do_redraw = 1;
- }
- else if(evt.event == CHANGED) {
+ } else if( evt.event == CHANGED ) {
sa->win_swap = 0;
do_change = 1;
do_redraw = 1;
- }
- else {
- scrarea_do_winhandle(sa, &evt);
+ } else {
+ scrarea_do_winhandle( sa, &evt );
}
}
}
- if (oldsa) {
- areawinset(oldsa->win);
- set_g_activearea(oldsa);
+ if( oldsa ) {
+ areawinset( oldsa->win );
+ set_g_activearea( oldsa );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_GetMouseCoords(PyObject *self)
+static PyObject *M_Window_GetMouseCoords( PyObject * self )
{
short mval[2];
- getmouse(mval);
-
- return Py_BuildValue("hh", mval[0], mval[1]);
+ getmouse( mval );
+
+ return Py_BuildValue( "hh", mval[0], mval[1] );
}
-static PyObject *M_Window_SetMouseCoords(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args )
{
int ok, x, y;
- if (!G.curscreen)
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "no current screen to retrieve info from!");
-
+ if( !G.curscreen )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "no current screen to retrieve info from!" );
+
x = G.curscreen->sizex / 2;
y = G.curscreen->sizey / 2;
- if (PyObject_Length(args) == 2)
- ok = PyArg_ParseTuple(args, "hh", &x, &y);
+ if( PyObject_Length( args ) == 2 )
+ ok = PyArg_ParseTuple( args, "hh", &x, &y );
else
- ok = PyArg_ParseTuple(args, "|(hh)", &x, &y);
+ ok = PyArg_ParseTuple( args, "|(hh)", &x, &y );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected [i, i] or i,i as arguments (or nothing).");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected [i, i] or i,i as arguments (or nothing)." );
- warp_pointer(x, y);
+ warp_pointer( x, y );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_GetMouseButtons(PyObject *self)
+static PyObject *M_Window_GetMouseButtons( PyObject * self )
{
- short mbut = get_mbut();
-
- return Py_BuildValue("h", mbut);
+ short mbut = get_mbut( );
+
+ return Py_BuildValue( "h", mbut );
}
-static PyObject *M_Window_GetKeyQualifiers(PyObject *self)
+static PyObject *M_Window_GetKeyQualifiers( PyObject * self )
{
- short qual = get_qual();
+ short qual = get_qual( );
- return Py_BuildValue("h", qual);
+ return Py_BuildValue( "h", qual );
}
-static PyObject *M_Window_SetKeyQualifiers(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetKeyQualifiers( PyObject * self, PyObject * args )
{
short qual = 0;
- if (!PyArg_ParseTuple(args, "|h", &qual))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or an int (or'ed flags) as argument");
+ if( !PyArg_ParseTuple( args, "|h", &qual ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int (or'ed flags) as argument" );
- if (qual < 0)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value must be a positive int, check Blender.Window.Qual");
+ if( qual < 0 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value must be a positive int, check Blender.Window.Qual" );
G.qual = qual;
- return Py_BuildValue("h", qual);
+ return Py_BuildValue( "h", qual );
}
-static PyObject *M_Window_GetAreaSize(PyObject *self)
+static PyObject *M_Window_GetAreaSize( PyObject * self )
{
ScrArea *sa = curarea;
- if (!sa) return EXPP_incr_ret(Py_None);
+ if( !sa )
+ return EXPP_incr_ret( Py_None );
- return Py_BuildValue("hh", sa->winx, sa->winy);
+ return Py_BuildValue( "hh", sa->winx, sa->winy );
}
-static PyObject *M_Window_GetAreaID(PyObject *self)
+static PyObject *M_Window_GetAreaID( PyObject * self )
{
ScrArea *sa = curarea;
- if (!sa) return EXPP_incr_ret(Py_None);
+ if( !sa )
+ return EXPP_incr_ret( Py_None );
- return Py_BuildValue("h", sa->win);
+ return Py_BuildValue( "h", sa->win );
}
-static PyObject *M_Window_GetScreenSize(PyObject *self)
+static PyObject *M_Window_GetScreenSize( PyObject * self )
{
bScreen *scr = G.curscreen;
- if (!scr) return EXPP_incr_ret(Py_None);
+ if( !scr )
+ return EXPP_incr_ret( Py_None );
- return Py_BuildValue("hh", scr->sizex, scr->sizey);
+ return Py_BuildValue( "hh", scr->sizex, scr->sizey );
}
-static PyObject *M_Window_SetScreen(PyObject *self, PyObject *args)
+static PyObject *M_Window_SetScreen( PyObject * self, PyObject * args )
{
bScreen *scr = G.main->screen.first;
char *name = NULL;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string as argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string as argument" );
- while (scr) {
- if (!strcmp(scr->id.name+2, name)) {
- setscreen(scr);
+ while( scr ) {
+ if( !strcmp( scr->id.name + 2, name ) ) {
+ setscreen( scr );
break;
}
scr = scr->id.next;
}
- if (!scr)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no such screen, check Window.GetScreens() for valid names.");
+ if( !scr )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no such screen, check Window.GetScreens() for valid names." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *M_Window_GetScreens(PyObject *self)
+static PyObject *M_Window_GetScreens( PyObject * self )
{
bScreen *scr = G.main->screen.first;
- PyObject *list = PyList_New(0);
+ PyObject *list = PyList_New( 0 );
PyObject *str = NULL;
- if (!list)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create py list!");
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create py list!" );
- while (scr) {
- str = PyString_FromString(scr->id.name+2);
+ while( scr ) {
+ str = PyString_FromString( scr->id.name + 2 );
- if (!str) {
- Py_DECREF(list);
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create py string!");
+ if( !str ) {
+ Py_DECREF( list );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create py string!" );
}
- PyList_Append(list, str); /* incref's str */
- Py_DECREF(str);
+ PyList_Append( list, str ); /* incref's str */
+ Py_DECREF( str );
scr = scr->id.next;
}
- return list;
+ return list;
}
-static PyObject *M_Window_GetScreenInfo(PyObject *self, PyObject *args,
- PyObject *kwords)
+static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args,
+ PyObject * kwords )
{
ScrArea *sa = G.curscreen->areabase.first;
bScreen *scr = G.main->screen.first;
@@ -1109,29 +1140,29 @@ static PyObject *M_Window_GetScreenInfo(PyObject *self, PyObject *args,
int type = -1;
char *rect = "win";
char *screen = "";
- static char *kwlist[] = {"type", "rect", "screen", NULL};
+ static char *kwlist[] = { "type", "rect", "screen", NULL };
int rctype = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwords, "|iss", kwlist, &type,
- &rect, &screen))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected nothing or an int and two strings as arguments");
+ if( !PyArg_ParseTupleAndKeywords( args, kwords, "|iss", kwlist, &type,
+ &rect, &screen ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int and two strings as arguments" );
- if (!strcmp(rect, "win"))
+ if( !strcmp( rect, "win" ) )
rctype = 0;
- else if (!strcmp(rect, "total"))
+ else if( !strcmp( rect, "total" ) )
rctype = 1;
- else if (!strcmp(rect, "header"))
+ else if( !strcmp( rect, "header" ) )
rctype = 2;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "requested invalid type for area rectangle coordinates.");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "requested invalid type for area rectangle coordinates." );
- list = PyList_New(0);
+ list = PyList_New( 0 );
- if (screen && screen[0] != '\0') {
- while (scr) {
- if (!strcmp(scr->id.name+2, screen)) {
+ if( screen && screen[0] != '\0' ) {
+ while( scr ) {
+ if( !strcmp( scr->id.name + 2, screen ) ) {
sa = scr->areabase.first;
break;
}
@@ -1139,35 +1170,37 @@ static PyObject *M_Window_GetScreenInfo(PyObject *self, PyObject *args,
}
}
- if (!scr) {
- Py_DECREF(list);
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "no such screen, see existing ones with Window.GetScreens.");
+ if( !scr ) {
+ Py_DECREF( list );
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no such screen, see existing ones with Window.GetScreens." );
}
-
- while (sa) {
- if (type != -1 && sa->spacetype != type) {
+
+ while( sa ) {
+ if( type != -1 && sa->spacetype != type ) {
sa = sa->next;
continue;
}
- switch (rctype) {
- case 0:
- rct = &sa->winrct;
- break;
- case 1:
- rct = &sa->totrct;
- break;
- case 2:
- default:
- rct = &sa->headrct;
+ switch ( rctype ) {
+ case 0:
+ rct = &sa->winrct;
+ break;
+ case 1:
+ rct = &sa->totrct;
+ break;
+ case 2:
+ default:
+ rct = &sa->headrct;
}
- item = Py_BuildValue("{s:[h,h,h,h],s:h,s:h}",
- "vertices", rct->xmin, rct->ymin, rct->xmax, rct->ymax,
- "type", (short)sa->spacetype, "id", (short)sa->win);
- PyList_Append(list, item);
- Py_DECREF(item);
+ item = Py_BuildValue( "{s:[h,h,h,h],s:h,s:h}",
+ "vertices", rct->xmin, rct->ymin,
+ rct->xmax, rct->ymax, "type",
+ ( short ) sa->spacetype, "id",
+ ( short ) sa->win );
+ PyList_Append( list, item );
+ Py_DECREF( item );
sa = sa->next;
}
@@ -1176,57 +1209,59 @@ static PyObject *M_Window_GetScreenInfo(PyObject *self, PyObject *args,
}
/*****************************************************************************/
-/* Function: Window_Init */
+/* Function: Window_Init */
/*****************************************************************************/
-PyObject *Window_Init (void)
+PyObject *Window_Init( void )
{
- PyObject *submodule, *Types, *Qual, *dict;
-
- submodule = Py_InitModule3("Blender.Window", M_Window_methods, M_Window_doc);
-
- dict = PyModule_GetDict(submodule);
- if (dict) PyDict_SetItemString(dict, "Theme", Theme_Init());
-
- Types = M_constant_New();
- Qual = M_constant_New();
-
- if (Types) {
- BPy_constant *d = (BPy_constant *)Types;
-
- constant_insert(d, "VIEW3D", PyInt_FromLong(SPACE_VIEW3D));
- constant_insert(d, "IPO", PyInt_FromLong(SPACE_IPO));
- constant_insert(d, "OOPS", PyInt_FromLong(SPACE_OOPS));
- constant_insert(d, "BUTS", PyInt_FromLong(SPACE_BUTS));
- constant_insert(d, "FILE", PyInt_FromLong(SPACE_FILE));
- constant_insert(d, "IMAGE", PyInt_FromLong(SPACE_IMAGE));
- constant_insert(d, "INFO", PyInt_FromLong(SPACE_INFO));
- constant_insert(d, "SEQ", PyInt_FromLong(SPACE_SEQ));
- constant_insert(d, "IMASEL", PyInt_FromLong(SPACE_IMASEL));
- constant_insert(d, "SOUND", PyInt_FromLong(SPACE_SOUND));
- constant_insert(d, "ACTION", PyInt_FromLong(SPACE_ACTION));
- constant_insert(d, "TEXT", PyInt_FromLong(SPACE_TEXT));
- constant_insert(d, "NLA", PyInt_FromLong(SPACE_NLA));
- constant_insert(d, "SCRIPT", PyInt_FromLong(SPACE_SCRIPT));
-
- PyModule_AddObject(submodule, "Types", Types);
+ PyObject *submodule, *Types, *Qual, *dict;
+
+ submodule =
+ Py_InitModule3( "Blender.Window", M_Window_methods,
+ M_Window_doc );
+
+ dict = PyModule_GetDict( submodule );
+ if( dict )
+ PyDict_SetItemString( dict, "Theme", Theme_Init( ) );
+
+ Types = M_constant_New( );
+ Qual = M_constant_New( );
+
+ if( Types ) {
+ BPy_constant *d = ( BPy_constant * ) Types;
+
+ constant_insert( d, "VIEW3D", PyInt_FromLong( SPACE_VIEW3D ) );
+ constant_insert( d, "IPO", PyInt_FromLong( SPACE_IPO ) );
+ constant_insert( d, "OOPS", PyInt_FromLong( SPACE_OOPS ) );
+ constant_insert( d, "BUTS", PyInt_FromLong( SPACE_BUTS ) );
+ constant_insert( d, "FILE", PyInt_FromLong( SPACE_FILE ) );
+ constant_insert( d, "IMAGE", PyInt_FromLong( SPACE_IMAGE ) );
+ constant_insert( d, "INFO", PyInt_FromLong( SPACE_INFO ) );
+ constant_insert( d, "SEQ", PyInt_FromLong( SPACE_SEQ ) );
+ constant_insert( d, "IMASEL", PyInt_FromLong( SPACE_IMASEL ) );
+ constant_insert( d, "SOUND", PyInt_FromLong( SPACE_SOUND ) );
+ constant_insert( d, "ACTION", PyInt_FromLong( SPACE_ACTION ) );
+ constant_insert( d, "TEXT", PyInt_FromLong( SPACE_TEXT ) );
+ constant_insert( d, "NLA", PyInt_FromLong( SPACE_NLA ) );
+ constant_insert( d, "SCRIPT", PyInt_FromLong( SPACE_SCRIPT ) );
+
+ PyModule_AddObject( submodule, "Types", Types );
}
- if (Qual) {
- BPy_constant *d = (BPy_constant *)Qual;
+ if( Qual ) {
+ BPy_constant *d = ( BPy_constant * ) Qual;
- constant_insert(d, "LALT", PyInt_FromLong(L_ALTKEY));
- constant_insert(d, "RALT", PyInt_FromLong(R_ALTKEY));
- constant_insert(d, "ALT", PyInt_FromLong(LR_ALTKEY));
- constant_insert(d, "LCTRL", PyInt_FromLong(L_CTRLKEY));
- constant_insert(d, "RCTRL", PyInt_FromLong(R_CTRLKEY));
- constant_insert(d, "CTRL", PyInt_FromLong(LR_CTRLKEY));
- constant_insert(d, "LSHIFT", PyInt_FromLong(L_SHIFTKEY));
- constant_insert(d, "RSHIFT", PyInt_FromLong(R_SHIFTKEY));
- constant_insert(d, "SHIFT", PyInt_FromLong(LR_SHIFTKEY));
+ constant_insert( d, "LALT", PyInt_FromLong( L_ALTKEY ) );
+ constant_insert( d, "RALT", PyInt_FromLong( R_ALTKEY ) );
+ constant_insert( d, "ALT", PyInt_FromLong( LR_ALTKEY ) );
+ constant_insert( d, "LCTRL", PyInt_FromLong( L_CTRLKEY ) );
+ constant_insert( d, "RCTRL", PyInt_FromLong( R_CTRLKEY ) );
+ constant_insert( d, "CTRL", PyInt_FromLong( LR_CTRLKEY ) );
+ constant_insert( d, "LSHIFT", PyInt_FromLong( L_SHIFTKEY ) );
+ constant_insert( d, "RSHIFT", PyInt_FromLong( R_SHIFTKEY ) );
+ constant_insert( d, "SHIFT", PyInt_FromLong( LR_SHIFTKEY ) );
- PyModule_AddObject(submodule, "Qual", Qual);
+ PyModule_AddObject( submodule, "Qual", Qual );
}
return submodule;
}
-
diff --git a/source/blender/python/api2_2x/Window.h b/source/blender/python/api2_2x/Window.h
index 81b288f395f..a615f408b42 100644
--- a/source/blender/python/api2_2x/Window.h
+++ b/source/blender/python/api2_2x/Window.h
@@ -1,4 +1,5 @@
/*
+ * $Id:*
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -34,4 +35,4 @@
#ifndef EXPP_WINDOW_H
#define EXPP_WINDOW_H
-#endif /* EXPP_WINDOW_H */
+#endif /* EXPP_WINDOW_H */
diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c
index c20b41d542f..4f1c20d851d 100644
--- a/source/blender/python/api2_2x/World.c
+++ b/source/blender/python/api2_2x/World.c
@@ -53,41 +53,40 @@
/*****************************************************************************/
-/* Python World_Type callback function prototypes: */
+/* Python World_Type callback function prototypes: */
/*****************************************************************************/
-static void World_DeAlloc (BPy_World *self);
+static void World_DeAlloc( BPy_World * self );
//static int World_Print (BPy_World *self, FILE *fp, int flags);
-static int World_SetAttr (BPy_World *self, char *name, PyObject *v);
-static int World_Compare (BPy_World *a, BPy_World *b);
-static PyObject *World_GetAttr (BPy_World *self, char *name);
-static PyObject *World_Repr (BPy_World *self);
+static int World_SetAttr( BPy_World * self, char *name, PyObject * v );
+static int World_Compare( BPy_World * a, BPy_World * b );
+static PyObject *World_GetAttr( BPy_World * self, char *name );
+static PyObject *World_Repr( BPy_World * self );
/*****************************************************************************/
-/* Python World_Type structure definition: */
+/* Python World_Type structure definition: */
/*****************************************************************************/
-PyTypeObject World_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "World", /* tp_name */
- sizeof (BPy_World), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject World_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "World", /* tp_name */
+ sizeof( BPy_World ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)World_DeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)World_GetAttr, /* tp_getattr */
- (setattrfunc)World_SetAttr, /* tp_setattr */
- (cmpfunc)World_Compare, /* tp_compare */
- (reprfunc)World_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_World_methods, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) World_DeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) World_GetAttr, /* tp_getattr */
+ ( setattrfunc ) World_SetAttr, /* tp_setattr */
+ ( cmpfunc ) World_Compare, /* tp_compare */
+ ( reprfunc ) World_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_World_methods, /* tp_methods */
+ 0, /* tp_members */
};
/**
@@ -107,38 +106,39 @@ PyTypeObject World_Type =
* \return A new World PyObject.
*/
-static PyObject *M_World_New(PyObject *self, PyObject *args, PyObject *kwords)
+static PyObject *M_World_New( PyObject * self, PyObject * args,
+ PyObject * kwords )
{
- World *add_world(char *name);
- char*name = NULL;
- BPy_World *pyworld;
- World *blworld;
+ World *add_world( char *name );
+ char *name = NULL;
+ BPy_World *pyworld;
+ World *blworld;
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
- blworld = add_world(name);
+ blworld = add_world( name );
- if (blworld){
- /* return user count to zero because add_world() inc'd it */
- blworld->id.us = 0;
- /* create python wrapper obj */
- pyworld = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create World Data in Blender"));
+ if( blworld ) {
+ /* return user count to zero because add_world() inc'd it */
+ blworld->id.us = 0;
+ /* create python wrapper obj */
+ pyworld =
+ ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create World Data in Blender" ) );
- if (pyworld == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create World Data object"));
+ if( pyworld == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create World Data object" ) );
- pyworld->world = blworld;
+ pyworld->world = blworld;
- return (PyObject *)pyworld;
+ return ( PyObject * ) pyworld;
}
/**
@@ -154,70 +154,75 @@ static PyObject *M_World_New(PyObject *self, PyObject *args, PyObject *kwords)
* in Blender.
*/
-static PyObject *M_World_Get(PyObject *self, PyObject *args)
+static PyObject *M_World_Get( PyObject * self, PyObject * args )
{
- char *name = NULL;
+ char *name = NULL;
World *world_iter;
PyObject *worldlist;
BPy_World *wanted_world = NULL;
char error_msg[64];
- if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)"));
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" ) );
world_iter = G.main->world.first;
- if (name) { /* (name) - Search world by name */
- while ((world_iter) && (wanted_world == NULL)) {
- if (strcmp (name, world_iter->id.name+2) == 0) {
- wanted_world = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
- if (wanted_world) wanted_world->world = world_iter;
+ if( name ) { /* (name) - Search world by name */
+ while( ( world_iter ) && ( wanted_world == NULL ) ) {
+ if( strcmp( name, world_iter->id.name + 2 ) == 0 ) {
+ wanted_world =
+ ( BPy_World * )
+ PyObject_NEW( BPy_World, &World_Type );
+ if( wanted_world )
+ wanted_world->world = world_iter;
}
world_iter = world_iter->id.next;
}
- if (wanted_world == NULL) { /* Requested world doesn't exist */
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "World \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ if( wanted_world == NULL ) { /* Requested world doesn't exist */
+ PyOS_snprintf( error_msg, sizeof( error_msg ),
+ "World \"%s\" not found", name );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_NameError, error_msg ) );
}
- return (PyObject *)wanted_world;
+ return ( PyObject * ) wanted_world;
}
- else { /* return a list of all worlds in the scene */
- worldlist = PyList_New (0);
- if (worldlist == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList"));
+ else { /* return a list of all worlds in the scene */
+ worldlist = PyList_New( 0 );
+ if( worldlist == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" ) );
- while (world_iter) {
- BPy_World *found_world = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
+ while( world_iter ) {
+ BPy_World *found_world =
+ ( BPy_World * ) PyObject_NEW( BPy_World,
+ &World_Type );
found_world->world = world_iter;
- PyList_Append (worldlist , (PyObject *)found_world);
+ PyList_Append( worldlist, ( PyObject * ) found_world );
world_iter = world_iter->id.next;
}
- return (worldlist);
+ return ( worldlist );
}
}
-static PyObject *M_World_GetActive(PyObject *self)
+static PyObject *M_World_GetActive( PyObject * self )
{
BPy_World *w = NULL;
- if(!G.scene->world)
- {
- Py_INCREF(Py_None);
- return Py_None;
- }
- w = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
+ if( !G.scene->world ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ w = ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
w->world = G.scene->world;
- return (PyObject *)w;
+ return ( PyObject * ) w;
}
/*@}*/
@@ -230,96 +235,102 @@ static PyObject *M_World_GetActive(PyObject *self)
* \return PyObject*: The initialized submodule.
*/
-PyObject *World_Init (void)
+PyObject *World_Init( void )
{
- PyObject *submodule;
+ PyObject *submodule;
World_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.World",
- M_World_methods, M_World_doc);
+ submodule = Py_InitModule3( "Blender.World",
+ M_World_methods, M_World_doc );
- return (submodule);
+ return ( submodule );
}
/*****************************************************************************/
-/* Python BPy_World methods: */
+/* Python BPy_World methods: */
/*****************************************************************************/
-static PyObject *World_getRange(BPy_World *self)
+static PyObject *World_getRange( BPy_World * self )
{
- return PyFloat_FromDouble(self->world->range);
+ return PyFloat_FromDouble( self->world->range );
}
-static PyObject *World_setRange(BPy_World *self, PyObject *args)
+static PyObject *World_setRange( BPy_World * self, PyObject * args )
{
- float range=0.f;
- if (!PyArg_ParseTuple(args, "f", &range))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected a float argument"));
- self->world->range = range;
- Py_INCREF(Py_None);
- return Py_None;
+ float range = 0.f;
+ if( !PyArg_ParseTuple( args, "f", &range ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a float argument" ) );
+ self->world->range = range;
+ Py_INCREF( Py_None );
+ return Py_None;
}
-static PyObject *World_getIpo(BPy_World *self)
+static PyObject *World_getIpo( BPy_World * self )
{
struct Ipo *ipo = self->world->ipo;
- if (!ipo) {
- Py_INCREF (Py_None);
+ if( !ipo ) {
+ Py_INCREF( Py_None );
return Py_None;
}
- return Ipo_CreatePyObject (ipo);
+ return Ipo_CreatePyObject( ipo );
}
-static PyObject *World_setIpo(BPy_World *self, PyObject *args)
+static PyObject *World_setIpo( BPy_World * 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");
+ if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected Ipo as argument" );
- ipo = Ipo_FromPyObject(pyipo);
+ ipo = Ipo_FromPyObject( pyipo );
- if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+ if( !ipo )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "null ipo!" );
- if (ipo->blocktype != ID_CA)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "this ipo is not a World type ipo");
+ if( ipo->blocktype != ID_CA )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "this ipo is not a World type ipo" );
oldipo = self->world->ipo;
- if (oldipo) {
+ if( oldipo ) {
ID *id = &oldipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
}
- ((ID *)&ipo->id)->us++;
+ ( ( ID * ) & ipo->id )->us++;
self->world->ipo = ipo;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *World_clearIpo(BPy_World *self)
+static PyObject *World_clearIpo( BPy_World * self )
{
World *world = self->world;
- Ipo *ipo = (Ipo *)world->ipo;
+ Ipo *ipo = ( Ipo * ) world->ipo;
- if (ipo) {
+ if( ipo ) {
ID *id = &ipo->id;
- if (id->us > 0) id->us--;
+ if( id->us > 0 )
+ id->us--;
world->ipo = NULL;
- Py_INCREF (Py_True);
+ Py_INCREF( Py_True );
return Py_True;
}
- Py_INCREF (Py_False); /* no ipo found */
+ Py_INCREF( Py_False ); /* no ipo found */
return Py_False;
}
@@ -329,30 +340,33 @@ static PyObject *World_clearIpo(BPy_World *self)
* \return string: The World Data name.
*/
-static PyObject *World_getName(BPy_World *self)
+static PyObject *World_getName( BPy_World * self )
{
- PyObject *attr = PyString_FromString(self->world->id.name+2);
+ PyObject *attr = PyString_FromString( self->world->id.name + 2 );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get World.name attribute" ) );
}
+
/**
* \brief World PyMethod setName
* \param name - string: The new World Data name.
*/
-static PyObject *World_setName(BPy_World *self, PyObject *args)
+static PyObject *World_setName( BPy_World * self, PyObject * args )
{
char *name = 0;
char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument"));
- snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&self->world->id, buf);
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected string argument" ) );
+ snprintf( buf, sizeof( buf ), "%s", name );
+ rename_id( &self->world->id, buf );
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -366,14 +380,15 @@ static PyObject *World_setName(BPy_World *self, PyObject *args)
* \return int : The World Data skytype.
*/
-static PyObject *World_getSkytype(BPy_World *self)
+static PyObject *World_getSkytype( BPy_World * self )
{
- PyObject *attr = PyInt_FromLong((long)self->world->skytype);
+ PyObject *attr = PyInt_FromLong( ( long ) self->world->skytype );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.skytype attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get World.skytype attribute" ) );
}
@@ -383,15 +398,15 @@ static PyObject *World_getSkytype(BPy_World *self)
* \return int : The World Data skytype.
*/
-static PyObject *World_setSkytype(BPy_World *self, PyObject *args )
+static PyObject *World_setSkytype( BPy_World * self, PyObject * args )
{
int skytype;
- if (!PyArg_ParseTuple(args, "i", &skytype))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &skytype ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
self->world->skytype = skytype;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -402,14 +417,15 @@ static PyObject *World_setSkytype(BPy_World *self, PyObject *args )
* \return int : The World Data mode.
*/
-static PyObject *World_getMode(BPy_World *self)
+static PyObject *World_getMode( BPy_World * self )
{
- PyObject *attr = PyInt_FromLong((long)self->world->mode);
+ PyObject *attr = PyInt_FromLong( ( long ) self->world->mode );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.mode attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get World.mode attribute" ) );
}
@@ -419,15 +435,15 @@ static PyObject *World_getMode(BPy_World *self)
* \return int : The World Data mode.
*/
-static PyObject *World_setMode(BPy_World *self, PyObject *args )
+static PyObject *World_setMode( BPy_World * self, PyObject * args )
{
int mode;
- if (!PyArg_ParseTuple(args, "i", &mode))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &mode ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
self->world->mode = mode;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -450,14 +466,15 @@ static PyObject *World_setMode(BPy_World *self, PyObject *args )
* \return int : The World Data mistype.
*/
-static PyObject *World_getMistype(BPy_World *self)
+static PyObject *World_getMistype( BPy_World * self )
{
- PyObject *attr = PyInt_FromLong((long)self->world->mistype);
+ PyObject *attr = PyInt_FromLong( ( long ) self->world->mistype );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.mistype attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get World.mistype attribute" ) );
}
@@ -467,15 +484,15 @@ static PyObject *World_getMistype(BPy_World *self)
* \return int : The World Data mistype.
*/
-static PyObject *World_setMistype(BPy_World *self, PyObject *args )
+static PyObject *World_setMistype( BPy_World * self, PyObject * args )
{
int mistype;
- if (!PyArg_ParseTuple(args, "i", &mistype))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if( !PyArg_ParseTuple( args, "i", &mistype ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" ) );
self->world->mistype = mistype;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -483,125 +500,136 @@ static PyObject *World_setMistype(BPy_World *self, PyObject *args )
-static PyObject *World_getHor(BPy_World *self)
+static PyObject *World_getHor( BPy_World * self )
{
- PyObject *attr = PyList_New(0);
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
- PyList_Append(attr, PyFloat_FromDouble(self->world->horr));
- PyList_Append(attr, PyFloat_FromDouble(self->world->horg));
- PyList_Append(attr, PyFloat_FromDouble(self->world->horb));
+ PyObject *attr = PyList_New( 0 );
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create list" ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->horr ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->horg ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->horb ) );
return attr;
}
-static PyObject *World_setHor(BPy_World *self, PyObject *args )
+static PyObject *World_setHor( BPy_World * self, PyObject * args )
{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected list argument"));
- self->world->horr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->horg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->world->horb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- Py_INCREF(Py_None);
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list argument" ) );
+ self->world->horr = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->world->horg = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->world->horb = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *World_getZen(BPy_World *self)
+static PyObject *World_getZen( BPy_World * self )
{
- PyObject *attr = PyList_New(0);
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
- PyList_Append(attr, PyFloat_FromDouble(self->world->zenr));
- PyList_Append(attr, PyFloat_FromDouble(self->world->zeng));
- PyList_Append(attr, PyFloat_FromDouble(self->world->zenb));
+ PyObject *attr = PyList_New( 0 );
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create list" ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->zenr ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->zeng ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->zenb ) );
return attr;
}
-static PyObject *World_setZen(BPy_World *self, PyObject *args )
+static PyObject *World_setZen( BPy_World * self, PyObject * args )
{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected list argument"));
- self->world->zenr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->zeng = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->world->zenb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- Py_INCREF(Py_None);
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected list argument" ) );
+ self->world->zenr = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->world->zeng = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->world->zenb = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *World_getAmb(BPy_World *self)
+static PyObject *World_getAmb( BPy_World * self )
{
- PyObject *attr = PyList_New(0);
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
- PyList_Append(attr, PyFloat_FromDouble(self->world->ambr));
- PyList_Append(attr, PyFloat_FromDouble(self->world->ambg));
- PyList_Append(attr, PyFloat_FromDouble(self->world->ambb));
+ PyObject *attr = PyList_New( 0 );
+ if( !attr )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create list" ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->ambr ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->ambg ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->ambb ) );
return attr;
}
-static PyObject *World_setAmb(BPy_World *self, PyObject *args )
+static PyObject *World_setAmb( BPy_World * self, PyObject * args )
{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (PyList_Size(listargs)!=3)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
- self->world->ambr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->ambg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->world->ambb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- Py_INCREF(Py_None);
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( PyList_Size( listargs ) != 3 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "wrong list size" ) );
+ self->world->ambr = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->world->ambg = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->world->ambb = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *World_getStar(BPy_World *self)
+static PyObject *World_getStar( BPy_World * self )
{
- PyObject *attr = PyList_New(0);
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,"couldn't create list"));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starr));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starg));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starb));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starsize));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starmindist));
- PyList_Append(attr, PyFloat_FromDouble(self->world->stardist));
- PyList_Append(attr, PyFloat_FromDouble(self->world->starcolnoise));
+ PyObject *attr = PyList_New( 0 );
+ if( !attr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError, "couldn't create list" ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starr ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starg ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starb ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starsize ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starmindist ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->stardist ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->starcolnoise ) );
return attr;
}
-static PyObject *World_setStar(BPy_World *self, PyObject *args )
-{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (PyList_Size(listargs)!=7)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
- self->world->starr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->starg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->world->starb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- self->world->starsize = PyFloat_AsDouble(PyList_GetItem(listargs,3));
- self->world->starmindist = PyFloat_AsDouble(PyList_GetItem(listargs,4));
- self->world->stardist = PyFloat_AsDouble(PyList_GetItem(listargs,5));
- self->world->starcolnoise = PyFloat_AsDouble(PyList_GetItem(listargs,6));
- Py_INCREF(Py_None);
+static PyObject *World_setStar( BPy_World * self, PyObject * args )
+{
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( PyList_Size( listargs ) != 7 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "wrong list size" ) );
+ self->world->starr = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->world->starg = PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->world->starb = PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ self->world->starsize =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 3 ) );
+ self->world->starmindist =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 4 ) );
+ self->world->stardist =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 5 ) );
+ self->world->starcolnoise =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 6 ) );
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -610,87 +638,98 @@ static PyObject *World_setStar(BPy_World *self, PyObject *args )
-static PyObject *World_getMist(BPy_World *self)
+static PyObject *World_getMist( BPy_World * self )
{
- PyObject *attr = PyList_New(0);
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't create list"));
- PyList_Append(attr, PyFloat_FromDouble(self->world->misi));
- PyList_Append(attr, PyFloat_FromDouble(self->world->miststa));
- PyList_Append(attr, PyFloat_FromDouble(self->world->mistdist));
- PyList_Append(attr, PyFloat_FromDouble(self->world->misthi));
+ PyObject *attr = PyList_New( 0 );
+ if( !attr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError, "couldn't create list" ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->misi ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->miststa ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->mistdist ) );
+ PyList_Append( attr, PyFloat_FromDouble( self->world->misthi ) );
return attr;
}
-static PyObject *World_setMist(BPy_World *self, PyObject *args )
-{
- PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
- if (PyList_Size(listargs)!=4)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
- self->world->misi = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->miststa = PyFloat_AsDouble(PyList_GetItem(listargs,1));
- self->world->mistdist = PyFloat_AsDouble(PyList_GetItem(listargs,2));
- self->world->misthi = PyFloat_AsDouble(PyList_GetItem(listargs,3));
- Py_INCREF(Py_None);
+static PyObject *World_setMist( BPy_World * self, PyObject * args )
+{
+ PyObject *listargs = 0;
+ if( !PyArg_ParseTuple( args, "O", &listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( !PyList_Check( listargs ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected list argument" ) );
+ if( PyList_Size( listargs ) != 4 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "wrong list size" ) );
+ self->world->misi = PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
+ self->world->miststa =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
+ self->world->mistdist =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
+ self->world->misthi =
+ PyFloat_AsDouble( PyList_GetItem( listargs, 3 ) );
+ Py_INCREF( Py_None );
return Py_None;
}
/* world.addScriptLink */
-static PyObject *World_addScriptLink (BPy_World *self, PyObject *args)
+static PyObject *World_addScriptLink( BPy_World * self, PyObject * args )
{
World *world = self->world;
ScriptLink *slink = NULL;
- slink = &(world)->scriptlink;
+ slink = &( world )->scriptlink;
- if (!EXPP_addScriptLink(slink, args, 0))
- return EXPP_incr_ret (Py_None);
- else return NULL;
+ if( !EXPP_addScriptLink( slink, args, 0 ) )
+ return EXPP_incr_ret( Py_None );
+ else
+ return NULL;
}
/* world.clearScriptLinks */
-static PyObject *World_clearScriptLinks (BPy_World *self)
+static PyObject *World_clearScriptLinks( BPy_World * self )
{
World *world = self->world;
ScriptLink *slink = NULL;
- slink = &(world)->scriptlink;
+ slink = &( world )->scriptlink;
- return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink)));
+ return EXPP_incr_ret( Py_BuildValue
+ ( "i", EXPP_clearScriptLinks( slink ) ) );
}
/* world.getScriptLinks */
-static PyObject *World_getScriptLinks (BPy_World *self, PyObject *args)
+static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args )
{
World *world = self->world;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
- slink = &(world)->scriptlink;
+ slink = &( world )->scriptlink;
- ret = EXPP_getScriptLinks(slink, args, 0);
+ ret = EXPP_getScriptLinks( slink, args, 0 );
- if (ret) return ret;
- else return NULL;
+ if( ret )
+ return ret;
+ else
+ return NULL;
}
/* world.makeActive */
-static PyObject *World_makeActive (BPy_World *self)
+static PyObject *World_makeActive( BPy_World * self )
{
World *world = self->world;
/* If there is a world then it now has one less user */
- if( G.scene->world)
+ if( G.scene->world )
G.scene->world->id.us--;
world->id.us++;
G.scene->world = world;
- Py_INCREF(Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
@@ -701,9 +740,9 @@ static PyObject *World_makeActive (BPy_World *self)
* \brief The World PyType destructor
*/
-static void World_DeAlloc (BPy_World *self)
+static void World_DeAlloc( BPy_World * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/**
@@ -713,19 +752,28 @@ static void World_DeAlloc (BPy_World *self)
* World PyObject data members. Ex. in Python: "print myworld.lens".
*/
-static PyObject *World_GetAttr (BPy_World *self, char *name)
-{
-
-if (strcmp (name, "name") == 0)return World_getName (self);
-if (strcmp (name, "skytype") == 0)return World_getSkytype (self);
-if (strcmp (name, "mode") == 0)return World_getMode (self);
-if (strcmp (name, "mistype") == 0)return World_getMistype (self);
-if (strcmp (name, "hor") == 0)return World_getHor (self);
-if (strcmp (name, "zen") == 0)return World_getZen (self);
-if (strcmp (name, "amb") == 0)return World_getAmb (self);
-if (strcmp (name, "star") == 0)return World_getStar (self);
-if (strcmp (name, "mist") == 0)return World_getMist (self);
- return Py_FindMethod(BPy_World_methods, (PyObject *)self, name);
+static PyObject *World_GetAttr( BPy_World * self, char *name )
+{
+
+ if( strcmp( name, "name" ) == 0 )
+ return World_getName( self );
+ if( strcmp( name, "skytype" ) == 0 )
+ return World_getSkytype( self );
+ if( strcmp( name, "mode" ) == 0 )
+ return World_getMode( self );
+ if( strcmp( name, "mistype" ) == 0 )
+ return World_getMistype( self );
+ if( strcmp( name, "hor" ) == 0 )
+ return World_getHor( self );
+ if( strcmp( name, "zen" ) == 0 )
+ return World_getZen( self );
+ if( strcmp( name, "amb" ) == 0 )
+ return World_getAmb( self );
+ if( strcmp( name, "star" ) == 0 )
+ return World_getStar( self );
+ if( strcmp( name, "mist" ) == 0 )
+ return World_getMist( self );
+ return Py_FindMethod( BPy_World_methods, ( PyObject * ) self, name );
}
/**
@@ -735,23 +783,32 @@ if (strcmp (name, "mist") == 0)return World_getMist (self);
* World data member. Ex. in Python: "myworld.lens = 45.0".
*/
-static int World_SetAttr (BPy_World *self, char *name, PyObject *value)
-{
- PyObject *valtuple = Py_BuildValue("(O)", value);
-
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "WorldSetAttr: couldn't parse args");
- if (strcmp (name, "name") == 0) World_setName (self,valtuple);
-if (strcmp (name, "skytype") == 0) World_setSkytype (self,valtuple);
-if (strcmp (name, "mode") == 0) World_setMode (self,valtuple);
-if (strcmp (name, "mistype") == 0) World_setMistype (self,valtuple);
-if (strcmp (name, "hor") == 0) World_setHor (self,valtuple);
-if (strcmp (name, "zen") == 0) World_setZen (self,valtuple);
-if (strcmp (name, "amb") == 0) World_setAmb (self,valtuple);
-if (strcmp (name, "star") == 0) World_setStar (self,valtuple);
-if (strcmp (name, "mist") == 0) World_setMist (self,valtuple);
-return 0; /* normal exit */
+static int World_SetAttr( BPy_World * self, char *name, PyObject * value )
+{
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
+
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "WorldSetAttr: couldn't parse args" );
+ if( strcmp( name, "name" ) == 0 )
+ World_setName( self, valtuple );
+ if( strcmp( name, "skytype" ) == 0 )
+ World_setSkytype( self, valtuple );
+ if( strcmp( name, "mode" ) == 0 )
+ World_setMode( self, valtuple );
+ if( strcmp( name, "mistype" ) == 0 )
+ World_setMistype( self, valtuple );
+ if( strcmp( name, "hor" ) == 0 )
+ World_setHor( self, valtuple );
+ if( strcmp( name, "zen" ) == 0 )
+ World_setZen( self, valtuple );
+ if( strcmp( name, "amb" ) == 0 )
+ World_setAmb( self, valtuple );
+ if( strcmp( name, "star" ) == 0 )
+ World_setStar( self, valtuple );
+ if( strcmp( name, "mist" ) == 0 )
+ World_setMist( self, valtuple );
+ return 0; /* normal exit */
}
/**
@@ -765,10 +822,10 @@ return 0; /* normal exit */
* comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
*/
-static int World_Compare (BPy_World *a, BPy_World *b)
+static int World_Compare( BPy_World * a, BPy_World * b )
{
World *pa = a->world, *pb = b->world;
- return (pa == pb) ? 0:-1;
+ return ( pa == pb ) ? 0 : -1;
}
/**
@@ -793,9 +850,10 @@ static int World_Print(BPy_World *self, FILE *fp, int flags)
* Python. Repr gives a string representation of a PyObject.
*/
-static PyObject *World_Repr (BPy_World *self)
+static PyObject *World_Repr( BPy_World * self )
{
- return PyString_FromFormat("[World \"%s\"]", self->world->id.name+2);
+ return PyString_FromFormat( "[World \"%s\"]",
+ self->world->id.name + 2 );
}
/*@}*/
@@ -806,59 +864,55 @@ static int World_compare (BPy_World *a, BPy_World *b)
return (pa == pb) ? 0:-1;
}
*/
-PyObject* World_CreatePyObject (struct World *world)
+PyObject *World_CreatePyObject( struct World * world )
{
- BPy_World * blen_object;
+ BPy_World *blen_object;
- blen_object = (BPy_World*)PyObject_NEW (BPy_World, &World_Type);
+ blen_object = ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
- if (blen_object == NULL)
- {
- return (NULL);
- }
- blen_object->world = world;
- return ((PyObject*)blen_object);
+ if( blen_object == NULL ) {
+ return ( NULL );
+ }
+ blen_object->world = world;
+ return ( ( PyObject * ) blen_object );
}
-int World_CheckPyObject (PyObject *py_obj)
+int World_CheckPyObject( PyObject * py_obj )
{
-return (py_obj->ob_type == &World_Type);
+ return ( py_obj->ob_type == &World_Type );
}
-World* World_FromPyObject (PyObject *py_obj)
+World *World_FromPyObject( PyObject * py_obj )
{
- BPy_World * blen_obj;
+ BPy_World *blen_obj;
- blen_obj = (BPy_World*)py_obj;
- return (blen_obj->world);
+ blen_obj = ( BPy_World * ) py_obj;
+ return ( blen_obj->world );
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
-World * GetWorldByName (char * name)
+World *GetWorldByName( char *name )
{
- World * world_iter;
+ World *world_iter;
world_iter = G.main->world.first;
- while (world_iter)
- {
- if (StringEqual (name, GetIdName (&(world_iter->id))))
- {
- return (world_iter);
+ while( world_iter ) {
+ if( StringEqual( name, GetIdName( &( world_iter->id ) ) ) ) {
+ return ( world_iter );
}
world_iter = world_iter->id.next;
}
/* There is no object with the given name */
- return (NULL);
+ return ( NULL );
}
-
diff --git a/source/blender/python/api2_2x/World.h b/source/blender/python/api2_2x/World.h
index d7c99ac9231..ed9968480d7 100644
--- a/source/blender/python/api2_2x/World.h
+++ b/source/blender/python/api2_2x/World.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -44,10 +45,10 @@
/*****************************************************************************/
/* Python API function prototypes for the World module. */
/*****************************************************************************/
-static PyObject *M_World_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_World_Get (PyObject *self, PyObject *args);
-static PyObject *M_World_GetActive (PyObject *self);
+static PyObject *M_World_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_World_Get( PyObject * self, PyObject * args );
+static PyObject *M_World_GetActive( PyObject * self );
/*****************************************************************************/
@@ -55,16 +56,16 @@ static PyObject *M_World_GetActive (PyObject *self);
/* In Python these will be written to the console when doing a */
/* Blender.World.__doc__ */
/*****************************************************************************/
-static char M_World_doc[] =
-"The Blender World module\n\n\
+static char M_World_doc[] = "The Blender World module\n\n\
This module provides access to **World Data** objects in Blender\n\n";
-static char M_World_New_doc[] ="() - return a new World object";
+static char M_World_New_doc[] = "() - return a new World object";
-static char M_World_Get_doc[] ="(name) - return the world with the name 'name', \
+static char M_World_Get_doc[] =
+ "(name) - return the world with the name 'name', \
returns None if not found.\n If 'name' is not specified, \
it returns a list of all worlds in the\ncurrent scene.";
-static char M_World_GetActive_doc[] ="() - returns the current world, or \
+static char M_World_GetActive_doc[] = "() - returns the current world, or \
None if the Scene has no world";
@@ -73,109 +74,115 @@ None if the Scene has no world";
/* Python method structure definition for Blender.World module: */
/*****************************************************************************/
struct PyMethodDef M_World_methods[] = {
- {"New",(PyCFunction)M_World_New, METH_VARARGS|METH_KEYWORDS,M_World_New_doc},
- {"Get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {"GetActive", (PyCFunction)M_World_GetActive, METH_NOARGS, M_World_GetActive_doc },
- {"get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {NULL, NULL, 0, NULL}
+ {"New", ( PyCFunction ) M_World_New, METH_VARARGS | METH_KEYWORDS,
+ M_World_New_doc},
+ {"Get", M_World_Get, METH_VARARGS, M_World_Get_doc},
+ {"GetActive", ( PyCFunction ) M_World_GetActive, METH_NOARGS,
+ M_World_GetActive_doc},
+ {"get", M_World_Get, METH_VARARGS, M_World_Get_doc},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python BPy_World methods declarations: */
/*****************************************************************************/
-static PyObject *World_getRange(BPy_World *self);
-static PyObject *World_setRange(BPy_World *self, PyObject *args);
-static PyObject *World_getIpo(BPy_World *self);
-static PyObject *World_setIpo(BPy_World *self, PyObject *args);
-static PyObject *World_clearIpo(BPy_World *self);
-static PyObject *World_getName(BPy_World *self);
-static PyObject *World_setName(BPy_World *self, PyObject *args);
-static PyObject *World_getSkytype(BPy_World *self);
-static PyObject *World_setSkytype(BPy_World *self, PyObject *args );
-static PyObject *World_getMistype(BPy_World *self);
-static PyObject *World_setMistype(BPy_World *self, PyObject *args );
-static PyObject *World_getHor(BPy_World *self);
-static PyObject *World_setHor(BPy_World *self, PyObject *args );
-static PyObject *World_getZen(BPy_World *self);
-static PyObject *World_setZen(BPy_World *self, PyObject *args );
-static PyObject *World_getAmb(BPy_World *self);
-static PyObject *World_setAmb(BPy_World *self, PyObject *args );
-static PyObject *World_getStar(BPy_World *self);
-static PyObject *World_setStar(BPy_World *self, PyObject *args );
-static PyObject *World_getMist(BPy_World *self);
-static PyObject *World_setMist(BPy_World *self, PyObject *args );
-static PyObject *World_getScriptLinks(BPy_World *self, PyObject *args);
-static PyObject *World_addScriptLink(BPy_World *self, PyObject *args);
-static PyObject *World_clearScriptLinks(BPy_World *self);
+static PyObject *World_getRange( BPy_World * self );
+static PyObject *World_setRange( BPy_World * self, PyObject * args );
+static PyObject *World_getIpo( BPy_World * self );
+static PyObject *World_setIpo( BPy_World * self, PyObject * args );
+static PyObject *World_clearIpo( BPy_World * self );
+static PyObject *World_getName( BPy_World * self );
+static PyObject *World_setName( BPy_World * self, PyObject * args );
+static PyObject *World_getSkytype( BPy_World * self );
+static PyObject *World_setSkytype( BPy_World * self, PyObject * args );
+static PyObject *World_getMistype( BPy_World * self );
+static PyObject *World_setMistype( BPy_World * self, PyObject * args );
+static PyObject *World_getHor( BPy_World * self );
+static PyObject *World_setHor( BPy_World * self, PyObject * args );
+static PyObject *World_getZen( BPy_World * self );
+static PyObject *World_setZen( BPy_World * self, PyObject * args );
+static PyObject *World_getAmb( BPy_World * self );
+static PyObject *World_setAmb( BPy_World * self, PyObject * args );
+static PyObject *World_getStar( BPy_World * self );
+static PyObject *World_setStar( BPy_World * self, PyObject * args );
+static PyObject *World_getMist( BPy_World * self );
+static PyObject *World_setMist( BPy_World * self, PyObject * args );
+static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args );
+static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
+static PyObject *World_clearScriptLinks( BPy_World * self );
+static PyObject *World_makeActive( BPy_World * self );
/*****************************************************************************/
/* Python BPy_World methods table: */
/*****************************************************************************/
static PyMethodDef BPy_World_methods[] = {
- {"getRange", (PyCFunction)World_getRange, METH_NOARGS,
- "() - Return World Range"},
- {"setRange", (PyCFunction)World_setRange, METH_VARARGS,
- "() - Change this World's range"},
- {"getIpo", (PyCFunction)World_getIpo, METH_NOARGS,
- "() - Return World Ipo"},
- {"setIpo", (PyCFunction)World_setIpo, METH_VARARGS,
- "() - Change this World's ipo"},
- {"clearIpo", (PyCFunction)World_clearIpo, METH_VARARGS,
- "() - Unlink Ipo from this World"},
- {"getName", (PyCFunction)World_getName, METH_NOARGS,
- "() - Return World Data name"},
- {"setName", (PyCFunction)World_setName, METH_VARARGS,
- "() - Return World Data name"},
- {"getSkytype", (PyCFunction)World_getSkytype, METH_NOARGS,
- "() - Return World Data skytype"},
- {"setSkytype", (PyCFunction)World_setSkytype, METH_VARARGS,
- "() - Return World Data skytype"},
- {"getMistype", (PyCFunction)World_getMistype, METH_NOARGS,
- "() - Return World Data mistype"},
- {"setMistype", (PyCFunction)World_setMistype, METH_VARARGS,
- "() - Return World Data mistype"},
- {"getHor", (PyCFunction)World_getHor, METH_NOARGS,
- "() - Return World Data hor"},
- {"setHor", (PyCFunction)World_setHor, METH_VARARGS,
- "() - Return World Data hor"},
- {"getZen", (PyCFunction)World_getZen, METH_NOARGS,
- "() - Return World Data zen"},
- {"setZen", (PyCFunction)World_setZen, METH_VARARGS,
- "() - Return World Data zen"},
- {"getAmb", (PyCFunction)World_getAmb, METH_NOARGS,
- "() - Return World Data amb"},
- {"setAmb", (PyCFunction)World_setAmb, METH_VARARGS,
- "() - Return World Data amb"},
- {"getStar", (PyCFunction)World_getStar, METH_NOARGS,
- "() - Return World Data star"},
- {"setStar", (PyCFunction)World_setStar, METH_VARARGS,
- "() - Return World Data star"},
- {"getMist", (PyCFunction)World_getMist, METH_NOARGS,
- "() - Return World Data mist"},
- {"setMist", (PyCFunction)World_setMist, METH_VARARGS,
- "() - Return World Data mist"},
- {"getScriptLinks", (PyCFunction)World_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this world's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", (PyCFunction)World_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new world scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", (PyCFunction)World_clearScriptLinks, METH_NOARGS,
- "() - Delete all scriptlinks from this world :)."},
- {NULL, NULL, 0, NULL}
+ {"getRange", ( PyCFunction ) World_getRange, METH_NOARGS,
+ "() - Return World Range"},
+ {"setRange", ( PyCFunction ) World_setRange, METH_VARARGS,
+ "() - Change this World's range"},
+ {"getIpo", ( PyCFunction ) World_getIpo, METH_NOARGS,
+ "() - Return World Ipo"},
+ {"setIpo", ( PyCFunction ) World_setIpo, METH_VARARGS,
+ "() - Change this World's ipo"},
+ {"clearIpo", ( PyCFunction ) World_clearIpo, METH_VARARGS,
+ "() - Unlink Ipo from this World"},
+ {"getName", ( PyCFunction ) World_getName, METH_NOARGS,
+ "() - Return World Data name"},
+ {"setName", ( PyCFunction ) World_setName, METH_VARARGS,
+ "() - Return World Data name"},
+ {"getSkytype", ( PyCFunction ) World_getSkytype, METH_NOARGS,
+ "() - Return World Data skytype"},
+ {"setSkytype", ( PyCFunction ) World_setSkytype, METH_VARARGS,
+ "() - Return World Data skytype"},
+ {"getMistype", ( PyCFunction ) World_getMistype, METH_NOARGS,
+ "() - Return World Data mistype"},
+ {"setMistype", ( PyCFunction ) World_setMistype, METH_VARARGS,
+ "() - Return World Data mistype"},
+ {"getHor", ( PyCFunction ) World_getHor, METH_NOARGS,
+ "() - Return World Data hor"},
+ {"setHor", ( PyCFunction ) World_setHor, METH_VARARGS,
+ "() - Return World Data hor"},
+ {"getZen", ( PyCFunction ) World_getZen, METH_NOARGS,
+ "() - Return World Data zen"},
+ {"setZen", ( PyCFunction ) World_setZen, METH_VARARGS,
+ "() - Return World Data zen"},
+ {"getAmb", ( PyCFunction ) World_getAmb, METH_NOARGS,
+ "() - Return World Data amb"},
+ {"setAmb", ( PyCFunction ) World_setAmb, METH_VARARGS,
+ "() - Return World Data amb"},
+ {"getStar", ( PyCFunction ) World_getStar, METH_NOARGS,
+ "() - Return World Data star"},
+ {"setStar", ( PyCFunction ) World_setStar, METH_VARARGS,
+ "() - Return World Data star"},
+ {"getMist", ( PyCFunction ) World_getMist, METH_NOARGS,
+ "() - Return World Data mist"},
+ {"setMist", ( PyCFunction ) World_setMist, METH_VARARGS,
+ "() - Return World Data mist"},
+ {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this world's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) World_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new world scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) World_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this world :)."},
+ {"makeActive", ( PyCFunction ) World_makeActive, METH_NOARGS,
+ "() - Makes this world the active world for the current scene."},
+ {NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python World_Type helper functions needed by Blender (the Init function) */
/* and Object modules. */
/*****************************************************************************/
-PyObject *World_Init (void);
-PyObject *World_CreatePyObject (World *world);
-World *World_FromPyObject (PyObject *pyobj);
-int World_CheckPyObject (PyObject *pyobj);
+PyObject *World_Init( void );
+PyObject *World_CreatePyObject( World * world );
+World *World_FromPyObject( PyObject * pyobj );
+int World_CheckPyObject( PyObject * pyobj );
-#endif /* EXPP_WORLD_H */
+#endif /* EXPP_WORLD_H */
diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h
index b7a084f2c3a..2c409d4ab78 100644
--- a/source/blender/python/api2_2x/bpy_types.h
+++ b/source/blender/python/api2_2x/bpy_types.h
@@ -53,13 +53,11 @@ extern PyTypeObject Camera_Type;
((v)->ob_type == &Camera_Type) /* for type checking */
/* Python BPy_Camera structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Camera * camera;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Camera * camera;
-}
-BPy_Camera;
+} BPy_Camera;
/*****************************************************************************/
/* Lamp Data */
@@ -70,13 +68,11 @@ extern PyTypeObject Lamp_Type;
((v)->ob_type == &Lamp_Type) /* for type checking */
/* Python BPy_Lamp structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Lamp * lamp;
- BPy_rgbTuple *color;
-}
-BPy_Lamp;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Lamp * lamp;
+ BPy_rgbTuple *color;
+} BPy_Lamp;
/*****************************************************************************/
/* Ipo Data */
@@ -86,12 +82,10 @@ extern PyTypeObject Ipo_Type;
#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */
/* Python BPy_Ipo structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Ipo * ipo;
-}
-BPy_Ipo;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Ipo * ipo;
+} BPy_Ipo;
/*****************************************************************************/
/* Metaball Data */
@@ -101,12 +95,10 @@ extern PyTypeObject Metaball_Type;
#define BPy_Metaball_Check(v) ((v)->ob_type==&Metaball_Type)
/* Python BPy_Metaball structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- MetaBall * metaball;
-}
-BPy_Metaball;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ MetaBall * metaball;
+} BPy_Metaball;
/*****************************************************************************/
/* Metaelem Data */
@@ -116,12 +108,10 @@ extern PyTypeObject Metaelem_Type;
#define BPy_Metaelem_Check(v) ((v)->ob_type==&Metaelem_Type)
/* Python BPy_Metaelem structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- MetaElem * metaelem;
-}
-BPy_Metaelem;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ MetaElem * metaelem;
+} BPy_Metaelem;
/*****************************************************************************/
/* Effect Data */
@@ -131,12 +121,10 @@ extern PyTypeObject Effect_Type;
#define BPy_Effect_Check(v) ((v)->ob_type==&Effect_Type)
/* Python BPy_Effect structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Effect * effect;
-}
-BPy_Effect;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * effect;
+} BPy_Effect;
/*****************************************************************************/
/* Wave Data */
@@ -146,12 +134,10 @@ extern PyTypeObject Wave_Type;
#define BPy_Wave_Check(v) ((v)->ob_type==&Wave_Type)
/* Python BPy_Wave structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Effect * wave;
-}
-BPy_Wave;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * wave;
+} BPy_Wave;
/*****************************************************************************/
/* Build Data */
@@ -161,12 +147,10 @@ extern PyTypeObject Build_Type;
#define BPy_Build_Check(v) ((v)->ob_type==&Build_Type)
/* Python BPy_Build structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Effect * build;
-}
-BPy_Build;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * build;
+} BPy_Build;
/*****************************************************************************/
/* Particle Data */
@@ -176,12 +160,10 @@ extern PyTypeObject Particle_Type;
#define BPy_Particle_Check(v) ((v)->ob_type==&Particle_Type)
/* Python BPy_Particle structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- Effect * particle;
-}
-BPy_Particle;
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * particle;
+} BPy_Particle;
/*****************************************************************************/
/* Curve Data */
@@ -191,14 +173,12 @@ extern PyTypeObject Curve_Type;
#define BPy_Curve_Check(v) ((v)->ob_type==&Curve_Type)
/* Python BPy_Curve structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
+typedef struct {
+ PyObject_HEAD /* required py macro */
Curve * curve;
/* pointer for iterator: does not point to owned memory */
Nurb *iter_pointer;
-}
-BPy_Curve;
+} BPy_Curve;
/**********
CurNurb data
@@ -214,10 +194,10 @@ typedef struct {
Nurb * nurb; /* pointer to Blender data */
/* iterator stuff */
- /* internal ptrs to point data. do not free */
+ /* internal ptrs to point data. do not free */
BPoint *bp;
BezTriple *bezt;
- int atEnd; /* iter exhausted flag */
+ int atEnd; /* iter exhausted flag */
int nextPoint;
} BPy_CurNurb;
@@ -231,11 +211,9 @@ extern PyTypeObject World_Type;
#define BPy_World_Check(v) ((v)->ob_type==&World_Type)
/* Python BPy_World structure definition */
-typedef struct
-{
- PyObject_HEAD /* required py macro */
- World * world;
-}
-BPy_World;
-
-#endif /* EXPP_bpy_types_h */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ World * world;
+} BPy_World;
+
+#endif /* EXPP_bpy_types_h */
diff --git a/source/blender/python/api2_2x/charRGBA.c b/source/blender/python/api2_2x/charRGBA.c
index 032df56920c..690361eed5d 100644
--- a/source/blender/python/api2_2x/charRGBA.c
+++ b/source/blender/python/api2_2x/charRGBA.c
@@ -36,91 +36,90 @@
Blender */
/*****************************************************************************/
-/* Python charRGBA_Type callback function prototypes: */
+/* Python charRGBA_Type callback function prototypes: */
/*****************************************************************************/
-static void charRGBA_dealloc (BPy_charRGBA *self);
-static PyObject *charRGBA_getAttr (BPy_charRGBA *self, char *name);
-static int charRGBA_setAttr (BPy_charRGBA *self, char *name, PyObject *v);
-static PyObject *charRGBA_repr (BPy_charRGBA *self);
+static void charRGBA_dealloc( BPy_charRGBA * self );
+static PyObject *charRGBA_getAttr( BPy_charRGBA * self, char *name );
+static int charRGBA_setAttr( BPy_charRGBA * self, char *name, PyObject * v );
+static PyObject *charRGBA_repr( BPy_charRGBA * self );
-static int charRGBALength(BPy_charRGBA *self);
+static int charRGBALength( BPy_charRGBA * self );
-static PyObject *charRGBASubscript(BPy_charRGBA *self, PyObject *key);
-static int charRGBAAssSubscript(BPy_charRGBA *self, PyObject *who,
- PyObject *cares);
+static PyObject *charRGBASubscript( BPy_charRGBA * self, PyObject * key );
+static int charRGBAAssSubscript( BPy_charRGBA * self, PyObject * who,
+ PyObject * cares );
-static PyObject *charRGBAItem(BPy_charRGBA *self, int i);
-static int charRGBAAssItem(BPy_charRGBA *self, int i, PyObject *ob);
-static PyObject *charRGBASlice(BPy_charRGBA *self, int begin, int end);
-static int charRGBAAssSlice(BPy_charRGBA *self, int begin, int end,
- PyObject *seq);
+static PyObject *charRGBAItem( BPy_charRGBA * self, int i );
+static int charRGBAAssItem( BPy_charRGBA * self, int i, PyObject * ob );
+static PyObject *charRGBASlice( BPy_charRGBA * self, int begin, int end );
+static int charRGBAAssSlice( BPy_charRGBA * self, int begin, int end,
+ PyObject * seq );
/*****************************************************************************/
-/* Python charRGBA_Type Mapping Methods table: */
+/* Python charRGBA_Type Mapping Methods table: */
/*****************************************************************************/
-static PyMappingMethods charRGBAAsMapping =
-{
- (inquiry)charRGBALength, /* mp_length */
- (binaryfunc)charRGBASubscript, /* mp_subscript */
- (objobjargproc)charRGBAAssSubscript, /* mp_ass_subscript */
+static PyMappingMethods charRGBAAsMapping = {
+ ( inquiry ) charRGBALength, /* mp_length */
+ ( binaryfunc ) charRGBASubscript, /* mp_subscript */
+ ( objobjargproc ) charRGBAAssSubscript, /* mp_ass_subscript */
};
/*****************************************************************************/
-/* Python charRGBA_Type Sequence Methods table: */
+/* Python charRGBA_Type Sequence Methods table: */
/*****************************************************************************/
-static PySequenceMethods charRGBAAsSequence =
-{
- (inquiry) charRGBALength, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) charRGBAItem, /* sq_item */
- (intintargfunc) charRGBASlice, /* sq_slice */
- (intobjargproc) charRGBAAssItem, /* sq_ass_item */
- (intintobjargproc) charRGBAAssSlice, /* sq_ass_slice */
+static PySequenceMethods charRGBAAsSequence = {
+ ( inquiry ) charRGBALength, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) charRGBAItem, /* sq_item */
+ ( intintargfunc ) charRGBASlice, /* sq_slice */
+ ( intobjargproc ) charRGBAAssItem, /* sq_ass_item */
+ ( intintobjargproc ) charRGBAAssSlice, /* sq_ass_slice */
};
/*****************************************************************************/
-/* Python charRGBA_Type structure definition: */
+/* Python charRGBA_Type structure definition: */
/*****************************************************************************/
-PyTypeObject charRGBA_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "charRGBA", /* tp_name */
- sizeof (BPy_charRGBA), /* tp_basicsize */
- 0, /* tp_itemsize */
+PyTypeObject charRGBA_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "charRGBA", /* tp_name */
+ sizeof( BPy_charRGBA ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)charRGBA_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)charRGBA_getAttr, /* tp_getattr */
- (setattrfunc)charRGBA_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)charRGBA_repr, /* tp_repr */
- 0, /* tp_as_number */
- &charRGBAAsSequence, /* tp_as_sequence */
- &charRGBAAsMapping, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- 0, /* tp_methods */
- 0, /* tp_members */
+ ( destructor ) charRGBA_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) charRGBA_getAttr, /* tp_getattr */
+ ( setattrfunc ) charRGBA_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) charRGBA_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ &charRGBAAsSequence, /* tp_as_sequence */
+ &charRGBAAsMapping, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_doc */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
-/* Function: charRGBA_New */
+/* Function: charRGBA_New */
/*****************************************************************************/
-PyObject *charRGBA_New(char *rgba)
+PyObject *charRGBA_New( char *rgba )
{
BPy_charRGBA *charRGBA;
charRGBA_Type.ob_type = &PyType_Type;
- charRGBA = (BPy_charRGBA *)PyObject_NEW(BPy_charRGBA, &charRGBA_Type);
+ charRGBA =
+ ( BPy_charRGBA * ) PyObject_NEW( BPy_charRGBA,
+ &charRGBA_Type );
- if (charRGBA == NULL)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create charRGBA object");
+ if( charRGBA == NULL )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create charRGBA object" );
/* rgba is a pointer to the first item of a char[4] array */
charRGBA->rgba[0] = &rgba[0];
@@ -128,271 +127,295 @@ PyObject *charRGBA_New(char *rgba)
charRGBA->rgba[2] = &rgba[2];
charRGBA->rgba[3] = &rgba[3];
- return (PyObject *)charRGBA;
+ return ( PyObject * ) charRGBA;
}
/*****************************************************************************/
-/* Functions: charRGBA_getCol and charRGBA_setCol */
-/* Description: These functions get/set rgba color triplet values. The */
-/* get function returns a tuple, the set one accepts three */
-/* chars (separated or in a tuple) as arguments. */
+/* Functions: charRGBA_getCol and charRGBA_setCol */
+/* Description: These functions get/set rgba color triplet values. The */
+/* get function returns a tuple, the set one accepts three */
+/* chars (separated or in a tuple) as arguments. */
/*****************************************************************************/
-PyObject *charRGBA_getCol (BPy_charRGBA *self)
+PyObject *charRGBA_getCol( BPy_charRGBA * self )
{
- PyObject *list = PyList_New (4);
+ PyObject *list = PyList_New( 4 );
- if (!list) return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList");
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- PyList_SET_ITEM (list, 0, Py_BuildValue ("b", *(self->rgba[0]) ));
- PyList_SET_ITEM (list, 1, Py_BuildValue ("b", *(self->rgba[1]) ));
- PyList_SET_ITEM (list, 2, Py_BuildValue ("b", *(self->rgba[2]) ));
- PyList_SET_ITEM (list, 3, Py_BuildValue ("b", *(self->rgba[3]) ));
+ PyList_SET_ITEM( list, 0, Py_BuildValue( "b", *( self->rgba[0] ) ) );
+ PyList_SET_ITEM( list, 1, Py_BuildValue( "b", *( self->rgba[1] ) ) );
+ PyList_SET_ITEM( list, 2, Py_BuildValue( "b", *( self->rgba[2] ) ) );
+ PyList_SET_ITEM( list, 3, Py_BuildValue( "b", *( self->rgba[3] ) ) );
return list;
}
-PyObject *charRGBA_setCol (BPy_charRGBA *self, PyObject *args)
+PyObject *charRGBA_setCol( BPy_charRGBA * self, PyObject * args )
{
int ok;
char r = 0, g = 0, b = 0, a = 0;
- if (PyObject_Length (args) == 4)
- ok = PyArg_ParseTuple (args, "bbbb", &r, &g, &b, &a);
+ if( PyObject_Length( args ) == 4 )
+ ok = PyArg_ParseTuple( args, "bbbb", &r, &g, &b, &a );
- else ok = PyArg_ParseTuple (args, "|(bbbb)", &r, &g, &b, &a);
+ else
+ ok = PyArg_ParseTuple( args, "|(bbbb)", &r, &g, &b, &a );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected 1-byte ints [b,b,b,b] or b,b,b,b as arguments (or nothing)");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected 1-byte ints [b,b,b,b] or b,b,b,b as arguments (or nothing)" );
- *(self->rgba[0]) = EXPP_ClampInt (r, 0, 255);
- *(self->rgba[1]) = EXPP_ClampInt (g, 0, 255);
- *(self->rgba[2]) = EXPP_ClampInt (b, 0, 255);
- *(self->rgba[3]) = EXPP_ClampInt (a, 0, 255);
+ *( self->rgba[0] ) = EXPP_ClampInt( r, 0, 255 );
+ *( self->rgba[1] ) = EXPP_ClampInt( g, 0, 255 );
+ *( self->rgba[2] ) = EXPP_ClampInt( b, 0, 255 );
+ *( self->rgba[3] ) = EXPP_ClampInt( a, 0, 255 );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/*****************************************************************************/
-/* Function: charRGBA_dealloc */
+/* Function: charRGBA_dealloc */
/* Description: This is a callback function for the BPy_charRGBA type. It is */
-/* the destructor function. */
+/* the destructor function. */
/*****************************************************************************/
-static void charRGBA_dealloc (BPy_charRGBA *self)
+static void charRGBA_dealloc( BPy_charRGBA * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
-/* Function: charRGBA_getAttr */
+/* Function: charRGBA_getAttr */
/* Description: This is a callback function for the BPy_charRGBA type. It is */
-/* the function that accesses BPy_charRGBA member variables and */
-/* methods. */
+/* the function that accesses BPy_charRGBA member variables and */
+/* methods. */
/*****************************************************************************/
-static PyObject* charRGBA_getAttr (BPy_charRGBA *self, char *name)
+static PyObject *charRGBA_getAttr( BPy_charRGBA * self, char *name )
{
int i;
- if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s,s]", "R", "G", "B", "A");
-
- else if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
- else if (!strcmp(name, "A") || !strcmp(name, "a")) i = 3;
+ if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s,s]", "R", "G", "B", "A" );
+
+ else if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
+ else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
+ i = 3;
else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "attribute not found"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "attribute not found" ) );
- return Py_BuildValue("b", *(self->rgba[i]));
+ return Py_BuildValue( "b", *( self->rgba[i] ) );
}
/*****************************************************************************/
-/* Function: charRGBA_setAttr */
+/* Function: charRGBA_setAttr */
/* Description: This is a callback function for the BPy_charRGBA type. It is */
-/* the function that changes BPy_charRGBA member variables. */
+/* the function that changes BPy_charRGBA member variables. */
/*****************************************************************************/
-static int charRGBA_setAttr (BPy_charRGBA *self, char *name, PyObject *v)
+static int charRGBA_setAttr( BPy_charRGBA * self, char *name, PyObject * v )
{
char value;
- if (!PyArg_Parse (v, "b", &value))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected char argument");
+ if( !PyArg_Parse( v, "b", &value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected char argument" );
- value = EXPP_ClampInt(value, 0, 255);
+ value = EXPP_ClampInt( value, 0, 255 );
- if (!strcmp(name, "R") || !strcmp(name, "r"))
- *(self->rgba[0]) = value;
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ *( self->rgba[0] ) = value;
- else if (!strcmp(name, "G") || !strcmp(name, "g"))
- *(self->rgba[1]) = value;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ *( self->rgba[1] ) = value;
- else if (!strcmp(name, "B") || !strcmp(name, "b"))
- *(self->rgba[2]) = value;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ *( self->rgba[2] ) = value;
- else if (!strcmp(name, "A") || !strcmp(name, "a"))
- *(self->rgba[3]) = value;
+ else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
+ *( self->rgba[3] ) = value;
- else return (EXPP_ReturnIntError (PyExc_AttributeError,
- "attribute not found"));
+ else
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "attribute not found" ) );
return 0;
}
/*****************************************************************************/
-/* Section: charRGBA as Mapping */
-/* These functions provide code to access charRGBA objects as */
-/* mappings. */
+/* Section: charRGBA as Mapping */
+/* These functions provide code to access charRGBA objects as */
+/* mappings. */
/*****************************************************************************/
-static int charRGBALength(BPy_charRGBA *self)
+static int charRGBALength( BPy_charRGBA * self )
{
return 4;
}
-static PyObject *charRGBASubscript(BPy_charRGBA *self, PyObject *key)
+static PyObject *charRGBASubscript( BPy_charRGBA * self, PyObject * key )
{
char *name = NULL;
int i;
- if (PyNumber_Check(key)) return charRGBAItem(self, (int)PyInt_AsLong(key));
-
- if (!PyArg_ParseTuple(key, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int or string argument");
-
- if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
- else if (!strcmp(name, "A") || !strcmp(name, "a")) i = 3;
+ if( PyNumber_Check( key ) )
+ return charRGBAItem( self, ( int ) PyInt_AsLong( key ) );
+
+ if( !PyArg_ParseTuple( key, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int or string argument" );
+
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
+ else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
+ i = 3;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError, name);
+ return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
- return Py_BuildValue("b", *(self->rgba[i]));
+ return Py_BuildValue( "b", *( self->rgba[i] ) );
}
-static int charRGBAAssSubscript(BPy_charRGBA *self, PyObject *key, PyObject *v)
+static int charRGBAAssSubscript( BPy_charRGBA * self, PyObject * key,
+ PyObject * v )
{
char *name = NULL;
int i;
- if (!PyNumber_Check(v)) return EXPP_ReturnIntError(PyExc_TypeError,
- "value to assign must be a number");
-
- if (PyNumber_Check(key))
- return charRGBAAssItem(self, (int)PyInt_AsLong(key), v);
-
- if (!PyArg_Parse(key, "s", &name))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected int or string argument");
-
- if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
- else if (!strcmp(name, "A") || !strcmp(name, "a")) i = 3;
+ if( !PyNumber_Check( v ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "value to assign must be a number" );
+
+ if( PyNumber_Check( key ) )
+ return charRGBAAssItem( self, ( int ) PyInt_AsLong( key ), v );
+
+ if( !PyArg_Parse( key, "s", &name ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int or string argument" );
+
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
+ else if( !strcmp( name, "A" ) || !strcmp( name, "a" ) )
+ i = 3;
else
- return EXPP_ReturnIntError (PyExc_AttributeError, name);
+ return EXPP_ReturnIntError( PyExc_AttributeError, name );
- *(self->rgba[i]) = EXPP_ClampInt(PyInt_AsLong(v), 0, 255);
+ *( self->rgba[i] ) = EXPP_ClampInt( PyInt_AsLong( v ), 0, 255 );
return 0;
}
/*****************************************************************************/
-/* Section: charRGBA as Sequence */
-/* These functions provide code to access charRGBA objects as */
-/* sequences. */
+/* Section: charRGBA as Sequence */
+/* These functions provide code to access charRGBA objects as */
+/* sequences. */
/*****************************************************************************/
-static PyObject *charRGBAItem(BPy_charRGBA *self, int i)
+static PyObject *charRGBAItem( BPy_charRGBA * self, int i )
{
- if (i < 0 || i >= 4)
- return EXPP_ReturnPyObjError (PyExc_IndexError,
- "array index out of range");
+ if( i < 0 || i >= 4 )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range" );
- return Py_BuildValue("b", *(self->rgba[i]));
+ return Py_BuildValue( "b", *( self->rgba[i] ) );
}
-static PyObject *charRGBASlice(BPy_charRGBA *self, int begin, int end)
+static PyObject *charRGBASlice( BPy_charRGBA * self, int begin, int end )
{
PyObject *list;
int count;
- if (begin < 0) begin = 0;
- if (end > 4) end = 4;
- if (begin > end) begin = end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > 4 )
+ end = 4;
+ if( begin > end )
+ begin = end;
- list = PyList_New(end - begin);
+ list = PyList_New( end - begin );
- for (count = begin; count < end; count++)
- PyList_SetItem(list, count - begin,
- PyInt_FromLong(*(self->rgba[count])));
+ for( count = begin; count < end; count++ )
+ PyList_SetItem( list, count - begin,
+ PyInt_FromLong( *( self->rgba[count] ) ) );
return list;
}
-static int charRGBAAssItem(BPy_charRGBA *self, int i, PyObject *ob)
+static int charRGBAAssItem( BPy_charRGBA * self, int i, PyObject * ob )
{
- if (i < 0 || i >= 4)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range");
+ if( i < 0 || i >= 4 )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range" );
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "color component must be a number");
+ if( !PyNumber_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "color component must be a number" );
- *(self->rgba[i]) = EXPP_ClampInt(PyInt_AsLong(ob), 0, 255);
+ *( self->rgba[i] ) = EXPP_ClampInt( PyInt_AsLong( ob ), 0, 255 );
return 0;
}
-static int charRGBAAssSlice(BPy_charRGBA *self, int begin, int end,
- PyObject *seq)
+static int charRGBAAssSlice( BPy_charRGBA * self, int begin, int end,
+ PyObject * seq )
{
int count;
-
- if (begin < 0) begin = 0;
- if (end > 4) end = 4;
- if (begin > end) begin = end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation");
+ if( begin < 0 )
+ begin = 0;
+ if( end > 4 )
+ end = 4;
+ if( begin > end )
+ begin = end;
+
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation" );
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment");
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment" );
- for (count = begin; count < end; count++) {
+ for( count = begin; count < end; count++ ) {
char value;
- PyObject *ob = PySequence_GetItem(seq, count);
+ PyObject *ob = PySequence_GetItem( seq, count );
- if (!PyArg_Parse(ob, "b", &value)) {
- Py_DECREF(ob);
+ if( !PyArg_Parse( ob, "b", &value ) ) {
+ Py_DECREF( ob );
return -1;
}
- *(self->rgba[count]) = EXPP_ClampInt(value, 0, 255);
+ *( self->rgba[count] ) = EXPP_ClampInt( value, 0, 255 );
- Py_DECREF(ob);
+ Py_DECREF( ob );
}
return 0;
}
/*****************************************************************************/
-/* Function: charRGBA_repr */
-/* Description: This is a callback function for the BPy_charRGBA type. It */
-/* builds a meaninful string to represent charRGBA objects. */
+/* Function: charRGBA_repr */
+/* Description: This is a callback function for the BPy_charRGBA type. It */
+/* builds a meaninful string to represent charRGBA objects. */
/*****************************************************************************/
-static PyObject *charRGBA_repr (BPy_charRGBA *self)
+static PyObject *charRGBA_repr( BPy_charRGBA * self )
{
char r, g, b, a;
- r = *(self->rgba[0]);
- g = *(self->rgba[1]);
- b = *(self->rgba[2]);
- a = *(self->rgba[3]);
+ r = *( self->rgba[0] );
+ g = *( self->rgba[1] );
+ b = *( self->rgba[2] );
+ a = *( self->rgba[3] );
- return PyString_FromFormat("[%d, %d, %d, %d]", r, g, b, a);
+ return PyString_FromFormat( "[%d, %d, %d, %d]", r, g, b, a );
}
diff --git a/source/blender/python/api2_2x/charRGBA.h b/source/blender/python/api2_2x/charRGBA.h
index d6d39439721..dc59a244b6d 100644
--- a/source/blender/python/api2_2x/charRGBA.h
+++ b/source/blender/python/api2_2x/charRGBA.h
@@ -45,16 +45,15 @@
/* Python BPy_charRGBA structure definition: */
typedef struct {
- PyObject_HEAD
- char *rgba[4]; /* array of four pointers to chars */
+ PyObject_HEAD char *rgba[4]; /* array of four pointers to chars */
} BPy_charRGBA;
/*****************************************************************************/
/* Python API function prototypes for the charRGBA helper module. */
/*****************************************************************************/
-PyObject *charRGBA_New (char *rgba);
-PyObject *charRGBA_getCol (BPy_charRGBA *self);
-PyObject *charRGBA_setCol (BPy_charRGBA *self, PyObject *args);
+PyObject *charRGBA_New( char *rgba );
+PyObject *charRGBA_getCol( BPy_charRGBA * self );
+PyObject *charRGBA_setCol( BPy_charRGBA * self, PyObject * args );
-#endif /* EXPP_charRGBA_H */
+#endif /* EXPP_charRGBA_H */
diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c
index d9c8fbc928a..481ab17e732 100644
--- a/source/blender/python/api2_2x/constant.c
+++ b/source/blender/python/api2_2x/constant.c
@@ -32,132 +32,131 @@
#include "constant.h"
-/* This file is heavily based on the old bpython Constant object code in
+/* This file is heavily based on the old bpython Constant object code in
Blender */
/*****************************************************************************/
/* Python constant_Type callback function prototypes: */
/*****************************************************************************/
-static void constant_dealloc (BPy_constant *cam);
-static PyObject *constant_getAttr (BPy_constant *cam, char *name);
-static PyObject *constant_repr (BPy_constant *cam);
-static int constantLength(BPy_constant *self);
-static PyObject *constantSubscript(BPy_constant *self, PyObject *key);
-static int constantAssSubscript(BPy_constant *self, PyObject *who,
- PyObject *cares);
+static void constant_dealloc( BPy_constant * cam );
+static PyObject *constant_getAttr( BPy_constant * cam, char *name );
+static PyObject *constant_repr( BPy_constant * cam );
+static int constantLength( BPy_constant * self );
+static PyObject *constantSubscript( BPy_constant * self, PyObject * key );
+static int constantAssSubscript( BPy_constant * self, PyObject * who,
+ PyObject * cares );
/*****************************************************************************/
/* Python constant_Type Mapping Methods table: */
/*****************************************************************************/
-static PyMappingMethods constantAsMapping =
-{
- (inquiry)constantLength, /* mp_length */
- (binaryfunc)constantSubscript, /* mp_subscript */
- (objobjargproc)constantAssSubscript, /* mp_ass_subscript */
+static PyMappingMethods constantAsMapping = {
+ ( inquiry ) constantLength, /* mp_length */
+ ( binaryfunc ) constantSubscript, /* mp_subscript */
+ ( objobjargproc ) constantAssSubscript, /* mp_ass_subscript */
};
/*****************************************************************************/
/* Python constant_Type structure definition: */
/*****************************************************************************/
-PyTypeObject constant_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender constant", /* tp_name */
- sizeof (BPy_constant), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)constant_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)constant_getAttr, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)constant_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- &constantAsMapping, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- 0, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject constant_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender constant", /* tp_name */
+ sizeof( BPy_constant ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) constant_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) constant_getAttr, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) constant_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ &constantAsMapping, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_doc */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
/* Function: constant_New */
/*****************************************************************************/
-static PyObject *new_const(void);
+static PyObject *new_const( void );
-PyObject *M_constant_New(void) /* can't be static, we call it in other files */
-{
- return new_const();
+PyObject *M_constant_New( void )
+{ /* can't be static, we call it in other files */
+ return new_const( );
}
-static PyObject *new_const(void)
-{ /* this is the static one */
- BPy_constant *constant;
+static PyObject *new_const( void )
+{ /* this is the static one */
+ BPy_constant *constant;
+
+ constant_Type.ob_type = &PyType_Type;
- constant_Type.ob_type = &PyType_Type;
+ constant =
+ ( BPy_constant * ) PyObject_NEW( BPy_constant,
+ &constant_Type );
- constant = (BPy_constant *)PyObject_NEW(BPy_constant, &constant_Type);
+ if( constant == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create constant object" ) );
- if (constant == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create constant object"));
+ if( ( constant->dict = PyDict_New( ) ) == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create constant object's dictionary" ) );
- if ((constant->dict = PyDict_New()) == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create constant object's dictionary"));
-
- return (PyObject *)constant;
+ return ( PyObject * ) constant;
}
/*****************************************************************************/
/* Python BPy_constant methods: */
/*****************************************************************************/
-int constant_insert (BPy_constant *self, char *name, PyObject *value)
+int constant_insert( BPy_constant * self, char *name, PyObject * value )
{
- return PyDict_SetItemString (self->dict, name, value);
+ return PyDict_SetItemString( self->dict, name, value );
}
/*****************************************************************************/
-/* Function: constant_dealloc */
+/* Function: constant_dealloc */
/* Description: This is a callback function for the BPy_constant type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void constant_dealloc (BPy_constant *self)
+static void constant_dealloc( BPy_constant * self )
{
- Py_DECREF(self->dict);
- PyObject_DEL (self);
+ Py_DECREF( self->dict );
+ PyObject_DEL( self );
}
/*****************************************************************************/
-/* Function: constant_getAttr */
+/* Function: constant_getAttr */
/* Description: This is a callback function for the BPy_constant type. It is */
/* the function that accesses BPy_constant member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject *constant_getAttr (BPy_constant *self, char *name)
+static PyObject *constant_getAttr( BPy_constant * self, char *name )
{
- if (self->dict)
- {
- PyObject *v;
-
- if (!strcmp(name, "__members__"))
- return PyDict_Keys(self->dict);
-
- v = PyDict_GetItemString(self->dict, name);
- if (v) {
- Py_INCREF(v); /* was a borrowed ref */
- return v;
- }
-
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "attribute not found"));
- }
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "constant object lacks a dictionary"));
+ if( self->dict ) {
+ PyObject *v;
+
+ if( !strcmp( name, "__members__" ) )
+ return PyDict_Keys( self->dict );
+
+ v = PyDict_GetItemString( self->dict, name );
+ if( v ) {
+ Py_INCREF( v ); /* was a borrowed ref */
+ return v;
+ }
+
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "attribute not found" ) );
+ }
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "constant object lacks a dictionary" ) );
}
/*****************************************************************************/
@@ -165,30 +164,30 @@ static PyObject *constant_getAttr (BPy_constant *self, char *name)
/* These functions provide code to access constant objects as */
/* mappings. */
/*****************************************************************************/
-static int constantLength(BPy_constant *self)
+static int constantLength( BPy_constant * self )
{
- return 0;
+ return 0;
}
-static PyObject *constantSubscript(BPy_constant *self, PyObject *key)
+static PyObject *constantSubscript( BPy_constant * self, PyObject * key )
{
- if (self->dict) {
- PyObject *v = PyDict_GetItem(self->dict, key);
+ if( self->dict ) {
+ PyObject *v = PyDict_GetItem( self->dict, key );
- if (v) {
- Py_INCREF(v);
- return v;
- }
- }
+ if( v ) {
+ Py_INCREF( v );
+ return v;
+ }
+ }
- return NULL;
+ return NULL;
}
-static int constantAssSubscript(BPy_constant *self, PyObject *who,
- PyObject *cares)
+static int constantAssSubscript( BPy_constant * self, PyObject * who,
+ PyObject * cares )
{
- /* no user assignments allowed */
- return 0;
+ /* no user assignments allowed */
+ return 0;
}
/*****************************************************************************/
@@ -196,8 +195,8 @@ static int constantAssSubscript(BPy_constant *self, PyObject *who,
/* Description: This is a callback function for the BPy_constant type. It */
/* builds a meaninful string to represent constant objects. */
/*****************************************************************************/
-static PyObject *constant_repr (BPy_constant *self)
+static PyObject *constant_repr( BPy_constant * self )
{
- PyObject *repr = PyObject_Repr(self->dict);
- return repr;
+ PyObject *repr = PyObject_Repr( self->dict );
+ return repr;
}
diff --git a/source/blender/python/api2_2x/constant.h b/source/blender/python/api2_2x/constant.h
index 3f95f11dd2b..4d28c4a85f6 100644
--- a/source/blender/python/api2_2x/constant.h
+++ b/source/blender/python/api2_2x/constant.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -43,20 +44,19 @@
/*****************************************************************************/
/* Python API function prototypes for the constant module. */
/*****************************************************************************/
-PyObject *M_constant_New (void);
+PyObject *M_constant_New( void );
/*****************************************************************************/
/* Python BPy_constant structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- PyObject *dict;
+ PyObject_HEAD PyObject * dict;
} BPy_constant;
/*****************************************************************************/
/* Python BPy_constant methods declarations: */
/*****************************************************************************/
-int constant_insert(BPy_constant *self, char *name, PyObject *value);
+int constant_insert( BPy_constant * self, char *name, PyObject * value );
-#endif /* EXPP_constant_H */
+#endif /* EXPP_constant_H */
diff --git a/source/blender/python/api2_2x/euler.c b/source/blender/python/api2_2x/euler.c
index 09e6b01bffc..d55b5814270 100644
--- a/source/blender/python/api2_2x/euler.c
+++ b/source/blender/python/api2_2x/euler.c
@@ -32,25 +32,24 @@
#include "euler.h"
//doc strings
-char Euler_Zero_doc[] =
-"() - set all values in the euler to 0";
+char Euler_Zero_doc[] = "() - set all values in the euler to 0";
char Euler_Unique_doc[] =
-"() - sets the euler rotation a unique shortest arc rotation - tests for gimbal lock";
+ "() - sets the euler rotation a unique shortest arc rotation - tests for gimbal lock";
char Euler_ToMatrix_doc[] =
-"() - returns a rotation matrix representing the euler rotation";
+ "() - returns a rotation matrix representing the euler rotation";
char Euler_ToQuat_doc[] =
-"() - returns a quaternion representing the euler rotation";
+ "() - returns a quaternion representing the euler rotation";
//methods table
struct PyMethodDef Euler_methods[] = {
- {"zero",(PyCFunction)Euler_Zero, METH_NOARGS,
- Euler_Zero_doc},
- {"unique",(PyCFunction)Euler_Unique, METH_NOARGS,
- Euler_Unique_doc},
- {"toMatrix",(PyCFunction)Euler_ToMatrix, METH_NOARGS,
- Euler_ToMatrix_doc},
- {"toQuat",(PyCFunction)Euler_ToQuat, METH_NOARGS,
- Euler_ToQuat_doc},
+ {"zero", ( PyCFunction ) Euler_Zero, METH_NOARGS,
+ Euler_Zero_doc},
+ {"unique", ( PyCFunction ) Euler_Unique, METH_NOARGS,
+ Euler_Unique_doc},
+ {"toMatrix", ( PyCFunction ) Euler_ToMatrix, METH_NOARGS,
+ Euler_ToMatrix_doc},
+ {"toQuat", ( PyCFunction ) Euler_ToQuat, METH_NOARGS,
+ Euler_ToQuat_doc},
{NULL, NULL, 0, NULL}
};
@@ -59,274 +58,285 @@ struct PyMethodDef Euler_methods[] = {
/*****************************/
//euler methods
-PyObject *Euler_ToQuat(EulerObject *self)
+PyObject *Euler_ToQuat( EulerObject * self )
{
float *quat;
int x;
- for(x = 0; x < 3; x++){
- self->eul[x] *= (float)(Py_PI/180);
+ for( x = 0; x < 3; x++ ) {
+ self->eul[x] *= ( float ) ( Py_PI / 180 );
}
- quat = PyMem_Malloc(4*sizeof(float));
- EulToQuat(self->eul, quat);
- for(x = 0; x < 3; x++){
- self->eul[x] *= (float)(180/Py_PI);
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ EulToQuat( self->eul, quat );
+ for( x = 0; x < 3; x++ ) {
+ self->eul[x] *= ( float ) ( 180 / Py_PI );
}
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-PyObject *Euler_ToMatrix(EulerObject *self)
+PyObject *Euler_ToMatrix( EulerObject * self )
{
float *mat;
int x;
- for(x = 0; x < 3; x++){
- self->eul[x] *= (float)(Py_PI/180);
+ for( x = 0; x < 3; x++ ) {
+ self->eul[x] *= ( float ) ( Py_PI / 180 );
}
- mat = PyMem_Malloc(3*3*sizeof(float));
- EulToMat3(self->eul, (float(*)[3])mat);
- for(x = 0; x < 3; x++){
- self->eul[x] *= (float)(180/Py_PI);
+ mat = PyMem_Malloc( 3 * 3 * sizeof( float ) );
+ EulToMat3( self->eul, ( float ( * )[3] ) mat );
+ for( x = 0; x < 3; x++ ) {
+ self->eul[x] *= ( float ) ( 180 / Py_PI );
}
- return (PyObject*)newMatrixObject(mat,3,3);
+ return ( PyObject * ) newMatrixObject( mat, 3, 3 );
}
-PyObject *Euler_Unique(EulerObject *self)
+PyObject *Euler_Unique( EulerObject * self )
{
float heading, pitch, bank;
- float pi2 = (float)Py_PI * 2.0f;
- float piO2 = (float)Py_PI / 2.0f;
+ float pi2 = ( float ) Py_PI * 2.0f;
+ float piO2 = ( float ) Py_PI / 2.0f;
float Opi2 = 1.0f / pi2;
//radians
- heading = self->eul[0] * (float)(Py_PI/180);
- pitch = self->eul[1] * (float)(Py_PI/180);
- bank = self->eul[2] * (float)(Py_PI/180);
-
+ heading = self->eul[0] * ( float ) ( Py_PI / 180 );
+ pitch = self->eul[1] * ( float ) ( Py_PI / 180 );
+ bank = self->eul[2] * ( float ) ( Py_PI / 180 );
+
//wrap heading in +180 / -180
- pitch += (float)Py_PI;
- pitch -= (float)floor(pitch * Opi2) * pi2;
- pitch -= (float)Py_PI;
-
-
- if(pitch < -piO2){
- pitch = (float)-Py_PI - pitch;
- heading += (float)Py_PI;
- bank += (float)Py_PI;
- }else if (pitch > piO2){
- pitch = (float)Py_PI - pitch;
- heading += (float)Py_PI;
- bank += (float)Py_PI;
+ pitch += ( float ) Py_PI;
+ pitch -= ( float ) floor( pitch * Opi2 ) * pi2;
+ pitch -= ( float ) Py_PI;
+
+
+ if( pitch < -piO2 ) {
+ pitch = ( float ) -Py_PI - pitch;
+ heading += ( float ) Py_PI;
+ bank += ( float ) Py_PI;
+ } else if( pitch > piO2 ) {
+ pitch = ( float ) Py_PI - pitch;
+ heading += ( float ) Py_PI;
+ bank += ( float ) Py_PI;
}
-
//gimbal lock test
- if(fabs(pitch) > piO2 - 1e-4){
+ if( fabs( pitch ) > piO2 - 1e-4 ) {
heading += bank;
bank = 0.0f;
- }else{
- bank += (float)Py_PI;
- bank -= (float)(floor(bank * Opi2)) * pi2;
- bank -= (float)Py_PI;
+ } else {
+ bank += ( float ) Py_PI;
+ bank -= ( float ) ( floor( bank * Opi2 ) ) * pi2;
+ bank -= ( float ) Py_PI;
}
- heading += (float)Py_PI;
- heading -= (float)(floor(heading * Opi2)) * pi2;
- heading -= (float)Py_PI;
-
+ heading += ( float ) Py_PI;
+ heading -= ( float ) ( floor( heading * Opi2 ) ) * pi2;
+ heading -= ( float ) Py_PI;
+
//back to degrees
- self->eul[0] = heading * (float)(180/Py_PI);
- self->eul[1] = pitch * (float)(180/Py_PI);
- self->eul[2] = bank * (float)(180/Py_PI);
+ self->eul[0] = heading * ( float ) ( 180 / Py_PI );
+ self->eul[1] = pitch * ( float ) ( 180 / Py_PI );
+ self->eul[2] = bank * ( float ) ( 180 / Py_PI );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Euler_Zero(EulerObject *self)
+PyObject *Euler_Zero( EulerObject * self )
{
self->eul[0] = 0.0;
self->eul[1] = 0.0;
self->eul[2] = 0.0;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static void Euler_dealloc(EulerObject *self)
+static void Euler_dealloc( EulerObject * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Euler_getattr(EulerObject *self, char *name)
+static PyObject *Euler_getattr( EulerObject * self, char *name )
{
- if (ELEM3(name[0], 'x', 'y', 'z') && name[1]==0){
- return PyFloat_FromDouble(self->eul[name[0]-'x']);
+ if( ELEM3( name[0], 'x', 'y', 'z' ) && name[1] == 0 ) {
+ return PyFloat_FromDouble( self->eul[name[0] - 'x'] );
}
- return Py_FindMethod(Euler_methods, (PyObject*)self, name);
+ return Py_FindMethod( Euler_methods, ( PyObject * ) self, name );
}
-static int Euler_setattr(EulerObject *self, char *name, PyObject *e)
+static int Euler_setattr( EulerObject * self, char *name, PyObject * e )
{
float val;
- if (!PyArg_Parse(e, "f", &val))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "unable to parse float argument\n");
+ if( !PyArg_Parse( e, "f", &val ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "unable to parse float argument\n" );
- if (ELEM3(name[0], 'x', 'y', 'z') && name[1]==0){
- self->eul[name[0]-'x']= val;
+ if( ELEM3( name[0], 'x', 'y', 'z' ) && name[1] == 0 ) {
+ self->eul[name[0] - 'x'] = val;
return 0;
- }
- else return -1;
+ } else
+ return -1;
}
/* Eulers Sequence methods */
-static PyObject *Euler_item(EulerObject *self, int i)
+static PyObject *Euler_item( EulerObject * self, int i )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnPyObjError (PyExc_IndexError, "array index out of range\n");
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range\n" );
- return Py_BuildValue("f", self->eul[i]);
+ return Py_BuildValue( "f", self->eul[i] );
}
-static PyObject *Euler_slice(EulerObject *self, int begin, int end)
+static PyObject *Euler_slice( EulerObject * self, int begin, int end )
{
PyObject *list;
int count;
-
- if (begin < 0) begin= 0;
- if (end > 3) end= 3;
- if (begin > end) begin= end;
- list= PyList_New(end-begin);
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
+
+ list = PyList_New( end - begin );
- for (count = begin; count < end; count++){
- PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->eul[count]));
+ for( count = begin; count < end; count++ ) {
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( self->eul[count] ) );
}
return list;
}
-static int Euler_ass_item(EulerObject *self, int i, PyObject *ob)
+static int Euler_ass_item( EulerObject * self, int i, PyObject * ob )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range\n");
-
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "Euler member must be a number\n");
-
- if(!PyFloat_Check(ob) && !PyInt_Check(ob)){
- return EXPP_ReturnIntError(PyExc_TypeError,"int or float expected\n");
- }else{
- self->eul[i]= (float)PyFloat_AsDouble(ob);
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range\n" );
+
+ if( !PyNumber_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "Euler member must be a number\n" );
+
+ if( !PyFloat_Check( ob ) && !PyInt_Check( ob ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "int or float expected\n" );
+ } else {
+ self->eul[i] = ( float ) PyFloat_AsDouble( ob );
}
return 0;
}
-static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
+static int Euler_ass_slice( EulerObject * self, int begin, int end,
+ PyObject * seq )
{
int count, z;
- if (begin < 0) begin= 0;
- if (end > 3) end= 3;
- if (begin > end) begin= end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation\n");
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment\n");
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation\n" );
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment\n" );
z = 0;
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, z); z++;
+ for( count = begin; count < end; count++ ) {
+ PyObject *ob = PySequence_GetItem( seq, z );
+ z++;
- if(!PyFloat_Check(ob) && !PyInt_Check(ob)){
- Py_DECREF(ob);
+ if( !PyFloat_Check( ob ) && !PyInt_Check( ob ) ) {
+ Py_DECREF( ob );
return -1;
- }else{
- if (!PyArg_Parse(ob, "f", &self->eul[count])) {
- Py_DECREF(ob);
+ } else {
+ if( !PyArg_Parse( ob, "f", &self->eul[count] ) ) {
+ Py_DECREF( ob );
return -1;
}
}
}
- return 0;
+ return 0;
}
-static PyObject *Euler_repr (EulerObject *self)
+static PyObject *Euler_repr( EulerObject * self )
{
int i, maxindex = 3 - 1;
char ftoa[24];
PyObject *str1, *str2;
- str1 = PyString_FromString ("[");
+ str1 = PyString_FromString( "[" );
- for (i = 0; i < maxindex; i++) {
- sprintf(ftoa, "%.4f, ", self->eul[i]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ for( i = 0; i < maxindex; i++ ) {
+ sprintf( ftoa, "%.4f, ", self->eul[i] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
}
- sprintf(ftoa, "%.4f]\n", self->eul[maxindex]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ sprintf( ftoa, "%.4f]\n", self->eul[maxindex] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
- if (str1) return str1;
+ if( str1 )
+ return str1;
-error:
- Py_XDECREF (str1);
- Py_XDECREF (str2);
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString!\n");
+ error:
+ Py_XDECREF( str1 );
+ Py_XDECREF( str2 );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyString!\n" );
}
-static PySequenceMethods Euler_SeqMethods =
-{
- (inquiry) 0, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Euler_item, /* sq_item */
- (intintargfunc) Euler_slice, /* sq_slice */
- (intobjargproc) Euler_ass_item, /* sq_ass_item */
- (intintobjargproc) Euler_ass_slice, /* sq_ass_slice */
+static PySequenceMethods Euler_SeqMethods = {
+ ( inquiry ) 0, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) Euler_item, /* sq_item */
+ ( intintargfunc ) Euler_slice, /* sq_slice */
+ ( intobjargproc ) Euler_ass_item, /* sq_ass_item */
+ ( intintobjargproc ) Euler_ass_slice, /* sq_ass_slice */
};
-PyTypeObject euler_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "euler", /*tp_name*/
- sizeof(EulerObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Euler_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Euler_getattr, /*tp_getattr*/
- (setattrfunc) Euler_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Euler_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &Euler_SeqMethods, /*tp_as_sequence*/
+PyTypeObject euler_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /*ob_size */
+ "euler", /*tp_name */
+ sizeof( EulerObject ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Euler_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Euler_getattr, /*tp_getattr */
+ ( setattrfunc ) Euler_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) Euler_repr, /*tp_repr */
+ 0, /*tp_as_number */
+ &Euler_SeqMethods, /*tp_as_sequence */
};
-PyObject *newEulerObject(float *eul)
+PyObject *newEulerObject( float *eul )
{
- EulerObject *self;
- int x;
+ EulerObject *self;
+ int x;
- euler_Type.ob_type = &PyType_Type;
+ euler_Type.ob_type = &PyType_Type;
- self = PyObject_NEW(EulerObject, &euler_Type);
+ self = PyObject_NEW( EulerObject, &euler_Type );
- if(!eul){
- self->eul = PyMem_Malloc (3*sizeof (float));
- for(x = 0; x < 3; x++){
- self->eul[x] = 0.0f;
- }
- }else self->eul = eul;
-
- return (PyObject*) self;
-}
+ if( !eul ) {
+ self->eul = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ ) {
+ self->eul[x] = 0.0f;
+ }
+ } else
+ self->eul = eul;
+ return ( PyObject * ) self;
+}
diff --git a/source/blender/python/api2_2x/euler.h b/source/blender/python/api2_2x/euler.h
index 2e33c7cf350..1c3b21f7ffc 100644
--- a/source/blender/python/api2_2x/euler.h
+++ b/source/blender/python/api2_2x/euler.h
@@ -1,4 +1,8 @@
-/* * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -50,16 +54,14 @@
#define EulerObject_Check(v) ((v)->ob_type == &euler_Type)
typedef struct {
- PyObject_VAR_HEAD
- float * eul;
+ PyObject_VAR_HEAD float *eul;
} EulerObject;
//prototypes
-PyObject *newEulerObject(float *eul);
-PyObject *Euler_Zero(EulerObject *self);
-PyObject *Euler_Unique(EulerObject *self);
-PyObject *Euler_ToMatrix(EulerObject *self);
-PyObject *Euler_ToQuat(EulerObject *self);
-
-#endif /* EXPP_euler_h */
+PyObject *newEulerObject( float *eul );
+PyObject *Euler_Zero( EulerObject * self );
+PyObject *Euler_Unique( EulerObject * self );
+PyObject *Euler_ToMatrix( EulerObject * self );
+PyObject *Euler_ToQuat( EulerObject * self );
+#endif /* EXPP_euler_h */
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 4cbdbc90ea0..0b289a77ecb 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -30,7 +30,7 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include <strings.h> /*for strcasecmp */
+#include <strings.h> /*for strcasecmp */
#include <DNA_text_types.h>
#include <MEM_guardedalloc.h>
@@ -38,132 +38,137 @@
#include "constant.h"
/*****************************************************************************/
-/* Description: This function clamps an int to the given interval */
-/* [min, max]. */
+/* Description: This function clamps an int to the given interval */
+/* [min, max]. */
/*****************************************************************************/
-int EXPP_ClampInt (int value, int min, int max)
+int EXPP_ClampInt( int value, int min, int max )
{
- if (value < min) return min;
- else if (value > max) return max;
+ if( value < min )
+ return min;
+ else if( value > max )
+ return max;
return value;
}
/*****************************************************************************/
-/* Description: This function clamps a float to the given interval */
-/* [min, max]. */
+/* Description: This function clamps a float to the given interval */
+/* [min, max]. */
/*****************************************************************************/
-float EXPP_ClampFloat (float value, float min, float max)
+float EXPP_ClampFloat( float value, float min, float max )
{
- if (value < min) return min;
- else if (value > max) return max;
+ if( value < min )
+ return min;
+ else if( value > max )
+ return max;
return value;
}
/*****************************************************************************/
/* Description: This function returns true if both given strings are equal, */
-/* otherwise it returns false. */
+/* otherwise it returns false. */
/*****************************************************************************/
-int StringEqual (const char * string1, const char * string2)
+int StringEqual( const char *string1, const char *string2 )
{
- return (strcmp(string1, string2)==0);
+ return ( strcmp( string1, string2 ) == 0 );
}
/*****************************************************************************/
-/* Description: This function returns the name of the given ID struct */
-/* without the Object type identifying characters prepended. */
+/* Description: This function returns the name of the given ID struct */
+/* without the Object type identifying characters prepended. */
/*****************************************************************************/
-char * GetIdName (ID *id)
+char *GetIdName( ID * id )
{
- return ((id->name)+2);
+ return ( ( id->name ) + 2 );
}
/*****************************************************************************/
-/* Description: This function returns the ID of the object with given name */
-/* from a given list. */
+/* Description: This function returns the ID of the object with given name */
+/* from a given list. */
/*****************************************************************************/
-ID *GetIdFromList(ListBase *list, char *name)
+ID *GetIdFromList( ListBase * list, char *name )
{
ID *id = list->first;
- while (id) {
- if(strcmp(name, id->name+2) == 0) break;
- id= id->next;
+ while( id ) {
+ if( strcmp( name, id->name + 2 ) == 0 )
+ break;
+ id = id->next;
}
return id;
}
/*****************************************************************************/
-/* Description: These functions set an internal string with the given type */
-/* and error_msg arguments. */
+/* Description: These functions set an internal string with the given type */
+/* and error_msg arguments. */
/*****************************************************************************/
-PyObject *EXPP_ReturnPyObjError (PyObject * type, char * error_msg)
-{ /* same as above, just to change its name smoothly */
- PyErr_SetString (type, error_msg);
+PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg )
+{ /* same as above, just to change its name smoothly */
+ PyErr_SetString( type, error_msg );
return NULL;
}
-int EXPP_ReturnIntError (PyObject *type, char *error_msg)
+int EXPP_ReturnIntError( PyObject * type, char *error_msg )
{
- PyErr_SetString (type, error_msg);
+ PyErr_SetString( type, error_msg );
return -1;
}
/*****************************************************************************/
-/* Description: This function increments the reference count of the given */
-/* Python object (usually Py_None) and returns it. */
+/* Description: This function increments the reference count of the given */
+/* Python object (usually Py_None) and returns it. */
/*****************************************************************************/
-PyObject *EXPP_incr_ret (PyObject *object)
+PyObject *EXPP_incr_ret( PyObject * object )
{
- Py_INCREF (object);
- return (object);
+ Py_INCREF( object );
+ return ( object );
}
/*****************************************************************************/
-/* Description: This function maps the event identifier to a string. */
+/* Description: This function maps the event identifier to a string. */
/*****************************************************************************/
-char * event_to_name(short event)
+char *event_to_name( short event )
{
- switch (event)
- {
- case SCRIPT_FRAMECHANGED:
- return "FrameChanged";
- case SCRIPT_ONLOAD:
- return "OnLoad";
- case SCRIPT_ONSAVE:
- return "OnSave";
- case SCRIPT_REDRAW:
- return "Redraw";
- default:
- return "Unknown";
+ switch ( event ) {
+ case SCRIPT_FRAMECHANGED:
+ return "FrameChanged";
+ case SCRIPT_ONLOAD:
+ return "OnLoad";
+ case SCRIPT_ONSAVE:
+ return "OnSave";
+ case SCRIPT_REDRAW:
+ return "Redraw";
+ default:
+ return "Unknown";
}
-}
+}
/*****************************************************************************/
-/* Description: Checks whether all objects in a PySequence are of a same */
-/* given type. Returns 0 if not, 1 on success. */
+/* Description: Checks whether all objects in a PySequence are of a same */
+/* given type. Returns 0 if not, 1 on success. */
/*****************************************************************************/
-int EXPP_check_sequence_consistency(PyObject *seq, PyTypeObject *against)
+int EXPP_check_sequence_consistency( PyObject * seq, PyTypeObject * against )
{
PyObject *ob;
- int len = PySequence_Length(seq);
+ int len = PySequence_Length( seq );
int i, result = 1;
- for (i = 0; i < len; i++) {
- ob = PySequence_GetItem(seq, i);
- if (ob == Py_None) result = 2;
- else if (ob->ob_type != against) {
- Py_DECREF(ob);
+ for( i = 0; i < len; i++ ) {
+ ob = PySequence_GetItem( seq, i );
+ if( ob == Py_None )
+ result = 2;
+ else if( ob->ob_type != against ) {
+ Py_DECREF( ob );
return 0;
}
- Py_DECREF(ob);
+ Py_DECREF( ob );
}
- return result; /* 1 if all of 'against' type, 2 if there are (also) Nones */
+ return result; /* 1 if all of 'against' type, 2 if there are (also) Nones */
}
-PyObject *EXPP_tuple_repr(PyObject *self, int size)
+PyObject *EXPP_tuple_repr( PyObject * self, int size )
{
PyObject *repr, *item;
int i;
@@ -171,17 +176,18 @@ PyObject *EXPP_tuple_repr(PyObject *self, int size)
/*@ note: a value must be built because the list is decrefed!
* otherwise we have nirvana pointers inside python.. */
- repr = PyString_FromString("");
- if (!repr) return 0;
+ repr = PyString_FromString( "" );
+ if( !repr )
+ return 0;
- item = PySequence_GetItem(self, 0);
- PyString_ConcatAndDel(&repr, PyObject_Repr(item));
- Py_DECREF(item);
+ item = PySequence_GetItem( self, 0 );
+ PyString_ConcatAndDel( &repr, PyObject_Repr( item ) );
+ Py_DECREF( item );
- for (i = 1; i < size; i++) {
- item = PySequence_GetItem(self, i);
- PyString_ConcatAndDel(&repr, PyObject_Repr(item));
- Py_DECREF(item);
+ for( i = 1; i < size; i++ ) {
+ item = PySequence_GetItem( self, i );
+ PyString_ConcatAndDel( &repr, PyObject_Repr( item ) );
+ Py_DECREF( item );
}
return repr;
@@ -189,73 +195,67 @@ PyObject *EXPP_tuple_repr(PyObject *self, int size)
/****************************************************************************/
/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
+/* pair is present, its ival is stored in *ival and nonzero is */
+/* returned. If the pair is absent, zero is returned. */
/****************************************************************************/
-int EXPP_map_getIntVal (const EXPP_map_pair *map, const char *sval, int *ival)
+int EXPP_map_getIntVal( const EXPP_map_pair * map, const char *sval,
+ int *ival )
{
- while (map->sval)
- {
- if (StringEqual(sval, map->sval))
- {
- *ival = map->ival;
- return 1;
- }
- ++map;
+ while( map->sval ) {
+ if( StringEqual( sval, map->sval ) ) {
+ *ival = map->ival;
+ return 1;
}
- return 0;
+ ++map;
+ }
+ return 0;
}
/* same as above, but string case is ignored */
-int EXPP_map_case_getIntVal (const EXPP_map_pair *map, const char *sval,
- int *ival)
+int EXPP_map_case_getIntVal( const EXPP_map_pair * map, const char *sval,
+ int *ival )
{
- while (map->sval)
- {
- if (!strcasecmp(sval, map->sval))
- {
- *ival = map->ival;
- return 1;
- }
- ++map;
+ while( map->sval ) {
+ if( !strcasecmp( sval, map->sval ) ) {
+ *ival = map->ival;
+ return 1;
}
- return 0;
+ ++map;
+ }
+ return 0;
}
/****************************************************************************/
/* Description: searches through a map for a pair with a given name. If the */
-/* pair is present, its ival is stored in *ival and nonzero is */
-/* returned. If the pair is absent, zero is returned. */
-/* note: this function is identical to EXPP_map_getIntVal except that the */
-/* output is stored in a short value. */
+/* pair is present, its ival is stored in *ival and nonzero is */
+/* returned. If the pair is absent, zero is returned. */
+/* note: this function is identical to EXPP_map_getIntVal except that the */
+/* output is stored in a short value. */
/****************************************************************************/
-int EXPP_map_getShortVal (const EXPP_map_pair *map,
- const char *sval, short *ival)
+int EXPP_map_getShortVal( const EXPP_map_pair * map,
+ const char *sval, short *ival )
{
- while (map->sval)
- {
- if (StringEqual(sval, map->sval))
- {
- *ival = map->ival;
- return 1;
- }
- ++map;
+ while( map->sval ) {
+ if( StringEqual( sval, map->sval ) ) {
+ *ival = map->ival;
+ return 1;
}
- return 0;
+ ++map;
+ }
+ return 0;
}
/****************************************************************************/
/* Description: searches through a map for a pair with a given ival. If the */
-/* pair is present, a pointer to its name is stored in *sval */
-/* and nonzero is returned. If the pair is absent, zero is */
-/* returned. */
+/* pair is present, a pointer to its name is stored in *sval */
+/* and nonzero is returned. If the pair is absent, zero is */
+/* returned. */
/****************************************************************************/
-int EXPP_map_getStrVal (const EXPP_map_pair *map, int ival, const char **sval)
+int EXPP_map_getStrVal( const EXPP_map_pair * map, int ival,
+ const char **sval )
{
- while (map->sval)
- {
- if (ival == map->ival)
- {
+ while( map->sval ) {
+ if( ival == map->ival ) {
*sval = map->sval;
return 1;
}
@@ -267,61 +267,67 @@ int EXPP_map_getStrVal (const EXPP_map_pair *map, int ival, const char **sval)
/************************************************************************/
/* Scriptlink-related functions, used by scene, object, etc. bpyobjects */
/************************************************************************/
-PyObject *EXPP_getScriptLinks (ScriptLink *slink, PyObject *args, int is_scene)
+PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
+ int is_scene )
{
PyObject *list = NULL;
char *eventname = NULL;
int i, event = 0;
/* actually !scriptlink shouldn't happen ... */
- if (!slink || !slink->totscript)
- return EXPP_incr_ret (Py_None);
+ if( !slink || !slink->totscript )
+ return EXPP_incr_ret( Py_None );
- if (!PyArg_ParseTuple(args, "s", &eventname))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected event name (string) as argument");
+ if( !PyArg_ParseTuple( args, "s", &eventname ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected event name (string) as argument" );
- list = PyList_New(0);
- if (!list)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList!");
+ list = PyList_New( 0 );
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList!" );
- if (!strcmp(eventname, "FrameChanged"))
+ if( !strcmp( eventname, "FrameChanged" ) )
event = SCRIPT_FRAMECHANGED;
- else if (!strcmp(eventname, "Redraw"))
+ else if( !strcmp( eventname, "Redraw" ) )
event = SCRIPT_REDRAW;
- else if (is_scene && !strcmp(eventname, "OnLoad"))
+ else if( is_scene && !strcmp( eventname, "OnLoad" ) )
event = SCRIPT_ONLOAD;
- else if (is_scene && !strcmp(eventname, "OnSave"))
+ else if( is_scene && !strcmp( eventname, "OnSave" ) )
event = SCRIPT_ONSAVE;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "invalid event name");
-
- for (i = 0; i < slink->totscript; i++) {
- if ((slink->flag[i] == event) && slink->scripts[i])
- PyList_Append(list, PyString_FromString(slink->scripts[i]->name+2));
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "invalid event name" );
+
+ for( i = 0; i < slink->totscript; i++ ) {
+ if( ( slink->flag[i] == event ) && slink->scripts[i] )
+ PyList_Append( list,
+ PyString_FromString( slink->scripts[i]->
+ name + 2 ) );
}
return list;
}
-int EXPP_clearScriptLinks (ScriptLink *slink)
+int EXPP_clearScriptLinks( ScriptLink * slink )
{
/* actually !scriptlink shouldn't happen ... */
- if (!slink || !slink->totscript) return -1;
+ if( !slink || !slink->totscript )
+ return -1;
- if (slink->scripts) MEM_freeN(slink->scripts);
- if (slink->flag) MEM_freeN(slink->flag);
+ if( slink->scripts )
+ MEM_freeN( slink->scripts );
+ if( slink->flag )
+ MEM_freeN( slink->flag );
slink->scripts = NULL;
slink->flag = NULL;
slink->totscript = slink->actscript = 0;
- return 0; /* normal return */
+ return 0; /* normal return */
}
-int EXPP_addScriptLink (ScriptLink *slink, PyObject *args, int is_scene)
+int EXPP_addScriptLink( ScriptLink * slink, PyObject * args, int is_scene )
{
int event = 0, found_txt = 0;
void *stmp = NULL, *ftmp = NULL;
@@ -330,59 +336,66 @@ int EXPP_addScriptLink (ScriptLink *slink, PyObject *args, int is_scene)
char *eventname = NULL;
/* !scriptlink shouldn't happen ... */
- if (!slink) {
- return EXPP_ReturnIntError (PyExc_RuntimeError,
- "internal error: no scriptlink!");
+ if( !slink ) {
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "internal error: no scriptlink!" );
}
- if (!PyArg_ParseTuple(args, "ss", &textname, &eventname))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected two strings as arguments");
+ if( !PyArg_ParseTuple( args, "ss", &textname, &eventname ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected two strings as arguments" );
- while (bltxt) {
- if (!strcmp(bltxt->id.name+2, textname)) {
+ while( bltxt ) {
+ if( !strcmp( bltxt->id.name + 2, textname ) ) {
found_txt = 1;
break;
}
bltxt = bltxt->id.next;
}
- if (!found_txt)
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "no such Blender Text.");
+ if( !found_txt )
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "no such Blender Text." );
- if (!strcmp(eventname, "FrameChanged"))
+ if( !strcmp( eventname, "FrameChanged" ) )
event = SCRIPT_FRAMECHANGED;
- else if (!strcmp(eventname, "Redraw"))
+ else if( !strcmp( eventname, "Redraw" ) )
event = SCRIPT_REDRAW;
- else if (is_scene && !strcmp(eventname, "OnLoad"))
+ else if( is_scene && !strcmp( eventname, "OnLoad" ) )
event = SCRIPT_ONLOAD;
- else if (is_scene && !strcmp(eventname, "OnSave"))
+ else if( is_scene && !strcmp( eventname, "OnSave" ) )
event = SCRIPT_ONSAVE;
else
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "invalid event name.");
-
- stmp= slink->scripts;
- slink->scripts= MEM_mallocN(sizeof(ID*)*(slink->totscript+1), "bpySlinkL");
-
- ftmp= slink->flag;
- slink->flag= MEM_mallocN(sizeof(short*)*(slink->totscript+1), "bpySlinkF");
-
- if (slink->totscript) {
- memcpy(slink->scripts, stmp, sizeof(ID*)*(slink->totscript));
- MEM_freeN(stmp);
-
- memcpy(slink->flag, ftmp, sizeof(short)*(slink->totscript));
- MEM_freeN(ftmp);
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "invalid event name." );
+
+ stmp = slink->scripts;
+ slink->scripts =
+ MEM_mallocN( sizeof( ID * ) * ( slink->totscript + 1 ),
+ "bpySlinkL" );
+
+ ftmp = slink->flag;
+ slink->flag =
+ MEM_mallocN( sizeof( short * ) * ( slink->totscript + 1 ),
+ "bpySlinkF" );
+
+ if( slink->totscript ) {
+ memcpy( slink->scripts, stmp,
+ sizeof( ID * ) * ( slink->totscript ) );
+ MEM_freeN( stmp );
+
+ memcpy( slink->flag, ftmp,
+ sizeof( short ) * ( slink->totscript ) );
+ MEM_freeN( ftmp );
}
- slink->scripts[slink->totscript] = (ID*)bltxt;
- slink->flag[slink->totscript]= event;
+ slink->scripts[slink->totscript] = ( ID * ) bltxt;
+ slink->flag[slink->totscript] = event;
slink->totscript++;
-
- if (slink->actscript < 1) slink->actscript = 1;
- return 0; /* normal exit */
+ if( slink->actscript < 1 )
+ slink->actscript = 1;
+
+ return 0; /* normal exit */
}
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
index 8ef41114ffb..514542ada71 100644
--- a/source/blender/python/api2_2x/gen_utils.h
+++ b/source/blender/python/api2_2x/gen_utils.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -34,7 +35,7 @@
#include <Python.h>
#include "compile.h"
-#include "eval.h" /* for PyEval_GetLocals */
+#include "eval.h" /* for PyEval_GetLocals */
#include <stdio.h>
#include <string.h>
@@ -50,24 +51,24 @@
#define Py_PI 3.14159265358979323846
-int StringEqual (const char * string1, const char * string2);
-char * GetIdName (ID *id);
-ID *GetIdFromList(ListBase *list, char *name);
+int StringEqual( const char *string1, const char *string2 );
+char *GetIdName( ID * id );
+ID *GetIdFromList( ListBase * list, char *name );
-PyObject *PythonReturnErrorObject (PyObject * type, char * error_msg);
-PyObject *PythonIncRef (PyObject *object);
+PyObject *PythonReturnErrorObject( PyObject * type, char *error_msg );
+PyObject *PythonIncRef( PyObject * object );
-char * event_to_name (short event);
+char *event_to_name( short event );
-float EXPP_ClampFloat (float value, float min, float max);
-int EXPP_ClampInt (int value, int min, int max);
+float EXPP_ClampFloat( float value, float min, float max );
+int EXPP_ClampInt( int value, int min, int max );
-PyObject *EXPP_incr_ret (PyObject *object);
-PyObject *EXPP_ReturnPyObjError (PyObject * type, char * error_msg);
-int EXPP_ReturnIntError (PyObject *type, char *error_msg);
+PyObject *EXPP_incr_ret( PyObject * object );
+PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg );
+int EXPP_ReturnIntError( PyObject * type, char *error_msg );
-int EXPP_check_sequence_consistency (PyObject *seq, PyTypeObject *against);
-PyObject *EXPP_tuple_repr(PyObject *self, int size);
+int EXPP_check_sequence_consistency( PyObject * seq, PyTypeObject * against );
+PyObject *EXPP_tuple_repr( PyObject * self, int size );
/* mapping utilities - see Texture.c for an example of how to use these */
typedef struct {
@@ -76,18 +77,19 @@ typedef struct {
} EXPP_map_pair;
/* maps must end with a pair that has NULL as sval */
-int EXPP_map_getIntVal (const EXPP_map_pair *map,
- const char *sval, int *ival);
-int EXPP_map_case_getIntVal (const EXPP_map_pair *map,
- const char *sval, int *ival);
-int EXPP_map_getShortVal (const EXPP_map_pair *map,
- const char *sval, short *ival);
-int EXPP_map_getStrVal (const EXPP_map_pair *map,
- int ival, const char **sval);
+int EXPP_map_getIntVal( const EXPP_map_pair * map,
+ const char *sval, int *ival );
+int EXPP_map_case_getIntVal( const EXPP_map_pair * map,
+ const char *sval, int *ival );
+int EXPP_map_getShortVal( const EXPP_map_pair * map,
+ const char *sval, short *ival );
+int EXPP_map_getStrVal( const EXPP_map_pair * map,
+ int ival, const char **sval );
/* scriplinks-related: */
-PyObject *EXPP_getScriptLinks (ScriptLink *slink, PyObject *args, int is_scene);
-int EXPP_clearScriptLinks (ScriptLink *slink);
-int EXPP_addScriptLink (ScriptLink *slink, PyObject *args, int is_scene);
+PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args,
+ int is_scene );
+int EXPP_clearScriptLinks( ScriptLink * slink );
+int EXPP_addScriptLink( ScriptLink * slink, PyObject * args, int is_scene );
-#endif /* EXPP_gen_utils_h */
+#endif /* EXPP_gen_utils_h */
diff --git a/source/blender/python/api2_2x/logic.c b/source/blender/python/api2_2x/logic.c
index 397d84924b1..d3631a00ba9 100644
--- a/source/blender/python/api2_2x/logic.c
+++ b/source/blender/python/api2_2x/logic.c
@@ -35,435 +35,522 @@
#include <MEM_guardedalloc.h>
#include <BLI_blenlib.h>
-//--------------- Python BPy_Property methods declarations:---------------------------------------------------
-static PyObject *Property_getName (BPy_Property * self);
-static PyObject *Property_setName (BPy_Property * self, PyObject * args);
-static PyObject *Property_getData (BPy_Property * self);
-static PyObject *Property_setData (BPy_Property * self, PyObject * args);
-static PyObject *Property_getType (BPy_Property * self);
-//--------------- Python BPy_Property methods table:-----------------------------------------------------------------
+//--------------- Python BPy_Property methods declarations:---------------
+static PyObject *Property_getName( BPy_Property * self );
+static PyObject *Property_setName( BPy_Property * self, PyObject * args );
+static PyObject *Property_getData( BPy_Property * self );
+static PyObject *Property_setData( BPy_Property * self, PyObject * args );
+static PyObject *Property_getType( BPy_Property * self );
+//--------------- Python BPy_Property methods table:----------------------
static PyMethodDef BPy_Property_methods[] = {
- {"getName", (PyCFunction) Property_getName, METH_NOARGS,
- "() - return Property name"},
- {"setName", (PyCFunction)Property_setName, METH_VARARGS,
- "() - set the name of this Property"},
- {"getData", (PyCFunction) Property_getData, METH_NOARGS,
- "() - return Property data"},
- {"setData", (PyCFunction)Property_setData, METH_VARARGS,
- "() - set the data of this Property"},
- {"getType", (PyCFunction) Property_getType, METH_NOARGS,
- "() - return Property type"},
- {NULL, NULL, 0, NULL}
+ {"getName", ( PyCFunction ) Property_getName, METH_NOARGS,
+ "() - return Property name"},
+ {"setName", ( PyCFunction ) Property_setName, METH_VARARGS,
+ "() - set the name of this Property"},
+ {"getData", ( PyCFunction ) Property_getData, METH_NOARGS,
+ "() - return Property data"},
+ {"setData", ( PyCFunction ) Property_setData, METH_VARARGS,
+ "() - set the data of this Property"},
+ {"getType", ( PyCFunction ) Property_getType, METH_NOARGS,
+ "() - return Property type"},
+ {NULL, NULL, 0, NULL}
};
-//--------------- Python TypeProperty callback function prototypes----------------------------------------
-static void Property_dealloc (BPy_Property * Property);
-static PyObject *Property_getAttr (BPy_Property * Property, char *name);
-static int Property_setAttr (BPy_Property * Property, char *name, PyObject * v);
-static PyObject *Property_repr (BPy_Property * Property);
-static int Property_compare (BPy_Property * a1, BPy_Property * a2);
-//--------------- Python TypeProperty structure definition------------------------------------------------------
+//--------------- Python TypeProperty callback function prototypes--------
+static void Property_dealloc( BPy_Property * Property );
+static PyObject *Property_getAttr( BPy_Property * Property, char *name );
+static int Property_setAttr( BPy_Property * Property, char *name,
+ PyObject * v );
+static PyObject *Property_repr( BPy_Property * Property );
+static int Property_compare( BPy_Property * a1, BPy_Property * a2 );
+//--------------- Python TypeProperty structure definition----------------
PyTypeObject property_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Property", /* tp_name */
- sizeof (BPy_Property), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) Property_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Property_getAttr, /* tp_getattr */
- (setattrfunc) Property_setAttr, /* tp_setattr */
- (cmpfunc) Property_compare, /* tp_compare */
- (reprfunc) Property_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_Property_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Property", /* tp_name */
+ sizeof( BPy_Property ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Property_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Property_getAttr, /* tp_getattr */
+ ( setattrfunc ) Property_setAttr, /* tp_setattr */
+ ( cmpfunc ) Property_compare, /* tp_compare */
+ ( reprfunc ) Property_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_Property_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//--------------- Property module internal callbacks-------------------------------------------------------------
-//--------------- updatePyProperty-------------------------------------------------------------------------------------
-int
-updatePyProperty(BPy_Property *self)
+//--------------- Property module internal callbacks-------------------
+
+//--------------- updatePyProperty-------------------------------------
+int updatePyProperty( BPy_Property * self )
{
- if(!self->property){
+ if( !self->property ) {
return 0; //nothing to update - not linked
- }else{
- BLI_strncpy(self->name, self->property->name, 32);
+ } else {
+ BLI_strncpy( self->name, self->property->name, 32 );
self->type = self->property->type;
- if(self->property->type == PROP_BOOL){
- if(*((int*)&self->property->poin)){
- self->data = EXPP_incr_ret(Py_True);
- }else{
- self->data = EXPP_incr_ret(Py_False);
+ if( self->property->type == PROP_BOOL ) {
+ if( *( ( int * ) &self->property->poin ) ) {
+ self->data = EXPP_incr_ret( Py_True );
+ } else {
+ self->data = EXPP_incr_ret( Py_False );
}
- }else if (self->property->type == PROP_INT){
- self->data = PyInt_FromLong(self->property->data);
- }else if (self->property->type == PROP_FLOAT){
- self->data = PyFloat_FromDouble(*((float*)&self->property->data));
- }else if (self->property->type == PROP_TIME){
- self->data = PyFloat_FromDouble(*((float*)&self->property->data));
- }else if (self->property->type == PROP_STRING){
- self->data = PyString_FromString(self->property->poin);
+ } else if( self->property->type == PROP_INT ) {
+ self->data = PyInt_FromLong( self->property->data );
+ } else if( self->property->type == PROP_FLOAT ) {
+ self->data =
+ PyFloat_FromDouble( *
+ ( ( float * ) &self->
+ property->data ) );
+ } else if( self->property->type == PROP_TIME ) {
+ self->data =
+ PyFloat_FromDouble( *
+ ( ( float * ) &self->
+ property->data ) );
+ } else if( self->property->type == PROP_STRING ) {
+ self->data =
+ PyString_FromString( self->property->poin );
}
return 1;
}
return 0;
}
-//--------------- updatePropertyData-------------------------------------------------------------------------------------
-int
-updateProperyData(BPy_Property *self)
+
+//--------------- updatePropertyData------------------------------------
+int updateProperyData( BPy_Property * self )
{
- if(!self->property){
+ if( !self->property ) {
//nothing to update - not linked
return 0;
- }else{
- BLI_strncpy(self->property->name, self->name, 32);
+ } else {
+ BLI_strncpy( self->property->name, self->name, 32 );
self->property->type = self->type;
- if(PyInt_Check(self->data)){
- *((int*)&self->property->data) = (int)PyInt_AsLong(self->data);
- }else if (PyFloat_Check(self->data)){
- *((float *)&self->property->data) = (float)PyFloat_AsDouble(self->data);
- }else if (PyString_Check(self->data)){
- BLI_strncpy(self->property->poin, PyString_AsString(self->data), MAX_PROPSTRING);
+ if( PyInt_Check( self->data ) ) {
+ *( ( int * ) &self->property->data ) =
+ ( int ) PyInt_AsLong( self->data );
+ } else if( PyFloat_Check( self->data ) ) {
+ *( ( float * ) &self->property->data ) =
+ ( float ) PyFloat_AsDouble( self->data );
+ } else if( PyString_Check( self->data ) ) {
+ BLI_strncpy( self->property->poin,
+ PyString_AsString( self->data ),
+ MAX_PROPSTRING );
}
return 1;
}
return 0;
}
-//--------------- checkValidData_ptr-------------------------------------------------------------------------------------
-int
-checkValidData_ptr(BPy_Property *self)
-{
+
+//--------------- checkValidData_ptr--------------------------------
+int checkValidData_ptr( BPy_Property * self )
+{
int length;
//test pointer to see if data was removed (oops)
- length = MEM_allocN_len(self->property);
- if(length != sizeof(bProperty)){ //data was freed
+ length = MEM_allocN_len( self->property );
+ if( length != sizeof( bProperty ) ) { //data was freed
self->property = NULL;
return 0;
- }else{ //it's ok as far as we can tell
+ } else { //it's ok as far as we can tell
return 1;
}
}
-//---------------BPy_Property internal callbacks/methods---------------------------------------------
-//--------------- dealloc---------------------------------------------------------------------------------------
-static void
-Property_dealloc (BPy_Property * self)
+
+//---------------BPy_Property internal callbacks/methods------------
+
+//--------------- dealloc-------------------------------------------
+static void Property_dealloc( BPy_Property * self )
{
- PyMem_Free (self->name);
- PyObject_DEL (self);
+ PyMem_Free( self->name );
+ PyObject_DEL( self );
}
-//---------------getattr---------------------------------------------------------------------------------------
-static PyObject *
-Property_getAttr (BPy_Property * self, char *name)
+
+//---------------getattr--------------------------------------------
+static PyObject *Property_getAttr( BPy_Property * self, char *name )
{
PyObject *attr = Py_None;
- checkValidData_ptr(self);
- if (strcmp (name, "name") == 0)
- attr = Property_getName (self);
- else if (strcmp (name, "data") == 0)
- attr = Property_getData (self);
- else if (strcmp (name, "type") == 0)
- attr = Property_getType (self);
- else if (strcmp (name, "__members__") == 0){
- attr = Py_BuildValue ("[s,s,s]", "name", "data","type");
+ checkValidData_ptr( self );
+ if( strcmp( name, "name" ) == 0 )
+ attr = Property_getName( self );
+ else if( strcmp( name, "data" ) == 0 )
+ attr = Property_getData( self );
+ else if( strcmp( name, "type" ) == 0 )
+ attr = Property_getType( self );
+ else if( strcmp( name, "__members__" ) == 0 ) {
+ attr = Py_BuildValue( "[s,s,s]", "name", "data", "type" );
}
- if (!attr)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,"couldn't create PyObject"));
+ if( !attr )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError, "couldn't create PyObject" ) );
- if (attr != Py_None) return attr;
+ if( attr != Py_None )
+ return attr;
- return Py_FindMethod (BPy_Property_methods, (PyObject *) self, name);
+ return Py_FindMethod( BPy_Property_methods, ( PyObject * ) self,
+ name );
}
-//--------------- setattr---------------------------------------------------------------------------------------
+
+//--------------- setattr-------------------------------------------
static int
-Property_setAttr (BPy_Property * self, char *name, PyObject * value)
+Property_setAttr( BPy_Property * self, char *name, PyObject * value )
{
PyObject *valtuple;
PyObject *error = NULL;
- checkValidData_ptr(self);
- valtuple = Py_BuildValue ("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError,
- "PropertySetAttr: couldn't create tuple");
-
- if (strcmp (name, "name") == 0)
- error = Property_setName (self, valtuple);
- else if (strcmp(name, "data") == 0)
- error = Property_setData (self, valtuple);
- else{
- Py_DECREF (valtuple);
- return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found"));
+ checkValidData_ptr( self );
+ valtuple = Py_BuildValue( "(O)", value );
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "PropertySetAttr: couldn't create tuple" );
+
+ if( strcmp( name, "name" ) == 0 )
+ error = Property_setName( self, valtuple );
+ else if( strcmp( name, "data" ) == 0 )
+ error = Property_setData( self, valtuple );
+ else {
+ Py_DECREF( valtuple );
+ return ( EXPP_ReturnIntError
+ ( PyExc_KeyError, "attribute not found" ) );
}
- Py_DECREF (valtuple);
+ Py_DECREF( valtuple );
- if (error != Py_None) return -1;
+ if( error != Py_None )
+ return -1;
- Py_DECREF (Py_None);
- return 0;
+ Py_DECREF( Py_None );
+ return 0;
}
-//--------------- repr---------------------------------------------------------------------------------------
-static PyObject *
-Property_repr (BPy_Property * self)
+
+//--------------- repr----------------------------------------------
+static PyObject *Property_repr( BPy_Property * self )
{
- checkValidData_ptr(self);
- if (self->property){
- return PyString_FromFormat ("[Property \"%s\"]", self->property->name);
- }else{
- return PyString_FromFormat ("[Property \"%s\"]", self->name);
+ checkValidData_ptr( self );
+ if( self->property ) {
+ return PyString_FromFormat( "[Property \"%s\"]",
+ self->property->name );
+ } else {
+ return PyString_FromFormat( "[Property \"%s\"]", self->name );
}
}
-//--------------- compare---------------------------------------------------------------------------------------
+
+//--------------- compare-------------------------------------------
//compares property.name and property.data
-static int
-Property_compare (BPy_Property * a, BPy_Property * b)
+static int Property_compare( BPy_Property * a, BPy_Property * b )
{
BPy_Property *py_propA, *py_propB;
int retval = -1;
- checkValidData_ptr(a);
- checkValidData_ptr(b);
+ checkValidData_ptr( a );
+ checkValidData_ptr( b );
//2 python objects
- if (!a->property && !b->property) {
- if(a->type != b->type) retval = -1;
- if(BLI_streq(a->name, b->name)){
- retval = PyObject_Compare(a->data, b->data);
- }else retval = -1;
- }else if (a->property && b->property){ //2 real properties
- if(a->property->type != b->property->type) retval = -1;
- if(BLI_streq(a->property->name, b->property->name)){
- if(a->property->type == PROP_BOOL || a->property->type == PROP_INT){
- if(a->property->data == b->property->data) retval = 0;
- else retval = -1;
- }else if (a->property->type == PROP_FLOAT || a->property->type == PROP_TIME){
- if(*((float*)&a->property->data) == *((float*)&b->property->data)) retval = 0;
- else retval = -1;
- }else if (a->property->type == PROP_STRING){
- if(BLI_streq(a->property->poin, b->property->poin)) retval = 0;
- else retval = -1;
+ if( !a->property && !b->property ) {
+ if( a->type != b->type )
+ retval = -1;
+ if( BLI_streq( a->name, b->name ) ) {
+ retval = PyObject_Compare( a->data, b->data );
+ } else
+ retval = -1;
+ } else if( a->property && b->property ) { //2 real properties
+ if( a->property->type != b->property->type )
+ retval = -1;
+ if( BLI_streq( a->property->name, b->property->name ) ) {
+ if( a->property->type == PROP_BOOL
+ || a->property->type == PROP_INT ) {
+ if( a->property->data == b->property->data )
+ retval = 0;
+ else
+ retval = -1;
+ } else if( a->property->type == PROP_FLOAT
+ || a->property->type == PROP_TIME ) {
+ if( *( ( float * ) &a->property->data ) ==
+ *( ( float * ) &b->property->data ) )
+ retval = 0;
+ else
+ retval = -1;
+ } else if( a->property->type == PROP_STRING ) {
+ if( BLI_streq
+ ( a->property->poin, b->property->poin ) )
+ retval = 0;
+ else
+ retval = -1;
}
- }else retval = -1;
- }else{ //1 real 1 python
- if(!a->property){
- py_propA = a; py_propB = b;
- }else {
- py_propA = b; py_propB = a;
+ } else
+ retval = -1;
+ } else { //1 real 1 python
+ if( !a->property ) {
+ py_propA = a;
+ py_propB = b;
+ } else {
+ py_propA = b;
+ py_propB = a;
}
- if(py_propB->property->type != py_propA->type) retval = -1;
- if(BLI_streq(py_propB->property->name, py_propA->name)){
- if(py_propB->property->type == PROP_BOOL ||
- py_propB->property->type == PROP_INT){
- retval = PyObject_Compare(py_propA->data,
- PyInt_FromLong(py_propB->property->data));
- }else if (py_propB->property->type == PROP_FLOAT ||
- py_propB->property->type == PROP_TIME){
- retval = PyObject_Compare(py_propA->data,
- PyFloat_FromDouble(*((float*)&py_propB->property->data)));
- }else if (py_propB->property->type == PROP_STRING){
- retval = PyObject_Compare(py_propA->data,
- PyString_FromString(py_propB->property->poin));
+ if( py_propB->property->type != py_propA->type )
+ retval = -1;
+ if( BLI_streq( py_propB->property->name, py_propA->name ) ) {
+ if( py_propB->property->type == PROP_BOOL ||
+ py_propB->property->type == PROP_INT ) {
+ retval = PyObject_Compare( py_propA->data,
+ PyInt_FromLong
+ ( py_propB->
+ property->
+ data ) );
+ } else if( py_propB->property->type == PROP_FLOAT
+ || py_propB->property->type == PROP_TIME ) {
+ retval = PyObject_Compare( py_propA->data,
+ PyFloat_FromDouble
+ ( *
+ ( ( float * )
+ &py_propB->
+ property->
+ data ) ) );
+ } else if( py_propB->property->type == PROP_STRING ) {
+ retval = PyObject_Compare( py_propA->data,
+ PyString_FromString
+ ( py_propB->
+ property->
+ poin ) );
}
- }else retval = -1;
+ } else
+ retval = -1;
}
return retval;
}
-//--------------- Property visible functions--------------------------------------------------------------------
-//--------------- Property_CreatePyObject--------------------------------------------------------------------
-PyObject *
-Property_CreatePyObject (struct bProperty * Property)
+
+//--------------- Property visible functions------------------------
+//--------------- Property_CreatePyObject---------------------------
+PyObject *Property_CreatePyObject( struct bProperty * Property )
{
BPy_Property *py_property;
- py_property = (BPy_Property *)PyObject_NEW (BPy_Property, &property_Type);
+ py_property =
+ ( BPy_Property * ) PyObject_NEW( BPy_Property,
+ &property_Type );
//set the struct flag
py_property->property = Property;
//allocate space for python vars
- py_property->name= PyMem_Malloc (32);
+ py_property->name = PyMem_Malloc( 32 );
- if(!updatePyProperty(py_property))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError , "Property struct empty"));
+ if( !updatePyProperty( py_property ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, "Property struct empty" ) );
- return ((PyObject *) py_property);
+ return ( ( PyObject * ) py_property );
}
-//--------------- Property_CheckPyObject--------------------------------------------------------------------
-int
-Property_CheckPyObject (PyObject * py_obj)
+
+//--------------- Property_CheckPyObject----------------------------
+int Property_CheckPyObject( PyObject * py_obj )
{
- return (py_obj->ob_type == &property_Type);
+ return ( py_obj->ob_type == &property_Type );
}
-//--------------- Property_FromPyObject--------------------------------------------------------------------
-struct bProperty *
-Property_FromPyObject (PyObject * py_obj)
+
+//--------------- Property_FromPyObject-----------------------------
+struct bProperty *Property_FromPyObject( PyObject * py_obj )
{
- BPy_Property *py_property;
+ BPy_Property *py_property;
- py_property = (BPy_Property *) py_obj;
- if (!py_property->property) return NULL;
- else return (py_property->property);
+ py_property = ( BPy_Property * ) py_obj;
+ if( !py_property->property )
+ return NULL;
+ else
+ return ( py_property->property );
}
-//--------------- newPropertyObject()----------------------------------------------------------------------------
-PyObject *
-newPropertyObject (char *name, PyObject *data, int type)
+
+//--------------- newPropertyObject()-------------------------------
+PyObject *newPropertyObject( char *name, PyObject * data, int type )
{
BPy_Property *py_property;
- py_property = (BPy_Property *)PyObject_NEW (BPy_Property, &property_Type);
- py_property->name= PyMem_Malloc (32);
+ py_property =
+ ( BPy_Property * ) PyObject_NEW( BPy_Property,
+ &property_Type );
+ py_property->name = PyMem_Malloc( 32 );
py_property->property = NULL;
- BLI_strncpy(py_property->name, name, 32);
+ BLI_strncpy( py_property->name, name, 32 );
py_property->data = data;
py_property->type = type;
- return (PyObject*)py_property;
+ return ( PyObject * ) py_property;
}
-//--------------- Python BPy_Property methods------------------------------------------------------------------
-//--------------- BPy_Property.getName()--------------------------------------------------------------------------
-static PyObject *
-Property_getName (BPy_Property * self)
+
+//--------------- Python BPy_Property methods-----------------------
+//--------------- BPy_Property.getName()----------------------------
+static PyObject *Property_getName( BPy_Property * self )
{
PyObject *attr = NULL;
- if (!self->property) attr = PyString_FromString (self->name);
- else attr = PyString_FromString (self->property->name);
+ if( !self->property )
+ attr = PyString_FromString( self->name );
+ else
+ attr = PyString_FromString( self->property->name );
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Property.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Property.name attribute" ) );
}
-//--------------- BPy_Property.setName()--------------------------------------------------------------------------
-static PyObject *
-Property_setName (BPy_Property * self, PyObject * args)
+
+//--------------- BPy_Property.setName()----------------------------
+static PyObject *Property_setName( BPy_Property * self, PyObject * args )
{
char *name;
- if (!PyArg_ParseTuple (args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected string argument"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
- if (!self->property){
- BLI_strncpy(self->name, name, 32);
- }else{
- BLI_strncpy(self->property->name, name, 32);
- updatePyProperty(self);
+ if( !self->property ) {
+ BLI_strncpy( self->name, name, 32 );
+ } else {
+ BLI_strncpy( self->property->name, name, 32 );
+ updatePyProperty( self );
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Property.getData()--------------------------------------------------------------------------
-static PyObject *
-Property_getData (BPy_Property * self)
+
+//--------------- BPy_Property.getData()----------------------------
+static PyObject *Property_getData( BPy_Property * self )
{
- PyObject *attr = NULL;
-
- if (!self->property) {
- attr = EXPP_incr_ret(self->data);
- }else{
- if(self->property->type == PROP_BOOL){
- if(*((int*)&self->property->poin))
- attr = EXPP_incr_ret(Py_True);
+ PyObject *attr = NULL;
+
+ if( !self->property ) {
+ attr = EXPP_incr_ret( self->data );
+ } else {
+ if( self->property->type == PROP_BOOL ) {
+ if( *( ( int * ) &self->property->poin ) )
+ attr = EXPP_incr_ret( Py_True );
else
- attr = EXPP_incr_ret(Py_False);
- }else if (self->property->type == PROP_INT){
- attr = PyInt_FromLong(self->property->data);
- }else if (self->property->type == PROP_FLOAT ||
- self->property->type == PROP_TIME){
- attr = PyFloat_FromDouble(*((float*)&self->property->data));
- }else if (self->property->type == PROP_STRING){
- attr = PyString_FromString(self->property->poin);
+ attr = EXPP_incr_ret( Py_False );
+ } else if( self->property->type == PROP_INT ) {
+ attr = PyInt_FromLong( self->property->data );
+ } else if( self->property->type == PROP_FLOAT ||
+ self->property->type == PROP_TIME ) {
+ attr = PyFloat_FromDouble( *
+ ( ( float * ) &self->
+ property->data ) );
+ } else if( self->property->type == PROP_STRING ) {
+ attr = PyString_FromString( self->property->poin );
}
}
- if (attr) return attr;
+ if( attr )
+ return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Property.name attribute"));
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get Property.name attribute" ) );
}
-//--------------- BPy_Property.setData()--------------------------------------------------------------------------
-static PyObject *
-Property_setData (BPy_Property * self, PyObject * args)
+
+//--------------- BPy_Property.setData()----------------------------
+static PyObject *Property_setData( BPy_Property * self, PyObject * args )
{
PyObject *data;
char *type_str = NULL;
int type = -1;
short *p_type = NULL;
- if (!PyArg_ParseTuple (args, "O|s", &data, &type_str))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected object and optional string argument"));
+ if( !PyArg_ParseTuple( args, "O|s", &data, &type_str ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected object and optional string argument" ) );
- if(!PyInt_Check(data) && !PyFloat_Check(data) && !PyString_Check(data))
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "float, int, or string expected as data"));
+ if( !PyInt_Check( data ) && !PyFloat_Check( data )
+ && !PyString_Check( data ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError,
+ "float, int, or string expected as data" ) );
//parse property name
- if(type_str){
- if(BLI_streq(type_str, "BOOL")) type = PROP_BOOL;
- else if (BLI_streq(type_str, "INT")) type = PROP_INT;
- else if (BLI_streq(type_str, "FLOAT")) type = PROP_FLOAT;
- else if (BLI_streq(type_str, "TIME")) type = PROP_TIME;
- else if (BLI_streq(type_str, "STRING")) type = PROP_STRING;
- else return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "BOOL, INT, FLOAT, TIME or STRING expected"));
+ if( type_str ) {
+ if( BLI_streq( type_str, "BOOL" ) )
+ type = PROP_BOOL;
+ else if( BLI_streq( type_str, "INT" ) )
+ type = PROP_INT;
+ else if( BLI_streq( type_str, "FLOAT" ) )
+ type = PROP_FLOAT;
+ else if( BLI_streq( type_str, "TIME" ) )
+ type = PROP_TIME;
+ else if( BLI_streq( type_str, "STRING" ) )
+ type = PROP_STRING;
+ else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "BOOL, INT, FLOAT, TIME or STRING expected" ) );
}
-
//get pointer to type
- if(self->property) p_type = &self->property->type;
- else p_type = &self->type;
+ if( self->property )
+ p_type = &self->property->type;
+ else
+ p_type = &self->type;
//set the type
- if(PyInt_Check(data)){
- if(type == -1 || type == PROP_INT) *p_type = PROP_INT;
- else *p_type = PROP_BOOL;
- }else if(PyFloat_Check(data)){
- if(type == -1 || type == PROP_FLOAT) *p_type = PROP_FLOAT;
- else *p_type = PROP_TIME;
- }else if(PyString_Check(data)){
- if(type == -1 || type == PROP_STRING) *p_type = PROP_STRING;
- }else{
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "cant set unknown data type"));
+ if( PyInt_Check( data ) ) {
+ if( type == -1 || type == PROP_INT )
+ *p_type = PROP_INT;
+ else
+ *p_type = PROP_BOOL;
+ } else if( PyFloat_Check( data ) ) {
+ if( type == -1 || type == PROP_FLOAT )
+ *p_type = PROP_FLOAT;
+ else
+ *p_type = PROP_TIME;
+ } else if( PyString_Check( data ) ) {
+ if( type == -1 || type == PROP_STRING )
+ *p_type = PROP_STRING;
+ } else {
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "cant set unknown data type" ) );
}
//set the data
- if(self->property){
- if(PyInt_Check(data)){
- *((int*)&self->property->data) = (int)PyInt_AsLong(data);
- }else if (PyFloat_Check(data)){
- *((float *)&self->property->data) = (float)PyFloat_AsDouble(data);
- }else if (PyString_Check(data)){
- BLI_strncpy(self->property->poin, PyString_AsString(data), MAX_PROPSTRING);
+ if( self->property ) {
+ if( PyInt_Check( data ) ) {
+ *( ( int * ) &self->property->data ) =
+ ( int ) PyInt_AsLong( data );
+ } else if( PyFloat_Check( data ) ) {
+ *( ( float * ) &self->property->data ) =
+ ( float ) PyFloat_AsDouble( data );
+ } else if( PyString_Check( data ) ) {
+ BLI_strncpy( self->property->poin,
+ PyString_AsString( data ),
+ MAX_PROPSTRING );
}
- updatePyProperty(self);
- }else{
+ updatePyProperty( self );
+ } else {
self->data = data;
}
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//--------------- BPy_Property.getType()--------------------------------------------------------------------------
-static PyObject *
-Property_getType (BPy_Property * self)
+
+//--------------- BPy_Property.getType()----------------------------
+static PyObject *Property_getType( BPy_Property * self )
{
PyObject *attr = Py_None;
int type;
- if(self->property) type = self->property->type;
- else type = self->type;
-
- if(type == PROP_BOOL) attr = Py_BuildValue("s", "BOOL");
- else if (type == PROP_INT) attr = Py_BuildValue("s", "INT");
- else if (type == PROP_FLOAT) attr = Py_BuildValue("s", "FLOAT");
- else if (type == PROP_STRING) attr = Py_BuildValue("s", "STRING");
- else if (type == PROP_TIME) attr = Py_BuildValue("s", "TIME");
+ if( self->property )
+ type = self->property->type;
+ else
+ type = self->type;
+
+ if( type == PROP_BOOL )
+ attr = Py_BuildValue( "s", "BOOL" );
+ else if( type == PROP_INT )
+ attr = Py_BuildValue( "s", "INT" );
+ else if( type == PROP_FLOAT )
+ attr = Py_BuildValue( "s", "FLOAT" );
+ else if( type == PROP_STRING )
+ attr = Py_BuildValue( "s", "STRING" );
+ else if( type == PROP_TIME )
+ attr = Py_BuildValue( "s", "TIME" );
return attr;
}
-
diff --git a/source/blender/python/api2_2x/logic.h b/source/blender/python/api2_2x/logic.h
index cf4a1070bb2..dfd42f19b72 100644
--- a/source/blender/python/api2_2x/logic.h
+++ b/source/blender/python/api2_2x/logic.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -35,23 +36,23 @@
#include "Python.h"
#include <DNA_property_types.h>
-//--------------------------Python BPy_Property structure definition.---------------------
-typedef struct{
- PyObject_HEAD
- //reference to property data if object linked
- bProperty *property;
+//--------------------------Python BPy_Property structure definition.----
+typedef struct {
+ PyObject_HEAD
+ //reference to property data if object linked
+ bProperty * property;
//list of vars that define the property
- char *name;
+ char *name;
PyObject *data;
short type;
-}BPy_Property;
+} BPy_Property;
-//------------------------------visible prototypes----------------------------------------------
-PyObject *Property_CreatePyObject (struct bProperty *prop);
-int Property_CheckPyObject (PyObject * py_obj);
-bProperty *Property_FromPyObject (PyObject * py_obj);
-PyObject * newPropertyObject (char *name, PyObject *data, int type);
-int updatePyProperty(BPy_Property *self);
-int updateProperyData(BPy_Property *self);
+//------------------------------visible prototypes-----------------------
+PyObject *Property_CreatePyObject( struct bProperty *prop );
+int Property_CheckPyObject( PyObject * py_obj );
+bProperty *Property_FromPyObject( PyObject * py_obj );
+PyObject *newPropertyObject( char *name, PyObject * data, int type );
+int updatePyProperty( BPy_Property * self );
+int updateProperyData( BPy_Property * self );
#endif
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c
index 4bb93fe8ac7..1bf0e91640f 100644
--- a/source/blender/python/api2_2x/matrix.c
+++ b/source/blender/python/api2_2x/matrix.c
@@ -31,49 +31,44 @@
#include "matrix.h"
//doc strings
-char Matrix_Zero_doc[] =
-"() - set all values in the matrix to 0";
+char Matrix_Zero_doc[] = "() - set all values in the matrix to 0";
char Matrix_Identity_doc[] =
-"() - set the square matrix to it's identity matrix";
-char Matrix_Transpose_doc[] =
-"() - set the matrix to it's transpose";
-char Matrix_Determinant_doc[] =
-"() - return the determinant of the matrix";
+ "() - set the square matrix to it's identity matrix";
+char Matrix_Transpose_doc[] = "() - set the matrix to it's transpose";
+char Matrix_Determinant_doc[] = "() - return the determinant of the matrix";
char Matrix_Invert_doc[] =
-"() - set the matrix to it's inverse if an inverse is possible";
-char Matrix_TranslationPart_doc[] =
-"() - return a vector encompassing the translation of the matrix";
-char Matrix_RotationPart_doc[] =
-"() - return a vector encompassing the rotation of the matrix";
-char Matrix_Resize4x4_doc[] =
-"() - resize the matrix to a 4x4 square matrix";
-char Matrix_toEuler_doc[] =
-"() - convert matrix to a euler angle rotation";
-char Matrix_toQuat_doc[] =
-"() - convert matrix to a quaternion rotation";
+ "() - set the matrix to it's inverse if an inverse is possible";
+char Matrix_TranslationPart_doc[] =
+ "() - return a vector encompassing the translation of the matrix";
+char Matrix_RotationPart_doc[] =
+ "() - return a vector encompassing the rotation of the matrix";
+char Matrix_Resize4x4_doc[] = "() - resize the matrix to a 4x4 square matrix";
+char Matrix_toEuler_doc[] = "() - convert matrix to a euler angle rotation";
+char Matrix_toQuat_doc[] = "() - convert matrix to a quaternion rotation";
//methods table
struct PyMethodDef Matrix_methods[] = {
- {"zero",(PyCFunction)Matrix_Zero, METH_NOARGS,
- Matrix_Zero_doc},
- {"identity",(PyCFunction)Matrix_Identity, METH_NOARGS,
- Matrix_Identity_doc},
- {"transpose",(PyCFunction)Matrix_Transpose, METH_NOARGS,
- Matrix_Transpose_doc},
- {"determinant",(PyCFunction)Matrix_Determinant, METH_NOARGS,
- Matrix_Determinant_doc},
- {"invert",(PyCFunction)Matrix_Invert, METH_NOARGS,
- Matrix_Invert_doc},
- {"translationPart",(PyCFunction)Matrix_TranslationPart, METH_NOARGS,
- Matrix_TranslationPart_doc},
- {"rotationPart",(PyCFunction)Matrix_RotationPart, METH_NOARGS,
- Matrix_RotationPart_doc},
- {"resize4x4",(PyCFunction)Matrix_Resize4x4, METH_NOARGS,
- Matrix_Resize4x4_doc},
- {"toEuler",(PyCFunction)Matrix_toEuler, METH_NOARGS,
- Matrix_toEuler_doc},
- {"toQuat",(PyCFunction)Matrix_toQuat, METH_NOARGS,
- Matrix_toQuat_doc},
+ {"zero", ( PyCFunction ) Matrix_Zero, METH_NOARGS,
+ Matrix_Zero_doc},
+ {"identity", ( PyCFunction ) Matrix_Identity, METH_NOARGS,
+ Matrix_Identity_doc},
+ {"transpose", ( PyCFunction ) Matrix_Transpose, METH_NOARGS,
+ Matrix_Transpose_doc},
+ {"determinant", ( PyCFunction ) Matrix_Determinant, METH_NOARGS,
+ Matrix_Determinant_doc},
+ {"invert", ( PyCFunction ) Matrix_Invert, METH_NOARGS,
+ Matrix_Invert_doc},
+ {"translationPart", ( PyCFunction ) Matrix_TranslationPart,
+ METH_NOARGS,
+ Matrix_TranslationPart_doc},
+ {"rotationPart", ( PyCFunction ) Matrix_RotationPart, METH_NOARGS,
+ Matrix_RotationPart_doc},
+ {"resize4x4", ( PyCFunction ) Matrix_Resize4x4, METH_NOARGS,
+ Matrix_Resize4x4_doc},
+ {"toEuler", ( PyCFunction ) Matrix_toEuler, METH_NOARGS,
+ Matrix_toEuler_doc},
+ {"toQuat", ( PyCFunction ) Matrix_toQuat, METH_NOARGS,
+ Matrix_toQuat_doc},
{NULL, NULL, 0, NULL}
};
@@ -81,400 +76,423 @@ struct PyMethodDef Matrix_methods[] = {
// Matrix Python Object
/*****************************/
-PyObject *Matrix_toQuat(MatrixObject *self)
+PyObject *Matrix_toQuat( MatrixObject * self )
{
float *quat, *mat;
- if(self->colSize < 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
- }else if (self->colSize > 2){ //3 or 4 col
- if(self->rowSize < 3) //3 or 4 row
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
-
- mat = PyMem_Malloc(3*3*sizeof(float));
- mat[0] = self->matrix[0][0]; mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2]; mat[3] = self->matrix[1][0];
- mat[4] = self->matrix[1][1]; mat[5] = self->matrix[1][2];
- mat[6] = self->matrix[2][0]; mat[7] = self->matrix[2][1];
+ if( self->colSize < 3 ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+ } else if( self->colSize > 2 ) { //3 or 4 col
+ if( self->rowSize < 3 ) //3 or 4 row
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+
+ mat = PyMem_Malloc( 3 * 3 * sizeof( float ) );
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[2] = self->matrix[0][2];
+ mat[3] = self->matrix[1][0];
+ mat[4] = self->matrix[1][1];
+ mat[5] = self->matrix[1][2];
+ mat[6] = self->matrix[2][0];
+ mat[7] = self->matrix[2][1];
mat[8] = self->matrix[2][2];
}
- quat = PyMem_Malloc(4*sizeof(float));
- Mat3ToQuat((float(*)[3])mat,quat);
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ Mat3ToQuat( ( float ( * )[3] ) mat, quat );
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-PyObject *Matrix_toEuler(MatrixObject *self)
+PyObject *Matrix_toEuler( MatrixObject * self )
{
float *eul, *mat;
int x;
- if(self->colSize < 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
- }else if (self->colSize > 2){ //3 or 4 col
- if(self->rowSize < 3) //3 or 4 row
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
-
- mat = PyMem_Malloc(3*3*sizeof(float));
- mat[0] = self->matrix[0][0]; mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2]; mat[3] = self->matrix[1][0];
- mat[4] = self->matrix[1][1]; mat[5] = self->matrix[1][2];
- mat[6] = self->matrix[2][0]; mat[7] = self->matrix[2][1];
+ if( self->colSize < 3 ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+ } else if( self->colSize > 2 ) { //3 or 4 col
+ if( self->rowSize < 3 ) //3 or 4 row
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+
+ mat = PyMem_Malloc( 3 * 3 * sizeof( float ) );
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[2] = self->matrix[0][2];
+ mat[3] = self->matrix[1][0];
+ mat[4] = self->matrix[1][1];
+ mat[5] = self->matrix[1][2];
+ mat[6] = self->matrix[2][0];
+ mat[7] = self->matrix[2][1];
mat[8] = self->matrix[2][2];
}
- eul = PyMem_Malloc(3*sizeof(float));
- Mat3ToEul((float(*)[3])mat,eul);
+ eul = PyMem_Malloc( 3 * sizeof( float ) );
+ Mat3ToEul( ( float ( * )[3] ) mat, eul );
- for(x = 0; x < 3; x++){
- eul[x] *= (float)(180/Py_PI);
+ for( x = 0; x < 3; x++ ) {
+ eul[x] *= ( float ) ( 180 / Py_PI );
}
- return (PyObject*)newEulerObject(eul);
+ return ( PyObject * ) newEulerObject( eul );
}
-PyObject *Matrix_Resize4x4(MatrixObject *self)
+PyObject *Matrix_Resize4x4( MatrixObject * self )
{
float *mat;
- float * contigPtr;
+ float *contigPtr;
int x, row, col;
- if(self->colSize == 4 && self->rowSize == 4)
- return EXPP_incr_ret(Py_None);
+ if( self->colSize == 4 && self->rowSize == 4 )
+ return EXPP_incr_ret( Py_None );
- mat = PyMem_Malloc(4*4*sizeof(float));
- for(x = 0; x < 16; x++){
+ mat = PyMem_Malloc( 4 * 4 * sizeof( float ) );
+ for( x = 0; x < 16; x++ ) {
mat[x] = 0.0f;
}
- if(self->colSize == 2){ //2x2, 2x3, 2x4
- mat[0] = self->matrix[0][0];mat[1] = self->matrix[0][1];
- mat[4] = self->matrix[1][0];mat[5] = self->matrix[1][1];
- if (self->rowSize > 2){
- mat[8] = self->matrix[2][0];mat[9] = self->matrix[2][1];
+ if( self->colSize == 2 ) { //2x2, 2x3, 2x4
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[4] = self->matrix[1][0];
+ mat[5] = self->matrix[1][1];
+ if( self->rowSize > 2 ) {
+ mat[8] = self->matrix[2][0];
+ mat[9] = self->matrix[2][1];
}
- if (self->rowSize > 3){
- mat[12] = self->matrix[3][0];mat[13] = self->matrix[3][1];
+ if( self->rowSize > 3 ) {
+ mat[12] = self->matrix[3][0];
+ mat[13] = self->matrix[3][1];
}
- mat[10] = 1.0f; mat[15] = 1.0f;
- }else if (self->colSize == 3){ //3x2, 3x3, 3x4
- mat[0] = self->matrix[0][0];mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2];mat[4] = self->matrix[1][0];
- mat[5] = self->matrix[1][1];mat[6] = self->matrix[1][2];
- if (self->rowSize > 2){
- mat[8] = self->matrix[2][0];mat[9] = self->matrix[2][1];
+ mat[10] = 1.0f;
+ mat[15] = 1.0f;
+ } else if( self->colSize == 3 ) { //3x2, 3x3, 3x4
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[2] = self->matrix[0][2];
+ mat[4] = self->matrix[1][0];
+ mat[5] = self->matrix[1][1];
+ mat[6] = self->matrix[1][2];
+ if( self->rowSize > 2 ) {
+ mat[8] = self->matrix[2][0];
+ mat[9] = self->matrix[2][1];
mat[10] = self->matrix[2][2];
}
- if (self->rowSize > 3){
- mat[12] = self->matrix[3][0];mat[13] = self->matrix[3][1];
+ if( self->rowSize > 3 ) {
+ mat[12] = self->matrix[3][0];
+ mat[13] = self->matrix[3][1];
mat[14] = self->matrix[3][2];
}
- if(self->rowSize == 2) mat[10] = 1.0f;
- mat[15] = 1.0f;
- }else if (self->colSize == 4){ //2x4, 3x4
- mat[0] = self->matrix[0][0];mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2];mat[3] = self->matrix[0][3];
- mat[4] = self->matrix[1][0];mat[5] = self->matrix[1][1];
- mat[6] = self->matrix[1][2];mat[7] = self->matrix[1][3];
- if (self->rowSize > 2
- ){
- mat[8] = self->matrix[2][0];mat[9] = self->matrix[2][1];
- mat[10] = self->matrix[2][2];mat[11] = self->matrix[2][3];
+ if( self->rowSize == 2 )
+ mat[10] = 1.0f;
+ mat[15] = 1.0f;
+ } else if( self->colSize == 4 ) { //2x4, 3x4
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[2] = self->matrix[0][2];
+ mat[3] = self->matrix[0][3];
+ mat[4] = self->matrix[1][0];
+ mat[5] = self->matrix[1][1];
+ mat[6] = self->matrix[1][2];
+ mat[7] = self->matrix[1][3];
+ if( self->rowSize > 2 ) {
+ mat[8] = self->matrix[2][0];
+ mat[9] = self->matrix[2][1];
+ mat[10] = self->matrix[2][2];
+ mat[11] = self->matrix[2][3];
}
- if(self->rowSize == 2) mat[10] = 1.0f;
+ if( self->rowSize == 2 )
+ mat[10] = 1.0f;
mat[15] = 1.0f;
}
- PyMem_Free(*self->matrix);
- contigPtr = PyMem_Malloc(4 * 4 * sizeof(float));
- if(contigPtr == NULL){
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "problem allocating array space\n\n"));
+ PyMem_Free( *self->matrix );
+ contigPtr = PyMem_Malloc( 4 * 4 * sizeof( float ) );
+ if( contigPtr == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "problem allocating array space\n\n" ) );
}
- self->matrix = PyMem_Malloc(4* sizeof(float*));
- if(self->matrix == NULL){
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "problem allocating pointer space\n\n"));
+ self->matrix = PyMem_Malloc( 4 * sizeof( float * ) );
+ if( self->matrix == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "problem allocating pointer space\n\n" ) );
+ }
+ for( x = 0; x < 4; x++ ) {
+ self->matrix[x] = contigPtr + ( x * 4 );
}
- for (x = 0; x < 4; x++){
- self->matrix[x] = contigPtr + (x *4);
- }
- for (row = 0; row < 4; row++){
- for(col = 0; col < 4; col++){
- self->matrix[row][col] = mat[(row * 4) + col];
+ for( row = 0; row < 4; row++ ) {
+ for( col = 0; col < 4; col++ ) {
+ self->matrix[row][col] = mat[( row * 4 ) + col];
}
}
- PyMem_Free(mat);
+ PyMem_Free( mat );
self->colSize = 4;
self->rowSize = 4;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Matrix_TranslationPart(MatrixObject *self)
+PyObject *Matrix_TranslationPart( MatrixObject * self )
{
float *vec;
- if(self->colSize < 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
- }else if (self->colSize > 2){ //3 or 4 columns
- if(self->rowSize < 4) //all 4 rows
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
+ if( self->colSize < 3 ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+ } else if( self->colSize > 2 ) { //3 or 4 columns
+ if( self->rowSize < 4 ) //all 4 rows
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
- vec = PyMem_Malloc(3 * sizeof(float));
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
vec[0] = self->matrix[3][0];
vec[1] = self->matrix[3][1];
vec[2] = self->matrix[3][2];
}
- return (PyObject*)newVectorObject(vec,3);
+ return ( PyObject * ) newVectorObject( vec, 3 );
}
-PyObject *Matrix_RotationPart(MatrixObject *self)
+PyObject *Matrix_RotationPart( MatrixObject * self )
{
float *mat;
- if(self->colSize < 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
- }else if (self->colSize > 2){ //3 or 4 col
- if(self->rowSize < 3) //3 or 4 row
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "inappropriate matrix size\n");
-
- mat = PyMem_Malloc(3*3*sizeof(float));
- mat[0] = self->matrix[0][0]; mat[1] = self->matrix[0][1];
- mat[2] = self->matrix[0][2]; mat[3] = self->matrix[1][0];
- mat[4] = self->matrix[1][1]; mat[5] = self->matrix[1][2];
- mat[6] = self->matrix[2][0]; mat[7] = self->matrix[2][1];
+ if( self->colSize < 3 ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+ } else if( self->colSize > 2 ) { //3 or 4 col
+ if( self->rowSize < 3 ) //3 or 4 row
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "inappropriate matrix size\n" );
+
+ mat = PyMem_Malloc( 3 * 3 * sizeof( float ) );
+ mat[0] = self->matrix[0][0];
+ mat[1] = self->matrix[0][1];
+ mat[2] = self->matrix[0][2];
+ mat[3] = self->matrix[1][0];
+ mat[4] = self->matrix[1][1];
+ mat[5] = self->matrix[1][2];
+ mat[6] = self->matrix[2][0];
+ mat[7] = self->matrix[2][1];
mat[8] = self->matrix[2][2];
}
- return (PyObject*)newMatrixObject(mat,3,3);
+ return ( PyObject * ) newMatrixObject( mat, 3, 3 );
}
-PyObject *Matrix_Invert(MatrixObject *self)
+PyObject *Matrix_Invert( MatrixObject * self )
{
float det;
- int x,y,z;
+ int x, y, z;
float *mat = NULL;
float t;
- if(self->rowSize != self->colSize)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "only square matrices are supported\n");
+ if( self->rowSize != self->colSize )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "only square matrices are supported\n" );
//calculate the determinant
- if(self->rowSize == 2){
- det = Det2x2(self->matrix[0][0], self->matrix[0][1],
- self->matrix[1][0], self->matrix[1][1]);
- }else if(self->rowSize == 3){
- det = Det3x3(self->matrix[0][0], self->matrix[0][1],
- self->matrix[0][2], self->matrix[1][0],
- self->matrix[1][1], self->matrix[1][2],
- self->matrix[2][0], self->matrix[2][1],
- self->matrix[2][2]);
- }else if(self->rowSize == 4){
- det = Det4x4(*self->matrix);
- }else{
- return EXPP_ReturnPyObjError(PyExc_StandardError,
- "error calculating determinant for inverse()\n");
- }
-
- if(det != 0){
+ if( self->rowSize == 2 ) {
+ det = Det2x2( self->matrix[0][0], self->matrix[0][1],
+ self->matrix[1][0], self->matrix[1][1] );
+ } else if( self->rowSize == 3 ) {
+ det = Det3x3( self->matrix[0][0], self->matrix[0][1],
+ self->matrix[0][2], self->matrix[1][0],
+ self->matrix[1][1], self->matrix[1][2],
+ self->matrix[2][0], self->matrix[2][1],
+ self->matrix[2][2] );
+ } else if( self->rowSize == 4 ) {
+ det = Det4x4( *self->matrix );
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_StandardError,
+ "error calculating determinant for inverse()\n" );
+ }
+
+ if( det != 0 ) {
//calculate the classical adjoint
- if(self->rowSize == 2){
- mat = PyMem_Malloc(self->rowSize * self->colSize * sizeof(float));
+ if( self->rowSize == 2 ) {
+ mat = PyMem_Malloc( self->rowSize * self->colSize *
+ sizeof( float ) );
mat[0] = self->matrix[1][1];
mat[1] = -self->matrix[1][0];
mat[2] = -self->matrix[0][1];
mat[3] = self->matrix[0][0];
- }else if(self->rowSize == 3){
- mat = PyMem_Malloc(self->rowSize * self->colSize * sizeof(float));
- Mat3Adj((float(*)[3])mat, *self->matrix);
- }else if (self->rowSize == 4){
- mat = PyMem_Malloc(self->rowSize * self->colSize * sizeof(float));
- Mat4Adj((float(*)[4])mat, *self->matrix);
+ } else if( self->rowSize == 3 ) {
+ mat = PyMem_Malloc( self->rowSize * self->colSize *
+ sizeof( float ) );
+ Mat3Adj( ( float ( * )[3] ) mat, *self->matrix );
+ } else if( self->rowSize == 4 ) {
+ mat = PyMem_Malloc( self->rowSize * self->colSize *
+ sizeof( float ) );
+ Mat4Adj( ( float ( * )[4] ) mat, *self->matrix );
}
-
//divide by determinate
- for(x = 0; x < (self->rowSize * self->colSize); x++){
+ for( x = 0; x < ( self->rowSize * self->colSize ); x++ ) {
mat[x] /= det;
}
//set values
z = 0;
- for(x = 0; x < self->rowSize; x++){
- for(y = 0; y < self->colSize; y++){
+ for( x = 0; x < self->rowSize; x++ ) {
+ for( y = 0; y < self->colSize; y++ ) {
self->matrix[x][y] = mat[z];
z++;
}
}
//transpose
- if(self->rowSize == 2){
+ if( self->rowSize == 2 ) {
t = self->matrix[1][0];
self->matrix[1][0] = self->matrix[0][1];
self->matrix[0][1] = t;
- }else if(self->rowSize == 3){
- Mat3Transp((float(*)[3])mat);
- }
- else if (self->rowSize == 4){
- Mat4Transp((float(*)[4])mat);
+ } else if( self->rowSize == 3 ) {
+ Mat3Transp( ( float ( * )[3] ) mat );
+ } else if( self->rowSize == 4 ) {
+ Mat4Transp( ( float ( * )[4] ) mat );
}
- }else{
- printf("matrix does not have an inverse - none attempted\n");
+ } else {
+ printf( "matrix does not have an inverse - none attempted\n" );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Matrix_Determinant(MatrixObject *self)
+PyObject *Matrix_Determinant( MatrixObject * self )
{
float det;
- if(self->rowSize != self->colSize)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "only square matrices are supported\n");
-
- if(self->rowSize == 2){
- det = Det2x2(self->matrix[0][0], self->matrix[0][1],
- self->matrix[1][0], self->matrix[1][1]);
- }else if(self->rowSize == 3){
- det = Det3x3(self->matrix[0][0], self->matrix[0][1],
- self->matrix[0][2], self->matrix[1][0],
- self->matrix[1][1], self->matrix[1][2],
- self->matrix[2][0], self->matrix[2][1],
- self->matrix[2][2]);
- }else if(self->rowSize == 4){
- det = Det4x4(*self->matrix);
- }else{
- return EXPP_ReturnPyObjError(PyExc_StandardError,
- "error in determinant()\n");
- }
- return PyFloat_FromDouble(det);
+ if( self->rowSize != self->colSize )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "only square matrices are supported\n" );
+
+ if( self->rowSize == 2 ) {
+ det = Det2x2( self->matrix[0][0], self->matrix[0][1],
+ self->matrix[1][0], self->matrix[1][1] );
+ } else if( self->rowSize == 3 ) {
+ det = Det3x3( self->matrix[0][0], self->matrix[0][1],
+ self->matrix[0][2], self->matrix[1][0],
+ self->matrix[1][1], self->matrix[1][2],
+ self->matrix[2][0], self->matrix[2][1],
+ self->matrix[2][2] );
+ } else if( self->rowSize == 4 ) {
+ det = Det4x4( *self->matrix );
+ } else {
+ return EXPP_ReturnPyObjError( PyExc_StandardError,
+ "error in determinant()\n" );
+ }
+ return PyFloat_FromDouble( det );
}
-PyObject *Matrix_Transpose(MatrixObject *self)
+PyObject *Matrix_Transpose( MatrixObject * self )
{
float t;
- if(self->rowSize != self->colSize)
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "only square matrices are supported\n");
+ if( self->rowSize != self->colSize )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "only square matrices are supported\n" );
- if(self->rowSize == 2){
+ if( self->rowSize == 2 ) {
t = self->matrix[1][0];
self->matrix[1][0] = self->matrix[0][1];
self->matrix[0][1] = t;
- }
- else if(self->rowSize == 3){
- Mat3Transp(*self->matrix);
- }
- else if (self->rowSize == 4){
- Mat4Transp(*self->matrix);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "unable to transpose matrix\n"));
-
- return EXPP_incr_ret(Py_None);
+ } else if( self->rowSize == 3 ) {
+ Mat3Transp( *self->matrix );
+ } else if( self->rowSize == 4 ) {
+ Mat4Transp( *self->matrix );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unable to transpose matrix\n" ) );
+
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Matrix_Zero(MatrixObject *self)
+PyObject *Matrix_Zero( MatrixObject * self )
{
int row, col;
- for (row = 0; row < self->rowSize; row++){
- for (col = 0; col < self->colSize; col++){
+ for( row = 0; row < self->rowSize; row++ ) {
+ for( col = 0; col < self->colSize; col++ ) {
self->matrix[row][col] = 0.0f;
}
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Matrix_Identity(MatrixObject *self)
+PyObject *Matrix_Identity( MatrixObject * self )
{
- if(self->rowSize != self->colSize)
- return (EXPP_ReturnPyObjError(PyExc_AttributeError,
- "only square matrices supported\n"));
+ if( self->rowSize != self->colSize )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "only square matrices supported\n" ) );
- if(self->rowSize == 2){
+ if( self->rowSize == 2 ) {
self->matrix[0][0] = 1.0f;
self->matrix[0][1] = 0.0f;
self->matrix[1][0] = 0.0f;
self->matrix[1][1] = 1.0f;
- }
- else if(self->rowSize == 3){
- Mat3One(*self->matrix);
- }
- else if (self->rowSize == 4){
- Mat4One(*self->matrix);
- }
- else
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "unable to create identity matrix\n"));
-
- return EXPP_incr_ret(Py_None);
+ } else if( self->rowSize == 3 ) {
+ Mat3One( *self->matrix );
+ } else if( self->rowSize == 4 ) {
+ Mat4One( *self->matrix );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unable to create identity matrix\n" ) );
+
+ return EXPP_incr_ret( Py_None );
}
-static void Matrix_dealloc (MatrixObject *self)
+static void Matrix_dealloc( MatrixObject * self )
{
- PyMem_Free (self->matrix);
- PyMem_DEL (self);
+ PyMem_Free( self->matrix );
+ PyMem_DEL( self );
}
-static PyObject * Matrix_getattr (MatrixObject *self, char *name)
+static PyObject *Matrix_getattr( MatrixObject * self, char *name )
{
- if (strcmp (name, "rowSize") == 0){
- return PyInt_FromLong((long)self->rowSize);
- }
- else if (strcmp (name, "colSize") == 0){
- return PyInt_FromLong((long)self->colSize);
- }
-
- return Py_FindMethod(Matrix_methods, (PyObject*)self, name);
+ if( strcmp( name, "rowSize" ) == 0 ) {
+ return PyInt_FromLong( ( long ) self->rowSize );
+ } else if( strcmp( name, "colSize" ) == 0 ) {
+ return PyInt_FromLong( ( long ) self->colSize );
+ }
+
+ return Py_FindMethod( Matrix_methods, ( PyObject * ) self, name );
}
-static int Matrix_setattr (MatrixObject *self, char *name, PyObject *v)
+static int Matrix_setattr( MatrixObject * self, char *name, PyObject * v )
{
- /* This is not supported. */
- return (-1);
+ /* This is not supported. */
+ return ( -1 );
}
-static PyObject * Matrix_repr (MatrixObject *self)
+static PyObject *Matrix_repr( MatrixObject * self )
{
PyObject *repr, *str;
- int x,y;
+ int x, y;
char ftoa[24];
- repr = PyString_FromString("");
- if (!repr)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Attribute error in PyMatrix (repr)\n"));
+ repr = PyString_FromString( "" );
+ if( !repr )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Attribute error in PyMatrix (repr)\n" ) );
- for(x = 0; x < self->rowSize; x++){
- str = PyString_FromString ("[");
- PyString_ConcatAndDel(&repr,str);
+ for( x = 0; x < self->rowSize; x++ ) {
+ str = PyString_FromString( "[" );
+ PyString_ConcatAndDel( &repr, str );
- for(y = 0; y < (self->colSize - 1); y++){
- sprintf(ftoa, "%.4f, ", self->matrix[x][y]);
- str = PyString_FromString (ftoa);
- PyString_ConcatAndDel(&repr,str);
+ for( y = 0; y < ( self->colSize - 1 ); y++ ) {
+ sprintf( ftoa, "%.4f, ", self->matrix[x][y] );
+ str = PyString_FromString( ftoa );
+ PyString_ConcatAndDel( &repr, str );
}
- sprintf(ftoa, "%.4f]\n", self->matrix[x][y]);
- str = PyString_FromString (ftoa);
- PyString_ConcatAndDel(&repr,str);
+ sprintf( ftoa, "%.4f]\n", self->matrix[x][y] );
+ str = PyString_FromString( ftoa );
+ PyString_ConcatAndDel( &repr, str );
}
return repr;
}
@@ -482,398 +500,421 @@ static PyObject * Matrix_repr (MatrixObject *self)
//no support for matrix[x][y] so have to return by sequence index
//will return a row from the matrix to support previous API
//compatability
-static PyObject * Matrix_item (MatrixObject *self, int i)
+static PyObject *Matrix_item( MatrixObject * self, int i )
{
float *vec;
int x;
- if(i < 0 || i >= self->rowSize)
- return EXPP_ReturnPyObjError(PyExc_IndexError,
- "matrix row index out of range\n");
+ if( i < 0 || i >= self->rowSize )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "matrix row index out of range\n" );
- vec = PyMem_Malloc (self->colSize *sizeof (float));
- for(x = 0; x < self->colSize; x++){
+ vec = PyMem_Malloc( self->colSize * sizeof( float ) );
+ for( x = 0; x < self->colSize; x++ ) {
vec[x] = self->matrix[i][x];
}
- return (PyObject*)newVectorObject(vec, self->colSize);
+ return ( PyObject * ) newVectorObject( vec, self->colSize );
}
-static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
+static PyObject *Matrix_slice( MatrixObject * self, int begin, int end )
{
PyObject *list;
int count, maxsize, x, y;
-
+
maxsize = self->colSize * self->rowSize;
- if (begin < 0) begin= 0;
- if (end > maxsize) end= maxsize;
- if (begin > end) begin= end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > maxsize )
+ end = maxsize;
+ if( begin > end )
+ begin = end;
- list= PyList_New(end-begin);
+ list = PyList_New( end - begin );
- for (count = begin; count < end; count++){
- x = (int)floor((double)(count / self->colSize));
+ for( count = begin; count < end; count++ ) {
+ x = ( int ) floor( ( double ) ( count / self->colSize ) );
y = count % self->colSize;
- PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->matrix[x][y]));
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( self->matrix[x][y] ) );
}
return list;
}
-static int Matrix_ass_item(MatrixObject *self, int i, PyObject *ob)
+static int Matrix_ass_item( MatrixObject * self, int i, PyObject * ob )
{
int maxsize, x, y;
maxsize = self->colSize * self->rowSize;
- if (i < 0 || i >= maxsize)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range\n");
- if (!PyInt_Check(ob) && !PyFloat_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "matrix member must be a number\n");
-
- x = (int)floor((double)(i / self->colSize));
+ if( i < 0 || i >= maxsize )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range\n" );
+ if( !PyInt_Check( ob ) && !PyFloat_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "matrix member must be a number\n" );
+
+ x = ( int ) floor( ( double ) ( i / self->colSize ) );
y = i % self->colSize;
- self->matrix[x][y] = (float)PyFloat_AsDouble(ob);
+ self->matrix[x][y] = ( float ) PyFloat_AsDouble( ob );
return 0;
}
-static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *seq)
+static int Matrix_ass_slice( MatrixObject * self, int begin, int end,
+ PyObject * seq )
{
int count, maxsize, x, y, z;
-
- maxsize = self->colSize * self->rowSize;
- if (begin < 0) begin= 0;
- if (end > maxsize) end= maxsize;
- if (begin > end) begin= end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation\n");
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment\n");
+ maxsize = self->colSize * self->rowSize;
+ if( begin < 0 )
+ begin = 0;
+ if( end > maxsize )
+ end = maxsize;
+ if( begin > end )
+ begin = end;
+
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation\n" );
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment\n" );
z = 0;
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, z); z++;
- if (!PyInt_Check(ob) && !PyFloat_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "list member must be a number\n");
-
- x = (int)floor((double)(count / self->colSize));
+ for( count = begin; count < end; count++ ) {
+ PyObject *ob = PySequence_GetItem( seq, z );
+ z++;
+ if( !PyInt_Check( ob ) && !PyFloat_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "list member must be a number\n" );
+
+ x = ( int ) floor( ( double ) ( count / self->colSize ) );
y = count % self->colSize;
- if (!PyArg_Parse(ob, "f", &self->matrix[x][y])){
- Py_DECREF(ob);
+ if( !PyArg_Parse( ob, "f", &self->matrix[x][y] ) ) {
+ Py_DECREF( ob );
return -1;
}
}
- return 0;
+ return 0;
}
-static int Matrix_len(MatrixObject *self)
+static int Matrix_len( MatrixObject * self )
{
- return (self->colSize * self->rowSize);
+ return ( self->colSize * self->rowSize );
}
-PyObject * Matrix_add(PyObject *m1, PyObject * m2)
+PyObject *Matrix_add( PyObject * m1, PyObject * m2 )
{
- float * mat;
- int matSize, rowSize, colSize, x,y;
-
- if((!Matrix_CheckPyObject(m1)) || (!Matrix_CheckPyObject(m2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
-
- if(((MatrixObject*)m1)->flag > 0 || ((MatrixObject*)m2)->flag > 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "cannot add scalar to a matrix\n");
-
- if(((MatrixObject*)m1)->rowSize!= ((MatrixObject*)m2)->rowSize ||
- ((MatrixObject*)m1)->colSize != ((MatrixObject*)m2)->colSize)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "matrices must be the same same for this operation\n");
-
- rowSize = (((MatrixObject*)m1)->rowSize);
- colSize = (((MatrixObject*)m1)->colSize);
+ float *mat;
+ int matSize, rowSize, colSize, x, y;
+
+ if( ( !Matrix_CheckPyObject( m1 ) )
+ || ( !Matrix_CheckPyObject( m2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+
+ if( ( ( MatrixObject * ) m1 )->flag > 0
+ || ( ( MatrixObject * ) m2 )->flag > 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "cannot add scalar to a matrix\n" );
+
+ if( ( ( MatrixObject * ) m1 )->rowSize !=
+ ( ( MatrixObject * ) m2 )->rowSize
+ || ( ( MatrixObject * ) m1 )->colSize !=
+ ( ( MatrixObject * ) m2 )->colSize )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "matrices must be the same same for this operation\n" );
+
+ rowSize = ( ( ( MatrixObject * ) m1 )->rowSize );
+ colSize = ( ( ( MatrixObject * ) m1 )->colSize );
matSize = rowSize * colSize;
-
- mat = PyMem_Malloc (matSize * sizeof(float));
-
- for(x = 0; x < rowSize; x++){
- for(y = 0; y < colSize; y++){
- mat[((x * rowSize) + y)] =
- ((MatrixObject*)m1)->matrix[x][y] +
- ((MatrixObject*)m2)->matrix[x][y];
+
+ mat = PyMem_Malloc( matSize * sizeof( float ) );
+
+ for( x = 0; x < rowSize; x++ ) {
+ for( y = 0; y < colSize; y++ ) {
+ mat[( ( x * rowSize ) + y )] =
+ ( ( MatrixObject * ) m1 )->matrix[x][y] +
+ ( ( MatrixObject * ) m2 )->matrix[x][y];
}
}
- return newMatrixObject(mat, rowSize, colSize);
+ return newMatrixObject( mat, rowSize, colSize );
}
-PyObject * Matrix_sub(PyObject *m1, PyObject * m2)
+PyObject *Matrix_sub( PyObject * m1, PyObject * m2 )
{
- float * mat;
- int matSize, rowSize, colSize, x,y;
-
- if((!Matrix_CheckPyObject(m1)) || (!Matrix_CheckPyObject(m2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
-
- if(((MatrixObject*)m1)->flag > 0 || ((MatrixObject*)m2)->flag > 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "cannot subtract a scalar from a matrix\n");
+ float *mat;
+ int matSize, rowSize, colSize, x, y;
+
+ if( ( !Matrix_CheckPyObject( m1 ) )
+ || ( !Matrix_CheckPyObject( m2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+
+ if( ( ( MatrixObject * ) m1 )->flag > 0
+ || ( ( MatrixObject * ) m2 )->flag > 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "cannot subtract a scalar from a matrix\n" );
+
+ if( ( ( MatrixObject * ) m1 )->rowSize !=
+ ( ( MatrixObject * ) m2 )->rowSize
+ || ( ( MatrixObject * ) m1 )->colSize !=
+ ( ( MatrixObject * ) m2 )->colSize )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "matrices must be the same same for this operation\n" );
+
+ rowSize = ( ( ( MatrixObject * ) m1 )->rowSize );
+ colSize = ( ( ( MatrixObject * ) m1 )->colSize );
+ matSize = rowSize * colSize;
- if(((MatrixObject*)m1)->rowSize!= ((MatrixObject*)m2)->rowSize ||
- ((MatrixObject*)m1)->colSize != ((MatrixObject*)m2)->colSize)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "matrices must be the same same for this operation\n");
+ mat = PyMem_Malloc( matSize * sizeof( float ) );
- rowSize = (((MatrixObject*)m1)->rowSize);
- colSize = (((MatrixObject*)m1)->colSize);
- matSize = rowSize * colSize;
-
- mat = PyMem_Malloc (matSize * sizeof(float));
-
- for(x = 0; x < rowSize; x++){
- for(y = 0; y < colSize; y++){
- mat[((x * rowSize) + y)] =
- ((MatrixObject*)m1)->matrix[x][y] -
- ((MatrixObject*)m2)->matrix[x][y];
+ for( x = 0; x < rowSize; x++ ) {
+ for( y = 0; y < colSize; y++ ) {
+ mat[( ( x * rowSize ) + y )] =
+ ( ( MatrixObject * ) m1 )->matrix[x][y] -
+ ( ( MatrixObject * ) m2 )->matrix[x][y];
}
}
- return newMatrixObject(mat, rowSize, colSize);
+ return newMatrixObject( mat, rowSize, colSize );
}
-PyObject * Matrix_mul(PyObject *m1, PyObject * m2)
+PyObject *Matrix_mul( PyObject * m1, PyObject * m2 )
{
- float * mat;
- int matSizeV, rowSizeV, colSizeV, rowSizeW, colSizeW, matSizeW, x, y, z;
+ float *mat;
+ int matSizeV, rowSizeV, colSizeV, rowSizeW, colSizeW, matSizeW, x, y,
+ z;
float dot = 0;
- MatrixObject * matV;
- MatrixObject * matW;
+ MatrixObject *matV;
+ MatrixObject *matW;
- if((!Matrix_CheckPyObject(m1)) || (!Matrix_CheckPyObject(m2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
+ if( ( !Matrix_CheckPyObject( m1 ) )
+ || ( !Matrix_CheckPyObject( m2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
//get some vars
- rowSizeV = (((MatrixObject*)m1)->rowSize);
- colSizeV = (((MatrixObject*)m1)->colSize);
+ rowSizeV = ( ( ( MatrixObject * ) m1 )->rowSize );
+ colSizeV = ( ( ( MatrixObject * ) m1 )->colSize );
matSizeV = rowSizeV * colSizeV;
- rowSizeW = (((MatrixObject*)m2)->rowSize);
- colSizeW = (((MatrixObject*)m2)->colSize);
+ rowSizeW = ( ( ( MatrixObject * ) m2 )->rowSize );
+ colSizeW = ( ( ( MatrixObject * ) m2 )->colSize );
matSizeW = rowSizeW * colSizeW;
- matV = ((MatrixObject*)m1);
- matW = ((MatrixObject*)m2);
+ matV = ( ( MatrixObject * ) m1 );
+ matW = ( ( MatrixObject * ) m2 );
//coerced int or float for scalar multiplication
- if(matW->flag > 1 || matW->flag > 2){
-
- if(rowSizeV != rowSizeW && colSizeV != colSizeW)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Matrix dimension error during scalar multiplication\n");
-
- mat = PyMem_Malloc (matSizeV * sizeof(float));
-
- for(x = 0; x < rowSizeV; x++){
- for(y = 0; y < colSizeV; y++){
- mat[((x * rowSizeV) + y)] =
- matV->matrix[x][y] * matW->matrix[x][y];
+ if( matW->flag > 1 || matW->flag > 2 ) {
+
+ if( rowSizeV != rowSizeW && colSizeV != colSizeW )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Matrix dimension error during scalar multiplication\n" );
+
+ mat = PyMem_Malloc( matSizeV * sizeof( float ) );
+
+ for( x = 0; x < rowSizeV; x++ ) {
+ for( y = 0; y < colSizeV; y++ ) {
+ mat[( ( x * rowSizeV ) + y )] =
+ matV->matrix[x][y] *
+ matW->matrix[x][y];
}
}
- return newMatrixObject(mat, rowSizeV, colSizeV);
- }
- else if (matW->flag == 0 && matV->flag == 0){ //true matrix multiplication
- if(colSizeV != rowSizeW){
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Matrix multiplication undefined...\n");
+ return newMatrixObject( mat, rowSizeV, colSizeV );
+ } else if( matW->flag == 0 && matV->flag == 0 ) { //true matrix multiplication
+ if( colSizeV != rowSizeW ) {
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Matrix multiplication undefined...\n" );
}
- mat = PyMem_Malloc((rowSizeV * colSizeW) * sizeof(float));
+ mat = PyMem_Malloc( ( rowSizeV * colSizeW ) *
+ sizeof( float ) );
- for(x = 0; x < rowSizeV; x++){
- for(y = 0; y < colSizeW; y++){
- for(z = 0; z < colSizeV; z++){
- dot += (matV->matrix[x][z] * matW->matrix[z][y]);
+ for( x = 0; x < rowSizeV; x++ ) {
+ for( y = 0; y < colSizeW; y++ ) {
+ for( z = 0; z < colSizeV; z++ ) {
+ dot += ( matV->matrix[x][z] *
+ matW->matrix[z][y] );
}
- mat[((x * rowSizeV) + y)] = dot;
+ mat[( ( x * rowSizeV ) + y )] = dot;
dot = 0;
}
}
- return newMatrixObject(mat, rowSizeV, colSizeW);
- }
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Error in matrix_mul...\n");
+ return newMatrixObject( mat, rowSizeV, colSizeW );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Error in matrix_mul...\n" );
}
//coercion of unknown types to type MatrixObject for numeric protocols
-int Matrix_coerce(PyObject **m1, PyObject **m2)
-{
+int Matrix_coerce( PyObject ** m1, PyObject ** m2 )
+{
long *tempI;
double *tempF;
float *mat;
int x, matSize;
- matSize = (((MatrixObject*)*m1)->rowSize) * (((MatrixObject*)*m1)->rowSize);
- if (Matrix_CheckPyObject(*m1)) {
- if (Matrix_CheckPyObject(*m2)) { //matrix & matrix
- Py_INCREF(*m1);
- Py_INCREF(*m2);
+ matSize =
+ ( ( ( MatrixObject * ) * m1 )->rowSize ) *
+ ( ( ( MatrixObject * ) * m1 )->rowSize );
+ if( Matrix_CheckPyObject( *m1 ) ) {
+ if( Matrix_CheckPyObject( *m2 ) ) { //matrix & matrix
+ Py_INCREF( *m1 );
+ Py_INCREF( *m2 );
return 0;
- }else{
- if(VectorObject_Check(*m2)){ //matrix & vector?
- printf("use MatMultVec() for column vector multiplication\n");
- Py_INCREF(*m1);
+ } else {
+ if( VectorObject_Check( *m2 ) ) { //matrix & vector?
+ printf( "use MatMultVec() for column vector multiplication\n" );
+ Py_INCREF( *m1 );
return 0;
- }else if(PyNumber_Check(*m2)){ //& scalar?
- if(PyInt_Check(*m2)){ //it's a int
- tempI = PyMem_Malloc(1*sizeof(long));
- *tempI = PyInt_AsLong(*m2);
- mat = PyMem_Malloc (matSize * sizeof (float));
- for(x = 0; x < matSize; x++){
- mat[x] = (float)*tempI;
+ } else if( PyNumber_Check( *m2 ) ) { //& scalar?
+ if( PyInt_Check( *m2 ) ) { //it's a int
+ tempI = PyMem_Malloc( 1 *
+ sizeof( long ) );
+ *tempI = PyInt_AsLong( *m2 );
+ mat = PyMem_Malloc( matSize *
+ sizeof( float ) );
+ for( x = 0; x < matSize; x++ ) {
+ mat[x] = ( float ) *tempI;
}
- PyMem_Free(tempI);
- *m2 = newMatrixObject(mat, (((MatrixObject*)*m1)->rowSize),
- (((MatrixObject*)*m1)->colSize));
- ((MatrixObject*)*m2)->flag = 1; //int coercion
- PyMem_Free(mat);
- Py_INCREF(*m1);
+ PyMem_Free( tempI );
+ *m2 = newMatrixObject( mat,
+ ( ( ( MatrixObject * ) * m1 )->rowSize ), ( ( ( MatrixObject * ) * m1 )->colSize ) );
+ ( ( MatrixObject * ) * m2 )->flag = 1; //int coercion
+ PyMem_Free( mat );
+ Py_INCREF( *m1 );
return 0;
- }else if(PyFloat_Check(*m2)){ //it's a float
- tempF = PyMem_Malloc(1*sizeof(double));
- *tempF = PyFloat_AsDouble(*m2);
- mat = PyMem_Malloc (matSize * sizeof (float));
- for(x = 0; x < matSize; x++){
- mat[x] = (float)*tempF;
+ } else if( PyFloat_Check( *m2 ) ) { //it's a float
+ tempF = PyMem_Malloc( 1 *
+ sizeof
+ ( double ) );
+ *tempF = PyFloat_AsDouble( *m2 );
+ mat = PyMem_Malloc( matSize *
+ sizeof( float ) );
+ for( x = 0; x < matSize; x++ ) {
+ mat[x] = ( float ) *tempF;
}
- PyMem_Free(tempF);
- *m2 = newMatrixObject(mat, (((MatrixObject*)*m1)->rowSize),
- (((MatrixObject*)*m1)->colSize));
- ((MatrixObject*)*m2)->flag = 2; //float coercion
- PyMem_Free(mat);
- Py_INCREF(*m1);
+ PyMem_Free( tempF );
+ *m2 = newMatrixObject( mat,
+ ( ( ( MatrixObject * ) * m1 )->rowSize ), ( ( ( MatrixObject * ) * m1 )->colSize ) );
+ ( ( MatrixObject * ) * m2 )->flag = 2; //float coercion
+ PyMem_Free( mat );
+ Py_INCREF( *m1 );
return 0;
}
}
//unknom2n type or numeric cast failure
- printf("attempting matrix operation m2ith unsupported type...\n");
- Py_INCREF(*m1);
- return 0; //operation m2ill type check
+ printf( "attempting matrix operation m2ith unsupported type...\n" );
+ Py_INCREF( *m1 );
+ return 0; //operation m2ill type check
}
- }else{
+ } else {
//1st not Matrix
- printf("numeric protocol failure...\n");
- return -1; //this should not occur - fail
+ printf( "numeric protocol failure...\n" );
+ return -1; //this should not occur - fail
}
- return -1;
+ return -1;
}
//******************************************************************
-// Matrix definition
+// Matrix definition
//******************************************************************
-static PySequenceMethods Matrix_SeqMethods =
-{
- (inquiry) Matrix_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Matrix_item, /* sq_item */
- (intintargfunc) Matrix_slice, /* sq_slice */
- (intobjargproc) Matrix_ass_item, /* sq_ass_item */
- (intintobjargproc) Matrix_ass_slice, /* sq_ass_slice */
+static PySequenceMethods Matrix_SeqMethods = {
+ ( inquiry ) Matrix_len, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) Matrix_item, /* sq_item */
+ ( intintargfunc ) Matrix_slice, /* sq_slice */
+ ( intobjargproc ) Matrix_ass_item, /* sq_ass_item */
+ ( intintobjargproc ) Matrix_ass_slice, /* sq_ass_slice */
};
-static PyNumberMethods Matrix_NumMethods =
-{
- (binaryfunc) Matrix_add, /* __add__ */
- (binaryfunc) Matrix_sub, /* __sub__ */
- (binaryfunc) Matrix_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Matrix_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
+static PyNumberMethods Matrix_NumMethods = {
+ ( binaryfunc ) Matrix_add, /* __add__ */
+ ( binaryfunc ) Matrix_sub, /* __sub__ */
+ ( binaryfunc ) Matrix_mul, /* __mul__ */
+ ( binaryfunc ) 0, /* __div__ */
+ ( binaryfunc ) 0, /* __mod__ */
+ ( binaryfunc ) 0, /* __divmod__ */
+ ( ternaryfunc ) 0, /* __pow__ */
+ ( unaryfunc ) 0, /* __neg__ */
+ ( unaryfunc ) 0, /* __pos__ */
+ ( unaryfunc ) 0, /* __abs__ */
+ ( inquiry ) 0, /* __nonzero__ */
+ ( unaryfunc ) 0, /* __invert__ */
+ ( binaryfunc ) 0, /* __lshift__ */
+ ( binaryfunc ) 0, /* __rshift__ */
+ ( binaryfunc ) 0, /* __and__ */
+ ( binaryfunc ) 0, /* __xor__ */
+ ( binaryfunc ) 0, /* __or__ */
+ ( coercion ) Matrix_coerce, /* __coerce__ */
+ ( unaryfunc ) 0, /* __int__ */
+ ( unaryfunc ) 0, /* __long__ */
+ ( unaryfunc ) 0, /* __float__ */
+ ( unaryfunc ) 0, /* __oct__ */
+ ( unaryfunc ) 0, /* __hex__ */
};
-PyTypeObject matrix_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Matrix", /*tp_name*/
- sizeof(MatrixObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Matrix_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Matrix_getattr, /*tp_getattr*/
- (setattrfunc) Matrix_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Matrix_repr, /*tp_repr*/
- &Matrix_NumMethods, /*tp_as_number*/
- &Matrix_SeqMethods, /*tp_as_sequence*/
+PyTypeObject matrix_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /*ob_size */
+ "Matrix", /*tp_name */
+ sizeof( MatrixObject ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Matrix_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Matrix_getattr, /*tp_getattr */
+ ( setattrfunc ) Matrix_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) Matrix_repr, /*tp_repr */
+ &Matrix_NumMethods, /*tp_as_number */
+ &Matrix_SeqMethods, /*tp_as_sequence */
};
//******************************************************************
-//Function: newMatrixObject
+//Function: newMatrixObject
//******************************************************************
-PyObject * newMatrixObject (float * mat, int rowSize, int colSize)
+PyObject *newMatrixObject( float *mat, int rowSize, int colSize )
{
- MatrixObject * self;
- float * contigPtr;
+ MatrixObject *self;
+ float *contigPtr;
int row, col, x;
- if (rowSize < 2 || rowSize > 4 || colSize < 2 || colSize > 4)
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "row and column sizes must be between 2 and 4\n"));
+ if( rowSize < 2 || rowSize > 4 || colSize < 2 || colSize > 4 )
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "row and column sizes must be between 2 and 4\n" ) );
- self = PyObject_NEW (MatrixObject, &matrix_Type);
+ self = PyObject_NEW( MatrixObject, &matrix_Type );
//generate contigous memory space
- contigPtr = PyMem_Malloc(rowSize * colSize* sizeof(float));
- if(contigPtr == NULL){
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "problem allocating array space\n\n"));
+ contigPtr = PyMem_Malloc( rowSize * colSize * sizeof( float ) );
+ if( contigPtr == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "problem allocating array space\n\n" ) );
}
-
//create pointer array
- self->matrix = PyMem_Malloc(rowSize * sizeof(float*));
- if(self->matrix == NULL){
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
- "problem allocating pointer space\n\n"));
+ self->matrix = PyMem_Malloc( rowSize * sizeof( float * ) );
+ if( self->matrix == NULL ) {
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "problem allocating pointer space\n\n" ) );
}
-
//pointer array points to contigous memory
- for (x = 0; x < rowSize; x++){
- self->matrix[x] = contigPtr + (x * colSize);
- }
-
- if(mat){ //if a float array passed
- for (row = 0; row < rowSize; row++){
- for(col = 0; col < colSize; col++){
- self->matrix[row][col] = mat[(row * colSize) + col];
+ for( x = 0; x < rowSize; x++ ) {
+ self->matrix[x] = contigPtr + ( x * colSize );
+ }
+
+ if( mat ) { //if a float array passed
+ for( row = 0; row < rowSize; row++ ) {
+ for( col = 0; col < colSize; col++ ) {
+ self->matrix[row][col] =
+ mat[( row * colSize ) + col];
}
}
- }else{ //or if NULL passed
- for (row = 0; row < rowSize; row++){
- for (col = 0; col < colSize; col++){
+ } else { //or if NULL passed
+ for( row = 0; row < rowSize; row++ ) {
+ for( col = 0; col < colSize; col++ ) {
self->matrix[row][col] = 0.0f;
}
}
@@ -886,7 +927,5 @@ PyObject * newMatrixObject (float * mat, int rowSize, int colSize)
//set coercion flag
self->flag = 0;
- return ((PyObject *)self);
+ return ( ( PyObject * ) self );
}
-
-
diff --git a/source/blender/python/api2_2x/matrix.h b/source/blender/python/api2_2x/matrix.h
index b7370179a74..fdd31af5b2a 100644
--- a/source/blender/python/api2_2x/matrix.h
+++ b/source/blender/python/api2_2x/matrix.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -48,30 +49,28 @@
typedef float **ptRow;
typedef struct _Matrix {
- PyObject_VAR_HEAD
-
- ptRow matrix;
+ PyObject_VAR_HEAD ptRow matrix;
int rowSize;
int colSize;
int flag;
- //0 - no coercion
- //1 - coerced from int
- //2 - coerced from float
+ //0 - no coercion
+ //1 - coerced from int
+ //2 - coerced from float
} MatrixObject;
/*****************************************************************************/
-/* Python API function prototypes. */
+/* Python API function prototypes. */
/*****************************************************************************/
-PyObject *newMatrixObject(float * mat, int rowSize, int colSize);
-PyObject *Matrix_Zero(MatrixObject *self);
-PyObject *Matrix_Identity(MatrixObject *self);
-PyObject *Matrix_Transpose(MatrixObject *self);
-PyObject *Matrix_Determinant(MatrixObject *self);
-PyObject *Matrix_Invert(MatrixObject *self);
-PyObject *Matrix_TranslationPart(MatrixObject *self);
-PyObject *Matrix_RotationPart(MatrixObject *self);
-PyObject *Matrix_Resize4x4(MatrixObject *self);
-PyObject *Matrix_toEuler(MatrixObject *self);
-PyObject *Matrix_toQuat(MatrixObject *self);
+PyObject *newMatrixObject( float *mat, int rowSize, int colSize );
+PyObject *Matrix_Zero( MatrixObject * self );
+PyObject *Matrix_Identity( MatrixObject * self );
+PyObject *Matrix_Transpose( MatrixObject * self );
+PyObject *Matrix_Determinant( MatrixObject * self );
+PyObject *Matrix_Invert( MatrixObject * self );
+PyObject *Matrix_TranslationPart( MatrixObject * self );
+PyObject *Matrix_RotationPart( MatrixObject * self );
+PyObject *Matrix_Resize4x4( MatrixObject * self );
+PyObject *Matrix_toEuler( MatrixObject * self );
+PyObject *Matrix_toQuat( MatrixObject * self );
-#endif /* EXPP_matrix_H */
+#endif /* EXPP_matrix_H */
diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h
index 08abd05d8e0..6d021ebb0b3 100644
--- a/source/blender/python/api2_2x/modules.h
+++ b/source/blender/python/api2_2x/modules.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -64,146 +65,147 @@ extern PyObject *g_blenderdict;
/* Module Init functions and Data Object helper functions (used by the */
/* Object module to work with its .data field for the various Data objs */
/*****************************************************************************/
-void M_Blender_Init (void);
+void M_Blender_Init( void );
-void types_InitAll(void); /* in Types.c */
+void types_InitAll( void ); /* in Types.c */
/* sys */
-PyObject * sys_Init (void);
+PyObject *sys_Init( void );
/* Registry */
-PyObject * Registry_Init (void);
+PyObject *Registry_Init( void );
/* Object itself */
-PyObject * Object_Init (void);
-PyObject * Object_CreatePyObject (struct Object *obj);
-Object * Object_FromPyObject (PyObject *py_obj);
-int Object_CheckPyObject (PyObject *py_obj);
-Object * GetObjectByName (char * name);
+PyObject *Object_Init( void );
+PyObject *Object_CreatePyObject( struct Object *obj );
+Object *Object_FromPyObject( PyObject * py_obj );
+int Object_CheckPyObject( PyObject * py_obj );
+Object *GetObjectByName( char *name );
/* Scene */
-PyObject * Scene_Init (void);
-PyObject * Scene_CreatePyObject (struct Scene *sce);
-Scene * Scene_FromPyObject (PyObject *pyobj);
-int Scene_CheckPyObject (PyObject *pyobj);
-Scene * GetSceneByName (char * name);
+PyObject *Scene_Init( void );
+PyObject *Scene_CreatePyObject( struct Scene *sce );
+Scene *Scene_FromPyObject( PyObject * pyobj );
+int Scene_CheckPyObject( PyObject * pyobj );
+Scene *GetSceneByName( char *name );
/* Types */
-PyObject * Types_Init (void);
+PyObject *Types_Init( void );
/* NMesh Data */
-PyObject * NMesh_Init (void);
-PyObject * NMesh_CreatePyObject (Mesh *me, Object *ob);
-Mesh * Mesh_FromPyObject (PyObject *pyobj, Object *ob);
-int NMesh_CheckPyObject (PyObject *pyobj);
+PyObject *NMesh_Init( void );
+PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob );
+Mesh *Mesh_FromPyObject( PyObject * pyobj, Object * ob );
+int NMesh_CheckPyObject( PyObject * pyobj );
/* Material */
-PyObject * Material_Init (void);
-PyObject * Material_CreatePyObject (struct Material *mat);
-int Material_CheckPyObject (PyObject *pyobj);
-Material **EXPP_newMaterialList_fromPyList (PyObject *list);
-Material **EXPP_newMaterialList(int len);
-int EXPP_releaseMaterialList (Material **matlist, int len);
-int EXPP_synchronizeMaterialLists (Object *object);
-void EXPP_incr_mats_us (Material **matlist, int len);
-PyObject * EXPP_PyList_fromMaterialList(Material **matlist, int len, int all);
-Material * GetMaterialByName (char * name);
+PyObject *Material_Init( void );
+PyObject *Material_CreatePyObject( struct Material *mat );
+int Material_CheckPyObject( PyObject * pyobj );
+Material **EXPP_newMaterialList_fromPyList( PyObject * list );
+Material **EXPP_newMaterialList( int len );
+int EXPP_releaseMaterialList( Material ** matlist, int len );
+int EXPP_synchronizeMaterialLists( Object * object );
+void EXPP_incr_mats_us( Material ** matlist, int len );
+PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
+ int all );
+Material *GetMaterialByName( char *name );
/* Texture */
-PyObject * Texture_Init (void);
+PyObject *Texture_Init( void );
/* Camera Data */
-PyObject * Camera_Init (void);
-PyObject * Camera_CreatePyObject (struct Camera *cam);
-Camera * Camera_FromPyObject (PyObject *pyobj);
-int Camera_CheckPyObject (PyObject *pyobj);
-Camera * GetCameraByName (char * name);
+PyObject *Camera_Init( void );
+PyObject *Camera_CreatePyObject( struct Camera *cam );
+Camera *Camera_FromPyObject( PyObject * pyobj );
+int Camera_CheckPyObject( PyObject * pyobj );
+Camera *GetCameraByName( char *name );
/* Lamp Data */
-PyObject * Lamp_Init (void);
-PyObject * Lamp_CreatePyObject (struct Lamp *lamp);
-Lamp * Lamp_FromPyObject (PyObject *pyobj);
-int Lamp_CheckPyObject (PyObject *pyobj);
-Lamp * GetLampByName (char * name);
+PyObject *Lamp_Init( void );
+PyObject *Lamp_CreatePyObject( struct Lamp *lamp );
+Lamp *Lamp_FromPyObject( PyObject * pyobj );
+int Lamp_CheckPyObject( PyObject * pyobj );
+Lamp *GetLampByName( char *name );
/* Curve Data */
-PyObject * Curve_Init (void);
-PyObject * Curve_CreatePyObject (struct Curve *curve);
-Curve * Curve_FromPyObject (PyObject *py_obj);
-int Curve_CheckPyObject (PyObject *py_obj);
+PyObject *Curve_Init( void );
+PyObject *Curve_CreatePyObject( struct Curve *curve );
+Curve *Curve_FromPyObject( PyObject * py_obj );
+int Curve_CheckPyObject( PyObject * py_obj );
/* Armature Data */
-PyObject * Armature_Init (void);
-PyObject * Armature_CreatePyObject (bArmature *armature);
-bArmature * Armature_FromPyObject (PyObject *py_obj);
-int Armature_CheckPyObject (PyObject *py_obj);
+PyObject *Armature_Init( void );
+PyObject *Armature_CreatePyObject( bArmature * armature );
+bArmature *Armature_FromPyObject( PyObject * py_obj );
+int Armature_CheckPyObject( PyObject * py_obj );
/* Ipo Data */
-PyObject * BezTriple_CreatePyObject (BezTriple *bzt);
-int BezTriple_CheckPyObject (PyObject *pyobj);
-BezTriple* BezTriple_FromPyObject (PyObject *pyobj);
+PyObject *BezTriple_CreatePyObject( BezTriple * bzt );
+int BezTriple_CheckPyObject( PyObject * pyobj );
+BezTriple *BezTriple_FromPyObject( PyObject * pyobj );
-PyObject * IpoCurve_Init(void);
-PyObject * IpoCurve_CreatePyObject (IpoCurve *ipo);
-int IpoCurve_CheckPyObject (PyObject *pyobj);
-IpoCurve * IpoCurve_FromPyObject (PyObject *pyobj);
+PyObject *IpoCurve_Init( void );
+PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo );
+int IpoCurve_CheckPyObject( PyObject * pyobj );
+IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj );
-PyObject * Ipo_Init (void);
-PyObject * Ipo_CreatePyObject (struct Ipo *ipo);
-Ipo * Ipo_FromPyObject (PyObject *py_obj);
-int Ipo_CheckPyObject (PyObject *py_obj);
+PyObject *Ipo_Init( void );
+PyObject *Ipo_CreatePyObject( struct Ipo *ipo );
+Ipo *Ipo_FromPyObject( PyObject * py_obj );
+int Ipo_CheckPyObject( PyObject * py_obj );
/* Metaball Data */
-PyObject * Metaball_Init (void);
-PyObject * Metaball_CreatePyObject (MetaBall *metaball);
-MetaBall * Metaball_FromPyObject (PyObject *py_obj);
-int Metaball_CheckPyObject (PyObject *py_obj);
+PyObject *Metaball_Init( void );
+PyObject *Metaball_CreatePyObject( MetaBall * metaball );
+MetaBall *Metaball_FromPyObject( PyObject * py_obj );
+int Metaball_CheckPyObject( PyObject * py_obj );
/* Particle Effects Data */
-PyObject * Effect_Init (void);
-PyObject * Effect_CreatePyObject (struct Effect *effect);
-Effect * Effect_FromPyObject (PyObject *py_obj);
-int Effect_CheckPyObject (PyObject *py_obj);
+PyObject *Effect_Init( void );
+PyObject *Effect_CreatePyObject( struct Effect *effect );
+Effect *Effect_FromPyObject( PyObject * py_obj );
+int Effect_CheckPyObject( PyObject * py_obj );
/* Image */
-PyObject * Image_Init (void);
-PyObject * Image_CreatePyObject (Image *image);
-int Image_CheckPyObject (PyObject *pyobj);
+PyObject *Image_Init( void );
+PyObject *Image_CreatePyObject( Image * image );
+int Image_CheckPyObject( PyObject * pyobj );
/* Text */
-PyObject * Text_Init (void);
-PyObject * Text_CreatePyObject (Text *txt);
+PyObject *Text_Init( void );
+PyObject *Text_CreatePyObject( Text * txt );
/* World */
-PyObject * World_Init (void);
-PyObject * World_CreatePyObject (struct World *world);
-int World_CheckPyObject (PyObject *py_obj);
-World * World_FromPyObject (PyObject *py_obj);
-World * GetWorldByName (char * name);
+PyObject *World_Init( void );
+PyObject *World_CreatePyObject( struct World *world );
+int World_CheckPyObject( PyObject * py_obj );
+World *World_FromPyObject( PyObject * py_obj );
+World *GetWorldByName( char *name );
/* Lattice */
-PyObject * Lattice_Init (void);
-PyObject * Lattice_CreatePyObject (Lattice *lt);
-Lattice * Lattice_FromPyObject (PyObject *pyobj);
-int Lattice_CheckPyObject (PyObject *pyobj);
+PyObject *Lattice_Init( void );
+PyObject *Lattice_CreatePyObject( Lattice * lt );
+Lattice *Lattice_FromPyObject( PyObject * pyobj );
+int Lattice_CheckPyObject( PyObject * pyobj );
/* Noise */
-PyObject * Noise_Init (void);
+PyObject *Noise_Init( void );
/* CurNurb */
-PyObject * CurNurb_Init (void);
-PyObject * CurNurb_CreatePyObject (Nurb *bzt);
-int CurNurb_CheckPyObject (PyObject *pyobj);
-Nurb * CurNurb_FromPyObject (PyObject *pyobj);
+PyObject *CurNurb_Init( void );
+PyObject *CurNurb_CreatePyObject( Nurb * bzt );
+int CurNurb_CheckPyObject( PyObject * pyobj );
+Nurb *CurNurb_FromPyObject( PyObject * pyobj );
/* Init functions for other modules */
-PyObject * Window_Init (void);
-PyObject * Draw_Init (void);
-PyObject * BGL_Init (void);
-PyObject * Mathutils_Init (void);
-PyObject * NLA_Init (void);
-PyObject * Library_Init (void);
-PyObject * Sound_Init (void);
-PyObject * Theme_Init (void); /* Window.Theme */
-
-#endif /* EXPP_modules_h */
+PyObject *Window_Init( void );
+PyObject *Draw_Init( void );
+PyObject *BGL_Init( void );
+PyObject *Mathutils_Init( void );
+PyObject *NLA_Init( void );
+PyObject *Library_Init( void );
+PyObject *Sound_Init( void );
+PyObject *Theme_Init( void ); /* Window.Theme */
+
+#endif /* EXPP_modules_h */
diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c
index 44324191535..2432a3c1f5e 100644
--- a/source/blender/python/api2_2x/quat.c
+++ b/source/blender/python/api2_2x/quat.c
@@ -33,36 +33,34 @@
//doc strings
char Quaternion_Identity_doc[] =
-"() - set the quaternion to it's identity (1, vector)";
+ "() - set the quaternion to it's identity (1, vector)";
char Quaternion_Negate_doc[] =
-"() - set all values in the quaternion to their negative";
-char Quaternion_Conjugate_doc[] =
-"() - set the quaternion to it's conjugate";
-char Quaternion_Inverse_doc[] =
-"() - set the quaternion to it's inverse";
+ "() - set all values in the quaternion to their negative";
+char Quaternion_Conjugate_doc[] = "() - set the quaternion to it's conjugate";
+char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse";
char Quaternion_Normalize_doc[] =
-"() - normalize the vector portion of the quaternion";
+ "() - normalize the vector portion of the quaternion";
char Quaternion_ToEuler_doc[] =
-"() - return a euler rotation representing the quaternion";
+ "() - return a euler rotation representing the quaternion";
char Quaternion_ToMatrix_doc[] =
-"() - return a rotation matrix representing the quaternion";
+ "() - return a rotation matrix representing the quaternion";
//methods table
struct PyMethodDef Quaternion_methods[] = {
- {"identity",(PyCFunction)Quaternion_Identity, METH_NOARGS,
- Quaternion_Identity_doc},
- {"negate",(PyCFunction)Quaternion_Negate, METH_NOARGS,
- Quaternion_Negate_doc},
- {"conjugate",(PyCFunction)Quaternion_Conjugate, METH_NOARGS,
- Quaternion_Conjugate_doc},
- {"inverse",(PyCFunction)Quaternion_Inverse, METH_NOARGS,
- Quaternion_Inverse_doc},
- {"normalize",(PyCFunction)Quaternion_Normalize, METH_NOARGS,
- Quaternion_Normalize_doc},
- {"toEuler",(PyCFunction)Quaternion_ToEuler, METH_NOARGS,
- Quaternion_ToEuler_doc},
- {"toMatrix",(PyCFunction)Quaternion_ToMatrix, METH_NOARGS,
- Quaternion_ToMatrix_doc},
+ {"identity", ( PyCFunction ) Quaternion_Identity, METH_NOARGS,
+ Quaternion_Identity_doc},
+ {"negate", ( PyCFunction ) Quaternion_Negate, METH_NOARGS,
+ Quaternion_Negate_doc},
+ {"conjugate", ( PyCFunction ) Quaternion_Conjugate, METH_NOARGS,
+ Quaternion_Conjugate_doc},
+ {"inverse", ( PyCFunction ) Quaternion_Inverse, METH_NOARGS,
+ Quaternion_Inverse_doc},
+ {"normalize", ( PyCFunction ) Quaternion_Normalize, METH_NOARGS,
+ Quaternion_Normalize_doc},
+ {"toEuler", ( PyCFunction ) Quaternion_ToEuler, METH_NOARGS,
+ Quaternion_ToEuler_doc},
+ {"toMatrix", ( PyCFunction ) Quaternion_ToMatrix, METH_NOARGS,
+ Quaternion_ToMatrix_doc},
{NULL, NULL, 0, NULL}
};
@@ -70,212 +68,230 @@ struct PyMethodDef Quaternion_methods[] = {
// Quaternion Python Object
/*****************************/
-PyObject *Quaternion_ToEuler(QuaternionObject *self)
+PyObject *Quaternion_ToEuler( QuaternionObject * self )
{
float *eul;
int x;
- eul = PyMem_Malloc(3*sizeof(float));
- QuatToEul(self->quat, eul);
+ eul = PyMem_Malloc( 3 * sizeof( float ) );
+ QuatToEul( self->quat, eul );
- for(x = 0; x < 3; x++){
- eul[x] *= (float)(180/Py_PI);
+ for( x = 0; x < 3; x++ ) {
+ eul[x] *= ( float ) ( 180 / Py_PI );
}
- return (PyObject*)newEulerObject(eul);
+ return ( PyObject * ) newEulerObject( eul );
}
-PyObject *Quaternion_ToMatrix(QuaternionObject *self)
+PyObject *Quaternion_ToMatrix( QuaternionObject * self )
{
float *mat;
- mat = PyMem_Malloc(3*3*sizeof(float));
- QuatToMat3(self->quat, (float(*)[3])mat);
+ mat = PyMem_Malloc( 3 * 3 * sizeof( float ) );
+ QuatToMat3( self->quat, ( float ( * )[3] ) mat );
- return (PyObject*)newMatrixObject(mat, 3,3);
+ return ( PyObject * ) newMatrixObject( mat, 3, 3 );
}
//normalize the axis of rotation of [theta,vector]
-PyObject *Quaternion_Normalize(QuaternionObject *self)
+PyObject *Quaternion_Normalize( QuaternionObject * self )
{
- NormalQuat(self->quat);
- return EXPP_incr_ret(Py_None);
+ NormalQuat( self->quat );
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Quaternion_Inverse(QuaternionObject *self)
+PyObject *Quaternion_Inverse( QuaternionObject * self )
{
float mag = 0.0f;
int x;
- for(x = 1; x < 4; x++){
+ for( x = 1; x < 4; x++ ) {
self->quat[x] = -self->quat[x];
}
- for(x = 0; x < 4; x++){
- mag += (self->quat[x] * self->quat[x]);
+ for( x = 0; x < 4; x++ ) {
+ mag += ( self->quat[x] * self->quat[x] );
}
- mag = (float)sqrt(mag);
- for(x = 0; x < 4; x++){
- self->quat[x] /= (mag * mag);
+ mag = ( float ) sqrt( mag );
+ for( x = 0; x < 4; x++ ) {
+ self->quat[x] /= ( mag * mag );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Quaternion_Identity(QuaternionObject *self)
+PyObject *Quaternion_Identity( QuaternionObject * self )
{
self->quat[0] = 1.0;
- self->quat[1] = 0.0; self->quat[2] = 0.0; self->quat[3] = 0.0;
+ self->quat[1] = 0.0;
+ self->quat[2] = 0.0;
+ self->quat[3] = 0.0;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Quaternion_Negate(QuaternionObject *self)
+PyObject *Quaternion_Negate( QuaternionObject * self )
{
int x;
- for(x = 0; x < 4; x++){
+ for( x = 0; x < 4; x++ ) {
self->quat[x] = -self->quat[x];
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Quaternion_Conjugate(QuaternionObject *self)
+PyObject *Quaternion_Conjugate( QuaternionObject * self )
{
int x;
- for(x = 1; x < 4; x++){
+ for( x = 1; x < 4; x++ ) {
self->quat[x] = -self->quat[x];
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static void Quaternion_dealloc(QuaternionObject *self)
+static void Quaternion_dealloc( QuaternionObject * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Quaternion_getattr(QuaternionObject *self, char *name)
+static PyObject *Quaternion_getattr( QuaternionObject * self, char *name )
{
double mag = 0.0f;
float *vec;
int x;
- if (ELEM4(name[0], 'w', 'x', 'y', 'z') && name[1]==0){
- return PyFloat_FromDouble(self->quat[name[0]-'w']);
+ if( ELEM4( name[0], 'w', 'x', 'y', 'z' ) && name[1] == 0 ) {
+ return PyFloat_FromDouble( self->quat[name[0] - 'w'] );
}
- if(strcmp(name,"magnitude") == 0){
- for(x = 0; x < 4; x++){
+ if( strcmp( name, "magnitude" ) == 0 ) {
+ for( x = 0; x < 4; x++ ) {
mag += self->quat[x] * self->quat[x];
}
- mag = (float)sqrt(mag);
- return PyFloat_FromDouble(mag);
+ mag = ( float ) sqrt( mag );
+ return PyFloat_FromDouble( mag );
}
- if(strcmp(name,"angle") == 0){
+ if( strcmp( name, "angle" ) == 0 ) {
mag = self->quat[0];
- mag = 2 * (acos(mag));
- mag *= (180/Py_PI);
- return PyFloat_FromDouble(mag);
+ mag = 2 * ( acos( mag ) );
+ mag *= ( 180 / Py_PI );
+ return PyFloat_FromDouble( mag );
}
- if(strcmp(name,"axis") == 0){
-
- mag = (double)(self->quat[0] * (Py_PI/180));
- mag = 2 * (acos(mag));
- mag = sin(mag/2);
- vec = PyMem_Malloc(3*sizeof(float));
- for(x = 0; x < 3; x++){
- vec[x] = (self->quat[x + 1]/((float)(mag)));
+ if( strcmp( name, "axis" ) == 0 ) {
+
+ mag = ( double ) ( self->quat[0] * ( Py_PI / 180 ) );
+ mag = 2 * ( acos( mag ) );
+ mag = sin( mag / 2 );
+ vec = PyMem_Malloc( 3 * sizeof( float ) );
+ for( x = 0; x < 3; x++ ) {
+ vec[x] = ( self->quat[x + 1] / ( ( float ) ( mag ) ) );
}
- Normalise(vec);
- return (PyObject*)newVectorObject(vec,3);
+ Normalise( vec );
+ return ( PyObject * ) newVectorObject( vec, 3 );
}
- return Py_FindMethod(Quaternion_methods, (PyObject*)self, name);
+ return Py_FindMethod( Quaternion_methods, ( PyObject * ) self, name );
}
-static int Quaternion_setattr(QuaternionObject *self, char *name, PyObject *v)
+static int Quaternion_setattr( QuaternionObject * self, char *name,
+ PyObject * v )
{
float val;
- if(!PyFloat_Check(v) && !PyInt_Check(v)){
- return EXPP_ReturnIntError(PyExc_TypeError,"int or float expected\n");
- }else{
- if (!PyArg_Parse(v, "f", &val))
- return EXPP_ReturnIntError(PyExc_TypeError, "unable to parse float argument\n");
+ if( !PyFloat_Check( v ) && !PyInt_Check( v ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "int or float expected\n" );
+ } else {
+ if( !PyArg_Parse( v, "f", &val ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "unable to parse float argument\n" );
}
- if (ELEM4(name[0], 'w', 'x', 'y', 'z') && name[1]==0){
- self->quat[name[0]-'w']= val;
- }else return -1;
+ if( ELEM4( name[0], 'w', 'x', 'y', 'z' ) && name[1] == 0 ) {
+ self->quat[name[0] - 'w'] = val;
+ } else
+ return -1;
return 0;
}
/* Quaternions Sequence methods */
-static PyObject *Quaternion_item(QuaternionObject *self, int i)
+static PyObject *Quaternion_item( QuaternionObject * self, int i )
{
- if (i < 0 || i >= 4)
- return EXPP_ReturnPyObjError (PyExc_IndexError, "array index out of range\n");
+ if( i < 0 || i >= 4 )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range\n" );
- return Py_BuildValue("f", self->quat[i]);
+ return Py_BuildValue( "f", self->quat[i] );
}
-static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
+static PyObject *Quaternion_slice( QuaternionObject * self, int begin,
+ int end )
{
PyObject *list;
int count;
-
- if (begin < 0) begin= 0;
- if (end > 4) end= 4;
- if (begin > end) begin= end;
- list= PyList_New(end-begin);
+ if( begin < 0 )
+ begin = 0;
+ if( end > 4 )
+ end = 4;
+ if( begin > end )
+ begin = end;
- for (count = begin; count < end; count++){
- PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->quat[count]));
+ list = PyList_New( end - begin );
+
+ for( count = begin; count < end; count++ ) {
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( self->quat[count] ) );
}
return list;
}
-static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
+static int Quaternion_ass_item( QuaternionObject * self, int i, PyObject * ob )
{
- if (i < 0 || i >= 4)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range\n");
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "Quaternion member must be a number\n");
-
- if(!PyFloat_Check(ob) && !PyInt_Check(ob)){
- return EXPP_ReturnIntError(PyExc_TypeError,"int or float expected\n");
- }else{
- self->quat[i]= (float)PyFloat_AsDouble(ob);
+ if( i < 0 || i >= 4 )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range\n" );
+ if( !PyNumber_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "Quaternion member must be a number\n" );
+
+ if( !PyFloat_Check( ob ) && !PyInt_Check( ob ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "int or float expected\n" );
+ } else {
+ self->quat[i] = ( float ) PyFloat_AsDouble( ob );
}
return 0;
}
-static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyObject *seq)
+static int Quaternion_ass_slice( QuaternionObject * self, int begin, int end,
+ PyObject * seq )
{
int count, z;
- if (begin < 0) begin= 0;
- if (end > 4) end= 4;
- if (begin > end) begin= end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > 4 )
+ end = 4;
+ if( begin > end )
+ begin = end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation\n");
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment\n");
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation\n" );
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment\n" );
z = 0;
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, z); z++;
+ for( count = begin; count < end; count++ ) {
+ PyObject *ob = PySequence_GetItem( seq, z );
+ z++;
- if(!PyFloat_Check(ob) && !PyInt_Check(ob)){
- Py_DECREF(ob);
+ if( !PyFloat_Check( ob ) && !PyInt_Check( ob ) ) {
+ Py_DECREF( ob );
return -1;
- }else{
- if (!PyArg_Parse(ob, "f", &self->quat[count])) {
- Py_DECREF(ob);
+ } else {
+ if( !PyArg_Parse( ob, "f", &self->quat[count] ) ) {
+ Py_DECREF( ob );
return -1;
}
}
@@ -283,224 +299,240 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
return 0;
}
-static PyObject *Quaternion_repr (QuaternionObject *self)
+static PyObject *Quaternion_repr( QuaternionObject * self )
{
int i, maxindex = 4 - 1;
char ftoa[24];
PyObject *str1, *str2;
- str1 = PyString_FromString ("[");
+ str1 = PyString_FromString( "[" );
- for (i = 0; i < maxindex; i++) {
- sprintf(ftoa, "%.4f, ", self->quat[i]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ for( i = 0; i < maxindex; i++ ) {
+ sprintf( ftoa, "%.4f, ", self->quat[i] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
}
- sprintf(ftoa, "%.4f]", self->quat[maxindex]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ sprintf( ftoa, "%.4f]", self->quat[maxindex] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
- if (str1) return str1;
+ if( str1 )
+ return str1;
-error:
- Py_XDECREF (str1);
- Py_XDECREF (str2);
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString!\n");
+ error:
+ Py_XDECREF( str1 );
+ Py_XDECREF( str2 );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyString!\n" );
}
-PyObject * Quaternion_add(PyObject *q1, PyObject *q2)
+PyObject *Quaternion_add( PyObject * q1, PyObject * q2 )
{
- float * quat;
+ float *quat;
int x;
- if((!QuaternionObject_Check(q1)) || (!QuaternionObject_Check(q2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((QuaternionObject*)q1)->flag > 0 || ((QuaternionObject*)q2)->flag > 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "cannot add a scalar and a quat\n");
-
- quat = PyMem_Malloc (4*sizeof(float));
- for(x = 0; x < 4; x++){
- quat[x] = (((QuaternionObject*)q1)->quat[x]) + (((QuaternionObject*)q2)->quat[x]);
+ if( ( !QuaternionObject_Check( q1 ) )
+ || ( !QuaternionObject_Check( q2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( QuaternionObject * ) q1 )->flag > 0
+ || ( ( QuaternionObject * ) q2 )->flag > 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "cannot add a scalar and a quat\n" );
+
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
+ quat[x] =
+ ( ( ( QuaternionObject * ) q1 )->quat[x] ) +
+ ( ( ( QuaternionObject * ) q2 )->quat[x] );
}
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-PyObject * Quaternion_sub(PyObject *q1, PyObject *q2)
+PyObject *Quaternion_sub( PyObject * q1, PyObject * q2 )
{
- float * quat;
+ float *quat;
int x;
- if((!QuaternionObject_Check(q1)) || (!QuaternionObject_Check(q2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((QuaternionObject*)q1)->flag > 0 || ((QuaternionObject*)q2)->flag > 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "cannot subtract a scalar and a quat\n");
-
- quat = PyMem_Malloc (4*sizeof(float));
- for(x = 0; x < 4; x++){
- quat[x] = (((QuaternionObject*)q1)->quat[x]) - (((QuaternionObject*)q2)->quat[x]);
+ if( ( !QuaternionObject_Check( q1 ) )
+ || ( !QuaternionObject_Check( q2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( QuaternionObject * ) q1 )->flag > 0
+ || ( ( QuaternionObject * ) q2 )->flag > 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "cannot subtract a scalar and a quat\n" );
+
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
+ quat[x] =
+ ( ( ( QuaternionObject * ) q1 )->quat[x] ) -
+ ( ( ( QuaternionObject * ) q2 )->quat[x] );
}
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
-PyObject * Quaternion_mul(PyObject *q1, PyObject * q2)
+PyObject *Quaternion_mul( PyObject * q1, PyObject * q2 )
{
- float * quat;
+ float *quat;
int x;
- if((!QuaternionObject_Check(q1)) || (!QuaternionObject_Check(q2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((QuaternionObject*)q1)->flag == 0 && ((QuaternionObject*)q2)->flag == 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "please use the dot or cross product to multiply quaternions\n");
+ if( ( !QuaternionObject_Check( q1 ) )
+ || ( !QuaternionObject_Check( q2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( QuaternionObject * ) q1 )->flag == 0
+ && ( ( QuaternionObject * ) q2 )->flag == 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "please use the dot or cross product to multiply quaternions\n" );
- quat = PyMem_Malloc (4*sizeof(float));
+ quat = PyMem_Malloc( 4 * sizeof( float ) );
//scalar mult by quat
- for(x = 0; x < 4; x++){
- quat[x] = ((QuaternionObject*)q1)->quat[x] * ((QuaternionObject*)q2)->quat[x];
+ for( x = 0; x < 4; x++ ) {
+ quat[x] =
+ ( ( QuaternionObject * ) q1 )->quat[x] *
+ ( ( QuaternionObject * ) q2 )->quat[x];
}
- return (PyObject*)newQuaternionObject(quat);
+ return ( PyObject * ) newQuaternionObject( quat );
}
//coercion of unknown types to type QuaternionObject for numeric protocols
-int Quaternion_coerce(PyObject **q1, PyObject **q2)
-{
+int Quaternion_coerce( PyObject ** q1, PyObject ** q2 )
+{
long *tempI;
double *tempF;
float *quat;
int x;
- if (QuaternionObject_Check(*q1)) {
- if (QuaternionObject_Check(*q2)) { //two Quaternions
- Py_INCREF(*q1);
- Py_INCREF(*q2);
+ if( QuaternionObject_Check( *q1 ) ) {
+ if( QuaternionObject_Check( *q2 ) ) { //two Quaternions
+ Py_INCREF( *q1 );
+ Py_INCREF( *q2 );
return 0;
- }else{
- if(PyNumber_Check(*q2)){
- if(PyInt_Check(*q2)){ //cast scalar to Quaternion
- tempI = PyMem_Malloc(1*sizeof(long));
- *tempI = PyInt_AsLong(*q2);
- quat = PyMem_Malloc (4*sizeof (float));
- for(x = 0; x < 4; x++){
- quat[x] = (float)*tempI;
+ } else {
+ if( PyNumber_Check( *q2 ) ) {
+ if( PyInt_Check( *q2 ) ) { //cast scalar to Quaternion
+ tempI = PyMem_Malloc( 1 *
+ sizeof( long ) );
+ *tempI = PyInt_AsLong( *q2 );
+ quat = PyMem_Malloc( 4 *
+ sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
+ quat[x] = ( float ) *tempI;
}
- PyMem_Free(tempI);
- *q2 = newQuaternionObject(quat);
- ((QuaternionObject*)*q2)->flag = 1; //int coercion
- Py_INCREF(*q1);
+ PyMem_Free( tempI );
+ *q2 = newQuaternionObject( quat );
+ ( ( QuaternionObject * ) * q2 )->flag = 1; //int coercion
+ Py_INCREF( *q1 );
return 0;
- }else if(PyFloat_Check(*q2)){ //cast scalar to Quaternion
- tempF = PyMem_Malloc(1*sizeof(double));
- *tempF = PyFloat_AsDouble(*q2);
- quat = PyMem_Malloc (4*sizeof (float));
- for(x = 0; x < 4; x++){
- quat[x] = (float)*tempF;
+ } else if( PyFloat_Check( *q2 ) ) { //cast scalar to Quaternion
+ tempF = PyMem_Malloc( 1 *
+ sizeof
+ ( double ) );
+ *tempF = PyFloat_AsDouble( *q2 );
+ quat = PyMem_Malloc( 4 *
+ sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
+ quat[x] = ( float ) *tempF;
}
- PyMem_Free(tempF);
- *q2 = newQuaternionObject(quat);
- ((QuaternionObject*)*q2)->flag = 2; //float coercion
- Py_INCREF(*q1);
+ PyMem_Free( tempF );
+ *q2 = newQuaternionObject( quat );
+ ( ( QuaternionObject * ) * q2 )->flag = 2; //float coercion
+ Py_INCREF( *q1 );
return 0;
}
}
//unknown type or numeric cast failure
- printf("attempting quaternion operation with unsupported type...\n");
- Py_INCREF(*q1);
- return 0; //operation will type check
+ printf( "attempting quaternion operation with unsupported type...\n" );
+ Py_INCREF( *q1 );
+ return 0; //operation will type check
}
- }else{
- printf("numeric protocol failure...\n");
- return -1; //this should not occur - fail
+ } else {
+ printf( "numeric protocol failure...\n" );
+ return -1; //this should not occur - fail
}
return -1;
}
-static PySequenceMethods Quaternion_SeqMethods =
-{
- (inquiry) 0, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Quaternion_item, /* sq_item */
- (intintargfunc) Quaternion_slice, /* sq_slice */
- (intobjargproc) Quaternion_ass_item, /* sq_ass_item */
- (intintobjargproc) Quaternion_ass_slice, /* sq_ass_slice */
+static PySequenceMethods Quaternion_SeqMethods = {
+ ( inquiry ) 0, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) Quaternion_item, /* sq_item */
+ ( intintargfunc ) Quaternion_slice, /* sq_slice */
+ ( intobjargproc ) Quaternion_ass_item, /* sq_ass_item */
+ ( intintobjargproc ) Quaternion_ass_slice, /* sq_ass_slice */
};
-static PyNumberMethods Quaternion_NumMethods =
-{
- (binaryfunc) Quaternion_add, /* __add__ */
- (binaryfunc) Quaternion_sub, /* __sub__ */
- (binaryfunc) Quaternion_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Quaternion_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
+static PyNumberMethods Quaternion_NumMethods = {
+ ( binaryfunc ) Quaternion_add, /* __add__ */
+ ( binaryfunc ) Quaternion_sub, /* __sub__ */
+ ( binaryfunc ) Quaternion_mul, /* __mul__ */
+ ( binaryfunc ) 0, /* __div__ */
+ ( binaryfunc ) 0, /* __mod__ */
+ ( binaryfunc ) 0, /* __divmod__ */
+ ( ternaryfunc ) 0, /* __pow__ */
+ ( unaryfunc ) 0, /* __neg__ */
+ ( unaryfunc ) 0, /* __pos__ */
+ ( unaryfunc ) 0, /* __abs__ */
+ ( inquiry ) 0, /* __nonzero__ */
+ ( unaryfunc ) 0, /* __invert__ */
+ ( binaryfunc ) 0, /* __lshift__ */
+ ( binaryfunc ) 0, /* __rshift__ */
+ ( binaryfunc ) 0, /* __and__ */
+ ( binaryfunc ) 0, /* __xor__ */
+ ( binaryfunc ) 0, /* __or__ */
+ ( coercion ) Quaternion_coerce, /* __coerce__ */
+ ( unaryfunc ) 0, /* __int__ */
+ ( unaryfunc ) 0, /* __long__ */
+ ( unaryfunc ) 0, /* __float__ */
+ ( unaryfunc ) 0, /* __oct__ */
+ ( unaryfunc ) 0, /* __hex__ */
};
-PyTypeObject quaternion_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "quaternion", /*tp_name*/
- sizeof(QuaternionObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Quaternion_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Quaternion_getattr, /*tp_getattr*/
- (setattrfunc) Quaternion_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Quaternion_repr, /*tp_repr*/
- &Quaternion_NumMethods, /*tp_as_number*/
- &Quaternion_SeqMethods, /*tp_as_sequence*/
+PyTypeObject quaternion_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /*ob_size */
+ "quaternion", /*tp_name */
+ sizeof( QuaternionObject ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Quaternion_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Quaternion_getattr, /*tp_getattr */
+ ( setattrfunc ) Quaternion_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) Quaternion_repr, /*tp_repr */
+ &Quaternion_NumMethods, /*tp_as_number */
+ &Quaternion_SeqMethods, /*tp_as_sequence */
};
-PyObject *newQuaternionObject(float *quat)
+PyObject *newQuaternionObject( float *quat )
{
- QuaternionObject *self;
- int x;
-
- quaternion_Type.ob_type = &PyType_Type;
-
- self = PyObject_NEW(QuaternionObject, &quaternion_Type);
-
- if(!quat){
- self->quat = PyMem_Malloc (4 *sizeof (float));
- for(x = 0; x < 4; x++){
- self->quat[x] = 0.0f;
- }
- self->quat[3] = 1.0f;
- }else{
- self->quat = quat;
- }
- self->flag = 0;
-
- return (PyObject*) self;
-}
+ QuaternionObject *self;
+ int x;
+
+ quaternion_Type.ob_type = &PyType_Type;
+
+ self = PyObject_NEW( QuaternionObject, &quaternion_Type );
+ if( !quat ) {
+ self->quat = PyMem_Malloc( 4 * sizeof( float ) );
+ for( x = 0; x < 4; x++ ) {
+ self->quat[x] = 0.0f;
+ }
+ self->quat[3] = 1.0f;
+ } else {
+ self->quat = quat;
+ }
+ self->flag = 0;
+
+ return ( PyObject * ) self;
+}
diff --git a/source/blender/python/api2_2x/quat.h b/source/blender/python/api2_2x/quat.h
index 586c8beba3e..a04e0ee7c37 100644
--- a/source/blender/python/api2_2x/quat.h
+++ b/source/blender/python/api2_2x/quat.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -51,24 +52,22 @@
#define QuaternionObject_Check(v) ((v)->ob_type == &quaternion_Type)
typedef struct {
- PyObject_VAR_HEAD
- float * quat;
+ PyObject_VAR_HEAD float *quat;
int flag;
- //0 - no coercion
- //1 - coerced from int
- //2 - coerced from float
+ //0 - no coercion
+ //1 - coerced from int
+ //2 - coerced from float
} QuaternionObject;
//prototypes
-PyObject *newQuaternionObject(float *quat);
-PyObject *Quaternion_Identity(QuaternionObject *self);
-PyObject *Quaternion_Negate(QuaternionObject *self);
-PyObject *Quaternion_Conjugate(QuaternionObject *self);
-PyObject *Quaternion_Inverse(QuaternionObject *self);
-PyObject *Quaternion_Normalize(QuaternionObject *self);
-PyObject *Quaternion_ToEuler(QuaternionObject *self);
-PyObject *Quaternion_ToMatrix(QuaternionObject *self);
-
-#endif /* EXPP_quat_h */
+PyObject *newQuaternionObject( float *quat );
+PyObject *Quaternion_Identity( QuaternionObject * self );
+PyObject *Quaternion_Negate( QuaternionObject * self );
+PyObject *Quaternion_Conjugate( QuaternionObject * self );
+PyObject *Quaternion_Inverse( QuaternionObject * self );
+PyObject *Quaternion_Normalize( QuaternionObject * self );
+PyObject *Quaternion_ToEuler( QuaternionObject * self );
+PyObject *Quaternion_ToMatrix( QuaternionObject * self );
+#endif /* EXPP_quat_h */
diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c
index 60ffa616f3b..c61120bfd75 100644
--- a/source/blender/python/api2_2x/rgbTuple.c
+++ b/source/blender/python/api2_2x/rgbTuple.c
@@ -38,94 +38,94 @@
/*****************************************************************************/
/* Python rgbTuple_Type callback function prototypes: */
/*****************************************************************************/
-static void rgbTuple_dealloc (BPy_rgbTuple *self);
-static PyObject *rgbTuple_getAttr (BPy_rgbTuple *self, char *name);
-static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v);
-static PyObject *rgbTuple_repr (BPy_rgbTuple *self);
+static void rgbTuple_dealloc( BPy_rgbTuple * self );
+static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name );
+static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v );
+static PyObject *rgbTuple_repr( BPy_rgbTuple * self );
-static int rgbTupleLength(BPy_rgbTuple *self);
+static int rgbTupleLength( BPy_rgbTuple * self );
-static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key);
-static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *who,
- PyObject *cares);
+static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key );
+static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * who,
+ PyObject * cares );
-static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i);
-static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob);
-static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end);
-static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end, PyObject *seq);
+static PyObject *rgbTupleItem( BPy_rgbTuple * self, int i );
+static int rgbTupleAssItem( BPy_rgbTuple * self, int i, PyObject * ob );
+static PyObject *rgbTupleSlice( BPy_rgbTuple * self, int begin, int end );
+static int rgbTupleAssSlice( BPy_rgbTuple * self, int begin, int end,
+ PyObject * seq );
/*****************************************************************************/
/* Python rgbTuple_Type Mapping Methods table: */
/*****************************************************************************/
-static PyMappingMethods rgbTupleAsMapping =
-{
- (inquiry)rgbTupleLength, /* mp_length */
- (binaryfunc)rgbTupleSubscript, /* mp_subscript */
- (objobjargproc)rgbTupleAssSubscript, /* mp_ass_subscript */
+static PyMappingMethods rgbTupleAsMapping = {
+ ( inquiry ) rgbTupleLength, /* mp_length */
+ ( binaryfunc ) rgbTupleSubscript, /* mp_subscript */
+ ( objobjargproc ) rgbTupleAssSubscript, /* mp_ass_subscript */
};
/*****************************************************************************/
/* Python rgbTuple_Type Sequence Methods table: */
/*****************************************************************************/
-static PySequenceMethods rgbTupleAsSequence =
-{
- (inquiry) rgbTupleLength, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) rgbTupleItem, /* sq_item */
- (intintargfunc) rgbTupleSlice, /* sq_slice */
- (intobjargproc) rgbTupleAssItem, /* sq_ass_item */
- (intintobjargproc) rgbTupleAssSlice, /* sq_ass_slice */
+static PySequenceMethods rgbTupleAsSequence = {
+ ( inquiry ) rgbTupleLength, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) rgbTupleItem, /* sq_item */
+ ( intintargfunc ) rgbTupleSlice, /* sq_slice */
+ ( intobjargproc ) rgbTupleAssItem, /* sq_ass_item */
+ ( intintobjargproc ) rgbTupleAssSlice, /* sq_ass_slice */
};
/*****************************************************************************/
/* Python rgbTuple_Type structure definition: */
/*****************************************************************************/
-PyTypeObject rgbTuple_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "rgbTuple", /* tp_name */
- sizeof (BPy_rgbTuple), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)rgbTuple_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)rgbTuple_getAttr, /* tp_getattr */
- (setattrfunc)rgbTuple_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)rgbTuple_repr, /* tp_repr */
- 0, /* tp_as_number */
- &rgbTupleAsSequence, /* tp_as_sequence */
- &rgbTupleAsMapping, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- 0, /* tp_methods */
- 0, /* tp_members */
+PyTypeObject rgbTuple_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "rgbTuple", /* tp_name */
+ sizeof( BPy_rgbTuple ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) rgbTuple_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) rgbTuple_getAttr, /* tp_getattr */
+ ( setattrfunc ) rgbTuple_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) rgbTuple_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ &rgbTupleAsSequence, /* tp_as_sequence */
+ &rgbTupleAsMapping, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_doc */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_methods */
+ 0, /* tp_members */
};
/*****************************************************************************/
/* Function: rgbTuple_New */
/*****************************************************************************/
-PyObject *rgbTuple_New(float *rgb[3])
+PyObject *rgbTuple_New( float *rgb[3] )
{
- BPy_rgbTuple *rgbTuple;
+ BPy_rgbTuple *rgbTuple;
- rgbTuple_Type.ob_type = &PyType_Type;
+ rgbTuple_Type.ob_type = &PyType_Type;
- rgbTuple = (BPy_rgbTuple *)PyObject_NEW(BPy_rgbTuple, &rgbTuple_Type);
+ rgbTuple =
+ ( BPy_rgbTuple * ) PyObject_NEW( BPy_rgbTuple,
+ &rgbTuple_Type );
- if (rgbTuple == NULL)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create rgbTuple object");
+ if( rgbTuple == NULL )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create rgbTuple object" );
rgbTuple->rgb[0] = rgb[0];
rgbTuple->rgb[1] = rgb[1];
rgbTuple->rgb[2] = rgb[2];
- return (PyObject *)rgbTuple;
+ return ( PyObject * ) rgbTuple;
}
/*****************************************************************************/
@@ -134,39 +134,41 @@ PyObject *rgbTuple_New(float *rgb[3])
/* get function returns a tuple, the set one accepts three */
/* floats (separated or in a tuple) as arguments. */
/*****************************************************************************/
-PyObject *rgbTuple_getCol (BPy_rgbTuple *self)
+PyObject *rgbTuple_getCol( BPy_rgbTuple * self )
{
- PyObject *list = PyList_New (3);
+ PyObject *list = PyList_New( 3 );
- if (!list) return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyList");
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- PyList_SET_ITEM (list, 0, Py_BuildValue ("f", *(self->rgb[0]) ));
- PyList_SET_ITEM (list, 1, Py_BuildValue ("f", *(self->rgb[1]) ));
- PyList_SET_ITEM (list, 2, Py_BuildValue ("f", *(self->rgb[2]) ));
+ PyList_SET_ITEM( list, 0, Py_BuildValue( "f", *( self->rgb[0] ) ) );
+ PyList_SET_ITEM( list, 1, Py_BuildValue( "f", *( self->rgb[1] ) ) );
+ PyList_SET_ITEM( list, 2, Py_BuildValue( "f", *( self->rgb[2] ) ) );
return list;
}
-PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args)
+PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
{
int ok;
float r = 0, g = 0, b = 0;
- if (PyObject_Length (args) == 3)
- ok = PyArg_ParseTuple (args, "fff", &r, &g, &b);
+ if( PyObject_Length( args ) == 3 )
+ ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
- else ok = PyArg_ParseTuple (args, "|(fff)", &r, &g, &b);
+ else
+ ok = PyArg_ParseTuple( args, "|(fff)", &r, &g, &b );
- if (!ok)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected [f,f,f] or f,f,f as arguments (or nothing)");
+ if( !ok )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected [f,f,f] or f,f,f as arguments (or nothing)" );
- *(self->rgb[0]) = EXPP_ClampFloat (r, 0.0, 1.0);
- *(self->rgb[1]) = EXPP_ClampFloat (g, 0.0, 1.0);
- *(self->rgb[2]) = EXPP_ClampFloat (b, 0.0, 1.0);
+ *( self->rgb[0] ) = EXPP_ClampFloat( r, 0.0, 1.0 );
+ *( self->rgb[1] ) = EXPP_ClampFloat( g, 0.0, 1.0 );
+ *( self->rgb[2] ) = EXPP_ClampFloat( b, 0.0, 1.0 );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/*****************************************************************************/
@@ -174,9 +176,9 @@ PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args)
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void rgbTuple_dealloc (BPy_rgbTuple *self)
+static void rgbTuple_dealloc( BPy_rgbTuple * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
/*****************************************************************************/
@@ -185,21 +187,24 @@ static void rgbTuple_dealloc (BPy_rgbTuple *self)
/* the function that accesses BPy_rgbTuple member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject* rgbTuple_getAttr (BPy_rgbTuple *self, char *name)
+static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name )
{
int i;
- if (strcmp(name, "__members__") == 0)
- return Py_BuildValue("[s,s,s]", "R", "G", "B");
+ if( strcmp( name, "__members__" ) == 0 )
+ return Py_BuildValue( "[s,s,s]", "R", "G", "B" );
- else if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
+ else if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "attribute not found"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "attribute not found" ) );
- return Py_BuildValue("f", *(self->rgb[i]));
+ return Py_BuildValue( "f", *( self->rgb[i] ) );
}
/*****************************************************************************/
@@ -207,27 +212,28 @@ static PyObject* rgbTuple_getAttr (BPy_rgbTuple *self, char *name)
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
/* the function that changes BPy_rgbTuple member variables. */
/*****************************************************************************/
-static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v)
+static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v )
{
float value;
- if (!PyArg_Parse (v, "f", &value))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected float argument");
+ if( !PyArg_Parse( v, "f", &value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected float argument" );
- value = EXPP_ClampFloat(value, 0.0, 1.0);
+ value = EXPP_ClampFloat( value, 0.0, 1.0 );
- if (!strcmp(name, "R") || !strcmp(name, "r"))
- *(self->rgb[0]) = value;
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ *( self->rgb[0] ) = value;
- else if (!strcmp(name, "G") || !strcmp(name, "g"))
- *(self->rgb[1]) = value;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ *( self->rgb[1] ) = value;
- else if (!strcmp(name, "B") || !strcmp(name, "b"))
- *(self->rgb[2]) = value;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ *( self->rgb[2] ) = value;
- else return (EXPP_ReturnIntError (PyExc_AttributeError,
- "attribute not found"));
+ else
+ return ( EXPP_ReturnIntError( PyExc_AttributeError,
+ "attribute not found" ) );
return 0;
}
@@ -237,55 +243,64 @@ static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v)
/* These functions provide code to access rgbTuple objects as */
/* mappings. */
/*****************************************************************************/
-static int rgbTupleLength(BPy_rgbTuple *self)
+static int rgbTupleLength( BPy_rgbTuple * self )
{
- return 3;
+ return 3;
}
-static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key)
+static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key )
{
char *name = NULL;
int i;
- if (PyNumber_Check(key)) return rgbTupleItem(self, (int)PyInt_AsLong(key));
+ if( PyNumber_Check( key ) )
+ return rgbTupleItem( self, ( int ) PyInt_AsLong( key ) );
- if (!PyArg_ParseTuple(key, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int or string argument");
+ if( !PyArg_ParseTuple( key, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int or string argument" );
- if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError, name);
+ return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
- return Py_BuildValue("f", *(self->rgb[i]));
+ return Py_BuildValue( "f", *( self->rgb[i] ) );
}
-static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *key, PyObject *v)
+static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * key,
+ PyObject * v )
{
- char *name = NULL;
+ char *name = NULL;
int i;
- if (!PyNumber_Check(v)) return EXPP_ReturnIntError(PyExc_TypeError,
- "value to assign must be a number");
+ if( !PyNumber_Check( v ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "value to assign must be a number" );
- if (PyNumber_Check(key))
- return rgbTupleAssItem(self, (int)PyInt_AsLong(key), v);
+ if( PyNumber_Check( key ) )
+ return rgbTupleAssItem( self, ( int ) PyInt_AsLong( key ), v );
- if (!PyArg_Parse(key, "s", &name))
- return EXPP_ReturnIntError (PyExc_TypeError,
- "expected int or string argument");
+ if( !PyArg_Parse( key, "s", &name ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int or string argument" );
- if (!strcmp(name, "R") || !strcmp(name, "r")) i = 0;
- else if (!strcmp(name, "G") || !strcmp(name, "g")) i = 1;
- else if (!strcmp(name, "B") || !strcmp(name, "b")) i = 2;
+ if( !strcmp( name, "R" ) || !strcmp( name, "r" ) )
+ i = 0;
+ else if( !strcmp( name, "G" ) || !strcmp( name, "g" ) )
+ i = 1;
+ else if( !strcmp( name, "B" ) || !strcmp( name, "b" ) )
+ i = 2;
else
- return EXPP_ReturnIntError (PyExc_AttributeError, name);
+ return EXPP_ReturnIntError( PyExc_AttributeError, name );
- *(self->rgb[i]) = EXPP_ClampFloat(PyFloat_AsDouble(v), 0.0, 1.0);
+ *( self->rgb[i] ) = EXPP_ClampFloat( PyFloat_AsDouble( v ), 0.0, 1.0 );
- return 0;
+ return 0;
}
/*****************************************************************************/
@@ -293,77 +308,84 @@ static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *key, PyObject *v)
/* These functions provide code to access rgbTuple objects as */
/* sequences. */
/*****************************************************************************/
-static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i)
+static PyObject *rgbTupleItem( BPy_rgbTuple * self, int i )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnPyObjError (PyExc_IndexError,
- "array index out of range");
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range" );
- return Py_BuildValue("f", *(self->rgb[i]));
+ return Py_BuildValue( "f", *( self->rgb[i] ) );
}
-static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end)
+static PyObject *rgbTupleSlice( BPy_rgbTuple * self, int begin, int end )
{
PyObject *list;
int count;
- if (begin < 0) begin = 0;
- if (end > 3) end = 3;
- if (begin > end) begin = end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
- list = PyList_New(end - begin);
+ list = PyList_New( end - begin );
- for (count = begin; count < end; count++)
- PyList_SetItem(list, count - begin,
- PyFloat_FromDouble(*(self->rgb[count])));
+ for( count = begin; count < end; count++ )
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( *( self->rgb[count] ) ) );
return list;
}
-static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob)
+static int rgbTupleAssItem( BPy_rgbTuple * self, int i, PyObject * ob )
{
- if (i < 0 || i >= 3)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range");
+ if( i < 0 || i >= 3 )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range" );
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "color component must be a number");
+ if( !PyNumber_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "color component must be a number" );
/* XXX this check above is probably ... */
- *(self->rgb[i]) = EXPP_ClampFloat(PyFloat_AsDouble(ob), 0.0, 1.0);
+ *( self->rgb[i] ) =
+ EXPP_ClampFloat( PyFloat_AsDouble( ob ), 0.0, 1.0 );
return 0;
}
-static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
- PyObject *seq)
+static int rgbTupleAssSlice( BPy_rgbTuple * self, int begin, int end,
+ PyObject * seq )
{
int count;
-
- if (begin < 0) begin = 0;
- if (end > 3) end = 3;
- if (begin > end) begin = end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation");
+ if( begin < 0 )
+ begin = 0;
+ if( end > 3 )
+ end = 3;
+ if( begin > end )
+ begin = end;
+
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation" );
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment");
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment" );
- for (count = begin; count < end; count++) {
+ for( count = begin; count < end; count++ ) {
float value;
- PyObject *ob = PySequence_GetItem(seq, count);
+ PyObject *ob = PySequence_GetItem( seq, count );
- if (!PyArg_Parse(ob, "f", &value)) {
- Py_DECREF(ob);
+ if( !PyArg_Parse( ob, "f", &value ) ) {
+ Py_DECREF( ob );
return -1;
}
- *(self->rgb[count]) = EXPP_ClampFloat(value, 0.0, 1.0);
+ *( self->rgb[count] ) = EXPP_ClampFloat( value, 0.0, 1.0 );
- Py_DECREF(ob);
+ Py_DECREF( ob );
}
return 0;
@@ -374,13 +396,13 @@ static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
/* Description: This is a callback function for the BPy_rgbTuple type. It */
/* builds a meaninful string to represent rgbTuple objects. */
/*****************************************************************************/
-static PyObject *rgbTuple_repr (BPy_rgbTuple *self)
+static PyObject *rgbTuple_repr( BPy_rgbTuple * self )
{
float r, g, b;
- r = *(self->rgb[0]);
- g = *(self->rgb[1]);
- b = *(self->rgb[2]);
+ r = *( self->rgb[0] );
+ g = *( self->rgb[1] );
+ b = *( self->rgb[2] );
- return PyString_FromFormat("[%f, %f, %f]", r, g, b);
+ return PyString_FromFormat( "[%f, %f, %f]", r, g, b );
}
diff --git a/source/blender/python/api2_2x/rgbTuple.h b/source/blender/python/api2_2x/rgbTuple.h
index 731c8904738..42a5318d001 100644
--- a/source/blender/python/api2_2x/rgbTuple.h
+++ b/source/blender/python/api2_2x/rgbTuple.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -41,19 +42,18 @@
* objects, so this header file must contain only 'public' declarations */
/*****************************************************************************/
-/* Python BPy_rgbTuple structure definition: */
+/* Python BPy_rgbTuple structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- float *rgb[3]; /* array of three pointers to floats */
+ PyObject_HEAD float *rgb[3]; /* array of three pointers to floats */
} BPy_rgbTuple;
/*****************************************************************************/
/* Python API function prototypes for the rgbTuple helper module. */
/*****************************************************************************/
-PyObject *rgbTuple_New (float *rgb[3]);
-PyObject *rgbTuple_getCol (BPy_rgbTuple *self);
-PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args);
+PyObject *rgbTuple_New( float *rgb[3] );
+PyObject *rgbTuple_getCol( BPy_rgbTuple * self );
+PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
-#endif /* EXPP_rgbTuple_H */
+#endif /* EXPP_rgbTuple_H */
diff --git a/source/blender/python/api2_2x/sceneRadio.c b/source/blender/python/api2_2x/sceneRadio.c
index 443094c4202..40be3efa3e3 100644
--- a/source/blender/python/api2_2x/sceneRadio.c
+++ b/source/blender/python/api2_2x/sceneRadio.c
@@ -30,9 +30,9 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include "sceneRadio.h" /* includes Python.h */
+#include "sceneRadio.h" /* includes Python.h */
#include "radio.h"
-#include <BKE_object.h> /* disable_where_script() */
+#include <BKE_object.h> /* disable_where_script() */
#include "gen_utils.h"
#include "constant.h"
@@ -76,731 +76,826 @@
#define EXPP_RADIO_drawtype_SOLID 1
#define EXPP_RADIO_drawtype_GOURAUD 2
-static int EXPP_check_scene(Scene *scene)
+static int EXPP_check_scene( Scene * scene )
{
- if (scene != G.scene) {
- PyErr_SetString(PyExc_EnvironmentError,
- "\nradiosity only works on the current scene, check scene.makeCurrent().");
+ if( scene != G.scene ) {
+ PyErr_SetString( PyExc_EnvironmentError,
+ "\nradiosity only works on the current scene, check scene.makeCurrent()." );
return 0;
- }
- else if (!scene->radio) {
- PyErr_SetString(PyExc_EnvironmentError,
- "\nradiosity data was deleted from scene!");
+ } else if( !scene->radio ) {
+ PyErr_SetString( PyExc_EnvironmentError,
+ "\nradiosity data was deleted from scene!" );
return 0;
}
return 1;
}
-static PyObject *Radio_collectMeshes(BPy_Radio *self);
-static PyObject *Radio_go(BPy_Radio *self);
-static PyObject *Radio_freeData(BPy_Radio *self);
-static PyObject *Radio_replaceMeshes(BPy_Radio *self);
-static PyObject *Radio_addMesh(BPy_Radio *self);
-static PyObject *Radio_filterFaces(BPy_Radio *self);
-static PyObject *Radio_filterElems(BPy_Radio *self);
-static PyObject *Radio_limitSubdivide(BPy_Radio *self);
-static PyObject *Radio_subdividePatches(BPy_Radio *self);
-static PyObject *Radio_subdivideElems(BPy_Radio *self);
-static PyObject *Radio_removeDoubles(BPy_Radio *self);
+static PyObject *Radio_collectMeshes( BPy_Radio * self );
+static PyObject *Radio_go( BPy_Radio * self );
+static PyObject *Radio_freeData( BPy_Radio * self );
+static PyObject *Radio_replaceMeshes( BPy_Radio * self );
+static PyObject *Radio_addMesh( BPy_Radio * self );
+static PyObject *Radio_filterFaces( BPy_Radio * self );
+static PyObject *Radio_filterElems( BPy_Radio * self );
+static PyObject *Radio_limitSubdivide( BPy_Radio * self );
+static PyObject *Radio_subdividePatches( BPy_Radio * self );
+static PyObject *Radio_subdivideElems( BPy_Radio * self );
+static PyObject *Radio_removeDoubles( BPy_Radio * self );
-static void Radio_dealloc (BPy_Radio *self);
-static PyObject *Radio_repr (BPy_Radio *self);
+static void Radio_dealloc( BPy_Radio * self );
+static PyObject *Radio_repr( BPy_Radio * self );
-static PyObject *EXPP_create_ret_PyInt(int value)
+static PyObject *EXPP_create_ret_PyInt( int value )
{
- PyObject *pyval = PyInt_FromLong(value);
+ PyObject *pyval = PyInt_FromLong( value );
- if (!pyval)
- PyErr_SetString(PyExc_MemoryError, "couldn't create py int!");
+ if( !pyval )
+ PyErr_SetString( PyExc_MemoryError,
+ "couldn't create py int!" );
return pyval;
}
-static PyObject *EXPP_create_ret_PyFloat(float value)
+static PyObject *EXPP_create_ret_PyFloat( float value )
{
- PyObject *pyval = PyFloat_FromDouble((double)value);
+ PyObject *pyval = PyFloat_FromDouble( ( double ) value );
- if (!pyval)
- PyErr_SetString(PyExc_MemoryError, "couldn't create py int!");
+ if( !pyval )
+ PyErr_SetString( PyExc_MemoryError,
+ "couldn't create py int!" );
return pyval;
}
-static PyObject *Radio_get_hemires(BPy_Radio *self)
+static PyObject *Radio_get_hemires( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->hemires);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->hemires );
}
-static PyObject *Radio_get_maxiter(BPy_Radio *self)
+static PyObject *Radio_get_maxiter( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->maxiter);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxiter );
}
-static PyObject *Radio_get_subshootp(BPy_Radio *self)
+static PyObject *Radio_get_subshootp( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->subshootp);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->subshootp );
}
-static PyObject *Radio_get_subshoote(BPy_Radio *self)
+static PyObject *Radio_get_subshoote( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->subshoote);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->subshoote );
}
-static PyObject *Radio_get_nodelim(BPy_Radio *self)
+static PyObject *Radio_get_nodelim( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->nodelim);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->nodelim );
}
-static PyObject *Radio_get_maxsublamp(BPy_Radio *self)
+static PyObject *Radio_get_maxsublamp( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->maxsublamp);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxsublamp );
}
-static PyObject *Radio_get_pama(BPy_Radio *self)
+static PyObject *Radio_get_pama( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->pama);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->pama );
}
-static PyObject *Radio_get_pami(BPy_Radio *self)
+static PyObject *Radio_get_pami( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->pami);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->pami );
}
-static PyObject *Radio_get_elma(BPy_Radio *self)
+static PyObject *Radio_get_elma( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->elma);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->elma );
}
-static PyObject *Radio_get_elmi(BPy_Radio *self)
+static PyObject *Radio_get_elmi( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->elmi);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->elmi );
}
-static PyObject *Radio_get_drawtype(BPy_Radio *self)
+static PyObject *Radio_get_drawtype( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->drawtype);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->drawtype );
}
-static PyObject *Radio_get_flag(BPy_Radio *self)
+static PyObject *Radio_get_flag( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->flag);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->flag );
}
-static PyObject *Radio_get_maxnode(BPy_Radio *self)
+static PyObject *Radio_get_maxnode( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyInt((int)self->scene->radio->maxnode);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyInt( ( int ) self->scene->radio->maxnode );
}
-static PyObject *Radio_get_convergence(BPy_Radio *self)
+static PyObject *Radio_get_convergence( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyFloat(self->scene->radio->convergence);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyFloat( self->scene->radio->convergence );
}
-static PyObject *Radio_get_radfac(BPy_Radio *self)
+static PyObject *Radio_get_radfac( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyFloat(self->scene->radio->radfac);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyFloat( self->scene->radio->radfac );
}
-static PyObject *Radio_get_gamma(BPy_Radio *self)
+static PyObject *Radio_get_gamma( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_create_ret_PyFloat(self->scene->radio->gamma);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_create_ret_PyFloat( self->scene->radio->gamma );
}
-static PyObject *EXPP_unpack_set_int(PyObject *args, int *ptr,
- int min, int max)
+static PyObject *EXPP_unpack_set_int( PyObject * args, int *ptr,
+ int min, int max )
{
int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
- *ptr = EXPP_ClampInt(value, min, max);
+ *ptr = EXPP_ClampInt( value, min, max );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
/* could merge with set_int, but is cleaner this way */
-static PyObject *EXPP_unpack_set_short(PyObject *args, short *ptr,
- short min, short max)
+static PyObject *EXPP_unpack_set_short( PyObject * args, short *ptr,
+ short min, short max )
{
int value;
- if (!PyArg_ParseTuple(args, "i", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument");
+ if( !PyArg_ParseTuple( args, "i", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int argument" );
- *ptr = (short)EXPP_ClampInt(value, min, max);
+ *ptr = ( short ) EXPP_ClampInt( value, min, max );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *EXPP_unpack_set_float(PyObject *args, float *ptr,
- float min, float max)
+static PyObject *EXPP_unpack_set_float( PyObject * args, float *ptr,
+ float min, float max )
{
float value;
- if (!PyArg_ParseTuple(args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument");
+ if( !PyArg_ParseTuple( args, "f", &value ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected float argument" );
- *ptr = EXPP_ClampFloat(value, min, max);
+ *ptr = EXPP_ClampFloat( value, min, max );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_set_hemires(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_hemires( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_short(args, &self->scene->radio->hemires,
- EXPP_RADIO_hemires_MIN, EXPP_RADIO_hemires_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_short( args, &self->scene->radio->hemires,
+ EXPP_RADIO_hemires_MIN,
+ EXPP_RADIO_hemires_MAX );
- if (ret) rad_setlimits();
+ if( ret )
+ rad_setlimits( );
return ret;
}
-static PyObject *Radio_set_maxiter(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_maxiter( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_short(args, &self->scene->radio->maxiter,
- EXPP_RADIO_maxiter_MIN, EXPP_RADIO_maxiter_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_short( args, &self->scene->radio->maxiter,
+ EXPP_RADIO_maxiter_MIN,
+ EXPP_RADIO_maxiter_MAX );
}
-static PyObject *Radio_set_subshootp(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_subshootp( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_short(args, &self->scene->radio->subshootp,
- EXPP_RADIO_subshootp_MIN, EXPP_RADIO_subshootp_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_short( args, &self->scene->radio->subshootp,
+ EXPP_RADIO_subshootp_MIN,
+ EXPP_RADIO_subshootp_MAX );
}
-static PyObject *Radio_set_subshoote(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_subshoote( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_short(args, &self->scene->radio->subshoote,
- EXPP_RADIO_subshoote_MIN, EXPP_RADIO_subshoote_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_short( args, &self->scene->radio->subshoote,
+ EXPP_RADIO_subshoote_MIN,
+ EXPP_RADIO_subshoote_MAX );
}
-static PyObject *Radio_set_nodelim(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_nodelim( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_short(args, &self->scene->radio->nodelim,
- EXPP_RADIO_nodelim_MIN, EXPP_RADIO_nodelim_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_short( args, &self->scene->radio->nodelim,
+ EXPP_RADIO_nodelim_MIN,
+ EXPP_RADIO_nodelim_MAX );
}
-static PyObject *Radio_set_maxsublamp(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_maxsublamp( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_short(args, &self->scene->radio->maxsublamp,
- EXPP_RADIO_maxsublamp_MIN, EXPP_RADIO_maxsublamp_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_short( args, &self->scene->radio->maxsublamp,
+ EXPP_RADIO_maxsublamp_MIN,
+ EXPP_RADIO_maxsublamp_MAX );
}
-static PyObject *Radio_set_pama(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_pama( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_short(args, &self->scene->radio->pama,
- EXPP_RADIO_pama_MIN, EXPP_RADIO_pama_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_short( args, &self->scene->radio->pama,
+ EXPP_RADIO_pama_MIN,
+ EXPP_RADIO_pama_MAX );
- if (ret) rad_setlimits();
+ if( ret )
+ rad_setlimits( );
return ret;
}
-static PyObject *Radio_set_pami(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_pami( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_short(args, &self->scene->radio->pami,
- EXPP_RADIO_pami_MIN, EXPP_RADIO_pami_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_short( args, &self->scene->radio->pami,
+ EXPP_RADIO_pami_MIN,
+ EXPP_RADIO_pami_MAX );
- if (ret) rad_setlimits();
+ if( ret )
+ rad_setlimits( );
return ret;
}
-static PyObject *Radio_set_elma(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_elma( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_short(args, &self->scene->radio->elma,
- EXPP_RADIO_elma_MIN, EXPP_RADIO_elma_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_short( args, &self->scene->radio->elma,
+ EXPP_RADIO_elma_MIN,
+ EXPP_RADIO_elma_MAX );
- if (ret) rad_setlimits();
+ if( ret )
+ rad_setlimits( );
return ret;
}
-static PyObject *Radio_set_elmi(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_elmi( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_short(args, &self->scene->radio->elmi,
- EXPP_RADIO_elmi_MIN, EXPP_RADIO_elmi_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_short( args, &self->scene->radio->elmi,
+ EXPP_RADIO_elmi_MIN,
+ EXPP_RADIO_elmi_MAX );
- if (ret) rad_setlimits();
+ if( ret )
+ rad_setlimits( );
return ret;
}
-static PyObject *Radio_set_drawtype(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_drawtype( BPy_Radio * self, PyObject * args )
{
PyObject *pyob = NULL;
char *str = NULL;
short dt = EXPP_RADIO_drawtype_WIRE;
- if (!EXPP_check_scene(self->scene)) return NULL;
-
- if (!PyArg_ParseTuple (args, "O", &pyob))
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expected int or string and another optional int as arguments");
-
- if (PyString_Check(pyob)) {
- str = PyString_AsString(pyob);
- if (!str)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create py string!");
- else if (!strcmp(str, "Wire")) dt = EXPP_RADIO_drawtype_WIRE;
- else if (!strcmp(str, "Solid")) dt = EXPP_RADIO_drawtype_SOLID;
- else if (!strcmp(str, "Gouraud")) dt = EXPP_RADIO_drawtype_GOURAUD;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+
+ if( !PyArg_ParseTuple( args, "O", &pyob ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int or string and another optional int as arguments" );
+
+ if( PyString_Check( pyob ) ) {
+ str = PyString_AsString( pyob );
+ if( !str )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create py string!" );
+ else if( !strcmp( str, "Wire" ) )
+ dt = EXPP_RADIO_drawtype_WIRE;
+ else if( !strcmp( str, "Solid" ) )
+ dt = EXPP_RADIO_drawtype_SOLID;
+ else if( !strcmp( str, "Gouraud" ) )
+ dt = EXPP_RADIO_drawtype_GOURAUD;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown drawtype string");
- }
- else if (PyInt_Check(pyob)) {
- dt = (short)EXPP_ClampInt(PyInt_AsLong(pyob),
- EXPP_RADIO_drawtype_WIRE, EXPP_RADIO_drawtype_GOURAUD);
- }
- else
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int or string as argument");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown drawtype string" );
+ } else if( PyInt_Check( pyob ) ) {
+ dt = ( short ) EXPP_ClampInt( PyInt_AsLong( pyob ),
+ EXPP_RADIO_drawtype_WIRE,
+ EXPP_RADIO_drawtype_GOURAUD );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected int or string as argument" );
self->scene->radio->drawtype = dt;
- set_radglobal(); /* needed to update 3d view(s) */
+ set_radglobal( ); /* needed to update 3d view(s) */
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_set_flag(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_flag( BPy_Radio * self, PyObject * args )
{
int i, imode = 0;
- char *mode[2] = {NULL, NULL};
-
- if (!EXPP_check_scene(self->scene)) return NULL;
-
- if (!PyArg_ParseTuple(args, "|ss", &mode[0], &mode[1]))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string arguments (or nothing)");
-
- for (i = 0; i < 2; i++) {
- if (!mode[i]) break;
- else if (!strcmp(mode[i], "ShowLimits")) imode |= EXPP_RADIO_flag_SHOWLIM;
- else if (!strcmp(mode[i], "Z")) imode |= EXPP_RADIO_flag_Z;
- else return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown mode string");
+ char *mode[2] = { NULL, NULL };
+
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+
+ if( !PyArg_ParseTuple( args, "|ss", &mode[0], &mode[1] ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string arguments (or nothing)" );
+
+ for( i = 0; i < 2; i++ ) {
+ if( !mode[i] )
+ break;
+ else if( !strcmp( mode[i], "ShowLimits" ) )
+ imode |= EXPP_RADIO_flag_SHOWLIM;
+ else if( !strcmp( mode[i], "Z" ) )
+ imode |= EXPP_RADIO_flag_Z;
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown mode string" );
}
- self->scene->radio->flag = (short)EXPP_ClampInt(imode, 0, 3);
+ self->scene->radio->flag = ( short ) EXPP_ClampInt( imode, 0, 3 );
- set_radglobal(); /* needed to update 3d view(s) */
+ set_radglobal( ); /* needed to update 3d view(s) */
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_set_maxnode(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_maxnode( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_int(args, &self->scene->radio->maxnode,
- EXPP_RADIO_maxnode_MIN, EXPP_RADIO_maxnode_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_int( args, &self->scene->radio->maxnode,
+ EXPP_RADIO_maxnode_MIN,
+ EXPP_RADIO_maxnode_MAX );
}
-static PyObject *Radio_set_convergence(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_convergence( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_float(args, &self->scene->radio->convergence,
- EXPP_RADIO_convergence_MIN, EXPP_RADIO_convergence_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_float( args, &self->scene->radio->convergence,
+ EXPP_RADIO_convergence_MIN,
+ EXPP_RADIO_convergence_MAX );
}
-static PyObject *Radio_set_radfac(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_radfac( BPy_Radio * self, PyObject * args )
{
PyObject *ret;
- if (!EXPP_check_scene(self->scene)) return NULL;
- ret = EXPP_unpack_set_float(args, &self->scene->radio->radfac,
- EXPP_RADIO_radfac_MIN, EXPP_RADIO_radfac_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ ret = EXPP_unpack_set_float( args, &self->scene->radio->radfac,
+ EXPP_RADIO_radfac_MIN,
+ EXPP_RADIO_radfac_MAX );
- if (ret) {
- set_radglobal();
- if (rad_phase() & RAD_PHASE_FACES) make_face_tab();
- else make_node_display();
+ if( ret ) {
+ set_radglobal( );
+ if( rad_phase( ) & RAD_PHASE_FACES )
+ make_face_tab( );
+ else
+ make_node_display( );
}
return ret;
}
-static PyObject *Radio_set_gamma(BPy_Radio *self, PyObject *args)
+static PyObject *Radio_set_gamma( BPy_Radio * self, PyObject * args )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
- return EXPP_unpack_set_float(args, &self->scene->radio->gamma,
- EXPP_RADIO_gamma_MIN, EXPP_RADIO_gamma_MAX);
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
+ return EXPP_unpack_set_float( args, &self->scene->radio->gamma,
+ EXPP_RADIO_gamma_MIN,
+ EXPP_RADIO_gamma_MAX );
}
static PyMethodDef BPy_Radio_methods[] = {
- {"collectMeshes", (PyCFunction) Radio_collectMeshes, METH_NOARGS,
- "() - Convert selected meshes to patches."},
- {"go", (PyCFunction) Radio_go, METH_NOARGS,
- "() - Start radiosity calculations."},
- {"freeData", (PyCFunction) Radio_freeData, METH_NOARGS,
- "() - Free all memory used by radiosity."},
- {"addMesh", (PyCFunction) Radio_addMesh, METH_NOARGS,
- "() - Add a new mesh with the radio values as vertex colors to Blender."},
- {"replaceMeshes", (PyCFunction) Radio_replaceMeshes, METH_NOARGS,
- "() - Replace input meshes with the one created by radiosity simulation."},
- {"limitSubdivide", (PyCFunction) Radio_limitSubdivide, METH_NOARGS,
- "() - Subdivide patches."},
- {"filterFaces", (PyCFunction) Radio_filterFaces, METH_NOARGS,
- "() - Force an extra smoothing."},
- {"filterElems", (PyCFunction) Radio_filterElems, METH_NOARGS,
- "() - Filter elements to remove aliasing artifacts."},
- {"subdividePatches", (PyCFunction) Radio_subdividePatches, METH_NOARGS,
- "() - Pre-subdivision: detect high-energy patches and subdivide them."},
- {"subdivideElems", (PyCFunction) Radio_subdivideElems, METH_NOARGS,
- "() - Pre-subdivision: detect high-energy elements and subdivide them."},
- {"removeDoubles", (PyCFunction) Radio_removeDoubles, METH_NOARGS,
- "() - Join elements which differ less than the defined node limit."},
- {"getHemiRes", (PyCFunction) Radio_get_hemires, METH_NOARGS,
- "() - Get hemicube size."},
- {"setHemiRes", (PyCFunction) Radio_set_hemires, METH_VARARGS,
- "(int) - Set hemicube size, the range is [100, 1000]."},
- {"getMaxIter", (PyCFunction) Radio_get_maxiter, METH_NOARGS,
- "() - Get maximum number of radiosity rounds."},
- {"setMaxIter", (PyCFunction) Radio_set_maxiter, METH_VARARGS,
- "(i) - Set maximum number of radiosity rounds in [0, 10000]."},
- {"getSubShPatch", (PyCFunction) Radio_get_subshootp, METH_NOARGS,
- "() - Get max number of times environment is tested to detect patches."},
- {"setSubShPatch", (PyCFunction) Radio_set_subshootp, METH_VARARGS,
- "(i) - Set max number of times environment is tested to detect patches.\n\
+ {"collectMeshes", ( PyCFunction ) Radio_collectMeshes, METH_NOARGS,
+ "() - Convert selected meshes to patches."},
+ {"go", ( PyCFunction ) Radio_go, METH_NOARGS,
+ "() - Start radiosity calculations."},
+ {"freeData", ( PyCFunction ) Radio_freeData, METH_NOARGS,
+ "() - Free all memory used by radiosity."},
+ {"addMesh", ( PyCFunction ) Radio_addMesh, METH_NOARGS,
+ "() - Add a new mesh with the radio values as vertex colors to Blender."},
+ {"replaceMeshes", ( PyCFunction ) Radio_replaceMeshes, METH_NOARGS,
+ "() - Replace input meshes with the one created by radiosity simulation."},
+ {"limitSubdivide", ( PyCFunction ) Radio_limitSubdivide, METH_NOARGS,
+ "() - Subdivide patches."},
+ {"filterFaces", ( PyCFunction ) Radio_filterFaces, METH_NOARGS,
+ "() - Force an extra smoothing."},
+ {"filterElems", ( PyCFunction ) Radio_filterElems, METH_NOARGS,
+ "() - Filter elements to remove aliasing artifacts."},
+ {"subdividePatches", ( PyCFunction ) Radio_subdividePatches,
+ METH_NOARGS,
+ "() - Pre-subdivision: detect high-energy patches and subdivide them."},
+ {"subdivideElems", ( PyCFunction ) Radio_subdivideElems, METH_NOARGS,
+ "() - Pre-subdivision: detect high-energy elements and subdivide them."},
+ {"removeDoubles", ( PyCFunction ) Radio_removeDoubles, METH_NOARGS,
+ "() - Join elements which differ less than the defined node limit."},
+ {"getHemiRes", ( PyCFunction ) Radio_get_hemires, METH_NOARGS,
+ "() - Get hemicube size."},
+ {"setHemiRes", ( PyCFunction ) Radio_set_hemires, METH_VARARGS,
+ "(int) - Set hemicube size, the range is [100, 1000]."},
+ {"getMaxIter", ( PyCFunction ) Radio_get_maxiter, METH_NOARGS,
+ "() - Get maximum number of radiosity rounds."},
+ {"setMaxIter", ( PyCFunction ) Radio_set_maxiter, METH_VARARGS,
+ "(i) - Set maximum number of radiosity rounds in [0, 10000]."},
+ {"getSubShPatch", ( PyCFunction ) Radio_get_subshootp, METH_NOARGS,
+ "() - Get max number of times environment is tested to detect patches."},
+ {"setSubShPatch", ( PyCFunction ) Radio_set_subshootp, METH_VARARGS,
+ "(i) - Set max number of times environment is tested to detect patches.\n\
Range is [0, 10]."},
- {"getSubShElem", (PyCFunction) Radio_get_subshoote, METH_NOARGS,
- "() - Get number of times environment is tested to detect elements."},
- {"setSubShElem", (PyCFunction) Radio_set_subshoote, METH_VARARGS,
- "(i) - Set number of times environment is tested to detect elements.\n\
+ {"getSubShElem", ( PyCFunction ) Radio_get_subshoote, METH_NOARGS,
+ "() - Get number of times environment is tested to detect elements."},
+ {"setSubShElem", ( PyCFunction ) Radio_set_subshoote, METH_VARARGS,
+ "(i) - Set number of times environment is tested to detect elements.\n\
Range is [0, 10]."},
- {"getElemLimit", (PyCFunction) Radio_get_nodelim, METH_NOARGS,
- "() - Get the range for removing doubles."},
- {"setElemLimit", (PyCFunction) Radio_set_nodelim, METH_VARARGS,
- "(i) - Set the range for removing doubles in [0, 50]."},
- {"getMaxSubdivSh", (PyCFunction) Radio_get_maxsublamp, METH_NOARGS,
- "() - Get max number of initial shoot patches evaluated."},
- {"setMaxSubdivSh", (PyCFunction) Radio_set_maxsublamp, METH_VARARGS,
- "(i) - Set max number of initial shoot patches evaluated in [1, 250]."},
- {"getPatchMax", (PyCFunction) Radio_get_pama, METH_NOARGS,
- "() - Get max size of a patch."},
- {"setPatchMax", (PyCFunction) Radio_set_pama, METH_VARARGS,
- "(i) - Set max size of a patch in [10, 1000]."},
- {"getPatchMin", (PyCFunction) Radio_get_pami, METH_NOARGS,
- "() - Get minimum size of a patch."},
- {"setPatchMin", (PyCFunction) Radio_set_pami, METH_VARARGS,
- "(i) - Set minimum size of a patch in [10, 1000]."},
- {"getElemMax", (PyCFunction) Radio_get_elma, METH_NOARGS,
- "() - Get max size of an element."},
- {"setElemMax", (PyCFunction) Radio_set_elma, METH_VARARGS,
- "(i) - Set max size of an element in [1, 100]."},
- {"getElemMin", (PyCFunction) Radio_get_elmi, METH_NOARGS,
- "() - Get minimum size of an element."},
- {"setElemMin", (PyCFunction) Radio_set_elmi, METH_VARARGS,
- "(i) - Set minimum size of an element in [1, 100]."},
- {"getMaxElems", (PyCFunction) Radio_get_maxnode, METH_NOARGS,
- "() - Get maximum number of elements."},
- {"setMaxElems", (PyCFunction) Radio_set_maxnode, METH_VARARGS,
- "(i) - Set maximum nunber of elements in [1, 250000]."},
- {"getConvergence", (PyCFunction) Radio_get_convergence, METH_NOARGS,
- "() - Get lower threshold of unshot energy."},
- {"setConvergence", (PyCFunction) Radio_set_convergence, METH_VARARGS,
- "(f) - Set lower threshold of unshot energy in [0.0, 1.0]."},
- {"getMult", (PyCFunction) Radio_get_radfac, METH_NOARGS,
- "() - Get energy value multiplier."},
- {"setMult", (PyCFunction) Radio_set_radfac, METH_VARARGS,
- "(f) - Set energy value multiplier in [0.001, 250.0]."},
- {"getGamma", (PyCFunction) Radio_get_gamma, METH_NOARGS,
- "() - Get change in the contrast of energy values."},
- {"setGamma", (PyCFunction) Radio_set_gamma, METH_VARARGS,
- "(f) - Set change in the contrast of energy values in [0.2, 10.0]."},
- {"getDrawType", (PyCFunction) Radio_get_drawtype, METH_NOARGS,
- "() - Get the draw type: Wire, Solid or Gouraud as an int value."},
- {"setDrawType", (PyCFunction) Radio_set_drawtype, METH_VARARGS,
- "(i or s) - Set the draw type: wire, solid (default) or gouraud."},
- {"getMode", (PyCFunction) Radio_get_flag, METH_NOARGS,
- "() - Get mode as int (or'ed bitflags), see Radio.Modes dict."},
- {"setMode", (PyCFunction) Radio_set_flag, METH_VARARGS,
- "(|ss) - Set mode flags as strings: 'ShowLimits', 'Z'."},
+ {"getElemLimit", ( PyCFunction ) Radio_get_nodelim, METH_NOARGS,
+ "() - Get the range for removing doubles."},
+ {"setElemLimit", ( PyCFunction ) Radio_set_nodelim, METH_VARARGS,
+ "(i) - Set the range for removing doubles in [0, 50]."},
+ {"getMaxSubdivSh", ( PyCFunction ) Radio_get_maxsublamp, METH_NOARGS,
+ "() - Get max number of initial shoot patches evaluated."},
+ {"setMaxSubdivSh", ( PyCFunction ) Radio_set_maxsublamp, METH_VARARGS,
+ "(i) - Set max number of initial shoot patches evaluated in [1, 250]."},
+ {"getPatchMax", ( PyCFunction ) Radio_get_pama, METH_NOARGS,
+ "() - Get max size of a patch."},
+ {"setPatchMax", ( PyCFunction ) Radio_set_pama, METH_VARARGS,
+ "(i) - Set max size of a patch in [10, 1000]."},
+ {"getPatchMin", ( PyCFunction ) Radio_get_pami, METH_NOARGS,
+ "() - Get minimum size of a patch."},
+ {"setPatchMin", ( PyCFunction ) Radio_set_pami, METH_VARARGS,
+ "(i) - Set minimum size of a patch in [10, 1000]."},
+ {"getElemMax", ( PyCFunction ) Radio_get_elma, METH_NOARGS,
+ "() - Get max size of an element."},
+ {"setElemMax", ( PyCFunction ) Radio_set_elma, METH_VARARGS,
+ "(i) - Set max size of an element in [1, 100]."},
+ {"getElemMin", ( PyCFunction ) Radio_get_elmi, METH_NOARGS,
+ "() - Get minimum size of an element."},
+ {"setElemMin", ( PyCFunction ) Radio_set_elmi, METH_VARARGS,
+ "(i) - Set minimum size of an element in [1, 100]."},
+ {"getMaxElems", ( PyCFunction ) Radio_get_maxnode, METH_NOARGS,
+ "() - Get maximum number of elements."},
+ {"setMaxElems", ( PyCFunction ) Radio_set_maxnode, METH_VARARGS,
+ "(i) - Set maximum nunber of elements in [1, 250000]."},
+ {"getConvergence", ( PyCFunction ) Radio_get_convergence, METH_NOARGS,
+ "() - Get lower threshold of unshot energy."},
+ {"setConvergence", ( PyCFunction ) Radio_set_convergence, METH_VARARGS,
+ "(f) - Set lower threshold of unshot energy in [0.0, 1.0]."},
+ {"getMult", ( PyCFunction ) Radio_get_radfac, METH_NOARGS,
+ "() - Get energy value multiplier."},
+ {"setMult", ( PyCFunction ) Radio_set_radfac, METH_VARARGS,
+ "(f) - Set energy value multiplier in [0.001, 250.0]."},
+ {"getGamma", ( PyCFunction ) Radio_get_gamma, METH_NOARGS,
+ "() - Get change in the contrast of energy values."},
+ {"setGamma", ( PyCFunction ) Radio_set_gamma, METH_VARARGS,
+ "(f) - Set change in the contrast of energy values in [0.2, 10.0]."},
+ {"getDrawType", ( PyCFunction ) Radio_get_drawtype, METH_NOARGS,
+ "() - Get the draw type: Wire, Solid or Gouraud as an int value."},
+ {"setDrawType", ( PyCFunction ) Radio_set_drawtype, METH_VARARGS,
+ "(i or s) - Set the draw type: wire, solid (default) or gouraud."},
+ {"getMode", ( PyCFunction ) Radio_get_flag, METH_NOARGS,
+ "() - Get mode as int (or'ed bitflags), see Radio.Modes dict."},
+ {"setMode", ( PyCFunction ) Radio_set_flag, METH_VARARGS,
+ "(|ss) - Set mode flags as strings: 'ShowLimits', 'Z'."},
{NULL, NULL, 0, NULL}
};
static PyTypeObject Radio_Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Blender Radiosity", /*tp_name*/
- sizeof(BPy_Radio), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Radio_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc)Radio_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "Blender radiosity", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_Radio_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0,0,0,0,0,0,0,0, /* up to tp_del, so we don't get a warning */
+ PyObject_HEAD_INIT( NULL )
+ 0, /*ob_size */
+ "Blender Radiosity", /*tp_name */
+ sizeof( BPy_Radio ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Radio_dealloc, /*tp_dealloc */
+ 0, /*tp_print */
+ 0, /*tp_getattr */
+ 0, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) Radio_repr, /*tp_repr */
+ 0, /*tp_as_number */
+ 0, /*tp_as_sequence */
+ 0, /*tp_as_mapping */
+ 0, /*tp_hash */
+ 0, /*tp_call */
+ 0, /*tp_str */
+ 0, /*tp_getattro */
+ 0, /*tp_setattro */
+ 0, /*tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags */
+ "Blender radiosity", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ BPy_Radio_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* up to tp_del, so we don't get a warning */
};
-static void Radio_dealloc (BPy_Radio *self)
+static void Radio_dealloc( BPy_Radio * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Radio_repr (BPy_Radio *self)
+static PyObject *Radio_repr( BPy_Radio * self )
{
- if (self->radio)
- return PyString_FromFormat ("[Radiosity \"%s\"]", self->scene->id.name + 2);
+ if( self->radio )
+ return PyString_FromFormat( "[Radiosity \"%s\"]",
+ self->scene->id.name + 2 );
else
- return PyString_FromString ("NULL");
+ return PyString_FromString( "NULL" );
}
-PyObject *Radio_CreatePyObject (struct Scene *scene)
+PyObject *Radio_CreatePyObject( struct Scene * scene )
{
BPy_Radio *py_radio;
- if (scene != G.scene) {
- return EXPP_ReturnPyObjError (PyExc_EnvironmentError,
- "\nradiosity only works on the current scene, check scene.makeCurrent().");
+ if( scene != G.scene ) {
+ return EXPP_ReturnPyObjError( PyExc_EnvironmentError,
+ "\nradiosity only works on the current scene, check scene.makeCurrent()." );
}
- py_radio = (BPy_Radio *) PyObject_NEW (BPy_Radio, &Radio_Type);
+ py_radio = ( BPy_Radio * ) PyObject_NEW( BPy_Radio, &Radio_Type );
- if (!py_radio) return NULL;
+ if( !py_radio )
+ return NULL;
- if (!scene->radio) add_radio(); /* adds to G.scene */
+ if( !scene->radio )
+ add_radio( ); /* adds to G.scene */
py_radio->radio = scene->radio;
py_radio->scene = scene;
- return ((PyObject *) py_radio);
+ return ( ( PyObject * ) py_radio );
}
-int Radio_CheckPyObject (PyObject *pyob)
+int Radio_CheckPyObject( PyObject * pyob )
{
- return (pyob->ob_type == &Radio_Type);
+ return ( pyob->ob_type == &Radio_Type );
}
-static PyObject *Radio_collectMeshes(BPy_Radio *self)
+static PyObject *Radio_collectMeshes( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- disable_where_script(1); /* used to avoid error popups */
- rad_collect_meshes();
- disable_where_script(0);
+ disable_where_script( 1 ); /* used to avoid error popups */
+ rad_collect_meshes( );
+ disable_where_script( 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_freeData(BPy_Radio *self)
+static PyObject *Radio_freeData( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- delete_radio();
+ delete_radio( );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_go(BPy_Radio *self)
+static PyObject *Radio_go( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() == RAD_PHASE_PATCHES) rad_go();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() first.");
+ if( rad_phase( ) == RAD_PHASE_PATCHES )
+ rad_go( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_replaceMeshes(BPy_Radio *self)
+static PyObject *Radio_replaceMeshes( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() & RAD_PHASE_FACES) rad_replacemesh();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) & RAD_PHASE_FACES )
+ rad_replacemesh( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_addMesh(BPy_Radio *self)
+static PyObject *Radio_addMesh( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() & RAD_PHASE_FACES) rad_addmesh();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) & RAD_PHASE_FACES )
+ rad_addmesh( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_filterFaces(BPy_Radio *self)
+static PyObject *Radio_filterFaces( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() & RAD_PHASE_FACES) filterFaces();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) & RAD_PHASE_FACES )
+ filterFaces( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_filterElems(BPy_Radio *self)
+static PyObject *Radio_filterElems( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() & RAD_PHASE_FACES) {
- set_radglobal();
- filterNodes();
- make_face_tab();
- }
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) & RAD_PHASE_FACES ) {
+ set_radglobal( );
+ filterNodes( );
+ make_face_tab( );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_limitSubdivide(BPy_Radio *self)
+static PyObject *Radio_limitSubdivide( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() == RAD_PHASE_PATCHES) rad_limit_subdivide();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call this before calculating the radiosity simulation.");
+ if( rad_phase( ) == RAD_PHASE_PATCHES )
+ rad_limit_subdivide( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call this before calculating the radiosity simulation." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_subdividePatches(BPy_Radio *self)
+static PyObject *Radio_subdividePatches( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() == RAD_PHASE_PATCHES) rad_subdivshootpatch();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call this before calculating the radiosity simulation.");
+ if( rad_phase( ) == RAD_PHASE_PATCHES )
+ rad_subdivshootpatch( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call this before calculating the radiosity simulation." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_subdivideElems(BPy_Radio *self)
+static PyObject *Radio_subdivideElems( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() == RAD_PHASE_PATCHES) rad_subdivshootelem();
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) == RAD_PHASE_PATCHES )
+ rad_subdivshootelem( );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyObject *Radio_removeDoubles(BPy_Radio *self)
+static PyObject *Radio_removeDoubles( BPy_Radio * self )
{
- if (!EXPP_check_scene(self->scene)) return NULL;
+ if( !EXPP_check_scene( self->scene ) )
+ return NULL;
- if (rad_phase() == RAD_PHASE_FACES) {
- set_radglobal();
- removeEqualNodes(self->scene->radio->nodelim);
- make_face_tab();
- }
- else return EXPP_ReturnPyObjError(PyExc_RuntimeError,
- "you need to call radio.collectMeshes() and radio.go() first.");
+ if( rad_phase( ) == RAD_PHASE_FACES ) {
+ set_radglobal( );
+ removeEqualNodes( self->scene->radio->nodelim );
+ make_face_tab( );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "you need to call radio.collectMeshes() and radio.go() first." );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static PyMethodDef M_Radio_methods[] = {{NULL, NULL, 0, NULL}};
+static PyMethodDef M_Radio_methods[] = { {NULL, NULL, 0, NULL} };
-PyObject *Radio_Init (void)
+PyObject *Radio_Init( void )
{
PyObject *submodule, *Modes, *DrawTypes;
- if (PyType_Ready(&Radio_Type) < 0) return NULL;
+ if( PyType_Ready( &Radio_Type ) < 0 )
+ return NULL;
- submodule = Py_InitModule3 ("Blender.Scene.Radio", M_Radio_methods,
- "The Blender Radiosity submodule");
+ submodule = Py_InitModule3( "Blender.Scene.Radio", M_Radio_methods,
+ "The Blender Radiosity submodule" );
- Modes = M_constant_New();
- DrawTypes = M_constant_New();
+ Modes = M_constant_New( );
+ DrawTypes = M_constant_New( );
- if (Modes) {
- BPy_constant *d = (BPy_constant *)Modes;
+ if( Modes ) {
+ BPy_constant *d = ( BPy_constant * ) Modes;
- constant_insert(d, "ShowLimits", PyInt_FromLong(EXPP_RADIO_flag_SHOWLIM));
- constant_insert(d, "Z", PyInt_FromLong(EXPP_RADIO_flag_Z));
+ constant_insert( d, "ShowLimits",
+ PyInt_FromLong( EXPP_RADIO_flag_SHOWLIM ) );
+ constant_insert( d, "Z", PyInt_FromLong( EXPP_RADIO_flag_Z ) );
- PyModule_AddObject(submodule, "Modes", Modes);
+ PyModule_AddObject( submodule, "Modes", Modes );
}
- if (DrawTypes) {
- BPy_constant *d = (BPy_constant *)DrawTypes;
+ if( DrawTypes ) {
+ BPy_constant *d = ( BPy_constant * ) DrawTypes;
- constant_insert(d, "Wire", PyInt_FromLong(EXPP_RADIO_drawtype_WIRE));
- constant_insert(d, "Solid", PyInt_FromLong(EXPP_RADIO_drawtype_SOLID));
- constant_insert(d, "Gouraud", PyInt_FromLong(EXPP_RADIO_drawtype_GOURAUD));
+ constant_insert( d, "Wire",
+ PyInt_FromLong( EXPP_RADIO_drawtype_WIRE ) );
+ constant_insert( d, "Solid",
+ PyInt_FromLong( EXPP_RADIO_drawtype_SOLID ) );
+ constant_insert( d, "Gouraud",
+ PyInt_FromLong
+ ( EXPP_RADIO_drawtype_GOURAUD ) );
- PyModule_AddObject(submodule, "DrawTypes", DrawTypes);
+ PyModule_AddObject( submodule, "DrawTypes", DrawTypes );
}
return submodule;
diff --git a/source/blender/python/api2_2x/sceneRadio.h b/source/blender/python/api2_2x/sceneRadio.h
index a08d7d4327b..7796e1f0c44 100644
--- a/source/blender/python/api2_2x/sceneRadio.h
+++ b/source/blender/python/api2_2x/sceneRadio.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -37,16 +38,14 @@
#include <DNA_scene_types.h>
/* BPy_Radio declaration */
-typedef struct
-{
- PyObject_HEAD
- struct Radio *radio;
- struct Scene *scene;
-}BPy_Radio;
+typedef struct {
+ PyObject_HEAD struct Radio *radio;
+ struct Scene *scene;
+} BPy_Radio;
-PyObject *Radio_Init (void);
+PyObject *Radio_Init( void );
-PyObject *Radio_CreatePyObject (struct Scene * scene);
-int Radio_CheckPyObject (PyObject * py_obj);
+PyObject *Radio_CreatePyObject( struct Scene *scene );
+int Radio_CheckPyObject( PyObject * py_obj );
-#endif /* EXPP_SCENERADIO_H */
+#endif /* EXPP_SCENERADIO_H */
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c
index 22884e4aecd..8b2f55a3398 100644
--- a/source/blender/python/api2_2x/sceneRender.c
+++ b/source/blender/python/api2_2x/sceneRender.c
@@ -51,7 +51,7 @@
#include "modules.h"
#ifdef HAVE_CONFIG_H
- #include <config.h>
+#include <config.h>
#endif
//local defines
@@ -66,1528 +66,1949 @@
RE_Render R;
-//----------------------------------------------Render prototypes---------------------------------------------------------------
-static PyObject *M_Render_CloseRenderWindow (PyObject *self);
-static PyObject *M_Render_EnableDispView (PyObject *self);
-static PyObject *M_Render_EnableDispWin (PyObject *self);
-static PyObject *M_Render_SetRenderWinPos (PyObject *self, PyObject *args);
-static PyObject *M_Render_EnableEdgeShift (PyObject *self, PyObject *args);
-static PyObject *M_Render_EnableEdgeAll (PyObject *self, PyObject *args);
-//----------------------------------------------Render doc strings--------------------------------------------------------------
+//---------------------------------------Render prototypes-------------
+static PyObject *M_Render_CloseRenderWindow( PyObject * self );
+static PyObject *M_Render_EnableDispView( PyObject * self );
+static PyObject *M_Render_EnableDispWin( PyObject * self );
+static PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args );
+static PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args );
+static PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args );
+//----------------------------------------------Render doc strings------
static char M_Render_doc[] = "The Blender Render module";
-//----------------------------------------------Render method def--------------------------------------------------------------
+//----------------------------------------------Render method def-------
struct PyMethodDef M_Render_methods[] = {
- {"CloseRenderWindow",(PyCFunction)M_Render_CloseRenderWindow, METH_NOARGS,
- "() - close the rendering window\n"},
- {"EnableDispView",(PyCFunction)M_Render_EnableDispView, METH_NOARGS,
- "(bool) - enable Sceneing in view\n"},
- {"EnableDispWin",(PyCFunction)M_Render_EnableDispWin, METH_NOARGS,
- "(bool) - enable Sceneing in new window\n"},
- {"SetRenderWinPos",(PyCFunction)M_Render_SetRenderWinPos, METH_VARARGS,
- "([string list]) - position the rendering window in around the edge of the screen\n"},
- {"EnableEdgeShift",(PyCFunction)M_Render_EnableEdgeShift, METH_VARARGS,
- "(bool) - with the unified renderer the outlines are shifted a bit.\n"},
- {"EnableEdgeAll",(PyCFunction)M_Render_EnableEdgeAll, METH_VARARGS,
- "(bool) - also consider transparent faces for edge-rendering with the unified renderer\n"},
- {NULL, NULL, 0, NULL}
+ {"CloseRenderWindow", ( PyCFunction ) M_Render_CloseRenderWindow,
+ METH_NOARGS,
+ "() - close the rendering window\n"},
+ {"EnableDispView", ( PyCFunction ) M_Render_EnableDispView,
+ METH_NOARGS,
+ "(bool) - enable Sceneing in view\n"},
+ {"EnableDispWin", ( PyCFunction ) M_Render_EnableDispWin, METH_NOARGS,
+ "(bool) - enable Sceneing in new window\n"},
+ {"SetRenderWinPos", ( PyCFunction ) M_Render_SetRenderWinPos,
+ METH_VARARGS,
+ "([string list]) - position the rendering window in around the edge of the screen\n"},
+ {"EnableEdgeShift", ( PyCFunction ) M_Render_EnableEdgeShift,
+ METH_VARARGS,
+ "(bool) - with the unified renderer the outlines are shifted a bit.\n"},
+ {"EnableEdgeAll", ( PyCFunction ) M_Render_EnableEdgeAll, METH_VARARGS,
+ "(bool) - also consider transparent faces for edge-rendering with the unified renderer\n"},
+ {NULL, NULL, 0, NULL}
};
-//------------------------------------BPy_RenderData methods/callbacks--------------------------------------------------
-static PyObject *RenderData_Render (BPy_RenderData *self);
-static PyObject *RenderData_RenderAnim (BPy_RenderData *self);
-static PyObject *RenderData_Play (BPy_RenderData *self);
-static PyObject *RenderData_SetRenderPath (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_GetRenderPath (BPy_RenderData *self);
-static PyObject *RenderData_SetBackbufPath (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_GetBackbufPath (BPy_RenderData *self);
-static PyObject *RenderData_EnableBackbuf (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetFtypePath (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_GetFtypePath (BPy_RenderData *self);
-static PyObject *RenderData_EnableExtensions (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableSequencer (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableRenderDaemon (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableToonShading (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EdgeIntensity (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetEdgeColor (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_GetEdgeColor(BPy_RenderData *self);
-static PyObject *RenderData_EdgeAntiShift (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableOversampling (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_SetOversamplingLevel (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableMotionBlur (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_MotionBlurLevel (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_PartsX (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_PartsY (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableSky (BPy_RenderData *self);
-static PyObject *RenderData_EnablePremultiply (BPy_RenderData *self);
-static PyObject *RenderData_EnableKey (BPy_RenderData *self);
-static PyObject *RenderData_EnableShadow (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnablePanorama (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableEnvironmentMap (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableRayTracing (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableRadiosityRender (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_SetRenderWinSize (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableFieldRendering (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableOddFieldFirst (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableFieldTimeDisable (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableGaussFilter (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EnableBorderRender (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_SetBorder(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableGammaCorrection (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_GaussFilterSize (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_StartFrame (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_CurrentFrame (BPy_RenderData*self, PyObject *args);
-static PyObject *RenderData_EndFrame (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_ImageSizeX (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_ImageSizeY (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_AspectRatioX (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_AspectRatioY (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetRenderer (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableCropping (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetImageType (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_Quality (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_FramesPerSec (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableGrayscale (BPy_RenderData *self);
-static PyObject *RenderData_EnableRGBColor (BPy_RenderData *self);
-static PyObject *RenderData_EnableRGBAColor (BPy_RenderData *self);
-static PyObject *RenderData_SizePreset(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableUnifiedRenderer (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetYafrayGIQuality (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SetYafrayGIMethod (BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIPower(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIDepth(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGICDepth(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableYafrayGICache(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableYafrayGIPhotons(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIPhotonCount(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIPhotonRadius(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIPhotonMixCount(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableYafrayGITunePhotons(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIShadowQuality(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIPixelsPerSample(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableYafrayGIGradient(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGIRefinement(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayRayBias(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayRayDepth(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayGamma(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayExposure(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_YafrayProcessorCount(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableGameFrameStretch(BPy_RenderData *self);
-static PyObject *RenderData_EnableGameFrameExpose(BPy_RenderData *self);
-static PyObject *RenderData_EnableGameFrameBars(BPy_RenderData *self);
-static PyObject *RenderData_SetGameFrameColor(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_GetGameFrameColor(BPy_RenderData *self);
-static PyObject *RenderData_GammaLevel(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_PostProcessAdd(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_PostProcessMultiply(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_PostProcessGamma(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_SGIMaxsize(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_EnableSGICosmo(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_OldMapValue(BPy_RenderData *self, PyObject *args);
-static PyObject *RenderData_NewMapValue(BPy_RenderData *self, PyObject *args);
-
-static void RenderData_dealloc (BPy_RenderData * self);
-static PyObject *RenderData_getAttr (BPy_RenderData * self, char *name);
-static PyObject *RenderData_repr (BPy_RenderData * self);
-//------------------------------------BPy_RenderData method def-----------------------------------------------------------
+//------------------------------------BPy_RenderData methods/callbacks--
+static PyObject *RenderData_Render( BPy_RenderData * self );
+static PyObject *RenderData_RenderAnim( BPy_RenderData * self );
+static PyObject *RenderData_Play( BPy_RenderData * self );
+static PyObject *RenderData_SetRenderPath( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GetRenderPath( BPy_RenderData * self );
+static PyObject *RenderData_SetBackbufPath( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GetBackbufPath( BPy_RenderData * self );
+static PyObject *RenderData_EnableBackbuf( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetFtypePath( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GetFtypePath( BPy_RenderData * self );
+static PyObject *RenderData_EnableExtensions( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableSequencer( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EdgeIntensity( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetEdgeColor( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GetEdgeColor( BPy_RenderData * self );
+static PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args );
+static PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args );
+static PyObject *RenderData_EnableSky( BPy_RenderData * self );
+static PyObject *RenderData_EnablePremultiply( BPy_RenderData * self );
+static PyObject *RenderData_EnableKey( BPy_RenderData * self );
+static PyObject *RenderData_EnableShadow( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnablePanorama( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableRayTracing( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetBorder( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GaussFilterSize( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_StartFrame( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_CurrentFrame( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args );
+static PyObject *RenderData_ImageSizeX( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_ImageSizeY( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_AspectRatioX( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_AspectRatioY( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetRenderer( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableCropping( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetImageType( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args );
+static PyObject *RenderData_FramesPerSec( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableGrayscale( BPy_RenderData * self );
+static PyObject *RenderData_EnableRGBColor( BPy_RenderData * self );
+static PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self );
+static PyObject *RenderData_SizePreset( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIPower( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableYafrayGIGradient( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayRayBias( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayGamma( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayExposure( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self );
+static PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self );
+static PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self );
+static PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self );
+static PyObject *RenderData_GammaLevel( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_PostProcessAdd( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_PostProcessGamma( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_SGIMaxsize( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_OldMapValue( BPy_RenderData * self,
+ PyObject * args );
+static PyObject *RenderData_NewMapValue( BPy_RenderData * self,
+ PyObject * args );
+
+static void RenderData_dealloc( BPy_RenderData * self );
+static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name );
+static PyObject *RenderData_repr( BPy_RenderData * self );
+//------------------------------------BPy_RenderData method def--------
static PyMethodDef BPy_RenderData_methods[] = {
- {"render",(PyCFunction)RenderData_Render, METH_NOARGS,
- "() - render the scene\n"},
- {"renderAnim",(PyCFunction)RenderData_RenderAnim, METH_NOARGS,
- "() - render a sequence from start frame to end frame\n"},
- {"play",(PyCFunction)RenderData_Play, METH_NOARGS,
- "() - play animation of rendered images/avi (searches Pics: field)\n"},
- {"setRenderPath",(PyCFunction)RenderData_SetRenderPath, METH_VARARGS,
- "(string) - get/set the path to output the rendered images to\n"},
- {"getRenderPath",(PyCFunction)RenderData_GetRenderPath, METH_NOARGS,
- "() - get the path to directory where rendered images will go\n"},
- {"setBackbufPath",(PyCFunction)RenderData_SetBackbufPath, METH_VARARGS,
- "(string) - get/set the path to a background image and load it\n"},
- {"getBackbufPath",(PyCFunction)RenderData_GetBackbufPath, METH_NOARGS,
- "() - get the path to background image file\n"},
- {"enableBackbuf",(PyCFunction)RenderData_EnableBackbuf, METH_VARARGS,
- "(bool) - enable/disable the backbuf image\n"},
- {"setFtypePath",(PyCFunction)RenderData_SetFtypePath, METH_VARARGS,
- "(string) - get/set the path to output the Ftype file\n"},
- {"getFtypePath",(PyCFunction)RenderData_GetFtypePath, METH_NOARGS,
- "() - get the path to Ftype file\n"},
- {"enableExtensions",(PyCFunction)RenderData_EnableExtensions, METH_VARARGS,
- "(bool) - enable/disable windows extensions for output files\n"},
- {"enableSequencer",(PyCFunction)RenderData_EnableSequencer, METH_VARARGS,
- "(bool) - enable/disable Do Sequence\n"},
- {"enableRenderDaemon",(PyCFunction)RenderData_EnableRenderDaemon, METH_VARARGS,
- "(bool) - enable/disable Scene daemon\n"},
- {"enableToonShading",(PyCFunction)RenderData_EnableToonShading, METH_VARARGS,
- "(bool) - enable/disable Edge rendering\n"},
- {"edgeIntensity",(PyCFunction)RenderData_EdgeIntensity, METH_VARARGS,
- "(int) - get/set edge intensity for toon shading\n"},
- {"setEdgeColor",(PyCFunction)RenderData_SetEdgeColor, METH_VARARGS,
- "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected.\n"},
- {"getEdgeColor",(PyCFunction)RenderData_GetEdgeColor, METH_VARARGS,
- "() - get the edge color for toon shading - Red,Green,Blue expected.\n"},
- {"edgeAntiShift",(PyCFunction)RenderData_EdgeAntiShift, METH_VARARGS,
- "(int) - with the unified renderer to reduce intensity on boundaries.\n"},
- {"enableOversampling",(PyCFunction)RenderData_EnableOversampling, METH_VARARGS,
- "(bool) - enable/disable oversampling (anit-aliasing).\n"},
- {"setOversamplingLevel",(PyCFunction)RenderData_SetOversamplingLevel, METH_VARARGS,
- "(enum) - get/set the level of oversampling (anit-aliasing).\n"},
- {"enableMotionBlur",(PyCFunction)RenderData_EnableMotionBlur, METH_VARARGS,
- "(bool) - enable/disable MBlur.\n"},
- {"motionBlurLevel",(PyCFunction)RenderData_MotionBlurLevel, METH_VARARGS,
- "(float) - get/set the length of shutter time for motion blur.\n"},
- {"partsX",(PyCFunction)RenderData_PartsX, METH_VARARGS,
- "(int) - get/set the number of parts to divide the render in the X direction\n"},
- {"partsY",(PyCFunction)RenderData_PartsY, METH_VARARGS,
- "(int) - get/set the number of parts to divide the render in the Y direction\n"},
- {"enableSky",(PyCFunction)RenderData_EnableSky, METH_NOARGS,
- "() - enable render background with sky\n"},
- {"enablePremultiply",(PyCFunction)RenderData_EnablePremultiply, METH_NOARGS,
- "() - enable premultiply alpha\n"},
- {"enableKey",(PyCFunction)RenderData_EnableKey, METH_NOARGS,
- "() - enable alpha and colour values remain unchanged\n"},
- {"enableShadow",(PyCFunction)RenderData_EnableShadow, METH_VARARGS,
- "(bool) - enable/disable shadow calculation\n"},
- {"enablePanorama",(PyCFunction)RenderData_EnablePanorama, METH_VARARGS,
- "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)\n"},
- {"enableEnvironmentMap",(PyCFunction)RenderData_EnableEnvironmentMap, METH_VARARGS,
- "(bool) - enable/disable environment map rendering\n"},
- {"enableRayTracing",(PyCFunction)RenderData_EnableRayTracing, METH_VARARGS,
- "(bool) - enable/disable ray tracing\n"},
- {"enableRadiosityRender",(PyCFunction)RenderData_EnableRadiosityRender, METH_VARARGS,
- "(bool) - enable/disable radiosity rendering\n"},
- {"setRenderWinSize",(PyCFunction)RenderData_SetRenderWinSize, METH_VARARGS,
- "(enum) - get/set the size of the render window\n"},
- {"enableFieldRendering",(PyCFunction)RenderData_EnableFieldRendering, METH_VARARGS,
- "(bool) - enable/disable field rendering\n"},
- {"enableOddFieldFirst",(PyCFunction)RenderData_EnableOddFieldFirst, METH_VARARGS,
- "(bool) - enable/disable Odd field first rendering (Default: Even field)\n"},
- {"enableFieldTimeDisable",(PyCFunction)RenderData_EnableFieldTimeDisable, METH_VARARGS,
- "(bool) - enable/disable time difference in field calculations\n"},
- {"enableGaussFilter",(PyCFunction)RenderData_EnableGaussFilter, METH_VARARGS,
- "(bool) - enable/disable Gauss sampling filter for antialiasing\n"},
- {"enableBorderRender",(PyCFunction)RenderData_EnableBorderRender, METH_VARARGS,
- "(bool) - enable/disable small cut-out rendering\n"},
- {"setBorder",(PyCFunction)RenderData_SetBorder, METH_VARARGS,
- "(f,f,f,f) - set the border for border rendering\n"},
- {"enableGammaCorrection",(PyCFunction)RenderData_EnableGammaCorrection, METH_VARARGS,
- "(bool) - enable/disable gamma correction\n"},
- {"gaussFilterSize",(PyCFunction)RenderData_GaussFilterSize, METH_VARARGS,
- "(float) - get/sets the Gauss filter size\n"},
- {"startFrame",(PyCFunction)RenderData_StartFrame, METH_VARARGS,
- "(int) - get/set the starting frame for rendering\n"},
- {"currentFrame",(PyCFunction)RenderData_CurrentFrame, METH_VARARGS,
- "(int) - get/set the current frame for rendering\n"},
- {"endFrame",(PyCFunction)RenderData_EndFrame, METH_VARARGS,
- "(int) - get/set the ending frame for rendering\n"},
- {"imageSizeX",(PyCFunction)RenderData_ImageSizeX, METH_VARARGS,
- "(int) - get/set the image width in pixels\n"},
- {"imageSizeY",(PyCFunction)RenderData_ImageSizeY, METH_VARARGS,
- "(int) - get/set the image height in pixels\n"},
- {"aspectRatioX",(PyCFunction)RenderData_AspectRatioX, METH_VARARGS,
- "(int) - get/set the horizontal aspect ratio\n"},
- {"aspectRatioY",(PyCFunction)RenderData_AspectRatioY, METH_VARARGS,
- "(int) - get/set the vertical aspect ratio\n"},
- {"setRenderer",(PyCFunction)RenderData_SetRenderer, METH_VARARGS,
- "(enum) - get/set which renderer to render the output\n"},
- {"enableCropping",(PyCFunction)RenderData_EnableCropping, METH_VARARGS,
- "(bool) - enable/disable exclusion of border rendering from total image\n"},
- {"setImageType",(PyCFunction)RenderData_SetImageType, METH_VARARGS,
- "(enum) - get/set the type of image to output from the render\n"},
- {"quality",(PyCFunction)RenderData_Quality, METH_VARARGS,
- "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies\n"},
- {"framesPerSec",(PyCFunction)RenderData_FramesPerSec, METH_VARARGS,
- "(int) - get/set frames per second\n"},
- {"enableGrayscale",(PyCFunction)RenderData_EnableGrayscale, METH_NOARGS,
- "() - images are saved with BW (grayscale) data\n"},
- {"enableRGBColor",(PyCFunction)RenderData_EnableRGBColor, METH_NOARGS,
- "() - images are saved with RGB (color) data\n"},
- {"enableRGBAColor",(PyCFunction)RenderData_EnableRGBAColor, METH_NOARGS,
- "() - images are saved with RGB and Alpha data (if supported)\n"},
- {"sizePreset",(PyCFunction)RenderData_SizePreset, METH_VARARGS,
- "(enum) - get/set the render to one of a few preget/sets\n"},
- {"enableUnifiedRenderer",(PyCFunction)RenderData_EnableUnifiedRenderer, METH_VARARGS,
- "(bool) - use the unified renderer\n"},
- {"setYafrayGIQuality",(PyCFunction)RenderData_SetYafrayGIQuality, METH_VARARGS,
- "(enum) - get/set yafray global Illumination quality\n"},
- {"setYafrayGIMethod",(PyCFunction)RenderData_SetYafrayGIMethod, METH_VARARGS,
- "(enum) - get/set yafray global Illumination method\n"},
- {"yafrayGIPower",(PyCFunction)RenderData_YafrayGIPower, METH_VARARGS,
- "(float) - get/set GI lighting intensity scale\n"},
- {"yafrayGIDepth",(PyCFunction)RenderData_YafrayGIDepth, METH_VARARGS,
- "(int) - get/set number of bounces of the indirect light\n"},
- {"yafrayGICDepth",(PyCFunction)RenderData_YafrayGICDepth, METH_VARARGS,
- "(int) - get/set number of bounces inside objects (for caustics)\n"},
- {"enableYafrayGICache",(PyCFunction)RenderData_EnableYafrayGICache, METH_VARARGS,
- "(bool) - enable/disable cache irradiance samples (faster)\n"},
- {"enableYafrayGIPhotons",(PyCFunction)RenderData_EnableYafrayGIPhotons, METH_VARARGS,
- "(bool) - enable/disable use global photons to help in GI\n"},
- {"yafrayGIPhotonCount",(PyCFunction)RenderData_YafrayGIPhotonCount, METH_VARARGS,
- "(int) - get/set number of photons to shoot\n"},
- {"yafrayGIPhotonRadius",(PyCFunction)RenderData_YafrayGIPhotonRadius, METH_VARARGS,
- "(float) - get/set radius to search for photons to mix (blur)\n"},
- {"yafrayGIPhotonMixCount",(PyCFunction)RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
- "(int) - get/set number of photons to shoot\n"},
- {"enableYafrayGITunePhotons",(PyCFunction)RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
- "(bool) - enable/disable show the photonmap directly in the render for tuning\n"},
- {"yafrayGIShadowQuality",(PyCFunction)RenderData_YafrayGIShadowQuality, METH_VARARGS,
- "(float) - get/set the shadow quality, keep it under 0.95\n"},
- {"yafrayGIPixelsPerSample",(PyCFunction)RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
- "(int) - get/set maximum number of pixels without samples, the lower the better and slower\n"},
- {"enableYafrayGIGradient",(PyCFunction)RenderData_EnableYafrayGIGradient, METH_VARARGS,
- "(bool) - enable/disable try to smooth lighting using a gradient\n"},
- {"yafrayGIRefinement",(PyCFunction)RenderData_YafrayGIRefinement, METH_VARARGS,
- "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement\n"},
- {"yafrayRayBias",(PyCFunction)RenderData_YafrayRayBias, METH_VARARGS,
- "(float) - get/set shadow ray bias to avoid self shadowing\n"},
- {"yafrayRayDepth",(PyCFunction)RenderData_YafrayRayDepth, METH_VARARGS,
- "(int) - get/set maximum render ray depth from the camera\n"},
- {"yafrayGamma",(PyCFunction)RenderData_YafrayGamma, METH_VARARGS,
- "(float) - get/set gamma correction, 1 is off\n"},
- {"yafrayExposure",(PyCFunction)RenderData_YafrayExposure, METH_VARARGS,
- "(float) - get/set exposure adjustment, 0 is off\n"},
- {"yafrayProcessorCount",(PyCFunction)RenderData_YafrayProcessorCount, METH_VARARGS,
- "(int) - get/set number of processors to use\n"},
- {"enableGameFrameStretch",(PyCFunction)RenderData_EnableGameFrameStretch, METH_NOARGS,
- "(l) - enble stretch or squeeze the viewport to fill the display window\n"},
- {"enableGameFrameExpose",(PyCFunction)RenderData_EnableGameFrameExpose, METH_NOARGS,
- "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically\n"},
- {"enableGameFrameBars",(PyCFunction)RenderData_EnableGameFrameBars, METH_NOARGS,
- "() - enable show the entire viewport in the display window, using bar horizontally or vertically\n"},
- {"setGameFrameColor",(PyCFunction)RenderData_SetGameFrameColor, METH_VARARGS,
- "(f,f,f) - set the red, green, blue component of the bars\n"},
- {"getGameFrameColor",(PyCFunction)RenderData_GetGameFrameColor, METH_VARARGS,
- "() - get the red, green, blue component of the bars\n"},
- {"gammaLevel",(PyCFunction)RenderData_GammaLevel, METH_VARARGS,
- "(float) - get/set the gamma value for blending oversampled images (1.0 = no correction\n"},
- {"postProcessAdd",(PyCFunction)RenderData_PostProcessAdd, METH_VARARGS,
- "(float) - get/set post processing add\n"},
- {"postProcessMultiply",(PyCFunction)RenderData_PostProcessMultiply, METH_VARARGS,
- "(float) - get/set post processing multiply\n"},
- {"postProcessGamma",(PyCFunction)RenderData_PostProcessGamma, METH_VARARGS,
- "(float) - get/set post processing gamma\n"},
- {"SGIMaxsize",(PyCFunction)RenderData_SGIMaxsize, METH_VARARGS,
- "(int) - get/set maximum size per frame to save in an SGI movie\n"},
- {"enableSGICosmo",(PyCFunction)RenderData_EnableSGICosmo, METH_VARARGS,
- "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware\n"},
- {"oldMapValue",(PyCFunction)RenderData_OldMapValue, METH_VARARGS,
- "(int) - get/set specify old map value in frames\n"},
- {"newMapValue",(PyCFunction)RenderData_NewMapValue, METH_VARARGS,
- "(int) - get/set specify new map value in frames\n"},
- {NULL, NULL, 0, NULL}
+ {"render", ( PyCFunction ) RenderData_Render, METH_NOARGS,
+ "() - render the scene\n"},
+ {"renderAnim", ( PyCFunction ) RenderData_RenderAnim, METH_NOARGS,
+ "() - render a sequence from start frame to end frame\n"},
+ {"play", ( PyCFunction ) RenderData_Play, METH_NOARGS,
+ "() - play animation of rendered images/avi (searches Pics: field)\n"},
+ {"setRenderPath", ( PyCFunction ) RenderData_SetRenderPath,
+ METH_VARARGS,
+ "(string) - get/set the path to output the rendered images to\n"},
+ {"getRenderPath", ( PyCFunction ) RenderData_GetRenderPath,
+ METH_NOARGS,
+ "() - get the path to directory where rendered images will go\n"},
+ {"setBackbufPath", ( PyCFunction ) RenderData_SetBackbufPath,
+ METH_VARARGS,
+ "(string) - get/set the path to a background image and load it\n"},
+ {"getBackbufPath", ( PyCFunction ) RenderData_GetBackbufPath,
+ METH_NOARGS,
+ "() - get the path to background image file\n"},
+ {"enableBackbuf", ( PyCFunction ) RenderData_EnableBackbuf,
+ METH_VARARGS,
+ "(bool) - enable/disable the backbuf image\n"},
+ {"setFtypePath", ( PyCFunction ) RenderData_SetFtypePath, METH_VARARGS,
+ "(string) - get/set the path to output the Ftype file\n"},
+ {"getFtypePath", ( PyCFunction ) RenderData_GetFtypePath, METH_NOARGS,
+ "() - get the path to Ftype file\n"},
+ {"enableExtensions", ( PyCFunction ) RenderData_EnableExtensions,
+ METH_VARARGS,
+ "(bool) - enable/disable windows extensions for output files\n"},
+ {"enableSequencer", ( PyCFunction ) RenderData_EnableSequencer,
+ METH_VARARGS,
+ "(bool) - enable/disable Do Sequence\n"},
+ {"enableRenderDaemon", ( PyCFunction ) RenderData_EnableRenderDaemon,
+ METH_VARARGS,
+ "(bool) - enable/disable Scene daemon\n"},
+ {"enableToonShading", ( PyCFunction ) RenderData_EnableToonShading,
+ METH_VARARGS,
+ "(bool) - enable/disable Edge rendering\n"},
+ {"edgeIntensity", ( PyCFunction ) RenderData_EdgeIntensity,
+ METH_VARARGS,
+ "(int) - get/set edge intensity for toon shading\n"},
+ {"setEdgeColor", ( PyCFunction ) RenderData_SetEdgeColor, METH_VARARGS,
+ "(f,f,f) - set the edge color for toon shading - Red,Green,Blue expected.\n"},
+ {"getEdgeColor", ( PyCFunction ) RenderData_GetEdgeColor, METH_VARARGS,
+ "() - get the edge color for toon shading - Red,Green,Blue expected.\n"},
+ {"edgeAntiShift", ( PyCFunction ) RenderData_EdgeAntiShift,
+ METH_VARARGS,
+ "(int) - with the unified renderer to reduce intensity on boundaries.\n"},
+ {"enableOversampling", ( PyCFunction ) RenderData_EnableOversampling,
+ METH_VARARGS,
+ "(bool) - enable/disable oversampling (anit-aliasing).\n"},
+ {"setOversamplingLevel",
+ ( PyCFunction ) RenderData_SetOversamplingLevel, METH_VARARGS,
+ "(enum) - get/set the level of oversampling (anit-aliasing).\n"},
+ {"enableMotionBlur", ( PyCFunction ) RenderData_EnableMotionBlur,
+ METH_VARARGS,
+ "(bool) - enable/disable MBlur.\n"},
+ {"motionBlurLevel", ( PyCFunction ) RenderData_MotionBlurLevel,
+ METH_VARARGS,
+ "(float) - get/set the length of shutter time for motion blur.\n"},
+ {"partsX", ( PyCFunction ) RenderData_PartsX, METH_VARARGS,
+ "(int) - get/set the number of parts to divide the render in the X direction\n"},
+ {"partsY", ( PyCFunction ) RenderData_PartsY, METH_VARARGS,
+ "(int) - get/set the number of parts to divide the render in the Y direction\n"},
+ {"enableSky", ( PyCFunction ) RenderData_EnableSky, METH_NOARGS,
+ "() - enable render background with sky\n"},
+ {"enablePremultiply", ( PyCFunction ) RenderData_EnablePremultiply,
+ METH_NOARGS,
+ "() - enable premultiply alpha\n"},
+ {"enableKey", ( PyCFunction ) RenderData_EnableKey, METH_NOARGS,
+ "() - enable alpha and colour values remain unchanged\n"},
+ {"enableShadow", ( PyCFunction ) RenderData_EnableShadow, METH_VARARGS,
+ "(bool) - enable/disable shadow calculation\n"},
+ {"enablePanorama", ( PyCFunction ) RenderData_EnablePanorama,
+ METH_VARARGS,
+ "(bool) - enable/disable panorama rendering (output width is multiplied by Xparts)\n"},
+ {"enableEnvironmentMap",
+ ( PyCFunction ) RenderData_EnableEnvironmentMap, METH_VARARGS,
+ "(bool) - enable/disable environment map rendering\n"},
+ {"enableRayTracing", ( PyCFunction ) RenderData_EnableRayTracing,
+ METH_VARARGS,
+ "(bool) - enable/disable ray tracing\n"},
+ {"enableRadiosityRender",
+ ( PyCFunction ) RenderData_EnableRadiosityRender, METH_VARARGS,
+ "(bool) - enable/disable radiosity rendering\n"},
+ {"setRenderWinSize", ( PyCFunction ) RenderData_SetRenderWinSize,
+ METH_VARARGS,
+ "(enum) - get/set the size of the render window\n"},
+ {"enableFieldRendering",
+ ( PyCFunction ) RenderData_EnableFieldRendering, METH_VARARGS,
+ "(bool) - enable/disable field rendering\n"},
+ {"enableOddFieldFirst", ( PyCFunction ) RenderData_EnableOddFieldFirst,
+ METH_VARARGS,
+ "(bool) - enable/disable Odd field first rendering (Default: Even field)\n"},
+ {"enableFieldTimeDisable",
+ ( PyCFunction ) RenderData_EnableFieldTimeDisable, METH_VARARGS,
+ "(bool) - enable/disable time difference in field calculations\n"},
+ {"enableGaussFilter", ( PyCFunction ) RenderData_EnableGaussFilter,
+ METH_VARARGS,
+ "(bool) - enable/disable Gauss sampling filter for antialiasing\n"},
+ {"enableBorderRender", ( PyCFunction ) RenderData_EnableBorderRender,
+ METH_VARARGS,
+ "(bool) - enable/disable small cut-out rendering\n"},
+ {"setBorder", ( PyCFunction ) RenderData_SetBorder, METH_VARARGS,
+ "(f,f,f,f) - set the border for border rendering\n"},
+ {"enableGammaCorrection",
+ ( PyCFunction ) RenderData_EnableGammaCorrection, METH_VARARGS,
+ "(bool) - enable/disable gamma correction\n"},
+ {"gaussFilterSize", ( PyCFunction ) RenderData_GaussFilterSize,
+ METH_VARARGS,
+ "(float) - get/sets the Gauss filter size\n"},
+ {"startFrame", ( PyCFunction ) RenderData_StartFrame, METH_VARARGS,
+ "(int) - get/set the starting frame for rendering\n"},
+ {"currentFrame", ( PyCFunction ) RenderData_CurrentFrame, METH_VARARGS,
+ "(int) - get/set the current frame for rendering\n"},
+ {"endFrame", ( PyCFunction ) RenderData_EndFrame, METH_VARARGS,
+ "(int) - get/set the ending frame for rendering\n"},
+ {"imageSizeX", ( PyCFunction ) RenderData_ImageSizeX, METH_VARARGS,
+ "(int) - get/set the image width in pixels\n"},
+ {"imageSizeY", ( PyCFunction ) RenderData_ImageSizeY, METH_VARARGS,
+ "(int) - get/set the image height in pixels\n"},
+ {"aspectRatioX", ( PyCFunction ) RenderData_AspectRatioX, METH_VARARGS,
+ "(int) - get/set the horizontal aspect ratio\n"},
+ {"aspectRatioY", ( PyCFunction ) RenderData_AspectRatioY, METH_VARARGS,
+ "(int) - get/set the vertical aspect ratio\n"},
+ {"setRenderer", ( PyCFunction ) RenderData_SetRenderer, METH_VARARGS,
+ "(enum) - get/set which renderer to render the output\n"},
+ {"enableCropping", ( PyCFunction ) RenderData_EnableCropping,
+ METH_VARARGS,
+ "(bool) - enable/disable exclusion of border rendering from total image\n"},
+ {"setImageType", ( PyCFunction ) RenderData_SetImageType, METH_VARARGS,
+ "(enum) - get/set the type of image to output from the render\n"},
+ {"quality", ( PyCFunction ) RenderData_Quality, METH_VARARGS,
+ "(int) - get/set quality get/setting for JPEG images, AVI Jpeg and SGI movies\n"},
+ {"framesPerSec", ( PyCFunction ) RenderData_FramesPerSec, METH_VARARGS,
+ "(int) - get/set frames per second\n"},
+ {"enableGrayscale", ( PyCFunction ) RenderData_EnableGrayscale,
+ METH_NOARGS,
+ "() - images are saved with BW (grayscale) data\n"},
+ {"enableRGBColor", ( PyCFunction ) RenderData_EnableRGBColor,
+ METH_NOARGS,
+ "() - images are saved with RGB (color) data\n"},
+ {"enableRGBAColor", ( PyCFunction ) RenderData_EnableRGBAColor,
+ METH_NOARGS,
+ "() - images are saved with RGB and Alpha data (if supported)\n"},
+ {"sizePreset", ( PyCFunction ) RenderData_SizePreset, METH_VARARGS,
+ "(enum) - get/set the render to one of a few preget/sets\n"},
+ {"enableUnifiedRenderer",
+ ( PyCFunction ) RenderData_EnableUnifiedRenderer, METH_VARARGS,
+ "(bool) - use the unified renderer\n"},
+ {"setYafrayGIQuality", ( PyCFunction ) RenderData_SetYafrayGIQuality,
+ METH_VARARGS,
+ "(enum) - get/set yafray global Illumination quality\n"},
+ {"setYafrayGIMethod", ( PyCFunction ) RenderData_SetYafrayGIMethod,
+ METH_VARARGS,
+ "(enum) - get/set yafray global Illumination method\n"},
+ {"yafrayGIPower", ( PyCFunction ) RenderData_YafrayGIPower,
+ METH_VARARGS,
+ "(float) - get/set GI lighting intensity scale\n"},
+ {"yafrayGIDepth", ( PyCFunction ) RenderData_YafrayGIDepth,
+ METH_VARARGS,
+ "(int) - get/set number of bounces of the indirect light\n"},
+ {"yafrayGICDepth", ( PyCFunction ) RenderData_YafrayGICDepth,
+ METH_VARARGS,
+ "(int) - get/set number of bounces inside objects (for caustics)\n"},
+ {"enableYafrayGICache", ( PyCFunction ) RenderData_EnableYafrayGICache,
+ METH_VARARGS,
+ "(bool) - enable/disable cache irradiance samples (faster)\n"},
+ {"enableYafrayGIPhotons",
+ ( PyCFunction ) RenderData_EnableYafrayGIPhotons, METH_VARARGS,
+ "(bool) - enable/disable use global photons to help in GI\n"},
+ {"yafrayGIPhotonCount", ( PyCFunction ) RenderData_YafrayGIPhotonCount,
+ METH_VARARGS,
+ "(int) - get/set number of photons to shoot\n"},
+ {"yafrayGIPhotonRadius",
+ ( PyCFunction ) RenderData_YafrayGIPhotonRadius, METH_VARARGS,
+ "(float) - get/set radius to search for photons to mix (blur)\n"},
+ {"yafrayGIPhotonMixCount",
+ ( PyCFunction ) RenderData_YafrayGIPhotonMixCount, METH_VARARGS,
+ "(int) - get/set number of photons to shoot\n"},
+ {"enableYafrayGITunePhotons",
+ ( PyCFunction ) RenderData_EnableYafrayGITunePhotons, METH_VARARGS,
+ "(bool) - enable/disable show the photonmap directly in the render for tuning\n"},
+ {"yafrayGIShadowQuality",
+ ( PyCFunction ) RenderData_YafrayGIShadowQuality, METH_VARARGS,
+ "(float) - get/set the shadow quality, keep it under 0.95\n"},
+ {"yafrayGIPixelsPerSample",
+ ( PyCFunction ) RenderData_YafrayGIPixelsPerSample, METH_VARARGS,
+ "(int) - get/set maximum number of pixels without samples, the lower the better and slower\n"},
+ {"enableYafrayGIGradient",
+ ( PyCFunction ) RenderData_EnableYafrayGIGradient, METH_VARARGS,
+ "(bool) - enable/disable try to smooth lighting using a gradient\n"},
+ {"yafrayGIRefinement", ( PyCFunction ) RenderData_YafrayGIRefinement,
+ METH_VARARGS,
+ "(float) - get/setthreshold to refine shadows EXPERIMENTAL. 1 = no refinement\n"},
+ {"yafrayRayBias", ( PyCFunction ) RenderData_YafrayRayBias,
+ METH_VARARGS,
+ "(float) - get/set shadow ray bias to avoid self shadowing\n"},
+ {"yafrayRayDepth", ( PyCFunction ) RenderData_YafrayRayDepth,
+ METH_VARARGS,
+ "(int) - get/set maximum render ray depth from the camera\n"},
+ {"yafrayGamma", ( PyCFunction ) RenderData_YafrayGamma, METH_VARARGS,
+ "(float) - get/set gamma correction, 1 is off\n"},
+ {"yafrayExposure", ( PyCFunction ) RenderData_YafrayExposure,
+ METH_VARARGS,
+ "(float) - get/set exposure adjustment, 0 is off\n"},
+ {"yafrayProcessorCount",
+ ( PyCFunction ) RenderData_YafrayProcessorCount, METH_VARARGS,
+ "(int) - get/set number of processors to use\n"},
+ {"enableGameFrameStretch",
+ ( PyCFunction ) RenderData_EnableGameFrameStretch, METH_NOARGS,
+ "(l) - enble stretch or squeeze the viewport to fill the display window\n"},
+ {"enableGameFrameExpose",
+ ( PyCFunction ) RenderData_EnableGameFrameExpose, METH_NOARGS,
+ "(l) - enable show the entire viewport in the display window, viewing more horizontally or vertically\n"},
+ {"enableGameFrameBars", ( PyCFunction ) RenderData_EnableGameFrameBars,
+ METH_NOARGS,
+ "() - enable show the entire viewport in the display window, using bar horizontally or vertically\n"},
+ {"setGameFrameColor", ( PyCFunction ) RenderData_SetGameFrameColor,
+ METH_VARARGS,
+ "(f,f,f) - set the red, green, blue component of the bars\n"},
+ {"getGameFrameColor", ( PyCFunction ) RenderData_GetGameFrameColor,
+ METH_VARARGS,
+ "() - get the red, green, blue component of the bars\n"},
+ {"gammaLevel", ( PyCFunction ) RenderData_GammaLevel, METH_VARARGS,
+ "(float) - get/set the gamma value for blending oversampled images (1.0 = no correction\n"},
+ {"postProcessAdd", ( PyCFunction ) RenderData_PostProcessAdd,
+ METH_VARARGS,
+ "(float) - get/set post processing add\n"},
+ {"postProcessMultiply", ( PyCFunction ) RenderData_PostProcessMultiply,
+ METH_VARARGS,
+ "(float) - get/set post processing multiply\n"},
+ {"postProcessGamma", ( PyCFunction ) RenderData_PostProcessGamma,
+ METH_VARARGS,
+ "(float) - get/set post processing gamma\n"},
+ {"SGIMaxsize", ( PyCFunction ) RenderData_SGIMaxsize, METH_VARARGS,
+ "(int) - get/set maximum size per frame to save in an SGI movie\n"},
+ {"enableSGICosmo", ( PyCFunction ) RenderData_EnableSGICosmo,
+ METH_VARARGS,
+ "(bool) - enable/disable attempt to save SGI movies using Cosmo hardware\n"},
+ {"oldMapValue", ( PyCFunction ) RenderData_OldMapValue, METH_VARARGS,
+ "(int) - get/set specify old map value in frames\n"},
+ {"newMapValue", ( PyCFunction ) RenderData_NewMapValue, METH_VARARGS,
+ "(int) - get/set specify new map value in frames\n"},
+ {NULL, NULL, 0, NULL}
};
-//------------------------------------BPy_RenderData Type defintion--------------------------------------------------------
+//------------------------------------BPy_RenderData Type defintion------
PyTypeObject RenderData_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender RenderData", /* tp_name */
- sizeof (BPy_RenderData), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) RenderData_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) RenderData_getAttr, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc) RenderData_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_RenderData_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
+ "Blender RenderData", /* tp_name */
+ sizeof( BPy_RenderData ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) RenderData_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) RenderData_getAttr, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) RenderData_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_RenderData_methods, /* tp_methods */
+ 0, /* tp_members */
};
-//---------------------------------------------------Render Module Init--------------------------------------------------
-PyObject *
-Render_Init (void)
-{
- PyObject *submodule;
-
- RenderData_Type.ob_type = &PyType_Type;
-
- submodule = Py_InitModule3 ("Blender.Scene.Render",
- M_Render_methods, M_Render_doc);
-
- PyModule_AddIntConstant(submodule, "INTERNAL", R_INTERN);
- PyModule_AddIntConstant(submodule, "YAFRAY", R_YAFRAY);
- PyModule_AddIntConstant(submodule, "AVIRAW", R_AVIRAW);
- PyModule_AddIntConstant(submodule, "AVIJPEG", R_AVIJPEG);
- PyModule_AddIntConstant(submodule, "AVICODEC", R_AVICODEC);
- PyModule_AddIntConstant(submodule, "QUICKTIME", R_QUICKTIME);
- PyModule_AddIntConstant(submodule, "TARGA", R_TARGA);
- PyModule_AddIntConstant(submodule, "RAWTGA", R_RAWTGA);
- PyModule_AddIntConstant(submodule, "PNG", R_PNG);
- PyModule_AddIntConstant(submodule, "BMP", R_BMP);
- PyModule_AddIntConstant(submodule, "JPEG", R_JPEG90);
- PyModule_AddIntConstant(submodule, "HAMX", R_HAMX);
- PyModule_AddIntConstant(submodule, "IRIS", R_IRIS);
- PyModule_AddIntConstant(submodule, "IRISZ", R_IRIZ);
- PyModule_AddIntConstant(submodule, "FTYPE", R_FTYPE);
- PyModule_AddIntConstant(submodule, "PAL", B_PR_PAL);
- PyModule_AddIntConstant(submodule, "NTSC", B_PR_NTSC);
- PyModule_AddIntConstant(submodule, "DEFAULT", B_PR_PRESET);
- PyModule_AddIntConstant(submodule, "PREVIEW", B_PR_PRV);
- PyModule_AddIntConstant(submodule, "PC", B_PR_PC);
- PyModule_AddIntConstant(submodule, "PAL169", B_PR_PAL169);
- PyModule_AddIntConstant(submodule, "PANO", B_PR_PANO);
- PyModule_AddIntConstant(submodule, "FULL", B_PR_FULL);
- PyModule_AddIntConstant(submodule, "NONE", PY_NONE);
- PyModule_AddIntConstant(submodule, "LOW", PY_LOW);
- PyModule_AddIntConstant(submodule, "MEDIUM", PY_MEDIUM);
- PyModule_AddIntConstant(submodule, "HIGH", PY_HIGH);
- PyModule_AddIntConstant(submodule, "HIGHER", PY_HIGHER);
- PyModule_AddIntConstant(submodule, "BEST", PY_BEST);
- PyModule_AddIntConstant(submodule, "SKYDOME", PY_SKYDOME);
- PyModule_AddIntConstant(submodule, "GIFULL", PY_FULL);
-
- return (submodule);
-}
-//-----------------------------------BPy_RenderData Internal Protocols---------------------------------------------------
-//-------------------------------------------------dealloc-----------------------------------------------------------------
-static void
-RenderData_dealloc (BPy_RenderData * self)
-{
- PyObject_DEL (self);
-}
-//-------------------------------------------------getAttr-------------------------------------------------------------------
-static PyObject *
-RenderData_getAttr (BPy_RenderData * self, char *name)
-{
- return Py_FindMethod (BPy_RenderData_methods, (PyObject *) self, name);
-}
-//-------------------------------------------------repr---------------------------------------------------------------------
-static PyObject *
-RenderData_repr (BPy_RenderData * self)
-{
- if (self->renderContext)
- return PyString_FromFormat ("[RenderData \"%s\"]", self->scene->id.name + 2);
- else
- return PyString_FromString ("NULL");
-}
-//------------------------------BPy_RenderData Callbacks--------------------------------------------------------------
-//--------------------------------------CreatePyObject-----------------------------------------------------------------------
-PyObject *
-RenderData_CreatePyObject (struct Scene * scene)
-{
- BPy_RenderData *py_renderdata;
-
- py_renderdata = (BPy_RenderData *) PyObject_NEW (BPy_RenderData, &RenderData_Type);
-
- if (py_renderdata == NULL) {
- return (NULL);
- }
- py_renderdata->renderContext = &scene->r;
- py_renderdata->scene = scene;
-
- return ((PyObject *) py_renderdata);
-}
-//------------------------------CheckPyObject--------------------------------------------------------------------------------
-int
-RenderData_CheckPyObject (PyObject * py_obj)
-{
- return (py_obj->ob_type == &RenderData_Type);
-}
-//------------------------------------BitToggleInt---------------------------------------------------------------------------------
-static PyObject *M_Render_BitToggleInt(PyObject *args, int setting, int *structure)
+//---------------------------------------------------Render Module Init--
+PyObject *Render_Init( void )
+{
+ PyObject *submodule;
+
+ RenderData_Type.ob_type = &PyType_Type;
+
+ submodule = Py_InitModule3( "Blender.Scene.Render",
+ M_Render_methods, M_Render_doc );
+
+ PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
+ PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
+ PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
+ PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
+ PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
+ PyModule_AddIntConstant( submodule, "QUICKTIME", R_QUICKTIME );
+ PyModule_AddIntConstant( submodule, "TARGA", R_TARGA );
+ PyModule_AddIntConstant( submodule, "RAWTGA", R_RAWTGA );
+ PyModule_AddIntConstant( submodule, "PNG", R_PNG );
+ PyModule_AddIntConstant( submodule, "BMP", R_BMP );
+ PyModule_AddIntConstant( submodule, "JPEG", R_JPEG90 );
+ PyModule_AddIntConstant( submodule, "HAMX", R_HAMX );
+ PyModule_AddIntConstant( submodule, "IRIS", R_IRIS );
+ PyModule_AddIntConstant( submodule, "IRISZ", R_IRIZ );
+ PyModule_AddIntConstant( submodule, "FTYPE", R_FTYPE );
+ PyModule_AddIntConstant( submodule, "PAL", B_PR_PAL );
+ PyModule_AddIntConstant( submodule, "NTSC", B_PR_NTSC );
+ PyModule_AddIntConstant( submodule, "DEFAULT", B_PR_PRESET );
+ PyModule_AddIntConstant( submodule, "PREVIEW", B_PR_PRV );
+ PyModule_AddIntConstant( submodule, "PC", B_PR_PC );
+ PyModule_AddIntConstant( submodule, "PAL169", B_PR_PAL169 );
+ PyModule_AddIntConstant( submodule, "PANO", B_PR_PANO );
+ PyModule_AddIntConstant( submodule, "FULL", B_PR_FULL );
+ PyModule_AddIntConstant( submodule, "NONE", PY_NONE );
+ PyModule_AddIntConstant( submodule, "LOW", PY_LOW );
+ PyModule_AddIntConstant( submodule, "MEDIUM", PY_MEDIUM );
+ PyModule_AddIntConstant( submodule, "HIGH", PY_HIGH );
+ PyModule_AddIntConstant( submodule, "HIGHER", PY_HIGHER );
+ PyModule_AddIntConstant( submodule, "BEST", PY_BEST );
+ PyModule_AddIntConstant( submodule, "SKYDOME", PY_SKYDOME );
+ PyModule_AddIntConstant( submodule, "GIFULL", PY_FULL );
+
+ return ( submodule );
+}
+
+//-----------------------------------BPy_RenderData Internal Protocols---
+//-------------------------------------------------dealloc---------------
+static void RenderData_dealloc( BPy_RenderData * self )
+{
+ PyObject_DEL( self );
+}
+
+//-------------------------------------------------getAttr---------------
+static PyObject *RenderData_getAttr( BPy_RenderData * self, char *name )
+{
+ return Py_FindMethod( BPy_RenderData_methods, ( PyObject * ) self,
+ name );
+}
+
+//-------------------------------------------------repr------------------
+static PyObject *RenderData_repr( BPy_RenderData * self )
+{
+ if( self->renderContext )
+ return PyString_FromFormat( "[RenderData \"%s\"]",
+ self->scene->id.name + 2 );
+ else
+ return PyString_FromString( "NULL" );
+}
+
+//------------------------------BPy_RenderData Callbacks-----------------
+//--------------------------------------CreatePyObject-------------------
+PyObject *RenderData_CreatePyObject( struct Scene * scene )
+{
+ BPy_RenderData *py_renderdata;
+
+ py_renderdata =
+ ( BPy_RenderData * ) PyObject_NEW( BPy_RenderData,
+ &RenderData_Type );
+
+ if( py_renderdata == NULL ) {
+ return ( NULL );
+ }
+ py_renderdata->renderContext = &scene->r;
+ py_renderdata->scene = scene;
+
+ return ( ( PyObject * ) py_renderdata );
+}
+
+//------------------------------CheckPyObject----------------------------
+int RenderData_CheckPyObject( PyObject * py_obj )
+{
+ return ( py_obj->ob_type == &RenderData_Type );
+}
+
+//------------------------------------BitToggleInt-----------------------
+static PyObject *M_Render_BitToggleInt( PyObject * args, int setting,
+ int *structure )
{
int flag;
- if (!PyArg_ParseTuple(args, "i", &flag))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected TRUE or FALSE (1 or 0)"));
+ if( !PyArg_ParseTuple( args, "i", &flag ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected TRUE or FALSE (1 or 0)" ) );
- if(flag < 0 || flag > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected TRUE or FALSE (1 or 0)"));
+ if( flag < 0 || flag > 1 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected TRUE or FALSE (1 or 0)" ) );
- if(flag)
+ if( flag )
*structure |= setting;
else
*structure &= ~setting;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------BitToggleShort---------------------------------------------------------------------------------
-static PyObject *M_Render_BitToggleShort(PyObject *args, short setting, short *structure)
+
+//------------------------------------BitToggleShort---------------------
+static PyObject *M_Render_BitToggleShort( PyObject * args, short setting,
+ short *structure )
{
int flag;
- if (!PyArg_ParseTuple(args, "i", &flag))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected TRUE or FALSE (1 or 0)"));
+ if( !PyArg_ParseTuple( args, "i", &flag ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected TRUE or FALSE (1 or 0)" ) );
- if(flag < 0 || flag > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected TRUE or FALSE (1 or 0)"));
+ if( flag < 0 || flag > 1 )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "expected TRUE or FALSE (1 or 0)" ) );
- if(flag)
+ if( flag )
*structure |= setting;
else
*structure &= ~setting;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------GetSetAttributeFloat------------------------------------------------------------------------
-static PyObject *M_Render_GetSetAttributeFloat(PyObject *args, float *structure, float min, float max)
+
+//------------------------------------GetSetAttributeFloat---------------
+static PyObject *M_Render_GetSetAttributeFloat( PyObject * args,
+ float *structure, float min,
+ float max )
{
float property = -10.0f;
char error[48];
- if (!PyArg_ParseTuple(args, "|f", &property))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected float"));
+ if( !PyArg_ParseTuple( args, "|f", &property ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, "expected float" ) );
- if(property != -10.0f){
- if(property < min || property > max){
- sprintf(error, "out of range - expected %f to %f", min, max);
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, error));
+ if( property != -10.0f ) {
+ if( property < min || property > max ) {
+ sprintf( error, "out of range - expected %f to %f",
+ min, max );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, error ) );
}
*structure = property;
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
- }else
- return Py_BuildValue("f", *structure);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
+ } else
+ return Py_BuildValue( "f", *structure );
}
-//------------------------------------GetSetAttributeShort------------------------------------------------------------------------
-static PyObject *M_Render_GetSetAttributeShort(PyObject *args, short *structure, int min, int max)
+
+//------------------------------------GetSetAttributeShort---------------
+static PyObject *M_Render_GetSetAttributeShort( PyObject * args,
+ short *structure, int min,
+ int max )
{
short property = -10;
char error[48];
- if (!PyArg_ParseTuple(args, "|h", &property))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int"));
+ if( !PyArg_ParseTuple( args, "|h", &property ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int" ) );
- if(property != -10){
- if(property < min || property > max){
- sprintf(error, "out of range - expected %d to %d", min, max);
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, error));
+ if( property != -10 ) {
+ if( property < min || property > max ) {
+ sprintf( error, "out of range - expected %d to %d",
+ min, max );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, error ) );
}
*structure = property;
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
- }else
- return Py_BuildValue("h", *structure);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
+ } else
+ return Py_BuildValue( "h", *structure );
}
-//------------------------------------GetSetAttributeInt------------------------------------------------------------------------
-static PyObject *M_Render_GetSetAttributeInt(PyObject *args, int *structure, int min, int max)
+
+//------------------------------------GetSetAttributeInt-----------------
+static PyObject *M_Render_GetSetAttributeInt( PyObject * args, int *structure,
+ int min, int max )
{
int property = -10;
char error[48];
- if (!PyArg_ParseTuple(args, "|i", &property))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int"));
+ if( !PyArg_ParseTuple( args, "|i", &property ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int" ) );
- if(property != -10){
- if(property < min || property > max){
- sprintf(error, "out of range - expected %d to %d", min, max);
- return (EXPP_ReturnPyObjError (PyExc_AttributeError, error));
+ if( property != -10 ) {
+ if( property < min || property > max ) {
+ sprintf( error, "out of range - expected %d to %d",
+ min, max );
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError, error ) );
}
*structure = property;
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
- }else
- return Py_BuildValue("i", *structure);
-}
-//------------------------------------DoSizePrese ---------------------------------------------------------------------------------
-static void M_Render_DoSizePreset(BPy_RenderData *self, short xsch, short ysch, short xasp,
- short yasp, short size, short xparts, short yparts,
- short frames, float a, float b, float c, float d)
-{
- self->renderContext->xsch= xsch;
- self->renderContext->ysch= ysch;
- self->renderContext->xasp= xasp;
- self->renderContext->yasp= yasp;
- self->renderContext->size= size;
- self->renderContext->frs_sec= frames;
- self->renderContext->xparts= xparts;
- self->renderContext->yparts= yparts;
-
- BLI_init_rctf(&self->renderContext->safety, a, b, c, d);
- allqueue(REDRAWBUTSSCENE, 0);
- allqueue(REDRAWVIEWCAM, 0);
-}
-//------------------------------------Render Module Function Definitions-----------------------------------------------
-//------------------------------------Render.CloseRenderWindow() -------------------------------------------------------
-PyObject *M_Render_CloseRenderWindow(PyObject *self)
-{
- BIF_close_render_display();
- return EXPP_incr_ret(Py_None);
-}
-//------------------------------------Render.SetRenderWinPos() -------------------------------------------------------
-PyObject *M_Render_SetRenderWinPos(PyObject *self, PyObject *args)
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
+ } else
+ return Py_BuildValue( "i", *structure );
+}
+
+//------------------------------------DoSizePrese -----------------------
+static void M_Render_DoSizePreset( BPy_RenderData * self, short xsch,
+ short ysch, short xasp, short yasp,
+ short size, short xparts, short yparts,
+ short frames, float a, float b, float c,
+ float d )
+{
+ self->renderContext->xsch = xsch;
+ self->renderContext->ysch = ysch;
+ self->renderContext->xasp = xasp;
+ self->renderContext->yasp = yasp;
+ self->renderContext->size = size;
+ self->renderContext->frs_sec = frames;
+ self->renderContext->xparts = xparts;
+ self->renderContext->yparts = yparts;
+
+ BLI_init_rctf( &self->renderContext->safety, a, b, c, d );
+ allqueue( REDRAWBUTSSCENE, 0 );
+ allqueue( REDRAWVIEWCAM, 0 );
+}
+
+//------------------------------------Render Module Function Definitions-
+//------------------------------------Render.CloseRenderWindow() --------
+PyObject *M_Render_CloseRenderWindow( PyObject * self )
+{
+ BIF_close_render_display( );
+ return EXPP_incr_ret( Py_None );
+}
+
+//------------------------------------Render.SetRenderWinPos() ----------
+PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
{
PyObject *list = NULL;
char *loc = NULL;
int x;
- if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &list))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a list"));
+ if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a list" ) );
R.winpos = 0;
- for (x = 0; x < PyList_Size(list); x++) {
- if (!PyArg_Parse(PyList_GetItem(list, x), "s", &loc)){
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "python list not parseable\n");
- }
- if(strcmp(loc,"SW") == 0 || strcmp(loc,"sw") == 0)
+ for( x = 0; x < PyList_Size( list ); x++ ) {
+ if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "python list not parseable\n" );
+ }
+ if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
R.winpos |= 1;
- else if (strcmp(loc,"S") == 0 || strcmp(loc,"s") == 0)
+ else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
R.winpos |= 2;
- else if (strcmp(loc,"SE") == 0 || strcmp(loc,"se") == 0)
+ else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
R.winpos |= 4;
- else if (strcmp(loc,"W") == 0 || strcmp(loc,"w") == 0)
+ else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
R.winpos |= 8;
- else if (strcmp(loc,"C") == 0 || strcmp(loc,"c") == 0)
+ else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
R.winpos |= 16;
- else if (strcmp(loc,"E") == 0 || strcmp(loc,"e") == 0)
+ else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
R.winpos |= 32;
- else if (strcmp(loc,"NW") == 0 || strcmp(loc,"nw") == 0)
+ else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
R.winpos |= 64;
- else if (strcmp(loc,"N") == 0 || strcmp(loc,"n") == 0)
+ else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
R.winpos |= 128;
- else if (strcmp(loc,"NE") == 0 || strcmp(loc,"ne") == 0)
+ else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
R.winpos |= 256;
else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "list contains unknown string\n");
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "list contains unknown string\n" );
}
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------Render.EnableDispView() -------------------------------------------------------------------------
-PyObject *M_Render_EnableDispView(PyObject *self)
+
+//------------------------------------Render.EnableDispView() -----------
+PyObject *M_Render_EnableDispView( PyObject * self )
{
R.displaymode = R_DISPLAYVIEW;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------Render.EnableDispWin() -------------------------------------------------------------------------
-PyObject *M_Render_EnableDispWin(PyObject *self)
+
+//------------------------------------Render.EnableDispWin() ------------
+PyObject *M_Render_EnableDispWin( PyObject * self )
{
R.displaymode = R_DISPLAYWIN;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------Render.EnableEdgeShift() -------------------------------------------------------------------------
-PyObject *M_Render_EnableEdgeShift(PyObject *self, PyObject *args)
+
+//------------------------------------Render.EnableEdgeShift() ----------
+PyObject *M_Render_EnableEdgeShift( PyObject * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, 1, &G.compat);
+ return M_Render_BitToggleInt( args, 1, &G.compat );
}
-//------------------------------------Render.EnableEdgeAll() -------------------------------------------------------------------------
-PyObject *M_Render_EnableEdgeAll(PyObject *self, PyObject *args)
+
+//------------------------------------Render.EnableEdgeAll() ------------
+PyObject *M_Render_EnableEdgeAll( PyObject * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, 1, &G.notonlysolid);
+ return M_Render_BitToggleInt( args, 1, &G.notonlysolid );
}
-//------------------------------------BPy_RenderData Function Definitions-----------------------------------------------
-//------------------------------------RenderData.Render() -------------------------------------------------------------------------
-PyObject *RenderData_Render(BPy_RenderData *self)
+
+//----------------------------BPy_RenderData Function Definitions--------
+
+//------------------------------------RenderData.Render() ---------------
+PyObject *RenderData_Render( BPy_RenderData * self )
{
- Scene* oldsce;
+ Scene *oldsce;
- oldsce= G.scene;
- set_scene(self->scene);
- BIF_do_render(0);
- set_scene(oldsce);
- return EXPP_incr_ret(Py_None);
+ oldsce = G.scene;
+ set_scene( self->scene );
+ BIF_do_render( 0 );
+ set_scene( oldsce );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.RenderAnim() ------------------------------------------------------------------
-PyObject *RenderData_RenderAnim(BPy_RenderData *self)
+
+//------------------------------------RenderData.RenderAnim() -----------
+PyObject *RenderData_RenderAnim( BPy_RenderData * self )
{
- Scene* oldsce;
+ Scene *oldsce;
- oldsce= G.scene;
- set_scene(self->scene);
- BIF_do_render(1);
- set_scene(oldsce);
- return EXPP_incr_ret(Py_None);
+ oldsce = G.scene;
+ set_scene( self->scene );
+ BIF_do_render( 1 );
+ set_scene( oldsce );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.Play() -------------------------------------------------------------------------
-PyObject *RenderData_Play(BPy_RenderData *self)
+
+//------------------------------------RenderData.Play() -----------------
+PyObject *RenderData_Play( BPy_RenderData * self )
{
- char file[FILE_MAXDIR+FILE_MAXFILE];
+ char file[FILE_MAXDIR + FILE_MAXFILE];
extern char bprogname[];
- char str[FILE_MAXDIR+FILE_MAXFILE];
+ char str[FILE_MAXDIR + FILE_MAXFILE];
int pos[2], size[2];
char txt[64];
#ifdef WITH_QUICKTIME
- if(self->renderContext->imtype == R_QUICKTIME){
-
- strcpy(file, self->renderContext->pic);
- BLI_convertstringcode(file, self->scene, self->renderContext->cfra);
- RE_make_existing_file(file);
- if (strcasecmp(file + strlen(file) - 4, ".mov")) {
- sprintf(txt, "%04d_%04d.mov", (self->renderContext->sfra) ,
- (self->renderContext->efra));
- strcat(file, txt);
+ if( self->renderContext->imtype == R_QUICKTIME ) {
+
+ strcpy( file, self->renderContext->pic );
+ BLI_convertstringcode( file, self->scene,
+ self->renderContext->cfra );
+ RE_make_existing_file( file );
+ if( strcasecmp( file + strlen( file ) - 4, ".mov" ) ) {
+ sprintf( txt, "%04d_%04d.mov",
+ ( self->renderContext->sfra ),
+ ( self->renderContext->efra ) );
+ strcat( file, txt );
}
- }else
+ } else
#endif
{
- strcpy(file, self->renderContext->pic);
- BLI_convertstringcode(file, G.sce, self->renderContext->cfra);
- RE_make_existing_file(file);
- if (strcasecmp(file + strlen(file) - 4, ".avi")) {
- sprintf(txt, "%04d_%04d.avi", (self->renderContext->sfra) ,
- (self->renderContext->efra) );
- strcat(file, txt);
+ strcpy( file, self->renderContext->pic );
+ BLI_convertstringcode( file, G.sce,
+ self->renderContext->cfra );
+ RE_make_existing_file( file );
+ if( strcasecmp( file + strlen( file ) - 4, ".avi" ) ) {
+ sprintf( txt, "%04d_%04d.avi",
+ ( self->renderContext->sfra ),
+ ( self->renderContext->efra ) );
+ strcat( file, txt );
}
}
- if(BLI_exist(file)) {
- calc_renderwin_rectangle(R.winpos, pos, size);
- sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
- system(str);
- }
- else {
- makepicstring(file, self->renderContext->sfra);
- if(BLI_exist(file)) {
- calc_renderwin_rectangle(R.winpos, pos, size);
- sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
- system(str);
- }
- else sprintf("Can't find image: %s", file);
+ if( BLI_exist( file ) ) {
+ calc_renderwin_rectangle( R.winpos, pos, size );
+ sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
+ pos[1], file );
+ system( str );
+ } else {
+ makepicstring( file, self->renderContext->sfra );
+ if( BLI_exist( file ) ) {
+ calc_renderwin_rectangle( R.winpos, pos, size );
+ sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
+ pos[0], pos[1], file );
+ system( str );
+ } else
+ sprintf( "Can't find image: %s", file );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.StRenderPath() ---------------------------------------------------------
-PyObject *RenderData_SetRenderPath(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.StRenderPath() ---------
+PyObject *RenderData_SetRenderPath( BPy_RenderData * self, PyObject * args )
{
char *name;
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string" ) );
- if(strlen(name) > 160)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "path is too long (SetRenderPath)"));
+ if( strlen( name ) > 160 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "path is too long (SetRenderPath)" ) );
- strcpy(self->renderContext->pic, name);
- allqueue(REDRAWBUTSSCENE, 0);
+ strcpy( self->renderContext->pic, name );
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.GetRenderPath() -------------------------------------------------------
-PyObject *RenderData_GetRenderPath(BPy_RenderData *self)
+
+//------------------------------------RenderData.GetRenderPath() --------
+PyObject *RenderData_GetRenderPath( BPy_RenderData * self )
{
- return Py_BuildValue("s", self->renderContext->pic);
+ return Py_BuildValue( "s", self->renderContext->pic );
}
-//------------------------------------RenderData.SetBackbufPath() -------------------------------------------------------
-PyObject *RenderData_SetBackbufPath(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetBackbufPath() -------
+PyObject *RenderData_SetBackbufPath( BPy_RenderData * self, PyObject * args )
{
char *name;
Image *ima;
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string" ) );
- if(strlen(name) > 160)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "path is too long (SetBackbufPath)"));
+ if( strlen( name ) > 160 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "path is too long (SetBackbufPath)" ) );
- strcpy(self->renderContext->backbuf, name);
- allqueue(REDRAWBUTSSCENE, 0);
+ strcpy( self->renderContext->backbuf, name );
+ allqueue( REDRAWBUTSSCENE, 0 );
- ima= add_image(name);
- if(ima) {
- free_image_buffers(ima);
- ima->ok= 1;
+ ima = add_image( name );
+ if( ima ) {
+ free_image_buffers( ima );
+ ima->ok = 1;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.GetBackbufPath() --------------------------------------------------------------
-PyObject *RenderData_GetBackbufPath(BPy_RenderData *self)
+
+//------------------------------------RenderData.GetBackbufPath() -------
+PyObject *RenderData_GetBackbufPath( BPy_RenderData * self )
{
- return Py_BuildValue("s", self->renderContext->backbuf);
+ return Py_BuildValue( "s", self->renderContext->backbuf );
}
-//------------------------------------RenderData.EnableBackbuf() ----------------------------------------------------------------
-PyObject *RenderData_EnableBackbuf(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableBackbuf() --------
+PyObject *RenderData_EnableBackbuf( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleShort(args, 1, &self->renderContext->bufflag);
+ return M_Render_BitToggleShort( args, 1,
+ &self->renderContext->bufflag );
}
-//------------------------------------RenderData.SetFtypePath() ------------------------------------------------------------------
-PyObject *RenderData_SetFtypePath(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetFtypePath() ---------
+PyObject *RenderData_SetFtypePath( BPy_RenderData * self, PyObject * args )
{
char *name;
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected a string"));
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected a string" ) );
- if(strlen(name) > 160)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "path is too long (SetFtypePath)"));
+ if( strlen( name ) > 160 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "path is too long (SetFtypePath)" ) );
- strcpy(self->renderContext->ftype, name);
- allqueue(REDRAWBUTSSCENE, 0);
+ strcpy( self->renderContext->ftype, name );
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.GetFtypePath() --------------------------------------------------------
-PyObject *RenderData_GetFtypePath(BPy_RenderData *self)
+
+//------------------------------------RenderData.GetFtypePath() ---------
+PyObject *RenderData_GetFtypePath( BPy_RenderData * self )
{
- return Py_BuildValue("s", self->renderContext->ftype);
+ return Py_BuildValue( "s", self->renderContext->ftype );
}
-//------------------------------------RenderData.EnableExtensions() --------------------------------------------------
-PyObject *RenderData_EnableExtensions(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableExtensions() -----
+PyObject *RenderData_EnableExtensions( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleShort(args, R_EXTENSION, &self->renderContext->scemode);
+ return M_Render_BitToggleShort( args, R_EXTENSION,
+ &self->renderContext->scemode );
}
-//------------------------------------RenderData.EnableSequencer() --------------------------------------------------
-PyObject *RenderData_EnableSequencer(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableSequencer() ------
+PyObject *RenderData_EnableSequencer( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleShort(args, R_DOSEQ, &self->renderContext->scemode);
+ return M_Render_BitToggleShort( args, R_DOSEQ,
+ &self->renderContext->scemode );
}
-//------------------------------------RenderData.EnableRenderDaemon() ------------------------------------------
-PyObject *RenderData_EnableRenderDaemon(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableRenderDaemon() ---
+PyObject *RenderData_EnableRenderDaemon( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleShort(args, R_BG_RENDER, &self->renderContext->scemode);
+ return M_Render_BitToggleShort( args, R_BG_RENDER,
+ &self->renderContext->scemode );
}
-//------------------------------------RenderData.EnableToonShading() ------------------------------------------
-PyObject *RenderData_EnableToonShading(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableToonShading() ----
+PyObject *RenderData_EnableToonShading( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_EDGE, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_EDGE,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EdgeIntensity() --------------------------------------------------------
-PyObject *RenderData_EdgeIntensity(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EdgeIntensity() --------
+PyObject *RenderData_EdgeIntensity( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->edgeint, 0, 255);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->edgeint, 0,
+ 255 );
}
-//------------------------------------RenderData.SetEdgeColor() ------------------------------------------------------
-PyObject *RenderData_SetEdgeColor(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetEdgeColor() ---------
+PyObject *RenderData_SetEdgeColor( BPy_RenderData * self, PyObject * args )
{
float red = 0.0f;
float green = 0.0f;
float blue = 0.0f;
- if (!PyArg_ParseTuple(args, "fff", &red, &green, &blue))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected three floats"));
+ if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected three floats" ) );
- if(red < 0 || red > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (red)"));
- if(green < 0 || green > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (green)"));
- if(blue < 0 || blue > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (blue)"));
+ if( red < 0 || red > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (red)" ) );
+ if( green < 0 || green > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (green)" ) );
+ if( blue < 0 || blue > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (blue)" ) );
self->renderContext->edgeR = red;
self->renderContext->edgeG = green;
self->renderContext->edgeB = blue;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.GetEdgeColor() -----------------------------------------------------
-PyObject *RenderData_GetEdgeColor(BPy_RenderData *self)
+
+//------------------------------------RenderData.GetEdgeColor() ---------
+PyObject *RenderData_GetEdgeColor( BPy_RenderData * self )
{
char rgb[24];
- sprintf(rgb, "[%.3f,%.3f,%.3f]\n", self->renderContext->edgeR,
- self->renderContext->edgeG, self->renderContext->edgeB);
- return PyString_FromString (rgb);
+ sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->renderContext->edgeR,
+ self->renderContext->edgeG, self->renderContext->edgeB );
+ return PyString_FromString( rgb );
}
-//------------------------------------RenderData.EdgeAntiShift() -------------------------------------------------------
-PyObject *RenderData_EdgeAntiShift(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EdgeAntiShift() --------
+PyObject *RenderData_EdgeAntiShift( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->same_mat_redux, 0, 255);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->
+ same_mat_redux, 0, 255 );
}
-//------------------------------------RenderData.EnableOversampling() ------------------------------------------
-PyObject *RenderData_EnableOversampling(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableOversampling() ---
+PyObject *RenderData_EnableOversampling( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_OSA, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_OSA,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.SetOversamplingLevel() ------------------------------------------
-PyObject *RenderData_SetOversamplingLevel(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetOversamplingLevel() -
+PyObject *RenderData_SetOversamplingLevel( BPy_RenderData * self,
+ PyObject * args )
{
int level;
- if (!PyArg_ParseTuple(args, "i", &level))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int"));
+ if( !PyArg_ParseTuple( args, "i", &level ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int" ) );
- if(level != 5 && level != 8 && level != 11 && level != 16)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 5,8,11, or 16"));
+ if( level != 5 && level != 8 && level != 11 && level != 16 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 5,8,11, or 16" ) );
self->renderContext->osa = level;
- allqueue(REDRAWBUTSSCENE, 0);
-
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableMotionBlur() -------------------------------------------------
-PyObject *RenderData_EnableMotionBlur(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableMotionBlur() -----
+PyObject *RenderData_EnableMotionBlur( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, R_MBLUR, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_MBLUR,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.MotionBlurLevel() ----------------------------------------------------
-PyObject *RenderData_MotionBlurLevel(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.MotionBlurLevel() ------
+PyObject *RenderData_MotionBlurLevel( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->blurfac, 0.01f, 5.0f);
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->blurfac,
+ 0.01f, 5.0f );
}
-//------------------------------------RenderData.PartsX() ------------------------------------------------------------
-PyObject *RenderData_PartsX(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.PartsX() ---------------
+PyObject *RenderData_PartsX( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->xparts, 1, 64);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->xparts, 1,
+ 64 );
}
-//------------------------------------RenderData.PartsY() -------------------------------------------------------------
-PyObject *RenderData_PartsY(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.PartsY() ---------------
+PyObject *RenderData_PartsY( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->yparts, 1, 64);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->yparts, 1,
+ 64 );
}
-//------------------------------------RenderData.EnableSky() ------------------------------------------------------
-PyObject *RenderData_EnableSky(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableSky() ------------
+PyObject *RenderData_EnableSky( BPy_RenderData * self )
{
self->renderContext->alphamode = R_ADDSKY;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnablePremultiply() ------------------------------------------
-PyObject *RenderData_EnablePremultiply(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnablePremultiply() ----
+PyObject *RenderData_EnablePremultiply( BPy_RenderData * self )
{
self->renderContext->alphamode = R_ALPHAPREMUL;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableKey() ----------------------------------------------------
-PyObject *RenderData_EnableKey(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableKey() ------------
+PyObject *RenderData_EnableKey( BPy_RenderData * self )
{
self->renderContext->alphamode = R_ALPHAKEY;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableShadow() ------------------------------------------
-PyObject *RenderData_EnableShadow(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableShadow() ---------
+PyObject *RenderData_EnableShadow( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, R_SHADOW, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_SHADOW,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnvironmentMap() ------------------------------------------
-PyObject *RenderData_EnableEnvironmentMap(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnvironmentMap() -------
+PyObject *RenderData_EnableEnvironmentMap( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_ENVMAP, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_ENVMAP,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnablePanorama() ------------------------------------------
-PyObject *RenderData_EnablePanorama(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnablePanorama() -------
+PyObject *RenderData_EnablePanorama( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, R_PANORAMA, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_PANORAMA,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableRayTracing() ------------------------------------------
-PyObject *RenderData_EnableRayTracing(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableRayTracing() -----
+PyObject *RenderData_EnableRayTracing( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, R_RAYTRACE, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_RAYTRACE,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableRadiosityRender() ------------------------------------------
-PyObject *RenderData_EnableRadiosityRender(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableRadiosityRender()
+PyObject *RenderData_EnableRadiosityRender( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_RADIO, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_RADIO,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.SetRenderWinSize() ------------------------------------------
-PyObject *RenderData_SetRenderWinSize(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetRenderWinSize() -----
+PyObject *RenderData_SetRenderWinSize( BPy_RenderData * self, PyObject * args )
{
int size;
- if (!PyArg_ParseTuple(args, "i", &size))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected int"));
+ if( !PyArg_ParseTuple( args, "i", &size ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected int" ) );
- if(size != 25 && size != 50 && size != 75 && size != 100)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected 25, 50, 75, or 100"));
+ if( size != 25 && size != 50 && size != 75 && size != 100 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected 25, 50, 75, or 100" ) );
self->renderContext->size = size;
- allqueue(REDRAWBUTSSCENE, 0);
-
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableFieldRendering() ------------------------------------------
-PyObject *RenderData_EnableFieldRendering(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableFieldRendering() -
+PyObject *RenderData_EnableFieldRendering( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_FIELDS, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_FIELDS,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableOddFieldFirst() ------------------------------------------
-PyObject *RenderData_EnableOddFieldFirst(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableOddFieldFirst() --
+PyObject *RenderData_EnableOddFieldFirst( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_ODDFIELD, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_ODDFIELD,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableFieldTimeDisable() ------------------------------------------
-PyObject *RenderData_EnableFieldTimeDisable(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableFieldTimeDisable()
+PyObject *RenderData_EnableFieldTimeDisable( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_FIELDSTILL, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_FIELDSTILL,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableGaussFilter() ------------------------------------------
-PyObject *RenderData_EnableGaussFilter(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableGaussFilter() ----
+PyObject *RenderData_EnableGaussFilter( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_GAUSS, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_GAUSS,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.EnableBorderRender() ------------------------------------------
-PyObject *RenderData_EnableBorderRender(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableBorderRender() ---
+PyObject *RenderData_EnableBorderRender( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_BORDER, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_BORDER,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.SetBorder() ---------------------------------------------------------
-PyObject *RenderData_SetBorder(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetBorder() ------------
+PyObject *RenderData_SetBorder( BPy_RenderData * self, PyObject * args )
{
- float xmin, ymin, xmax, ymax;
+ float xmin, ymin, xmax, ymax;
int status = 0;
PyObject *ob_args;
-
+
//left,botton | right,top coords - in that order
- if (PyObject_Length (args) == 4) {
- status = PyArg_ParseTuple (args, "ffff", &xmin, &ymin, &xmax, &ymax);
- }else{
- if ( PyArg_ParseTuple (args, "O", &ob_args)){
- if(PyList_Check(ob_args))
- status = PyArg_ParseTuple (args, "(ffff)", &xmin, &ymin, &xmax, &ymax);
- else{
+ if( PyObject_Length( args ) == 4 ) {
+ status = PyArg_ParseTuple( args, "ffff", &xmin, &ymin, &xmax,
+ &ymax );
+ } else {
+ if( PyArg_ParseTuple( args, "O", &ob_args ) ) {
+ if( PyList_Check( ob_args ) )
+ status = PyArg_ParseTuple( args, "(ffff)",
+ &xmin, &ymin, &xmax,
+ &ymax );
+ else {
status = 0;
}
- }else{
+ } else {
status = 0;
}
}
- if( !status) /* parsing args failed */
- return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "expected four floats"));
- if ( xmin > 1.0 || xmin < 0.0 || ymin > 1.0 || ymin < 0.0 ||
- xmax > 1.0 || xmax < 0.0 || ymax > 1.0 || ymax < 0.0)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "all values must be between 0.0 and 1.0"));
-
+ if( !status ) /* parsing args failed */
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected four floats" ) );
+ if( xmin > 1.0 || xmin < 0.0 || ymin > 1.0 || ymin < 0.0 ||
+ xmax > 1.0 || xmax < 0.0 || ymax > 1.0 || ymax < 0.0 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "all values must be between 0.0 and 1.0" ) );
+
self->renderContext->border.xmin = xmin;
self->renderContext->border.ymin = ymin;
self->renderContext->border.xmax = xmax;
self->renderContext->border.ymax = ymax;
- allqueue(REDRAWVIEWCAM, 1);
-
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWVIEWCAM, 1 );
+
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableGammaCorrection() ------------------------------------------
-PyObject *RenderData_EnableGammaCorrection(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableGammaCorrection()
+PyObject *RenderData_EnableGammaCorrection( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_GAMMA, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_GAMMA,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.GaussFilterSize() ------------------------------------------------------
-PyObject *RenderData_GaussFilterSize(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.GaussFilterSize() ------
+PyObject *RenderData_GaussFilterSize( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->gauss, 0.5f, 1.5f);
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->gauss,
+ 0.5f, 1.5f );
}
-//------------------------------------RenderData.StartFrame() --------------------------------------------------------
-PyObject *RenderData_StartFrame(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.StartFrame() -----------
+PyObject *RenderData_StartFrame( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->sfra, 1, 18000);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->sfra,
+ 1, 18000 );
}
-//------------------------------------RenderData.CurrentFrame() --------------------------------------------------------
-PyObject *RenderData_CurrentFrame(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.CurrentFrame() ---------
+PyObject *RenderData_CurrentFrame( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->cfra, 1, 18000);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->cfra,
+ 1, 18000 );
}
-//------------------------------------RenderData.EndFrame() ---------------------------------------------------------
-PyObject *RenderData_EndFrame(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EndFrame() -------------
+PyObject *RenderData_EndFrame( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->efra, 1, 18000);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->efra,
+ 1, 18000 );
}
- //------------------------------------RenderData.ImageSizeX() ---------------------------------------------------------
-PyObject *RenderData_ImageSizeX(BPy_RenderData *self, PyObject *args)
+
+ //------------------------------------RenderData.ImageSizeX() ----------
+PyObject *RenderData_ImageSizeX( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->xsch, 4, 10000);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->xsch,
+ 4, 10000 );
}
-//------------------------------------RenderData.ImageSizeY() -------------------------------------------------------
-PyObject *RenderData_ImageSizeY(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.ImageSizeY() -----------
+PyObject *RenderData_ImageSizeY( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->ysch, 4, 10000);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->ysch,
+ 4, 10000 );
}
-//------------------------------------RenderData.AspectRatioX() ----------------------------------------------------
-PyObject *RenderData_AspectRatioX(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.AspectRatioX() ---------
+PyObject *RenderData_AspectRatioX( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->xasp, 1, 200);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->xasp,
+ 1, 200 );
}
-//------------------------------------RenderData.AspectRatioY() ----------------------------------------------------
-PyObject *RenderData_AspectRatioY(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.AspectRatioY() ---------
+PyObject *RenderData_AspectRatioY( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->yasp, 1, 200);
+ return M_Render_GetSetAttributeShort( args, &self->renderContext->yasp,
+ 1, 200 );
}
-//------------------------------------RenderData.SetRenderer() ----------------------------------------------------
-PyObject *RenderData_SetRenderer(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetRenderer() ----------
+PyObject *RenderData_SetRenderer( BPy_RenderData * self, PyObject * args )
{
int type;
- if (!PyArg_ParseTuple(args, "i", &type))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected constant INTERN or YAFRAY"));
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected constant INTERN or YAFRAY" ) );
- if(type == R_INTERN)
+ if( type == R_INTERN )
self->renderContext->renderer = R_INTERN;
- else if (type == R_YAFRAY)
+ else if( type == R_YAFRAY )
self->renderContext->renderer = R_YAFRAY;
else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected INTERN or YAFRAY"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected INTERN or YAFRAY" ) );
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableCropping() ----------------------------------------------------
-PyObject *RenderData_EnableCropping(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableCropping() -------
+PyObject *RenderData_EnableCropping( BPy_RenderData * self, PyObject * args )
{
- return M_Render_BitToggleInt(args, R_MOVIECROP, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_MOVIECROP,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.SetImageType() ----------------------------------------------------
-PyObject *RenderData_SetImageType(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetImageType() ---------
+PyObject *RenderData_SetImageType( BPy_RenderData * self, PyObject * args )
{
int type;
- if (!PyArg_ParseTuple(args, "i", &type))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected constant"));
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected constant" ) );
- if(type == R_AVIRAW)
+ if( type == R_AVIRAW )
self->renderContext->imtype = R_AVIRAW;
- else if (type == R_AVIJPEG)
+ else if( type == R_AVIJPEG )
self->renderContext->imtype = R_AVIJPEG;
#ifdef _WIN32
- else if (type == R_AVICODEC)
+ else if( type == R_AVICODEC )
self->renderContext->imtype = R_AVICODEC;
#endif
- else if (type == R_QUICKTIME && G.have_quicktime)
+ else if( type == R_QUICKTIME && G.have_quicktime )
self->renderContext->imtype = R_QUICKTIME;
- else if (type == R_TARGA)
+ else if( type == R_TARGA )
self->renderContext->imtype = R_TARGA;
- else if (type == R_RAWTGA)
+ else if( type == R_RAWTGA )
self->renderContext->imtype = R_RAWTGA;
- else if (type == R_PNG)
+ else if( type == R_PNG )
self->renderContext->imtype = R_PNG;
- else if (type == R_BMP)
+ else if( type == R_BMP )
self->renderContext->imtype = R_BMP;
- else if (type == R_JPEG90)
+ else if( type == R_JPEG90 )
self->renderContext->imtype = R_JPEG90;
- else if (type == R_HAMX)
+ else if( type == R_HAMX )
self->renderContext->imtype = R_HAMX;
- else if (type == R_IRIS)
+ else if( type == R_IRIS )
self->renderContext->imtype = R_IRIS;
- else if (type == R_IRIZ)
+ else if( type == R_IRIZ )
self->renderContext->imtype = R_IRIZ;
- else if (type == R_FTYPE)
+ else if( type == R_FTYPE )
self->renderContext->imtype = R_FTYPE;
else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown constant - see modules dict for help"));
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown constant - see modules dict for help" ) );
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.Quality() ----------------------------------------------------
-PyObject *RenderData_Quality(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.Quality() --------------
+PyObject *RenderData_Quality( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->quality, 10, 100);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->quality,
+ 10, 100 );
}
-//------------------------------------RenderData.FramesPerSec() ----------------------------------------------------
-PyObject *RenderData_FramesPerSec(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.FramesPerSec() ---------
+PyObject *RenderData_FramesPerSec( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->frs_sec, 1, 120);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->frs_sec, 1,
+ 120 );
}
-//------------------------------------RenderData.EnableGrayscale() ----------------------------------------------------
-PyObject *RenderData_EnableGrayscale(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableGrayscale() ------
+PyObject *RenderData_EnableGrayscale( BPy_RenderData * self )
{
self->renderContext->planes = R_PLANESBW;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableRGBColor() ----------------------------------------------------
-PyObject *RenderData_EnableRGBColor(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableRGBColor() -------
+PyObject *RenderData_EnableRGBColor( BPy_RenderData * self )
{
self->renderContext->planes = R_PLANES24;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableRGBAColor() ----------------------------------------------------
-PyObject *RenderData_EnableRGBAColor(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableRGBAColor() ------
+PyObject *RenderData_EnableRGBAColor( BPy_RenderData * self )
{
self->renderContext->planes = R_PLANES32;
- allqueue(REDRAWBUTSSCENE, 0);
+ allqueue( REDRAWBUTSSCENE, 0 );
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.SizePreset() ----------------------------------------------------------------
-PyObject *RenderData_SizePreset(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SizePreset() -----------
+PyObject *RenderData_SizePreset( BPy_RenderData * self, PyObject * args )
{
int type;
- if (!PyArg_ParseTuple(args, "i", &type))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected constant"));
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected constant" ) );
- if(type == B_PR_PAL){
- M_Render_DoSizePreset(self,720,576,54,51,100, self->renderContext->xparts,
- self->renderContext->yparts, 25, 0.1, 0.9, 0.1, 0.9);
+ if( type == B_PR_PAL ) {
+ M_Render_DoSizePreset( self, 720, 576, 54, 51, 100,
+ self->renderContext->xparts,
+ self->renderContext->yparts, 25, 0.1,
+ 0.9, 0.1, 0.9 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_NTSC){
- M_Render_DoSizePreset(self,720,480,10,11,100, 1, 1,
- 30, 0.1, 0.9, 0.1, 0.9);
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_NTSC ) {
+ M_Render_DoSizePreset( self, 720, 480, 10, 11, 100, 1, 1,
+ 30, 0.1, 0.9, 0.1, 0.9 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_PRESET){
- M_Render_DoSizePreset(self,720,576,54,51,100, 1, 1,
- self->renderContext->frs_sec, 0.1, 0.9, 0.1, 0.9);
- self->renderContext->mode= R_OSA+R_SHADOW+R_FIELDS;
- self->renderContext->imtype= R_TARGA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_PRV){
- M_Render_DoSizePreset(self,640,512,1,1,50, 1, 1,
- self->renderContext->frs_sec, 0.1, 0.9, 0.1, 0.9);
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_PRESET ) {
+ M_Render_DoSizePreset( self, 720, 576, 54, 51, 100, 1, 1,
+ self->renderContext->frs_sec, 0.1, 0.9,
+ 0.1, 0.9 );
+ self->renderContext->mode = R_OSA + R_SHADOW + R_FIELDS;
+ self->renderContext->imtype = R_TARGA;
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_PRV ) {
+ M_Render_DoSizePreset( self, 640, 512, 1, 1, 50, 1, 1,
+ self->renderContext->frs_sec, 0.1, 0.9,
+ 0.1, 0.9 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_PC){
- M_Render_DoSizePreset(self,640,480,100,100,100, 1, 1,
- self->renderContext->frs_sec, 0.0, 1.0, 0.0, 1.0);
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_PC ) {
+ M_Render_DoSizePreset( self, 640, 480, 100, 100, 100, 1, 1,
+ self->renderContext->frs_sec, 0.0, 1.0,
+ 0.0, 1.0 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.0, 1.0, 0.0, 1.0);
- }else if (type == B_PR_PAL169){
- M_Render_DoSizePreset(self,720,576,64,45,100, 1, 1,
- 25, 0.1, 0.9, 0.1, 0.9);
+ BLI_init_rctf( &self->renderContext->safety, 0.0, 1.0, 0.0,
+ 1.0 );
+ } else if( type == B_PR_PAL169 ) {
+ M_Render_DoSizePreset( self, 720, 576, 64, 45, 100, 1, 1,
+ 25, 0.1, 0.9, 0.1, 0.9 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_PANO){
- M_Render_DoSizePreset(self,36,176,115,100,100, 16, 1,
- self->renderContext->frs_sec, 0.1, 0.9, 0.1, 0.9);
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_PANO ) {
+ M_Render_DoSizePreset( self, 36, 176, 115, 100, 100, 16, 1,
+ self->renderContext->frs_sec, 0.1, 0.9,
+ 0.1, 0.9 );
self->renderContext->mode |= R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else if (type == B_PR_FULL){
- M_Render_DoSizePreset(self,1280,1024,1,1,100, 1, 1,
- self->renderContext->frs_sec, 0.1, 0.9, 0.1, 0.9);
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else if( type == B_PR_FULL ) {
+ M_Render_DoSizePreset( self, 1280, 1024, 1, 1, 100, 1, 1,
+ self->renderContext->frs_sec, 0.1, 0.9,
+ 0.1, 0.9 );
self->renderContext->mode &= ~R_PANORAMA;
- BLI_init_rctf(&self->renderContext->safety, 0.1, 0.9, 0.1, 0.9);
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown constant - see modules dict for help"));
+ BLI_init_rctf( &self->renderContext->safety, 0.1, 0.9, 0.1,
+ 0.9 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown constant - see modules dict for help" ) );
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableUnifiedRenderer() ----------------------------------------------------
-PyObject *RenderData_EnableUnifiedRenderer(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableUnifiedRenderer()
+PyObject *RenderData_EnableUnifiedRenderer( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_BitToggleInt(args, R_UNIFIED, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_UNIFIED,
+ &self->renderContext->mode );
}
-//------------------------------------RenderData.SetYafrayGIQuality() ----------------------------------------------------
-PyObject *RenderData_SetYafrayGIQuality(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetYafrayGIQuality() ---
+PyObject *RenderData_SetYafrayGIQuality( BPy_RenderData * self,
+ PyObject * args )
{
int type;
- if (!PyArg_ParseTuple(args, "i", &type))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected constant"));
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected constant" ) );
- if( type == PY_NONE || type == PY_LOW ||
- type == PY_MEDIUM || type == PY_HIGH ||
- type == PY_HIGHER || type == PY_BEST){
+ if( type == PY_NONE || type == PY_LOW ||
+ type == PY_MEDIUM || type == PY_HIGH ||
+ type == PY_HIGHER || type == PY_BEST ) {
self->renderContext->GIquality = type;
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown constant - see modules dict for help"));
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown constant - see modules dict for help" ) );
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.SetYafrayGIMethod() ----------------------------------------------------
-PyObject *RenderData_SetYafrayGIMethod(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetYafrayGIMethod() ----
+PyObject *RenderData_SetYafrayGIMethod( BPy_RenderData * self,
+ PyObject * args )
{
int type;
- if (!PyArg_ParseTuple(args, "i", &type))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected constant"));
+ if( !PyArg_ParseTuple( args, "i", &type ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected constant" ) );
- if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL){
+ if( type == PY_NONE || type == PY_SKYDOME || type == PY_FULL ) {
self->renderContext->GImethod = type;
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown constant - see modules dict for help"));
-
- allqueue(REDRAWBUTSSCENE, 0);
- return EXPP_incr_ret(Py_None);
-}
-//------------------------------------RenderData.YafrayGIPower() ----------------------------------------------------
-PyObject *RenderData_YafrayGIPower(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod>0) {
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->GIpower, 0.01f, 100.00f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'"));
-}
-//------------------------------------RenderData.YafrayGIDepth() ----------------------------------------------------
-PyObject *RenderData_YafrayGIDepth(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2) {
- return M_Render_GetSetAttributeInt(args, &self->renderContext->GIdepth, 1, 8);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'"));
-}
-//------------------------------------RenderData.afrayGICDepth() ----------------------------------------------------
-PyObject *RenderData_YafrayGICDepth(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2) {
- return M_Render_GetSetAttributeInt(args, &self->renderContext->GIcausdepth, 1, 8);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'"));
-}
-//------------------------------------RenderData.EnableYafrayGICache() ----------------------------------------------------
-PyObject *RenderData_EnableYafrayGICache(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2) {
- return M_Render_BitToggleShort(args, 1, &self->renderContext->GIcache);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'"));
-}
-//------------------------------------RenderData.EnableYafrayGIPhotons() ----------------------------------------------------
-PyObject *RenderData_EnableYafrayGIPhotons(BPy_RenderData *self, PyObject *args)
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown constant - see modules dict for help" ) );
+
+ allqueue( REDRAWBUTSSCENE, 0 );
+ return EXPP_incr_ret( Py_None );
+}
+
+//------------------------------------RenderData.YafrayGIPower() --------
+PyObject *RenderData_YafrayGIPower( BPy_RenderData * self, PyObject * args )
+{
+ if( self->renderContext->GImethod > 0 ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ GIpower, 0.01f,
+ 100.00f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'SKYDOME' or 'FULL'" ) );
+}
+
+//------------------------------------RenderData.YafrayGIDepth() --------
+PyObject *RenderData_YafrayGIDepth( BPy_RenderData * self, PyObject * args )
+{
+ if( self->renderContext->GImethod == 2 ) {
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->
+ GIdepth, 1, 8 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL'" ) );
+}
+
+//------------------------------------RenderData.afrayGICDepth() --------
+PyObject *RenderData_YafrayGICDepth( BPy_RenderData * self, PyObject * args )
+{
+ if( self->renderContext->GImethod == 2 ) {
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->
+ GIcausdepth, 1, 8 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL'" ) );
+}
+
+//------------------------------------RenderData.EnableYafrayGICache() --
+PyObject *RenderData_EnableYafrayGICache( BPy_RenderData * self,
+ PyObject * args )
+{
+ if( self->renderContext->GImethod == 2 ) {
+ return M_Render_BitToggleShort( args, 1,
+ &self->renderContext->
+ GIcache );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL'" ) );
+}
+
+//------------------------------------RenderData.EnableYafrayGIPhotons()
+PyObject *RenderData_EnableYafrayGIPhotons( BPy_RenderData * self,
+ PyObject * args )
+{
+ if( self->renderContext->GImethod == 2 ) {
+ return M_Render_BitToggleShort( args, 1,
+ &self->renderContext->
+ GIphotons );;
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL'" ) );
+}
+
+//------------------------------------RenderData.YafrayGIPhotonCount() --
+PyObject *RenderData_YafrayGIPhotonCount( BPy_RenderData * self,
+ PyObject * args )
+{
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIphotons == 1 ) {
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->
+ GIphotoncount, 0,
+ 10000000 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
+}
+
+//------------------------------------RenderData.YafrayGIPhotonRadius() -
+PyObject *RenderData_YafrayGIPhotonRadius( BPy_RenderData * self,
+ PyObject * args )
+{
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIphotons == 1 ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ GIphotonradius, 0.00001f,
+ 100.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
+}
+
+//------------------------------------RenderData.YafrayGIPhotonMixCount()
+PyObject *RenderData_YafrayGIPhotonMixCount( BPy_RenderData * self,
+ PyObject * args )
+{
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIphotons == 1 ) {
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->
+ GImixphotons, 0, 1000 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n" ) );
+}
+
+//--------------------------RenderData.EnableYafrayGITunePhotons() ------
+PyObject *RenderData_EnableYafrayGITunePhotons( BPy_RenderData * self,
+ PyObject * args )
{
- if (self->renderContext->GImethod==2) {
- return M_Render_BitToggleShort(args, 1, &self->renderContext->GIphotons);;
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL'"));
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIphotons == 1 ) {
+ return M_Render_BitToggleShort( args, 1,
+ &self->renderContext->
+ GIdirect );;
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled" ) );
}
-//------------------------------------RenderData.YafrayGIPhotonCount() ----------------------------------------------------
-PyObject *RenderData_YafrayGIPhotonCount(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2 && self->renderContext->GIphotons==1) {
- return M_Render_GetSetAttributeInt(args, &self->renderContext->GIphotoncount, 0, 10000000);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n"));
-}
-//------------------------------------RenderData.YafrayGIPhotonRadius() ----------------------------------------------------
-PyObject *RenderData_YafrayGIPhotonRadius(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2 && self->renderContext->GIphotons==1) {
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->GIphotonradius, 0.00001f, 100.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n"));
-}
-//------------------------------------RenderData.YafrayGIPhotonMixCount() ----------------------------------------------------
-PyObject *RenderData_YafrayGIPhotonMixCount(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2 && self->renderContext->GIphotons==1) {
- return M_Render_GetSetAttributeInt(args, &self->renderContext->GImixphotons, 0, 1000);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled\n"));
-}
-//------------------------------------RenderData.EnableYafrayGITunePhotons() ----------------------------------------------------
-PyObject *RenderData_EnableYafrayGITunePhotons(BPy_RenderData *self, PyObject *args)
-{
- if (self->renderContext->GImethod==2 && self->renderContext->GIphotons==1) {
- return M_Render_BitToggleShort(args, 1, &self->renderContext->GIdirect);;
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GIPhotons must be enabled"));
-}
-//------------------------------------RenderData.YafrayGIShadowQuality() ----------------------------------------------------
-PyObject *RenderData_YafrayGIShadowQuality(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayGIShadowQuality()
+PyObject *RenderData_YafrayGIShadowQuality( BPy_RenderData * self,
+ PyObject * args )
{
- if (self->renderContext->GImethod==2 && self->renderContext->GIcache==1) {
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->GIshadowquality, 0.01f, 1.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n"));
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIcache == 1 ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ GIshadowquality, 0.01f,
+ 1.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
}
-//------------------------------------RenderData.YafrayGIPixelsPerSample() ----------------------------------------------------
-PyObject *RenderData_YafrayGIPixelsPerSample(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayGIPixelsPerSample()
+PyObject *RenderData_YafrayGIPixelsPerSample( BPy_RenderData * self,
+ PyObject * args )
{
- if (self->renderContext->GImethod==2 && self->renderContext->GIcache==1) {
- return M_Render_GetSetAttributeInt(args, &self->renderContext->GIpixelspersample, 1, 50);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n"));
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIcache == 1 ) {
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->
+ GIpixelspersample, 1, 50 );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
}
-//------------------------------------RenderData.EnableYafrayGIGradient() ----------------------------------------------------
-PyObject *RenderData_EnableYafrayGIGradient(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableYafrayGIGradient()
+PyObject *RenderData_EnableYafrayGIGradient( BPy_RenderData * self,
+ PyObject * args )
{
- if (self->renderContext->GImethod==2 && self->renderContext->GIcache==1) {
- return M_Render_BitToggleShort(args, 1, &self->renderContext->GIgradient);;
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled"));
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIcache == 1 ) {
+ return M_Render_BitToggleShort( args, 1,
+ &self->renderContext->
+ GIgradient );;
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GICache must be enabled" ) );
}
-//------------------------------------RenderData.YafrayGIRefinement() ----------------------------------------------------
-PyObject *RenderData_YafrayGIRefinement(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayGIRefinement() ----
+PyObject *RenderData_YafrayGIRefinement( BPy_RenderData * self,
+ PyObject * args )
{
- if (self->renderContext->GImethod==2 && self->renderContext->GIcache==1) {
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->GIrefinement, 0.001f, 1.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n"));
+ if( self->renderContext->GImethod == 2
+ && self->renderContext->GIcache == 1 ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ GIrefinement, 0.001f,
+ 1.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "YafrayGIMethod must be set to 'FULL' and GICache must be enabled\n" ) );
}
-//------------------------------------RenderData.YafrayRayBias() -------------------------------------------------------------
-PyObject *RenderData_YafrayRayBias(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayRayBias() ---------
+PyObject *RenderData_YafrayRayBias( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->YF_raybias, 0.0f, 10.0f);
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->YF_raybias,
+ 0.0f, 10.0f );
}
-//------------------------------------RenderData.YafrayRayDepth() -----------------------------------------------------------
-PyObject *RenderData_YafrayRayDepth(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayRayDepth() --------
+PyObject *RenderData_YafrayRayDepth( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeInt(args, &self->renderContext->YF_raydepth, 1, 80);
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->YF_raydepth,
+ 1, 80 );
}
-//------------------------------------RenderData.YafrayGamma() -----------------------------------------------------------
-PyObject *RenderData_YafrayGamma(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayGamma() -----------
+PyObject *RenderData_YafrayGamma( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->YF_gamma, 0.001f, 5.0f);
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->YF_gamma,
+ 0.001f, 5.0f );
}
-//------------------------------------RenderData.YafrayExposure() -----------------------------------------------------------
-PyObject *RenderData_YafrayExposure(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayExposure() --------
+PyObject *RenderData_YafrayExposure( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->YF_exposure, 0.0f, 10.0f);
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ YF_exposure, 0.0f, 10.0f );
}
-//------------------------------------RenderData.YafrayProcessorCount() -----------------------------------------------------------
-PyObject *RenderData_YafrayProcessorCount(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.YafrayProcessorCount() --
+PyObject *RenderData_YafrayProcessorCount( BPy_RenderData * self,
+ PyObject * args )
{
- return M_Render_GetSetAttributeInt(args, &self->renderContext->YF_numprocs, 1, 8);
+ return M_Render_GetSetAttributeInt( args,
+ &self->renderContext->YF_numprocs,
+ 1, 8 );
}
+
//------------------------------------RenderData.EnableGameFrameStretch() -----------------------------------------------------------
-PyObject *RenderData_EnableGameFrameStretch(BPy_RenderData *self)
+PyObject *RenderData_EnableGameFrameStretch( BPy_RenderData * self )
{
self->scene->framing.type = SCE_GAMEFRAMING_SCALE;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableGameFrameExpose() -----------------------------------------------------------
-PyObject *RenderData_EnableGameFrameExpose(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableGameFrameExpose() -
+PyObject *RenderData_EnableGameFrameExpose( BPy_RenderData * self )
{
self->scene->framing.type = SCE_GAMEFRAMING_EXTEND;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.EnableGameFrameBars() -----------------------------------------------------------
-PyObject *RenderData_EnableGameFrameBars(BPy_RenderData *self)
+
+//------------------------------------RenderData.EnableGameFrameBars() ---
+PyObject *RenderData_EnableGameFrameBars( BPy_RenderData * self )
{
self->scene->framing.type = SCE_GAMEFRAMING_BARS;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.SetGameFrameColor() -----------------------------------------------------------
-PyObject *RenderData_SetGameFrameColor(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SetGameFrameColor() -----
+PyObject *RenderData_SetGameFrameColor( BPy_RenderData * self,
+ PyObject * args )
{
float red = 0.0f;
float green = 0.0f;
float blue = 0.0f;
- if (!PyArg_ParseTuple(args, "fff", &red, &green, &blue))
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected three floats"));
+ if( !PyArg_ParseTuple( args, "fff", &red, &green, &blue ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected three floats" ) );
- if(red < 0 || red > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (red)"));
- if(green < 0 || green > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (green)"));
- if(blue < 0 || blue > 1)
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "value out of range 0.000 - 1.000 (blue)"));
+ if( red < 0 || red > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (red)" ) );
+ if( green < 0 || green > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (green)" ) );
+ if( blue < 0 || blue > 1 )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "value out of range 0.000 - 1.000 (blue)" ) );
self->scene->framing.col[0] = red;
self->scene->framing.col[1] = green;
self->scene->framing.col[2] = blue;
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-//------------------------------------RenderData.GetGameFrameColor() -----------------------------------------------------------
-PyObject *RenderData_GetGameFrameColor(BPy_RenderData *self)
+
+//------------------------------------RenderData.GetGameFrameColor() -----
+PyObject *RenderData_GetGameFrameColor( BPy_RenderData * self )
{
char rgb[24];
- sprintf(rgb, "[%.3f,%.3f,%.3f]\n", self->scene->framing.col[0],
- self->scene->framing.col[1], self->scene->framing.col[2]);
- return PyString_FromString (rgb);
+ sprintf( rgb, "[%.3f,%.3f,%.3f]\n", self->scene->framing.col[0],
+ self->scene->framing.col[1], self->scene->framing.col[2] );
+ return PyString_FromString( rgb );
}
-//------------------------------------RenderData.GammaLevel() -----------------------------------------------------------
-PyObject *RenderData_GammaLevel(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.GammaLevel() ------------
+PyObject *RenderData_GammaLevel( BPy_RenderData * self, PyObject * args )
{
- if(self->renderContext->mode & R_UNIFIED){
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->gamma, 0.2f, 5.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Unified Render must be enabled"));
+ if( self->renderContext->mode & R_UNIFIED ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ gamma, 0.2f, 5.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unified Render must be enabled" ) );
}
-//------------------------------------RenderData.PostProcessAdd() -----------------------------------------------------------
-PyObject *RenderData_PostProcessAdd(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.PostProcessAdd() --------
+PyObject *RenderData_PostProcessAdd( BPy_RenderData * self, PyObject * args )
{
- if(self->renderContext->mode & R_UNIFIED){
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->postadd, -1.0f, 1.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Unified Render must be enabled"));
+ if( self->renderContext->mode & R_UNIFIED ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ postadd, -1.0f, 1.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unified Render must be enabled" ) );
}
-//------------------------------------RenderData.PostProcessMultiply() -----------------------------------------------------------
-PyObject *RenderData_PostProcessMultiply(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.PostProcessMultiply() ---
+PyObject *RenderData_PostProcessMultiply( BPy_RenderData * self,
+ PyObject * args )
{
- if(self->renderContext->mode & R_UNIFIED){
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->postmul, 0.01f, 4.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Unified Render must be enabled"));
+ if( self->renderContext->mode & R_UNIFIED ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ postmul, 0.01f, 4.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unified Render must be enabled" ) );
}
-//------------------------------------RenderData.PostProcessGamma() -----------------------------------------------------------
-PyObject *RenderData_PostProcessGamma(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.PostProcessGamma() ------
+PyObject *RenderData_PostProcessGamma( BPy_RenderData * self, PyObject * args )
{
- if(self->renderContext->mode & R_UNIFIED){
- return M_Render_GetSetAttributeFloat(args, &self->renderContext->postgamma, 0.2f, 2.0f);
- }else
- return (EXPP_ReturnPyObjError (PyExc_AttributeError,
- "Unified Render must be enabled"));
+ if( self->renderContext->mode & R_UNIFIED ) {
+ return M_Render_GetSetAttributeFloat( args,
+ &self->renderContext->
+ postgamma, 0.2f, 2.0f );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Unified Render must be enabled" ) );
}
-//------------------------------------RenderData.SGIMaxsize() -----------------------------------------------------------
-PyObject *RenderData_SGIMaxsize(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.SGIMaxsize() ------------
+PyObject *RenderData_SGIMaxsize( BPy_RenderData * self, PyObject * args )
{
#ifdef __sgi
- return M_Render_GetSetAttributeShort(args, &self->renderContext->maximsize, 0, 500);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->maximsize,
+ 0, 500 );
#else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "SGI is not defined on this machine"));
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "SGI is not defined on this machine" ) );
#endif
}
-//------------------------------------RenderData.EnableSGICosmo() -----------------------------------------------------------
-PyObject *RenderData_EnableSGICosmo(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.EnableSGICosmo() --------
+PyObject *RenderData_EnableSGICosmo( BPy_RenderData * self, PyObject * args )
{
#ifdef __sgi
- return M_Render_BitToggleInt(args, R_COSMO, &self->renderContext->mode);
+ return M_Render_BitToggleInt( args, R_COSMO,
+ &self->renderContext->mode );
#else
- return (EXPP_ReturnPyObjError (PyExc_StandardError,
- "SGI is not defined on this machine"));
+ return ( EXPP_ReturnPyObjError( PyExc_StandardError,
+ "SGI is not defined on this machine" ) );
#endif
}
-//------------------------------------RenderData.OldMapValue() -----------------------------------------------------------
-PyObject *RenderData_OldMapValue(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.OldMapValue() -----------
+PyObject *RenderData_OldMapValue( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->framapto, 1, 900);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->framapto,
+ 1, 900 );
}
-//------------------------------------RenderData.NewMapValue() -----------------------------------------------------------
-PyObject *RenderData_NewMapValue(BPy_RenderData *self, PyObject *args)
+
+//------------------------------------RenderData.NewMapValue() -----------
+PyObject *RenderData_NewMapValue( BPy_RenderData * self, PyObject * args )
{
- return M_Render_GetSetAttributeShort(args, &self->renderContext->images, 1, 900);
+ return M_Render_GetSetAttributeShort( args,
+ &self->renderContext->images, 1,
+ 900 );
}
-
-
-
diff --git a/source/blender/python/api2_2x/sceneRender.h b/source/blender/python/api2_2x/sceneRender.h
index 965e7b8ce78..c36415227b9 100644
--- a/source/blender/python/api2_2x/sceneRender.h
+++ b/source/blender/python/api2_2x/sceneRender.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -35,17 +36,15 @@
#include <Python.h>
#include <DNA_scene_types.h>
-//------------------------------------Struct definitions----------------------------------------------------------------------
-typedef struct
-{
- PyObject_HEAD
- struct RenderData *renderContext;
- Scene *scene;
-}BPy_RenderData;
-//------------------------------------Visible prototypes-------------------------------------------------------------------
-PyObject *Render_Init (void);
+//------------------------------------Struct definitions-------
+typedef struct {
+ PyObject_HEAD struct RenderData *renderContext;
+ Scene *scene;
+} BPy_RenderData;
+//------------------------------------Visible prototypes-------
+PyObject *Render_Init( void );
-PyObject *RenderData_CreatePyObject (struct Scene * scene);
-int RenderData_CheckPyObject (PyObject * py_obj);
+PyObject *RenderData_CreatePyObject( struct Scene *scene );
+int RenderData_CheckPyObject( PyObject * py_obj );
-#endif /* EXPP_SCENERENDER_H */
+#endif /* EXPP_SCENERENDER_H */
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index 564ccec56fb..aefa5dfb821 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -31,33 +31,27 @@
#include "vector.h"
//doc strings
-char Vector_Zero_doc[] =
-"() - set all values in the vector to 0";
-char Vector_Normalize_doc[] =
-"() - normalize the vector";
-char Vector_Negate_doc[] =
-"() - changes vector to it's additive inverse";
-char Vector_Resize2D_doc[] =
-"() - resize a vector to [x,y]";
-char Vector_Resize3D_doc[] =
-"() - resize a vector to [x,y,z]";
-char Vector_Resize4D_doc[] =
-"() - resize a vector to [x,y,z,w]";
+char Vector_Zero_doc[] = "() - set all values in the vector to 0";
+char Vector_Normalize_doc[] = "() - normalize the vector";
+char Vector_Negate_doc[] = "() - changes vector to it's additive inverse";
+char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]";
+char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]";
+char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]";
//method table
struct PyMethodDef Vector_methods[] = {
- {"zero",(PyCFunction)Vector_Zero, METH_NOARGS,
- Vector_Zero_doc},
- {"normalize",(PyCFunction)Vector_Normalize, METH_NOARGS,
- Vector_Normalize_doc},
- {"negate",(PyCFunction)Vector_Negate, METH_NOARGS,
- Vector_Negate_doc},
- {"resize2D",(PyCFunction)Vector_Resize2D, METH_NOARGS,
- Vector_Resize2D_doc},
- {"resize3D",(PyCFunction)Vector_Resize3D, METH_NOARGS,
- Vector_Resize2D_doc},
- {"resize4D",(PyCFunction)Vector_Resize4D, METH_NOARGS,
- Vector_Resize2D_doc},
+ {"zero", ( PyCFunction ) Vector_Zero, METH_NOARGS,
+ Vector_Zero_doc},
+ {"normalize", ( PyCFunction ) Vector_Normalize, METH_NOARGS,
+ Vector_Normalize_doc},
+ {"negate", ( PyCFunction ) Vector_Negate, METH_NOARGS,
+ Vector_Negate_doc},
+ {"resize2D", ( PyCFunction ) Vector_Resize2D, METH_NOARGS,
+ Vector_Resize2D_doc},
+ {"resize3D", ( PyCFunction ) Vector_Resize3D, METH_NOARGS,
+ Vector_Resize2D_doc},
+ {"resize4D", ( PyCFunction ) Vector_Resize4D, METH_NOARGS,
+ Vector_Resize2D_doc},
{NULL, NULL, 0, NULL}
};
@@ -66,110 +60,108 @@ struct PyMethodDef Vector_methods[] = {
/*****************************/
//object methods
-PyObject *Vector_Zero(VectorObject *self)
+PyObject *Vector_Zero( VectorObject * self )
{
int x;
- for(x = 0; x < self->size; x++){
+ for( x = 0; x < self->size; x++ ) {
self->vec[x] = 0.0f;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Vector_Normalize(VectorObject *self)
+PyObject *Vector_Normalize( VectorObject * self )
{
float norm;
int x;
norm = 0.0f;
- for(x = 0; x < self->size; x++){
+ for( x = 0; x < self->size; x++ ) {
norm += self->vec[x] * self->vec[x];
}
- norm = (float)sqrt(norm);
- for(x = 0; x < self->size; x++){
+ norm = ( float ) sqrt( norm );
+ for( x = 0; x < self->size; x++ ) {
self->vec[x] /= norm;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Vector_Negate(VectorObject *self)
+PyObject *Vector_Negate( VectorObject * self )
{
int x;
- for(x = 0; x < self->size; x++){
- self->vec[x] = -(self->vec[x]);
+ for( x = 0; x < self->size; x++ ) {
+ self->vec[x] = -( self->vec[x] );
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Vector_Resize2D(VectorObject *self)
+PyObject *Vector_Resize2D( VectorObject * self )
{
float x, y;
- if(self->size == 4 || self->size == 3){
+ if( self->size == 4 || self->size == 3 ) {
x = self->vec[0];
y = self->vec[1];
- PyMem_Free(self->vec);
- self->vec = PyMem_Malloc(2*sizeof (float));
+ PyMem_Free( self->vec );
+ self->vec = PyMem_Malloc( 2 * sizeof( float ) );
self->vec[0] = x;
self->vec[1] = y;
self->size = 2;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Vector_Resize3D(VectorObject *self)
+PyObject *Vector_Resize3D( VectorObject * self )
{
float x, y, z;
- if(self->size == 2){
+ if( self->size == 2 ) {
x = self->vec[0];
y = self->vec[1];
- PyMem_Free(self->vec);
- self->vec = PyMem_Malloc(3*sizeof (float));
+ PyMem_Free( self->vec );
+ self->vec = PyMem_Malloc( 3 * sizeof( float ) );
self->vec[0] = x;
self->vec[1] = y;
self->vec[2] = 0.0f;
self->size = 3;
- }
- else if (self->size == 4){
+ } else if( self->size == 4 ) {
x = self->vec[0];
y = self->vec[1];
z = self->vec[2];
- PyMem_Free(self->vec);
- self->vec = PyMem_Malloc(3*sizeof (float));
+ PyMem_Free( self->vec );
+ self->vec = PyMem_Malloc( 3 * sizeof( float ) );
self->vec[0] = x;
self->vec[1] = y;
self->vec[2] = z;
self->size = 3;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Vector_Resize4D(VectorObject *self)
+PyObject *Vector_Resize4D( VectorObject * self )
{
float x, y, z;
- if(self->size == 2){
+ if( self->size == 2 ) {
x = self->vec[0];
y = self->vec[1];
- PyMem_Free(self->vec);
- self->vec = PyMem_Malloc(4*sizeof (float));
+ PyMem_Free( self->vec );
+ self->vec = PyMem_Malloc( 4 * sizeof( float ) );
self->vec[0] = x;
self->vec[1] = y;
self->vec[2] = 0.0f;
self->vec[3] = 1.0f;
self->size = 4;
- }
- else if (self->size == 3){
+ } else if( self->size == 3 ) {
x = self->vec[0];
y = self->vec[1];
z = self->vec[2];
- PyMem_Free(self->vec);
- self->vec = PyMem_Malloc(4*sizeof (float));
+ PyMem_Free( self->vec );
+ self->vec = PyMem_Malloc( 4 * sizeof( float ) );
self->vec[0] = x;
self->vec[1] = y;
self->vec[2] = z;
@@ -177,405 +169,474 @@ PyObject *Vector_Resize4D(VectorObject *self)
self->size = 4;
}
- return EXPP_incr_ret(Py_None);
+ return EXPP_incr_ret( Py_None );
}
-static void Vector_dealloc(VectorObject *self)
+static void Vector_dealloc( VectorObject * self )
{
- /* if we own this memory we must delete it */
- if( self->delete_pymem )
- PyMem_Free( self->vec );
+ /* if we own this memory we must delete it */
+ if( self->delete_pymem )
+ PyMem_Free( self->vec );
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Vector_getattr(VectorObject *self, char *name)
+static PyObject *Vector_getattr( VectorObject * self, char *name )
{
- if (self->size==4 && ELEM4(name[0], 'x', 'y', 'z', 'w') && name[1]==0){
- if ((name[0]) == ('w')){
- return PyFloat_FromDouble(self->vec[3]);
- }else{
- return PyFloat_FromDouble(self->vec[name[0]-'x']);
+ if( self->size == 4 && ELEM4( name[0], 'x', 'y', 'z', 'w' )
+ && name[1] == 0 ) {
+ if( ( name[0] ) == ( 'w' ) ) {
+ return PyFloat_FromDouble( self->vec[3] );
+ } else {
+ return PyFloat_FromDouble( self->vec[name[0] - 'x'] );
}
- }
- else if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
- return PyFloat_FromDouble(self->vec[name[0]-'x']);
- else if (self->size==2 && ELEM(name[0], 'x', 'y') && name[1]==0)
- return PyFloat_FromDouble(self->vec[name[0]-'x']);
-
- if ((strcmp(name,"length") == 0)){
- if(self->size == 4){
- return PyFloat_FromDouble(sqrt(self->vec[0] * self->vec[0] +
- self->vec[1] * self->vec[1] +
- self->vec[2] * self->vec[2] +
- self->vec[3] * self->vec[3]));
- }
- else if(self->size == 3){
- return PyFloat_FromDouble(sqrt(self->vec[0] * self->vec[0] +
- self->vec[1] * self->vec[1] +
- self->vec[2] * self->vec[2]));
- }else if (self->size == 2){
- return PyFloat_FromDouble(sqrt(self->vec[0] * self->vec[0] +
- self->vec[1] * self->vec[1]));
- }else EXPP_ReturnPyObjError(PyExc_AttributeError,
- "can only return the length of a 2D ,3D or 4D vector\n");
+ } else if( self->size == 3 && ELEM3( name[0], 'x', 'y', 'z' )
+ && name[1] == 0 )
+ return PyFloat_FromDouble( self->vec[name[0] - 'x'] );
+ else if( self->size == 2 && ELEM( name[0], 'x', 'y' ) && name[1] == 0 )
+ return PyFloat_FromDouble( self->vec[name[0] - 'x'] );
+
+ if( ( strcmp( name, "length" ) == 0 ) ) {
+ if( self->size == 4 ) {
+ return PyFloat_FromDouble( sqrt
+ ( self->vec[0] *
+ self->vec[0] +
+ self->vec[1] *
+ self->vec[1] +
+ self->vec[2] *
+ self->vec[2] +
+ self->vec[3] *
+ self->vec[3] ) );
+ } else if( self->size == 3 ) {
+ return PyFloat_FromDouble( sqrt
+ ( self->vec[0] *
+ self->vec[0] +
+ self->vec[1] *
+ self->vec[1] +
+ self->vec[2] *
+ self->vec[2] ) );
+ } else if( self->size == 2 ) {
+ return PyFloat_FromDouble( sqrt
+ ( self->vec[0] *
+ self->vec[0] +
+ self->vec[1] *
+ self->vec[1] ) );
+ } else
+ EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "can only return the length of a 2D ,3D or 4D vector\n" );
}
- return Py_FindMethod(Vector_methods, (PyObject*)self, name);
+ return Py_FindMethod( Vector_methods, ( PyObject * ) self, name );
}
-static int Vector_setattr(VectorObject *self, char *name, PyObject *v)
+static int Vector_setattr( VectorObject * self, char *name, PyObject * v )
{
float val;
int valTemp;
- if(!PyFloat_Check(v)){
- if(!PyInt_Check(v)){
- return EXPP_ReturnIntError(PyExc_TypeError,"int or float expected\n");
- }else{
- if (!PyArg_Parse(v, "i", &valTemp))
- return EXPP_ReturnIntError(PyExc_TypeError, "unable to parse int argument\n");
- val = (float)valTemp;
+ if( !PyFloat_Check( v ) ) {
+ if( !PyInt_Check( v ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "int or float expected\n" );
+ } else {
+ if( !PyArg_Parse( v, "i", &valTemp ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "unable to parse int argument\n" );
+ val = ( float ) valTemp;
}
- }else{
- if (!PyArg_Parse(v, "f", &val))
- return EXPP_ReturnIntError(PyExc_TypeError, "unable to parse float argument\n");
+ } else {
+ if( !PyArg_Parse( v, "f", &val ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "unable to parse float argument\n" );
}
- if (self->size==4 && ELEM4(name[0], 'x', 'y', 'z', 'w') && name[1]==0){
- if ((name[0]) == ('w')){
- self->vec[3]= val;
- }else{
- self->vec[name[0]-'x']= val;
+ if( self->size == 4 && ELEM4( name[0], 'x', 'y', 'z', 'w' )
+ && name[1] == 0 ) {
+ if( ( name[0] ) == ( 'w' ) ) {
+ self->vec[3] = val;
+ } else {
+ self->vec[name[0] - 'x'] = val;
}
- }
- else if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
- self->vec[name[0]-'x']= val;
- else if (self->size==2 && ELEM(name[0], 'x', 'y') && name[1]==0)
- self->vec[name[0]-'x']= val;
- else return -1;
+ } else if( self->size == 3 && ELEM3( name[0], 'x', 'y', 'z' )
+ && name[1] == 0 )
+ self->vec[name[0] - 'x'] = val;
+ else if( self->size == 2 && ELEM( name[0], 'x', 'y' ) && name[1] == 0 )
+ self->vec[name[0] - 'x'] = val;
+ else
+ return -1;
return 0;
}
/* Vectors Sequence methods */
-static int Vector_len(VectorObject *self)
+static int Vector_len( VectorObject * self )
{
return self->size;
}
-static PyObject *Vector_item(VectorObject *self, int i)
+static PyObject *Vector_item( VectorObject * self, int i )
{
- if (i < 0 || i >= self->size)
- return EXPP_ReturnPyObjError (PyExc_IndexError, "array index out of range\n");
+ if( i < 0 || i >= self->size )
+ return EXPP_ReturnPyObjError( PyExc_IndexError,
+ "array index out of range\n" );
- return Py_BuildValue("f", self->vec[i]);
+ return Py_BuildValue( "f", self->vec[i] );
}
-static PyObject *Vector_slice(VectorObject *self, int begin, int end)
+static PyObject *Vector_slice( VectorObject * self, int begin, int end )
{
PyObject *list;
int count;
-
- if (begin < 0) begin= 0;
- if (end > self->size) end= self->size;
- if (begin > end) begin= end;
- list= PyList_New(end-begin);
+ if( begin < 0 )
+ begin = 0;
+ if( end > self->size )
+ end = self->size;
+ if( begin > end )
+ begin = end;
- for (count = begin; count < end; count++){
- PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->vec[count]));
+ list = PyList_New( end - begin );
+
+ for( count = begin; count < end; count++ ) {
+ PyList_SetItem( list, count - begin,
+ PyFloat_FromDouble( self->vec[count] ) );
}
return list;
}
-static int Vector_ass_item(VectorObject *self, int i, PyObject *ob)
+static int Vector_ass_item( VectorObject * self, int i, PyObject * ob )
{
- if (i < 0 || i >= self->size)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range\n");
- if (!PyInt_Check(ob) && !PyFloat_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "vector member must be a number\n");
+ if( i < 0 || i >= self->size )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "array assignment index out of range\n" );
+ if( !PyInt_Check( ob ) && !PyFloat_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "vector member must be a number\n" );
- self->vec[i]= (float)PyFloat_AsDouble(ob);
+ self->vec[i] = ( float ) PyFloat_AsDouble( ob );
return 0;
}
-static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq)
+static int Vector_ass_slice( VectorObject * self, int begin, int end,
+ PyObject * seq )
{
int count, z;
- if (begin < 0) begin= 0;
- if (end > self->size) end= self->size;
- if (begin > end) begin= end;
+ if( begin < 0 )
+ begin = 0;
+ if( end > self->size )
+ end = self->size;
+ if( begin > end )
+ begin = end;
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation\n");
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment\n");
+ if( !PySequence_Check( seq ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "illegal argument type for built-in operation\n" );
+ if( PySequence_Length( seq ) != ( end - begin ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "size mismatch in slice assignment\n" );
z = 0;
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, z); z++;
- if (!PyInt_Check(ob) && !PyFloat_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "list member must be a number\n");
-
- if (!PyArg_Parse(ob, "f", &self->vec[count])){
- Py_DECREF(ob);
+ for( count = begin; count < end; count++ ) {
+ PyObject *ob = PySequence_GetItem( seq, z );
+ z++;
+ if( !PyInt_Check( ob ) && !PyFloat_Check( ob ) )
+ return EXPP_ReturnIntError( PyExc_IndexError,
+ "list member must be a number\n" );
+
+ if( !PyArg_Parse( ob, "f", &self->vec[count] ) ) {
+ Py_DECREF( ob );
return -1;
}
}
- return 0;
+ return 0;
}
-static PyObject *Vector_repr (VectorObject *self)
+static PyObject *Vector_repr( VectorObject * self )
{
int i, maxindex = self->size - 1;
char ftoa[24];
PyObject *str1, *str2;
- str1 = PyString_FromString ("[");
+ str1 = PyString_FromString( "[" );
- for (i = 0; i < maxindex; i++) {
- sprintf(ftoa, "%.4f, ", self->vec[i]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ for( i = 0; i < maxindex; i++ ) {
+ sprintf( ftoa, "%.4f, ", self->vec[i] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
}
- sprintf(ftoa, "%.4f]", self->vec[maxindex]);
- str2 = PyString_FromString (ftoa);
- if (!str1 || !str2) goto error;
- PyString_ConcatAndDel (&str1, str2);
+ sprintf( ftoa, "%.4f]", self->vec[maxindex] );
+ str2 = PyString_FromString( ftoa );
+ if( !str1 || !str2 )
+ goto error;
+ PyString_ConcatAndDel( &str1, str2 );
- if (str1) return str1;
+ if( str1 )
+ return str1;
-error:
- Py_XDECREF (str1);
- Py_XDECREF (str2);
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyString!\n");
+ error:
+ Py_XDECREF( str1 );
+ Py_XDECREF( str2 );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyString!\n" );
}
-PyObject * Vector_add(PyObject *v1, PyObject *v2)
+PyObject *Vector_add( PyObject * v1, PyObject * v2 )
{
- float * vec;
+ float *vec;
int x;
- if((!VectorObject_Check(v1)) || (!VectorObject_Check(v2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((VectorObject*)v1)->flag != 0 || ((VectorObject*)v2)->flag != 0)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "cannot add a scalar to a vector\n");
- if(((VectorObject*)v1)->size != ((VectorObject*)v2)->size)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "vectors must have the same dimensions for this operation\n");
-
- vec = PyMem_Malloc ((((VectorObject*)v1)->size)*sizeof (float));
-
- for(x = 0; x < ((VectorObject*)v1)->size; x++){
- vec[x] = ((VectorObject*)v1)->vec[x] + ((VectorObject*)v2)->vec[x];
+ if( ( !VectorObject_Check( v1 ) ) || ( !VectorObject_Check( v2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( VectorObject * ) v1 )->flag != 0
+ || ( ( VectorObject * ) v2 )->flag != 0 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "cannot add a scalar to a vector\n" );
+ if( ( ( VectorObject * ) v1 )->size !=
+ ( ( VectorObject * ) v2 )->size )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "vectors must have the same dimensions for this operation\n" );
+
+ vec = PyMem_Malloc( ( ( ( VectorObject * ) v1 )->size ) *
+ sizeof( float ) );
+
+ for( x = 0; x < ( ( VectorObject * ) v1 )->size; x++ ) {
+ vec[x] = ( ( VectorObject * ) v1 )->vec[x] +
+ ( ( VectorObject * ) v2 )->vec[x];
}
-
- return (PyObject*)newVectorObject(vec, (((VectorObject*)v1)->size));
+
+ return ( PyObject * ) newVectorObject( vec,
+ ( ( ( VectorObject * ) v1 )->
+ size ) );
}
-PyObject * Vector_sub(PyObject *v1, PyObject *v2)
+PyObject *Vector_sub( PyObject * v1, PyObject * v2 )
{
- float * vec;
+ float *vec;
int x;
- if((!VectorObject_Check(v1)) || (!VectorObject_Check(v2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((VectorObject*)v1)->flag != 0 || ((VectorObject*)v2)->flag != 0)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "cannot subtract a scalar from a vector\n");
- if(((VectorObject*)v1)->size != ((VectorObject*)v2)->size)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "vectors must have the same dimensions for this operation\n");
-
- vec = PyMem_Malloc ((((VectorObject*)v1)->size)*sizeof (float));
-
- for(x = 0; x < ((VectorObject*)v1)->size; x++){
- vec[x] = ((VectorObject*)v1)->vec[x] - ((VectorObject*)v2)->vec[x];
+ if( ( !VectorObject_Check( v1 ) ) || ( !VectorObject_Check( v2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( VectorObject * ) v1 )->flag != 0
+ || ( ( VectorObject * ) v2 )->flag != 0 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "cannot subtract a scalar from a vector\n" );
+ if( ( ( VectorObject * ) v1 )->size !=
+ ( ( VectorObject * ) v2 )->size )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "vectors must have the same dimensions for this operation\n" );
+
+ vec = PyMem_Malloc( ( ( ( VectorObject * ) v1 )->size ) *
+ sizeof( float ) );
+
+ for( x = 0; x < ( ( VectorObject * ) v1 )->size; x++ ) {
+ vec[x] = ( ( VectorObject * ) v1 )->vec[x] -
+ ( ( VectorObject * ) v2 )->vec[x];
}
-
- return (PyObject*)newVectorObject(vec, (((VectorObject*)v1)->size));
+
+ return ( PyObject * ) newVectorObject( vec,
+ ( ( ( VectorObject * ) v1 )->
+ size ) );
}
-PyObject * Vector_mul(PyObject *v1, PyObject * v2)
+PyObject *Vector_mul( PyObject * v1, PyObject * v2 )
{
- float * vec;
+ float *vec;
int x;
- if((!VectorObject_Check(v1)) || (!VectorObject_Check(v2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((VectorObject*)v1)->flag == 0 && ((VectorObject*)v2)->flag == 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "please use the dot product or the cross product to multiply vectors\n");
- if(((VectorObject*)v1)->size != ((VectorObject*)v2)->size)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "vector dimension error during Vector_mul\n");
-
- vec = PyMem_Malloc ((((VectorObject*)v1)->size)*sizeof(float));
-
- for(x = 0; x < ((VectorObject*)v1)->size; x++){
- vec[x] = ((VectorObject*)v1)->vec[x] * ((VectorObject*)v2)->vec[x];
+ if( ( !VectorObject_Check( v1 ) ) || ( !VectorObject_Check( v2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( VectorObject * ) v1 )->flag == 0
+ && ( ( VectorObject * ) v2 )->flag == 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "please use the dot product or the cross product to multiply vectors\n" );
+ if( ( ( VectorObject * ) v1 )->size !=
+ ( ( VectorObject * ) v2 )->size )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "vector dimension error during Vector_mul\n" );
+
+ vec = PyMem_Malloc( ( ( ( VectorObject * ) v1 )->size ) *
+ sizeof( float ) );
+
+ for( x = 0; x < ( ( VectorObject * ) v1 )->size; x++ ) {
+ vec[x] = ( ( VectorObject * ) v1 )->vec[x] *
+ ( ( VectorObject * ) v2 )->vec[x];
}
-
- return (PyObject*)newVectorObject(vec, (((VectorObject*)v1)->size));
+
+ return ( PyObject * ) newVectorObject( vec,
+ ( ( ( VectorObject * ) v1 )->
+ size ) );
}
-PyObject * Vector_div(PyObject *v1, PyObject * v2)
+PyObject *Vector_div( PyObject * v1, PyObject * v2 )
{
- float * vec;
+ float *vec;
int x;
- if((!VectorObject_Check(v1)) || (!VectorObject_Check(v2)))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "unsupported type for this operation\n");
- if(((VectorObject*)v1)->flag == 0 && ((VectorObject*)v2)->flag == 0)
- return EXPP_ReturnPyObjError (PyExc_ArithmeticError,
- "cannot divide two vectors\n");
- if(((VectorObject*)v1)->flag != 0 && ((VectorObject*)v2)->flag == 0)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "cannot divide a scalar by a vector\n");
- if(((VectorObject*)v1)->size != ((VectorObject*)v2)->size)
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "vector dimension error during Vector_mul\n");
-
- vec = PyMem_Malloc ((((VectorObject*)v1)->size)*sizeof(float));
-
- for(x = 0; x < ((VectorObject*)v1)->size; x++){
- vec[x] = ((VectorObject*)v1)->vec[x] / ((VectorObject*)v2)->vec[x];
+ if( ( !VectorObject_Check( v1 ) ) || ( !VectorObject_Check( v2 ) ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "unsupported type for this operation\n" );
+ if( ( ( VectorObject * ) v1 )->flag == 0
+ && ( ( VectorObject * ) v2 )->flag == 0 )
+ return EXPP_ReturnPyObjError( PyExc_ArithmeticError,
+ "cannot divide two vectors\n" );
+ if( ( ( VectorObject * ) v1 )->flag != 0
+ && ( ( VectorObject * ) v2 )->flag == 0 )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "cannot divide a scalar by a vector\n" );
+ if( ( ( VectorObject * ) v1 )->size !=
+ ( ( VectorObject * ) v2 )->size )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "vector dimension error during Vector_mul\n" );
+
+ vec = PyMem_Malloc( ( ( ( VectorObject * ) v1 )->size ) *
+ sizeof( float ) );
+
+ for( x = 0; x < ( ( VectorObject * ) v1 )->size; x++ ) {
+ vec[x] = ( ( VectorObject * ) v1 )->vec[x] /
+ ( ( VectorObject * ) v2 )->vec[x];
}
-
- return (PyObject*)newVectorObject(vec, (((VectorObject*)v1)->size));
+
+ return ( PyObject * ) newVectorObject( vec,
+ ( ( ( VectorObject * ) v1 )->
+ size ) );
}
//coercion of unknown types to type VectorObject for numeric protocols
-int Vector_coerce(PyObject **v1, PyObject **v2)
-{
+int Vector_coerce( PyObject ** v1, PyObject ** v2 )
+{
long *tempI;
double *tempF;
float *vec;
int x;
- if (VectorObject_Check(*v1)) {
- if (VectorObject_Check(*v2)) { //two vectors
- Py_INCREF(*v1);
- Py_INCREF(*v2);
+ if( VectorObject_Check( *v1 ) ) {
+ if( VectorObject_Check( *v2 ) ) { //two vectors
+ Py_INCREF( *v1 );
+ Py_INCREF( *v2 );
return 0;
- }else{
- if(Matrix_CheckPyObject(*v2)){
- printf("vector/matrix numeric protocols unsupported...\n");
- Py_INCREF(*v1);
- return 0; //operation will type check
- }else if(PyNumber_Check(*v2)){
- if(PyInt_Check(*v2)){ //cast scalar to vector
- tempI = PyMem_Malloc(1*sizeof(long));
- *tempI = PyInt_AsLong(*v2);
- vec = PyMem_Malloc ((((VectorObject*)*v1)->size)*sizeof (float));
- for(x = 0; x < (((VectorObject*)*v1)->size); x++){
- vec[x] = (float)*tempI;
+ } else {
+ if( Matrix_CheckPyObject( *v2 ) ) {
+ printf( "vector/matrix numeric protocols unsupported...\n" );
+ Py_INCREF( *v1 );
+ return 0; //operation will type check
+ } else if( PyNumber_Check( *v2 ) ) {
+ if( PyInt_Check( *v2 ) ) { //cast scalar to vector
+ tempI = PyMem_Malloc( 1 *
+ sizeof( long ) );
+ *tempI = PyInt_AsLong( *v2 );
+ vec = PyMem_Malloc( ( ( ( VectorObject
+ * ) *
+ v1 )->size ) *
+ sizeof( float ) );
+ for( x = 0;
+ x <
+ ( ( ( VectorObject * ) *
+ v1 )->size ); x++ ) {
+ vec[x] = ( float ) *tempI;
}
- PyMem_Free(tempI);
- *v2 = newVectorObject(vec, (((VectorObject*)*v1)->size));
- ((VectorObject*)*v2)->flag = 1; //int coercion
- Py_INCREF(*v1);
+ PyMem_Free( tempI );
+ *v2 = newVectorObject( vec,
+ ( ( ( VectorObject * ) * v1 )->size ) );
+ ( ( VectorObject * ) * v2 )->flag = 1; //int coercion
+ Py_INCREF( *v1 );
return 0;
- }else if(PyFloat_Check(*v2)){ //cast scalar to vector
- tempF = PyMem_Malloc(1*sizeof(double));
- *tempF = PyFloat_AsDouble(*v2);
- vec = PyMem_Malloc ((((VectorObject*)*v1)->size)*sizeof (float));
- for(x = 0; x < (((VectorObject*)*v1)->size); x++){
- vec[x] = (float)*tempF;
+ } else if( PyFloat_Check( *v2 ) ) { //cast scalar to vector
+ tempF = PyMem_Malloc( 1 *
+ sizeof
+ ( double ) );
+ *tempF = PyFloat_AsDouble( *v2 );
+ vec = PyMem_Malloc( ( ( ( VectorObject
+ * ) *
+ v1 )->size ) *
+ sizeof( float ) );
+ for( x = 0;
+ x <
+ ( ( ( VectorObject * ) *
+ v1 )->size ); x++ ) {
+ vec[x] = ( float ) *tempF;
}
- PyMem_Free(tempF);
- *v2 = newVectorObject(vec, (((VectorObject*)*v1)->size));
- ((VectorObject*)*v2)->flag = 2; //float coercion
- Py_INCREF(*v1);
+ PyMem_Free( tempF );
+ *v2 = newVectorObject( vec,
+ ( ( ( VectorObject * ) * v1 )->size ) );
+ ( ( VectorObject * ) * v2 )->flag = 2; //float coercion
+ Py_INCREF( *v1 );
return 0;
}
}
//unknown type or numeric cast failure
- printf("attempting vector operation with unsupported type...\n");
- Py_INCREF(*v1);
- return 0; //operation will type check
+ printf( "attempting vector operation with unsupported type...\n" );
+ Py_INCREF( *v1 );
+ return 0; //operation will type check
}
- }else{
- printf("numeric protocol failure...\n");
- return -1; //this should not occur - fail
+ } else {
+ printf( "numeric protocol failure...\n" );
+ return -1; //this should not occur - fail
}
return -1;
}
-static PySequenceMethods Vector_SeqMethods =
-{
- (inquiry) Vector_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Vector_item, /* sq_item */
- (intintargfunc) Vector_slice, /* sq_slice */
- (intobjargproc) Vector_ass_item, /* sq_ass_item */
- (intintobjargproc) Vector_ass_slice, /* sq_ass_slice */
+static PySequenceMethods Vector_SeqMethods = {
+ ( inquiry ) Vector_len, /* sq_length */
+ ( binaryfunc ) 0, /* sq_concat */
+ ( intargfunc ) 0, /* sq_repeat */
+ ( intargfunc ) Vector_item, /* sq_item */
+ ( intintargfunc ) Vector_slice, /* sq_slice */
+ ( intobjargproc ) Vector_ass_item, /* sq_ass_item */
+ ( intintobjargproc ) Vector_ass_slice, /* sq_ass_slice */
};
-static PyNumberMethods Vector_NumMethods =
-{
- (binaryfunc) Vector_add, /* __add__ */
- (binaryfunc) Vector_sub, /* __sub__ */
- (binaryfunc) Vector_mul, /* __mul__ */
- (binaryfunc) Vector_div, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- (coercion) Vector_coerce, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
+static PyNumberMethods Vector_NumMethods = {
+ ( binaryfunc ) Vector_add, /* __add__ */
+ ( binaryfunc ) Vector_sub, /* __sub__ */
+ ( binaryfunc ) Vector_mul, /* __mul__ */
+ ( binaryfunc ) Vector_div, /* __div__ */
+ ( binaryfunc ) 0, /* __mod__ */
+ ( binaryfunc ) 0, /* __divmod__ */
+ ( ternaryfunc ) 0, /* __pow__ */
+ ( unaryfunc ) 0, /* __neg__ */
+ ( unaryfunc ) 0, /* __pos__ */
+ ( unaryfunc ) 0, /* __abs__ */
+ ( inquiry ) 0, /* __nonzero__ */
+ ( unaryfunc ) 0, /* __invert__ */
+ ( binaryfunc ) 0, /* __lshift__ */
+ ( binaryfunc ) 0, /* __rshift__ */
+ ( binaryfunc ) 0, /* __and__ */
+ ( binaryfunc ) 0, /* __xor__ */
+ ( binaryfunc ) 0, /* __or__ */
+ ( coercion ) Vector_coerce, /* __coerce__ */
+ ( unaryfunc ) 0, /* __int__ */
+ ( unaryfunc ) 0, /* __long__ */
+ ( unaryfunc ) 0, /* __float__ */
+ ( unaryfunc ) 0, /* __oct__ */
+ ( unaryfunc ) 0, /* __hex__ */
};
-PyTypeObject vector_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "vector", /*tp_name*/
- sizeof(VectorObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Vector_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Vector_getattr, /*tp_getattr*/
- (setattrfunc) Vector_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Vector_repr, /*tp_repr*/
- &Vector_NumMethods, /*tp_as_number*/
- &Vector_SeqMethods, /*tp_as_sequence*/
+PyTypeObject vector_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "vector", /*tp_name */
+ sizeof( VectorObject ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ ( destructor ) Vector_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) Vector_getattr, /*tp_getattr */
+ ( setattrfunc ) Vector_setattr, /*tp_setattr */
+ 0, /*tp_compare */
+ ( reprfunc ) Vector_repr, /*tp_repr */
+ &Vector_NumMethods, /*tp_as_number */
+ &Vector_SeqMethods, /*tp_as_sequence */
};
@@ -587,30 +648,30 @@ PyTypeObject vector_Type =
* size arg is number of floats to alloc.
*/
-PyObject *newVectorObject(float *vec, int size)
+PyObject *newVectorObject( float *vec, int size )
{
- VectorObject *self;
- int x;
-
- vector_Type.ob_type = &PyType_Type;
-
- self = PyObject_NEW(VectorObject, &vector_Type);
-
- if(!vec){
- self->vec = PyMem_Malloc (size *sizeof (float));
- for(x = 0; x < size; x++){
- self->vec[x] = 0.0f;
- }
- if(size == 4) self->vec[3] = 1.0f;
- self->delete_pymem = 1; /* must free this alloc later */
- }else{
- self->vec = vec;
- self->delete_pymem = 0;
- }
-
- self->size = size;
- self->flag = 0;
-
- return (PyObject*) self;
-}
+ VectorObject *self;
+ int x;
+
+ vector_Type.ob_type = &PyType_Type;
+
+ self = PyObject_NEW( VectorObject, &vector_Type );
+
+ if( !vec ) {
+ self->vec = PyMem_Malloc( size * sizeof( float ) );
+ for( x = 0; x < size; x++ ) {
+ self->vec[x] = 0.0f;
+ }
+ if( size == 4 )
+ self->vec[3] = 1.0f;
+ self->delete_pymem = 1; /* must free this alloc later */
+ } else {
+ self->vec = vec;
+ self->delete_pymem = 0;
+ }
+ self->size = size;
+ self->flag = 0;
+
+ return ( PyObject * ) self;
+}
diff --git a/source/blender/python/api2_2x/vector.h b/source/blender/python/api2_2x/vector.h
index 733602f2f12..cf07b5ce78e 100644
--- a/source/blender/python/api2_2x/vector.h
+++ b/source/blender/python/api2_2x/vector.h
@@ -50,24 +50,22 @@
#define VectorObject_Check(v) ((v)->ob_type == &vector_Type)
typedef struct {
- PyObject_VAR_HEAD
- float * vec;
+ PyObject_VAR_HEAD float *vec;
int size;
int flag;
- //0 - no coercion
- //1 - coerced from int
- //2 - coerced from float
- int delete_pymem; /* do we need to delete the memory vec points at? */
+ //0 - no coercion
+ //1 - coerced from int
+ //2 - coerced from float
+ int delete_pymem; /* flag to delete the memory vec points at */
} VectorObject;
//prototypes
-PyObject *newVectorObject(float *vec, int size);
-PyObject *Vector_Zero(VectorObject *self);
-PyObject *Vector_Normalize(VectorObject *self);
-PyObject *Vector_Negate(VectorObject *self);
-PyObject *Vector_Resize2D(VectorObject *self);
-PyObject *Vector_Resize3D(VectorObject *self);
-PyObject *Vector_Resize4D(VectorObject *self);
-
-#endif /* EXPP_vector_h */
+PyObject *newVectorObject( float *vec, int size );
+PyObject *Vector_Zero( VectorObject * self );
+PyObject *Vector_Normalize( VectorObject * self );
+PyObject *Vector_Negate( VectorObject * self );
+PyObject *Vector_Resize2D( VectorObject * self );
+PyObject *Vector_Resize3D( VectorObject * self );
+PyObject *Vector_Resize4D( VectorObject * self );
+#endif /* EXPP_vector_h */
diff --git a/source/blender/python/api2_2x/windowTheme.c b/source/blender/python/api2_2x/windowTheme.c
index 56901520fb9..3bd7ac1a1c7 100644
--- a/source/blender/python/api2_2x/windowTheme.c
+++ b/source/blender/python/api2_2x/windowTheme.c
@@ -60,15 +60,14 @@ static const EXPP_map_pair themes_map[] = {
{"oops", SPACE_OOPS},
{NULL, 0}
};
-
-static PyObject *M_Theme_New (PyObject *self, PyObject *args);
-static PyObject *M_Theme_Get (PyObject *self, PyObject *args);
+
+static PyObject *M_Theme_New( PyObject * self, PyObject * args );
+static PyObject *M_Theme_Get( PyObject * self, PyObject * args );
static char M_Theme_doc[] = "The Blender Theme module\n\n\
This module provides access to UI Theme data in Blender";
-static char M_Theme_New_doc[] =
-"Theme.New (name = 'New Theme'):\n\
+static char M_Theme_New_doc[] = "Theme.New (name = 'New Theme'):\n\
Return a new Theme Data object with the given type and name.";
static char M_Theme_Get_doc[] = "Theme.Get (name = None):\n\
@@ -76,7 +75,7 @@ static char M_Theme_Get_doc[] = "Theme.Get (name = None):\n\
Return a list with all Theme Data objects if no argument was given.";
/*****************************************************************************/
-/* Python method structure definition for Blender.Theme module: */
+/* Python method structure definition for Blender.Theme module: */
/*****************************************************************************/
struct PyMethodDef M_Theme_methods[] = {
{"New", M_Theme_New, METH_VARARGS, M_Theme_New_doc},
@@ -84,42 +83,43 @@ struct PyMethodDef M_Theme_methods[] = {
{NULL, NULL, 0, NULL}
};
-static void ThemeSpace_dealloc (BPy_ThemeSpace *self);
-static int ThemeSpace_compare (BPy_ThemeSpace *a, BPy_ThemeSpace *b);
-static PyObject *ThemeSpace_repr (BPy_ThemeSpace *self);
-static PyObject *ThemeSpace_getAttr (BPy_ThemeSpace *self, char *name);
-static int ThemeSpace_setAttr (BPy_ThemeSpace *self, char *name, PyObject *val);
+static void ThemeSpace_dealloc( BPy_ThemeSpace * self );
+static int ThemeSpace_compare( BPy_ThemeSpace * a, BPy_ThemeSpace * b );
+static PyObject *ThemeSpace_repr( BPy_ThemeSpace * self );
+static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name );
+static int ThemeSpace_setAttr( BPy_ThemeSpace * self, char *name,
+ PyObject * val );
static PyMethodDef BPy_ThemeSpace_methods[] = {
{NULL, NULL, 0, NULL}
};
PyTypeObject ThemeSpace_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Space Theme", /* tp_name */
- sizeof (BPy_Theme), /* tp_basicsize */
- 0, /* tp_itemsize */
+ PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
+ "Blender Space Theme", /* tp_name */
+ sizeof( BPy_Theme ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor) ThemeSpace_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) ThemeSpace_getAttr, /* tp_getattr */
- (setattrfunc) ThemeSpace_setAttr, /* tp_setattr */
- (cmpfunc) ThemeSpace_compare, /* tp_compare */
- (reprfunc) ThemeSpace_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
+ ( destructor ) ThemeSpace_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) ThemeSpace_getAttr, /* tp_getattr */
+ ( setattrfunc ) ThemeSpace_setAttr, /* tp_setattr */
+ ( cmpfunc ) ThemeSpace_compare, /* tp_compare */
+ ( reprfunc ) ThemeSpace_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, /* tp_doc */
0, 0, 0, 0, 0, 0,
- 0, //BPy_ThemeSpace_methods, /* tp_methods */
- 0, /* tp_members */
+ 0, //BPy_ThemeSpace_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static void ThemeSpace_dealloc (BPy_ThemeSpace *self)
+static void ThemeSpace_dealloc( BPy_ThemeSpace * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
#define ELSEIF_TSP_RGBA(attr)\
@@ -131,163 +131,171 @@ static void ThemeSpace_dealloc (BPy_ThemeSpace *self)
* attr = charRGBA_New(&tsp->back[0])
*/
-static PyObject *ThemeSpace_getAttr (BPy_ThemeSpace *self, char *name)
+static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name )
{
PyObject *attrib = Py_None;
ThemeSpace *tsp = self->tsp;
- if (!strcmp (name, "theme"))
- attrib = PyString_FromString (self->theme->name);
- ELSEIF_TSP_RGBA(back)
- ELSEIF_TSP_RGBA(text)
- ELSEIF_TSP_RGBA(text_hi)
- ELSEIF_TSP_RGBA(header)
- ELSEIF_TSP_RGBA(panel)
- ELSEIF_TSP_RGBA(shade1)
- ELSEIF_TSP_RGBA(shade2)
- ELSEIF_TSP_RGBA(hilite)
- ELSEIF_TSP_RGBA(grid)
- ELSEIF_TSP_RGBA(wire)
- ELSEIF_TSP_RGBA(select)
- ELSEIF_TSP_RGBA(active)
- ELSEIF_TSP_RGBA(transform)
- ELSEIF_TSP_RGBA(vertex)
- ELSEIF_TSP_RGBA(vertex_select)
- ELSEIF_TSP_RGBA(edge)
- ELSEIF_TSP_RGBA(edge_select)
- ELSEIF_TSP_RGBA(edge_seam)
- ELSEIF_TSP_RGBA(edge_facesel)
- ELSEIF_TSP_RGBA(face)
- ELSEIF_TSP_RGBA(face_select)
- ELSEIF_TSP_RGBA(normal)
- else if (!strcmp (name, "vertex_size"))
- attrib = Py_BuildValue("i", tsp->vertex_size);
- else if (!strcmp (name, "__members__"))
- attrib = Py_BuildValue("[ssssssssssssssssssssssss]", "theme",
- "back", "text", "text_hi", "header", "panel", "shade1", "shade2",
- "hilite", "grid", "wire", "select", "active", "transform",
- "vertex", "vertex_select", "edge", "edge_select", "edge_seam",
- "edge_facesel", "face", "face_select", "normal", "vertex_size");
-
- if (attrib != Py_None) return attrib;
-
- return Py_FindMethod(BPy_ThemeSpace_methods, (PyObject *)self, name);
+ if( !strcmp( name, "theme" ) )
+ attrib = PyString_FromString( self->theme->name );
+ ELSEIF_TSP_RGBA( back )
+ ELSEIF_TSP_RGBA( text )
+ ELSEIF_TSP_RGBA( text_hi )
+ ELSEIF_TSP_RGBA( header )
+ ELSEIF_TSP_RGBA( panel )
+ ELSEIF_TSP_RGBA( shade1 )
+ ELSEIF_TSP_RGBA( shade2 )
+ ELSEIF_TSP_RGBA( hilite )
+ ELSEIF_TSP_RGBA( grid )
+ ELSEIF_TSP_RGBA( wire )
+ ELSEIF_TSP_RGBA( select )
+ ELSEIF_TSP_RGBA( active )
+ ELSEIF_TSP_RGBA( transform )
+ ELSEIF_TSP_RGBA( vertex )
+ ELSEIF_TSP_RGBA( vertex_select )
+ ELSEIF_TSP_RGBA( edge )
+ ELSEIF_TSP_RGBA( edge_select )
+ ELSEIF_TSP_RGBA( edge_seam )
+ ELSEIF_TSP_RGBA( edge_facesel )
+ ELSEIF_TSP_RGBA( face )
+ ELSEIF_TSP_RGBA( face_select )
+ ELSEIF_TSP_RGBA( normal )
+ else if( !strcmp( name, "vertex_size" ) )
+ attrib = Py_BuildValue( "i", tsp->vertex_size );
+ else if( !strcmp( name, "__members__" ) )
+ attrib = Py_BuildValue( "[ssssssssssssssssssssssss]", "theme",
+ "back", "text", "text_hi", "header",
+ "panel", "shade1", "shade2", "hilite",
+ "grid", "wire", "select", "active",
+ "transform", "vertex", "vertex_select",
+ "edge", "edge_select", "edge_seam",
+ "edge_facesel", "face", "face_select",
+ "normal", "vertex_size" );
+
+ if( attrib != Py_None )
+ return attrib;
+
+ return Py_FindMethod( BPy_ThemeSpace_methods, ( PyObject * ) self,
+ name );
}
-static int ThemeSpace_setAttr (BPy_ThemeSpace *self, char *name,
- PyObject *value)
+static int ThemeSpace_setAttr( BPy_ThemeSpace * self, char *name,
+ PyObject * value )
{
PyObject *attrib = NULL;
ThemeSpace *tsp = self->tsp;
int ret = -1;
- if (!strcmp (name, "back"))
- attrib = charRGBA_New(&tsp->back[0]);
- ELSEIF_TSP_RGBA(back)
- ELSEIF_TSP_RGBA(text)
- ELSEIF_TSP_RGBA(text_hi)
- ELSEIF_TSP_RGBA(header)
- ELSEIF_TSP_RGBA(panel)
- ELSEIF_TSP_RGBA(shade1)
- ELSEIF_TSP_RGBA(shade2)
- ELSEIF_TSP_RGBA(hilite)
- ELSEIF_TSP_RGBA(grid)
- ELSEIF_TSP_RGBA(wire)
- ELSEIF_TSP_RGBA(select)
- ELSEIF_TSP_RGBA(active)
- ELSEIF_TSP_RGBA(transform)
- ELSEIF_TSP_RGBA(vertex)
- ELSEIF_TSP_RGBA(vertex_select)
- ELSEIF_TSP_RGBA(edge)
- ELSEIF_TSP_RGBA(edge_select)
- ELSEIF_TSP_RGBA(edge_seam)
- ELSEIF_TSP_RGBA(edge_facesel)
- ELSEIF_TSP_RGBA(face)
- ELSEIF_TSP_RGBA(face_select)
- ELSEIF_TSP_RGBA(normal)
- else if (!strcmp (name, "vertex_size")) {
+ if( !strcmp( name, "back" ) )
+ attrib = charRGBA_New( &tsp->back[0] );
+ ELSEIF_TSP_RGBA( back )
+ ELSEIF_TSP_RGBA( text )
+ ELSEIF_TSP_RGBA( text_hi )
+ ELSEIF_TSP_RGBA( header )
+ ELSEIF_TSP_RGBA( panel )
+ ELSEIF_TSP_RGBA( shade1 )
+ ELSEIF_TSP_RGBA( shade2 )
+ ELSEIF_TSP_RGBA( hilite )
+ ELSEIF_TSP_RGBA( grid )
+ ELSEIF_TSP_RGBA( wire )
+ ELSEIF_TSP_RGBA( select )
+ ELSEIF_TSP_RGBA( active )
+ ELSEIF_TSP_RGBA( transform )
+ ELSEIF_TSP_RGBA( vertex )
+ ELSEIF_TSP_RGBA( vertex_select )
+ ELSEIF_TSP_RGBA( edge )
+ ELSEIF_TSP_RGBA( edge_select )
+ ELSEIF_TSP_RGBA( edge_seam )
+ ELSEIF_TSP_RGBA( edge_facesel )
+ ELSEIF_TSP_RGBA( face )
+ ELSEIF_TSP_RGBA( face_select )
+ ELSEIF_TSP_RGBA( normal )
+ else if( !strcmp( name, "vertex_size" ) ) {
int val;
- if (!PyInt_Check(value))
- return EXPP_ReturnIntError (PyExc_TypeError, "expected integer value");
+ if( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected integer value" );
- val = (int)PyInt_AsLong(value);
- tsp->vertex_size = EXPP_ClampInt(val,
- EXPP_THEME_VTX_SIZE_MIN, EXPP_THEME_VTX_SIZE_MAX);
+ val = ( int ) PyInt_AsLong( value );
+ tsp->vertex_size = EXPP_ClampInt( val,
+ EXPP_THEME_VTX_SIZE_MIN,
+ EXPP_THEME_VTX_SIZE_MAX );
ret = 0;
- }
- else
- return EXPP_ReturnIntError (PyExc_AttributeError, "attribute not found");
+ } else
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "attribute not found" );
- if (attrib) {
+ if( attrib ) {
PyObject *pyret = NULL;
- PyObject *valtuple = Py_BuildValue("(O)", value);
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError, "couldn't create tuple!");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "couldn't create tuple!" );
- pyret = charRGBA_setCol((BPy_charRGBA *)attrib, valtuple);
- Py_DECREF(valtuple);
+ pyret = charRGBA_setCol( ( BPy_charRGBA * ) attrib, valtuple );
+ Py_DECREF( valtuple );
- if (pyret == Py_None) {
- Py_DECREF (Py_None); /* was increfed by charRGBA_setCol */
+ if( pyret == Py_None ) {
+ Py_DECREF( Py_None ); /* was increfed by charRGBA_setCol */
ret = 0;
}
- Py_DECREF(attrib); /* we're done with it */
+ Py_DECREF( attrib ); /* we're done with it */
}
- return ret; /* 0 if all went well */
+ return ret; /* 0 if all went well */
}
-static int ThemeSpace_compare (BPy_ThemeSpace *a, BPy_ThemeSpace *b)
+static int ThemeSpace_compare( BPy_ThemeSpace * a, BPy_ThemeSpace * b )
{
ThemeSpace *pa = a->tsp, *pb = b->tsp;
- return (pa == pb) ? 0 : -1;
+ return ( pa == pb ) ? 0 : -1;
}
-static PyObject *ThemeSpace_repr (BPy_ThemeSpace *self)
+static PyObject *ThemeSpace_repr( BPy_ThemeSpace * self )
{
- return PyString_FromFormat ("[Space theme from theme \"%s\"]",
- self->theme->name);
+ return PyString_FromFormat( "[Space theme from theme \"%s\"]",
+ self->theme->name );
}
-static void ThemeUI_dealloc (BPy_ThemeUI *self);
-static int ThemeUI_compare (BPy_ThemeUI *a, BPy_ThemeUI *b);
-static PyObject *ThemeUI_repr (BPy_ThemeUI *self);
-static PyObject *ThemeUI_getAttr (BPy_ThemeUI *self, char *name);
-static int ThemeUI_setAttr (BPy_ThemeUI *self, char *name, PyObject *val);
+static void ThemeUI_dealloc( BPy_ThemeUI * self );
+static int ThemeUI_compare( BPy_ThemeUI * a, BPy_ThemeUI * b );
+static PyObject *ThemeUI_repr( BPy_ThemeUI * self );
+static PyObject *ThemeUI_getAttr( BPy_ThemeUI * self, char *name );
+static int ThemeUI_setAttr( BPy_ThemeUI * self, char *name, PyObject * val );
static PyMethodDef BPy_ThemeUI_methods[] = {
{NULL, NULL, 0, NULL}
};
PyTypeObject ThemeUI_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender UI Theme", /* tp_name */
- sizeof (BPy_Theme), /* tp_basicsize */
- 0, /* tp_itemsize */
+ PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
+ "Blender UI Theme", /* tp_name */
+ sizeof( BPy_Theme ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor) ThemeUI_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) ThemeUI_getAttr, /* tp_getattr */
- (setattrfunc) ThemeUI_setAttr, /* tp_setattr */
- (cmpfunc) ThemeUI_compare, /* tp_compare */
- (reprfunc) ThemeUI_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
+ ( destructor ) ThemeUI_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) ThemeUI_getAttr, /* tp_getattr */
+ ( setattrfunc ) ThemeUI_setAttr, /* tp_setattr */
+ ( cmpfunc ) ThemeUI_compare, /* tp_compare */
+ ( reprfunc ) ThemeUI_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, /* tp_doc */
0, 0, 0, 0, 0, 0,
- 0, //BPy_ThemeUI_methods, /* tp_methods */
- 0, /* tp_members */
+ 0, //BPy_ThemeUI_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static void ThemeUI_dealloc (BPy_ThemeUI *self)
+static void ThemeUI_dealloc( BPy_ThemeUI * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
#define ELSEIF_TUI_RGBA(attr)\
@@ -299,238 +307,256 @@ static void ThemeUI_dealloc (BPy_ThemeUI *self)
* attr = charRGBA_New(&tui->outline[0])
*/
-static PyObject *ThemeUI_getAttr (BPy_ThemeUI *self, char *name)
+static PyObject *ThemeUI_getAttr( BPy_ThemeUI * self, char *name )
{
PyObject *attrib = Py_None;
ThemeUI *tui = self->tui;
- if (!strcmp (name, "theme"))
- attrib = PyString_FromString (self->theme->name);
- ELSEIF_TUI_RGBA(outline)
- ELSEIF_TUI_RGBA(neutral)
- ELSEIF_TUI_RGBA(action)
- ELSEIF_TUI_RGBA(setting)
- ELSEIF_TUI_RGBA(setting1)
- ELSEIF_TUI_RGBA(setting2)
- ELSEIF_TUI_RGBA(num)
- ELSEIF_TUI_RGBA(textfield)
- ELSEIF_TUI_RGBA(popup)
- ELSEIF_TUI_RGBA(text)
- ELSEIF_TUI_RGBA(text_hi)
- ELSEIF_TUI_RGBA(menu_back)
- ELSEIF_TUI_RGBA(menu_item)
- ELSEIF_TUI_RGBA(menu_hilite)
- ELSEIF_TUI_RGBA(menu_text)
- ELSEIF_TUI_RGBA(menu_text_hi)
- else if (!strcmp (name, "drawType"))
- attrib = PyInt_FromLong((char)tui->but_drawtype);
- else if (!strcmp (name, "__members__"))
- attrib = Py_BuildValue("[ssssssssssssssssss]", "theme",
- "outline", "neutral", "action", "setting", "setting1", "setting2",
- "num", "textfield", "popup", "text", "text_hi", "menu_back", "menu_item",
- "menu_hilite", "menu_text", "menu_text_hi", "drawType");
-
- if (attrib != Py_None) return attrib;
-
- return Py_FindMethod(BPy_ThemeUI_methods, (PyObject *)self, name);
+ if( !strcmp( name, "theme" ) )
+ attrib = PyString_FromString( self->theme->name );
+ ELSEIF_TUI_RGBA( outline )
+ ELSEIF_TUI_RGBA( neutral )
+ ELSEIF_TUI_RGBA( action )
+ ELSEIF_TUI_RGBA( setting )
+ ELSEIF_TUI_RGBA( setting1 )
+ ELSEIF_TUI_RGBA( setting2 )
+ ELSEIF_TUI_RGBA( num )
+ ELSEIF_TUI_RGBA( textfield )
+ ELSEIF_TUI_RGBA( popup )
+ ELSEIF_TUI_RGBA( text )
+ ELSEIF_TUI_RGBA( text_hi )
+ ELSEIF_TUI_RGBA( menu_back )
+ ELSEIF_TUI_RGBA( menu_item )
+ ELSEIF_TUI_RGBA( menu_hilite )
+ ELSEIF_TUI_RGBA( menu_text )
+ ELSEIF_TUI_RGBA( menu_text_hi )
+ else if( !strcmp( name, "drawType" ) )
+ attrib = PyInt_FromLong( ( char ) tui->but_drawtype );
+ else if( !strcmp( name, "__members__" ) )
+ attrib = Py_BuildValue( "[ssssssssssssssssss]", "theme",
+ "outline", "neutral", "action",
+ "setting", "setting1", "setting2",
+ "num", "textfield", "popup", "text",
+ "text_hi", "menu_back", "menu_item",
+ "menu_hilite", "menu_text",
+ "menu_text_hi", "drawType" );
+
+ if( attrib != Py_None )
+ return attrib;
+
+ return Py_FindMethod( BPy_ThemeUI_methods, ( PyObject * ) self, name );
}
-static int ThemeUI_setAttr (BPy_ThemeUI *self, char *name, PyObject *value)
+static int ThemeUI_setAttr( BPy_ThemeUI * self, char *name, PyObject * value )
{
PyObject *attrib = NULL;
ThemeUI *tui = self->tui;
int ret = -1;
- if (!strcmp (name, "outline"))
- attrib = charRGBA_New(&tui->outline[0]);
- ELSEIF_TUI_RGBA(neutral)
- ELSEIF_TUI_RGBA(action)
- ELSEIF_TUI_RGBA(setting)
- ELSEIF_TUI_RGBA(setting1)
- ELSEIF_TUI_RGBA(setting2)
- ELSEIF_TUI_RGBA(num)
- ELSEIF_TUI_RGBA(textfield)
- ELSEIF_TUI_RGBA(popup)
- ELSEIF_TUI_RGBA(text)
- ELSEIF_TUI_RGBA(text_hi)
- ELSEIF_TUI_RGBA(menu_back)
- ELSEIF_TUI_RGBA(menu_item)
- ELSEIF_TUI_RGBA(menu_hilite)
- ELSEIF_TUI_RGBA(menu_text)
- ELSEIF_TUI_RGBA(menu_text_hi)
- else if (!strcmp (name, "drawType")) {
+ if( !strcmp( name, "outline" ) )
+ attrib = charRGBA_New( &tui->outline[0] );
+ ELSEIF_TUI_RGBA( neutral )
+ ELSEIF_TUI_RGBA( action )
+ ELSEIF_TUI_RGBA( setting )
+ ELSEIF_TUI_RGBA( setting1 )
+ ELSEIF_TUI_RGBA( setting2 )
+ ELSEIF_TUI_RGBA( num )
+ ELSEIF_TUI_RGBA( textfield )
+ ELSEIF_TUI_RGBA( popup )
+ ELSEIF_TUI_RGBA( text )
+ ELSEIF_TUI_RGBA( text_hi )
+ ELSEIF_TUI_RGBA( menu_back )
+ ELSEIF_TUI_RGBA( menu_item )
+ ELSEIF_TUI_RGBA( menu_hilite )
+ ELSEIF_TUI_RGBA( menu_text )
+ ELSEIF_TUI_RGBA( menu_text_hi )
+ else if( !strcmp( name, "drawType" ) ) {
int val;
- if (!PyInt_Check(value))
- return EXPP_ReturnIntError (PyExc_TypeError, "expected integer value");
+ if( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected integer value" );
- val = (int)PyInt_AsLong(value);
- tui->but_drawtype = EXPP_ClampInt(val,
- EXPP_THEME_DRAWTYPE_MIN, EXPP_THEME_DRAWTYPE_MAX);
+ val = ( int ) PyInt_AsLong( value );
+ tui->but_drawtype = EXPP_ClampInt( val,
+ EXPP_THEME_DRAWTYPE_MIN,
+ EXPP_THEME_DRAWTYPE_MAX );
ret = 0;
- }
- else
- return EXPP_ReturnIntError (PyExc_AttributeError, "attribute not found");
+ } else
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "attribute not found" );
- if (attrib) {
+ if( attrib ) {
PyObject *pyret = NULL;
- PyObject *valtuple = Py_BuildValue("(O)", value);
+ PyObject *valtuple = Py_BuildValue( "(O)", value );
- if (!valtuple)
- return EXPP_ReturnIntError (PyExc_MemoryError, "couldn't create tuple!");
+ if( !valtuple )
+ return EXPP_ReturnIntError( PyExc_MemoryError,
+ "couldn't create tuple!" );
- pyret = charRGBA_setCol((BPy_charRGBA *)attrib, valtuple);
- Py_DECREF(valtuple);
+ pyret = charRGBA_setCol( ( BPy_charRGBA * ) attrib, valtuple );
+ Py_DECREF( valtuple );
- if (pyret == Py_None) {
- Py_DECREF (Py_None); /* was increfed by charRGBA_setCol */
+ if( pyret == Py_None ) {
+ Py_DECREF( Py_None ); /* was increfed by charRGBA_setCol */
ret = 0;
}
- Py_DECREF(attrib); /* we're done with it */
+ Py_DECREF( attrib ); /* we're done with it */
}
- return ret; /* 0 if all went well */
+ return ret; /* 0 if all went well */
}
-static int ThemeUI_compare (BPy_ThemeUI *a, BPy_ThemeUI *b)
+static int ThemeUI_compare( BPy_ThemeUI * a, BPy_ThemeUI * b )
{
ThemeUI *pa = a->tui, *pb = b->tui;
- return (pa == pb) ? 0 : -1;
+ return ( pa == pb ) ? 0 : -1;
}
-static PyObject *ThemeUI_repr (BPy_ThemeUI *self)
+static PyObject *ThemeUI_repr( BPy_ThemeUI * self )
{
- return PyString_FromFormat("[UI theme from theme \"%s\"]", self->theme->name);
+ return PyString_FromFormat( "[UI theme from theme \"%s\"]",
+ self->theme->name );
}
-static void Theme_dealloc (BPy_Theme *self);
-static int Theme_compare (BPy_Theme *a, BPy_Theme *b);
-static PyObject *Theme_getAttr (BPy_Theme *self, char *name);
-static PyObject *Theme_repr (BPy_Theme *self);
+static void Theme_dealloc( BPy_Theme * self );
+static int Theme_compare( BPy_Theme * a, BPy_Theme * b );
+static PyObject *Theme_getAttr( BPy_Theme * self, char *name );
+static PyObject *Theme_repr( BPy_Theme * self );
-static PyObject *Theme_get(BPy_Theme *self, PyObject *args);
-static PyObject *Theme_getName(BPy_Theme *self);
-static PyObject *Theme_setName(BPy_Theme *self, PyObject *args);
+static PyObject *Theme_get( BPy_Theme * self, PyObject * args );
+static PyObject *Theme_getName( BPy_Theme * self );
+static PyObject *Theme_setName( BPy_Theme * self, PyObject * args );
static PyMethodDef BPy_Theme_methods[] = {
- {"get", (PyCFunction) Theme_get, METH_VARARGS,
- "(param) - Return UI or Space theme object.\n\
+ {"get", ( PyCFunction ) Theme_get, METH_VARARGS,
+ "(param) - Return UI or Space theme object.\n\
(param) - the chosen theme object as an int or a string:\n\
- () - default: UI;\n\
- (i) - int: an entry from the Blender.Window.Types dictionary;\n\
- (s) - string: 'UI' or a space name, like 'VIEW3D', etc."},
- {"getName", (PyCFunction) Theme_getName, METH_NOARGS,
- "() - Return Theme name"},
- {"setName", (PyCFunction) Theme_setName, METH_VARARGS,
- "(s) - Set Theme name"},
+ {"getName", ( PyCFunction ) Theme_getName, METH_NOARGS,
+ "() - Return Theme name"},
+ {"setName", ( PyCFunction ) Theme_setName, METH_VARARGS,
+ "(s) - Set Theme name"},
{NULL, NULL, 0, NULL}
};
PyTypeObject Theme_Type = {
- PyObject_HEAD_INIT (NULL) 0, /* ob_size */
- "Blender Theme", /* tp_name */
- sizeof (BPy_Theme), /* tp_basicsize */
- 0, /* tp_itemsize */
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Theme", /* tp_name */
+ sizeof( BPy_Theme ), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor) Theme_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc) Theme_getAttr, /* tp_getattr */
- 0,//(setattrfunc) Theme_setAttr, /* tp_setattr */
- (cmpfunc) Theme_compare, /* tp_compare */
- (reprfunc) Theme_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
+ ( destructor ) Theme_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Theme_getAttr, /* tp_getattr */
+ 0, //(setattrfunc) Theme_setAttr, /* tp_setattr */
+ ( cmpfunc ) Theme_compare, /* tp_compare */
+ ( reprfunc ) Theme_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, /* tp_doc */
0, 0, 0, 0, 0, 0,
- 0, //BPy_Theme_methods, /* tp_methods */
- 0, /* tp_members */
+ 0, //BPy_Theme_methods, /* tp_methods */
+ 0, /* tp_members */
};
-static PyObject *M_Theme_New (PyObject *self, PyObject *args)
+static PyObject *M_Theme_New( PyObject * self, PyObject * args )
{
char *name = "New Theme";
BPy_Theme *pytheme = NULL, *base_pytheme = NULL;
bTheme *btheme = NULL, *newtheme = NULL;
- if (!PyArg_ParseTuple (args, "|sO!", &name, &Theme_Type, &base_pytheme))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected nothing or a name and optional theme object as arguments");
+ if( !PyArg_ParseTuple
+ ( args, "|sO!", &name, &Theme_Type, &base_pytheme ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected nothing or a name and optional theme object as arguments" );
- if (base_pytheme) btheme = base_pytheme->theme;
- if (!btheme) btheme = U.themes.first;
+ if( base_pytheme )
+ btheme = base_pytheme->theme;
+ if( !btheme )
+ btheme = U.themes.first;
- newtheme = MEM_callocN(sizeof(bTheme), "theme");
+ newtheme = MEM_callocN( sizeof( bTheme ), "theme" );
- if (newtheme) pytheme = PyObject_New (BPy_Theme, &Theme_Type);
- if (!pytheme) return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create Theme Data in Blender");
+ if( newtheme )
+ pytheme = PyObject_New( BPy_Theme, &Theme_Type );
+ if( !pytheme )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Theme Data in Blender" );
- memcpy(newtheme, btheme, sizeof(bTheme));
- BLI_addhead(&U.themes, newtheme);
- BLI_strncpy(newtheme->name, name, 32);
+ memcpy( newtheme, btheme, sizeof( bTheme ) );
+ BLI_addhead( &U.themes, newtheme );
+ BLI_strncpy( newtheme->name, name, 32 );
pytheme->theme = newtheme;
- return (PyObject *)pytheme;
+ return ( PyObject * ) pytheme;
}
-static PyObject *M_Theme_Get (PyObject *self, PyObject *args)
+static PyObject *M_Theme_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
bTheme *iter;
PyObject *ret;
- if (!PyArg_ParseTuple (args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)");
+ if( !PyArg_ParseTuple( args, "|s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument (or nothing)" );
iter = U.themes.first;
- if (name) { /* (name) - return requested theme */
+ if( name ) { /* (name) - return requested theme */
BPy_Theme *wanted = NULL;
- while (iter) {
- if (strcmp (name, iter->name) == 0) {
- wanted = PyObject_New(BPy_Theme, &Theme_Type);
+ while( iter ) {
+ if( strcmp( name, iter->name ) == 0 ) {
+ wanted = PyObject_New( BPy_Theme,
+ &Theme_Type );
wanted->theme = iter;
break;
}
iter = iter->next;
}
- if (!wanted) {
+ if( !wanted ) {
char emsg[64];
- PyOS_snprintf (emsg, sizeof (emsg), "Theme \"%s\" not found", name);
- return EXPP_ReturnPyObjError (PyExc_NameError, emsg);
+ PyOS_snprintf( emsg, sizeof( emsg ),
+ "Theme \"%s\" not found", name );
+ return EXPP_ReturnPyObjError( PyExc_NameError, emsg );
}
- ret = (PyObject *)wanted;
+ ret = ( PyObject * ) wanted;
}
- else { /* () - return list with all themes */
+ else { /* () - return list with all themes */
int index = 0;
PyObject *list = NULL;
BPy_Theme *pytheme = NULL;
- list = PyList_New (BLI_countlist (&(U.themes)));
+ list = PyList_New( BLI_countlist( &( U.themes ) ) );
- if (!list)
- return EXPP_ReturnPyObjError(PyExc_MemoryError,"couldn't create PyList");
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create PyList" );
- while (iter) {
- pytheme = PyObject_New(BPy_Theme, &Theme_Type);
+ while( iter ) {
+ pytheme = PyObject_New( BPy_Theme, &Theme_Type );
pytheme->theme = iter;
- if (!pytheme)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create Theme PyObject");
+ if( !pytheme )
+ return EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "couldn't create Theme PyObject" );
- PyList_SET_ITEM (list, index, (PyObject *)pytheme);
+ PyList_SET_ITEM( list, index, ( PyObject * ) pytheme );
iter = iter->next;
index++;
@@ -542,7 +568,7 @@ static PyObject *M_Theme_Get (PyObject *self, PyObject *args)
return ret;
}
-static PyObject *Theme_get(BPy_Theme *self, PyObject *args)
+static PyObject *Theme_get( BPy_Theme * self, PyObject * args )
{
bTheme *btheme = self->theme;
ThemeUI *tui = NULL;
@@ -552,155 +578,157 @@ static PyObject *Theme_get(BPy_Theme *self, PyObject *args)
BPy_ThemeSpace *retSpc = NULL;
int type;
- if (!PyArg_ParseTuple(args, "|O", &pyob))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string or int argument or nothing");
+ if( !PyArg_ParseTuple( args, "|O", &pyob ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string or int argument or nothing" );
- if (!pyob) { /* (): return list with all names */
- PyObject *ret = PyList_New(EXPP_THEME_NUMBEROFTHEMES);
+ if( !pyob ) { /* (): return list with all names */
+ PyObject *ret = PyList_New( EXPP_THEME_NUMBEROFTHEMES );
- if (!ret)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create pylist!");
+ if( !ret )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create pylist!" );
- type = 0; /* using as a counter only */
+ type = 0; /* using as a counter only */
- while (type < EXPP_THEME_NUMBEROFTHEMES) {
- PyList_SET_ITEM(ret, type, PyString_FromString(themes_map[type].sval));
+ while( type < EXPP_THEME_NUMBEROFTHEMES ) {
+ PyList_SET_ITEM( ret, type,
+ PyString_FromString( themes_map[type].
+ sval ) );
type++;
}
return ret;
}
- else if (PyInt_Check(pyob)) /* (int) */
- type = (int)PyInt_AsLong(pyob);
- else if (PyString_Check(pyob)) { /* (str) */
- char *str = PyString_AsString(pyob);
- if (!EXPP_map_case_getIntVal(themes_map, str, &type))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown string argument");
- }
- else return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string or int argument or nothing");
-
- switch (type) {
- case -1: /* UI */
- tui = &btheme->tui;
- break;
- case SPACE_BUTS:
- tsp = &btheme->tbuts;
- break;
- case SPACE_VIEW3D:
- tsp = &btheme->tv3d;
- break;
- case SPACE_FILE:
- tsp = &btheme->tfile;
- break;
- case SPACE_IPO:
- tsp = &btheme->tipo;
- break;
- case SPACE_INFO:
- tsp = &btheme->tinfo;
- break;
- case SPACE_SOUND:
- tsp = &btheme->tsnd;
- break;
- case SPACE_ACTION:
- tsp = &btheme->tact;
- break;
- case SPACE_NLA:
- tsp = &btheme->tnla;
- break;
- case SPACE_SEQ:
- tsp = &btheme->tseq;
- break;
- case SPACE_IMAGE:
- tsp = &btheme->tima;
- break;
- case SPACE_IMASEL:
- tsp = &btheme->timasel;
- break;
- case SPACE_TEXT:
- tsp = &btheme->text;
- break;
- case SPACE_OOPS:
- tsp = &btheme->toops;
- break;
+ else if( PyInt_Check( pyob ) ) /* (int) */
+ type = ( int ) PyInt_AsLong( pyob );
+ else if( PyString_Check( pyob ) ) { /* (str) */
+ char *str = PyString_AsString( pyob );
+ if( !EXPP_map_case_getIntVal( themes_map, str, &type ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown string argument" );
+ } else
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string or int argument or nothing" );
+
+ switch ( type ) {
+ case -1: /* UI */
+ tui = &btheme->tui;
+ break;
+ case SPACE_BUTS:
+ tsp = &btheme->tbuts;
+ break;
+ case SPACE_VIEW3D:
+ tsp = &btheme->tv3d;
+ break;
+ case SPACE_FILE:
+ tsp = &btheme->tfile;
+ break;
+ case SPACE_IPO:
+ tsp = &btheme->tipo;
+ break;
+ case SPACE_INFO:
+ tsp = &btheme->tinfo;
+ break;
+ case SPACE_SOUND:
+ tsp = &btheme->tsnd;
+ break;
+ case SPACE_ACTION:
+ tsp = &btheme->tact;
+ break;
+ case SPACE_NLA:
+ tsp = &btheme->tnla;
+ break;
+ case SPACE_SEQ:
+ tsp = &btheme->tseq;
+ break;
+ case SPACE_IMAGE:
+ tsp = &btheme->tima;
+ break;
+ case SPACE_IMASEL:
+ tsp = &btheme->timasel;
+ break;
+ case SPACE_TEXT:
+ tsp = &btheme->text;
+ break;
+ case SPACE_OOPS:
+ tsp = &btheme->toops;
+ break;
}
- if (tui) {
- retUI = PyObject_New(BPy_ThemeUI, &ThemeUI_Type);
+ if( tui ) {
+ retUI = PyObject_New( BPy_ThemeUI, &ThemeUI_Type );
retUI->theme = btheme;
retUI->tui = tui;
- return (PyObject *)retUI;
- }
- else if (tsp) {
- retSpc = PyObject_New(BPy_ThemeSpace, &ThemeSpace_Type);
+ return ( PyObject * ) retUI;
+ } else if( tsp ) {
+ retSpc = PyObject_New( BPy_ThemeSpace, &ThemeSpace_Type );
retSpc->theme = btheme;
retSpc->tsp = tsp;
- return (PyObject *)retSpc;
- }
- else return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "invalid parameter");
+ return ( PyObject * ) retSpc;
+ } else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "invalid parameter" );
}
-static PyObject *Theme_getName(BPy_Theme *self)
+static PyObject *Theme_getName( BPy_Theme * self )
{
- return PyString_FromString (self->theme->name);
+ return PyString_FromString( self->theme->name );
}
-static PyObject *Theme_setName(BPy_Theme *self, PyObject *args)
+static PyObject *Theme_setName( BPy_Theme * self, PyObject * args )
{
char *name = NULL;
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- BLI_strncpy(self->theme->name, name, 32);
+ BLI_strncpy( self->theme->name, name, 32 );
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret( Py_None );
}
-PyObject *Theme_Init (void)
+PyObject *Theme_Init( void )
{
PyObject *submodule;
Theme_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3 ("Blender.Window.Theme",
- M_Theme_methods, M_Theme_doc);
+ submodule = Py_InitModule3( "Blender.Window.Theme",
+ M_Theme_methods, M_Theme_doc );
return submodule;
}
-static void Theme_dealloc (BPy_Theme *self)
+static void Theme_dealloc( BPy_Theme * self )
{
- PyObject_DEL (self);
+ PyObject_DEL( self );
}
-static PyObject *Theme_getAttr (BPy_Theme *self, char *name)
+static PyObject *Theme_getAttr( BPy_Theme * self, char *name )
{
PyObject *attr = Py_None;
- if (!strcmp (name, "name"))
- attr = PyString_FromString (self->theme->name);
- else if (!strcmp (name, "__members__"))
- attr = Py_BuildValue("[s]", "name");
+ if( !strcmp( name, "name" ) )
+ attr = PyString_FromString( self->theme->name );
+ else if( !strcmp( name, "__members__" ) )
+ attr = Py_BuildValue( "[s]", "name" );
- if (attr != Py_None) return attr;
+ if( attr != Py_None )
+ return attr;
- return Py_FindMethod(BPy_Theme_methods, (PyObject *)self, name);
+ return Py_FindMethod( BPy_Theme_methods, ( PyObject * ) self, name );
}
-static int Theme_compare (BPy_Theme *a, BPy_Theme *b)
+static int Theme_compare( BPy_Theme * a, BPy_Theme * b )
{
bTheme *pa = a->theme, *pb = b->theme;
- return (pa == pb) ? 0 : -1;
+ return ( pa == pb ) ? 0 : -1;
}
-static PyObject *Theme_repr (BPy_Theme *self)
+static PyObject *Theme_repr( BPy_Theme * self )
{
- return PyString_FromFormat ("[Theme \"%s\"]", self->theme->name);
+ return PyString_FromFormat( "[Theme \"%s\"]", self->theme->name );
}
diff --git a/source/blender/python/api2_2x/windowTheme.h b/source/blender/python/api2_2x/windowTheme.h
index b3a654c9fb7..22ae4a1ff00 100644
--- a/source/blender/python/api2_2x/windowTheme.h
+++ b/source/blender/python/api2_2x/windowTheme.h
@@ -38,23 +38,20 @@
#include <DNA_userdef_types.h>
typedef struct {
- PyObject_HEAD
- struct bTheme *theme;
+ PyObject_HEAD struct bTheme *theme;
struct ThemeUI *tui;
} BPy_ThemeUI;
typedef struct {
- PyObject_HEAD
- struct bTheme *theme;
+ PyObject_HEAD struct bTheme *theme;
struct ThemeSpace *tsp;
} BPy_ThemeSpace;
typedef struct {
- PyObject_HEAD
- struct bTheme *theme;
+ PyObject_HEAD struct bTheme *theme;
} BPy_Theme;
-#endif /* EXPP_WINDOWTHEME_H */
+#endif /* EXPP_WINDOWTHEME_H */