diff options
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 38 | ||||
-rw-r--r-- | source/blender/include/butspace.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_effect_types.h | 4 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 33 |
4 files changed, 66 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 8955b5ab2bd..2c2dbeaf06b 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1447,6 +1447,35 @@ static void make_weight_tables(PartEff *paf, Mesh *me, int totpart, MVert *vertl } } +/* helper function for build_particle_system() */ +static void make_length_tables(PartEff *paf, Mesh *me, int totvert, MFace *facelist, int totface, float **vlengths, float **flengths) +{ + MFace *mface; + float *folengths=NULL, *volengths=NULL; + int a; + + if((paf->flag & PAF_FACE)==0) totface= 0; + + /* collect emitting vertices & faces if vert groups used */ + if(paf->vertgroup_v && me->dvert) { + + /* allocate lengths array for all vertices, also for lookup of faces later on. note it's a malloc */ + *vlengths= volengths= MEM_mallocN( totvert*sizeof(float), "pafvolengths" ); + for(a=0; a<totvert; a++) { + volengths[a]= vert_weight(me->dvert+a, paf->vertgroup_v-1); + } + + if(totface) { + /* allocate lengths array for faces, note it's a malloc */ + *flengths= folengths= MEM_mallocN(totface*sizeof(float), "paffolengths" ); + for(a=0, mface=facelist; a<totface; a++, mface++) { + folengths[a] = face_weight(mface, volengths); + } + } + } +} + + /* for paf start to end, store all matrices for objects */ typedef struct pMatrixCache { float obmat[4][4]; @@ -1533,6 +1562,7 @@ void build_particle_system(Object *ob) float ftime, dtime, force[3], vec[3]; float fac, co[3]; float *voweights= NULL, *foweights= NULL, maxw=1.0f; + float *volengths= NULL, *folengths= NULL; int deform=0, a, totpart, paf_sta, paf_end; int dmNeedsFree, waitcursor_set= 0, totvert, totface, curface, curvert; short no[3]; @@ -1632,6 +1662,9 @@ void build_particle_system(Object *ob) /* if vertexweights or even distribution, it makes weight tables, also checks where it emits from */ make_weight_tables(paf, me, totpart, vertlist, totvert, facelist, totface, &voweights, &foweights); + /* vertexweights can define lengths too */ + make_length_tables(paf, me, totvert, facelist, totface, &volengths, &folengths); + /* now define where to emit from, if there are face weights we skip vertices */ if(paf->flag & PAF_OFACE) totvert= 0; if((paf->flag & PAF_FACE)==0) totface= 0; @@ -1819,6 +1852,9 @@ void build_particle_system(Object *ob) } pa->mat_nr= paf->omat; + if(folengths) + pa->lifetime*= folengths[curface]; + make_particle_keys(rng, ob, 0, a, paf, pa, force, deform, mtexmove, ob->lay); } @@ -1826,6 +1862,8 @@ void build_particle_system(Object *ob) give_mesh_particle_coord(NULL, NULL, NULL, 0, 0, NULL, NULL); if(voweights) MEM_freeN(voweights); if(foweights) MEM_freeN(foweights); + if(volengths) MEM_freeN(volengths); + if(folengths) MEM_freeN(folengths); if(mcache) MEM_freeN(mcache); if(deform) end_latt_deform(); diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index e6e291fb285..4cace979965 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -628,6 +628,7 @@ enum { #define B_FIELD_DEP 3414 #define B_FIELD_CHANGE 3415 #define B_PAF_SET_VG 3416 +#define B_PAF_SET_VG1 3417 #define B_MODIFIER_BUTS 3600 diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h index 084ad9ac82f..46ce9b7d017 100644 --- a/source/blender/makesdna/DNA_effect_types.h +++ b/source/blender/makesdna/DNA_effect_types.h @@ -122,9 +122,9 @@ typedef struct PartEff { short child[4], mat[4]; short texmap, curmult; short staticstep, omat, timetex, speedtex, flag2, flag2neg; - short disp, pad; + short disp, vertgroup_v; - char vgroupname[32]; + char vgroupname[32], vgroupname_v[32]; Particle *keys; } PartEff; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 05412d88862..e00c66d332a 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1624,6 +1624,20 @@ void do_effects_panels(unsigned short event) allqueue(REDRAWVIEW3D, 0); } break; + case B_PAF_SET_VG1: + + paf= give_parteff(ob); + if(paf) { + bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname_v); + if(dg) + paf->vertgroup_v= get_defgroup_num(ob, dg)+1; + else + paf->vertgroup_v= 0; + + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + } + break; case B_FIELD_DEP: DAG_scene_sort(G.scene); DAG_object_flush_update(G.scene, ob, OB_RECALC_OB); @@ -1895,6 +1909,7 @@ static void object_softbodies(Object *ob) static void object_panel_particles_motion(Object *ob) { uiBlock *block; + uiBut *but; PartEff *paf= give_parteff(ob); if (paf==NULL) return; @@ -1912,16 +1927,18 @@ static void object_panel_particles_motion(Object *ob) uiBlockEndAlign(block); /* left collumn */ - uiDefBut(block, LABEL, 0, "Velocity:", 0,150,150,20, NULL, 0.0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Velocity:", 0,160,150,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING2); - uiDefButF(block, NUM, B_CALCEFFECT, "Normal:", 0,130,150,20, &paf->normfac, -2.0, 2.0, 1, 3, "Let the mesh give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Object:", 0,110,150,20, &paf->obfac, -1.0, 1.0, 1, 3, "Let the object give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Random:", 0,90,150,20, &paf->randfac, 0.0, 2.0, 1, 3, "Give the startingspeed a random variation"); - uiDefButF(block, NUM, B_CALCEFFECT, "Texture:", 0,70,150,20, &paf->texfac, 0.0, 2.0, 1, 3, "Let the texture give the particle a starting speed"); - uiDefButF(block, NUM, B_CALCEFFECT, "Damping:", 0,50,150,20, &paf->damp, 0.0, 1.0, 1, 3, "Specify the damping factor"); - uiBlockEndAlign(block); + uiDefButF(block, NUM, B_CALCEFFECT, "Normal:", 0,140,150,18, &paf->normfac, -2.0, 2.0, 1, 3, "Let the mesh give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Object:", 0,122,150,18, &paf->obfac, -1.0, 1.0, 1, 3, "Let the object give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Random:", 0,104,150,18, &paf->randfac, 0.0, 2.0, 1, 3, "Give the startingspeed a random variation"); + uiDefButF(block, NUM, B_CALCEFFECT, "Texture:", 0,86,150,18, &paf->texfac, 0.0, 2.0, 1, 3, "Let the texture give the particle a starting speed"); + uiDefButF(block, NUM, B_CALCEFFECT, "Damping:", 0,68,150,18, &paf->damp, 0.0, 1.0, 1, 3, "Specify the damping factor"); uiBlockSetCol(block, TH_AUTO); + but=uiDefBut(block, TEX, B_PAF_SET_VG1, "VGroup:", 0,50,150,18, paf->vgroupname_v, 0, 31, 0, 0, "Name of vertex group to use for speed control"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)OBACT); + uiBlockEndAlign(block); uiDefBut(block, LABEL, 0, "Texture Emission", 0,30,150,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); @@ -1977,7 +1994,7 @@ static void object_panel_particles(Object *ob) uiDefBut(block, LABEL, 0, "Emit:", 0,150,75,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButI(block, NUM, B_CALCEFFECT, "Amount:", 0,130,150,20, &paf->totpart, 1.0, 100000.0, 0, 0, "The total number of particles"); + uiDefButI(block, NUM, B_CALCEFFECT, "Amount:", 0,130,150,20, &paf->totpart, 1.0, 100000.0, 0, 0, "The total number of particles"); if(paf->flag & PAF_STATIC) { uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 0,110,150,20, &paf->staticstep, 1.0, 100.0, 10, 0, "For static duplicators, the Step value skips particles"); } |