From 78575b11e4b95152c9c24f37403abd04a9664adb Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Thu, 15 Dec 2022 18:08:12 +0800 Subject: [PATCH] Added debug draw of wire spheres, filled cube and filled sphere --- SHADE_Application/src/Scenes/SBTestScene.cpp | 2 - .../MiddleEnd/Interface/SHDebugDrawSystem.cpp | 186 ++++++++++++++++-- .../MiddleEnd/Interface/SHDebugDrawSystem.h | 23 ++- SHADE_Engine/src/Tools/SHDebugDraw.cpp | 61 ++++-- SHADE_Engine/src/Tools/SHDebugDraw.h | 44 ++--- SHADE_Managed/src/Utility/Gizmos.cxx | 4 +- 6 files changed, 244 insertions(+), 76 deletions(-) diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp index bcc7f09d..a5edd124 100644 --- a/SHADE_Application/src/Scenes/SBTestScene.cpp +++ b/SHADE_Application/src/Scenes/SBTestScene.cpp @@ -231,8 +231,6 @@ namespace Sandbox SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem()); scriptEngine->RemoveAllScripts(testObj); } - - SHDebugDraw::Cube(SHColour::CRIMSON, SHVec3(1.0f, 0.0f, 0.0f), SHVec3(1.0f, 1.0f, 1.0f)); } void SBTestScene::Render() diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp index 926adae8..f3527ed2 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp @@ -67,14 +67,18 @@ namespace SHADE } } - // Set up persistent batches if it was wiped - if (system->persistentBuffersCleared[FRAME_IDX]) + // Set up persistent batches if it was changed + if (system->persistentBuffersUpdated[FRAME_IDX]) { for (auto& batch : system->persistentLineBatches) { system->prepareBatch(batch, FRAME_IDX); } - system->persistentBuffersCleared[FRAME_IDX] = false; + for (auto& batch : system->persistentMeshBatches) + { + system->prepareBatch(batch, FRAME_IDX); + } + system->persistentBuffersUpdated[FRAME_IDX] = false; } } @@ -113,6 +117,9 @@ namespace SHADE cmdBuffer->BeginLabeledSegment("SHDebugDraw (Meshes)"); { renderBatch(meshBatches[static_cast(MeshRenderMode::WireNoDepthTest)], cmdBuffer, FRAME_IDX); + renderBatch(meshBatches[static_cast(MeshRenderMode::FilledNoDepthTest)], cmdBuffer, FRAME_IDX); + renderBatch(persistentMeshBatches[static_cast(MeshRenderMode::WireNoDepthTest)], cmdBuffer, FRAME_IDX); + renderBatch(persistentMeshBatches[static_cast(MeshRenderMode::FilledNoDepthTest)], cmdBuffer, FRAME_IDX); } cmdBuffer->EndLabeledSegment(); } @@ -134,6 +141,9 @@ namespace SHADE cmdBuffer->BeginLabeledSegment("SHDebugDraw (Meshes)"); { renderBatch(meshBatches[static_cast(MeshRenderMode::WireDepthTested)], cmdBuffer, FRAME_IDX); + renderBatch(meshBatches[static_cast(MeshRenderMode::FilledDepthTested)], cmdBuffer, FRAME_IDX); + renderBatch(persistentMeshBatches[static_cast(MeshRenderMode::WireDepthTested)], cmdBuffer, FRAME_IDX); + renderBatch(persistentMeshBatches[static_cast(MeshRenderMode::FilledDepthTested)], cmdBuffer, FRAME_IDX); } cmdBuffer->EndLabeledSegment(); } @@ -167,11 +177,31 @@ namespace SHADE DrawLineLoop({ p1, p2, p3 }, color, depthTested); } + void SHDebugDrawSystem::DrawQuad(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHVec3& p4, const SHColour& color, bool depthTested) + { + DrawLineLoop({ p1, p2, p3, p4 }, color, depthTested); + } + void SHDebugDrawSystem::DrawWireCube(const SHMatrix& matrix, const SHColour& color, bool depthTested) { drawWireCube(getMeshBatch(false, depthTested), matrix, color); } + void SHDebugDrawSystem::DrawWireSphere(const SHMatrix& matrix, const SHColour& color /*= SHColour::WHITE*/, bool depthTested /*= false*/) + { + drawWireSphere(getMeshBatch(false, depthTested), matrix, color); + } + + void SHDebugDrawSystem::DrawCube(const SHMatrix& matrix, const SHColour& color /*= SHColour::WHITE*/, bool depthTested /*= false*/) + { + drawCube(getMeshBatch(true, depthTested), matrix, color); + } + + void SHDebugDrawSystem::DrawSphere(const SHMatrix& matrix, const SHColour& color /*= SHColour::WHITE*/, bool depthTested /*= false*/) + { + drawSphere(getMeshBatch(true, depthTested), matrix, color); + } + /*-----------------------------------------------------------------------------------*/ /* Persistent Draw Functions */ /*-----------------------------------------------------------------------------------*/ @@ -179,23 +209,55 @@ namespace SHADE { // Insert into the batch drawLine(getPersistentLineBatch(depthTested), start, end, color); + markPersistentDrawsDirty(); } void SHDebugDrawSystem::DrawPersistentLineLoop(std::initializer_list points, const SHColour& color, bool depthTested) { DrawPersistentLineLoop(points.begin(), points.end(), color, depthTested); + markPersistentDrawsDirty(); } void SHDebugDrawSystem::DrawPersistentTri(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHColour& color, bool depthTested) { DrawPersistentLineLoop({ p1, p2, p3 }, color, depthTested); + markPersistentDrawsDirty(); + } + + void SHDebugDrawSystem::DrawPersistentQuad(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHVec3& p4, const SHColour& color, bool depthTested) + { + DrawPersistentLineLoop({ p1, p2, p3, p4 }, color, depthTested); + markPersistentDrawsDirty(); + } + + void SHDebugDrawSystem::DrawPersistentWireCube(const SHMatrix& matrix, const SHColour& color, bool depthTested) + { + drawWireCube(getPersistentMeshBatch(false, depthTested), matrix, color); + markPersistentDrawsDirty(); + } + + void SHDebugDrawSystem::DrawPersistentWireSphere(const SHMatrix& matrix, const SHColour& color, bool depthTested) + { + drawWireSphere(getPersistentMeshBatch(false, depthTested), matrix, color); + markPersistentDrawsDirty(); + } + + void SHDebugDrawSystem::DrawPersistentCube(const SHMatrix& matrix, const SHColour& color, bool depthTested) + { + drawCube(getPersistentMeshBatch(true, depthTested), matrix, color); + markPersistentDrawsDirty(); + } + + void SHDebugDrawSystem::DrawPersistentSphere(const SHMatrix& matrix, const SHColour& color, bool depthTested) + { + drawSphere(getPersistentMeshBatch(true, depthTested), matrix, color); + markPersistentDrawsDirty(); } void SHDebugDrawSystem::ClearPersistentDraws() { for (auto& batch : persistentLineBatches) batch.Points.clear(); - for (bool& cleared : persistentBuffersCleared) - cleared = true; + markPersistentDrawsDirty(); } /*-----------------------------------------------------------------------------------*/ @@ -214,29 +276,56 @@ namespace SHADE batch.Points.emplace_back(end, color); } - void SHDebugDrawSystem::drawWireCube(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) + void SHDebugDrawSystem::drawMesh(Handle mesh, MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) { - - const auto* GFX_SYSTEM = SHSystemManager::GetSystem(); - if (!GFX_SYSTEM) - { - SHLOG_ERROR("[DebugDraw] Attempted to do debug draw without a graphics system."); - return; - } - - Handle box = GFX_SYSTEM->GetMeshPrimitive(PrimitiveType::LineCube); - // Create if doesn't exist - if (!batch.SubBatches.contains(box)) + if (!batch.SubBatches.contains(mesh)) { MeshBatch::MultiDrawSet set; - set.Mesh = box; - batch.SubBatches.emplace(box, std::move(set)); + set.Mesh = mesh; + batch.SubBatches.emplace(mesh, std::move(set)); } // Add to the batch - batch.SubBatches[box].InstanceTransforms.emplace_back(transformMatrix); - batch.SubBatches[box].InstanceColors.emplace_back(color); + auto& subBatch = batch.SubBatches[mesh]; + subBatch.InstanceTransforms.emplace_back(transformMatrix); + subBatch.InstanceColors.emplace_back(color); + } + + void SHDebugDrawSystem::drawWireCube(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) + { + drawMesh + ( + gfxSystem->GetMeshPrimitive(PrimitiveType::LineCube), + batch, transformMatrix, color + ); + } + + void SHDebugDrawSystem::drawWireSphere(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) + { + drawMesh + ( + gfxSystem->GetMeshPrimitive(PrimitiveType::Sphere), + batch, transformMatrix, color + ); + } + + void SHDebugDrawSystem::drawCube(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) + { + drawMesh + ( + gfxSystem->GetMeshPrimitive(PrimitiveType::Cube), + batch, transformMatrix, color + ); + } + + void SHDebugDrawSystem::drawSphere(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color) + { + drawMesh + ( + gfxSystem->GetMeshPrimitive(PrimitiveType::Sphere), + batch, transformMatrix, color + ); } /*-----------------------------------------------------------------------------------*/ @@ -386,6 +475,24 @@ namespace SHADE return meshBatches[static_cast(mode)]; } + SHDebugDrawSystem::MeshBatch& SHDebugDrawSystem::getPersistentMeshBatch(bool filled, bool depthTested) + { + MeshRenderMode mode = {}; + + if (filled) + { + mode = depthTested ? MeshRenderMode::FilledDepthTested + : MeshRenderMode::FilledNoDepthTest; + } + else + { + mode = depthTested ? MeshRenderMode::WireDepthTested + : MeshRenderMode::WireNoDepthTest; + } + + return persistentMeshBatches[static_cast(mode)]; + } + void SHDebugDrawSystem::createMeshBatches() { auto gfxSys = SHSystemManager::GetSystem(); @@ -416,6 +523,28 @@ namespace SHADE meshBatches[static_cast(MeshRenderMode::WireDepthTested)], gfxSys->GetDebugDrawPipeline(DebugDrawPipelineType::LineMeshDepthTested) ); + + // Set up persistent batches + initBatch + ( + persistentMeshBatches[static_cast(MeshRenderMode::FilledNoDepthTest)], + gfxSys->GetDebugDrawPipeline(DebugDrawPipelineType::FilledMeshNoDepthTest) + ); + initBatch + ( + persistentMeshBatches[static_cast(MeshRenderMode::FilledDepthTested)], + gfxSys->GetDebugDrawPipeline(DebugDrawPipelineType::FilledMeshDepthTested) + ); + initBatch + ( + persistentMeshBatches[static_cast(MeshRenderMode::WireNoDepthTest)], + gfxSys->GetDebugDrawPipeline(DebugDrawPipelineType::LineMeshNoDepthTest) + ); + initBatch + ( + persistentMeshBatches[static_cast(MeshRenderMode::WireDepthTested)], + gfxSys->GetDebugDrawPipeline(DebugDrawPipelineType::LineMeshDepthTested) + ); } void SHDebugDrawSystem::initBatch(MeshBatch& batch, Handle pipeline) { @@ -552,5 +681,20 @@ namespace SHADE destroyBatch(meshBatches[static_cast(MeshRenderMode::FilledDepthTested)]); destroyBatch(meshBatches[static_cast(MeshRenderMode::WireNoDepthTest)]); destroyBatch(meshBatches[static_cast(MeshRenderMode::WireDepthTested)]); + + destroyBatch(persistentMeshBatches[static_cast(MeshRenderMode::FilledNoDepthTest)]); + destroyBatch(persistentMeshBatches[static_cast(MeshRenderMode::FilledDepthTested)]); + destroyBatch(persistentMeshBatches[static_cast(MeshRenderMode::WireNoDepthTest)]); + destroyBatch(persistentMeshBatches[static_cast(MeshRenderMode::WireDepthTested)]); } + + /*-----------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*-----------------------------------------------------------------------------------*/ + void SHDebugDrawSystem::markPersistentDrawsDirty() + { + for (bool& dirty : persistentBuffersUpdated) + dirty = true; + } + } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h index c913de84..99b74855 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h @@ -100,7 +100,11 @@ namespace SHADE template void DrawLineLoop(IterType pointListBegin, IterType pointListEnd, const SHColour& color = SHColour::WHITE, bool depthTested = false); void DrawTri(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawQuad(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHVec3& p4, const SHColour& color = SHColour::WHITE, bool depthTested = false); void DrawWireCube(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawWireSphere(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawCube(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawSphere(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); /*---------------------------------------------------------------------------------*/ /* Persistent Draw Functions */ @@ -110,6 +114,11 @@ namespace SHADE template void DrawPersistentLineLoop(IterType pointListBegin, IterType pointListEnd, const SHColour& color = SHColour::WHITE, bool depthTested = false); void DrawPersistentTri(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawPersistentQuad(const SHVec3& p1, const SHVec3& p2, const SHVec3& p3, const SHVec3& p4, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawPersistentWireCube(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawPersistentWireSphere(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawPersistentCube(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); + void DrawPersistentSphere(const SHMatrix& matrix, const SHColour& color = SHColour::WHITE, bool depthTested = false); /// /// Clears any persistent drawn debug primitives. /// @@ -148,7 +157,6 @@ namespace SHADE // GPU Buffers TripleBuffer VertexBuffers; TripleUInt NumPoints; - }; struct MeshBatch : public Batch @@ -193,8 +201,9 @@ namespace SHADE std::array lineBatches; std::array persistentLineBatches; std::array meshBatches; + std::array persistentMeshBatches; // Tracking - TripleBool persistentBuffersCleared; // TODO: Use this + TripleBool persistentBuffersUpdated = { true, true, true }; /*---------------------------------------------------------------------------------*/ /* Helper Draw Functions */ @@ -202,7 +211,11 @@ namespace SHADE void drawLine(LinesBatch& batch, const SHVec3& start, const SHVec3& end, const SHColour& color); template void drawLineLoop(LinesBatch& batch, IterType pointListBegin, IterType pointListEnd, const SHColour& color); + void drawMesh(Handle mesh, MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color); void drawWireCube(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color); + void drawWireSphere(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color); + void drawCube(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color); + void drawSphere(MeshBatch& batch, const SHMatrix& transformMatrix, const SHColour& color); /*---------------------------------------------------------------------------------*/ /* Helper Batch Functions - Lines */ @@ -220,12 +233,18 @@ namespace SHADE /* Helper Batch Functions - Meshes */ /*---------------------------------------------------------------------------------*/ MeshBatch& getMeshBatch(bool filled, bool depthTested); + MeshBatch& getPersistentMeshBatch(bool filled, bool depthTested); void createMeshBatches(); void initBatch(MeshBatch& batch, Handle pipeline); void prepareBatch(MeshBatch& batch, uint32_t frameIndex); void renderBatch(MeshBatch& batch, Handle cmdBuffer, uint32_t frameIndex); void destroyBatch(MeshBatch& batch);; void destroyMeshBatches(); + + /*---------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*---------------------------------------------------------------------------------*/ + void markPersistentDrawsDirty(); }; } diff --git a/SHADE_Engine/src/Tools/SHDebugDraw.cpp b/SHADE_Engine/src/Tools/SHDebugDraw.cpp index b04f8629..3b64eabf 100644 --- a/SHADE_Engine/src/Tools/SHDebugDraw.cpp +++ b/SHADE_Engine/src/Tools/SHDebugDraw.cpp @@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited. #include "SHDebugDraw.h" // Project Includes #include "Math/Vector/SHVec4.h" +#include "Math/SHQuaternion.h" #include "Math/SHColour.h" #include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h" #include "ECS_Base/Managers/SHSystemManager.h" @@ -48,34 +49,52 @@ namespace SHADE void SHDebugDraw::Tri(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3) { - //dbgDrawSys->DrawTri(color, pt1, pt2, pt3); + dbgDrawSys->DrawTri(pt1, pt2, pt3, color); } void SHDebugDraw::Quad(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3, const SHVec3& pt4) { - //dbgDrawSys->DrawQuad(color, pt1, pt2, pt3, pt4); + dbgDrawSys->DrawQuad(pt1, pt2, pt3, pt4, color); } - void SHDebugDraw::Poly(const SHVec4& color, std::initializer_list pointList) + void SHDebugDraw::LineLoop(const SHVec4& color, std::initializer_list pointList) { - //dbgDrawSys->DrawPoly(color, pointList); + dbgDrawSys->DrawLineLoop(pointList, color); } - void SHDebugDraw::Cube(const SHVec4& color, const SHVec3& pos, const SHVec3& size) + void SHDebugDraw::Cube(const SHMatrix& mat, const SHVec4& color) { - //dbgDrawSys->DrawCube(color, pos, size); + dbgDrawSys->DrawCube(mat, color); } - void SHDebugDraw::Sphere(const SHVec4& color, const SHVec3& pos, double radius) + void SHDebugDraw::Sphere(const SHMatrix& mat, const SHVec4& color) { - //dbgDrawSys->DrawSphere(color, pos, radius); + dbgDrawSys->DrawSphere(mat, color); } void SHDebugDraw::WireCube(const SHMatrix& mat, const SHVec4& color) { dbgDrawSys->DrawWireCube(mat, color); } + + void SHDebugDraw::WireCube(const SHVec3& center, const SHVec3& scale, const SHVec4& color) + { + dbgDrawSys->DrawWireCube(SHMatrix::Transform(center, SHQuaternion(), scale), color); + } + void SHDebugDraw::WireSphere(const SHMatrix& mat, const SHVec4& color) + { + dbgDrawSys->DrawWireSphere(mat, color); + } + + void SHDebugDraw::WireSphere(const SHVec3& center, const SHVec3& scale, const SHVec4& color) + { + dbgDrawSys->DrawWireSphere(SHMatrix::Transform(center, SHQuaternion(), scale), color); + } + + /*-----------------------------------------------------------------------------------*/ + /* Persistent Draw Functions */ + /*-----------------------------------------------------------------------------------*/ void SHDebugDraw::PersistentLine(const SHVec4& color, const SHVec3& startPt, const SHVec3& endPt) { dbgDrawSys->DrawPersistentLine(startPt, endPt, color); @@ -83,27 +102,37 @@ namespace SHADE void SHDebugDraw::PersistentTri(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3) { - //dbgDrawSys->DrawPersistentTri(color, pt1, pt2, pt3); + dbgDrawSys->DrawPersistentTri(pt1, pt2, pt3, color); } void SHDebugDraw::PersistentQuad(const SHVec4& color, const SHVec3& pt1, const SHVec3& pt2, const SHVec3& pt3, const SHVec3& pt4) { - //dbgDrawSys->DrawPersistentQuad(color, pt1, pt2, pt3, pt4); + dbgDrawSys->DrawPersistentQuad(pt1, pt2, pt3, pt4, color); } - void SHDebugDraw::PersistentPoly(const SHVec4& color, std::initializer_list pointList) + void SHDebugDraw::PersistentLineLoop(const SHVec4& color, std::initializer_list pointList) { - //dbgDrawSys->DrawPersistentPoly(color, pointList); + dbgDrawSys->DrawPersistentLineLoop(pointList, color); + } + + void SHDebugDraw::PersistentCube(const SHMatrix& mat, const SHVec4& color) + { + dbgDrawSys->DrawPersistentCube(mat, color); } - void SHDebugDraw::PersistentCube(const SHVec4& color, const SHVec3& pos, const SHVec3& size) + void SHDebugDraw::PersistentSphere(const SHMatrix& mat, const SHVec4& color) { - //dbgDrawSys->DrawPersistentCube(color, pos, size); + dbgDrawSys->DrawPersistentSphere(mat, color); } - void SHDebugDraw::PersistentSphere(const SHVec4& color, const SHVec3& pos, double radius) + void SHDebugDraw::PersistentWireCube(const SHMatrix& mat, const SHVec4& color) { - //dbgDrawSys->DrawPersistentSphere(color, pos, radius); + dbgDrawSys->DrawPersistentWireCube(mat, color); + } + + void SHDebugDraw::PersistentWireSphere(const SHMatrix& mat, const SHVec4& color) + { + dbgDrawSys->DrawPersistentWireSphere(mat, color); } void SHDebugDraw::ClearPersistentDraws() diff --git a/SHADE_Engine/src/Tools/SHDebugDraw.h b/SHADE_Engine/src/Tools/SHDebugDraw.h index f3890e17..e213dc45 100644 --- a/SHADE_Engine/src/Tools/SHDebugDraw.h +++ b/SHADE_Engine/src/Tools/SHDebugDraw.h @@ -77,23 +77,13 @@ namespace SHADE /// /// Colour of the polygon. /// List of points for the polygon. - static void Poly(const SHVec4& color, std::initializer_list pointList); - /// - /// Renders a wireframe cube centered around the position specified in world space. - /// - /// Colour of the cube. - /// Position where the cube wil be centered at. - /// Size of the rendered cube. - static void Cube(const SHVec4& color, const SHVec3& pos, const SHVec3& size); - /// - /// Renders a wireframe sphere centered around the position specified in world space. - /// - /// Colour of the sphere. - /// Position where the sphere wil be centered at. - /// Size of the rendered sphere. - static void Sphere(const SHVec4& color, const SHVec3& pos, double radius); - + static void LineLoop(const SHVec4& color, std::initializer_list pointList); + static void Cube(const SHMatrix& mat, const SHVec4& color); + static void Sphere(const SHMatrix& mat, const SHVec4& color); static void WireCube(const SHMatrix& mat, const SHVec4& color); + static void WireCube(const SHVec3& center, const SHVec3& scale, const SHVec4& color); + static void WireSphere(const SHMatrix& mat, const SHVec4& color); + static void WireSphere(const SHVec3& center, const SHVec3& scale, const SHVec4& color); /*---------------------------------------------------------------------------------*/ /* Persistent Draw Functions */ @@ -131,23 +121,11 @@ namespace SHADE /// /// Colour of the polygon. /// List of points for the polygon. - static void PersistentPoly(const SHVec4& color, std::initializer_list pointList); - /// - /// Renders a wireframe cube centered around the position specified in world space - /// that will persist until ClearPersistentDraws() is called. - /// - /// Colour of the cube. - /// Position where the cube wil be centered at. - /// Size of the rendered cube. - static void PersistentCube(const SHVec4& color, const SHVec3& pos, const SHVec3& size); - /// - /// Renders a wireframe sphere centered around the position specified in world space - /// that will persist until ClearPersistentDraws() is called. - /// - /// Colour of the sphere. - /// Position where the sphere wil be centered at. - /// Size of the rendered sphere. - static void PersistentSphere(const SHVec4& color, const SHVec3& pos, double radius); + static void PersistentLineLoop(const SHVec4& color, std::initializer_list pointList); + static void PersistentCube(const SHMatrix& mat, const SHVec4& color); + static void PersistentSphere(const SHMatrix& mat, const SHVec4& color); + static void PersistentWireCube(const SHMatrix& mat, const SHVec4& color); + static void PersistentWireSphere(const SHMatrix& mat, const SHVec4& color); /// /// Clears any persistent drawn debug primitives. /// diff --git a/SHADE_Managed/src/Utility/Gizmos.cxx b/SHADE_Managed/src/Utility/Gizmos.cxx index 21636a5d..fe29e2ff 100644 --- a/SHADE_Managed/src/Utility/Gizmos.cxx +++ b/SHADE_Managed/src/Utility/Gizmos.cxx @@ -54,7 +54,7 @@ namespace SHADE void Gizmos::DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color) { - SHDebugDraw::Cube(Convert::ToNative(color), Convert::ToNative(center), Convert::ToNative(extents)); + SHDebugDraw::WireCube(Convert::ToNative(center), Convert::ToNative(extents), Convert::ToNative(color)); } void Gizmos::DrawWireSphere(Vector3 center, float radius) @@ -64,6 +64,6 @@ namespace SHADE void Gizmos::DrawWireSphere(Vector3 center, float radius, SHADE::Color color) { - SHDebugDraw::Sphere(Convert::ToNative(color), Convert::ToNative(center), radius); + SHDebugDraw::WireSphere(Convert::ToNative(center), SHVec3(radius, radius, radius), Convert::ToNative(color)); } }