Radium Engine  1.5.20
Loading...
Searching...
No Matches
SystemDisplay.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
9
10// define RA_DISABLE_DEBUG_DISPLAY
11
12#include <Core/Utils/Color.hpp>
13#include <Core/Utils/Singleton.hpp>
14
15#include <Engine/Scene/Component.hpp>
16#include <Engine/Scene/Entity.hpp>
17
18#ifndef RA_DISABLE_DEBUG_DISPLAY
19# include <Engine/Data/DrawPrimitives.hpp>
20#endif
21
22namespace Ra {
23namespace Engine {
24namespace Scene {
25
26#ifndef RA_DISABLE_DEBUG_DISPLAY
27
29class RA_ENGINE_API DebugComponent : public Component
30{
31 public:
32 explicit DebugComponent( Entity* entity ) : Component( "Debug", entity ) {}
33
34 void initialize() override {};
35
37 Rendering::RenderObject* getRenderObject( Core::Utils::Index idx );
38};
39
40#endif
41
43class RA_ENGINE_API UiComponent : public Component
44{
45 public:
46 explicit UiComponent( Entity* entity ) : Component( "UI", entity ) {}
47
48 void initialize() override {}
49};
50
53class RA_ENGINE_API SystemEntity : public Entity
54{
55 RA_SINGLETON_INTERFACE( SystemEntity );
56
57 public:
59
60 ~SystemEntity() override = default;
61
62#ifndef RA_DISABLE_DEBUG_DISPLAY
64 static DebugComponent* dbgCmp();
65
66#endif
68 static UiComponent* uiCmp();
69};
70
71} // namespace Scene
72} // namespace Engine
73} // namespace Ra
74
75#ifndef RA_DISABLE_DEBUG_DISPLAY
77# define RA_DISPLAY_POINT( p, color, scale ) \
78 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
79 Ra::Engine::Data::DrawPrimitives::Primitive( \
80 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
81 Ra::Engine::Data::DrawPrimitives::Point( p, color, scale ) ) )
82
83# define RA_DISPLAY_VECTOR( p, v, color ) \
84 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
85 Ra::Engine::Data::DrawPrimitives::Primitive( \
86 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
87 Ra::Engine::Data::DrawPrimitives::Vector( p, v, color ) ) )
88
89# define RA_DISPLAY_RAY( r, color ) \
90 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
91 Ra::Engine::Data::DrawPrimitives::Primitive( \
92 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
93 Ra::Engine::Data::DrawPrimitives::Ray( r, color ) ) )
94
95# define RA_DISPLAY_CIRCLE( c, n, r, color ) \
96 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
97 Ra::Engine::Data::DrawPrimitives::Primitive( \
98 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
99 Ra::Engine::Data::DrawPrimitives::Circle( c, n, r, 20, color ) ) )
100
101# define RA_DISPLAY_TRIANGLE( a, b, c, color ) \
102 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
103 Ra::Engine::Data::DrawPrimitives::Primitive( \
104 Ra::Engine::SystemEntity::dbgCmp(), \
105 Ra::Engine::Data::DrawPrimitives::Triangle( a, b, c, color ) ) )
106
107# define RA_DISPLAY_NORMAL( p, n, color, scale ) \
108 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
109 Ra::Engine::Scene::DrawPrimitives::Primitive( \
110 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
111 Ra::Engine::Scene::DrawPrimitives::Normal( p, n, color, scale ) ) )
112
113# define RA_DISPLAY_FRAME( t, scale ) \
114 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
115 Ra::Engine::Data::DrawPrimitives::Primitive( \
116 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
117 Ra::Engine::Data::DrawPrimitives::Frame( t, scale ) ) )
118
119# define RA_DISPLAY_AABB( a, color ) \
120 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
121 Ra::Engine::Data::DrawPrimitives::Primitive( \
122 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
123 Ra::Engine::Data::DrawPrimitives::AABB( a, color ) ) )
124
125# define RA_DISPLAY_OBB( a, color ) \
126 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
127 Ra::Engine::Data::DrawPrimitives::Primitive( \
128 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
129 Ra::Engine::Data::DrawPrimitives::OBB( a, color ) ) )
130
131# define RA_DISPLAY_SPHERE( c, r, color ) \
132 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
133 Ra::Engine::Data::DrawPrimitives::Primitive( \
134 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
135 Ra::Engine::Data::DrawPrimitives::Sphere( c, r, color ) ) )
136
137# define RA_DISPLAY_CAPSULE( p1, p2, r, color ) \
138 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
139 Ra::Engine::Data::DrawPrimitives::Primitive( \
140 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
141 Ra::Engine::Data::DrawPrimitives::Capsule( p1, p2, r, color ) ) )
142
143# define RA_DISPLAY_LINE( a, b, color ) \
144 Ra::Engine::Scene::SystemEntity::dbgCmp()->addRenderObject( \
145 Ra::Engine::Data::DrawPrimitives::Primitive( \
146 Ra::Engine::Scene::SystemEntity::dbgCmp(), \
147 Ra::Engine::Data::DrawPrimitives::Line( a, b, color ) ) )
148
149# define RA_CLEAR_DEBUG_DISPLAY() \
150 { \
151 auto cmp = Ra::Engine::Scene::SystemEntity::dbgCmp(); \
152 while ( cmp->m_renderObjects.size() ) { \
153 cmp->removeRenderObject( cmp->m_renderObjects[0] ); \
154 } \
155 }
156
157#else // if debug display is disabled
158
159# define RA_DISPLAY_POINT( p, color, scale ) // Nothing
160# define RA_DISPLAY_VECTOR( p, v, color ) // ...
161# define RA_DISPLAY_RAY( r, color ) // ...
162# define RA_DISPLAY_CIRCLE( c, n, r, color ) // ...
163# define RA_DISPLAY_TRIANGLE( a, b, c, color ) // ...
164# define RA_DISPLAY_NORMAL( p, n, color, scale ) // ...
165# define RA_DISPLAY_FRAME( t, scale ) // ...
166# define RA_DISPLAY_AABB( a, color ) // ...
167# define RA_DISPLAY_OBB( a, color ) // ...
168# define RA_DISPLAY_SPHERE( c, r, color ) // ...
169# define RA_DISPLAY_CAPSULE( p1, p2, r, color ) // ...
170# define RA_DISPLAY_LINE( a, b, color ) // ...
171# define RA_CLEAR_DEBUG_DISPLAY() // ...
172
173#endif
A component is an element that can be updated by a system. It is also linked to some other components...
Definition Component.hpp:31
Component for debug drawing.
void initialize() override
Pure virtual method to be overridden by any component. When this method is called you are guaranteed ...
An entity is an scene element. It ties together components with a transform.
Definition Entity.hpp:23
Component for UI drawing.
void initialize() override
Pure virtual method to be overridden by any component. When this method is called you are guaranteed ...
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3