[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22742] trunk/blender/source/blender: [ #18936] Particle Related Patch

Campbell Barton ideasman42 at gmail.com
Mon Aug 24 12:37:41 CEST 2009


Revision: 22742
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22742
Author:   campbellbarton
Date:     2009-08-24 12:37:39 +0200 (Mon, 24 Aug 2009)

Log Message:
-----------
[#18936] Particle Related Patch
from Alberto Santos (dnakhain)

This also adds the option to duplicate a particle system with an object.

 --- description from the patch submission.

This patch includes my latest additions to the Python API developed for my Degree's Project.

It includes:
 - Particle
    - Vertex group dictionary in doc (to use with setvertexgroup/getvertexgroup)
    - Particle.New return psys (not specified in doc)
    - Draw As variable and dict
    - Strand render toggle
 - Object
   - psys variable in duplicate
 - Material
   - Strand render variables
 - Texture
   - Use colorbands
 - Lamp
   - Spot buffer type selection

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/python/api2_2x/Lamp.c
    trunk/blender/source/blender/python/api2_2x/Material.c
    trunk/blender/source/blender/python/api2_2x/Object.c
    trunk/blender/source/blender/python/api2_2x/Particle.c
    trunk/blender/source/blender/python/api2_2x/Texture.c
    trunk/blender/source/blender/python/api2_2x/doc/Lamp.py
    trunk/blender/source/blender/python/api2_2x/doc/Material.py
    trunk/blender/source/blender/python/api2_2x/doc/Object.py
    trunk/blender/source/blender/python/api2_2x/doc/Particle.py
    trunk/blender/source/blender/python/api2_2x/doc/Texture.py
    trunk/blender/source/blender/src/editobject.c

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2009-08-24 10:21:53 UTC (rev 22741)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2009-08-24 10:37:39 UTC (rev 22742)
@@ -313,6 +313,7 @@
 #define USER_DUP_TEX			(1 << 8)
 #define	USER_DUP_ARM			(1 << 9)
 #define	USER_DUP_ACT			(1 << 10)
+#define	USER_DUP_PSYS			(1 << 11)
 
 /* gameflags */
 #define USER_DEPRECATED_FLAG	1

Modified: trunk/blender/source/blender/python/api2_2x/Lamp.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Lamp.c	2009-08-24 10:21:53 UTC (rev 22741)
+++ trunk/blender/source/blender/python/api2_2x/Lamp.c	2009-08-24 10:37:39 UTC (rev 22742)
@@ -125,6 +125,8 @@
 #define EXPP_LAMP_COL_MAX 1.0
 #define EXPP_LAMP_FALLOFF_MIN LA_FALLOFF_CONSTANT
 #define EXPP_LAMP_FALLOFF_MAX LA_FALLOFF_SLIDERS
+#define EXPP_LAMP_BUFFERTYPE_MIN LA_SHADBUF_REGULAR
+#define EXPP_LAMP_BUFFERTYPE_MAX LA_SHADBUF_HALFWAY
 
 /* Raytracing settings */
 #define EXPP_LAMP_RAYSAMPLES_MIN 1
@@ -268,6 +270,8 @@
 static int Lamp_setComponent( BPy_Lamp * self, PyObject * value, void * closure );
 static PyObject *Lamp_getFalloffType( BPy_Lamp * self );
 static int Lamp_setFalloffType( BPy_Lamp * self, PyObject * value );
+static PyObject *Lamp_getBufferType( BPy_Lamp * self );
+static int Lamp_setBufferType( BPy_Lamp * self, PyObject * value );
 
 /*****************************************************************************/
 /* Python BPy_Lamp methods table:                                            */
@@ -489,6 +493,10 @@
 	 (getter)Lamp_getFalloffType, (setter)Lamp_setFalloffType,
 	 "Lamp falloff type",
 	 NULL},
+	{"bufferType",
+	 (getter)Lamp_getBufferType, (setter)Lamp_setBufferType,
+	 "Lamp buffer type",
+	 NULL},
 	{"R",
 	 (getter)Lamp_getComponent, (setter)Lamp_setComponent,
 	 "Lamp color red component",
@@ -828,13 +836,31 @@
 	return Falloffs;
 }
 
+static PyObject *Lamp_BufferTypesDict( void )
+{			/* create the Blender.Lamp.BufferTypes constant dict */
+	PyObject *Types = PyConstant_New(  );
+
+	if( Types ) {
+		BPy_constant *c = ( BPy_constant * ) Types;
+
+		PyConstant_Insert( c, "REGULAR",
+				 PyInt_FromLong( LA_SHADBUF_REGULAR ) );
+		PyConstant_Insert( c, "IRREGULAR",
+				 PyInt_FromLong( LA_SHADBUF_IRREGULAR ) );
+		PyConstant_Insert( c, "HALFWAY",
+				 PyInt_FromLong( LA_SHADBUF_HALFWAY ) );
+	}
+
+	return Types;
+}
+
 /*****************************************************************************/
 /* Function:              Lamp_Init                                          */
 /*****************************************************************************/
 /* Needed by the Blender module, to register the Blender.Lamp submodule */
 PyObject *Lamp_Init( void )
 {
-	PyObject *submodule, *Types, *Modes, *Falloffs;
+	PyObject *submodule, *Types, *Modes, *Falloffs, *BufferTypes;
 
 	if( PyType_Ready( &Lamp_Type ) < 0)
 		return NULL;
@@ -842,6 +868,7 @@
 	Types = Lamp_TypesDict(  );
 	Modes = Lamp_ModesDict(  );
 	Falloffs = Lamp_FalloffsDict(  );
+	BufferTypes = Lamp_BufferTypesDict(  );
 
 	submodule =
 		Py_InitModule3( "Blender.Lamp", M_Lamp_methods, M_Lamp_doc );
@@ -852,6 +879,8 @@
 		PyModule_AddObject( submodule, "Modes", Modes );
 	if( Falloffs )
 		PyModule_AddObject( submodule, "Falloffs", Falloffs );
+	if( BufferTypes )
+		PyModule_AddObject( submodule, "BufferTypes", BufferTypes );
 
 	PyModule_AddIntConstant( submodule, "RGB",      IPOKEY_RGB );
 	PyModule_AddIntConstant( submodule, "ENERGY",   IPOKEY_ENERGY );
@@ -1029,6 +1058,11 @@
 	return PyInt_FromLong( (int)self->lamp->falloff_type );
 }
 
+static PyObject *Lamp_getBufferType( BPy_Lamp * self )
+{
+	return PyInt_FromLong( (int)self->lamp->buftype );
+}
+
 static int Lamp_setType( BPy_Lamp * self, PyObject * value )
 {
 	return EXPP_setIValueRange ( value, &self->lamp->type,
@@ -1217,6 +1251,11 @@
 				  				EXPP_LAMP_FALLOFF_MIN, EXPP_LAMP_FALLOFF_MAX, 'h' );
 }
 
+static int Lamp_setBufferType( BPy_Lamp * self, PyObject * value )
+{
+	return EXPP_setIValueRange ( value, &self->lamp->buftype,
+				  				EXPP_LAMP_BUFFERTYPE_MIN, EXPP_LAMP_BUFFERTYPE_MAX, 'h' );
+}
 
 static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure )
 {

Modified: trunk/blender/source/blender/python/api2_2x/Material.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Material.c	2009-08-24 10:21:53 UTC (rev 22741)
+++ trunk/blender/source/blender/python/api2_2x/Material.c	2009-08-24 10:37:39 UTC (rev 22742)
@@ -747,6 +747,26 @@
 static int Material_setColorbandDiffuseInput ( BPy_Material * self, PyObject * value);
 static int Material_setColorbandSpecularInput ( BPy_Material * self, PyObject * value);
 
+static PyObject *Material_getStrandTangentShad( BPy_Material * self );
+static int Material_setStrandTangentShad( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandSurfDiff( BPy_Material * self );
+static int Material_setStrandSurfDiff( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandDist( BPy_Material * self );
+static int Material_setStrandDist( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandBlendUnit( BPy_Material * self );
+static int Material_setStrandBlendUnit( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandStart( BPy_Material * self );
+static int Material_setStrandStart( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandEnd( BPy_Material * self );
+static int Material_setStrandEnd( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandMin( BPy_Material * self );
+static int Material_setStrandMin( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandShape( BPy_Material * self );
+static int Material_setStrandShape( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandWidthFad( BPy_Material * self );
+static int Material_setStrandWidthFad( BPy_Material * self, PyObject * value);
+static PyObject *Material_getStrandUV( BPy_Material * self );
+static int Material_setStrandUV( BPy_Material * self, PyObject * value);
 
 
 /*****************************************************************************/
@@ -1313,6 +1333,46 @@
 	 (getter)Material_getColorbandDiffuseInput, (setter)Material_setColorbandDiffuseInput,
 	 "The diffuse colorband input for this material",
 	 NULL},
+	{"strandTanShad",
+	 (getter)Material_getStrandTangentShad, (setter)Material_setStrandTangentShad,
+	 "Uses direction of strands as normal for tangent-shading",
+	 NULL},
+	{"strandSurfDiff",
+	 (getter)Material_getStrandSurfDiff, (setter)Material_setStrandSurfDiff,
+	 "Make diffuse shading more similar to shading the surface",
+	 NULL},
+	{"strandDist",
+	 (getter)Material_getStrandDist, (setter)Material_setStrandDist,
+	 "Distance in Blender units over which to blend in the surface normal",
+	 NULL},
+	{"strandBlendUnit",
+	 (getter)Material_getStrandBlendUnit, (setter)Material_setStrandBlendUnit,
+	 "Use actual Blender units for widths instead of pixels",
+	 NULL},
+	{"strandStart",
+	 (getter)Material_getStrandStart, (setter)Material_setStrandStart,
+	 "Start size of strands",
+	 NULL},
+	{"strandEnd",
+	 (getter)Material_getStrandEnd, (setter)Material_setStrandEnd,
+	 "End size of strands",
+	 NULL},
+	{"strandMin",
+	 (getter)Material_getStrandMin, (setter)Material_setStrandMin,
+	 "Minimum size of strands in pixels",
+	 NULL},
+	{"strandShape",
+	 (getter)Material_getStrandShape, (setter)Material_setStrandShape,
+	 "Shape of strands, positive value makes it rounder, negative makes it spiky",
+	 NULL},
+	{"strandFade",
+	 (getter)Material_getStrandWidthFad, (setter)Material_setStrandWidthFad,
+	 "Transparency along the width of the strand",
+	 NULL},
+	{"strandUV",
+	 (getter)Material_getStrandUV, (setter)Material_setStrandUV,
+	 "Set name of UV layer to override",
+	 NULL},
 
 	/* SSS settings */
 	{"enableSSS",
@@ -3582,3 +3642,146 @@
 	return EXPP_setIValueClamped(value, &self->material->rampin_spec,
 			MA_RAMP_IN_SHADER, MA_RAMP_IN_RESULT, 'b');
 }
+
+/* Strand */
+
+static PyObject *Material_getStrandTangentShad( BPy_Material * self )
+{
+	return PyInt_FromLong( ((long)( self->material->mode & MA_TANGENT_STR )) > 0 );
+}
+
+static int Material_setStrandTangentShad( BPy_Material * self, PyObject * value)
+{
+	int number;
+
+	if( !PyInt_Check( value ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
+
+	number = PyInt_AS_LONG( value );
+
+	if (number){
+		self->material->mode |= MA_TANGENT_STR;
+	}else{
+		self->material->mode &= ~MA_TANGENT_STR;
+	}
+
+	return 0;
+}
+
+static PyObject *Material_getStrandSurfDiff( BPy_Material * self )
+{
+	return PyInt_FromLong( ((long)( self->material->mode & MA_STR_SURFDIFF )) > 0 );
+}
+
+static int Material_setStrandSurfDiff( BPy_Material * self, PyObject * value)
+{
+	int number;
+
+	if( !PyInt_Check( value ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
+
+	number = PyInt_AS_LONG( value );
+
+	if (number){
+		self->material->mode |= MA_STR_SURFDIFF;
+	}else{
+		self->material->mode &= ~MA_STR_SURFDIFF;
+	}
+
+	return 0;
+}
+
+static PyObject *Material_getStrandDist( BPy_Material * self )
+{
+	return PyFloat_FromDouble( ((float)( self->material->strand_surfnor )) );
+}
+
+static int Material_setStrandDist( BPy_Material * self, PyObject * value)
+{
+	return EXPP_setFloatRange( value, &self->material->strand_surfnor,	0.0, 10.0 );
+}
+
+static PyObject *Material_getStrandBlendUnit( BPy_Material * self )
+{
+	return PyInt_FromLong( ((long)( self->material->mode & MA_STR_B_UNITS )) > 0 );
+}
+
+static int Material_setStrandBlendUnit( BPy_Material * self, PyObject * value)
+{
+	int number;
+
+	if( !PyInt_Check( value ) )
+		return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" );
+
+	number = PyInt_AS_LONG( value );
+
+	if (number){
+		self->material->mode |= MA_STR_B_UNITS;
+	}else{
+		self->material->mode &= ~MA_STR_B_UNITS;
+	}
+
+	return 0;
+}
+
+static PyObject *Material_getStrandStart( BPy_Material * self )
+{
+	return PyFloat_FromDouble( ((float)( self->material->strand_sta )) );
+}
+
+static int Material_setStrandStart( BPy_Material * self, PyObject * value)
+{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list