Fix linking errors WITH_MOD_FLUID=OFF

This commit is contained in:
Campbell Barton 2019-12-17 08:38:08 +11:00
parent 714e48ec55
commit 79c3e8db26
9 changed files with 100 additions and 30 deletions

View File

@ -1024,6 +1024,7 @@ static void do_physical_effector(EffectorCache *eff,
break;
case PFIELD_SMOKEFLOW:
zero_v3(force);
#ifdef WITH_FLUID
if (pd->f_source) {
float density;
if ((density = BKE_fluid_get_velocity_at(pd->f_source, point->loc, force)) >= 0.0f) {
@ -1036,6 +1037,7 @@ static void do_physical_effector(EffectorCache *eff,
madd_v3_v3fl(total_force, point->vel, -pd->f_flow * influence);
}
}
#endif
break;
}

View File

@ -87,6 +87,8 @@
#include "BLI_kdtree.h"
#include "BLI_voxel.h"
#ifdef WITH_FLUID
static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
struct Mesh;
@ -95,11 +97,11 @@ struct Scene;
struct FluidModifierData;
// timestep default value for nice appearance 0.1f
#define DT_DEFAULT 0.1f
# define DT_DEFAULT 0.1f
#define ADD_IF_LOWER_POS(a, b) (min_ff((a) + (b), max_ff((a), (b))))
#define ADD_IF_LOWER_NEG(a, b) (max_ff((a) + (b), min_ff((a), (b))))
#define ADD_IF_LOWER(a, b) (((b) > 0) ? ADD_IF_LOWER_POS((a), (b)) : ADD_IF_LOWER_NEG((a), (b)))
# define ADD_IF_LOWER_POS(a, b) (min_ff((a) + (b), max_ff((a), (b))))
# define ADD_IF_LOWER_NEG(a, b) (max_ff((a) + (b), min_ff((a), (b))))
# define ADD_IF_LOWER(a, b) (((b) > 0) ? ADD_IF_LOWER_POS((a), (b)) : ADD_IF_LOWER_NEG((a), (b)))
void BKE_fluid_reallocate_fluid(FluidDomainSettings *mds, int res[3], int free_old)
{
@ -856,11 +858,11 @@ void fluidModifier_createType(struct FluidModifierData *mmd)
mmd->domain->cache_high_comp = SM_CACHE_LIGHT;
/* OpenVDB cache options */
#ifdef WITH_OPENVDB_BLOSC
# ifdef WITH_OPENVDB_BLOSC
mmd->domain->openvdb_comp = VDB_COMPRESSION_BLOSC;
#else
# else
mmd->domain->openvdb_comp = VDB_COMPRESSION_ZIP;
#endif
# endif
mmd->domain->clipping = 1e-3f;
mmd->domain->data_depth = 0;
}
@ -1300,10 +1302,10 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
data->velocityZ[index] += (data->mes->type == FLUID_EFFECTOR_TYPE_GUIDE) ?
hit_vel[2] * data->mes->vel_multi :
hit_vel[2];
#if 0
# if 0
/* Debugging: Print object velocities. */
printf("adding effector object vel: [%f, %f, %f], dx is: %f\n", hit_vel[0], hit_vel[1], hit_vel[2], mds->dx);
#endif
# endif
}
}
}
@ -1576,10 +1578,10 @@ static void update_obstacles(Depsgraph *depsgraph,
scene->r.subframe = 0.0f;
scene->r.cfra = frame;
}
#if 0
# if 0
/* Debugging: Print subframe information. */
printf("effector: frame: %d // scene current frame: %d // scene current subframe: %f\n", frame, scene->r.cfra, scene->r.subframe);
#endif
# endif
/* TODO (sebbas): Using BKE_scene_frame_get(scene) instead of new DEG_get_ctime(depsgraph) as
* subframes dont work with the latter yet. */
BKE_object_modifier_update_subframe(
@ -2403,10 +2405,10 @@ static void sample_mesh(FluidFlowSettings *mfs,
velocity_map[index * 3] += hit_vel[0] * mfs->vel_multi;
velocity_map[index * 3 + 1] += hit_vel[1] * mfs->vel_multi;
velocity_map[index * 3 + 2] += hit_vel[2] * mfs->vel_multi;
#if 0
# if 0
/* Debugging: Print flow object velocities. */
printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
#endif
# endif
}
velocity_map[index * 3] += mfs->vel_coord[0];
velocity_map[index * 3 + 1] += mfs->vel_coord[1];
@ -3303,10 +3305,10 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
}
/* Sanity check: subframe portion must be between 0 and 1 */
CLAMP(scene->r.subframe, 0.0f, 1.0f);
#if 0
# if 0
/* Debugging: Print subframe information. */
printf("flow: frame (is first: %d): %d // scene current frame: %d // scene current subframe: %f\n", is_first_frame, frame, scene->r.cfra, scene->r.subframe);
#endif
# endif
/* Update frame time, this is considering current subframe fraction
* BLI_mutex_lock() called in manta_step(), so safe to update subframe here
* TODO (sebbas): Using BKE_scene_frame_get(scene) instead of new DEG_get_ctime(depsgraph)
@ -3351,10 +3353,10 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
}
}
}
#if 0
# if 0
/* Debugging: Print time information. */
printf("flow: frame: %d // time per frame: %f // frame length: %f // dt: %f\n", frame, time_per_frame, frame_length, dt);
#endif
# endif
/* Adjust domain size if needed. Only do this once for every frame */
if (mds->type == FLUID_DOMAIN_TYPE_GAS && mds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
@ -3683,10 +3685,10 @@ static Mesh *createLiquidGeometry(FluidDomainSettings *mds, Mesh *orgmesh, Objec
num_normals = manta_liquid_get_num_normals(mds->fluid);
num_faces = manta_liquid_get_num_triangles(mds->fluid);
#if 0
# if 0
/* Debugging: Print number of vertices, normals, and faces. */
printf("num_verts: %d, num_normals: %d, num_faces: %d\n", num_verts, num_normals, num_faces);
#endif
# endif
if (!num_verts || !num_faces) {
return NULL;
@ -3732,10 +3734,10 @@ static Mesh *createLiquidGeometry(FluidDomainSettings *mds, Mesh *orgmesh, Objec
mverts->co[0] *= max_size / fabsf(ob->scale[0]);
mverts->co[1] *= max_size / fabsf(ob->scale[1]);
mverts->co[2] *= max_size / fabsf(ob->scale[2]);
#if 0
# if 0
/* Debugging: Print coordinates of vertices. */
printf("mverts->co[0]: %f, mverts->co[1]: %f, mverts->co[2]: %f\n", mverts->co[0], mverts->co[1], mverts->co[2]);
#endif
# endif
}
// Normals
@ -3747,10 +3749,10 @@ static Mesh *createLiquidGeometry(FluidDomainSettings *mds, Mesh *orgmesh, Objec
no[2] = manta_liquid_get_normal_z_at(mds->fluid, i);
normal_float_to_short_v3(no_s, no);
#if 0
# if 0
/* Debugging: Print coordinates of normals. */
printf("no_s[0]: %d, no_s[1]: %d, no_s[2]: %d\n", no_s[0], no_s[1], no_s[2]);
#endif
# endif
}
// Triangles
@ -3765,10 +3767,10 @@ static Mesh *createLiquidGeometry(FluidDomainSettings *mds, Mesh *orgmesh, Objec
mloops[0].v = manta_liquid_get_triangle_x_at(mds->fluid, i);
mloops[1].v = manta_liquid_get_triangle_y_at(mds->fluid, i);
mloops[2].v = manta_liquid_get_triangle_z_at(mds->fluid, i);
#if 0
# if 0
/* Debugging: Print mesh faces. */
printf("mloops[0].v: %d, mloops[1].v: %d, mloops[2].v: %d\n", mloops[0].v, mloops[1].v, mloops[2].v);
#endif
# endif
}
BKE_mesh_ensure_normals(me);
@ -3799,10 +3801,10 @@ static Mesh *createLiquidGeometry(FluidDomainSettings *mds, Mesh *orgmesh, Objec
velarray[i].vel[0] = manta_liquid_get_vertvel_x_at(mds->fluid, i) * (mds->dx / time_mult);
velarray[i].vel[1] = manta_liquid_get_vertvel_y_at(mds->fluid, i) * (mds->dx / time_mult);
velarray[i].vel[2] = manta_liquid_get_vertvel_z_at(mds->fluid, i) * (mds->dx / time_mult);
#if 0
# if 0
/* Debugging: Print velocities of vertices. */
printf("velarray[%d].vel[0]: %f, velarray[%d].vel[1]: %f, velarray[%d].vel[2]: %f\n", i, velarray[i].vel[0], i, velarray[i].vel[1], i, velarray[i].vel[2]);
#endif
# endif
}
return me;
@ -4770,3 +4772,5 @@ void BKE_fluid_delete_particle_system(struct Object *ob, const int particle_type
}
}
}
#endif /* WITH_FLUID */

View File

@ -60,6 +60,7 @@ if(WITH_MOD_FLUID)
list(APPEND LIB
bf_intern_mantaflow
)
add_definitions(-DWITH_FLUID)
endif()
if(WITH_INTERNATIONAL)

View File

@ -494,7 +494,9 @@ static void fluid_free_startjob(void *customdata, short *stop, short *do_update,
if (fluid_is_free_guiding(job) || fluid_is_free_all(job)) {
cache_map |= FLUID_DOMAIN_OUTDATED_GUIDING;
}
#ifdef WITH_FLUID
BKE_fluid_cache_free(mds, job->ob, cache_map);
#endif
*do_update = true;
*stop = 0;

View File

@ -940,12 +940,14 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
/* *************************** Transfer functions *************************** */
#ifdef WITH_FLUID
enum {
TFUNC_FLAME_SPECTRUM = 0,
TFUNC_COLOR_RAMP = 1,
};
#define TFUNC_WIDTH 256
# define TFUNC_WIDTH 256
static void create_flame_spectrum_texture(float *data)
{
@ -1160,6 +1162,8 @@ static GPUTexture *create_flame_texture(FluidDomainSettings *mds, int highres)
return tex;
}
#endif /* WITH_FLUID */
void GPU_free_smoke(FluidModifierData *mmd)
{
if (mmd->type & MOD_FLUID_TYPE_DOMAIN && mmd->domain) {
@ -1197,6 +1201,9 @@ void GPU_free_smoke(FluidModifierData *mmd)
void GPU_create_smoke_coba_field(FluidModifierData *mmd)
{
#ifndef WITH_FLUID
UNUSED_VARS(mmd);
#else
if (mmd->type & MOD_FLUID_TYPE_DOMAIN) {
FluidDomainSettings *mds = mmd->domain;
@ -1207,10 +1214,14 @@ void GPU_create_smoke_coba_field(FluidModifierData *mmd)
mds->tex_coba = create_transfer_function(TFUNC_COLOR_RAMP, mds->coba);
}
}
#endif
}
void GPU_create_smoke(FluidModifierData *mmd, int highres)
{
#ifndef WITH_FLUID
UNUSED_VARS(mmd, highres);
#else
if (mmd->type & MOD_FLUID_TYPE_DOMAIN) {
FluidDomainSettings *mds = mmd->domain;
@ -1236,10 +1247,14 @@ void GPU_create_smoke(FluidModifierData *mmd, int highres)
NULL);
}
}
#endif /* WITH_FLUID */
}
void GPU_create_smoke_velocity(FluidModifierData *mmd)
{
#ifndef WITH_FLUID
UNUSED_VARS(mmd);
#else
if (mmd->type & MOD_FLUID_TYPE_DOMAIN) {
FluidDomainSettings *mds = mmd->domain;
@ -1260,6 +1275,7 @@ void GPU_create_smoke_velocity(FluidModifierData *mmd)
mds->res[0], mds->res[1], mds->res[2], GPU_R16F, vel_z, NULL);
}
}
#endif /* WITH_FLUID */
}
/* TODO Unify with the other GPU_free_smoke. */

