From 1fd33b6e777d54a3702e58253dabf94a752783e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jul 2011 18:40:21 +0000 Subject: [PATCH] cmake option to build without smoke sim: WITH_MOD_SMOKE --- CMakeLists.txt | 1 + intern/CMakeLists.txt | 5 ++++- intern/smoke/CMakeLists.txt | 2 +- source/blender/blenkernel/CMakeLists.txt | 4 ++++ source/blender/blenkernel/SConscript | 2 ++ source/blender/blenkernel/intern/pointcache.c | 6 ++++++ source/blender/blenkernel/intern/smoke.c | 17 +++++++++++++++++ source/blender/gpu/CMakeLists.txt | 4 ++++ source/blender/gpu/SConscript | 2 ++ source/blender/gpu/intern/gpu_draw.c | 6 ++++++ source/blender/render/CMakeLists.txt | 4 ++++ source/blender/render/SConscript | 2 ++ source/blender/render/intern/source/voxeldata.c | 9 ++++++++- 13 files changed, 61 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28b68c1e673..e5cd23ab66a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ endif() # Modifiers option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON) +option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON) option(WITH_MOD_DECIMATE "Enable Decimate Modifier" ON) option(WITH_MOD_BOOLEAN "Enable Boolean Modifier" ON) option(WITH_MOD_CLOTH_ELTOPO "Enable Experemental cloth solver" OFF) diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index 4c36cb43e7d..fe30d6cfa0c 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -31,7 +31,6 @@ add_subdirectory(moto) add_subdirectory(memutil) add_subdirectory(iksolver) add_subdirectory(opennl) -add_subdirectory(smoke) add_subdirectory(mikktspace) if(WITH_AUDASPACE) @@ -42,6 +41,10 @@ if(WITH_MOD_FLUID) add_subdirectory(elbeem) endif() +if(WITH_MOD_SMOKE) + add_subdirectory(smoke) +endif() + if(WITH_MOD_DECIMATE) add_subdirectory(container) add_subdirectory(decimation) diff --git a/intern/smoke/CMakeLists.txt b/intern/smoke/CMakeLists.txt index 30313f45a92..174ee8bc3ed 100644 --- a/intern/smoke/CMakeLists.txt +++ b/intern/smoke/CMakeLists.txt @@ -84,7 +84,7 @@ set(SRC ) if(WITH_OPENMP) - add_definitions(-DPARALLEL=1) + add_definitions(-DPARALLEL=1) endif() if(WITH_FFTW3) diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index a19d48daa75..92c50242e74 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -306,6 +306,10 @@ if(NOT WITH_MOD_FLUID) add_definitions(-DDISABLE_ELBEEM) endif() +if(WITH_MOD_SMOKE) + add_definitions(-DWITH_SMOKE) +endif() + if(WITH_JACK) add_definitions(-DWITH_JACK) endif() diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index b5f845acacb..36afce7946c 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -21,6 +21,8 @@ incs += ' ' + env['BF_ZLIB_INC'] defs = [ 'GLEW_STATIC' ] +defs.append('WITH_SMOKE') # TODO, make optional + if env['WITH_BF_PYTHON']: incs += ' ../python' incs += ' ' + env['BF_PYTHON_INC'] diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6b92c6e9540..b8f4b2d302f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -516,6 +516,7 @@ static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra)) return clmd->clothObject ? clmd->clothObject->numverts : 0; } +#ifdef WITH_SMOKE /* Smoke functions */ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) { @@ -652,6 +653,11 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) } } } +#else // WITH_SMOKE +static int ptcache_smoke_totpoint(void *UNUSED(smoke_v), int UNUSED(cfra)) { return 0; }; +static void ptcache_smoke_read(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) {} +static int ptcache_smoke_write(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; } +#endif // WITH_SMOKE /* Creating ID's */ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 4405bce3d51..6ab1574ca80 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -140,6 +140,19 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) #define TRI_UVOFFSET (1./4.) +/* Stubs to use when smoke is disabled */ +#ifndef WITH_SMOKE +struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; } +struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; } +void smoke_free(struct FLUID_3D *UNUSED(fluid)) {} +void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {} +void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {} +void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {} +long long smoke_get_mem_req(int UNUSED(xres), int UNUSED(yres), int UNUSED(zres), int UNUSED(amplify)) { return 0; } +void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) {} +#endif // WITH_SMOKE + + static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid) @@ -805,6 +818,9 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData // forward decleration static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct); static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct); + +#ifdef WITH_SMOKE + static int get_lamp(Scene *scene, float *light) { Base *base_tmp = NULL; @@ -1646,3 +1662,4 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa } } +#endif // WITH_SMOKE diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index ce3150476f9..76e347270ba 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -56,6 +56,10 @@ set(SRC intern/gpu_codegen.h ) +if(WITH_MOD_SMOKE) + add_definitions(-DWITH_SMOKE) +endif() + add_definitions(-DGLEW_STATIC) blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript index 515c7166c2a..b48e1d5a8e2 100644 --- a/source/blender/gpu/SConscript +++ b/source/blender/gpu/SConscript @@ -13,4 +13,6 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_OPENGL_INC'] +defs.append('WITH_SMOKE') # TODO, make optional + env.BlenderLib ( 'bf_gpu', sources, Split(incs), defines = defs, libtype=['core','player'], priority=[160,110] ) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 87d25ac850a..9878d83ff5a 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -822,12 +822,18 @@ void GPU_free_smoke(SmokeModifierData *smd) void GPU_create_smoke(SmokeModifierData *smd, int highres) { +#ifdef WITH_SMOKE if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres) smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smoke_get_density(smd->domain->fluid)); else if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highres) smd->domain->tex = GPU_texture_create_3D(smd->domain->res_wt[0], smd->domain->res_wt[1], smd->domain->res_wt[2], smoke_turbulence_get_density(smd->domain->wt)); smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow); +#else // WITH_SMOKE + (void)highres; + smd->domain->tex= NULL; + smd->domain->tex_shadow= NULL; +#endif // WITH_SMOKE } static ListBase image_free_queue = {NULL, NULL}; diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index a2d698b739e..003f0b839f8 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -120,6 +120,10 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +if(WITH_MOD_SMOKE) + add_definitions(-DWITH_SMOKE) +endif() + if(WITH_CODEC_QUICKTIME) list(APPEND INC ../quicktime) list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript index a402139b927..bff7797e0c7 100644 --- a/source/blender/render/SConscript +++ b/source/blender/render/SConscript @@ -14,6 +14,8 @@ cxxflags_raytrace = env['CXXFLAGS'] defs = [] defs_raytrace = [] +defs.append('WITH_SMOKE') # TODO, make optional + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): if env['WITH_BF_RAYOPTIMIZATION']: cflags_raytrace = env['CCFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index b8cb5c21337..232f7fdeede 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -220,6 +220,7 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) static void init_frame_smoke(VoxelData *vd, float cfra) { +#ifdef WITH_SMOKE Object *ob; ModifierData *md; @@ -300,7 +301,13 @@ static void init_frame_smoke(VoxelData *vd, float cfra) } vd->ok = 1; - return; + +#else // WITH_SMOKE + (void)vd; + (void)cfra; + + vd->dataset= NULL; +#endif } static void cache_voxeldata(struct Render *re, Tex *tex)