diff options
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index cf636cc2b94..d8841962e7b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -157,6 +157,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_main.h" #include "BKE_node.h" #include "BKE_packedFile.h" // for packAll +#include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_screen.h" // for waitcursor #include "BKE_sequence.h" @@ -582,19 +583,27 @@ static void write_boid_state(WriteData *wd, BoidState *state) /* TODO: replace *cache with *cachelist once it's coded */ #define PTCACHE_WRITE_PSYS 0 #define PTCACHE_WRITE_CLOTH 1 -static void write_pointcaches(WriteData *wd, PointCache *cache, int type) +static void write_pointcaches(WriteData *wd, ListBase *ptcaches) { - writestruct(wd, DATA, "PointCache", 1, cache); + PointCache *cache = ptcaches->first; + int i; + + for(; cache; cache=cache->next) { + writestruct(wd, DATA, "PointCache", 1, cache); - if((cache->flag & PTCACHE_DISK_CACHE)==0) { - PTCacheMem *pm = cache->mem_cache.first; + if((cache->flag & PTCACHE_DISK_CACHE)==0) { + PTCacheMem *pm = cache->mem_cache.first; - for(; pm; pm=pm->next) { - writestruct(wd, DATA, "PTCacheMem", 1, pm); - if(type==PTCACHE_WRITE_PSYS) - writestruct(wd, DATA, "ParticleKey", pm->totpoint, pm->data); - else if(type==PTCACHE_WRITE_CLOTH) - writedata(wd, DATA, 9 * sizeof(float) * pm->totpoint, pm->data); + for(; pm; pm=pm->next) { + writestruct(wd, DATA, "PTCacheMem", 1, pm); + if(pm->index_array) + writedata(wd, DATA, sizeof(int) * pm->totpoint, pm->index_array); + + for(i=0; i<BPHYS_TOT_DATA; i++) { + if(pm->data[i] && pm->data_types & (1<<i)) + writedata(wd, DATA, BKE_ptcache_data_size(i) * pm->totpoint, pm->data[i]); + } + } } } } @@ -652,8 +661,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles) if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child); writestruct(wd, DATA, "SoftBody", 1, psys->soft); - if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS); - write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS); + if(psys->soft) write_pointcaches(wd, &psys->soft->ptcaches); + write_pointcaches(wd, &psys->ptcaches); } } @@ -1112,7 +1121,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms); writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); - write_pointcaches(wd, clmd->point_cache, PTCACHE_WRITE_CLOTH); + write_pointcaches(wd, &clmd->ptcaches); } else if(md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; |