Physics Based Animation Toolkit
Project description
Physics Based Animation Toolkit
We recommend exploring the official CMake documentation to beginner CMake users.
Overview
The Physics Based Animation Toolkit (PBAT) is a (mostly templated) cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation in dimensions 1,2,3
. For most use cases, we recommend using our library via its Python interface, enabling seamless integration into Python's ecosystem of powerful scientific computing packages.
Features
- Finite Element Method (FEM) meshes and operators
- Dimensions
1,2,3
- Lagrange shape functions of order
1,2,3
- Line, triangle, quadrilateral, tetrahedron and hexahedron elements
- Dimensions
- Hyper elastic material models
- Saint-Venant Kirchhoff
- Stable Neo-Hookean
- Polynomial quadrature rules
- Simplices in dimensions
1,2,3
- Gauss-Legendre quadrature
- Simplices in dimensions
- Spatial query acceleration data structures
- Bounding volume hierarchy for triangles (2D+3D) and tetrahedra (3D)
- Nearest neighbours
- Overlapping primitive pairs
- Point containment
- Bounding volume hierarchy for triangles (2D+3D) and tetrahedra (3D)
- GPU algorithms
- eXtended Position Based Dynamics (XPBD)
- Broad phase collision detection
- Sweep and Prune
- Linear Bounding Volume Hierarchy
- Fixed-size matrix operations in kernel code
- Seamless profiling integration via Tracy
Dependencies
See vcpkg.json
for a versioned list of our dependencies, available via vcpkg (use of vcpkg is not mandatory, as long as dependencies have compatible versions and are discoverable by CMake's find_package
mechanism).
Configuration
Option | Values | Default | Description |
---|---|---|---|
PBAT_BUILD_PYTHON_BINDINGS |
ON,OFF |
OFF |
Enable PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit Python bindings. Generates the CMake target PhysicsBasedAnimationToolkit_Python , an extension module for Python, built by this project. |
PBAT_BUILD_TESTS |
ON,OFF |
OFF |
Enable PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit unit tests. Generates the CMake target executable PhysicsBasedAnimationToolkit_Tests , built by this project. |
PBAT_ENABLE_PROFILER |
ON,OFF |
OFF |
Enable Tracy instrumentation profiling in built PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit . |
PBAT_PROFILE_ON_DEMAND |
ON,OFF |
OFF |
Activate Tracy's on-demand profiling when PBAT_ENABLE_PROFILER is ON . |
PBAT_USE_INTEL_MKL |
ON,OFF |
OFF |
Link to user-provided Intel MKL installation via CMake's find_package . |
PBAT_USE_SUITESPARSE |
ON,OFF |
OFF |
Link to user-provided SuiteSparse installation via CMake's find_package . |
PBAT_BUILD_SHARED_LIBS |
ON,OFF |
OFF |
Build project's library targets as shared/dynamic. |
Our project provides configuration presets that capture typical use configurations. Refer to the CMake presets documentation for more information.
cmake -S <path/to/PhysicsBasedAnimationToolkit> -B <path/to/build> #-D<option>=<value>
# or, alternatively
cmake --preset=<my-favorite-user-preset>
Build
Build transparently across platforms using the cmake build CLI.
CMake build targets:
Target | Description |
---|---|
PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit |
The PBA Toolkit library. |
PhysicsBasedAnimationToolkit_Tests |
The test executable, using doctest. |
PhysicsBasedAnimationToolkit_Python |
PBAT's Python extension module, using pybind11. |
For example, to build tests, run:
cmake --build <path/to/build/folder> --target PhysicsBasedAnimationToolkit_Tests --config Release
Install
From command line:
cd path/to/PhysicsBasedAnimationToolkit
cmake -S . -B build # -D<option>=<value> ...
cmake --install build --config Release
Alternatively, if vcpkg
is installed and VCPKG_ROOT=path/to/vcpkg
is set as an environment variable, you can select one of our available presets, for example cmake --preset=default
and then install.
Quick start
We recommend downloading the Tracy profiler server to analyze execution of PBAT algorithms, available as precompiled executable. PBAT currently supports Tracy 0.10.
C++
Take a look at the unit tests, found in the library's source (.cpp
or .cu
) files.
Python
To download and install from PyPI, run in command line:
pip install pbatoolkit
To use
pbatoolkit
's GPU algorithms, you must build from source, i.e. the prebuiltpbatoolkit
package hosted from PyPI does not include GPU code.
For a local installation, which builds from source, our Python bindings build relies on Scikit-build-core, which relies on CMake's install
mechanism. As such, you can configure the installation as you typically would when using the CMake CLI directly, by now passing the corresponding CMake arguments in pip
's config-settings
parameter (refer to the Scikit-build-core documentation for the relevant parameters). See our pyinstall workflow for working examples of building from source on Linux, MacOS and Windows. Then, assuming that external dependencies are found via CMake's find_package
, you can build and install our Python package pbatoolkit
locally and get the most up to date features. Consider using a Python virtual environment for this step.
As an example, assuming use of vcpkg
for external dependency management, with VCPKG_ROOT
set as an environment variable, run
pip install . --config-settings=cmake.args="--preset=pip-local" -v
on the command line to build pbatoolkit
from source. To build with GPU algorithms included, refer to the Configuration section. Additional CMake variables (i.e. CMAKE_CUDA_ARCHITECTURES, CMAKE_CUDA_COMPILER) may be required to be set in order for CMake to discover your local CUDA installation.
Verify pbatoolkit
's contents in Python shell:
import pbatoolkit as pbat
help(pbat.fem)
help(pbat.geometry)
help(pbat.profiling)
help(pbat.math.linalg)
To profile relevant calls to pbatoolkit
functions/methods, connect to python.exe
in the Tracy
profiler server GUI.
All calls to pbat will be profiled on a per-frame basis in the Tracy profiler server GUI.
Use method
profile
ofpbatoolkit.profiling.Profiler
to profile code external to PBAT, allowing for an integrated profiling experience while using various scientific computing packages.def expensive_external_computation(): # Some expensive computation profiler.profile("My expensive external computation", expensive_external_computation)
Tutorial
Head over to our hands-on tutorials section to learn more about physics based animation in both theory and practice!
Gallery
Below, we show a few examples of what can be done in just a few lines of code using pbatoolkit
and Python. Code can be found here.
Harmonic interpolation
A smooth (harmonic) function is constructed on Entei, required to evaluate to 1
on its paws, and 0
at the top of its tail, using piece-wise linear (left) and quadratic (right) shape functions. Its isolines are displayed as black curves.
Heat method for geodesic distance computation
Approximate geodesic distances are computed from the top center vertex of Metagross by diffusing heat from it (left), and recovering a function whose gradient matches the normalized heat's negative gradient. Its isolines are displayed as black curves.
Mesh smoothing via diffusion
Fine details of Godzilla's skin are smoothed out by diffusing x,y,z
coordinates in time.
Hyper elastic simulation
Linear (left) and quadratic (right) shape functions are compared on a hyper elastic simulation of the beam model, whose left side is fixed. Quadratic shape functions result in visually smoother and softer bending.
Inter-penetration free elastodynamic contact
Combining pbatoolkit
's FEM+elasticity features and the IPC Toolkit
results in guaranteed inter-penetration free contact dynamics between deformable bodies.
Real-time elastodynamics
Our GPU implementation of the eXtended Position Based Dynamics (XPBD) algorithm simulates a ~324k element FEM elastic mesh interactively with contact.
Modal analysis
The hyper elastic beam's representative deformation modes, i.e. its low frequency eigen vectors, are animated as time continuous signals.
GPU broad phase collision detection
Real-time collision detection between 2 large scale meshes (~324k tetrahedra) is accelerated by highly parallel implementations of the sweep and prune algorithm, or linear bounding volume hierarchies.
Profiling statistics
Computation details are gathered when using pbatoolkit
and consulted in the Tracy profiling server GUI.
Contributing
Coding style
A .clang-format
description file is provided in the repository root which should be used to enforce a uniform coding style throughout the code base using the clang-format tool. Recent versions of Visual Studio Code and Visual Studio should come bundled with a clang-format
installation. On Unix-like systems, clang-format
can be installed using your favorite package manager.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pbatoolkit-0.0.7-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52049fb55e710480e8c9417a7578b14298259faceb6494bc26b1261de0680fbb |
|
MD5 | eeb003a2b731d47c85ea7cfad09cfc98 |
|
BLAKE2b-256 | 3d2a9a72d6a827351e25d50973599832e71089e74d19867430e5c69d004af6a9 |
File details
Details for the file pbatoolkit-0.0.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 10.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b9d19f5588c0986a1286396318d4a5c52243eff594b0cdf85e8a8e6146a7b9 |
|
MD5 | 09c35d61b411bbb3a4ecfe79655a5856 |
|
BLAKE2b-256 | c99d6b01d258260383880859442c7c86d3d52a36c135caf6855ae3115d187b9c |
File details
Details for the file pbatoolkit-0.0.7-cp312-cp312-macosx_14_0_arm64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c06c041711524817b1d75d1abd874cbe075392e21a390a8c3e2ee4584f1d5aaa |
|
MD5 | 896d3ae0d9e97e6a1a3bea6d2921976f |
|
BLAKE2b-256 | 3c7f21b0d9bbd32f18311863679ff79e3bab268542f62c13e348fb59bdfb617d |
File details
Details for the file pbatoolkit-0.0.7-cp312-cp312-macosx_13_0_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp312-cp312-macosx_13_0_x86_64.whl
- Upload date:
- Size: 7.9 MB
- Tags: CPython 3.12, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ae55c945120d1e881ac1f1e9a2b78dfbc38dfc2103167a71f7e644027e83392 |
|
MD5 | 1afa7a59875eb54dae374f64ae0187d0 |
|
BLAKE2b-256 | 8c53f3f6d7973ac6db0b092017ce666965df9debc592190d6e7419bb2d73296a |
File details
Details for the file pbatoolkit-0.0.7-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0522f51a7e56c42addda02d1f443c877a992bf354bb51ce079c7fac9cc54d080 |
|
MD5 | be69903af46e64a48adb9e3e19567519 |
|
BLAKE2b-256 | ee44d040353abd5e46359815bdda42e9a3fa7c5bdd8b9874b54d3db312e114ee |
File details
Details for the file pbatoolkit-0.0.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 10.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20e183d88b7d51e94aa4cd640e4e9728a77577a26d8eecc0af57da6f62991692 |
|
MD5 | 280813fce130071d64a2a894cf2c3b61 |
|
BLAKE2b-256 | 2bd4be6be7f82823a858b6b07137717772e404616e231b4884328e47843650df |
File details
Details for the file pbatoolkit-0.0.7-cp311-cp311-macosx_14_0_arm64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4331375cf1ea528dd32875953be14bb3d27dd16e147be877b04e06d901f34f4 |
|
MD5 | 00388db5f18c166cbaf45ce8eafb2509 |
|
BLAKE2b-256 | 70476bfb48d1bf61030fed19544b9709a793bb4b016361ab86250dda11cf7e86 |
File details
Details for the file pbatoolkit-0.0.7-cp311-cp311-macosx_13_0_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp311-cp311-macosx_13_0_x86_64.whl
- Upload date:
- Size: 7.9 MB
- Tags: CPython 3.11, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17732c4cb1138610cfcb6b0348e6ede06a7f1d095ecde2749056e5fffbb69ad1 |
|
MD5 | 6fba438e5548cb8769d9eda15d2270d6 |
|
BLAKE2b-256 | e8bd785ad6a3f0945dcc832bb7be0d34be8d6224f3012f534d6cf181051110e8 |
File details
Details for the file pbatoolkit-0.0.7-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa783822204a8f00203f81dbd39bb3a5562645a373641175af0291ac33027c06 |
|
MD5 | 226a9c47f26d28bba6a0e448978613a9 |
|
BLAKE2b-256 | 5bdd51fe306dd02fd0d8c446a990416077b20e319bfacde0f3ce58ce4b526a91 |
File details
Details for the file pbatoolkit-0.0.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 10.9 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 890c0c6de1f8cfdf88c07e0eb7eee7ed88dc66a3e2992f50841b44c049057972 |
|
MD5 | c5add0d0021437ec2ac860e32bbfaf15 |
|
BLAKE2b-256 | 76f786c491b960fd67d659d10f2d56656400d79c2ab45d51cab4a7c2dc982e2b |
File details
Details for the file pbatoolkit-0.0.7-cp310-cp310-macosx_14_0_arm64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5596a6e3276a7a05b8b91a0d6c7bf20a4bab9a436dd26822462bcbf783f266eb |
|
MD5 | 5669dd3d7b3d9d6c0685eb86888762cf |
|
BLAKE2b-256 | 69689641353022c3f5e150e82cbed72aae724a47f0eebb94c78ae57042681c39 |
File details
Details for the file pbatoolkit-0.0.7-cp310-cp310-macosx_13_0_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.7-cp310-cp310-macosx_13_0_x86_64.whl
- Upload date:
- Size: 7.9 MB
- Tags: CPython 3.10, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 975a47efb23ba602208c007d1b7ddbc13142dba62327d7554fd622a804685002 |
|
MD5 | 29a370fb59d019f188e0785e0e1645fc |
|
BLAKE2b-256 | 15ce6d5fd154ea990a358340a0182230b09fbfaf921e3b699adefe72bb776242 |