diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_particle.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 6 |
3 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index f357e77f84e..1416e1280cf 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -283,6 +283,8 @@ void psys_mat_hair_to_object(struct Object *ob, struct DerivedMesh *dm, short fr void psys_mat_hair_to_global(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[][4]); void psys_mat_hair_to_orco(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[][4]); +float psys_get_dietime_from_cache(struct PointCache *cache, int index); + void psys_free_pdd(struct ParticleSystem *psys); float *psys_cache_vgroup(struct DerivedMesh *dm, struct ParticleSystem *psys, int vgroup); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a27097f836c..a72e44df205 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1121,6 +1121,24 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float return ret == 2; } + +float psys_get_dietime_from_cache(PointCache *cache, int index) { + PTCacheMem *pm; + int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ + + for(pm=cache->mem_cache.last; pm; pm=pm->prev) { + if(pm->index_array) { + if(pm->index_array[index]) + return (float)pm->frame; + } + else { + return (float)pm->frame; + } + } + + return (float)dietime; +} + static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind) { diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fb0282c860b..2cf1e4ca00c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1983,6 +1983,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->dietime = pa->time + pa->lifetime; + if(sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED && + sim->psys->pointcache->mem_cache.first) { + float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p); + pa->dietime = MIN2(pa->dietime, dietime); + } + if(pa->time > cfra) pa->alive = PARS_UNBORN; else if(pa->dietime <= cfra) |