Skip to main content

Physics Based Animation Toolkit

Project description

Physics Based Animation Toolkit

Wheels

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
  • Hyper elastic material models
    • Saint-Venant Kirchhoff
    • Stable Neo-Hookean
  • Polynomial quadrature rules
    • Simplices in dimensions 1,2,3
    • Gauss-Legendre quadrature
  • Spatial query acceleration data structures
    • Bounding volume hierarchy for triangles (2D+3D) and tetrahedra (3D)
      • Nearest neighbours
      • Overlapping primitive pairs
      • Point containment
  • 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.

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

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 the pip's config-settings parameter, or via the SKBUILD_* environment variables. 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, using vcpkg for external dependencies, run in command line:

pip install . --config-settings=cmake.args="-DPBAT_BUILD_PYTHON_BINDINGS:BOOL=ON;-DPBAT_BUILD_TESTS:BOOL=OFF;-DPBAT_ENABLE_PROFILER:BOOL=ON;-DPBAT_PROFILE_ON_DEMAND:BOOL=ON;-DPBAT_BUILD_SHARED_LIBS:BOOL=OFF;-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON;-DCMAKE_TOOLCHAIN_FILE='path/to/vcpkg/scripts/buildsystems/vcpkg.cmake';-DVCPKG_MANIFEST_FEATURES=python;-DPBAT_PROFILE_ON_DEMAND:BOOL=ON" -v

For parallel builds on Unix systems, you can add the build.tool-args=-j<# threads> to the config-settings parameter, where <# threads> is the number of compilation jobs to run simultaneously. On Windows, using MSBuild, you may specify build.tool-args=/p:CL_MPCount=<# threads> instead. This assumes that parallel builds were enabled, meaning /MP may need to be appended to CMAKE_CXX_FLAGS through cmake.args. Otherwise, CMAKE_BUILD_PARALLEL_LEVEL=<# threads>may be usable, again through the cmake.args parameter of config-settings.

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 of pbatoolkit.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.

Harmonic interpolation on Entei model using linear shape functions Harmonic interpolation on Entei model using quadratic shape functions

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.

Heat source on top center of metagross model Reconstructed single source geodesic distance

Mesh smoothing via diffusion

Fine details of Godzilla's skin are smoothed out by diffusing x,y,z coordinates in time.

Godzilla model with fine details being smoothed out via diffusion

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.

Bending beam FEM elastic simulation using linear shape functions Bending beam FEM elastic simulation using quadratic shape functions

Modal analysis

The hyper elastic beam's representative deformation modes, i.e. its low frequency eigen vectors, are animated as time continuous signals.

Unconstrained hyper elastic beam's eigen frequencies

Profiling statistics

Computation details are gathered when using pbatoolkit and consulted in the Tracy profiling server GUI.

Profiling statistics widget in Tracy server

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pbatoolkit-0.0.6-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12 Windows x86-64

pbatoolkit-0.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pbatoolkit-0.0.6-cp312-cp312-macosx_14_0_arm64.whl (7.0 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

pbatoolkit-0.0.6-cp312-cp312-macosx_13_0_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.12 macOS 13.0+ x86-64

pbatoolkit-0.0.6-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11 Windows x86-64

pbatoolkit-0.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pbatoolkit-0.0.6-cp311-cp311-macosx_14_0_arm64.whl (7.0 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

pbatoolkit-0.0.6-cp311-cp311-macosx_13_0_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.11 macOS 13.0+ x86-64

pbatoolkit-0.0.6-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10 Windows x86-64

pbatoolkit-0.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pbatoolkit-0.0.6-cp310-cp310-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

pbatoolkit-0.0.6-cp310-cp310-macosx_13_0_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.10 macOS 13.0+ x86-64

File details

Details for the file pbatoolkit-0.0.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b88b11a83693853aea12eede09a72c9184096e0c09b843ba427e8d0d115a3b38
MD5 7c3e212ecc9a44891275feb73faf0621
BLAKE2b-256 3ec497649f3aee410d5570d3fcec86e5f5ec3caed95f870c0ecaffd55439c901

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e4f6a2f71271f3d7e3377eea042d091e6c2b9e688d9f569c9aae7fa082fbef3
MD5 38f855b4eb48550c6777547045f64bf3
BLAKE2b-256 0219d674a96e6b849987300f0aa7fa36685d35afd0e64fc2e253529fcfa36584

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 65b74c7d85266773a95b6addaf5f972b2b80fda96e9135236742e78b2a34cab8
MD5 8c8b114af1ef45622f76b37a6e1b023d
BLAKE2b-256 82c3b3bfc97ac6a3990a66a21e6120c658ef0d2d364dcd3e1503af395dfc094b

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 cfb58ed629a133d0d849f48bc3516166e7c0ec3383751003f1f99523975e3018
MD5 97c2911518674a98c27fa00ab5409f34
BLAKE2b-256 72fee27b945044983638401c77fa34bce3a73a195e1391adf8c718d2a1773cf5

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5342605900c2d4c71ae8b04b4b9fe475a14f44c4d76292d5748fbfc079cc94bb
MD5 53dba87ab86a16e4d6b707f5ee5e6021
BLAKE2b-256 6750af45fa3b4611b562f15a13f2d8b36204b0a87b1b9a2594174643a2d4644a

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9814a9326242d51d98fc176178dc047e33086d15c837bf500fe5257d9affe756
MD5 98c6972f3948d6da1452ce54f42b7a5a
BLAKE2b-256 cfb2135c61a937aab50ab8dd26413038dd30966b383c3a51a0b2f9485df11c31

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 dbcb49b97ce70896de309d0a5d743fe1ae48536b0cae77f1413ea62c8fa7bd15
MD5 faf004ebe46dedb7e2d58c0a99158838
BLAKE2b-256 028c189a163572eb8b3fce71a301c1bff439d061bad5ad2848bec22e684e02fe

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 56ff64af25bd5760b922a84faa377e3407f472e9564692acaf047c56084fa85e
MD5 f201c16f01fc8e1a4e0b6899fcefb89a
BLAKE2b-256 9a20d42a3169aed293507bad2d8d907fe0a66665ac7ba34b644278d022cac621

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4d93b4ce887b9adcf4d63ef0439976067043d246281b5bab633c9d684912a545
MD5 e6cb3f2e0a76b923b76520da501f3065
BLAKE2b-256 e568b88ead6a601875c3b6c30349eeeafac1dd98db6664befce49897418c3dba

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b86ebad4ed35101e8674bde059f37c6c0efa0ba78b51668b2244cb8e8a2ae2ee
MD5 2fbe5ce11a1fb654d17674efc5d144f8
BLAKE2b-256 a5b8482479ff210ca06a2f4504284c4a7b06455d26d251fe59adad54dd1cccb2

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f0d96dfad74698c93eba1dffbf486531d27d15ebf82a9bbdec891f283febdc7e
MD5 664d2c648448cb77a08d2f2c07042393
BLAKE2b-256 193768cb3bdd4f67856fe378756100167218c0b1e6393a8ca3ca084141988958

See more details on using hashes here.

File details

Details for the file pbatoolkit-0.0.6-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.6-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 2f238bbe2ff648edd8b20d55b1631c5d36aa88b03aeff4de66dbd1f4c3acb243
MD5 59d7b78b530a06c139bdc4b28d0fb07d
BLAKE2b-256 320a101037e17ce9cc9d83c2d6a5188eb32d41d0d1e25ac72a5e6f8c98db8706

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page