Added a compile time option to use double precision body positions. Most
math remains single precision with minimal performance loss.

`BOX3D_DOUBLE_PRECISION`

Improved accuracy of body inertia computation when shapes are far from
the body origin.

WARNING: several APIs changed but migration should be straight forward
if doubles are not enabled.
This commit is contained in:
Erin Catto 2026-06-18 20:51:16 -07:00 • committed by GitHub
commit 09c65b08ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
115 changed files with 7591 additions and 5295 deletions

View file

@ -22,11 +22,12 @@ static int ShapeMassTest( void )
float mass = 4.0f / 3.0f * B3_PI;
ENSURE_SMALL( md.mass - mass, FLT_EPSILON );
ENSURE( md.center.x == 1.0f && md.center.y == 0.0f );
// Inertia is now about the shape center of mass, so the offset does not appear.
float inertia = 2.0f / 5.0f * mass;
float offsetInertia = inertia + mass;
ENSURE_SMALL( md.inertia.cx.x - inertia, FLT_EPSILON );
ENSURE_SMALL( md.inertia.cy.y - offsetInertia, FLT_EPSILON );
ENSURE_SMALL( md.inertia.cz.z - offsetInertia, FLT_EPSILON );
ENSURE_SMALL( md.inertia.cy.y - inertia, FLT_EPSILON );
ENSURE_SMALL( md.inertia.cz.z - inertia, FLT_EPSILON );
}
// Analytic box hull