Fix for [#22167] Hair lattice only works with dynamic hair

* Doing hair effectors, guides & lattices all in one loop didn't work properly
This commit is contained in:
Janne Karhu
2010-07-25 13:18:15 +00:00
parent cc0f3146e7
commit 1e7f96343e

View File

@@ -2787,7 +2787,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step));
int totpart = psys->totpart;
float length, vec[3];
float *vg_effector= NULL, effector=0.0f;
float *vg_effector= NULL;
float *vg_length= NULL, pa_length=1.0f;
int keyed, baked;
@@ -2889,31 +2889,37 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/*--modify paths and calculate rotation & velocity--*/
sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co);
length = len_v3(vec);
effector= 1.0f;
if(!(psys->flag & PSYS_GLOBAL_HAIR)) {
/* apply effectors */
if((psys->part->flag & PART_CHILD_EFFECT) == 0) {
float effector= 1.0f;
if(vg_effector)
effector*= psys_particle_value_from_verts(psmd->dm,psys->part->from,pa,vg_effector);
for(k=0, ca=cache[p]; k<=steps; k++, ca++) {
if(!(psys->flag & PSYS_GLOBAL_HAIR)) {
/* apply effectors */
if(!(psys->part->flag & PART_CHILD_EFFECT) && k)
sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co);
length = len_v3(vec);
for(k=1, ca=cache[p]+1; k<=steps; k++, ca++)
do_path_effectors(sim, p, ca, k, steps, cache[p]->co, effector, dfra, cfra, &length, vec);
}
/* apply guide curves to path data */
if(sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0)
if(sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) {
for(k=0, ca=cache[p]; k<=steps; k++, ca++)
/* ca is safe to cast, since only co and vel are used */
do_guides(sim->psys->effectors, (ParticleKey*)ca, p, (float)k/(float)steps);
}
/* apply lattice */
if(psys->lattice)
/* lattices have to be calculated separately to avoid mixups between effector calculations */
if(psys->lattice) {
for(k=0, ca=cache[p]; k<=steps; k++, ca++)
calc_latt_deform(psys->lattice, ca->co, 1.0f);
}
}
/* finally do rotation & velocity */
for(k=1, ca=cache[p]+1; k<=steps; k++, ca++) {
/* figure out rotation */
if(k) {
float cosangle, angle, tangent[3], normal[3], q[4];
if(k == 1) {
@@ -2954,21 +2960,14 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
if(k == steps)
QUATCOPY(ca->rot, (ca - 1)->rot);
}
}
/* set velocity */
if(k){
VECSUB(ca->vel, ca->co, (ca-1)->co);
if(k==1) {
if(k==1)
VECCOPY((ca-1)->vel, ca->vel);
}
}
}
}
psys->totcached = totpart;