Home

Awesome

PBD2D

Unity package for Position Based Dynamics in two dimensions.

<br>

[!NOTE] Development of the package will resume in 2025. Stay tuned for updates! 😉

<br>

[!WARNING]
The package is in a preview state. The API may change without advance notice. Production usage is not recommended.

<br>

Build Tests openupm

The package provides an implementation of position based dynamics (PBD) 1 2 3 using HPC# (via Burst compiler) including extended position based dynamics (xPBD) 4, shape-matching 5, and various collision algorithms with a basic friction model 6. There are also upcoming features regarding one-dimensional structures (rods) 7 8 and fluids 9 with soft bodies coupling.

Check out Matthias Müller's YouTube channel 10 Minute Physics for the great tutorial about PBD-related topics!

Package summary:

Gallery

demo-01 demo-02

demo-03 demo-04

demo-05 demo-06

demo-07 demo-08

demo-09 demo-10

One can play the presented demos here. See PDB2D-examples github repo for source codes and scenes.

Warning

Currently, Burst compiler is not supported with WebGL. Demo scenes are for preview only. Performance may be limited in web builds.

Table od Contents

Getting started

Install the package using one of the following methods

<details open> <summary> Using scoped registry <b>(recommended)</b> </summary> Use OpenUPM CLI or add corresponding entries to the project's <code>manifest.json</code> manually. Add or modify scoped registries in the manifest <pre> "scopedRegistries": [ { "name": "OpenUPM", "url": "https://package.openupm.com/", "scopes": [ "com.andywiecko" ] } ] </pre> and in the dependencies provide selected version of the package <pre> "dependencies": { "com.andywiecko.pbd2d": "0.2.0", ... </pre> See Unity docs for more details https://docs.unity3d.com/2021.1/Documentation/Manual/upm-scoped.html </details> <details> <summary> <code>git</code> install </summary> Use package manager via git install: https://github.com/andywiecko/PBD2D.git#v0.2.0 </details> <details> <summary> Manual instalation </summary> Clone or download this repository and then select <code>package.json</code> using Package Manager (<code>Window/Package Manager</code>). </details>

See the example project here. To run your first simulation with PBD2D follow the steps presented in TUTORIAL.md.

Architecture

The project architecture is based on the custom ECS pattern and it uses andywiecko.ECS as the implementation of the core engine.

The package consists of three main assemblies:

Below one can find a dependency graph for the main project assemblies.

%%{init: {"theme": "neutral", "flowchart": {"curve": "stepBefore", "useMaxwidth": false}}}%%

graph TB
b <--- a
c <--- a

a[Core]
b[Components]
c[Systems]

click a href "andywiecko/PBD2D/tree/main/Runtime/Core"
click b href "andywiecko/PBD2D/tree/main/Runtime/Components"
click c href "andywiecko/PBD2D/tree/main/Runtime/Systems"

Preview for upcoming features

fluid-one-sided fluid-two-sided

Roadmap

v1.0.0:

v2.0.0:

Known Issues

  1. Bending constraint may cause simulation instabilities when stiffness/compliance is too large.
  2. Hard locks do not support shape-matching constraints.
  3. EdgeMeshRenderer does not update after serialized data change.

Dependencies

Bibliography

Footnotes

  1. M.Müller, B.Heidelberger, M.Hennix, and J.Ratcliff, "Position based dynamics," J. Vis. Commun. Image Represent., 18, 2 (2007).

  2. J.Bender, M.Müller, and M.Macklin, "A Survey on Position Based Dynamics," EG '17: Proceedings of the European Association for Computer Graphics: Tutorials (2017).

  3. J.Bender, M.Müller, M.A.Otaduy, M.Teschner, and M.Macklin, "A survey on position‐based simulation methods in computer graphics," Computer Graphics Forum, 33:228-251 (2014).

  4. M.Macklin, M.Müller, and N.Chentanez, "XPBD: position-based simulation of compliant constrained dynamics," Proceedings of the 9th International Conference on Motion in Games (2016).

  5. M.Müller, B.Heidelberger, M.Teschner, and M.Gros, "Meshless deformations based on shape matching," ACM Trans. Graph. 24, 3 (2005).

  6. M.Macklin, M.Müller, N.Chentanez, and T.-Y.Kim, "Unified particle physics for real-time applications," ACM Trans. Graph. 33, 4 (2014).

  7. U.Nobuyuki, R.Schmidt, and J.Stam, "Position-based elastic rods," SIGGRAPH '14: ACM SIGGRAPH 2014 Talks, 47, 1 (2014).

  8. K.Tassilo, and E.Schömer, "Position and orientation based Cosserat rods," Eurographics/ ACM SIGGRAPH Symposium on Computer Animation, (2016).

  9. M.Macklin, and M.Müller, "Position based fluids," ACM Trans. Graph. 32, 4, 104 (2013).