Some 2D collision detection and physics stuff written in C++.
Utilizes and remains consistent with the C++ General Utility Library (CGUL).
- Collision detection between various trivial 2D primitives
- Closest point algorithms
- "Complex" objects built from trivial primitives
- Triangulization from convex and concave primitives
- Collision prediction algorithms
- Collision response (impulse based?)
- Force generators (gravity/springs/explosions)
- Consistent results between identical iterations
- Hierarchy collision detection optimizations
- Binary space partitioning optimizations
Below is a matrix of supported collision algorithms between trivial 2D primitives.
| Circle | AABB | OBB | Line | Triangle | Point | |
|---|---|---|---|---|---|---|
| Circle | ✔️ | ✔️ | ✔️ | ✔️ | ||
| AABB | ✔️ | ✔️ | ✔️ | ✔️ | ||
| OBB | ✔️ | ✔️ | ✔️ | ✔️ | ||
| Line | ||||||
| Triangle | ✔️ | ✔️ | ✔️ | ✔️ | ||
| Point | ✔️ | ✔️ |
Planned types:
- Ovals ?
Closest point algorithms are implemented for the following types:
- Circle
- AABB
- OBB
- Line
- Triangle (kind of buggy right now!)
- Point
Requires CGUL built with GLEW.
Uses CMake build system.
Graphics via OpenGL 2.1(ish?)
Tested with GCC 4.2 (Mac), Clang 3.2 (Mac), GCC 4.7 (Linux & MinGW), and Visual Studio 2010 (Windows).
The code is under the BSD 2-clause License. You must include a copyright notice in your product's documentation if you use this code in full. Feel free to use snippets of the code, or re-implement the code, without this restriction.