Fixes 07 (#97)

#84 
#82 
Added B3_RESTITUTION_ITERATIONS to override restitution iterations.
Fix regression in hull stacking stability.
This commit is contained in:
Erin Catto 2026-07-20 22:05:11 -07:00 • committed by GitHub
commit 23861418d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 877 additions and 448 deletions

View file

@ -1,13 +1,12 @@
// SPDX-FileCopyrightText: 2025 Erin Catto
// SPDX-License-Identifier: MIT
#include "gfx/debug_adapter.h"
#include "gfx/draw.h"
#include "imgui.h"
#include "sample.h"
#include "gfx/draw.h"
#include "utils.h"
#include "gfx/debug_adapter.h"
#include "box3d/box3d.h"
#include <stdio.h>
@ -442,7 +441,7 @@ public:
m_runCount = 0;
m_failure = false;
m_autoGenerate = false;
m_collide = true;
m_stepWhilePaused = true;
Generate();
@ -549,13 +548,16 @@ public:
// Don't allow shapes to collide with each other. This
// makes isolating failures easier.
shapeDef.filter.categoryBits = 2;
shapeDef.filter.maskBits = 1;
if ( m_collide == false )
{
shapeDef.filter.categoryBits = 2;
shapeDef.filter.maskBits = 1;
}
g_randomSeed = (uint32_t)b3GetTicks();
bool simulateAll = true;
//g_randomSeed = 1910133196;
// g_randomSeed = 1910133196;
m_runCount += 1;
m_stepCount = 0;
@ -624,6 +626,11 @@ public:
Generate();
}
if ( ImGui::Checkbox( "Collide", &m_collide ) )
{
Generate();
}
if ( ImGui::Button( "Generate" ) )
{
Generate();
@ -645,8 +652,7 @@ 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 )
{
@ -736,6 +742,7 @@ public:
int m_runCount;
bool m_failure;
bool m_autoGenerate;
bool m_collide;
};
static int sampleMeshDrop = RegisterSample( "Continuous", "Mesh Drop", MeshDrop::Create );
@ -862,13 +869,12 @@ public:
if ( context->restart == false )
{
m_camera->SetView( 0.0f, 15.0f, 50.0f, { 0.0f, 15.0f, 0.0f } );
}
AddGroundBox( 40.0f );
b3BoxHull box = b3MakeBoxHull( 0.5f, 10.0f, 0.5f );
b3Capsule capsule = {{0.0f, -9.5f, 0.0f}, {0.0f, 9.5f, 0.0f}, 0.5f};
b3Capsule capsule = { { 0.0f, -9.5f, 0.0f }, { 0.0f, 9.5f, 0.0f }, 0.5f };
bool useCapsule = false;
@ -881,7 +887,7 @@ public:
b3BodyId bodyId = b3CreateBody( m_worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
if (useCapsule)
if ( useCapsule )
{
b3CreateCapsuleShape( bodyId, &shapeDef, &capsule );
}