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

@ -192,6 +192,8 @@ static b3Shape* b3CreateShapeInternal( b3World* world, b3Body* body, b3WorldTran
if ( shape->type == b3_compoundShape )
{
world->compoundShapeCount += 1;
// Own a copy of the compound materials so every shape frees its array the same way. Compounds
// are few, so the copy is cheap and avoids aliasing the geometry blob.
int materialCount = shape->compound->materialCount;
@ -481,6 +483,12 @@ static void b3DestroyShapeInternal( b3World* world, b3Shape* shape, b3Body* body
{
int shapeId = shape->id;
if ( shape->type == b3_compoundShape )
{
B3_ASSERT( world->compoundShapeCount > 0 );
world->compoundShapeCount -= 1;
}
// Remove the shape from the body's doubly linked list.
if ( shape->prevShapeId != B3_NULL_INDEX )
{