Unity Position Based Dynamics in two dimensions
Unity package for Position Based Dynamics in two dimensions.
Warning
The package is in a preview state. The API may change without advance notice. Production usage is not recommended.
The package provides an implementation of position based dynamics (PBD) [^1] [^3] [^5] using HPC# (via Burst compiler) including extended position based dynamics (xPBD) [^4], shape-matching [^2], 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:
One can play the presented demos here.
See PDB2D-examples
github repo for source codes and scenes.
Warning
Currently,
Burst
compiler is not supported withWebGL
. Demo scenes are for preview only. Performance may be limited in web builds.
Install the package using one of the following methods
manifest.json
manually.
Add or modify scoped registries in the manifest
"scopedRegistries": [ { "name": "OpenUPM", "url": "https://package.openupm.com/", "scopes": [ "com.andywiecko" ] } ]and in the dependencies provide selected version of the package
"dependencies": { "com.andywiecko.pbd2d": "0.2.0", ...See Unity docs for more details https://docs.unity3d.com/2021.1/Documentation/Manual/upm-scoped.html
git
install package.json
using Package Manager (Window/Package Manager
).
See the example project here.
To run your first simulation with PBD2D
follow the steps presented in TUTORIAL.md
.
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:
andywiecko.PBD2D.Core
contains all contracts, common structs, and all required abstractions.andywiecko.PBD2D.Components
which consists of components implementations.andywiecko.PBD2D.Systems
contains all available systems for components, i.e. all logic can be found here.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"
v1.0.0:
TriMeshSerializedDataTriangulatorPostprocess
(triangulate TriMeshSerializedData
).v2.0.0:
EdgeMeshRenderer
does not update after serialized data change.Unity.Burst
Unity.Mathematics
Unity.Collections
Unity.Jobs
andywiecko.ECS
andywiecko.BurstTriangulator
andywiecko.BurstCollections
andywiecko.BurstMathUtils
[^1]:M.Müller, B.Heidelberger, M.Hennix, and J.Ratcliff, "Position based dynamics," J. Vis. Commun. Image Represent., 18, 2 (2007). [^2]:M.Müller, B.Heidelberger, M.Teschner, and M.Gros, "Meshless deformations based on shape matching," ACM Trans. Graph. 24, 3 (2005). [^3]: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). [^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]: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). [^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).