diff --git a/include/Nazara/Renderer/DebugDrawer.hpp b/include/Nazara/Renderer/DebugDrawer.hpp index b8e272d5d..fc632765a 100644 --- a/include/Nazara/Renderer/DebugDrawer.hpp +++ b/include/Nazara/Renderer/DebugDrawer.hpp @@ -29,6 +29,8 @@ class NAZARA_API NzDebugDrawer static void Draw(const NzSkeleton* skeleton); static void DrawBinormals(const NzStaticMesh* subMesh); static void DrawCone(const NzVector3f& origin, const NzQuaternionf& rotation, float angle, float length); + static void DrawLine(const NzVector3f& p1, const NzVector3f& p2); + static void DrawPoints(const NzVector3f* ptr, unsigned int pointCount); static void DrawNormals(const NzStaticMesh* subMesh); static void DrawTangents(const NzStaticMesh* subMesh); diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 3e3f1490b..1a2e96ee7 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -486,6 +486,51 @@ void NzDebugDrawer::DrawCone(const NzVector3f& origin, const NzQuaternionf& rota NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 16); } +void NzDebugDrawer::DrawLine(const NzVector3f& p1, const NzVector3f& p2) +{ + if (!s_initialized && !Initialize()) + { + NazaraError("Failed to initialize Debug Drawer"); + return; + } + + NzVertexStruct_XYZ buffer[2]; + buffer[0].position = p1; + buffer[1].position = p2; + + s_vertexBuffer.Fill(&buffer[0], 0, 2); + + NzRenderer::SetRenderStates(s_renderStates); + NzRenderer::SetShader(s_shader); + NzRenderer::SetVertexBuffer(&s_vertexBuffer); + + s_shader->SendColor(s_colorLocation, s_primaryColor); + NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 2); +} + +void NzDebugDrawer::DrawPoints(const NzVector3f* ptr, unsigned int pointCount) +{ + static_assert(sizeof(NzVertexStruct_XYZ) == sizeof(NzVector3f), "NzVertexStruct_XYZ is no longer equal to NzVector3f, please rewrite this"); + + if (!s_initialized && !Initialize()) + { + NazaraError("Failed to initialize Debug Drawer"); + return; + } + + if (pointCount > 0) + { + s_vertexBuffer.Fill(ptr, 0, pointCount); + + NzRenderer::SetRenderStates(s_renderStates); + NzRenderer::SetShader(s_shader); + NzRenderer::SetVertexBuffer(&s_vertexBuffer); + + s_shader->SendColor(s_colorLocation, s_primaryColor); + NzRenderer::DrawPrimitives(nzPrimitiveMode_PointList, 0, pointCount); + } +} + void NzDebugDrawer::DrawNormals(const NzStaticMesh* subMesh) { if (!s_initialized && !Initialize())