Fix T77766: support animated global gravity toggle
Reviewers: sebbas Differential Revision: https://developer.blender.org/D8281
This commit is contained in:
parent
4096330b81
commit
01ec76842f
|
@ -870,9 +870,9 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
|
||||||
mRNAMap["GUIDING_ALPHA"] = to_string(fds->guide_alpha);
|
mRNAMap["GUIDING_ALPHA"] = to_string(fds->guide_alpha);
|
||||||
mRNAMap["GUIDING_BETA"] = to_string(fds->guide_beta);
|
mRNAMap["GUIDING_BETA"] = to_string(fds->guide_beta);
|
||||||
mRNAMap["GUIDING_FACTOR"] = to_string(fds->guide_vel_factor);
|
mRNAMap["GUIDING_FACTOR"] = to_string(fds->guide_vel_factor);
|
||||||
mRNAMap["GRAVITY_X"] = to_string(fds->gravity[0]);
|
mRNAMap["GRAVITY_X"] = to_string(fds->gravity_final[0]);
|
||||||
mRNAMap["GRAVITY_Y"] = to_string(fds->gravity[1]);
|
mRNAMap["GRAVITY_Y"] = to_string(fds->gravity_final[1]);
|
||||||
mRNAMap["GRAVITY_Z"] = to_string(fds->gravity[2]);
|
mRNAMap["GRAVITY_Z"] = to_string(fds->gravity_final[2]);
|
||||||
mRNAMap["CACHE_DIR"] = cacheDirectory;
|
mRNAMap["CACHE_DIR"] = cacheDirectory;
|
||||||
mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
|
mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
|
||||||
mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
|
mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
|
||||||
|
|
|
@ -491,6 +491,17 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds,
|
||||||
fds->cell_size[2] /= (float)fds->base_res[2];
|
fds->cell_size[2] /= (float)fds->base_res[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_final_gravity(FluidDomainSettings *fds, Scene *scene)
|
||||||
|
{
|
||||||
|
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
|
||||||
|
copy_v3_v3(fds->gravity_final, scene->physics_settings.gravity);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy_v3_v3(fds->gravity_final, fds->gravity);
|
||||||
|
}
|
||||||
|
mul_v3_fl(fds->gravity_final, fds->effector_weights->global_gravity);
|
||||||
|
}
|
||||||
|
|
||||||
static bool BKE_fluid_modifier_init(
|
static bool BKE_fluid_modifier_init(
|
||||||
FluidModifierData *fmd, Depsgraph *depsgraph, Object *ob, Scene *scene, Mesh *me)
|
FluidModifierData *fmd, Depsgraph *depsgraph, Object *ob, Scene *scene, Mesh *me)
|
||||||
{
|
{
|
||||||
|
@ -502,10 +513,7 @@ static bool BKE_fluid_modifier_init(
|
||||||
/* Set domain dimensions from mesh. */
|
/* Set domain dimensions from mesh. */
|
||||||
manta_set_domain_from_mesh(fds, ob, me, true);
|
manta_set_domain_from_mesh(fds, ob, me, true);
|
||||||
/* Set domain gravity, use global gravity if enabled. */
|
/* Set domain gravity, use global gravity if enabled. */
|
||||||
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
|
update_final_gravity(fds, scene);
|
||||||
copy_v3_v3(fds->gravity, scene->physics_settings.gravity);
|
|
||||||
}
|
|
||||||
mul_v3_fl(fds->gravity, fds->effector_weights->global_gravity);
|
|
||||||
/* Reset domain values. */
|
/* Reset domain values. */
|
||||||
zero_v3_int(fds->shift);
|
zero_v3_int(fds->shift);
|
||||||
zero_v3(fds->shift_f);
|
zero_v3(fds->shift_f);
|
||||||
|
@ -3808,10 +3816,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
|
||||||
fds->time_per_frame = 0;
|
fds->time_per_frame = 0;
|
||||||
|
|
||||||
/* Ensure that gravity is copied over every frame (could be keyframed). */
|
/* Ensure that gravity is copied over every frame (could be keyframed). */
|
||||||
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
|
update_final_gravity(fds, scene);
|
||||||
copy_v3_v3(fds->gravity, scene->physics_settings.gravity);
|
|
||||||
mul_v3_fl(fds->gravity, fds->effector_weights->global_gravity);
|
|
||||||
}
|
|
||||||
|
|
||||||
int next_frame = scene_framenr + 1;
|
int next_frame = scene_framenr + 1;
|
||||||
int prev_frame = scene_framenr - 1;
|
int prev_frame = scene_framenr - 1;
|
||||||
|
|
|
@ -471,9 +471,10 @@ typedef struct FluidDomainSettings {
|
||||||
int res_max[3]; /* Cell max. */
|
int res_max[3]; /* Cell max. */
|
||||||
int res[3]; /* Data resolution (res_max-res_min). */
|
int res[3]; /* Data resolution (res_max-res_min). */
|
||||||
int total_cells;
|
int total_cells;
|
||||||
float dx; /* 1.0f / res. */
|
float dx; /* 1.0f / res. */
|
||||||
float scale; /* Largest domain size. */
|
float scale; /* Largest domain size. */
|
||||||
int boundary_width; /* Usually this is just 1. */
|
int boundary_width; /* Usually this is just 1. */
|
||||||
|
float gravity_final[3]; /* Scene or domain gravity multiplied with gravity weight. */
|
||||||
|
|
||||||
/* -- User-accesible fields (from here on). -- */
|
/* -- User-accesible fields (from here on). -- */
|
||||||
|
|
||||||
|
@ -481,7 +482,6 @@ typedef struct FluidDomainSettings {
|
||||||
int adapt_margin;
|
int adapt_margin;
|
||||||
int adapt_res;
|
int adapt_res;
|
||||||
float adapt_threshold;
|
float adapt_threshold;
|
||||||
char _pad1[4]; /* Unused. */
|
|
||||||
|
|
||||||
/* Fluid domain options */
|
/* Fluid domain options */
|
||||||
int maxres; /* Longest axis on the BB gets this resolution assigned. */
|
int maxres; /* Longest axis on the BB gets this resolution assigned. */
|
||||||
|
|
Loading…
Reference in New Issue