Added an "effector" vertex group for hair, that defines how much
influence effectors have.
This commit is contained in:
@@ -2272,6 +2272,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
|
||||
float sel_col[3];
|
||||
float nosel_col[3];
|
||||
float length, vec[3];
|
||||
float *vg_effector= NULL, effector=0.0f;
|
||||
|
||||
/* we don't have anything valid to create paths from so let's quit here */
|
||||
if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0)
|
||||
@@ -2320,6 +2321,9 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
|
||||
ma= give_current_material(ob, psys->part->omat);
|
||||
if(ma && (psys->part->draw & PART_DRAW_MAT_COL))
|
||||
VECCOPY(col, &ma->r)
|
||||
|
||||
if(psys->part->from!=PART_FROM_PARTICLE)
|
||||
vg_effector = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_EFFECTOR);
|
||||
|
||||
/*---first main loop: create all actual particles' paths---*/
|
||||
for(i=0,pa=psys->particles; i<totpart; i++, pa++){
|
||||
@@ -2456,6 +2460,10 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
|
||||
VecSubf(vec,(cache[i]+1)->co,cache[i]->co);
|
||||
length = VecLength(vec);
|
||||
|
||||
effector= 1.0f;
|
||||
if(vg_effector)
|
||||
effector*= psys_interpolate_value_from_verts(psmd->dm,psys->part->from,pa->num,pa->fuv,vg_effector);
|
||||
|
||||
for(k=0, ca=cache[i]; k<=steps; k++, ca++) {
|
||||
/* apply effectors */
|
||||
if(edit==0 && k) {
|
||||
@@ -2468,7 +2476,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
|
||||
|
||||
do_effectors(i, pa, &eff_key, ob, psys, force, vel, dfra, cfra);
|
||||
|
||||
VecMulf(force, pow((float)k / (float)steps, 100.0f * psys->part->eff_hair) / (float)steps);
|
||||
VecMulf(force, effector*pow((float)k / (float)steps, 100.0f * psys->part->eff_hair) / (float)steps);
|
||||
|
||||
VecAddf(force, force, vec);
|
||||
|
||||
@@ -2581,6 +2589,9 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
|
||||
end_latt_deform();
|
||||
psys->lattice=0;
|
||||
}
|
||||
|
||||
if(vg_effector)
|
||||
MEM_freeN(vg_effector);
|
||||
}
|
||||
/************************************************/
|
||||
/* Particle Key handling */
|
||||
|
||||
@@ -2724,7 +2724,8 @@ static void apply_particle_forces(int pa_no, ParticleData *pa, Object *ob, Parti
|
||||
force[0]=force[1]=force[2]=0.0;
|
||||
tvel[0]=tvel[1]=tvel[2]=0.0;
|
||||
/* add effectors */
|
||||
do_effectors(pa_no,pa,states+i,ob,psys,force,tvel,dfra,fra);
|
||||
if(part->type != PART_HAIR)
|
||||
do_effectors(pa_no,pa,states+i,ob,psys,force,tvel,dfra,fra);
|
||||
|
||||
/* calculate air-particle interaction */
|
||||
if(part->dragfac!=0.0f){
|
||||
|
||||
@@ -415,7 +415,7 @@ typedef struct ParticleSystem{
|
||||
#define PARS_ALIVE 3
|
||||
|
||||
/* psys->vg */
|
||||
#define PSYS_TOT_VG 11
|
||||
#define PSYS_TOT_VG 12
|
||||
|
||||
#define PSYS_VG_DENSITY 0
|
||||
#define PSYS_VG_VEL 1
|
||||
@@ -428,6 +428,7 @@ typedef struct ParticleSystem{
|
||||
#define PSYS_VG_SIZE 8
|
||||
#define PSYS_VG_TAN 9
|
||||
#define PSYS_VG_ROT 10
|
||||
#define PSYS_VG_EFFECTOR 11
|
||||
|
||||
/* part->boidrules */
|
||||
#define BOID_TOT_RULES 8
|
||||
|
||||
@@ -4028,7 +4028,7 @@ static void object_panel_particle_extra(Object *ob)
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
uiDefButS(block, MENU, B_PART_REDRAW, "Attribute%t|TanRot%x10|TanVel%x9|Size%x8|RoughE%x7|Rough2%x6|Rough1%x5|Kink%x4|Clump%x3|Length%x2|Velocity%x1|Density%x0", butx,(buty-=buth),butw-40,buth, &vgnum, 14.0, 0.0, 0, 0, "Attribute effected by vertex group");
|
||||
uiDefButS(block, MENU, B_PART_REDRAW, "Attribute%t|Effector%x11|TanRot%x10|TanVel%x9|Size%x8|RoughE%x7|Rough2%x6|Rough1%x5|Kink%x4|Clump%x3|Length%x2|Velocity%x1|Density%x0", butx,(buty-=buth),butw-40,buth, &vgnum, 14.0, 0.0, 0, 0, "Attribute effected by vertex group");
|
||||
but=uiDefButBitS(block, TOG, (1<<vgnum), B_PART_REDRAW, "Neg", butx+butw-40,buty,40,buth, &psys->vg_neg, 0, 0, 0, 0, "Negate the effect of the vertex group");
|
||||
uiButSetFunc(but, particle_set_vg, (void *)ob, (void *)(&vgnum));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user