[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19682] trunk/blender/source/blender/ python/api2_2x: [#18516] Particle children API for python (Complete).

Campbell Barton ideasman42 at gmail.com
Sun Apr 12 19:07:40 CEST 2009


Revision: 19682
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19682
Author:   campbellbarton
Date:     2009-04-12 19:07:40 +0200 (Sun, 12 Apr 2009)

Log Message:
-----------
[#18516] Particle children API for python (Complete).
from Alberto Santos (dnakhain) 
----
This patch complete previous one that I submit with new variables relationated with Particle System children (With variables related to Rough, Kink and Branch).

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Particle.c
    trunk/blender/source/blender/python/api2_2x/doc/Particle.py

Modified: trunk/blender/source/blender/python/api2_2x/Particle.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Particle.c	2009-04-12 16:10:43 UTC (rev 19681)
+++ trunk/blender/source/blender/python/api2_2x/Particle.c	2009-04-12 17:07:40 UTC (rev 19682)
@@ -152,6 +152,38 @@
 static PyObject *Part_getChildSize( BPy_PartSys * self );
 static int Part_setChildRandom( BPy_PartSys * self, PyObject * args );
 static PyObject *Part_getChildRandom( BPy_PartSys * self );
+static int Part_setChildRough1( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRough1( BPy_PartSys * self );
+static int Part_setChildRough1Size( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRough1Size( BPy_PartSys * self );
+static int Part_setChildRough2( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRough2( BPy_PartSys * self );
+static int Part_setChildRough2Size( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRough2Size( BPy_PartSys * self );
+static int Part_setChildRough2Thres( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRough2Thres( BPy_PartSys * self );
+static int Part_setChildRoughE( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRoughE( BPy_PartSys * self );
+static int Part_setChildRoughEShape( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildRoughEShape( BPy_PartSys * self );
+static int Part_setChildKink( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildKink( BPy_PartSys * self );
+static int Part_setChildKinkAxis( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildKinkAxis( BPy_PartSys * self );
+static int Part_setChildKinkFreq( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildKinkFreq( BPy_PartSys * self );
+static int Part_setChildKinkShape( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildKinkShape( BPy_PartSys * self );
+static int Part_setChildKinkAmp( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildKinkAmp( BPy_PartSys * self );
+static int Part_setChildBranch( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildBranch( BPy_PartSys * self );
+static int Part_setChildBranchAnim( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildBranchAnim( BPy_PartSys * self );
+static int Part_setChildBranchSymm( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildBranchSymm( BPy_PartSys * self );
+static int Part_setChildBranchThre( BPy_PartSys * self, PyObject * args );
+static PyObject *Part_getChildBranchThre( BPy_PartSys * self );
 
 /*****************************************************************************/
 /* Python Effect_Type callback function prototypes:                           */
@@ -371,6 +403,70 @@
 	 (getter)Part_getChildRandom, (setter)Part_setChildRandom,
 	 "Random variation to the size of the child particles",
 	 NULL},
+	 {"childRough1",
+	 (getter)Part_getChildRough1, (setter)Part_setChildRough1,
+	 "Amount of location dependant rough",
+	 NULL},
+	 {"childRough1Size",
+	 (getter)Part_getChildRough1Size, (setter)Part_setChildRough1Size,
+	 "Size of location dependant rough",
+	 NULL},
+	 {"childRough2",
+	 (getter)Part_getChildRough2, (setter)Part_setChildRough2,
+	 "Amount of random rough",
+	 NULL},
+	 {"childRough2Size",
+	 (getter)Part_getChildRough2Size, (setter)Part_setChildRough2Size,
+	 "Size of random rough",
+	 NULL},
+	 {"childRough2Thresh",
+	 (getter)Part_getChildRough2Thres, (setter)Part_setChildRough2Thres,
+	 "Amount of particles left untouched by random rough",
+	 NULL},
+	 {"childRoughE",
+	 (getter)Part_getChildRoughE, (setter)Part_setChildRoughE,
+	 "Amount of end point rough",
+	 NULL},
+	 {"childRoughEShape",
+	 (getter)Part_getChildRoughEShape, (setter)Part_setChildRoughEShape,
+	 "Shape of end point rough",
+	 NULL},
+	 {"childKink",
+	 (getter)Part_getChildKink, (setter)Part_setChildKink,
+	 "Type of periodic offset on the path (Particle.CHILDKINK[ 'BRAID' | 'WAVE' | 'RADIAL' | 'CURL' | 'NOTHING' ])",
+	 NULL},
+	 {"childKinkAxis",
+	 (getter)Part_getChildKinkAxis, (setter)Part_setChildKinkAxis,
+	 "Which axis to use for offset (Particle.CHILDKINKAXIS[ 'Z' | 'Y' | 'X' ])",
+	 NULL},
+	 {"childKinkFreq",
+	 (getter)Part_getChildKinkFreq, (setter)Part_setChildKinkFreq,
+	 "The frequency of the offset (1/total length)",
+	 NULL},
+	 {"childKinkShape",
+	 (getter)Part_getChildKinkShape, (setter)Part_setChildKinkShape,
+	 "Adjust the offset to the beginning/end",
+	 NULL},
+	 {"childKinkAmp",
+	 (getter)Part_getChildKinkAmp, (setter)Part_setChildKinkAmp,
+	 "The amplitude of the offset",
+	 NULL},
+	 {"childBranch",
+	 (getter)Part_getChildBranch, (setter)Part_setChildBranch,
+	 "Branch child paths from eachother",
+	 NULL},
+	 {"childBranchAnim",
+	 (getter)Part_getChildBranchAnim, (setter)Part_setChildBranchAnim,
+	 "Animate branching",
+	 NULL},
+	 {"childBranchSymm",
+	 (getter)Part_getChildBranchSymm, (setter)Part_setChildBranchSymm,
+	 "Start and end points are the same",
+	 NULL},
+	 {"childBranchThre",
+	 (getter)Part_getChildBranchThre, (setter)Part_setChildBranchThre,
+	 "Threshold of branching",
+	 NULL},
 	{NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
 };
 
@@ -614,10 +710,8 @@
 		}
 
 		if( !wanted_obj){  /* requested object not found */
-			char error_msg[64];
-			PyOS_snprintf( error_msg, sizeof( error_msg ),
-						   "Particle System '%s' not found", name);
-			return EXPP_ReturnPyObjError( PyExc_NameError, error_msg );
+			PyErr_Format(PyExc_NameError, "Particle System '%s' not found", name);
+			return NULL;
 		}
 
 		return wanted_obj;
@@ -785,6 +879,48 @@
 	return ChildTypes;
 }
 
+/* create the Blender.Particle.ChildKink constant dict */
+
+static PyObject *Particle_ChildKinkDict( void )
+{
+	PyObject *ChildKinks = PyConstant_New(  );
+
+	if( ChildKinks ) {
+		BPy_constant *c = ( BPy_constant * ) ChildKinks;
+
+		PyConstant_Insert( c, "BRAID",
+				 PyInt_FromLong( 4 ) );
+		PyConstant_Insert( c, "WAVE",
+				 PyInt_FromLong( 3 ) );
+		PyConstant_Insert( c, "RADIAL",
+				 PyInt_FromLong( 2 ) );
+		PyConstant_Insert( c, "CURL",
+				 PyInt_FromLong( 1 ) );
+		PyConstant_Insert( c, "NOTHING",
+				 PyInt_FromLong( 0 ) );
+	}
+	return ChildKinks;
+}
+
+/* create the Blender.Particle.ChildKinkAxis constant dict */
+
+static PyObject *Particle_ChildKinkAxisDict( void )
+{
+	PyObject *ChildKinkAxes = PyConstant_New(  );
+
+	if( ChildKinkAxes ) {
+		BPy_constant *c = ( BPy_constant * ) ChildKinkAxes;
+
+		PyConstant_Insert( c, "Z",
+				 PyInt_FromLong( 2 ) );
+		PyConstant_Insert( c, "Y",
+				 PyInt_FromLong( 1 ) );
+		PyConstant_Insert( c, "X",
+				 PyInt_FromLong( 0 ) );
+	}
+	return ChildKinkAxes;
+}
+
 static PyObject *Particle_DrawAs( void )
 {
 	PyObject *DrawAs = PyConstant_New(  );
@@ -832,6 +968,8 @@
 	PyObject *Dist;
 	PyObject *DrawAs;
 	PyObject *ChildTypes;
+	PyObject *ChildKinks;
+	PyObject *ChildKinkAxes;
 
 
 	if( PyType_Ready( &ParticleSys_Type ) < 0)
@@ -843,6 +981,8 @@
 	DrawAs = Particle_DrawAs();
 	Dist = Particle_DistrDict();
 	ChildTypes = Particle_ChildTypeDict();
+	ChildKinks = Particle_ChildKinkDict();
+	ChildKinkAxes = Particle_ChildKinkAxisDict();
 
 	submodule = Py_InitModule3( "Blender.Particle", 
 								M_ParticleSys_methods, M_ParticleSys_doc );
@@ -859,6 +999,10 @@
 		PyModule_AddObject( submodule, "DRAWAS", DrawAs );
 	if( ChildTypes )
 		PyModule_AddObject( submodule, "CHILDTYPE", ChildTypes );
+	if( ChildKinks )
+		PyModule_AddObject( submodule, "CHILDKINK", ChildKinks );
+	if( ChildKinkAxes )
+		PyModule_AddObject( submodule, "CHILDKINKAXIS", ChildKinkAxes );
 
 	return ( submodule );
 }
@@ -1488,11 +1632,8 @@
 {
 	int number;
 
-	if( !PyInt_Check( args ) ) {
-		char errstr[128];
-		sprintf ( errstr, "expected int argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !PyInt_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
 
 	number = PyInt_AS_LONG( args );
 
@@ -1539,11 +1680,8 @@
 {
 	int number;
 
-	if( !PyInt_Check( args ) ) {
-		char errstr[128];
-		sprintf ( errstr, "expected int argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !PyInt_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
 
 	number = PyInt_AS_LONG( args );
 
@@ -1727,11 +1865,8 @@
 static int Part_setOb( BPy_PartSys * self, PyObject * args )
 {
 	Object *obj;
-	if( !BPy_Object_Check( args ) ) {
-		char errstr[128];
-		sprintf ( errstr, "expected object argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !BPy_Object_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected object argument" );
 
 	obj = Object_FromPyObject(args);
 
@@ -1754,11 +1889,8 @@
 {
 	int number;
 
-	if( !PyInt_Check( args ) ) {
-		char errstr[128];
-		sprintf ( errstr, "expected int argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !PyInt_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
 
 	number = PyInt_AS_LONG( args );
 
@@ -1781,19 +1913,14 @@
 static int Part_setParticleDist( BPy_PartSys * self, PyObject * args )
 {
 	int number;
-	char errstr[128];
 
-	if( !PyInt_Check( args ) ) {
-		sprintf ( errstr, "expected int argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !PyInt_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
 
 	number = PyInt_AS_LONG( args );
 
-	if (number < 0 || number > 3){
-		sprintf ( errstr, "expected int argument between 0 - 3" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if (number < 0 || number > 3)
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument between 0 - 3" );
 
 	self->psys->part->from = (short)number;
 
@@ -1811,11 +1938,8 @@
 {
 	int number;
 
-	if( !PyInt_Check( args ) ) {
-		char errstr[128];
-		sprintf ( errstr, "expected int argument" );
-		return EXPP_ReturnIntError( PyExc_TypeError, errstr );
-	}
+	if( !PyInt_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
 
 	number = PyInt_AS_LONG( args );
 
@@ -1838,19 +1962,14 @@
 static int Part_setDist( BPy_PartSys * self, PyObject * args )
 {
 	int number;
-	char errstr[128];
 
-	if( !PyInt_Check( args ) ) {
-		sprintf ( errstr, "expected int argument" );

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list