From 912c2f440b447aa8cae9f3e3a86acf51cd495e3d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 27 Jun 2009 15:28:58 +0000 Subject: Pointcache refresh part 2 * Based on what happens during simulation the cache is marked (also in cache panel, this could possibly be extended to 3d view as well) as: - exact (not marked) - outdated (simulation is not done completely with current settings) - non-exact (frames were skipped during simulation) * The parameter "cache step" effects the number of frames between saved cache frames. - This can save a lot of memory (or disk space) if absolutely frame accurate simulation is not required. - Speeds up the "quick caching" very much. - Frames between cached frames are interpolated from the cached frames. - Current default value of 10 frames works nicely with up/down-arrows (skip 10 frames forwards/backwards on timeline), but can be changed if wanted. * The caching can work in normal or "quick" mode: [Normal cache] - Basic: Calculate what even happens (settings change, big frame steps etc.) and cache results, if possible try to use "cache step" when saving cache frames. - Becomes non-exact: After larger than 1 frame steps. - Becomes outdated: After any change effecting the simulation other than frame steps. - Pros/cons: Freedom of doing anything and playing with particles, but exact results have to calculated from the beginning. [Quick cache] - Basic: Calculate simulation up to current frame automatically on changes with cache step sized jumps in simulation. With multiple "quick cached" simulations the smallest cache step is used. - Becomes non-exact: Always from frame 1 (unless cache step = 1). - Becomes outdated: Never. - Pros/cons: Not very accurate, but super fast! - Todo: Transform of any animated (non-autokeyed) object is locked! Probably needs some tinkering with anim sys overrides. * The simulation can be run forwards or backwards even if it's cache is outdated or non-exact, the following rules apply in these situations: - step forwards (to unknown) -> simulate from last exact frame, store result - step backwards (to known) -> result is interpolated from existing frames, store result, clear cache forwards if current frame is after last exact frame * "Calculate to current frame" runs the simulation from start to current frame with a frame steps of 1. - Baking does the same, but runs the simulation all the way to the end of simulation. - Rendering does this automatically if the simulation is outdated of non-exact, so all rendered simulations will always be updated and exact. * Every cache panel also holds buttons to "Bake all dynamics", "Free all dynamics" and "Update all dynamics to current frame". * Cloth simulation supports the new cache too. --- source/blender/blenkernel/BKE_pointcache.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/BKE_pointcache.h') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index b79357edf36..3f1c45d28ec 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -93,7 +93,7 @@ typedef struct PTCacheWriter { int cfra; int totelem; - float *(*elem_ptr)(int index, void *calldata); + void (*set_elem)(int index, void *calldata, float *data); void *calldata; } PTCacheWriter; @@ -103,12 +103,10 @@ typedef struct PTCacheReader { float cfra; int totelem; - void (*set_elem)(int index, void *calldata, float *data); - void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, int cfra1, int cfra2, float *data1, float *data2); + void (*set_elem)(int elem_index, void *calldata, float *data); + void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, float cfra1, float cfra2, float *data1, float *data2); void *calldata; - int allow_interpolate; - int allow_old; int *old_frame; } PTCacheReader; @@ -116,6 +114,7 @@ typedef struct PTCacheBaker { struct Scene *scene; int bake; int render; + int quick_step; struct PTCacheID *pid; int (*break_test)(void *data); void *break_data; @@ -146,6 +145,8 @@ void BKE_ptcache_file_close(PTCacheFile *pf); int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot); int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot); +void BKE_ptcache_update_info(PTCacheID *pid); + /* General cache reading/writing */ int BKE_ptcache_read_cache(PTCacheReader *reader); int BKE_ptcache_write_cache(PTCacheWriter *writer); @@ -160,7 +161,7 @@ void BKE_ptcache_free(struct PointCache *cache); struct PointCache *BKE_ptcache_copy(struct PointCache *cache); /* Baking */ -void BKE_ptcache_autocache_all(struct Scene *scene); +void BKE_ptcache_quick_cache_all(struct Scene *scene); void BKE_ptcache_make_cache(struct PTCacheBaker* baker); void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); -- cgit v1.2.3