diff options
author | Janne Karhu <jhkarh@gmail.com> | 2009-06-21 14:16:52 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2009-06-21 14:16:52 +0400 |
commit | 6b15024f4a7b999331694d8a9135d47e4b783a34 (patch) | |
tree | 0b5a5c3b02778a7ca9df7628e742f98704505bb7 /source/blender/blenloader | |
parent | 64274de2fe8ef3b9a98a5cb3bd7d691fa1cee600 (diff) |
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.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 24 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 20 |
2 files changed, 41 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a4856944d8a..77e256f1435 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2878,6 +2878,16 @@ static void direct_link_material(FileData *fd, Material *ma) static void direct_link_pointcache(FileData *fd, PointCache *cache) { + if((cache->flag & PTCACHE_DISK_CACHE)==0) { + PTCacheMem *pm; + + link_list(fd, &cache->mem_cache); + + pm = cache->mem_cache.first; + + for(; pm; pm=pm->next) + pm->data = newdataadr(fd, pm->data); + } cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE); cache->simframe= 0; } @@ -8996,6 +9006,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Scene *sce; Tex *tx; ParticleSettings *part; + Object *ob; for(screen= main->screen.first; screen; screen= screen->id.next) { do_versions_windowmanager_2_50(screen); @@ -9038,7 +9049,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; } - /* particle settings conversion */ + /* particle draw and render types */ for(part= main->particle.first; part; part= part->id.next) { if(part->draw_as) { if(part->draw_as == PART_DRAW_DOT) { @@ -9054,6 +9065,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + /* set old pointcaches to have disk cache flag */ + for(ob = main->object.first; ob; ob= ob->id.next) { + ParticleSystem *psys = ob->particlesystem.first; + + for(; psys; psys=psys->next) { + if(psys->pointcache) + psys->pointcache->flag |= PTCACHE_DISK_CACHE; + } + + /* TODO: softbody & cloth caches */ + } } /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f8112406e80..9ef062bd7b6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -549,6 +549,22 @@ static void write_userdef(WriteData *wd) } } +/* TODO: replace *cache with *cachelist once it's coded */ +#define PTCACHE_WRITE_PSYS 0 +static void write_pointcaches(WriteData *wd, PointCache *cache, int type) +{ + writestruct(wd, DATA, "PointCache", 1, cache); + + 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); + } + } +} static void write_particlesettings(WriteData *wd, ListBase *idbase) { ParticleSettings *part; @@ -585,8 +601,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) writestruct(wd, DATA, "PointCache", 1, psys->soft->pointcache); - writestruct(wd, DATA, "PointCache", 1, psys->pointcache); + if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS); + write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS); } } |