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.
Our Python bindings are currently not available on MacOS via PyPI. For now, we recommend MacOS users to build
pbatoolkit
locally.
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)
- 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_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. |
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. |
Install
From command line:
cd path/to/PhysicsBasedAnimationToolkit
cmake -S . -B build -A x64 -DPBAT_ENABLE_PROFILER:BOOL=ON -DPBAT_BUILD_TESTS:BOOL=ON
cmake --install build --config Release
Quick start
We recommend downloading the Tracy profiler server to analyze execution of PBAT algorithms, available as precompiled executable.
C++
Take a look at the unit tests, found in the library's source (.cpp
) files.
Python
To download and install from PyPI, run in command line:
pip install pbatoolkit
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 using the CMake CLI directly, via the SKBUILD_CMAKE_ARGS
environment/shell variable. See our wheels workflow for working examples of setting SKBUILD_CMAKE_ARGS
on Linux, MacOS and Windows. Then, assuming SKBUILD_CMAKE_ARGS
contains at least -DPBAT_BUILD_PYTHON_BINDINGS:BOOL=ON
and that external dependencies are found via CMake's find_package
, you can install our Python package pbatoolkit
locally and get the most up to date features, by running in command line:
pip install .
Verify pbatoolkit
's contents in Python shell:
import pbatoolkit as pbat
import pbatoolkit.fem, pbatoolkit.geometry, pbatoolkit.profiling
import pbatoolkit.math.linalg
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.
Modal analysis
The hyper elastic beam's representative deformation modes, i.e. its low frequency eigen vectors, are animated as time continuous signals.
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.4-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7f5baa4d49b7980e4adb7c816c4bdf2646216d3f0e6bd47ce420bf720b099e |
|
MD5 | e935afba5fc369a1ec5cf55d1f602f64 |
|
BLAKE2b-256 | dfd648593cf36e746b6253516be78540fcaded3973db4360cd0c680624d2c19f |
File details
Details for the file pbatoolkit-0.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.7 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.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00c3de06c7f4df75e5df19bc8432575cbb9dddf32608554091df44ef3993cc54 |
|
MD5 | 32748af1c0d2414bf8b6ef0155f99cee |
|
BLAKE2b-256 | f6d9fd029f5034ef5d545a4b80af43a5f7526b98f9351ea69ab1790c2bb453bd |
File details
Details for the file pbatoolkit-0.0.4-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e64190e3d67781ab8ac575ccd817435b470b0f01851d9497f0242066ee347de |
|
MD5 | 0047c24523e9fd6d52f721589cabb352 |
|
BLAKE2b-256 | 70a73a461c2c75aa7e0aae084b83af8c67a703b1e5239af7f2197d8b6f8c5537 |
File details
Details for the file pbatoolkit-0.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.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.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97dc1f6b5b189a7db8cb11478b3b1d4d2f87c8d64e63f315ae565da6b81eed08 |
|
MD5 | c1580fa72c0865ce416cf9076e45a4bf |
|
BLAKE2b-256 | aa833b78f5b8ba661f20b01d02ae2c22bff34ec7fca3550ec7f09881c8658636 |
File details
Details for the file pbatoolkit-0.0.4-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafb2527cd9d4158c3e2d161f8d317a939b852be639e4257fc6e07712c09a1a7 |
|
MD5 | bbe42b1ecf382d282585dd6deac6b41e |
|
BLAKE2b-256 | 9aeab92d083a688e3df82f40bf3c9e155c0aa8f75855efdb2813b391dbc61e8a |
File details
Details for the file pbatoolkit-0.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pbatoolkit-0.0.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.5 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.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec27b336c3490ffb38b0f9371731ca8377e8d9e0f2f5910b438989bbfe392aa0 |
|
MD5 | 2bc502473457ac7ae0d4de8e169f5de3 |
|
BLAKE2b-256 | 6af8b3bdbed3680180b27717897305daa388fe623bd2f5f0d3b85023a6ad89cc |