Fix for [#23298] Kill particle breaks when baking simulation

* Cached particle die times are now read from cached data
This commit is contained in:
Janne Karhu
2010-09-02 10:26:19 +00:00
parent 2e61c4be9b
commit f611fa80af
3 changed files with 26 additions and 0 deletions

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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)