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

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

Uploaded CPython 3.12 Windows x86-64

pbatoolkit-0.0.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pbatoolkit-0.0.9-cp312-cp312-macosx_14_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

pbatoolkit-0.0.9-cp312-cp312-macosx_13_0_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.12 macOS 13.0+ x86-64

pbatoolkit-0.0.9-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

pbatoolkit-0.0.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pbatoolkit-0.0.9-cp311-cp311-macosx_14_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

pbatoolkit-0.0.9-cp311-cp311-macosx_13_0_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.11 macOS 13.0+ x86-64

pbatoolkit-0.0.9-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10 Windows x86-64

pbatoolkit-0.0.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pbatoolkit-0.0.9-cp310-cp310-macosx_14_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

pbatoolkit-0.0.9-cp310-cp310-macosx_13_0_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.10 macOS 13.0+ x86-64

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 92166730047ce039b6eb12f49166ba2001897bc1864a410c782de5527c7b3c0d
MD5 fa071e40f08a0235c593743c8c82f2e9
BLAKE2b-256 45b834d96a92f0bfb24ce0d9fa8b5ad8f0c1c6841cb9a538eb904e4a5b0db57a

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66eea80d908fb550a5b4bc0a8e3b97e0f575ad3b53918295acd6c3b91a5a2905
MD5 d13003e461118917b492941d018d1b09
BLAKE2b-256 b6a65c085f6866c3b03ed0ab58ceeed3ce64abcd229009f954d325a980c5bb36

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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.9-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 cd882a72c6f080d6abafcd94004353ca241bb30414843f82a0bbe34bd2e2cd37
MD5 e02f226094266919531a52ea85befe23
BLAKE2b-256 e4dec44ff0c2693f466ed3ba75974c3c76074b53e391c38e0342c7092290e065

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 e955a21ceb10c2ac41b7a23800d7652193b928a4bf700f149dd02828ad979589
MD5 6497b9fadb8e750cbc42b76abece7b24
BLAKE2b-256 7f58152a255c9385642f78be829ea4f38b2944573b2a7675484c8d2a82446692

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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.9-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fc985e4b1f947941f7a4108b13179ed5752eb05eda76362d78f27ebea70eb02b
MD5 a4fbf9b4630da405551a3324bc98d79e
BLAKE2b-256 6086595a722b33f2811f50d77068f044ad90766b260080a158c860b426c3ed7c

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 643d2b920d5042d04b4df1ac432eb63d001d7dfbdf033f9aec01eef3ebff5e82
MD5 cffe15210d151424064ee8474134f247
BLAKE2b-256 1a910856dd3b734b38082870cb149e1627bf859afd23c797619ddc9ae3a35b54

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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.9-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 33a8ecdab9bb73e4a5ee4188b2c540235d58319c55f0a7b614bf6901d9d7dca1
MD5 4aaa7d2f7d012e62c92ff4c19b8d2d49
BLAKE2b-256 ef3ee498f49ad718edbfa90da02ef873a8e08561d1a23d521cb127f7b46a1db9

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 decf548ebae9a7917538e677434c099b010132d1beeffefb1caaca4270e7abc6
MD5 46bf41bece1873d6f36befcd51af3f79
BLAKE2b-256 d098b586411b6d273f2892f033190130a796cf36dad83f3a445a8a0bb10aa481

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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.9-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d53686f2a035a7458a15238918b2e93d582523929faa3b2cd431ea46e6f604a8
MD5 3d9f594769c7c6a238f8ee7161e62b48
BLAKE2b-256 f47e1117f25e0cdf607480ea50a7349e8908731de655e4a1d780843dac07da03

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7854fbd6e60689ff125dddabf89703b5da58e5a3b5398246d5790bc2a1d5213c
MD5 f4f4303abbd554560a826ad32b1d08b7
BLAKE2b-256 b6f89d0b6d96284e4beb7e46332eb8ab95347cbe5c2b9b9304140912cc80b3ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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.9-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 df73f93d4580f380ec483589870cf140a970f443b514455d1ce5988f7a99fbb3
MD5 030792ba39f17f6b2e4f2bc11f577a35
BLAKE2b-256 187a897529fce570f69460334ae0440a51db0e541841daa71fceb6e2f96a9f8b

See more details on using hashes here.

Provenance

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

Publisher: wheels.yml on Q-Minh/PhysicsBasedAnimationToolkit

Attestations:

File details

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

File metadata

File hashes

Hashes for pbatoolkit-0.0.9-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 1b4e7f608b4d936c87e473dac857a89833775ca101c5780e3efc631ca8df24db
MD5 f70a67d0125a2cb53c2270c6910d5aad
BLAKE2b-256 8878381b31e8efda9879199afcf100f3367df11c31b47a83f3399803f89cf1e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pbatoolkit-0.0.9-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