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,7 +22,7 @@ public:
{
if ( context->restart == false )
{
m_camera->SetView( 45.0f, 30.0f, 30.0f, b3Vec3_zero );
m_camera->SetView( 45.0f, 30.0f, 30.0f, b3Pos_zero );
}
AddGroundBox( 40.0f );
@ -80,7 +80,7 @@ public:
{
if ( context->restart == false )
{
m_camera->SetView( 45.0f, 45.0f, 50.0f, b3Vec3_zero );
m_camera->SetView( 45.0f, 45.0f, 50.0f, b3Pos_zero );
}
AddGroundBox( 10.0f );
@ -426,7 +426,7 @@ public:
{
if ( context->restart == false )
{
m_camera->SetView( 0.0f, 30.0f, 20.0f, b3Vec3_zero );
m_camera->SetView( 0.0f, 30.0f, 20.0f, b3Pos_zero );
GetGuiDraw()->forceScale = 0.1f;
}
@ -650,7 +650,8 @@ public:
{
PickRay pickRay = m_camera->BuildPickRay( m_context->mouseX, m_context->mouseY );
b3RayResult result = b3World_CastRayClosest( m_worldId, pickRay.origin, pickRay.translation, b3DefaultQueryFilter() );
b3RayResult result =
b3World_CastRayClosest( m_worldId, pickRay.origin, pickRay.translation, b3DefaultQueryFilter() );
if ( result.hit )
{
@ -669,7 +670,7 @@ public:
continue;
}
b3Vec3 massCenter = b3Body_GetWorldCenterOfMass( bodyId );
b3Pos massCenter = b3Body_GetWorldCenterOfMass( bodyId );
if ( massCenter.y < -2.0f )
{
IndexPair pair = ConvertToPair( b3Body_GetUserData( bodyId ) );
@ -752,11 +753,11 @@ public:
{
if ( context->restart == false )
{
m_camera->SetView( 0.0f, 30.0f, 20.0f, b3Vec3_zero );
m_camera->SetView( 0.0f, 30.0f, 20.0f, b3Pos_zero );
GetGuiDraw()->forceScale = 0.1f;
}
m_data = CreateMeshDrop( m_worldId );
m_data = CreateMeshDrop( m_worldId, b3Pos_zero );
m_failed = false;
}