66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "opengl/handles/shader_program_handle.hpp"
|
|
#include "rendering/batches/mesh_batch.hpp"
|
|
#include "assets/components/mesh_vertex_components.hpp"
|
|
#include "assets/components/material_components.hpp"
|
|
#include "opengl/handles/material_handle.hpp"
|
|
#include <span>
|
|
|
|
#include "geometry/aabb.hpp"
|
|
#include "rendering/modes/mesh_modes.hpp"
|
|
#include "rendering/shader_program_lookups/mesh_lookup.hpp"
|
|
#include "scene/lighting_setup.hpp"
|
|
|
|
namespace rendering
|
|
{
|
|
class mesh_batch_renderer
|
|
{
|
|
public:
|
|
using batch_components_type = std::pair<
|
|
components::mesh_vertex::flags,
|
|
material_component::flags
|
|
>;
|
|
using batch_type = mesh_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 mesh_batch_renderer(int render_mode_count);
|
|
|
|
std::optional<id_type> add(
|
|
const batch_components_type& batch_component,
|
|
const zgl::mesh_handle& mesh,
|
|
const aabb& bounding_box,
|
|
const zgl::model_matrix_handle& transform,
|
|
const zgl::material_handle& material,
|
|
const shader_program_lookups::mesh_lookup& shader_program_lookup
|
|
);
|
|
|
|
std::optional<aabb> bounding_box(id_type);
|
|
|
|
bool remove(id_type mesh_id);
|
|
|
|
void render(
|
|
modes::mesh render_mode,
|
|
const glm::mat4& vp_matrix,
|
|
const glm::mat4& view_matrix,
|
|
const glm::vec3& view_pos,
|
|
const lighting_setup& lights
|
|
);
|
|
|
|
protected:
|
|
[[nodiscard]] std::pair<std::size_t, bool> lookup_batch(const batch_components_type& batch_components) 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 };
|
|
};
|
|
}
|