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

@ -12,11 +12,12 @@
#define MESH_DROP_GRID_COUNT 32
MeshDropData CreateMeshDrop( b3WorldId worldId )
MeshDropData CreateMeshDrop( b3WorldId worldId, b3Pos origin )
{
MeshDropData data = { 0 };
{
b3BodyDef bodyDef = b3DefaultBodyDef();
bodyDef.position = origin;
b3BodyId groundId = b3CreateBody( worldId, &bodyDef );
int gridCount = 40;
@ -55,7 +56,8 @@ MeshDropData CreateMeshDrop( b3WorldId worldId )
b3Vec3 linearVelocity = RandomVec3Uniform( -1.0f, 1.0f );
b3Vec3 angularVelocity = RandomVec3Uniform( -5.0f, 5.0f );
bodyDef.position = (b3Vec3){ 0.5f * ( i - 0.5f * gridCount ), 5.0f, 0.5f * ( j - 0.5f * gridCount ) };
bodyDef.position =
b3OffsetPos( origin, (b3Vec3){ 0.5f * ( i - 0.5f * gridCount ), 5.0f, 0.5f * ( j - 0.5f * gridCount ) } );
bodyDef.linearVelocity = linearVelocity;
bodyDef.angularVelocity = angularVelocity;
b3BodyId bodyId = b3CreateBody( worldId, &bodyDef );