2#ifndef LIBSBX_GIZMOS_MESH_SUBRENDERER_HPP_
3#define LIBSBX_GIZMOS_MESH_SUBRENDERER_HPP_
6#include <unordered_set>
10#include <libsbx/utility/logger.hpp>
13#include <libsbx/math/vector3.hpp>
14#include <libsbx/math/matrix4x4.hpp>
16#include <libsbx/graphics/graphics_module.hpp>
17#include <libsbx/graphics/subrenderer.hpp>
18#include <libsbx/graphics/pipeline/pipeline.hpp>
19#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
20#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
21#include <libsbx/graphics/buffers/uniform_handler.hpp>
22#include <libsbx/graphics/buffers/storage_handler.hpp>
23#include <libsbx/graphics/images/image2d.hpp>
24#include <libsbx/graphics/images/separate_image2d_array.hpp>
25#include <libsbx/graphics/images/sampler_state.hpp>
27#include <libsbx/assets/assets_module.hpp>
29#include <libsbx/scenes/scenes_module.hpp>
30#include <libsbx/scenes/scene.hpp>
31#include <libsbx/scenes/node.hpp>
32#include <libsbx/scenes/components/static_mesh.hpp>
33#include <libsbx/scenes/components/gizmo.hpp>
34#include <libsbx/scenes/components/id.hpp>
35#include <libsbx/scenes/components/camera.hpp>
36#include <libsbx/scenes/components/tag.hpp>
37#include <libsbx/scenes/components/point_light.hpp>
39#include <libsbx/models/mesh.hpp>
41#include <libsbx/gizmos/pipeline.hpp>
43namespace sbx::gizmos {
53 inline static constexpr auto max_point_lights = std::size_t{16};
57 gizmos_subrenderer(
const std::vector<graphics::attachment_description>& attachments,
const std::filesystem::path& path,
const std::string& depth_image)
59 _pipeline{path, attachments},
60 _depth_image{depth_image} { }
138 auto _submit_mesh(
const scenes::node
node) ->
void {
139 auto& scenes_module = core::engine::get_module<scenes::scenes_module>();
140 auto& scene = scenes_module.active_scene();
141 auto& environment = scene.environment();
142 auto& graph = scene.graph();
146 const auto key = mesh_key{gizmo.mesh_id(), gizmo.submesh_index(), gizmo.texture_id()};
148 _used_uniforms.insert(key);
150 auto model = graph.world_transform(
node);
151 auto normal = math::matrix4x4::transposed(math::matrix4x4::inverted(model));
153 _static_meshes[key].push_back(per_mesh_data{std::move(model), std::move(normal), gizmo.tint()});
156 struct uniform_data {
163 std::uint32_t submesh_index;
167 struct per_mesh_data {
173 struct mesh_key_hash {
174 auto operator()(
const mesh_key& key)
const noexcept -> std::size_t {
175 auto seed = std::size_t{0};
177 utility::hash_combine(seed, key.mesh_id, key.submesh_index);
183 struct mesh_key_equal {
184 auto operator()(
const mesh_key& lhs,
const mesh_key& rhs)
const noexcept ->
bool {
185 return lhs.mesh_id == rhs.mesh_id && lhs.submesh_index == rhs.submesh_index;
191 std::string _depth_image;
193 std::unordered_map<mesh_key, uniform_data, mesh_key_hash, mesh_key_equal> _uniform_data;
194 std::unordered_set<mesh_key, mesh_key_hash, mesh_key_equal> _used_uniforms;
196 std::unordered_map<mesh_key, std::vector<per_mesh_data>, mesh_key_hash, mesh_key_equal> _static_meshes;
Definition: gizmos_subrenderer.hpp:51
Definition: pipeline.hpp:11
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: storage_handler.hpp:17
Definition: subrenderer.hpp:14
Definition: matrix4x4.hpp:26
RGBA color value type.
Definition: color.hpp:48
RGBA color representation and utilities.