Fix for particle texture influence bug causing undefined (nan) values: When using a texture with "Particles/Strands" coordinates that in turn has a "Lifetime" influence on the particles, the texture eval

accesses the particle lifetime/dietime data before it is actually defined! This is a design flaw, but to avoid corrupted data for now just initialize the lifetime/dietime values for particles in advance
before evaluating the texture.
This commit is contained in:
Lukas Toenne 2013-10-29 14:48:25 +00:00
parent 56cf901f03
commit 2cccdd1678

@ -2006,6 +2006,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = 100.0f; pa->lifetime = 100.0f;
} }
else { else {
/* initialize the lifetime, in case the texture coordinates
* are from Particles/Strands, which would cause undefined values
*/
pa->lifetime = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(p + 21));
pa->dietime = pa->time + pa->lifetime;
/* get possible textural influence */ /* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);