Skip to main content

High-performance Jolt Physics bindings for Python featuring Shadow Buffers and Free-Threading support.

Project description

Culverin Physics

Culverin is a Python wrapper for the Jolt Physics engine. It is designed for 3D games and simulations that require high performance and multi-threaded execution.

Key Concepts

  • Free-Threading Support: Designed for Python 3.13t and 3.14t. The engine releases the Global Interpreter Lock (GIL) during physics updates and raycast batches.
  • Shadow Buffers: All body positions, rotations, and velocities are stored in contiguous C-arrays. You can access this data via memoryview or numpy without the overhead of creating Python objects for every body.
  • Thread-Safe API: The engine uses a priority-based locking system. Simulation steps, state mutations, and queries can run on different threads without causing deadlocks or memory corruption.
  • Generational Handles: Bodies are referenced by 64-bit handles rather than pointers. This ensures that using a handle for a deleted object will not crash the program.
  • Double-Precision Internal: Uses double-precision floats for world positions to prevent physics jitter in large environments, while mirroring data to float32 buffers for rendering efficiency.

Features

  • Standard Primitives: Box, Sphere, Capsule, Cylinder, and Plane shapes.
  • Complex Shapes: Support for Convex Hulls, Heightfields (Terrain), and static Meshes.
  • Compound Bodies: Create single bodies composed of multiple child shapes.
  • Character Controller: A virtual character controller with built-in support for climbing stairs, sliding down slopes, and pushing objects.
  • Vehicles: Support for wheeled vehicles and tracked vehicles (tanks) with physical treads and skid-steering.
  • Constraints: Fixed, Point, Hinge, Slider, Distance, and Cone constraints.
  • Queries: Efficient single and batch Raycasting, Shapecasting (sweeps), and Overlap queries.
  • Collision Events: Native event buffer for contact added, persisted, and removed events.

Installation

Building from source requires CMake and a C++ compiler (Visual Studio on Windows, GCC or Clang on Linux/macOS).

# Clone the repository including submodules
git clone --recursive https://github.com/Evilpasture/culverin.git
cd culverin

# Install the package
pip install .

If you want Python 3.14t:

# Please install build module
pip install build

# Then build your wheel. Keyword: python3.14t, and have your 3.14t interpreter activated or available in PATH. usually the Python installer manages it for you.
python3.14t -m build --wheel

# then install via the wheel. please use your actual file name.
pip install culverin-*-win_amd64.whl

Quick Start

import culverin
import numpy as np

# Initialize the world with 500 bodies capacity
world = culverin.PhysicsWorld(settings={"gravity": (0, -9.81, 0), "max_bodies": 1000})

# Create a ground plane
world.create_body(pos=(0, 0, 0), shape=culverin.SHAPE_PLANE, motion=culverin.MOTION_STATIC)

# Create a dynamic box
handle = world.create_body(pos=(0, 10, 0), size=(1, 1, 1), shape=culverin.SHAPE_BOX, motion=culverin.MOTION_DYNAMIC)

# Simulation loop
for _ in range(1000):
    world.step(1/60)
    
    # Access position directly from the shadow buffer
    idx = world.get_index(handle)
    pos = world.positions[idx * 4 : idx * 4 + 3]
    print(f"Box Height: {pos[1]}")

Technical Specifications

Spec Standard
Units Metric (1.0 = 1 meter)
Coordinate System Right-Handed (Y-Up)
Angle Units Radians
Quaternion Format (x, y, z, w)
Internal Precision Float64 (Double)
Buffer Precision Float32
Minimum Python 3.11 (3.13+ recommended for multi-threading)

Performance Note

For maximum performance when reading state, use the world.positions and world.rotations attributes. These return memoryview objects that point directly to the engine's internal memory. Use numpy.frombuffer(world.positions, dtype=np.float32) to wrap them in a NumPy array without copying the data.

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

If you're not sure about the file name format, learn more about wheel file names.

culverin-0.3.0b1-cp313-cp313t-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.13tWindows x86-64

culverin-0.3.0b1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

culverin-0.3.0b1-cp313-cp313t-macosx_13_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13tmacOS 13.0+ ARM64

File details

Details for the file culverin-0.3.0b1-cp313-cp313t-win_amd64.whl.

File metadata

File hashes

Hashes for culverin-0.3.0b1-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 113328d22696704a009e2dba02dd052346cafa43bf9832e8434c5652f80f5c6e
MD5 32524d3e0a3caa403b6c2b2f567526ff
BLAKE2b-256 4be738f9862d3fde7f56f47462584d761d96befd25f186a2da4215b80062b56a

See more details on using hashes here.

Provenance

The following attestation bundles were made for culverin-0.3.0b1-cp313-cp313t-win_amd64.whl:

Publisher: build_wheels.yml on Evilpasture/Culverin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file culverin-0.3.0b1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for culverin-0.3.0b1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 083042b06e0e1c195237a576cecd0f0e198ee98230ee892ba66eda6f50f11049
MD5 f99694c8003c28de88dc76b3487ef26a
BLAKE2b-256 b38b4165c1b58eeac6556b90863ab5698912cab685fdb1f5d65bdc641255d03f

See more details on using hashes here.

Provenance

The following attestation bundles were made for culverin-0.3.0b1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on Evilpasture/Culverin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file culverin-0.3.0b1-cp313-cp313t-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for culverin-0.3.0b1-cp313-cp313t-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 677a056699fcfe913eb41afd5ce86ca2f0c7cc762426fa4e2d077a999215fd25
MD5 4d4d83128b16fea782de8ee2d85159bf
BLAKE2b-256 704fadd58c9060529bc97cf96dc9440732a82f4fc33e5afa0c78d9ccbe275c08

See more details on using hashes here.

Provenance

The following attestation bundles were made for culverin-0.3.0b1-cp313-cp313t-macosx_13_0_arm64.whl:

Publisher: build_wheels.yml on Evilpasture/Culverin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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