Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
DebugDraw.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <glm/mat4x4.hpp>
5#include <glm/vec3.hpp>
6#include <glm/vec4.hpp>
7#include <vector>
8
9namespace Engine::Rendering
10{
11 class RenderProcess;
12} // namespace Engine::Rendering
13
15{
16
21 {
22 glm::vec3 position; // 12 bytes
23 glm::vec4 color; // 16 bytes
24 }; // Total: 28 bytes per vertex
25
29 namespace Colors
30 {
31 constexpr glm::vec4 Red{ 1.0f, 0.0f, 0.0f, 1.0f };
32 constexpr glm::vec4 Green{ 0.0f, 1.0f, 0.0f, 1.0f };
33 constexpr glm::vec4 Blue{ 0.0f, 0.0f, 1.0f, 1.0f };
34 constexpr glm::vec4 Yellow{ 1.0f, 1.0f, 0.0f, 1.0f };
35 constexpr glm::vec4 Cyan{ 0.0f, 1.0f, 1.0f, 1.0f };
36 constexpr glm::vec4 Magenta{ 1.0f, 0.0f, 1.0f, 1.0f };
37 constexpr glm::vec4 White{ 1.0f, 1.0f, 1.0f, 1.0f };
38 constexpr glm::vec4 Orange{ 1.0f, 0.5f, 0.0f, 1.0f };
39 } // namespace DebugColors
40
53 class Draw
54 {
55 public:
60 static void setEnabled( bool enabled );
61
66 static bool isEnabled();
67
68 // ========================================================================
69 // Drawing Primitives
70 // ========================================================================
71
78 static void line(
79 const glm::vec3 & start,
80 const glm::vec3 & end,
81 const glm::vec4 & color = Colors::White
82 );
83
91 static void arrow(
92 const glm::vec3 & origin,
93 const glm::vec3 & direction,
94 const glm::vec4 & color = Colors::White,
95 float headSize = 0.1f
96 );
97
105 static void vector(
106 const glm::vec3 & origin,
107 const glm::vec3 & vec,
108 const glm::vec4 & color = Colors::White,
109 float scale = 1.0f
110 );
111
117 static void axes( const glm::vec3 & origin, float size = 1.0f );
118
125 static void point(
126 const glm::vec3 & position,
127 float size = 0.05f,
128 const glm::vec4 & color = Colors::White
129 );
130
137 static void
138 box( const glm::vec3 & center,
139 const glm::vec3 & halfExtents,
140 const glm::vec4 & color = Colors::Green );
141
148 static void
149 box( const glm::mat4 & transform,
150 const glm::vec3 & halfExtents,
151 const glm::vec4 & color = Colors::Green );
152
160 static void sphere(
161 const glm::vec3 & center,
162 float radius,
163 const glm::vec4 & color = Colors::Green,
164 int segments = 16
165 );
166
175 static void capsule(
176 const glm::mat4 & transform,
177 float radius,
178 float height,
179 const glm::vec4 & color = Colors::Green,
180 int segments = 16
181 );
182
189 static void convexHull(
190 const std::vector<glm::vec3> & vertices,
191 const glm::mat4 & transform = glm::mat4( 1.0f ),
192 const glm::vec4 & color = Colors::Cyan
193 );
194
202 static void triangleMesh(
203 const std::vector<glm::vec3> & vertices,
204 const std::vector<uint32_t> & indices,
205 const glm::mat4 & transform = glm::mat4( 1.0f ),
206 const glm::vec4 & color = Colors::Cyan
207 );
208
209 // ========================================================================
210 // Internal API (called by Renderer)
211 // ========================================================================
212
217 static void beginFrame( Engine::Rendering::RenderProcess * renderProcess );
218
223 static void setCurrentRenderProcess( Engine::Rendering::RenderProcess * renderProcess );
224
229 static uint32_t getLineCount();
230
231 static uint32_t getLastLineCount();
232
233 static uint32_t getLineCapacity();
234 private:
238 static void addLine( const glm::vec3 & start, const glm::vec3 & end, const glm::vec4 & color );
239
240 static bool enabled_;
241 static Engine::Rendering::RenderProcess * currentRenderProcess_;
242 };
243} // namespace Engine::Core::Debug
244
245
Static API for immediate-mode debug line drawing.
Definition DebugDraw.h:54
static void convexHull(const std::vector< glm::vec3 > &vertices, const glm::mat4 &transform=glm::mat4(1.0f), const glm::vec4 &color=Colors::Cyan)
Draw a convex hull from vertices.
static void axes(const glm::vec3 &origin, float size=1.0f)
Draw coordinate axes at a position (RGB = XYZ)
static uint32_t getLastLineCount()
static void addLine(const glm::vec3 &start, const glm::vec3 &end, const glm::vec4 &color)
Internal: add a single line to the buffer.
static void vector(const glm::vec3 &origin, const glm::vec3 &vec, const glm::vec4 &color=Colors::White, float scale=1.0f)
Draw a vector from origin (alias for arrow with scale)
static void box(const glm::mat4 &transform, const glm::vec3 &halfExtents, const glm::vec4 &color=Colors::Green)
Draw a wireframe box with transform.
static void setCurrentRenderProcess(Engine::Rendering::RenderProcess *renderProcess)
Set the current render process for line accumulation.
static Engine::Rendering::RenderProcess * currentRenderProcess_
Definition DebugDraw.h:241
static void arrow(const glm::vec3 &origin, const glm::vec3 &direction, const glm::vec4 &color=Colors::White, float headSize=0.1f)
Draw an arrow from origin in the given direction.
static void point(const glm::vec3 &position, float size=0.05f, const glm::vec4 &color=Colors::White)
Draw a point as a small cross.
static bool isEnabled()
Check if debug drawing is currently enabled.
static void line(const glm::vec3 &start, const glm::vec3 &end, const glm::vec4 &color=Colors::White)
Draw a line between two points.
static void setEnabled(bool enabled)
Enable or disable debug drawing globally.
static void box(const glm::vec3 &center, const glm::vec3 &halfExtents, const glm::vec4 &color=Colors::Green)
Draw a wireframe box.
static void capsule(const glm::mat4 &transform, float radius, float height, const glm::vec4 &color=Colors::Green, int segments=16)
Draw a wireframe capsule (cylinder with hemispherical ends)
static void beginFrame(Engine::Rendering::RenderProcess *renderProcess)
Called at frame start to clear previous frame's lines.
static uint32_t getLineCapacity()
static void sphere(const glm::vec3 &center, float radius, const glm::vec4 &color=Colors::Green, int segments=16)
Draw a wireframe sphere (approximated with circles)
static uint32_t getLineCount()
Get the number of lines in the current frame.
static void triangleMesh(const std::vector< glm::vec3 > &vertices, const std::vector< uint32_t > &indices, const glm::mat4 &transform=glm::mat4(1.0f), const glm::vec4 &color=Colors::Cyan)
Draw a triangle mesh wireframe.
Predefined colors for debug visualization.
Definition DebugDraw.h:30
constexpr glm::vec4 Orange
Definition DebugDraw.h:38
constexpr glm::vec4 Magenta
Definition DebugDraw.h:36
constexpr glm::vec4 Blue
Definition DebugDraw.h:33
constexpr glm::vec4 Cyan
Definition DebugDraw.h:35
constexpr glm::vec4 White
Definition DebugDraw.h:37
constexpr glm::vec4 Green
Definition DebugDraw.h:32
constexpr glm::vec4 Red
Definition DebugDraw.h:31
constexpr glm::vec4 Yellow
Definition DebugDraw.h:34
Vertex data for debug line rendering.
Definition DebugDraw.h:21