engine/include/system_mesh_render.h

44 lines
1.1 KiB
C
Raw Normal View History

2023-11-05 01:04:05 +00:00
#pragma once
#include <glm/mat4x4.hpp>
2023-09-19 07:40:45 +00:00
#include "ecs.h"
#include "scene.h"
#include "gfx.h"
namespace engine {
2023-08-31 13:18:42 +00:00
struct RenderListEntry {
2024-03-31 10:11:22 +00:00
const gfx::Pipeline* pipeline;
const gfx::Buffer* vertex_buffer;
const gfx::Buffer* index_buffer;
const gfx::DescriptorSet* material_set;
glm::mat4 model_matrix;
uint32_t index_count;
};
2023-08-31 13:18:42 +00:00
using RenderList = std::vector<RenderListEntry>;
2023-08-31 09:51:12 +00:00
class MeshRenderSystem : public System {
2024-03-31 10:11:22 +00:00
public:
MeshRenderSystem(Scene* scene);
~MeshRenderSystem();
2024-03-31 10:11:22 +00:00
void RebuildStaticRenderList();
const RenderList* GetStaticRenderList() const { return &static_render_list_; }
const RenderList* GetDynamicRenderList() const { return &dynamic_render_list_; }
2024-03-31 10:11:22 +00:00
void OnComponentInsert(Entity entity) override;
void OnUpdate(float ts) override;
2024-03-31 10:11:22 +00:00
private:
RenderList static_render_list_;
RenderList dynamic_render_list_;
bool list_needs_rebuild_ = false;
2023-08-31 13:18:42 +00:00
2024-03-31 10:11:22 +00:00
// with_static_entities = false, build list of dynamic meshes
// with_static_entities = true, build list of static meshes
void BuildRenderList(RenderList& render_list, bool with_static_entities);
};
2024-03-31 10:11:22 +00:00
} // namespace engine