8#include <entt/entity/registry.hpp>
9#include <entt/signal/sigh.hpp>
42struct DebugMeshComponent;
51 entt::registry &m_registry;
55 entt::dense_map<entt::hashed_string::hash_type,
56 std::unique_ptr<IDebugSubSystem>>
58 std::unordered_map<DebugMeshType, Mesh> m_sharedMeshes;
59 inline static const std::array<Float4, 3> m_triadColors = {
65 void initializeSharedMeshes();
75 return m_sharedMeshes.at(type);
84 const Device &
device() const noexcept {
return m_renderer.device; }
85 entt::registry &
registry() {
return m_registry; }
86 const entt::registry &
registry()
const {
return m_registry; }
89 template <std::derived_from<IDebugSubSystem> T,
typename... Args>
90 T &
addSystem(entt::hashed_string::hash_type name, Args &&...args) {
91 auto sys = std::make_unique<T>(*
this, std::forward<Args>(args)...);
92 auto [it, flag] = m_subsystems.emplace(name, std::move(sys));
93 return static_cast<T &
>(*it->second);
98 template <std::derived_from<IDebugSubSystem> T>
100 if (
auto it = m_subsystems.find(name); it != m_subsystems.cend()) {
101 return dynamic_cast<T *
>(it->second.get());
107 template <std::derived_from<IDebugSubSystem> T>
109 auto *p = m_subsystems.at(name).get();
110 return dynamic_cast<T &
>(*p);
114 std::tuple<entt::entity, DebugMeshComponent &>
119 std::tuple<entt::entity, DebugMeshComponent &>
123 std::tuple<entt::entity, DebugMeshComponent &>
127 for (
auto [hash, system] : m_subsystems) {
138static_assert(Scene<DebugScene>);
150 bool enable_pipeline_switch =
true);
Definition CommandBuffer.h:16
Scene for organizing debug entities and render systems.
Definition DebugScene.h:50
T * getSystem(entt::hashed_string::hash_type name)
Get a subsystem by key (a hashed string)
Definition DebugScene.h:99
entt::registry & registry()
Definition DebugScene.h:85
DebugScene & operator=(const DebugScene &)=delete
T & addSystem(entt::hashed_string::hash_type name, Args &&...args)
Add a subsystem (IDebugSubSystem) to the scene.
Definition DebugScene.h:90
const Mesh & getMesh(DebugMeshType type) const
Definition DebugScene.h:74
const entt::registry & registry() const
Definition DebugScene.h:86
DebugScene(entt::registry ®istry, const RenderContext &renderer)
void render(CommandBuffer &cmdBuf, const Camera &camera) const
std::tuple< entt::entity, DebugMeshComponent & > addTriad(const Float3 &scale=Float3::Ones())
Just the basic 3D triad.
DebugScene(DebugScene &&other)
std::tuple< entt::entity, DebugMeshComponent & > addArrow(const Float4 &color=0xEA2502FF_rgbaf)
Add an arrow debug entity.
@ TRANSFORM_SLOT
Definition DebugScene.h:70
T & tryGetSystem(entt::hashed_string::hash_type name)
Definition DebugScene.h:108
std::tuple< entt::entity, DebugMeshComponent & > addLineGrid(const Float4 &color=0xE0A236FF_rgbaf)
Add a basic line grid.
void update()
Definition DebugScene.h:126
@ COLOR_SLOT
Definition DebugScene.h:71
DebugScene & operator=(DebugScene &&)=delete
DebugScene(const DebugScene &)=delete
~DebugScene()
Definition DebugScene.h:136
const Device & device() const noexcept
Definition DebugScene.h:84
Class representing a graphics pipeline.
Definition GraphicsPipeline.h:15
This class defines the layout of a mesh's vertices.
Definition MeshLayout.h:122
Handle class for meshes (vertex buffers and an optional index buffer) on the GPU.
Definition Mesh.h:57
GUI utilities.
Definition DebugScene.h:148
void addDebugMesh(DebugMeshComponent &dmc, bool enable_pipeline_switch=true)
Eigen::Vector3f Float3
Definition math_types.h:8
DebugPipelines
Definition DebugScene.h:13
@ TRIANGLE_FILL
Definition DebugScene.h:14
@ TRIANGLE_LINE
Definition DebugScene.h:15
Eigen::Vector4f Float4
Definition math_types.h:9
DebugMeshType
Definition DebugScene.h:20
@ TRIAD
Definition DebugScene.h:21
@ GRID
Definition DebugScene.h:22
@ ARROW
Definition DebugScene.h:23
The main way of using a camera to render things.
Definition Camera.h:19
Definition DebugScene.h:140
std::vector< Float4 > colors
Definition DebugScene.h:143
DebugMeshType meshType
Definition DebugScene.h:142
DebugPipelines pipeline_type
Definition DebugScene.h:141
Float3 scale
Definition DebugScene.h:145
bool enable
Definition DebugScene.h:144
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
IDebugSubSystem(DebugScene &scene)
Definition DebugScene.h:36
DebugScene & m_scene
Definition DebugScene.h:35
virtual ~IDebugSubSystem()=default
The RenderContext class provides a rendering context for a graphical application.
Definition RenderContext.h:36