From b60304457977b9e874b3ff44606a25f5f0916966 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Mon, 16 Jan 2023 14:39:35 +0800 Subject: [PATCH] Fixed validation errors caused by debug draw and fixed SHDebugDraw::WireCapsule not being static --- .../Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp | 9 ++++++++- SHADE_Engine/src/Tools/SHDebugDraw.h | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp index ae8c62b2..5a694516 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp @@ -104,6 +104,10 @@ namespace SHADE auto subPass = renderGraph->GetNode("Debug Draw")->GetSubpass("Debug Draw"); subPass->AddExteriorDrawCalls([this](Handle cmdBuffer, Handle renderer, uint32_t frameIndex) { + // Set line width first + cmdBuffer->SetLineWidth(LineWidth); + + // Draw const uint32_t FRAME_IDX = gfxSystem->GetCurrentFrameIndex(); cmdBuffer->BeginLabeledSegment("SHDebugDraw (No Depth Test)"); { @@ -128,6 +132,10 @@ namespace SHADE auto subPassWithDepth = renderGraph->GetNode("Debug Draw with Depth")->GetSubpass("Debug Draw with Depth"); subPassWithDepth->AddExteriorDrawCalls([this](Handle cmdBuffer, Handle renderer, uint32_t frameIndex) { + // Set line width first + cmdBuffer->SetLineWidth(LineWidth); + + // Draw const uint32_t FRAME_IDX = gfxSystem->GetCurrentFrameIndex(); cmdBuffer->BeginLabeledSegment("SHDebugDraw (Depth Tested)"); { @@ -506,7 +514,6 @@ namespace SHADE if (batch.NumPoints[frameIndex] > 0) { cmdBuffer->BindPipeline(batch.Pipeline); - cmdBuffer->SetLineWidth(LineWidth); cmdBuffer->BindVertexBuffer(0, batch.VertexBuffers[frameIndex], 0); cmdBuffer->DrawArrays(batch.NumPoints[frameIndex], 1, 0, 0); } diff --git a/SHADE_Engine/src/Tools/SHDebugDraw.h b/SHADE_Engine/src/Tools/SHDebugDraw.h index 3d7bee2f..c775a514 100644 --- a/SHADE_Engine/src/Tools/SHDebugDraw.h +++ b/SHADE_Engine/src/Tools/SHDebugDraw.h @@ -205,7 +205,7 @@ namespace SHADE /// /// Colour to draw with. /// Whether or not drawn object will be occluded. - void WireCapsule(const SHVec3& position, const SHQuaternion& rotation, float height, float radius, const SHColour& color = SHColour::WHITE, bool depthTested = false); + static void WireCapsule(const SHVec3& position, const SHQuaternion& rotation, float height, float radius, const SHColour& color = SHColour::WHITE, bool depthTested = false); /*---------------------------------------------------------------------------------*/ /* Persistent Draw Function Class "Folder" */ @@ -388,7 +388,7 @@ namespace SHADE /// /// Colour to draw with. /// Whether or not drawn object will be occluded. - void WireCapsule(const SHVec3& position, const SHQuaternion& rotation, float height, float radius, const SHColour& color = SHColour::WHITE, bool depthTested = false); + static void WireCapsule(const SHVec3& position, const SHQuaternion& rotation, float height, float radius, const SHColour& color = SHColour::WHITE, bool depthTested = false); /// /// Clears any persistent drawn debug primitives. ///