Optimize Broad-Phase (#159)

Broad-phase optimization ported from Box2D.
This commit is contained in:
Erin Catto 2026-09-16 22:28:39 -07:00 • committed by GitHub
commit f555ee4208
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 3802 additions and 1830 deletions

View file

@ -1439,7 +1439,7 @@ public:
void Step() override
{
if ( m_context->pause == false || m_context->singleStep == 0 )
if ( m_context->pause == false || m_context->singleStep > 0 )
{
StepJunkyard( m_worldId, m_stepCount );
}
@ -1486,3 +1486,78 @@ public:
};
static int sampleConvexPile = RegisterSample( "Benchmark", "Convex Pile", BenchmarkConvexPile::Create );
class BenchmarkSpinner : public Sample
{
public:
explicit BenchmarkSpinner( SampleContext* context )
: Sample( context )
{
if ( m_context->restart == false )
{
m_camera->SetView( 0.0f, 12.0f, 45.0f, { 0.0f, 12.0f, 0.0f } );
}
b3Capacity capacity = {};
GetSpinnerCapacity( &capacity );
CreateWorld( &capacity );
CreateSpinner( m_worldId );
}
~BenchmarkSpinner() override
{
DestroySpinner();
}
void Step() override
{
Sample::Step();
DrawTextLine( "spinner angle = %.2f", GetSpinnerAngle() );
}
static Sample* Create( SampleContext* context )
{
return new BenchmarkSpinner( context );
}
};
static int benchmarkSpinner = RegisterSample( "Benchmark", "Spinner", BenchmarkSpinner::Create );
class BenchmarkSleep : public Sample
{
public:
explicit BenchmarkSleep( SampleContext* context )
: Sample( context )
{
if ( m_context->restart == false )
{
m_camera->SetView( -10.0f, 25.0f, 100.0f, { 0.0f, 3.0f, 0.0f } );
}
b3Capacity capacity = {};
GetSleepCapacity( &capacity );
CreateWorld( &capacity );
CreateSleep( m_worldId );
SetGroundShape( GetGroundShapeId() );
}
void Step() override
{
if ( m_context->pause == false || m_context->singleStep > 0 )
{
StepSleep( m_worldId, m_stepCount );
}
Sample::Step();
}
static Sample* Create( SampleContext* context )
{
return new BenchmarkSleep( context );
}
};
static int benchmarkSleep = RegisterSample( "Benchmark", "Sleep", BenchmarkSleep::Create );