From 979aa4e9904017144b049f90ff14a6cc928b437d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 9 Mar 2010 03:01:18 +0000 Subject: Point cache optimization: only cache particles that are alive. This reduces point cache sizes dramatically especially if particle life time is small compared to total simulation length. For example with the settings: particle amount = 10000, start = 1, end = 200, life = 10, cache step = 1, the unoptimized blend file size (compressed) was a little over 22 Mb and with this optimization the file is a little under 2 Mb (again compressed). In addition to saving memory/disk space this also probably speeds up reading from cache, since there's less data to read. As an additional fix the memory cache size (displayed in cache panel) is now calculated correctly. --- source/blender/blenkernel/intern/particle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/particle.c') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b88df677c9b..97e8d6c7f7d 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1067,12 +1067,12 @@ static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int inde while(pm && pm->next && (float)pm->frame < t) pm = pm->next; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] : index, pm->data, (float)pm->frame); - BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] : index, pm->prev->data, (float)pm->prev->frame); + BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); + BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { PTCacheMem *pm2 = cache->mem_cache.first; - BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] : index, pm2->data, (float)pm2->frame); + BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] - 1 : index, pm2->data, (float)pm2->frame); copy_particle_key(key1, key2, 1); } } -- cgit v1.2.3