Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2009-08-12 13:54:29 +0400
committerJanne Karhu <jhkarh@gmail.com>2009-08-12 13:54:29 +0400
commitb221c0e2e6f390f3ed810b7f520b0ad60511ba36 (patch)
tree09b3b18e14773ee015959b214284cc5010f6fdc4 /source/blender/blenkernel/BKE_pointcache.h
parent8641833b57606a2ac21f7c83b53ea5fc55664815 (diff)
New point cache file format:
- HEADER (beginning of each file) * general header: + 8 char: "BPHYSICS" + 1 int: simulation type (same as PTCacheID->type) * custom header (same for sb, particles and cloth, but can be different for new dynamics) + 1 int: totpoint (number of points) + 1 int: data_types (bit flags for what the stored data is) - DATA (directly after header) *totpoint times the data as specified in data_types flags - simulation type soft body = 0, particles = 1, cloth = 2 - data types (more can be added easily when needed) data flag contains ---------------------------------------- index (1<<0) 1 int (index of current point) location (1<<1) 3 float velocity (1<<2) 3 float rotation (1<<3) 4 float (quaternion) avelocity (1<<4) 3 float (used for particles) xconst (1<<4) 3 float (used for cloth) size (1<<5) 1 float times (1<<6) 3 float (birth, die & lifetime of particle) boids (1<<7) 1 BoidData Notes: - Every frame is not nescessary since data is interpolated for the inbetween frames. - For now every point is needed for every cached frame, the "index" data type is reserved for future usage. - For loading external particle caches only "location" data is necessary, other needed values are determined from the given data. - Non-dynamic data should be written into an info file if external usage is desired. * Info file is named as normal cache files, but with frame number 0; * "Non-dynamic" means data such as particle times. * Written automatically when baking to disk so basically a library of particle simulations should be possible. - Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend. - External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui. Other changes: - Multiple point caches per dynamics system. * In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used. * Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present. - Generalization of point cache baking etc operator & rna code. - Comb brushing particle hair didn't work smoothly.
Diffstat (limited to 'source/blender/blenkernel/BKE_pointcache.h')
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h77
1 files changed, 46 insertions, 31 deletions
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 8062f807055..a719ab92a80 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -30,6 +30,8 @@
#define BKE_POINTCACHE_H
#include "DNA_ID.h"
+#include "DNA_object_force.h"
+#include "DNA_boid_types.h"
#include "MEM_guardedalloc.h"
@@ -73,42 +75,52 @@ struct ClothModifierData;
struct PointCache;
struct ListBase;
+/* temp structure for read/write */
+typedef struct PTCacheData {
+ int index;
+ float loc[3];
+ float vel[3];
+ float rot[4];
+ float ave[3];
+ float size;
+ float times[3];
+ struct BoidData boids;
+} PTCacheData;
+
typedef struct PTCacheFile {
FILE *fp;
+
+ int totpoint, type;
+ unsigned int data_types;
+
+ struct PTCacheData data;
+ void *cur[BPHYS_TOT_DATA];
} PTCacheFile;
typedef struct PTCacheID {
struct PTCacheID *next, *prev;
+ struct Scene *scene;
struct Object *ob;
- void *data;
+ void *calldata;
int type;
int stack_index;
+ unsigned int data_types, info_types;
- struct PointCache *cache;
-} PTCacheID;
-
-typedef struct PTCacheWriter {
- struct PTCacheID *pid;
- int cfra;
- int totelem;
-
- void (*set_elem)(int index, void *calldata, float *data);
- void *calldata;
-} PTCacheWriter;
+ int (*write_elem)(int index, void *calldata, void **data);
+ void (*read_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float *old_data);
+ void (*interpolate_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data);
-typedef struct PTCacheReader {
- struct Scene *scene;
- struct PTCacheID *pid;
- float cfra;
- int totelem;
+ int (*totpoint)(void *calldata);
+ int (*totwrite)(void *calldata);
- 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 (*write_header)(PTCacheFile *pf);
+ int (*read_header)(PTCacheFile *pf);
- int *old_frame;
-} PTCacheReader;
+ struct PointCache *cache;
+ struct PointCache **cache_ptr;
+ struct ListBase *ptcaches;
+} PTCacheID;
typedef struct PTCacheBaker {
struct Scene *scene;
@@ -123,6 +135,9 @@ typedef struct PTCacheBaker {
void *progresscontext;
} PTCacheBaker;
+/* Particle functions */
+void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time);
+
/* 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);
@@ -140,30 +155,30 @@ 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 Scene *scene, struct Object *ob, int mode);
-/* File reading/writing */
-PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra);
-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);
+int BKE_ptcache_data_size(int data_type);
+void BKE_ptcache_data_get(void **data, int type, int index, void *to);
+void BKE_ptcache_data_set(void **data, int type, void *from);
+int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec);
+int BKE_ptcache_write_cache(PTCacheID *pid, int cfra);
/* Continue physics */
void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable);
int BKE_ptcache_get_continue_physics(void);
/* Point Cache */
-struct PointCache *BKE_ptcache_add(void);
+struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches);
+void BKE_ptache_free_mem(struct PointCache *cache);
void BKE_ptcache_free(struct PointCache *cache);
+void BKE_ptcache_free_list(struct ListBase *ptcaches);
struct PointCache *BKE_ptcache_copy(struct PointCache *cache);
/* Baking */
void BKE_ptcache_quick_cache_all(struct Scene *scene);
void BKE_ptcache_make_cache(struct PTCacheBaker* baker);
+void BKE_ptcache_disk_to_mem(struct PTCacheID *pid);
void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
void BKE_ptcache_load_external(struct PTCacheID *pid);