[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14783] trunk/blender/source/blender/ python/api2_2x: Initial commit for BPy Particle patch #8557 from Cedric Paille
Campbell Barton
ideasman42 at gmail.com
Sun May 11 13:47:01 CEST 2008
Hi Stivs, Cedric - thanks for getting this ready for release!
Any reason not to include the macro GENERIC_LIB_GETSETATTR for the
BPy_PartSys pyobject ~line 178, see Group.c as an example.
This adds access for .name .lib .users .fakeUser .properties and .tag
- Cam
On Sun, May 11, 2008 at 6:15 AM, Stephen Swaney <sswaney at centurytel.net> wrote:
> Revision: 14783
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14783
> Author: stiv
> Date: 2008-05-11 06:15:21 +0200 (Sun, 11 May 2008)
>
> Log Message:
> -----------
> Initial commit for BPy Particle patch #8557 from Cedric Paille
> Thanks, Cedric!
>
> *** WARNING **** This is a Work In Progress *** Warning ****
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/python/api2_2x/Blender.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/Particle.h
> trunk/blender/source/blender/python/api2_2x/doc/API_intro.py
> trunk/blender/source/blender/python/api2_2x/doc/Object.py
>
> Added Paths:
> -----------
> trunk/blender/source/blender/python/api2_2x/doc/Particle.py
>
> Modified: trunk/blender/source/blender/python/api2_2x/Blender.c
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Blender.c 2008-05-11 02:28:01 UTC (rev 14782)
> +++ trunk/blender/source/blender/python/api2_2x/Blender.c 2008-05-11 04:15:21 UTC (rev 14783)
> @@ -96,6 +96,7 @@
> #include "Window.h"
> #include "World.h"
> #include "Types.h"
> +#include "Particle.h"
>
> /**********************************************************/
> /* Python API function prototypes for the Blender module. */
> @@ -1074,6 +1075,7 @@
> PyDict_SetItemString(dict, "Node", Node_Init());
> PyDict_SetItemString(dict, "Noise", Noise_Init());
> PyDict_SetItemString(dict, "Object", Object_Init());
> + PyDict_SetItemString(dict, "Particle", ParticleSys_Init());
> PyDict_SetItemString(dict, "Group", Group_Init());
> PyDict_SetItemString(dict, "Registry", Registry_Init());
> PyDict_SetItemString(dict, "Scene", Scene_Init());
>
> Modified: trunk/blender/source/blender/python/api2_2x/Object.c
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Object.c 2008-05-11 02:28:01 UTC (rev 14782)
> +++ trunk/blender/source/blender/python/api2_2x/Object.c 2008-05-11 04:15:21 UTC (rev 14783)
> @@ -27,7 +27,7 @@
> *
> * Contributor(s): Michel Selten, Willian Germano, Jacques Guignot,
> * Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton, Johnny Matthews,
> - * Ken Hughes, Alex Mole, Jean-Michel Soler
> + * Ken Hughes, Alex Mole, Jean-Michel Soler, Cedric Paille
> *
> * ***** END GPL LICENSE BLOCK *****
> */
> @@ -117,6 +117,7 @@
> #include "EXPP_interface.h"
> #include "BIF_editkey.h"
> #include "IDProp.h"
> +#include "Particle.h"
>
> /* Defines for insertIpoKey */
>
> @@ -336,6 +337,9 @@
> static int setupSB(Object* ob); /*Make sure Softbody Pointer is initialized */
> static int setupPI(Object* ob);
>
> +static PyObject *Object_getParticleSys( BPy_Object * self );
> +/* fixme Object_newParticleSys( self, default-partsys-name ) */
> +static PyObject *Object_newParticleSys( 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 );
> @@ -465,6 +469,10 @@
> /*****************************************************************************/
> static PyMethodDef BPy_Object_methods[] = {
> /* name, method, flags, doc */
> + {"getParticleSystems", ( PyCFunction ) Object_getParticleSys, METH_NOARGS,
> + "Return a list of particle systems"},
> + {"newParticleSystem", ( PyCFunction ) Object_newParticleSys, METH_NOARGS,
> + "Create and link a new particle system"},
> {"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
> "Recalcs particle system (if any), (depricated, will always return an empty list in version 2.46)"},
> {"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
> @@ -1026,6 +1034,78 @@
> /* Python BPy_Object methods: */
> /*****************************************************************************/
>
> +PyObject *Object_getParticleSys( BPy_Object * self ){
> + ParticleSystem *blparticlesys = 0;
> + Object *ob = self->object;
> + PyObject *partsyslist,*current;
> +
> + blparticlesys = ob->particlesystem.first;
> +
> + partsyslist = PyList_New( 0 );
> +
> + if (!blparticlesys)
> + return partsyslist;
> +
> + current = ParticleSys_CreatePyObject( blparticlesys, ob );
> + PyList_Append(partsyslist,current);
> +
> + while(blparticlesys = blparticlesys->next){
> + current = ParticleSys_CreatePyObject( blparticlesys, ob );
> + PyList_Append(partsyslist,current);
> + }
> +
> + return partsyslist;
> +}
> +
> +PyObject *Object_newParticleSys( BPy_Object * self ){
> + ParticleSystem *psys = 0;
> + ParticleSystem *rpsys = 0;
> + ModifierData *md;
> + ParticleSystemModifierData *psmd;
> + Object *ob = self->object;
> + char *name = NULL;
> + ID *id;
> + int nr;
> +
> + id = (ID *)psys_new_settings("PSys", G.main);
> +
> + psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
> + psys->pointcache = BKE_ptcache_add();
> + psys->flag |= PSYS_ENABLED;
> + BLI_addtail(&ob->particlesystem,psys);
> +
> + md = modifier_new(eModifierType_ParticleSystem);
> + sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
> + psmd = (ParticleSystemModifierData*) md;
> + psmd->psys=psys;
> + BLI_addtail(&ob->modifiers, md);
> +
> + psys->part=(ParticleSettings*)id;
> + psys->totpart=0;
> + psys->flag=PSYS_ENABLED|PSYS_CURRENT;
> + psys->cfra=bsystem_time(ob,(float)G.scene->r.cfra+1,0.0);
> + rpsys = psys;
> +
> + /* check need for dupliobjects */
> +
> + nr=0;
> + for(psys=ob->particlesystem.first; psys; psys=psys->next){
> + if(ELEM(psys->part->draw_as,PART_DRAW_OB,PART_DRAW_GR))
> + nr++;
> + }
> + if(nr)
> + ob->transflag |= OB_DUPLIPARTS;
> + else
> + ob->transflag &= ~OB_DUPLIPARTS;
> +
> + BIF_undo_push("Browse Particle System");
> +
> + DAG_scene_sort(G.scene);
> + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
> +
> + return ParticleSys_CreatePyObject(rpsys,ob);
> +}
> +
> static PyObject *Object_buildParts( BPy_Object * self )
> {
> /* This is now handles by modifiers */
>
> Modified: trunk/blender/source/blender/python/api2_2x/Particle.c
> ===================================================================
> --- trunk/blender/source/blender/python/api2_2x/Particle.c 2008-05-11 02:28:01 UTC (rev 14782)
> +++ trunk/blender/source/blender/python/api2_2x/Particle.c 2008-05-11 04:15:21 UTC (rev 14783)
> @@ -22,941 +22,1813 @@
> *
> * This is a new part of Blender.
> *
> - * Contributor(s): Jacques Guignot, Jean-Michel Soler
> + * Contributor(s):
> + * Original version: Jacques Guignot, Jean-Michel Soler
> + * Rewrite : Cedric Paille, Stephen Swaney, Joilnen Leite
> *
> * ***** END GPL LICENSE BLOCK *****
> */
>
> -#include "Particle.h" /*This must come first */
> -
> -#include "DNA_object_types.h"
> -#include "BKE_effect.h"
> +#include "Particle.h"
> +#include "gen_utils.h"
> +#include "BKE_object.h"
> +#include "BKE_main.h"
> +#include "BKE_particle.h"
> #include "BKE_global.h"
> -#include "BKE_main.h"
> -#include "BKE_object.h"
> +#include "BKE_depsgraph.h"
> +#include "BKE_modifier.h"
> +#include "BKE_material.h"
> +#include "BKE_utildefines.h"
> +#include "BKE_pointcache.h"
> +#include "BIF_editparticle.h"
> +#include "BIF_space.h"
> +#include "blendef.h"
> +#include "DNA_modifier_types.h"
> +#include "DNA_scene_types.h"
> +#include "DNA_material_types.h"
> #include "BLI_blenlib.h"
> -#include "gen_utils.h"
> +#include "mydevice.h"
> +#include "Object.h"
> +#include "Material.h"
>
> -/*****************************************************************************/
> -/* Python API function prototypes for the Particle module. */
> -/*****************************************************************************/
> -PyObject *M_Particle_New( PyObject * self, PyObject * args );
> -PyObject *M_Particle_Get( PyObject * self, PyObject * args );
> +#include "MEM_guardedalloc.h"
>
> -/*****************************************************************************/
> -/* 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 );
>
> -/*****************************************************************************/
> -/* Python Particle_Type callback function prototypes: */
> -/*****************************************************************************/
> -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( void );
> -PyObject *ParticleCreatePyObject( struct Effect *particle );
> -int ParticleCheckPyObject( PyObject * py_obj );
> -struct Particle *ParticleFromPyObject( PyObject * py_obj );
>
> -
> -/*****************************************************************************/
> -/* Python BPy_Particle methods table: */
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
More information about the Bf-committers
mailing list