diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-01-15 17:50:02 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-01-15 18:28:56 +0300 |
commit | adcc9d014cc2ec27fea74168bdb4c47fddedbeb3 (patch) | |
tree | 52e989d4ca931bcb7764525e4d0f04bd9828de71 /source/blender/blenkernel/intern/fluid.c | |
parent | f7fa6cd1da61b5cc57f5a54d1580f1680f79006c (diff) |
Fluid: Moved grid reset loop for inner obstacle cells from blenkernel code into Mantaflow
Having this loop in directly Manta is faster and potentially fixes issues T72783 and T72894.
Diffstat (limited to 'source/blender/blenkernel/intern/fluid.c')
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 69 |
1 files changed, 7 insertions, 62 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index fba52d3d163..1900f6ebaad 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -616,7 +616,7 @@ typedef struct ObstaclesFromDMData { bool has_velocity; float *vert_vel; float *velocity_x, *velocity_y, *velocity_z; - int *num_objects; + float *num_objects; float *distances_map; } ObstaclesFromDMData; @@ -702,15 +702,9 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata, } else { /* Apply (i.e. add) effector object velocity */ - data->velocity_x[index] += (data->mes->type == FLUID_EFFECTOR_TYPE_GUIDE) ? - hit_vel[0] * data->mes->vel_multi : - hit_vel[0]; - data->velocity_y[index] += (data->mes->type == FLUID_EFFECTOR_TYPE_GUIDE) ? - hit_vel[1] * data->mes->vel_multi : - hit_vel[1]; - data->velocity_z[index] += (data->mes->type == FLUID_EFFECTOR_TYPE_GUIDE) ? - hit_vel[2] * data->mes->vel_multi : - hit_vel[2]; + data->velocity_x[index] += hit_vel[0]; + data->velocity_y[index] += hit_vel[1]; + data->velocity_z[index] += hit_vel[2]; # ifdef DEBUG_PRINT /* Debugging: Print object velocities. */ printf("adding effector object vel: [%f, %f, %f], dx is: %f\n", @@ -749,7 +743,7 @@ static void obstacles_from_mesh(Object *coll_ob, float *velocity_x, float *velocity_y, float *velocity_z, - int *num_objects, + float *num_objects, float dt) { if (!mes->mesh) { @@ -922,22 +916,11 @@ static void update_obstacles(Depsgraph *depsgraph, float *vel_x_guide = manta_get_guide_velocity_x(mds->fluid); float *vel_y_guide = manta_get_guide_velocity_y(mds->fluid); float *vel_z_guide = manta_get_guide_velocity_z(mds->fluid); - float *vel_x_orig = manta_get_velocity_x(mds->fluid); - float *vel_y_orig = manta_get_velocity_y(mds->fluid); - float *vel_z_orig = manta_get_velocity_z(mds->fluid); - float *density = manta_smoke_get_density(mds->fluid); - float *fuel = manta_smoke_get_fuel(mds->fluid); - float *flame = manta_smoke_get_flame(mds->fluid); - float *r = manta_smoke_get_color_r(mds->fluid); - float *g = manta_smoke_get_color_g(mds->fluid); - float *b = manta_smoke_get_color_b(mds->fluid); float *phi_obs_in = manta_get_phiobs_in(mds->fluid); float *phi_guide_in = manta_get_phiguide_in(mds->fluid); - int *obstacles = manta_smoke_get_obstacle(mds->fluid); - int *num_obstacles = manta_get_num_obstacle(mds->fluid); - int *num_guides = manta_get_num_guide(mds->fluid); + float *num_obstacles = manta_get_num_obstacle(mds->fluid); + float *num_guides = manta_get_num_guide(mds->fluid); uint z; - float tmp = 0; /* Grid reset before writing again. */ for (z = 0; z < mds->res[0] * mds->res[1] * mds->res[2]; z++) { @@ -1023,44 +1006,6 @@ static void update_obstacles(Depsgraph *depsgraph, } BKE_collision_objects_free(coll_ob_array); - - /* Obstacle cells should not contain any velocity from the smoke simulation. */ - for (z = 0; z < mds->res[0] * mds->res[1] * mds->res[2]; z++) { - if (obstacles[z] & 2) /* Mantaflow convention: FlagObstacle. */ - { - if (vel_x_orig && vel_y_orig && vel_z_orig) { - vel_x_orig[z] = 0.0f; - vel_y_orig[z] = 0.0f; - vel_z_orig[z] = 0.0f; - } - if (density) { - density[z] = 0.0f; - } - if (fuel) { - fuel[z] = 0.0f; - flame[z] = 0.0f; - } - if (r) { - r[z] = 0.0f; - g[z] = 0.0f; - b[z] = 0.0f; - } - } - /* Average velocities from multiple obstacles in one cell. */ - if (num_obstacles && num_obstacles[z]) { - tmp = 1.0f / num_obstacles[z]; - vel_x[z] *= tmp; - vel_y[z] *= tmp; - vel_z[z] *= tmp; - } - /* Average velocities from multiple guides in one cell. */ - if (num_guides && num_guides[z]) { - tmp = 1.0f / num_guides[z]; - vel_x_guide[z] *= tmp; - vel_y_guide[z] *= tmp; - vel_z_guide[z] *= tmp; - } - } } /** \} */ |