[Bf-blender-cvs] [5c00eda] openvdb: Merge branch 'master' into openvdb
Kévin Dietrich
noreply at git.blender.org
Sat Jan 9 06:16:18 CET 2016
Commit: 5c00edab940775d82e751d7c8f5323107f90c8f1
Author: Kévin Dietrich
Date: Sat Jan 9 05:55:15 2016 +0100
Branches: openvdb
https://developer.blender.org/rB5c00edab940775d82e751d7c8f5323107f90c8f1
Merge branch 'master' into openvdb
Conflicts:
source/blender/blenkernel/intern/smoke.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_smoke.h
index 45076f3,20366f0..0d99451
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@@ -33,11 -33,9 +33,11 @@@
* \author Daniel Genrich
*/
+struct OpenVDBCache;
+
typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
- struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, bool for_render);
+ struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
diff --cc source/blender/blenkernel/intern/smoke.c
index d2b562f,6287493..3b24cd7
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@@ -90,12 -90,14 +90,18 @@@
/* UNUSED so far, may be enabled later */
/* #define USE_SMOKE_COLLISION_DM */
+ //#define DEBUG_TIME
+
+ #ifdef DEBUG_TIME
+ # include "PIL_time.h"
+ #endif
+
#include "smoke_API.h"
+#ifdef WITH_OPENVDB
+# include "openvdb_capi.h"
+#endif
+
#ifdef WITH_SMOKE
static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
@@@ -2778,169 -2628,7 +2644,173 @@@ static DerivedMesh *createDomainGeometr
return result;
}
+/* simulate the actual smoke (c++ code in intern/smoke) */
- static void smokeModifier_step_simulation(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render, const int framenr, const int startframe)
++static void smokeModifier_step_simulation(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, const int framenr, const int startframe)
+{
+ SmokeDomainSettings *sds = smd->domain;
+
+ /* DG: interesting commenting this + deactivating loading of noise files */
+ if (framenr != startframe){
+ if (sds->flags & MOD_SMOKE_DISSOLVE) {
+ /* low res dissolve */
+ smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
+ /* high res dissolve */
+ if (sds->wt) {
+ smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
+ }
+ }
+
- step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base, for_render);
++ step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
+ }
+
+ /* create shadows before writing cache so they get stored */
+ smoke_calc_transparency(sds, scene);
+
+ if (sds->wt) {
+ smoke_turbulence_step(sds->wt, sds->fluid);
+ }
+}
+
- static void smokeModifier_process_pointcache(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render)
++static void smokeModifier_process_pointcache(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ SmokeDomainSettings *sds = smd->domain;
+ PointCache *cache = NULL;
+ PTCacheID pid;
+ int startframe, endframe, framenr;
+ float timescale;
+
+ framenr = scene->r.cfra;
+
+ //printf("time: %d\n", scene->r.cfra);
+
+ cache = sds->point_cache[0];
+ BKE_ptcache_id_from_smoke(&pid, ob, smd);
+ BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale);
+
+ if (!smd->domain->fluid || framenr == startframe)
+ {
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+ smokeModifier_reset_ex(smd, false);
+ BKE_ptcache_validate(cache, framenr);
+ cache->flag &= ~PTCACHE_REDO_NEEDED;
+ }
+
+ if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0)
+ return;
+
+ smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
+ CLAMP(framenr, startframe, endframe);
+
+ /* If already viewing a pre/after frame, no need to reload */
+ if ((smd->time == framenr) && (framenr != scene->r.cfra))
+ return;
+
+ if (smokeModifier_init(smd, ob, scene, dm) == 0)
+ {
+ printf("bad smokeModifier_init\n");
+ return;
+ }
+
+ /* try to read from cache */
+ if ((BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT)) {
+ BKE_ptcache_validate(cache, framenr);
+ smd->time = framenr;
+ return;
+ }
+
+ /* only calculate something when we advanced a single frame */
+ if (framenr != (int)smd->time + 1)
+ return;
+
+ /* don't simulate if viewing start frame, but scene frame is not real start frame */
+ if (framenr != scene->r.cfra)
+ return;
+
- tstart();
++#ifdef DEBUG_TIME
++ double start = PIL_check_seconds_timer();
++#endif
+
+ /* if on second frame, write cache for first frame */
+ if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
+ BKE_ptcache_write(&pid, startframe);
+ }
+
+ // set new time
+ smd->time = scene->r.cfra;
+
+ /* do simulation */
- smokeModifier_step_simulation(smd, scene, ob, dm, for_render, framenr, startframe);
++ smokeModifier_step_simulation(smd, scene, ob, dm, framenr, startframe);
+
+ BKE_ptcache_validate(cache, framenr);
+ if (framenr != startframe)
+ BKE_ptcache_write(&pid, framenr);
+
- tend();
- // printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, (float) tval() );
++#ifdef DEBUG_TIME
++ double end = PIL_check_seconds_timer();
++ printf("Frame: %d, Time: %f\n\n", (int)smd->time, (float)(end - start));
++#endif
+}
+
- static void smokeModifier_process_openvdb(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render)
++static void smokeModifier_process_openvdb(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ SmokeDomainSettings *sds = smd->domain;
+ OpenVDBCache *cache = BKE_openvdb_get_current_cache(sds);
+ int startframe, endframe, framenr;
+
+ framenr = scene->r.cfra;
+
+ if (cache) {
+ startframe = cache->startframe;
+ endframe = cache->endframe;
+ }
+ else {
+ startframe = scene->r.sfra;
+ endframe = scene->r.efra;
+ }
+
+ if (!smd->domain->fluid || framenr == startframe) {
+ smokeModifier_reset_ex(smd, false);
+ }
+
+ if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0)
+ return;
+
+ smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
+ CLAMP(framenr, startframe, endframe);
+
+ /* If already viewing a pre/after frame, no need to reload */
+ if ((smd->time == framenr) && (framenr != scene->r.cfra))
+ return;
+
+ if (smokeModifier_init(smd, ob, scene, dm) == 0) {
+ printf("bad smokeModifier_init\n");
+ return;
+ }
+
+ /* try to read from cache */
+ if (cache != NULL) {
+ if (smokeModifier_OpenVDB_import(smd, scene, ob, cache)) {
+ smd->time = framenr;
+ return;
+ }
+ }
+
+ /* only calculate something when we advanced a single frame */
+ if (framenr != (int)smd->time + 1)
+ return;
+
+ /* don't simulate if viewing start frame, but scene frame is not real start frame */
+ if (framenr != scene->r.cfra)
+ return;
+
+ // set new time
+ smd->time = scene->r.cfra;
+
+ /* do simulation */
- smokeModifier_step_simulation(smd, scene, ob, dm, for_render, framenr, startframe);
++ smokeModifier_step_simulation(smd, scene, ob, dm, framenr, startframe);
+}
+
- static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, bool for_render)
+ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
{
if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{
@@@ -2984,13 -2672,105 +2854,13 @@@
else if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
SmokeDomainSettings *sds = smd->domain;
- PointCache *cache = NULL;
- PTCacheID pid;
- int startframe, endframe, framenr;
- float timescale;
-
- framenr = scene->r.cfra;
-
- //printf("time: %d\n", scene->r.cfra);
-
- cache = sds->point_cache[0];
- BKE_ptcache_id_from_smoke(&pid, ob, smd);
- BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale);
-
- if (!smd->domain->fluid || framenr == startframe)
- {
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- smokeModifier_reset_ex(smd, false);
- BKE_ptcache_validate(cache, framenr);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- }
- if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0)
- return;
-
- smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
- CLAMP(framenr, startframe, endframe);
-
- /* If already viewing a pre/after frame, no need to reload */
- if ((smd->time == framenr) && (framenr != scene->r.cfra))
- return;
-
- if (smokeModifier_init(smd, ob, scene, dm) == 0)
- {
- printf("bad smokeModifier_init\n");
- return;
+ if (sds->cache_type == SMOKE_CACHE_POINTCACHE) {
- smokeModifier_process_pointcache(smd, scene, ob, dm, for_render);
++ smokeModifier_process_pointcache(smd, scene, ob, dm);
}
-
- /* try to read from cache */
- if (BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
- BKE_ptcache_validate(cache, framenr);
- smd->time = framenr;
- return;
- }
-
- /* only calculate something when we advanced a single frame */
- if (framenr != (int)smd->time + 1)
- return;
-
- /* don't simulate if viewing start frame, but scene frame is not real start frame */
- if (framenr != scene->r.cfra)
- return;
-
-#ifdef DEBUG_TIME
- double start = PIL_check_seconds_timer();
-#endif
-
- /* if on second frame, write cache for first frame */
- if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
- BKE_ptcache_write(&pid, startframe);
- }
-
- // set new time
- smd->time = scene->r.cfra;
-
- /* do simulation */
-
- // 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) {
- /* low res dissolve */
- smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
- /* high res dissolve */
- if (sds
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list