System that handles rendering of mesh and grid components, managing batches and Vulkan draw commands.
More...
#include <RenderSystem.hpp>
|
| struct | pair_hash |
| | Custom hash function for std::pair<Mesh*, Material*> used in batch rendering maps. More...
|
|
| | RenderSystem (Registry ®, VulkanRenderer &renderer) |
| | Construct a new Render System object and subscribes to component add/remove events.
|
| void | update (float dt) override |
| | System update called each frame to rebuild instance data.
|
| void | drawFrame (const std::function< void(VkCommandBuffer)> &overlayPass={}) |
| | Executes the rendering pass, drawing geometry, grid, and optional GUI/overlay passes.
|
| virtual | ~System ()=default |
| | Virtual destructor.
|
| void | addEntity (Entity e) |
| | Adds an entity to the system tracking list.
|
| void | removeEntity (Entity e) |
| | Removes an entity from system tracking.
|
|
| void | checkAndAdd (Entity e) |
| | Verifies if an entity meets requirements for rendering and adds it to the tracked list.
|
| void | removeEntity (Entity e) |
| | Removes an entity from tracking when components are removed.
|
| glm::mat4 | getWorldMatrix (Entity entity, int depth=0) |
| | Computes the absolute world matrix of an entity by traversing the hierarchy.
|
| void | buildInstanceData () |
| | Rebuilds instance data by iterating over entities.
|
| glm::vec3 | getCameraPosition () |
| | Retrieves the active camera's world position.
|
| void | drawBatches () |
| | Binds pipelines, descriptor sets, and draw buffers for geometry batches.
|
| void | drawGrids () |
| | Draws all active grid overlays.
|
|
| std::vector< Entity > | entities |
| | List of entities tracked by this system.
|
System that handles rendering of mesh and grid components, managing batches and Vulkan draw commands.
◆ RenderSystem()
Construct a new Render System object and subscribes to component add/remove events.
- Parameters
-
| reg | Reference to the ECS Registry. |
| renderer | Reference to the Vulkan Renderer. |
◆ buildInstanceData()
| void RenderSystem::buildInstanceData |
( |
| ) |
|
|
inlineprivate |
Rebuilds instance data by iterating over entities.
◆ checkAndAdd()
| void RenderSystem::checkAndAdd |
( |
Entity | e | ) |
|
|
inlineprivate |
Verifies if an entity meets requirements for rendering and adds it to the tracked list.
- Parameters
-
◆ drawBatches()
| void RenderSystem::drawBatches |
( |
| ) |
|
|
inlineprivate |
Binds pipelines, descriptor sets, and draw buffers for geometry batches.
◆ drawFrame()
| void RenderSystem::drawFrame |
( |
const std::function< void(VkCommandBuffer)> & | overlayPass = {} | ) |
|
|
inline |
Executes the rendering pass, drawing geometry, grid, and optional GUI/overlay passes.
- Parameters
-
| overlayPass | Optional callback function to execute additional rendering (e.g. ImGui) during the frame. |
◆ drawGrids()
| void RenderSystem::drawGrids |
( |
| ) |
|
|
inlineprivate |
Draws all active grid overlays.
◆ getCameraPosition()
| glm::vec3 RenderSystem::getCameraPosition |
( |
| ) |
|
|
inlineprivate |
Retrieves the active camera's world position.
- Returns
- Camera position, or zero vector if none is active.
◆ getWorldMatrix()
| glm::mat4 RenderSystem::getWorldMatrix |
( |
Entity | entity, |
|
|
int | depth = 0 ) |
|
inlineprivate |
Computes the absolute world matrix of an entity by traversing the hierarchy.
◆ removeEntity()
| void RenderSystem::removeEntity |
( |
Entity | e | ) |
|
|
inlineprivate |
Removes an entity from tracking when components are removed.
- Parameters
-
◆ update()
| void RenderSystem::update |
( |
float | dt | ) |
|
|
inlineoverridevirtual |
System update called each frame to rebuild instance data.
- Parameters
-
Implements System.
◆ entities
| std::vector<Entity> RenderSystem::entities |
|
private |
List of tracked entities that have renderable components.
◆ entityToInstanceIndex
| std::unordered_map<Entity, size_t> RenderSystem::entityToInstanceIndex |
|
private |
Mapping from entity to its instance index in CPU buffers.
◆ registry
Reference to the entity registry.
◆ renderableEntities
| std::vector<Entity> RenderSystem::renderableEntities |
|
private |
Vector to track renderable entities to avoid allocation.
◆ renderer
Reference to the renderer.
The documentation for this class was generated from the following file: