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
这是什么?Box3D 是一个面向游戏的 3D 物理引擎,由 Box2D 的作者 Erin Catto 编写。
它是一个链接进我游戏的库,还是一个可以运行的程序?是一个链接进你游戏的 C 库,CMake 目标是 box3d::box3d。仓库还附带一个带 imgui 界面的示例程序,可以用来试各种功能。
我怎么把它加到自己的项目里?最简单的方式是 CMake FetchContent;随源码自带的副本或 git 子模块走 add_subdirectory,已安装的副本则用 find_package。docs/hello.md 会带你写一个最简单的入门程序。
构建它需要什么?需要 CMake、git 和一个支持 C17 的编译器。库本身除了 C 运行时(Unix 上是 libm)不需要任何其他依赖;示例程序还额外要求 C++20。
构建时有什么坑需要我注意?它默认使用 SSE2 和 Neon SIMD,就连 WebAssembly 构建也依赖 SSE2——如果硬件较旧,可以定义 BOX3DDISABLESIMD 来禁用 SIMD 构建。
它能运行在哪些平台上?支持 Windows、Linux 和 macOS,每个平台都有对应的 CMake 预设(还支持 MinGW 和 Xcode)。另外还有一个面向 WebAssembly 的 Emscripten 构建。
我可以在商业游戏里用它吗?可以——Box3D 采用 MIT 许可证,商用没有问题。它由 Erin Catto 开发,并通过 GitHub Sponsors 获得支持。
它包含哪些物理功能?碰撞方面:连续碰撞检测、凸包、胶囊体、球体、三角网格和高度场、传感器、角色移动器,还有射线检测、形状投射和重叠查询。物理方面:Soft Step 刚体求解器、基于孤岛的休眠机制,以及带限位、马达和弹簧的旋转关节、移动关节、距离关节、马达关节、焊接关节和车轮关节。
在接入我的游戏之前,我能不能先试用一下?用 CMake 预设构建示例程序——比如先运行 cmake --preset windows,再运行 cmake --build --preset windows-release——然后从 Box3D 目录运行示例程序。它有 imgui 界面,并且演示了大部分功能。
这是 Box2D 的 3D 继任者吗?基本上可以这么说。它出自 Box2D 作者 Erin Catto 之手,README 里还提到了在 Box2D 和 Box3D 之间迁移代码的工具。
作者是用 AI 写出来的吗?部分是。LLM 被用于单元测试、示例程序、Box2D/Box3D 代码迁移、构建配置、代码审查和性能测试;其余代码由作者本人编写,他表示对每一行代码负责。
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