diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2021-08-09 12:19:42 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2021-08-09 12:19:42 +0300 |
commit | 4e84e076b2567ee2ec9fc70aced35a3ebd0ad19e (patch) | |
tree | bd81f667cd713eca1c812dd79750820eed943026 /source/blender/blenkernel/intern/particle_system.c | |
parent | 23d5bbd104581550f84c690a42e36ddbea070e21 (diff) |
Fluid: Initial support for 2D fluid simulationsfluid-mantaflow-2d
Initial adjustments for 2D (real-time) simulations.
Basic functionality includes:
- 2D/3D switcher in domain settings
- 2D simulation support for smoke/fire, wavelet noise, liquid
particles, secondary particles
- UI switcher to choose the axis that will be simulated on
- Planar visualization in workbench render
Some things that remain to do (non-exhaustive list):
- Eevee & Cycles support
- Liquid meshing
- Liquid viscosity solver
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f592b0f97ea..89da2c81f9b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4379,6 +4379,21 @@ static void particles_fluid_step(ParticleSimulationData *sim, const float posParticle[3] = {posX, posY, posZ}; copy_v3_v3(pa->state.co, posParticle); + /* Adjust particle position for 2d representation. */ + if (fds->solver_res == FLUID_DOMAIN_DIMENSION_2D) { + if (fds->slice_axis == SLICE_AXIS_X) { + float tmp = pa->state.co[1]; + pa->state.co[1] = pa->state.co[0]; + pa->state.co[0] = pa->state.co[2]; + pa->state.co[2] = tmp; + } + if (fds->slice_axis == SLICE_AXIS_Y) { + float tmp = pa->state.co[1]; + pa->state.co[1] = pa->state.co[2]; + pa->state.co[2] = tmp; + } + } + /* Normalize to unit cube around 0. */ float resDomain[3] = {resX, resY, resZ}; mul_v3_fl(resDomain, 0.5f); @@ -4412,6 +4427,21 @@ static void particles_fluid_step(ParticleSimulationData *sim, const float velParticle[3] = {velX, velY, velZ}; copy_v3_v3(pa->state.vel, velParticle); mul_v3_fl(pa->state.vel, fds->dx); + + /* Adjust particle velocity for 2d representation. */ + if (fds->solver_res == FLUID_DOMAIN_DIMENSION_2D) { + if (fds->slice_axis == SLICE_AXIS_X) { + float tmp = pa->state.vel[1]; + pa->state.vel[0] = pa->state.vel[2]; + pa->state.vel[1] = pa->state.vel[0]; + pa->state.vel[2] = tmp; + } + else if (fds->slice_axis == SLICE_AXIS_Y) { + float tmp = pa->state.vel[1]; + pa->state.vel[1] = pa->state.vel[2]; + pa->state.vel[2] = tmp; + } + } # if 0 /* Debugging: Print particle velocity. */ printf("pa->state.vel[0]: %f, pa->state.vel[1]: %f, pa->state.vel[2]: %f\n", |