Fixes 08 (#98)

- fix hull builder face and edge leak
- fix #95
- samples app will no longer crash if data folder is not found
This commit is contained in:
Erin Catto 2026-07-22 15:55:02 -07:00 • committed by GitHub
commit c52908c9a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 307 additions and 153 deletions

View file

@ -340,7 +340,10 @@ public:
shapeDef.materials = materials;
shapeDef.materialCount = 3;
b3CreateMeshShape( body, &shapeDef, m_levelMesh, b3Vec3_one );
if ( m_levelMesh != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_levelMesh, b3Vec3_one );
}
// b3Transform transform = { { 0.0f, 1.0f, 14.0f }, b3MakeQuatFromAxisAngle( b3Vec3_axisY, 0.75f * B3_PI ) };
// b3BoxHull box = b3MakeTransformedBoxHull( 5.0f, 1.0f, 0.5f, transform );
@ -371,7 +374,10 @@ public:
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3BodyId body = b3CreateBody( m_worldId, &bodyDef );
b3CreateMeshShape( body, &shapeDef, m_stairs, { 0.75f, 0.75f, -1.5f } );
if ( m_stairs != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_stairs, { 0.75f, 0.75f, -1.5f } );
}
}
{
@ -530,9 +536,9 @@ public:
{
m_camera->m_thirdPerson = false;
sapp_lock_mouse( false );
b3DestroyMesh( m_levelMesh );
b3DestroyMesh( m_stairs );
b3DestroyMesh( m_torus );
DestroyMeshData( m_levelMesh );
DestroyMeshData( m_stairs );
DestroyMeshData( m_torus );
b3DestroyHeightField( m_heightField );
}
@ -1340,7 +1346,10 @@ public:
shapeDef.materials = materials;
shapeDef.materialCount = 3;
b3CreateMeshShape( body, &shapeDef, m_levelMesh, b3Vec3_one );
if ( m_levelMesh != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_levelMesh, b3Vec3_one );
}
}
// --- Stairs mesh ---
@ -1351,7 +1360,10 @@ public:
b3BodyId body = b3CreateBody( m_worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateMeshShape( body, &shapeDef, m_stairs, { 0.75f, 0.75f, -1.5f } );
if ( m_stairs != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_stairs, { 0.75f, 0.75f, -1.5f } );
}
}
// --- High-poly building mesh ---
@ -1362,7 +1374,10 @@ public:
b3BodyId body = b3CreateBody( m_worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateMeshShape( body, &shapeDef, m_building, b3Vec3_one );
if ( m_building != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_building, b3Vec3_one );
}
}
// --- Voxel meshes (dense tri terrain) ---
@ -1373,7 +1388,10 @@ public:
b3BodyId body = b3CreateBody( m_worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateMeshShape( body, &shapeDef, m_voxel01, b3Vec3_one );
if ( m_voxel01 != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_voxel01, b3Vec3_one );
}
}
{
m_voxel02 = CreateMeshData( "data/meshes/voxel_mesh_02.obj", 1.0f, false, false, true, true );
@ -1382,7 +1400,10 @@ public:
b3BodyId body = b3CreateBody( m_worldId, &bodyDef );
b3ShapeDef shapeDef = b3DefaultShapeDef();
b3CreateMeshShape( body, &shapeDef, m_voxel02, b3Vec3_one );
if ( m_voxel02 != nullptr )
{
b3CreateMeshShape( body, &shapeDef, m_voxel02, b3Vec3_one );
}
}
// --- Height field terrain ---
@ -1494,11 +1515,11 @@ public:
{
m_camera->m_thirdPerson = false;
sapp_lock_mouse( false );
b3DestroyMesh( m_levelMesh );
b3DestroyMesh( m_stairs );
b3DestroyMesh( m_building );
b3DestroyMesh( m_voxel01 );
b3DestroyMesh( m_voxel02 );
DestroyMeshData( m_levelMesh );
DestroyMeshData( m_stairs );
DestroyMeshData( m_building );
DestroyMeshData( m_voxel01 );
DestroyMeshData( m_voxel02 );
b3DestroyHeightField( m_heightField );
}