diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-03-09 06:01:18 +0300 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-03-09 06:01:18 +0300 |
commit | 979aa4e9904017144b049f90ff14a6cc928b437d (patch) | |
tree | 10d0387a6e9a6d1252061bb7dcf055d63f3871c2 /source/blender/blenkernel/intern/particle.c | |
parent | 417c328874746d4c77f75eaf146da5414ee87958 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 6 |
1 files changed, 3 insertions, 3 deletions
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); } } |