>_ DevTrendsen

Language

Home

Languages

Sections

Frontend Backend Mobile DevOps AI / ML GameDev Blockchain Embedded Security
C

Erin Catto Brings Legendary Box2D Physics to 3D

If you've ever been interested in 2D game development, you've likely come across Box2D. Angry Birds, Limbo, and hundreds of other projects were built on this engine. Recently, its creator, Erin Catto, unveiled his new project — Box3D. It's a rigid body 3D physics library written from scratch in C.

Box3D Logo

What Box3D Is

The library is written in portable C17 and has no external dependencies beyond the standard C library. The examples included with the project are written in C++20 with the sokol graphics backend and Dear ImGui interface. The demo application builds without issues on Windows, macOS, and Linux, and lets you run physics directly in the browser via WebAssembly.

Box3D Video

Unlike bloated commercial alternatives, Box3D focuses on pure performance, a data-oriented approach, and predictability.

Key Library Features

Vector Computing and Performance

The physics engine core actively uses SSE2 vector instructions for x86 processors and Neon for ARM. If you're building the project for an exotic platform or microcontroller without SIMD support, vector math can be disabled via the BOX3D_DISABLE_SIMD macro definition.

Soft Step Solver and Joint Types

The Soft Step algorithm handles rigid body behavior. The engine supports convex hulls, capsules, spheres, polygonal meshes, and height fields. Multiple shapes can be attached to a single body.

Available joints include:

  • Hinges and sliders
  • Distance constraints and motors
  • Welds and wheel joints
  • Configurable limits, springs, and friction

To save resources, an island sleep system is used: if a group of objects has stopped, the engine temporarily excludes it from calculations.

Determinism and Simulation Recording

The result of physics world calculations remains identical across different platforms. This is critical for networked multiplayer games. Recording and replay of simulations is available out of the box, simplifying debugging of physics bugs.

Continuous Collision Detection

Fast-moving objects don't pass through walls thanks to a full Continuous Collision Detection (CCD) system. The algorithms handle both fast linear movements and rotations.

How to Integrate into a Project

Integrating Box3D into a CMake project takes literally a couple of minutes via FetchContent:

include(FetchContent)
FetchContent_Declare(box3d
  GIT_REPOSITORY https://github.com/erincatto/box3d.git
  GIT_TAG v0.1.0)
FetchContent_MakeAvailable(box3d)

target_link_libraries(my_app PRIVATE box3d::box3d)

If you prefer to keep third-party code local, the standard add_subdirectory will also work:

add_subdirectory(extern/box3d)

target_link_libraries(my_app PRIVATE box3d::box3d)

An Honest Conversation About AI in Development

An interesting detail in the README — the author honestly described the roles of neural networks in creating the library. Erin Catto explicitly states that he uses LLMs for generating unit tests, configuring CMake, migrating code from Box2D, writing benchmarks, and code review. However, he writes all physics engine logic himself and takes personal responsibility for every line of code.

Who This Project Is For

If you're writing your own 3D engine in C or C++ and were looking for a compact physics library without a massive graphics or engine overhead, Box3D deserves a detailed look. The project is at release 0.1.0 stage, pull requests are currently closed and only issues are accepted, but the source code is open under the MIT license and is very easy to read.

Related projects