Fix for [#24237] Hair dynamics with zero particles generates a segmentation fault
This commit is contained in:
parent
3d73a37b64
commit
d3bf6b7224
@ -402,6 +402,7 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics)
|
||||
modifier_free((ModifierData*)psys->clmd);
|
||||
|
||||
psys->clmd = NULL;
|
||||
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
|
||||
}
|
||||
else {
|
||||
cloth_free_modifier(ob, psys->clmd);
|
||||
|
@ -4016,8 +4016,13 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
|
||||
switch(part->type) {
|
||||
case PART_HAIR:
|
||||
{
|
||||
/* nothing to do so bail out early */
|
||||
if(psys->totpart == 0 && part->totpart == 0) {
|
||||
psys_free_path_cache(psys, NULL);
|
||||
free_hair(ob, psys, 0);
|
||||
}
|
||||
/* (re-)create hair */
|
||||
if(hair_needs_recalc(psys)) {
|
||||
else if(hair_needs_recalc(psys)) {
|
||||
float hcfra=0.0f;
|
||||
int i, recalc = psys->recalc;
|
||||
|
||||
|
@ -2993,13 +2993,17 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
||||
|
||||
void BKE_ptcache_validate(PointCache *cache, int framenr)
|
||||
{
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = framenr;
|
||||
if(cache) {
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = framenr;
|
||||
}
|
||||
}
|
||||
void BKE_ptcache_invalidate(PointCache *cache)
|
||||
{
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = 0;
|
||||
cache->last_exact = MIN2(cache->startframe, 0);
|
||||
if(cache) {
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = 0;
|
||||
cache->last_exact = MIN2(cache->startframe, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user