Thanks to visit codestin.com
Credit goes to github.com

Skip to content

2D fluid & soft body simulation based on Position Based Dynamics

License

matsuoka-601/Floaty

Repository files navigation

Floaty

Soft body & fluid simulation based on Position Based Dynamics (PBD).

demo

Try Demo Here!

How to run

npm install
npm run build
npm run dev

If you have trouble running the repo, feel free to open an issue.

Demo video

alt設定

Overview of the simulation

Soft bodies

Soft bodies are simulated using distance constraint and area constraint.

Distance constraints limit adjacent particles of each soft body from moving too far apart or too close together. And area constraints limit the movement of particles so that soft bodies do not collapse.

For more detail, reading section 3.3 (Constraint Projection) and 4.4 (Cloth Balloons) in the original PBD paper would help.

Fluid

The simulation of fluid is based on Position Based Fluids. That is, $i$ th fluid particle is constrained to satisfy the following density constraint( $\rho_0$ is the target density and $\rho_i$ is the density of $i$ th particle).

$$ C_i(\boldsymbol{p}_1,\dots, \boldsymbol{p}_n) = \frac{\rho_i}{\rho_0}-1=0 $$

My initial implementation is based on the one by Matthias Müller.

To simulate surface tension, cohesion and curvature term is used, which is described in Versatile Surface Tension and Adhesion for SPH Fluids by Akinci et al.

Two-Way coupling of fluid and soft bodies

Following the framework described in Unified Particle Physics for Real-Time Applications, two-way coupling of fluid and soft bodies can be naturally simulated.

In PBF calculations, fluid particles and soft body particles are treated in almost the same way. Buoyancy is automatically achieved using the mass weighted version of PBD (Eq. (4) and (5) in the paper).

Some tricks to stabilize the simulation

Prevent soft bodies from get entangling

The softbodies can easily get entangled when they collide. To prevent this problem, repulsive forces are applied between overlapping soft bodies. They still sometimes get entangled even with this trick, but it's less frequent than it would be without it.

In addition, soft body particles within other soft bodies do not interact with those soft bodies. This also prevents soft bodies from becoming entangled with each other.

Prevent fluid particles from entering soft bodies

To prevent fluid particles from remaining inside soft bodies, fluid particles inside soft bodies do not interact with soft body particles. Fluid particles naturally go out of the soft bodies thanks to this trick.

References

About

2D fluid & soft body simulation based on Position Based Dynamics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published