Hull sharing (#13)

Save memory when there are many duplicate hulls. Can improve performance
in some cases.

For consistency with b3MeshData, b3Hull is renamed to b3HullData.
This commit is contained in:
Erin Catto 2026-06-11 22:39:26 -07:00 • committed by GitHub
commit a252f03b19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 881 additions and 549 deletions

View file

@ -197,7 +197,7 @@ public:
return new GridMesh( context );
}
b3Hull* m_cylinderHull;
b3HullData* m_cylinderHull;
ShapeType m_shapeType;
b3BodyId m_bodyId;
b3MeshData* m_gridMesh;
@ -371,7 +371,7 @@ public:
return new BigBoxMesh( context );
}
b3Hull* m_cylinderHull;
b3HullData* m_cylinderHull;
ShapeType m_shapeType;
b3BodyId m_bodyId;
b3MeshData* m_boxMesh;
@ -543,7 +543,7 @@ public:
ShapeType m_shapeType;
b3BodyId m_bodyId;
b3MeshData* m_boxMesh;
b3Hull* m_cylinderHull;
b3HullData* m_cylinderHull;
b3ShapeId m_boxShapeId;
b3Vec3 m_scale;
};
@ -1443,7 +1443,7 @@ public:
points[i] = b3MulSV( 0.01f, b3Vec3{ p.y, p.z, p.x } );
}
b3Hull* hull = b3CreateHull( points, 16, 16 );
b3HullData* hull = b3CreateHull( points, 16, 16 );
b3BodyDef bodyDef = b3DefaultBodyDef();
bodyDef.name = "cylinder";
bodyDef.type = b3_dynamicBody;
@ -1516,7 +1516,7 @@ public:
b3ShapeDef shapeDef = b3DefaultShapeDef();
{
b3Hull* cylinderHull = b3CreateCylinder( 1.0f, 0.25f, 0.0f, 8 );
b3HullData* cylinderHull = b3CreateCylinder( 1.0f, 0.25f, 0.0f, 8 );
b3Vec3 positions[6] = {
{ 0.0f, -10.2f, 0.0f }, { 0.0f, 9.2f, 0.0f }, { -9.8f, 0.0f, 0.0f },