1#include "Scene/GetBounds.h"
2#include "Systems/Core/ClipShapeSystem.h"
3#include "Systems/Core/TransformSystem.h"
13 const glm::mat4& worldFromModel = context->transformSystem->getLocalToWorld(trComp);
14 const glm::mat4 modelFromWorld = glm::inverse(worldFromModel);
16 switch (clipComp.
shape) {
17 case ClipShapeType::Cube:
18 case ClipShapeType::InvertedCube:
19 clipData.
planes[0] = glm::vec4(1, 0, 0, -clipComp.
min.x) * modelFromWorld;
20 clipData.
planes[1] = glm::vec4(-1, 0, 0, clipComp.
max.x) * modelFromWorld;
21 clipData.
planes[2] = glm::vec4(0, 1, 0, -clipComp.
min.y) * modelFromWorld;
22 clipData.
planes[3] = glm::vec4(0, -1, 0, clipComp.
max.y) * modelFromWorld;
23 clipData.
planes[4] = glm::vec4(0, 0, 1, -clipComp.
min.z) * modelFromWorld;
24 clipData.
planes[5] = glm::vec4(0, 0, -1, clipComp.
max.z) * modelFromWorld;
25 clipData.planeCount = 6;
26 clipData.shape = clipComp.
shape;
29 clipData.planeCount = 0;
30 clipData.shape = ClipShapeType::None;
34 switch (clipComp.
shape) {
35 case ClipShapeType::Cube:
36 clipData.
clipBounds = Bounds::getTransformedBounds(Cogs::Geometry::BoundingBox{ clipComp.
min, clipComp.
max }, worldFromModel);
39 clipData.
clipBounds = Cogs::Geometry::BoundingBox();
54 updateComponent(
context,
this, clipComp, trComp);
68 updateComponent(context,
this, clipComp, trComp);
ComponentType * getComponent() const
Sets up a clipping shape that can be used by multiple entities.
glm::vec3 max
The high-end corner of cube-shapes.
ClipShapeType shape
The basic shape of the clip region.
glm::vec3 min
The low-end corner of cube-shapes.
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
void preUpdate()
Run the pre-update method of the system.
ComponentPool< ComponentType > pool
Pool of components managed by the system.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
Cogs::Geometry::BoundingBox clipBounds
Bounds on clip shape in world space, empty if clip shape is open.
glm::vec4 planes[6]
Clipping planes in world space.