Revision: 15301 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15301 Author: unclezeiv Date: 2008-06-22 01:55:54 +0200 (Sun, 22 Jun 2008)
Log Message: ----------- Python API: added "samplingMethod" attribute to Lamp. This allows to change it to "constant" or "QMC adaptive/halton" or "QMC constant/hammersley". I'm not sure if it makes sense to add this to trunk, but I added a SamplingMethods dict and updated docs as well, just in case. Modified Paths: -------------- branches/soc-2008-unclezeiv/source/blender/python/api2_2x/Lamp.c branches/soc-2008-unclezeiv/source/blender/python/api2_2x/doc/Lamp.py Modified: branches/soc-2008-unclezeiv/source/blender/python/api2_2x/Lamp.c =================================================================== --- branches/soc-2008-unclezeiv/source/blender/python/api2_2x/Lamp.c 2008-06-21 23:00:26 UTC (rev 15300) +++ branches/soc-2008-unclezeiv/source/blender/python/api2_2x/Lamp.c 2008-06-21 23:55:54 UTC (rev 15301) @@ -118,6 +118,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_SAMPLINGMETHOD_MIN LA_SAMP_CONSTANT +#define EXPP_LAMP_SAMPLINGMETHOD_MAX LA_SAMP_HAMMERSLEY /* Raytracing settings */ #define EXPP_LAMP_RAYSAMPLES_MIN 1 @@ -184,6 +186,7 @@ static PyObject *Lamp_getMode( BPy_Lamp * self ); static PyObject *Lamp_getModesConst( void ); static PyObject *Lamp_getSamples( BPy_Lamp * self ); +static PyObject *Lamp_getSamplingMethod( BPy_Lamp * self ); static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self ); static PyObject *Lamp_getRaySamplesY( BPy_Lamp * self ); static PyObject *Lamp_getAreaSizeX( BPy_Lamp * self ); @@ -233,6 +236,7 @@ static int Lamp_setType( BPy_Lamp * self, PyObject * args ); static int Lamp_setMode( BPy_Lamp * self, PyObject * args ); static int Lamp_setSamples( BPy_Lamp * self, PyObject * args ); +static int Lamp_setSamplingMethod( BPy_Lamp * self, PyObject * args ); static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * args ); static int Lamp_setRaySamplesY( BPy_Lamp * self, PyObject * args ); static int Lamp_setAreaSizeX( BPy_Lamp * self, PyObject * args ); @@ -263,7 +267,7 @@ /*****************************************************************************/ static PyMethodDef BPy_Lamp_methods[] = { /* name, method, flags, doc */ - + {"getType", ( PyCFunction ) Lamp_getType, METH_NOARGS, "() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3, 'Area':4, 'Photon':5"}, {"getMode", ( PyCFunction ) Lamp_getMode, METH_NOARGS, @@ -438,6 +442,10 @@ (getter)Lamp_getSamples, (setter)Lamp_setSamples, "Lamp shadow map samples", NULL}, + {"samplingMethod", + (getter)Lamp_getSamplingMethod, (setter)Lamp_setSamplingMethod, + "Lamp raytracing sampling method", + NULL}, {"raySamplesX", (getter)Lamp_getRaySamplesX, (setter)Lamp_setRaySamplesX, "Lamp raytracing samples on the X axis", @@ -807,13 +815,31 @@ return Falloffs; } +static PyObject *Lamp_SamplingMethodsDict( void ) +{ /* create the Blender.Lamp.SamplingMethods constant dict */ + PyObject *SamplingMethods = PyConstant_New( ); + + if( SamplingMethods ) { + BPy_constant *c = ( BPy_constant * ) SamplingMethods; + + PyConstant_Insert( c, "CONSTANT", + PyInt_FromLong( LA_SAMP_CONSTANT ) ); + PyConstant_Insert( c, "QMC_ADAPTIVE", + PyInt_FromLong( LA_SAMP_HALTON ) ); + PyConstant_Insert( c, "QMC_CONSTANT", + PyInt_FromLong( LA_SAMP_HAMMERSLEY ) ); + } + + return SamplingMethods; +} + /*****************************************************************************/ /* 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, *SamplingMethods; if( PyType_Ready( &Lamp_Type ) < 0) return NULL; @@ -821,6 +847,7 @@ Types = Lamp_TypesDict( ); Modes = Lamp_ModesDict( ); Falloffs = Lamp_FalloffsDict( ); + SamplingMethods = Lamp_SamplingMethodsDict( ); submodule = Py_InitModule3( "Blender.Lamp", M_Lamp_methods, M_Lamp_doc ); @@ -831,6 +858,8 @@ PyModule_AddObject( submodule, "Modes", Modes ); if( Falloffs ) PyModule_AddObject( submodule, "Falloffs", Falloffs ); + if( SamplingMethods ) + PyModule_AddObject( submodule, "SamplingMethods", SamplingMethods ); PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB ); PyModule_AddIntConstant( submodule, "ENERGY", IPOKEY_ENERGY ); @@ -908,6 +937,11 @@ return PyInt_FromLong( self->lamp->samp ); } +static PyObject *Lamp_getSamplingMethod( BPy_Lamp * self ) +{ + return PyInt_FromLong( self->lamp->ray_samp_method ); +} + static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self ) { return PyInt_FromLong( self->lamp->ray_samp ); @@ -1047,6 +1081,12 @@ EXPP_LAMP_SAMPLES_MAX, 'h' ); } +static int Lamp_setSamplingMethod( BPy_Lamp * self, PyObject * value ) +{ + return EXPP_setIValueClamped ( value, &self->lamp->ray_samp_method, + EXPP_LAMP_SAMPLINGMETHOD_MIN, + EXPP_LAMP_SAMPLINGMETHOD_MAX, 'h' ); +} static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * value ) { Modified: branches/soc-2008-unclezeiv/source/blender/python/api2_2x/doc/Lamp.py =================================================================== --- branches/soc-2008-unclezeiv/source/blender/python/api2_2x/doc/Lamp.py 2008-06-21 23:00:26 UTC (rev 15300) +++ branches/soc-2008-unclezeiv/source/blender/python/api2_2x/doc/Lamp.py 2008-06-21 23:55:54 UTC (rev 15301) @@ -56,6 +56,11 @@ if lamp.type == Lamp.Types["Spot"]: # Lamp type is not a flag lamp.mode &= ~Lamp.Modes["RayShadow"] # Disable RayShadow. lamp.mode |= Lamp.Modes["Shadows"] # Enable Shadowbuffer shadows [EMAIL PROTECTED] SamplingMethods: read-only dictionary [EMAIL PROTECTED] SamplingMethods: Ray tracing sampling methods. + - CONSTANT = 0 + - QMC_ADAPTIVE = 1 + - QMC_CONSTANT = 2 """ def New (type = 'Lamp', name = 'LampData'): @@ -136,6 +141,8 @@ @ivar samples: Lamp shadow map samples. Value is clamped to the range [1,16]. @type samples: int + @ivar samplingMethod: Lamp shadow map samples. See L{SamplingMethods} for values. + @type samplingMethod: int @ivar raySamplesX: Lamp raytracing X samples (X is used for the Y axis with square area lamps). Value is clamped to the range [1,16]. @type raySamplesX: int _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs