From 6b15024f4a7b999331694d8a9135d47e4b783a34 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 21 Jun 2009 10:16:52 +0000 Subject: Pointcache refresh part 1: * Particles support larger than 1 frame changes, bigger frame changes can result in inaccurate results, but it's super fast and you get a nice feeling of how the particles behave! * "Cache to current frame" button calculates the exact result of particles at current frame. * Current state of cache can be protected by making it a bake. * Cache is now in memory by default, disk cache is an option. * Only "viewport %" number of particles are calculated and cached in viewport, baking and rendering calculate all particles. * Info on cached frames and memory usage given in ui. * Support for exact "autocaching" of changes and large frame changes(disabled for now until exact place in event system is decided) * "Continue physics" is probably deprecated after this and should be removed once sb & cloth use the new cache code. Todo: * Make softbody & cloth use the new cache things. Other changes: * Some cleanup of particle buttons. --- source/blender/blenkernel/BKE_pointcache.h | 56 ++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 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 8ef3ff4d4b7..b79357edf36 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -31,6 +31,8 @@ #include "DNA_ID.h" +#include "MEM_guardedalloc.h" + /* Point cache clearing option, for BKE_ptcache_id_clear, before * and after are non inclusive (they wont remove the cfra) */ #define PTCACHE_CLEAR_ALL 0 @@ -42,6 +44,7 @@ #define PTCACHE_RESET_DEPSGRAPH 0 #define PTCACHE_RESET_BAKED 1 #define PTCACHE_RESET_OUTDATED 2 +#define PTCACHE_RESET_FREE 3 /* Add the blendfile name after blendcache_ */ #define PTCACHE_EXT ".bphys" @@ -56,6 +59,11 @@ #define PTCACHE_TYPE_PARTICLES 1 #define PTCACHE_TYPE_CLOTH 2 +/* PTCache read return code */ +#define PTCACHE_READ_EXACT 1 +#define PTCACHE_READ_INTERPOLATED 2 +#define PTCACHE_READ_OLD 3 + /* Structs */ struct Object; struct Scene; @@ -80,6 +88,41 @@ typedef struct PTCacheID { struct PointCache *cache; } PTCacheID; +typedef struct PTCacheWriter { + struct PTCacheID *pid; + int cfra; + int totelem; + + float *(*elem_ptr)(int index, void *calldata); + void *calldata; +} PTCacheWriter; + +typedef struct PTCacheReader { + struct Scene *scene; + struct PTCacheID *pid; + 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 *calldata; + + int allow_interpolate; + int allow_old; + int *old_frame; +} PTCacheReader; + +typedef struct PTCacheBaker { + struct Scene *scene; + int bake; + int render; + struct PTCacheID *pid; + int (*break_test)(void *data); + void *break_data; + void (*progressbar)(void *data, int num); + void *progresscontext; +} PTCacheBaker; + /* Creating ID's */ void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb); void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys); @@ -93,9 +136,9 @@ void BKE_ptcache_remove(void); /* ID specific functions */ void BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra); int BKE_ptcache_id_exist(PTCacheID *id, int cfra); -int BKE_ptcache_id_reset(PTCacheID *id, int mode); +int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode); void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale); -int BKE_ptcache_object_reset(struct Object *ob, int mode); +int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode); /* File reading/writing */ PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra); @@ -103,6 +146,10 @@ 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); +/* General cache reading/writing */ +int BKE_ptcache_read_cache(PTCacheReader *reader); +int BKE_ptcache_write_cache(PTCacheWriter *writer); + /* Continue physics */ void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable); int BKE_ptcache_get_continue_physics(void); @@ -112,4 +159,9 @@ struct PointCache *BKE_ptcache_add(void); 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_make_cache(struct PTCacheBaker* baker); +void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); + #endif -- cgit v1.2.3