2#ifndef LIBSBX_SCENES_SCENE_MODULE_HPP_
3#define LIBSBX_SCENES_SCENE_MODULE_HPP_
6#include <unordered_map>
10#include <libsbx/memory/tracking_allocator.hpp>
12#include <libsbx/math/vector4.hpp>
15#include <libsbx/utility/hashed_string.hpp>
17#include <libsbx/core/module.hpp>
19#include <libsbx/scenes/asset_registry.hpp>
20#include <libsbx/scenes/component_io.hpp>
21#include <libsbx/scenes/asset_io.hpp>
22#include <libsbx/scenes/scene.hpp>
24namespace sbx::scenes {
28 inline static const auto is_registered = register_module(stage::normal);
41 auto update() ->
void override;
43 auto create_scene(
const std::string& name =
"Scene") ->
scenes::scene&;
52 return *_active_scene;
55 auto active_scene() const -> const scenes::
scene& {
56 return *_active_scene;
60 if (
auto entry = _scenes.find(name); entry != _scenes.end()) {
61 return entry->second.get();
67 auto has_active_scene() const ->
bool {
68 return _active_scene !=
nullptr;
71 auto scene_count() const -> std::
size_t {
72 return _scenes.size();
75 auto save_scene(
const std::filesystem::path& path) ->
void {
77 _active_scene->save(path);
81 auto set_scene_viewport(std::string name) ->
void {
82 _scene_viewport = std::move(name);
85 auto scene_viewport() const -> const std::
string& {
86 return _scene_viewport;
89 auto asset_registry() -> scenes::asset_registry& {
90 return _asset_registry;
93 auto asset_registry() const -> const scenes::asset_registry& {
94 return _asset_registry;
97 auto get_component_io_registry() -> component_io_registry& {
98 return _component_io_registry;
101 auto get_asset_io_registry() -> asset_io_registry& {
102 return _asset_io_registry;
105 auto get_component_io(
const std::uint32_t
id) -> scenes::component_io& {
106 return _component_io_registry.get(
id);
109 auto has_component_io(
const std::uint32_t
id)
const ->
bool {
110 return _component_io_registry.has(
id);
113 auto debug_lines() const -> const std::vector<line>&;
115 auto clear_debug_lines() ->
void;
117 auto add_debug_line(const sbx::math::vector3& start, const sbx::math::vector3& end, const sbx::math::color& color) ->
void;
119 auto add_coordinate_arrows(const math::matrix4x4& transform, std::float_t length = 2.0f) ->
void;
121 auto add_debug_plane(const sbx::math::vector3& origin, const sbx::math::vector3& v1, const sbx::math::vector3& v2, std::uint32_t n1, std::uint32_t n2, std::float_t s1, std::float_t s2, const sbx::math::color& color, const sbx::math::color& outline) ->
void;
123 auto add_debug_volume(const math::matrix4x4& matrix, const math::volume& volume, const sbx::math::color& color) ->
void;
125 auto add_debug_box(const math::matrix4x4& matrix, const math::volume& volume, const sbx::math::color& color) ->
void;
127 auto add_debug_circle(const math::vector3& center, const std::float_t radius, const math::vector3& normal, const math::color& color, const std::uint32_t segments = 32) ->
void;
129 auto add_debug_sphere(const math::vector3& center, const std::float_t radius, const math::color& color, const std::uint32_t segments = 32) ->
void;
131 auto add_debug_frustum(const math::matrix4x4& view, const math::matrix4x4& projection, const sbx::math::color& color) ->
void;
135 scenes::asset_registry _asset_registry;
136 scenes::component_io_registry _component_io_registry;
137 scenes::asset_io_registry _asset_io_registry;
139 std::unordered_map<utility::hashed_string, std::unique_ptr<scenes::scene>> _scenes;
140 memory::observer_ptr<scenes::scene> _active_scene{
nullptr};
142 std::vector<line> _debug_lines{};
144 std::string _scene_viewport{std::string{graphics::viewport::window_name}};
Definition: module.hpp:92
Definition: vector4.hpp:24
RGBA color value type.
Definition: color.hpp:48
A non-owning pointer that can be used to observe the value of a pointer.
Definition: observer_ptr.hpp:29
Definition: scenes_module.hpp:26
Definition: hashed_string.hpp:17
RGBA color representation and utilities.
Definition: scenes_module.hpp:32