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:
parent
23861418d8
commit
c52908c9a9
11 changed files with 307 additions and 153 deletions
|
|
@ -574,9 +574,11 @@ public:
|
|||
constexpr int materialCapacity = 5;
|
||||
|
||||
b3SurfaceMaterial meshMaterials[materialCapacity];
|
||||
|
||||
// Without the building mesh the village still stands, just with no buildings
|
||||
b3MeshData* buildingMesh = CreateMeshData( "data/meshes/building.obj", 1.0f, false, false, true, true );
|
||||
|
||||
int materialCount = buildingMesh->materialCount;
|
||||
int materialCount = buildingMesh != nullptr ? buildingMesh->materialCount : 0;
|
||||
assert( materialCount <= materialCapacity );
|
||||
|
||||
for ( int i = 0; i < materialCount; ++i )
|
||||
|
|
@ -593,11 +595,11 @@ public:
|
|||
meshMaterials[i].userMaterialId = i + 42;
|
||||
}
|
||||
|
||||
b3CompoundMeshDef* meshes = new b3CompoundMeshDef[meshCount];
|
||||
b3CompoundMeshDef* meshes = buildingMesh != nullptr ? new b3CompoundMeshDef[meshCount] : nullptr;
|
||||
transform = b3Transform_identity;
|
||||
|
||||
int meshIndex = 0;
|
||||
for ( int i = 0; i < meshGridCount; ++i )
|
||||
for ( int i = 0; meshes != nullptr && i < meshGridCount; ++i )
|
||||
{
|
||||
transform.p.x = ( 2.0f * i - meshGridCount ) * b + 0.5f * b;
|
||||
|
||||
|
|
@ -630,7 +632,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
assert( meshIndex == meshCount );
|
||||
assert( meshes == nullptr || meshIndex == meshCount );
|
||||
|
||||
b3CompoundDef def = {};
|
||||
def.capsules = capsules;
|
||||
|
|
@ -639,7 +641,7 @@ public:
|
|||
def.hulls = hulls;
|
||||
def.hullCount = hullCount;
|
||||
def.meshes = meshes;
|
||||
def.meshCount = meshCount;
|
||||
def.meshCount = meshIndex;
|
||||
def.spheres = spheres;
|
||||
def.sphereCount = sphereIndex;
|
||||
|
||||
|
|
@ -665,7 +667,7 @@ public:
|
|||
delete[] spheres;
|
||||
spheres = nullptr;
|
||||
|
||||
b3DestroyMesh( buildingMesh );
|
||||
DestroyMeshData( buildingMesh );
|
||||
}
|
||||
|
||||
m_rayOrigin = { -0.45f * m_worldWidth, 20.0f, -0.45f * m_worldWidth };
|
||||
|
|
|
|||
Loading…
Reference in a new issue