Collision detection
A dynamic AABB tree finds candidate pairs. Skin-aware SAT generates contacts for circles, capsules, convex polygons, edges, and chains.
Fx2D is an open-source rigid-body physics engine written in C++20. It uses SAT collision detection and XPBD constraints, with YAML scene loading and optional raylib rendering. Licensed under BSD-3-Clause.

The playground runs the engine compiled to WebAssembly. You can drag bodies, spawn shapes, and change simulation settings. Its source is the same examples/playground program used by the desktop build.
Define a scene in YAML, load it, then step it. Use Fx2D/Core.h to add the raylib viewer, or work directly with FxScene for a headless simulation.
#include "Fx2D/Core.h"
int main() {
auto scene = FxYAML::buildScene("Scene.yml");
FxRylbRenderer renderer(scene, 60);
renderer.run();
}#include "Fx2D/Scene.h"
#include "Fx2D/YamlUtils.h"
int main() {
auto scene = FxYAML::buildScene("Scene.yml");
auto ball = scene.get_entity("ball");
for (int i = 0; i < 600; ++i) {
scene.step(1.0 / 60.0);
std::cout << ball->pose << '\n';
}
}See the installation guide for dependencies and build commands, and your first scene for a YAML example.
The repository includes C++ programs and YAML scenes for the examples below.
Each simulation step finds potentially colliding pairs, generates contacts, and resolves contact and joint constraints. The collision detection and XPBD solver pages describe the algorithms and equations used in the implementation.
| Fx2D | |
|---|---|
| Language | C++20; physics core built as a static library |
| Collision | Dynamic AABB tree + skin-aware SAT, opt-in speculative CCD |
| Solver | Substepped XPBD, warm-started, Coulomb friction, restitution |
| Joints | Revolute and prismatic with position / velocity / effort motors |
| Scenes | YAML with textures, joints, groups, reset |
| Headless | Yes — no raylib, no window, same API |
| Rendering | raylib + Dear ImGui inspector, optional |
| License | BSD-3-Clause |
Fx2D is developed in the open. The roadmap records pending work, known limitations, and measurements from previous changes. The contributing guide covers code style, tests, and benchmarks.
Bug reports, reproducible scenes, documentation corrections, and code contributions are welcome on GitHub.