3#include "Systems/ComponentSystem.h"
5#include "Components/Core/MeshRenderComponent.h"
7#include "Services/TaskManager.h"
9#include "Scene/RayPick.h"
11#include "Foundation/Geometry/BoundingBox.hpp"
18 enum struct MeshRenderDataFlags
21 LocalBoundsOverride = 1 << 0,
22 WorldBoundsOverride = 1 << 2,
25 ENABLE_ENUM_FLAGS(MeshRenderDataFlags)
27 constexpr uint32_t NoCullingIndex =
static_cast<uint32_t
>(-1);
31 MeshRenderDataFlags flags = MeshRenderDataFlags::None;
32 uint32_t cullingIndex = NoCullingIndex;
34 uint16_t localBoundsGeneration = 0;
35 uint16_t worldBoundsGeneration = 0;
36 uint8_t meshBoundsGeneration = 0;
38 glm::mat4 localToWorld;
60 const glm::mat4& worldPickMatrix,
61 const glm::mat4& rawViewProjection,
62 const glm::mat4& viewMatrix,
66 std::vector<RayPicking::RayPickHit>& hits)
override;
88 TaskId getTaskGroup()
const {
return geometryGroup; }
90 void setLocalBounds(
const MeshRenderComponent * component,
const Geometry::BoundingBox & bbox)
92 getLocalBounds(component) = bbox;
93 auto & data = getData<MeshRenderData>(component);
94 data.flags |= MeshRenderDataFlags::LocalBoundsOverride;
95 ++data.localBoundsGeneration;
100 return this->getData<LocalBounds>(component);
105 return this->getData<WorldBounds>(component);
110 size_t getGeneration()
const {
return generation; }
115 bool needsPost =
true;
116 size_t generation = 0;
117 TaskId geometryGroup = NoTask;
119 std::unique_ptr<MeshRenderPicker> picker;
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.
Base class for picking meshes.
Renders the contents of a MeshComponent using the given materials.
The mesh render system handles MeshRenderComponents.
void initialize(Context *context) override
Initialize the system.
ComponentHandle createComponent() override
Create a new component instance.
void cleanup(Context *context) override
Provided for custom cleanup logic in derived systems.
void destroyComponent(ComponentHandle component) override
Destroy the component held by the given handle.
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.