This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
LibUIPC is a cross-platform C++20 library implementing Unified Incremental Potential Contact for GPU-accelerated physics simulation. It simulates rigid bodies, soft bodies, cloth, and threads with penetration-free frictional contact. Both C++ and Python APIs are provided.
- CMake >= 3.26
- Python >= 3.11
- CUDA >= 12.4
- Vcpkg with
CMAKE_TOOLCHAIN_FILEenvironment variable set
# Using presets (recommended)
cmake --preset release
cmake --build --preset release -j8
# Or manually
mkdir build && cd build
cmake -S .. -DUIPC_BUILD_PYBIND=ON
cmake --build . --config Release -j8UIPC_BUILD_PYBIND- Build Python bindings (OFF by default)UIPC_BUILD_TESTS- Build test suite (ON by default)UIPC_BUILD_EXAMPLES- Build examples (ON by default)UIPC_WITH_CUDA_BACKEND- Enable CUDA backend (auto, disabled on macOS)
Tests are Catch2 executables built to build/Release/bin/:
./build/Release/bin/uipc_test_<name>cd build/python
pip install .
python ../python/uipc_info.py # verify installation- Engine - Simulation algorithm running on a backend (
"cuda"or"none") - World - Manages simulation lifecycle (
init(),advance(),retrieve()) - Scene - Data structure containing simulation state (Objects, Geometries, Constitutions, Contacts, Animator)
The codebase uses Data-Oriented Programming with an ECS-inspired RMR pattern for cache-friendly data flow between components. See docs/development/index.md.
src/core/- Main simulation engine, compiled intolibuipc_coreshared librarysrc/geometry/- Geometry processing (SimplicialComplex, BVH, distance, intersection)src/constitution/- Material models (AffineBody, NeoHookean, springs, constraints)src/backends/- Backend implementations loaded as dynamic modulescuda/- GPU backend with CUDA kernelsnone/- CPU reference implementation
src/pybind/- Python bindings via pybind11src/io/- File I/O (obj, gltf, serialization)
- SimplicialComplex - Core geometry type (vertices, edges, triangles, tetrahedra)
- Constitution - Material models applied via
apply_to(mesh, properties) - Contact Model - Pairwise contact parameters stored in tabular form
Backends are MODULE libraries dynamically loaded at runtime. They implement a visitor pattern for scene traversal and provide device-specific optimizations.
Tests are organized under apps/tests/:
geometry/- Geometry processing testscore/- Engine, scene, world testscommon/- Utility testsbackends/cuda/- CUDA backend testssim_case/- Full simulation scenarios
Test executables are named uipc_test_<name> via the uipc_add_test() CMake function.
Modules mirror C++ namespaces:
uipc.core- Engine, World, Sceneuipc.geometry- Geometry operationsuipc.constitution- Material modelsuipc.unit- Physical units (GPa, MPa, etc.)