Skip to main content

Physics Based Animation Toolkit

Project description

Physics Based Animation Toolkit

logo

build wheels pbatoolkit downloads GitHub Releases

entei

Overview

We recommend exploring the official CMake documentation to beginner CMake users, if they wish to build this project from source.

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

Online documentation coming soon.

Currently, the master branch may contain breaking changes at any point in time. We recommend users to use specific git tags, i.e. via git checkout v<major>.<minor>.<patch>, where the version <major>.<minor>.<patch> matches the installed pbatoolkit's version downloaded from PyPI (i.e. from pip install pbatoolkit).

Table of Contents

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

or, alternatively

pip install pbatoolkit-gpu

if your environment is properly setup to use our GPU algorithms.

Verify pbatoolkit's contents in a Python shell

import pbatoolkit as pbat
help(pbat.fem)
help(pbat.geometry)
help(pbat.profiling)
help(pbat.math)
help(pbat.gpu)

A bunch of Python scripts demonstrating usage of pbatoolkit can be found in the examples folder, along with their associated requirements.txt for easily downloading necessary dependencies via pip install -r path/to/requirements.txt. Their command line interface follows the pattern

python[.exe] path/to/examples/[example].py -i path/to/input/mesh

The full interface is always revealed by -h or --help, i.e.

python[.exe] path/to/examples/[example].py -h

The examples assume the user provides the meshes to pbatoolkit. Triangle (surface) meshes can easily be obtained via Thingi10K, TurboSquid or authored yourself in Blender. Tools like TetWild, fTetWild and TetGen can then convert them into tetrahedral (volume) meshes. We provide helper scripts to facilitate mesh processing and their associated requirements.txt.

Example results are showcased in our Gallery.

Tutorial

Head over to our hands-on tutorials section to learn more about physics based animation in both theory and practice!

Dependencies

See vcpkg.json for a versioned list of our external dependencies, available via vcpkg.

Use of vcpkg is not mandatory, as long as external dependencies have compatible versions and are discoverable by CMake's find_package mechanism.

CUDA

PyPI

pbatoolkit-gpu (downloaded from PyPI) requires dynamically linking to an instance of the

Recall that the CUDA Runtime is ABI compatible up to major version.

On 64-bit Windows, these are cudart64_12.dll and nvcuda.dll. Ensure that they are discoverable via Windows' DLL search order. We recommend adding <drive>:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.<minor>\bin (i.e. the binary folder of your CUDA Toolkit installation) to the PATH environment variable. The driver should already be on the search path by default after installation.

On Linux, they are libcudart.so.12 and libcuda.so.1. Ensure that they are discoverable via Linux's dynamic linker/loader. If they are not already in a default search path, we recommend simply updating the library search path, i.e. export LD_LIBRARY_PATH="path/to/driver/folder;path/to/runtime/folder;$LD_LIBRARY_PATH".

MacOS does not support CUDA GPUs.

Our pbatoolkit-gpu prebuilt binaries include PTX, such that program load times will be delayed by JIT compilation on first use. Verify that your NVIDIA GPU supports compute capability at least 7.0. For example, only RTX 2060 up to 4090 chips are supported in the GeForce series. Runtime GPU performance may be constrained by the targeted compute capability.

Local

Consider locally building and installing pbatoolkit against your native GPU for the following reasons.

  • Achieve optimal GPU performance for your platform.
  • Support older/newer GPUs and CUDA Toolkit versions.

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.

Either run CMake's configure step manually

cmake -S <path/to/PhysicsBasedAnimationToolkit> -B <path/to/build> -D<option>=<value> ...

or, alternatively (and preferably)

cmake --preset=<my-favorite-user-preset>

Our project provides configuration presets that capture typical use configurations. For the best experience, install vcpkg and set VCPKG_ROOT=path/to/vcpkg as an environment variable. Then, you can select one of our available presets, for example cmake --preset=default. Refer to the CMake presets documentation for more information.

Build & Install

C++

Build and install transparently across platforms using the cmake build CLI and cmake install CLI, respectively.

Our CMake project exposes the following 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

To install PhysicsBasedAnimationToolkit locally, run

cd path/to/PhysicsBasedAnimationToolkit
cmake -S . -B build -D<option>=<value> ...
cmake --install build --config Release

Python

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=path/to/vcpkg set as an environment variable, run

pip install . --config-settings=cmake.args="--preset=pip-cuda" -v

on the command line to build pbatoolkit from source with GPU algorithms included. Additional environment variables (i.e. CUDA_PATH) and/or CMake variables (i.e. CMAKE_CUDA_COMPILER) may be required to be set in order for CMake to correctly discover and compile against your targeted local CUDA installation. Refer to the CMake documentation for more details.

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.

Real-time hyper elasticity dynamics

Our GPU implementation of the eXtended Position Based Dynamics (XPBD) algorithm simulates a ~324k element FEM elastic mesh interactively with contact.

