3#include "RenderSystem.h"
4#include "Scene/GetBounds.h"
5#include "Scene/RayPick.h"
7#include "../../Components/Core/InstancedMeshRenderComponent.h"
9#include "Foundation/Geometry/BoundingBox.hpp"
15 class InstancedMeshRenderSystem;
22 virtual void getBounds(
Context* context, Cogs::Geometry::BoundingBox& bounds)
override;
35 const glm::mat4& worldPickMatrix,
36 const glm::mat4& rawViewProjection,
37 const glm::mat4& viewMatrix,
41 std::vector<RayPicking::RayPickHit>& hits)
override;
50 MeshRenderDataFlags flags = MeshRenderDataFlags::None;
51 uint32_t cullingIndex = NoCullingIndex;
53 uint16_t localBoundsGeneration = 0;
54 uint16_t worldBoundsGeneration = 0;
55 uint8_t meshBoundsGeneration = 0;
56 uint8_t instanceMeshBoundsGeneration = 0;
58 glm::mat4 localToWorld;
81 TaskId getTaskGroup()
const {
return geometryGroup; }
85 getLocalBounds(component) = bbox;
86 auto & data = getData<InstancedMeshRenderData>(component);
87 data.flags |= MeshRenderDataFlags::LocalBoundsOverride;
88 ++data.localBoundsGeneration;
93 return this->getData<LocalBounds>(component);
98 return this->getData<WorldBounds>(component);
103 size_t getGeneration()
const {
return generation; }
108 bool needsPost =
true;
109 size_t generation = 0;
110 TaskId geometryGroup = NoTask;
111 std::unique_ptr<InstancedMeshRenderBounds> bounds;
112 std::unique_ptr<InstancedMeshPicker> picker;
Container for components, providing composition of dynamic entities.
Context * context
Pointer to the Context instance the system lives in.
void postUpdate()
Perform post update logic in the system.
void update()
Updates the system state to that of the current frame.
Component system template with multiple parallel structures per component stored in separate pools si...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Implement custom bounds calculation.
virtual void getBounds(Context *context, Cogs::Geometry::BoundingBox &bounds) override
Expand bounds including bounds of all entities in this system in world coordinates.
Renders a mesh using instancing.
Instanced mesh render system.
ComponentHandle createComponent() override
Create a new component instance.
void destroyComponent(ComponentHandle component) override
Destroy the component held by the given handle.
void initialize(Context *context) override
Initialize the system.
void cleanup(Context *context) override
Provided for custom cleanup logic in derived systems.
Base class for picking meshes.
Base allocator implementation.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
PicksReturned
* Options for returning picking hits.
PickingFlags
Options for COGS picking.
ComponentIndex SizeType
Type used to track the size of pools.
Handle to a Component instance.
static ComponentHandle Empty()
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool().
bool pickImpl(Context *context, const glm::mat4 &worldPickMatrix, const glm::mat4 &rawViewProjection, const glm::mat4 &viewMatrix, const RayPicking::RayPickFilter &filter, PickingFlags pickingFlags, PicksReturned returnFlag, std::vector< RayPicking::RayPickHit > &hits) override
Each mesh rendering system should implement this function that goes through all components and calls ...
Task id struct used to identify unique Task instances.