Fix: Smoke wasn't using pointcache properly.

* The cache was reset almost constantly because smoke didn't save the first frame into cache. Although not necessary for smoke, it's vital to pointcache.
* Added info message to smoke cache panel for non saved files.
* Now smoke also only updates with a framestep of 1, so that scrubbing the timeline doesn't mess up the simulation.
* Among other things fixes report #23731.
This commit is contained in:
2010-09-27 12:24:12 +00:00
parent d6c8b41144
commit 8bc0cfc1ca
2 changed files with 24 additions and 4 deletions

View File

@@ -51,6 +51,11 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
layout.label(text=cache.info)
else:
if cachetype == 'SMOKE':
if bpy.data.is_dirty:
layout.label(text="Cache is disabled until the file is saved")
layout.enabled = false
layout.prop(cache, "name", text="File Name")
split = layout.split()

View File

@@ -1338,10 +1338,17 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
cache_wt = sds->point_cache[1];
BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd);
if(!smd->domain->fluid)
if(!smd->domain->fluid || framenr == startframe)
{
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_OUTDATED);
if(cache_wt) {
BKE_ptcache_validate(cache_wt, framenr);
cache_wt->flag &= ~PTCACHE_REDO_NEEDED;
}
}
if(framenr < startframe)
@@ -1368,6 +1375,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
if(cache_result == PTCACHE_READ_EXACT)
{
BKE_ptcache_validate(cache, framenr);
smd->time = framenr;
if(sds->wt)
{
@@ -1388,14 +1396,21 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
else
return;
}
/* only calculate something when we advanced a frame */
if(framenr == smd->time)
/* only calculate something when we advanced a single frame */
else if(framenr != (int)smd->time+1)
return;
tstart();
smoke_calc_domain(scene, ob, smd);
/* if on second frame, write cache for first frame */
/* this needs to be done for smoke too so that pointcache works properly */
if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) {
BKE_ptcache_write_cache(&pid, startframe);
if(sds->wt)
BKE_ptcache_write_cache(&pid_wt, startframe);
}
// set new time
smd->time = scene->r.cfra;