A 162k element armadillo mesh is dropped on top of another duplicate, but fixed, armadillo mesh on the bottom.

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.

A stack of bending beams fall on top of each other, simulated via Incremental Potential Contact (IPC).

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

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.

Broad phase collision detection on the GPU between 2 moving tetrahedral meshes

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

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.10-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

pbatoolkit-0.0.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

pbatoolkit-0.0.10-cp312-cp312-macosx_14_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

pbatoolkit-0.0.10-cp312-cp312-macosx_13_0_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12 macOS 13.0+ x86-64

pbatoolkit-0.0.10-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

pbatoolkit-0.0.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

pbatoolkit-0.0.10-cp311-cp311-macosx_14_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

pbatoolkit-0.0.10-cp311-cp311-macosx_13_0_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11 macOS 13.0+ x86-64

pbatoolkit-0.0.10-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

pbatoolkit-0.0.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.0 MB view details)

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

pbatoolkit-0.0.10-cp310-cp310-macosx_14_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

pbatoolkit-0.0.10-cp310-cp310-macosx_13_0_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10 macOS 13.0+ x86-64

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7c00294c63bac9f09101d2078bfd29581b7ac5b15a1a17ef6a59c9a89c727834
MD5 bd677bd28956e1b3eca59a618049fe5b
BLAKE2b-256 ce1b7a0678359bf64811de0c8c6220e2d002aab08fce16138b887c9163edc333

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00447e5ff5ccbf13acb65bddfb6ca7bd54e65bedc60d291a8ad8184f456a3107
MD5 75b9f1f3d485dd96e387a4bcc322f1df
BLAKE2b-256 ee941a6bef1b9ba8854c730387182a440504f1fa1495678d70149e59fbcc8660

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1135cc691a8b9dda75d8f20e5a07d3a1e482c2efb89223b38186de6f751e4efc
MD5 5cd16499de8f74ad23b17cbc9675ff91
BLAKE2b-256 468a0c2fd5a14bdb5376e7f16eae941f18553db1d66c103226c509a9fad525d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 3bcd35470ca3049c754ac6696db69a93925d38e23ab7908e2ef38a2cd7c3fb64
MD5 8e9154eab0831cfbdbde3cb009c6468b
BLAKE2b-256 6f56a9ea7716515925c766f953de5ce874d481f312d75d15c6b0cd265c589d47

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp312-cp312-macosx_13_0_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1fd8a5a633ada9583afd4f02dbd5ba1380736406c847b46b6b7d531187ab112c
MD5 5990f728715c1e006c21d0d13e497a3f
BLAKE2b-256 69f815a5eca3c033bcdf8f3344e9e62d53f12aedc1a6cb6ed38f06e7010281f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7381f9d91fd4f8f091906232c9f182ef5d27ee461237187b21ecf39aae50ea7
MD5 7882026225bbc05c8ee84184a8153136
BLAKE2b-256 258008d78e99a1c8364215a97dea9938cd2e211c50c8e0536a7278dc1c42e36d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5576718eee0f690a2cf6907ac7ce245542f8398aa048740ea503ca7963420f0a
MD5 c3ba5c5542cf314487c6dc2f54a75aee
BLAKE2b-256 21338fb6fa1145d603712e77d6cee13113d407e82fcd2e813349d3687518aea1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 7f9b6e062ce7c9e7c69b5134ee9561549ca0f47018922f31081c8f48e2a2d57e
MD5 96d7354b8bcfd85d5971842dbf67e292
BLAKE2b-256 f756e95631d883f6d4ba48af751cc4b337bcb131f0dbb957061fe5b770496747

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp311-cp311-macosx_13_0_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 02dba531d7e9b5245ab881ffef6c97364a1942e095fa17b6906994883bd2ba78
MD5 1db983d84c47062e5d92c276c9866b33
BLAKE2b-256 87418fb712be1be5744ea20f9860df4e4b720528552ff1bb8d0cf7a31135fafc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72f22b62a40b41e4554d2214f6ca0d191be8d34a3de050b1a0bf6733a8414790
MD5 74cd6dd2c66da3fa13e2aa75528d00fb
BLAKE2b-256 5f94e8fc2bc4d23615abd3c3ec6a8e42acda98eb7016b01e54f0a75300af2473

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2273e91d49fe19036859b00a0ade1af8d34d77372574a9da0f21f2635b0e7d23
MD5 858db3ff73e3f1e3ff09e9061f70c192
BLAKE2b-256 b5d5472df84b0763274ccf259e1ce332dd8c3cef639b4b92f9eba46ebf3001e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.10-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 8e8e51364e6d427da3d41c18c2437a24536a784930c7ceeb0afa04a154e65986
MD5 89205d347eb88c58c1bbbc27ef819a23
BLAKE2b-256 9c2993200a629b58fcbb0d652ee13dce256572c94ac9b3cb975ee64844c236b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.10-cp310-cp310-macosx_13_0_x86_64.whl:

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

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