static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr) { SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; smokeModifier_reset(settings->smd); rna_Smoke_resetCache(bmain, scene, ptr); rna_Smoke_update(bmain, scene, ptr); }
static void rna_Smoke_reset_dependancy(Main *bmain, Scene *scene, PointerRNA *ptr) { SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; smokeModifier_reset(settings->smd); if(settings->smd && settings->smd->domain) settings->smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; rna_Smoke_dependency_update(bmain, scene, ptr); }
void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) { if((smd->type & MOD_SMOKE_TYPE_FLOW)) { if(scene->r.cfra >= smd->time) smokeModifier_init(smd, ob, scene, dm); if(scene->r.cfra > smd->time) { // XXX TODO smd->time = scene->r.cfra; // rigid movement support /* Mat4CpyMat4(smd->flow->mat_old, smd->flow->mat); Mat4CpyMat4(smd->flow->mat, ob->obmat); */ } else if(scene->r.cfra < smd->time) { smd->time = scene->r.cfra; smokeModifier_reset(smd); } } else if(smd->type & MOD_SMOKE_TYPE_COLL) { if(scene->r.cfra >= smd->time) smokeModifier_init(smd, ob, scene, dm); if(scene->r.cfra > smd->time) { // XXX TODO smd->time = scene->r.cfra; if(smd->coll->dm) smd->coll->dm->release(smd->coll->dm); smd->coll->dm = CDDM_copy(dm); // rigid movement support Mat4CpyMat4(smd->coll->mat_old, smd->coll->mat); Mat4CpyMat4(smd->coll->mat, ob->obmat); } else if(scene->r.cfra < smd->time) { smd->time = scene->r.cfra; smokeModifier_reset(smd); } } else if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { SmokeDomainSettings *sds = smd->domain; float light[3]; PointCache *cache = NULL; PTCacheID pid; PointCache *cache_wt = NULL; PTCacheID pid_wt; int startframe, endframe, framenr; float timescale; int cache_result = 0, cache_result_wt = 0; framenr = scene->r.cfra; // printf("time: %d\n", scene->r.cfra); if(framenr == smd->time) return; cache = sds->point_cache[0]; BKE_ptcache_id_from_smoke(&pid, ob, smd); BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); cache_wt = sds->point_cache[1]; BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd); if(!smd->domain->fluid) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_OUTDATED); } if(framenr < startframe) return; if(framenr > endframe) return; if(!smd->domain->fluid && (framenr != startframe)) return; // printf("startframe: %d, framenr: %d\n", startframe, framenr); if(!smokeModifier_init(smd, ob, scene, dm)) { printf("bad smokeModifier_init\n"); return; } /* try to read from cache */ cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); // printf("cache_result: %d\n", cache_result); if(cache_result == PTCACHE_READ_EXACT) { cache->flag |= PTCACHE_SIMULATION_VALID; cache->simframe= framenr; if(sds->wt) { cache_result_wt = BKE_ptcache_read_cache(&pid_wt, (float)framenr, scene->r.frs_sec); if(cache_result_wt == PTCACHE_READ_EXACT) { cache_wt->flag |= PTCACHE_SIMULATION_VALID; cache_wt->simframe= framenr; } } return; } tstart(); smoke_calc_domain(scene, ob, smd); // set new time smd->time = scene->r.cfra; /* do simulation */ // low res cache->flag |= PTCACHE_SIMULATION_VALID; cache->simframe= framenr; // simulate the actual smoke (c++ code in intern/smoke) // DG: interesting commenting this line + deactivating loading of noise files if(framenr!=startframe) { if(sds->flags & MOD_SMOKE_DISSOLVE) smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); smoke_step(sds->fluid, smd->time); } // create shadows before writing cache so we get nice shadows for sstartframe, too if(get_lamp(scene, light)) smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx); BKE_ptcache_write_cache(&pid, framenr); if(sds->wt) { if(framenr!=startframe) { if(sds->flags & MOD_SMOKE_DISSOLVE) smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); smoke_turbulence_step(sds->wt, sds->fluid); } cache_wt->flag |= PTCACHE_SIMULATION_VALID; cache_wt->simframe= framenr; BKE_ptcache_write_cache(&pid_wt, framenr); } tend(); printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); } }