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
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-FileCopyrightText: 2025 Erin Catto
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "gfx/draw.h"
|
||||
#include "imgui.h"
|
||||
#include "mesh_loader.h"
|
||||
#include "sample.h"
|
||||
#include "gfx/draw.h"
|
||||
|
||||
#include "box3d/box3d.h"
|
||||
|
||||
|
|
@ -242,7 +242,6 @@ public:
|
|||
if ( context->restart == false )
|
||||
{
|
||||
m_camera->SetView( 0.0f, 15.0f, 10.0f, { 0.0f, 2.0f, 0.0f } );
|
||||
|
||||
}
|
||||
|
||||
AddGroundBox( 10.0f );
|
||||
|
|
@ -361,11 +360,11 @@ public:
|
|||
|
||||
b3ShapeDef shapeDef = b3DefaultShapeDef();
|
||||
m_heightField = b3CreateGrid( 40, 40, { 0.5f, 1.0f, 0.5f }, false );
|
||||
//m_heightField = b3CreateWave( 40, 40, {1.0f, 2.0f, 1.0f}, 0.02f, 0.04f, false );
|
||||
// m_heightField = b3CreateWave( 40, 40, {1.0f, 2.0f, 1.0f}, 0.02f, 0.04f, false );
|
||||
b3CreateHeightFieldShape( groundId, &shapeDef, m_heightField );
|
||||
|
||||
m_gridMesh = b3CreateGridMesh( 40, 40, 0.5f, 1, true );
|
||||
//b3CreateMeshShape( groundId, &shapeDef, m_gridMesh, b3Vec3_one );
|
||||
// b3CreateMeshShape( groundId, &shapeDef, m_gridMesh, b3Vec3_one );
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -444,6 +443,7 @@ public:
|
|||
|
||||
// --- Building mesh on top of ground ---
|
||||
m_building = CreateMeshData( "data/meshes/building.obj", 1.0f, false, false, true, true );
|
||||
if ( m_building != nullptr )
|
||||
{
|
||||
b3BodyDef bodyDef = b3DefaultBodyDef();
|
||||
bodyDef.position = { 0.0f, 0.1f, 0.0f };
|
||||
|
|
@ -492,7 +492,6 @@ public:
|
|||
|
||||
static int sampleIndex = RegisterSample( "Issues", "Capsule Mesh", CapsuleMeshBug::Create );
|
||||
|
||||
|
||||
// Reproduces s&box rigid body character ghost collisions on a FLAT floor.
|
||||
//
|
||||
// The s&box player is a fixed rotation dynamic body (zero radius box hull) moved by setting
|
||||
|
|
@ -564,7 +563,7 @@ public:
|
|||
b3ShapeDef shapeDef = b3DefaultShapeDef();
|
||||
shapeDef.baseMaterial.friction = 0.0f;
|
||||
shapeDef.baseMaterial.restitution = 0.0f;
|
||||
//shapeDef.baseMaterial.customColor = b3_colorLimeGreen;
|
||||
// shapeDef.baseMaterial.customColor = b3_colorLimeGreen;
|
||||
|
||||
float volume = 8.0f * m_bodyHalfWidth * m_bodyHalfHeight * m_bodyHalfWidth;
|
||||
shapeDef.density = m_characterMass / volume;
|
||||
|
|
@ -828,7 +827,7 @@ public:
|
|||
}
|
||||
else if ( position.z < -m_walkRangeZ )
|
||||
{
|
||||
m_walkDirectionZ= 1.0f;
|
||||
m_walkDirectionZ = 1.0f;
|
||||
}
|
||||
|
||||
b3Vec3 velocity = b3Body_GetLinearVelocity( m_characterId );
|
||||
|
|
@ -1096,11 +1095,11 @@ public:
|
|||
bodyDef.position = { 0.0f, startY + i * spacing, 0.0f };
|
||||
b3BodyId bodyId = b3CreateBody( m_worldId, &bodyDef );
|
||||
|
||||
//for ( int h = 0; h < s_metalWheel1HullCount; ++h )
|
||||
// for ( int h = 0; h < s_metalWheel1HullCount; ++h )
|
||||
//{
|
||||
// b3CreateHullShape( bodyId, &shapeDef, m_hulls[h] );
|
||||
//}
|
||||
|
||||
// }
|
||||
|
||||
// Using a single hull improves the simulation.
|
||||
b3CreateHullShape( bodyId, &shapeDef, wheelHull );
|
||||
}
|
||||
|
|
@ -1286,7 +1285,7 @@ public:
|
|||
bodyDef.type = b3_dynamicBody;
|
||||
bodyDef.position = { -boxOffset.x, 5.0f - boxOffset.y, -boxOffset.z };
|
||||
bodyDef.rotation = orientation;
|
||||
//bodyDef.angularVelocity = 25.0f * b3RotateVector( orientation, b3Vec3_axisY );
|
||||
// bodyDef.angularVelocity = 25.0f * b3RotateVector( orientation, b3Vec3_axisY );
|
||||
b3BodyId boxBody = b3CreateBody( m_worldId, &bodyDef );
|
||||
b3BoxHull mBox = b3MakeOffsetBoxHull( 1.0f, 0.5f, 1.0f, boxLocalCenter );
|
||||
shapeDef.baseMaterial.friction = 0.3f;
|
||||
|
|
|
|||
Loading…
Reference in a new issue