box3d README

The project's README from github.com/erincatto/box3d. As one markdown file: README.md.

Box3D

Build Status CLA assistant

Box3D Logo

Box3D is a 3D physics engine for games.

Introducing Box3D

Features

Collision

Physics

System

Samples

Building all platforms

This uses the presets in CMakePresets.json.

Run the samples app (must be in the Box3D directory).

Building for Visual Studio

Building for Linux

Building for Xcode

Building for Web

Box3D uses SSE2 with WebAssembly. Define BOX3D_DISABLE_SIMD to disable SSE2.

Building and installing

Using Box3D in your project

The core library has no dependencies beyond the C runtime (and libm on Unix). Linking it gives you the box3d::box3d target.

I recommend to use 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)

For a vendored copy or git submodule, point add_subdirectory at it:

add_subdirectory(extern/box3d)

target_link_libraries(my_app PRIVATE box3d::box3d)

To use a copy installed with cmake --install, find the package:

find_package(box3d 0.1 REQUIRED)

target_link_libraries(my_app PRIVATE box3d::box3d)

See docs/hello.md for a minimal first program.

Compatibility

The Box3D library and samples build and run on Windows, Linux, and Mac.

You will need a compiler that supports C17 to build the Box3D library.

You will need a compiler that supports C++20 to build the samples.

Box3D uses SSE2 and Neon SIMD math to improve performance. SIMD can be disabled by defining BOX3D_DISABLE_SIMD.

Documentation

The user manual lives in docs/ and is built with Doxygen. Enable the BOX3D_DOCS CMake option and build the doc target.

Community

Contributing

Pull requests are currently disabled. Instead, please file an issue for bugs or feature requests. For support, please visit the Discord server.

Giving feedback

Please file an issue or start a chat on discord. You can also use GitHub Discussions.

License

Box3D is developed by Erin Catto and uses the MIT license.

Sponsorship

Support development of Box3D through Github Sponsors.

Please consider starring this repository and subscribing to my YouTube channel.

LLM Usage

LLMs are used in the following areas:

Elsewhere all code is developed and written by me. I take responsibility for every line of code in Box2D/3D.

box3d (erincatto/box3d)

Searching Database…

6.6K ·GitHub
What is this?Box3D is a 3D physics engine for games, written by Erin Catto, the author of Box2D.
Is it a library I link into my game, or a program I run?A C library you link into your game - the CMake target is box3d::box3d. The repo also ships a samples app with an imgui UI for trying features.
How do I add it to my own project?Easiest is CMake FetchContent; a vendored copy or git submodule goes through add_subdirectory, and an installed copy via find_package. docs/hello.md walks you through a minimal first program.
What do I need to build it?CMake, git and a C17-capable compiler. The library itself needs nothing beyond the C runtime (libm on Unix); the samples additionally require C++20.
Any build pitfalls I should know about?It uses SSE2 and Neon SIMD by default, and even the WebAssembly build relies on SSE2 - on older hardware define BOX3DDISABLESIMD to build without it.
Which platforms does it run on?Windows, Linux and macOS, with CMake presets for each (plus MinGW and Xcode). There is also an Emscripten build targeting WebAssembly.
Can I use it in a commercial game?Yes - Box3D is MIT licensed, so commercial use is fine. It is developed by Erin Catto and supported through GitHub Sponsors.
What physics features does it include?Collision: continuous detection, convex hulls, capsules, spheres, triangle meshes and height fields, sensors, a character mover, plus ray casts, shape casts and overlap queries. Physics: a Soft Step rigid body solver, island-based sleep, and revolute, prismatic, distance, motor, weld and wheel joints with limits, motors and springs.
How do I try it before wiring it into my game?Build the samples with the CMake presets - for example cmake --preset windows, then cmake --build --preset windows-release - and run the samples executable from the Box3D directory. The app has an imgui interface and demos for most features.
Is this the 3D successor to Box2D?Effectively yes. It comes from Erin Catto, the author of Box2D, and the README mentions tooling for migrating code between Box2D and Box3D.
Did the author use AI to write it?Partly. LLMs were used for unit tests, the samples app, Box2D/Box3D code migration, build configuration, code reviews and benchmarking; the rest of the code is written by the author, who says he takes responsibility for every line.
What are similar projects?box2d, bgfx, JoltPhysics, raylib, iw4L, bevy, flutter_scene, GDevelop
Creator
erincatto
Size
3.6 MB
Stars
6.6K
Age
5mo
Commits · 90 Days