Debug draw is always enabled.
This commit is contained in:
parent
90ac168309
commit
7d7d40ba8e
|
@ -120,22 +120,26 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
rp3d::DebugRenderer* rp3dRenderer = nullptr;
|
rp3d::DebugRenderer* rp3dRenderer = nullptr;
|
||||||
#ifdef SHEDITOR
|
if (system->physicsSystem->worldState.world)
|
||||||
const auto* EDITOR = SHSystemManager::GetSystem<SHEditor>();
|
|
||||||
if (EDITOR && EDITOR->editorState != SHEditor::State::STOP)
|
|
||||||
{
|
|
||||||
rp3dRenderer = &system->physicsSystem->worldState.world->getDebugRenderer();
|
rp3dRenderer = &system->physicsSystem->worldState.world->getDebugRenderer();
|
||||||
rp3dRenderer->setIsDebugItemDisplayed(rp3d::DebugRenderer::DebugItem::CONTACT_POINT, false);
|
|
||||||
rp3dRenderer->setIsDebugItemDisplayed(rp3d::DebugRenderer::DebugItem::CONTACT_NORMAL, false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < SHUtilities::ConvertEnum(DebugDrawFlags::NUM_FLAGS); ++i)
|
for (int i = 0; i < SHUtilities::ConvertEnum(DebugDrawFlags::NUM_FLAGS); ++i)
|
||||||
{
|
{
|
||||||
const bool DRAW = (system->debugDrawFlags & (1U << i)) > 0;
|
const bool DRAW = (system->debugDrawFlags & (1U << i)) > 0;
|
||||||
if (DRAW)
|
if (DRAW)
|
||||||
|
{
|
||||||
drawFunctions[i](debugDrawSystem, rp3dRenderer);
|
drawFunctions[i](debugDrawSystem, rp3dRenderer);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rp3dRenderer && (i == 3 || i == 4))
|
||||||
|
{
|
||||||
|
rp3dRenderer->setIsDebugItemDisplayed(reactphysics3d::DebugRenderer::DebugItem::CONTACT_POINT, false);
|
||||||
|
rp3dRenderer->setIsDebugItemDisplayed(reactphysics3d::DebugRenderer::DebugItem::CONTACT_NORMAL, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Automatically clear the container of raycasts despite debug drawing state
|
// Automatically clear the container of raycasts despite debug drawing state
|
||||||
// TODO(Diren): Move this somewhere else
|
// TODO(Diren): Move this somewhere else
|
||||||
|
@ -180,6 +184,7 @@ namespace SHADE
|
||||||
void SHPhysicsDebugDrawSystem::drawContactPoints(SHDebugDrawSystem* debugRenderer, rp3d::DebugRenderer* rp3dRenderer) noexcept
|
void SHPhysicsDebugDrawSystem::drawContactPoints(SHDebugDrawSystem* debugRenderer, rp3d::DebugRenderer* rp3dRenderer) noexcept
|
||||||
{
|
{
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
const auto* EDITOR = SHSystemManager::GetSystem<SHEditor>();
|
const auto* EDITOR = SHSystemManager::GetSystem<SHEditor>();
|
||||||
if (EDITOR && EDITOR->editorState != SHEditor::State::STOP)
|
if (EDITOR && EDITOR->editorState != SHEditor::State::STOP)
|
||||||
{
|
{
|
||||||
|
@ -192,6 +197,18 @@ namespace SHADE
|
||||||
for (int i = 0; i < NUM_TRIS; ++i)
|
for (int i = 0; i < NUM_TRIS; ++i)
|
||||||
debugRenderer->DrawTri(SHColour::RED, TRI_ARRAY[i].point1, TRI_ARRAY[i].point2, TRI_ARRAY[i].point3);
|
debugRenderer->DrawTri(SHColour::RED, TRI_ARRAY[i].point1, TRI_ARRAY[i].point2, TRI_ARRAY[i].point3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
rp3dRenderer->setIsDebugItemDisplayed(rp3d::DebugRenderer::DebugItem::CONTACT_POINT, true);
|
||||||
|
const int NUM_TRIS = static_cast<int>(rp3dRenderer->getNbTriangles());
|
||||||
|
if (NUM_TRIS == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto& TRI_ARRAY = rp3dRenderer->getTrianglesArray();
|
||||||
|
for (int i = 0; i < NUM_TRIS; ++i)
|
||||||
|
debugRenderer->DrawTri(SHColour::RED, TRI_ARRAY[i].point1, TRI_ARRAY[i].point2, TRI_ARRAY[i].point3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +227,18 @@ namespace SHADE
|
||||||
for (int i = 0; i < NUM_LINES; ++i)
|
for (int i = 0; i < NUM_LINES; ++i)
|
||||||
debugRenderer->DrawLine(SHColour::RED, LINE_ARRAY[i].point1, LINE_ARRAY[i].point2);
|
debugRenderer->DrawLine(SHColour::RED, LINE_ARRAY[i].point1, LINE_ARRAY[i].point2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
rp3dRenderer->setIsDebugItemDisplayed(rp3d::DebugRenderer::DebugItem::CONTACT_NORMAL, true);
|
||||||
|
const int NUM_LINES = static_cast<int>(rp3dRenderer->getNbLines());
|
||||||
|
if (NUM_LINES == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto& LINE_ARRAY = rp3dRenderer->getLinesArray();
|
||||||
|
for (int i = 0; i < NUM_LINES; ++i)
|
||||||
|
debugRenderer->DrawLine(SHColour::RED, LINE_ARRAY[i].point1, LINE_ARRAY[i].point2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,8 +163,6 @@ namespace SHADE
|
||||||
// Destroy an existing world
|
// Destroy an existing world
|
||||||
if (worldState.world != nullptr)
|
if (worldState.world != nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
objectManager.RemoveAllObjects();
|
objectManager.RemoveAllObjects();
|
||||||
objectManager.SetWorld(nullptr);
|
objectManager.SetWorld(nullptr);
|
||||||
|
|
||||||
|
@ -175,11 +173,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
worldState.CreateWorld(factory);
|
worldState.CreateWorld(factory);
|
||||||
#ifdef _PUBLISH
|
|
||||||
worldState.world->setIsDebugRenderingEnabled(false);
|
|
||||||
#else
|
|
||||||
worldState.world->setIsDebugRenderingEnabled(true);
|
worldState.world->setIsDebugRenderingEnabled(true);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Link Collision Listener & Raycaster
|
// Link Collision Listener & Raycaster
|
||||||
collisionListener.BindToWorld(worldState.world);
|
collisionListener.BindToWorld(worldState.world);
|
||||||
|
@ -444,11 +438,7 @@ namespace SHADE
|
||||||
return onPlayEvent->handle;
|
return onPlayEvent->handle;
|
||||||
|
|
||||||
worldState.CreateWorld(factory);
|
worldState.CreateWorld(factory);
|
||||||
#ifdef _PUBLISH
|
|
||||||
worldState.world->setIsDebugRenderingEnabled(false);
|
|
||||||
#else
|
|
||||||
worldState.world->setIsDebugRenderingEnabled(true);
|
worldState.world->setIsDebugRenderingEnabled(true);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Link Collision Listener & Raycaster
|
// Link Collision Listener & Raycaster
|
||||||
collisionListener.BindToWorld(worldState.world);
|
collisionListener.BindToWorld(worldState.world);
|
||||||
|
|
|
@ -334,10 +334,6 @@ namespace SHADE
|
||||||
if (physicsObject.GetRigidBody()->isActive())
|
if (physicsObject.GetRigidBody()->isActive())
|
||||||
physicsObject.prevTransform = CURRENT_TF;
|
physicsObject.prevTransform = CURRENT_TF;
|
||||||
|
|
||||||
// Skip sleeping objects
|
|
||||||
if (physicsObject.GetRigidBody()->isSleeping())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Sync with rigid bodies
|
// Sync with rigid bodies
|
||||||
if (rigidBodyComponent && SHSceneManager::CheckNodeAndComponentsActive<SHRigidBodyComponent>(physicsObject.entityID))
|
if (rigidBodyComponent && SHSceneManager::CheckNodeAndComponentsActive<SHRigidBodyComponent>(physicsObject.entityID))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue