Developers can precisely calculate 3D object collisions and motion
You can directly control the calculations that keep game characters from passing through walls and allow numerous objects to stack naturally. Box3D is a 3D physics engine for game development that provides only the core for collision detection and rigid body motion. Written in the C17 standard, it guarantees identical results across platforms and is optimized for large-scale object simulation.
Collision Detection and Shape Support
Box3D performs continuous collision detection to prevent fast-moving objects from passing through others. It supports various object shapes, including spheres, capsules, convex hulls, triangle meshes, and terrain data, and allows multiple shapes to be applied to a single object simultaneously. You can check for objects in specific areas using ray casts or overlap queries, and trigger events when objects enter specific areas using the sensor system. It also includes a character mover to support the movement handling of game characters.
Rigid Body Solver and Joint System
Object movement is handled by a rigid body solver based on the Robust Soft Step algorithm. This method performs continuous physics calculations to ensure physical laws are not broken even when objects move or rotate quickly. It provides various types of joints, such as rotation, linear movement, distance maintenance, motor, weld, and wheel, each of which can be configured with limits, motors, springs, and friction. You can receive and process events when an object's movement changes or its sleep state transitions, making it easy to integrate with game logic.
Data-Centric Design and Determinism
This engine follows data-centric design principles and optimizes performance by utilizing multithreading and SIMD instructions. It is specifically designed to efficiently handle situations where numerous objects pile up in one place. It guarantees cross-platform determinism, ensuring that identical inputs produce identical results in all environments. It also includes a feature to record and replay the physics simulation process, which is useful for debugging or analysis.
Build Environment and Project Application
To use Box3D, you must have CMake and git installed. Using CMake presets is recommended, and you can execute specific commands for Windows, Linux, macOS, and MinGW environments. The core library has no additional dependencies other than the C runtime and libm in Unix environments. When applying it to a project, you can fetch it from a remote repository via FetchContent or copy it locally and include it using add_subdirectory.
Pre-Usage Checks
Box3D can be built and run on Windows, Linux, and Mac. Building the library requires a compiler that supports C17, while building the samples requires a compiler that supports C++20. It uses SSE2 and Neon SIMD math for performance improvements, which can be disabled by defining BOX3D_DISABLE_SIMD if necessary. In x86 environments, the AVX2 kernel is selected at runtime if the CPU supports it, and can be disabled by setting -DBOX3D_AVX2=OFF. Pull requests are currently disabled, and bugs or feature requests must be submitted as issues. It is distributed under the MIT license, allowing commercial use.