From 2cccdd1678c3813a00e319e5f0b82919f7397153 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 29 Oct 2013 14:48:25 +0000 Subject: 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. --- source/blender/blenkernel/intern/particle_system.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 526d54a97fa..ac32f96d59c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2006,6 +2006,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->lifetime = 100.0f; } 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 */ psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); -- cgit v1.2.3