Library:Box2D
Appearance
| On this wiki | Facts · Code · Notes · Topics |
|---|
Box2D is an MIT-licensed 2D physics engine by Erin Catto used in many 2D games; version 3.x is a C library with b2GetVersion(), the 2.x line is C++ with b2 prefixed classes, and a static build is spotted by those names and by its tuning constants.
Identification
- Version 3.x (C):
b2GetVersion()returns ab2Versionstruct of three ints (major, minor, revision) built fromB2_VERSION_MAJOR/MINOR/REVISION, defined ininclude/box2d/base.h; the tree read here is 3.2.0. See Fact:Box2D/struct/b2Version and b2GetVersion. - Constants that survive into a binary as float immediates:
B2_LINEAR_SLOP = 0.005f * lengthUnitsPerMeter(0.005),B2_SPECULATIVE_DISTANCE = 4 * B2_LINEAR_SLOP(0.02),B2_CONTACT_RECYCLE_DISTANCE = 10 * B2_LINEAR_SLOP(0.05) ininclude/box2d/constants.h. A float 0.005 next to 0.02 in .rdata of a game is a hint of Box2D 3.x. - Box2D 2.x (C++): classes
b2World,b2Body,b2Fixture,b2PolygonShape,b2ContactSolverand the constantb2_linearSlop(0.005f); read in the v2.4.1 tag (erincatto/box2d commit 9ebbbcd960ad424e03e5de6e66a40764c16f51bc):include/box2d/b2_world.hdefinesclass B2_API b2World(line 46),b2_body.hclass B2_API b2Body(line 128),b2_polygon_shape.hclass B2_API b2PolygonShape(line 32),src/dynamics/b2_contact_solver.hclass b2ContactSolver(line 74) andb2_common.hline 65#define b2_linearSlop (0.005f * b2_lengthUnitsPerMeter). The 3.x tree replaced this C++ API with C handles (b2WorldId,b2BodyId). Version 2.x has no version function, but it does have a global data object:extern B2_API b2Version b2_version;(b2_common.hline 136), defined insrc/common/b2_settings.cppline 30 asb2Version b2_version = {2, 4, 0};(the v2.4.1 tag still says 2.4.0), three ints major, minor, revision in .data. Look for that struct, the class names, RTTI and the constants. - Static build: Unverified: Box2D is usually linked statically (it is a small library); there is often no DLL to identify, so rely on RTTI/strings with the
b2prefix, the constants above and symbol names if the executable has them.
Sources
- erincatto/box2d (MIT): include/box2d/base.h, constants.h and src/core.c were read.
Code & repositories
- https://github.com/erincatto/box2d @
ac7c751eaeddbabdc1c4d41ae4f3a25d78627790· license: MIT
Box2D (MIT): include/box2d/base.h b2Version and B2_VERSION_* macros, include/box2d/constants.h tuning constants, src/core.c b2GetVersion
Tested on: source read, not run: source read only · checked 2026-10-18; last activity 2026-10-18