Files
Z3D/include/rendering/batch_renderers/point_cloud_batch_renderer.hpp
2024-12-22 16:58:40 +01:00

60 lines
1.6 KiB
C++

#pragma once
#include "opengl/handles/shader_program_handle.hpp"
#include "rendering/batches/point_cloud_batch.hpp"
#include "assets/components/point_cloud_vertex_components.hpp"
#include "rendering/modes/point_cloud_modes.hpp"
#include <optional>
#include "scene/lighting_setup.hpp"
#include "rendering/shader_program_lookups/point_cloud_lookup.hpp"
namespace rendering
{
class point_cloud_batch_renderer
{
public:
using batch_components_type = components::point_cloud_vertex::flags;
using batch_type = point_cloud_batch;
using batch_index_type = ztu::u32;
using batch_id_type = batch_index_type;
using id_type = std::pair<batch_id_type, batch_type::id_type>;
explicit point_cloud_batch_renderer(int render_mode_count);
std::optional<id_type> add(
batch_components_type batch_components,
const zgl::point_cloud_handle& point_cloud,
const aabb& bounding_box,
const zgl::model_matrix_handle& transform,
const shader_program_lookups::point_cloud_lookup& shader_program_lookup
);
std::optional<aabb> bounding_box(id_type id);
bool remove(id_type id);
void render(
modes::point_cloud render_mode,
const glm::mat4& vp_matrix,
const glm::vec3& camera_position,
const lighting_setup&
);
protected:
[[nodiscard]] std::pair<std::size_t, bool> lookup_batch(const batch_components_type& batch_component) const;
private:
int m_render_mode_count;
std::vector<std::pair<batch_components_type, batch_index_type>> m_component_lookup;
std::vector<batch_id_type> m_id_lookup;
std::vector<std::pair<batch_type, batch_components_type>> m_batches;
std::vector<zgl::shader_program_handle> m_shader_programs;
batch_id_type m_next_batch_id{ 0 };
};
}