View File

@ -87,9 +87,14 @@ static void rna_Fluid_resetCache(Main *UNUSED(bmain), Scene *scene, PointerRNA *
}
static void rna_Fluid_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
fluidModifier_reset(settings->mmd);
# ifdef WITH_FLUID
{
FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
fluidModifier_reset(settings->mmd);
}
# endif
rna_Fluid_resetCache(bmain, scene, ptr);
rna_Fluid_update(bmain, scene, ptr);
@ -99,7 +104,9 @@ static void rna_Fluid_reset_dependency(Main *bmain, Scene *scene, PointerRNA *pt
{
FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
# ifdef WITH_FLUID
fluidModifier_reset(settings->mmd);
# endif
if (settings->mmd && settings->mmd->domain)
settings->mmd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED;
@ -114,14 +121,22 @@ static void rna_Fluid_parts_create(Main *bmain,
const char *psys_name,
int psys_type)
{
# ifndef WITH_FLUID
UNUSED_VARS(bmain, ptr, pset_name, parts_name, psys_name, psys_type);
# else
Object *ob = (Object *)ptr->owner_id;
BKE_fluid_create_particle_system(bmain, ob, pset_name, parts_name, psys_name, psys_type);
# endif
}
static void rna_Fluid_parts_delete(PointerRNA *ptr, int ptype)
{
# ifndef WITH_FLUID
UNUSED_VARS(ptr, ptype);
# else
Object *ob = (Object *)ptr->owner_id;
BKE_fluid_delete_particle_system(ob, ptype);
# endif
}
static bool rna_Fluid_parts_exists(PointerRNA *ptr, int ptype)
@ -635,6 +650,12 @@ static char *rna_FluidEffectorSettings_path(PointerRNA *ptr)
return BLI_sprintfN("modifiers[\"%s\"].effec_settings", name_esc);
}
/* -------------------------------------------------------------------- */
/** \name Grid Accessors
* \{ */
# ifdef WITH_FLUID
static int rna_FluidModifier_grid_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
FluidDomainSettings *mds = (FluidDomainSettings *)ptr->data;
@ -855,6 +876,9 @@ static void rna_FluidModifier_temperature_grid_get(PointerRNA *ptr, float *value
BLI_rw_mutex_unlock(mds->fluid_mutex);
}
# endif /* WITH_FLUID */
/** \} */
static void rna_FluidFlow_density_vgroup_get(PointerRNA *ptr, char *value)
{
@ -1196,6 +1220,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
/* grid access */
# ifdef WITH_FLUID
prop = RNA_def_property(srna, "density_grid", PROP_FLOAT, PROP_NONE);
RNA_def_property_array(prop, 32);
RNA_def_property_flag(prop, PROP_DYNAMIC);
@ -1244,6 +1269,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_FluidModifier_temperature_grid_get", NULL, NULL);
RNA_def_property_ui_text(
prop, "Temperature Grid", "Smoke temperature grid, range 0..1 represents 0..1000K");
# endif /* WITH_FLUID */
/* domain object data */

View File

@ -1038,8 +1038,10 @@ static void rna_fluid_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
return;
}
# ifdef WITH_FLUID
fluidModifier_free(mmd); /* XXX TODO: completely free all 3 pointers */
fluidModifier_createType(mmd); /* create regarding of selected type */
# endif
switch (mmd->type) {
case MOD_FLUID_TYPE_DOMAIN:

View File

@ -133,6 +133,10 @@ if(WITH_MOD_REMESH)
add_definitions(-DWITH_MOD_REMESH)
endif()
if(WITH_MOD_FLUID)
add_definitions(-DWITH_FLUID)
endif()
if(WITH_MOD_OCEANSIM)
add_definitions(-DWITH_OCEANSIM)
endif()

View File

@ -60,18 +60,26 @@ static void initData(ModifierData *md)
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#ifndef WITH_FLUID
UNUSED_VARS(md, target, flag);
#else
const FluidModifierData *mmd = (const FluidModifierData *)md;
FluidModifierData *tmmd = (FluidModifierData *)target;
fluidModifier_free(tmmd);
fluidModifier_copy(mmd, tmmd, flag);
#endif /* WITH_FLUID */
}
static void freeData(ModifierData *md)
{
#ifndef WITH_FLUID
UNUSED_VARS(md);
#else
FluidModifierData *mmd = (FluidModifierData *)md;
fluidModifier_free(mmd);
#endif /* WITH_FLUID */
}
static void requiredDataMask(Object *UNUSED(ob),
@ -96,6 +104,10 @@ static void requiredDataMask(Object *UNUSED(ob),
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *me)
{
#ifndef WITH_FLUID
UNUSED_VARS(md, ctx);
return me;
#else
FluidModifierData *mmd = (FluidModifierData *)md;
Mesh *result = NULL;
@ -107,6 +119,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
result = fluidModifier_do(mmd, ctx->depsgraph, scene, ctx->object, me);
return result ? result : me;
#endif /* WITH_FLUID */
}
static bool dependsOnTime(ModifierData *UNUSED(md))