new in 2020.06
2D Fluid Simulation2D fluid simulation using the APIC method.
A 2D fluid simulation using the APIC (Affine Particle-in-Cell) method. Compared to 3D Fluid Simulation, the simulation is running in a single thread.
Controls
- mouse drag interacts with the simulation
- E emits more particles
- H shows / hides the overlay
- R resets the simulation
- Space pauses the simulation
Credits
This example was originally contributed by Nghia Truong.
Source
Full source code is linked below and also available in the magnum-examples GitHub repository. This example depends on the ImGuiIntegration library which is not a part of the core Magnum repository, see its documentation for usage instructions.
- CMakeLists.txt
- DataStructures/
Array2X.h - DataStructures/
MathHelpers.h - DataStructures/
PCGSolver.h - DataStructures/
SDFObject.h - DataStructures/
SparseMatrix.h - DrawableObjects/
FlatShadeObject2D.h - DrawableObjects/
ParticleGroup2D.cpp - DrawableObjects/
ParticleGroup2D.h - DrawableObjects/
WireframeObject2D.h - FluidSimulation2DExample.cpp
- FluidSolver/
ApicSolver2D.cpp - FluidSolver/
ApicSolver2D.h - FluidSolver/
SolverData.h - resources.conf
- Shaders/
ParticleSphereShader2D.cpp - Shaders/
ParticleSphereShader2D.frag - Shaders/
ParticleSphereShader.h - Shaders/
ParticleSphereShader2D.vert
The ports branch contains additional patches for Emscripten support that aren't present in master
in order to keep the example code as simple as possible.