Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/fluid.c')
-rw-r--r--source/blender/blenkernel/intern/fluid.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 803a99dd45f..7392c9161b8 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -925,7 +925,7 @@ static void update_velocities(FluidEffectorSettings *fes,
velocity_map[index * 3 + 2] = hit_vel[2];
# ifdef DEBUG_PRINT
/* Debugging: Print object velocities. */
- printf("adding effector object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
+ printf("setting effector object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
# endif
}
else {
@@ -1065,7 +1065,7 @@ static void obstacles_from_mesh(Object *coll_ob,
add_v3fl_v3fl_v3i(co, mvert[i].co, fds->shift);
if (has_velocity) {
sub_v3_v3v3(&vert_vel[i * 3], co, &fes->verts_old[i * 3]);
- mul_v3_fl(&vert_vel[i * 3], fds->dx / dt);
+ mul_v3_fl(&vert_vel[i * 3], 1.0f / dt);
}
copy_v3_v3(&fes->verts_old[i * 3], co);
@@ -1824,6 +1824,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
float *velocity_map,
int index,
const int base_res[3],
+ const float global_size[3],
const float flow_center[3],
BVHTreeFromMesh *tree_data,
const float ray_start[3],
@@ -1983,9 +1984,23 @@ static void sample_mesh(FluidFlowSettings *ffs,
printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
# endif
}
- velocity_map[index * 3] += ffs->vel_coord[0];
- velocity_map[index * 3 + 1] += ffs->vel_coord[1];
- velocity_map[index * 3 + 2] += ffs->vel_coord[2];
+ /* Convert xyz velocities flow settings from world to grid space. */
+ float convert_vel[3];
+ copy_v3_v3(convert_vel, ffs->vel_coord);
+ float time_mult = 1.0 / (25.f * DT_DEFAULT);
+ float size_mult = MAX3(base_res[0], base_res[1], base_res[2]) /
+ MAX3(global_size[0], global_size[1], global_size[2]);
+ mul_v3_v3fl(convert_vel, ffs->vel_coord, size_mult * time_mult);
+
+ velocity_map[index * 3] += convert_vel[0];
+ velocity_map[index * 3 + 1] += convert_vel[1];
+ velocity_map[index * 3 + 2] += convert_vel[2];
+# ifdef DEBUG_PRINT
+ printf("initial vel: [%f, %f, %f]\n",
+ velocity_map[index * 3],
+ velocity_map[index * 3 + 1],
+ velocity_map[index * 3 + 2]);
+# endif
}
}
@@ -2039,6 +2054,7 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
bb->velocity,
index,
data->fds->base_res,
+ data->fds->global_size,
data->flow_center,
data->tree,
ray_start,
@@ -2136,7 +2152,7 @@ static void emit_from_mesh(
add_v3fl_v3fl_v3i(co, mvert[i].co, fds->shift);
if (has_velocity) {
sub_v3_v3v3(&vert_vel[i * 3], co, &ffs->verts_old[i * 3]);
- mul_v3_fl(&vert_vel[i * 3], fds->dx / dt);
+ mul_v3_fl(&vert_vel[i * 3], 1.0 / dt);
}
copy_v3_v3(&ffs->verts_old[i * 3], co);
}
@@ -2434,19 +2450,6 @@ static void adaptive_domain_adjust(
/* Redo adapt time step in manta to refresh solver state (ie time variables) */
manta_adapt_timestep(fds->fluid);
}
-
- /* update global size field with new bbox size */
- /* volume bounds */
- float minf[3], maxf[3], size[3];
- madd_v3fl_v3fl_v3fl_v3i(minf, fds->p0, fds->cell_size, fds->res_min);
- madd_v3fl_v3fl_v3fl_v3i(maxf, fds->p0, fds->cell_size, fds->res_max);
- /* calculate domain dimensions */
- sub_v3_v3v3(size, maxf, minf);
- /* apply object scale */
- for (int i = 0; i < 3; i++) {
- size[i] = fabsf(size[i] * ob->scale[i]);
- }
- copy_v3_v3(fds->global_size, size);
}
BLI_INLINE void apply_outflow_fields(int index,
@@ -4423,7 +4426,7 @@ float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velo
FluidDomainSettings *fds = fmd->domain;
float time_mult = 25.f * DT_DEFAULT;
float size_mult = MAX3(fds->global_size[0], fds->global_size[1], fds->global_size[2]) /
- fds->maxres;
+ MAX3(fds->base_res[0], fds->base_res[1], fds->base_res[2]);
float vel_mag;
float density = 0.0f, fuel = 0.0f;
float pos[3];