From 3c6077e8ec59a2d2c74cf87ec1b54a5e168e7aa6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 7 Jan 2011 11:38:28 +0000 Subject: Bug fix: particle point cache was reset on start frame if particles had grid distribution even if there were no changes. --- source/blender/blenkernel/intern/particle_system.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 71cb3128506..207a9b8f839 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -130,6 +130,16 @@ int psys_get_current_display_percentage(ParticleSystem *psys) return psys->part->disp; } +static int tot_particles(ParticleSystem *psys, PTCacheID *pid) +{ + if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) + return pid->cache->totpoint; + else if(psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) + return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res; + else + return psys->part->totpart; +} + void psys_reset(ParticleSystem *psys, int mode) { PARTICLE_P; @@ -137,7 +147,7 @@ void psys_reset(ParticleSystem *psys, int mode) if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) { if(mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) { /* don't free if not absolutely necessary */ - if(psys->totpart != psys->part->totpart) { + if(psys->totpart != tot_particles(psys, NULL)) { psys_free_particles(psys); psys->totpart= 0; } @@ -3633,14 +3643,7 @@ static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNU ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; int oldtotpart = psys->totpart; - int totpart = oldtotpart; - - if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) - totpart = pid->cache->totpoint; - else if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) - totpart = part->grid_res*part->grid_res*part->grid_res; - else - totpart = psys->part->totpart; + int totpart = tot_particles(psys, pid); if(totpart != oldtotpart) realloc_particles(sim, totpart); -- cgit v1.2.3