Revision: 21372
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21372
Author:   jhk
Date:     2009-07-05 14:36:20 +0200 (Sun, 05 Jul 2009)

Log Message:
-----------
Added a particle instance modifier option to use particle size.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_modifier.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_modifier_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_modifier.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_modifier.py     
2009-07-05 06:36:56 UTC (rev 21371)
+++ branches/blender2.5/blender/release/ui/buttons_data_modifier.py     
2009-07-05 12:36:20 UTC (rev 21372)
@@ -299,12 +299,14 @@
                col = layout.column_flow()
                col.itemR(md, "normal")
                col.itemR(md, "children")
+               col.itemR(md, "size")
                col.itemR(md, "path")
                if md.path:
                        col.itemR(md, "keep_shape")
                col.itemR(md, "unborn")
                col.itemR(md, "alive")
                col.itemR(md, "dead")
+               col.itemL(md, "")
                if md.path:
                        col.itemR(md, "axis", text="")
                

Modified: 
branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c     
2009-07-05 06:36:56 UTC (rev 21371)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c     
2009-07-05 12:36:20 UTC (rev 21372)
@@ -6477,6 +6477,7 @@
        int i,totvert, totpart=0, totface, maxvert, maxface, first_particle=0;
        short track=ob->trackflag%3, trackneg, axis = pimd->axis;
        float max_co=0.0, min_co=0.0, temp_co[3], cross[3];
+       float *size=NULL;
 
        trackneg=((ob->trackflag>2)?1:0);
 
@@ -6503,6 +6504,25 @@
        if(totpart==0)
                return derivedData;
 
+       if(pimd->flag & eParticleInstanceFlag_UseSize) {
+               int p;
+               float *si;
+               si = size = MEM_callocN(totpart * sizeof(float), "particle size 
array");
+
+               if(pimd->flag & eParticleInstanceFlag_Parents) {
+                       for(p=0, pa= psys->particles; p<psys->totpart; p++, 
pa++, si++)
+                               *si = pa->size;
+               }
+
+               if(pimd->flag & eParticleInstanceFlag_Children) {
+                       ChildParticle *cpa = psys->child;
+
+                       for(p=0; p<psys->totchild; p++, cpa++, si++) {
+                               *si = psys_get_child_size(psys, cpa, 0.0f, 
NULL);
+                       }
+               }
+       }
+
        pars=psys->particles;
 
        totvert=dm->getNumVerts(dm);
@@ -6585,10 +6605,12 @@
                }
                else{
                        state.time=-1.0;
-                       psys_get_particle_state(md->scene, pimd->ob, psys, 
i/totvert, &state,1);
+                       psys_get_particle_state(md->scene, pimd->ob, psys, 
first_particle + i/totvert, &state,1);
                }       
 
                QuatMulVecf(state.rot,mv->co);
+               if(pimd->flag & eParticleInstanceFlag_UseSize)
+                       VecMulf(mv->co, size[i/totvert]);
                VECADD(mv->co,mv->co,state.co);
        }
 
@@ -6641,6 +6663,9 @@
                psys->lattice= NULL;
        }
 
+       if(size)
+               MEM_freeN(size);
+
        return result;
 }
 static DerivedMesh *particleInstanceModifier_applyModifierEM(
@@ -7279,10 +7304,10 @@
 
        timestep= psys_get_timestep(part);
 
-       if(part->flag & PART_GLOB_TIME)
+       //if(part->flag & PART_GLOB_TIME)
                cfra=bsystem_time(scene, 0,(float)scene->r.cfra,0.0);
-       else
-               cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
+       //else
+       //      cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
 
        /* hash table for vertice <-> particle relations */
        vertpahash= BLI_edgehash_new();

Modified: 
branches/blender2.5/blender/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_modifier_types.h    
2009-07-05 06:36:56 UTC (rev 21371)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_modifier_types.h    
2009-07-05 12:36:20 UTC (rev 21372)
@@ -504,6 +504,7 @@
        eParticleInstanceFlag_Alive =           (1<<4),
        eParticleInstanceFlag_Dead =            (1<<5),
        eParticleInstanceFlag_KeepShape =       (1<<6),
+       eParticleInstanceFlag_UseSize =         (1<<7),
 } ParticleInstanceModifierFlag;
 
 typedef struct ParticleInstanceModifierData {

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c   
2009-07-05 06:36:56 UTC (rev 21371)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c   
2009-07-05 12:36:20 UTC (rev 21372)
@@ -1365,6 +1365,11 @@
        RNA_def_property_ui_text(prop, "Keep Shape", "Don't stretch the 
object.");
        RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, 
"rna_Modifier_update");
 
+       prop= RNA_def_property(srna, "size", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
eParticleInstanceFlag_UseSize);
+       RNA_def_property_ui_text(prop, "Size", "Use particle size to scale the 
instances.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, 
"rna_Modifier_update");
+
        prop= RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "position");
        RNA_def_property_range(prop, 0.0, 1.0);


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to