Cogs.Core
GetBounds.h
1#pragma once
2
3#include "Base.h"
4#include "Components/Core/RenderComponent.h"
5
6#include "Foundation/Geometry/BoundingBox.hpp"
7
8#include <span>
9#include <vector>
10
11namespace Cogs
12{
13 namespace Core
14 {
15 class Context;
16 class CameraComponent;
17
21 {
22 public:
23 virtual ~IGetBounds() = default;
24
28 virtual void getBounds(Context* context, Cogs::Geometry::BoundingBox& bounds, float& /*nearPlaneLimit*/)
29 {
30 getBounds(context, bounds);
31 }
32
34 virtual void getBounds(Context* context, Cogs::Geometry::BoundingBox& bounds) = 0;
35
38 virtual bool getBounds(Context* /*context*/, const ComponentModel::Entity* /*entity*/, Cogs::Geometry::BoundingBox& /*bounds*/, bool /*ignoreVisibility*/) const
39 {
40 return false;
41 }
42 };
43
45 class Bounds
46 {
47 public:
48 [[nodiscard]] COGSCORE_DLL_API static Cogs::Geometry::BoundingBox getBounds(Context * context, const ComponentModel::Entity * entity, bool ignoreVisibility = false);
49
50 [[nodiscard]] static Cogs::Geometry::BoundingBox getTransformedBounds(const Cogs::Geometry::BoundingBox& bbox, const glm::mat4 & m);
51 [[nodiscard]] static Cogs::Geometry::BoundingBox getTransformedBoundsWithDivision(const Cogs::Geometry::BoundingBox& bbox, const glm::mat4 & m);
52
53 COGSCORE_DLL_API [[nodiscard]] static Cogs::Geometry::BoundingBox getBounds(Context * context, const EntityId id, bool ignoreVisibility = false);
54 COGSCORE_DLL_API [[nodiscard]] static Cogs::Geometry::BoundingBox getBounds(Context* context, std::span<const EntityId> ids, bool ignoreVisibility = false);
55
56
57 static void getCameraDepthBounds(Context* context,
58 float& depthBoundNear,
59 float& depthBoundFar,
60 const CameraComponent & cameraComponent);
61
62 [[nodiscard]] static Cogs::Geometry::BoundingBox getShadowBounds(Context* context);
63
66 COGSCORE_DLL_API void addBoundsExtension(IGetBounds * bounds);
67
69 COGSCORE_DLL_API void removeBoundsExtension(IGetBounds * bounds);
70
72 [[nodiscard]] std::span<IGetBounds*> getExtensions() { return extensions; }
73
74 [[nodiscard]] Cogs::Geometry::BoundingBox getSceneBounds(Context* context, RenderLayers layerMask = RenderLayers::AllStandard);
75 void getSceneBounds(Context * context, float * values, RenderLayers layerMask = RenderLayers::AllStandard);
76 void getClipPlanes(Context* context, float& nearDist, float& farDist, const CameraComponent & cameraComponent, const glm::mat4 & viewMatrix);
77
78 private:
79 std::vector<IGetBounds *> extensions;
80 };
81 }
82}
83
Container for components, providing composition of dynamic entities.
Definition: Entity.h:18
Utility class for bounds calculation of Scene / Entity.
Definition: GetBounds.h:46
COGSCORE_DLL_API void removeBoundsExtension(IGetBounds *bounds)
De-register bounds calculation.
Definition: GetBounds.cpp:900
COGSCORE_DLL_API void addBoundsExtension(IGetBounds *bounds)
Definition: GetBounds.cpp:895
std::span< IGetBounds * > getExtensions()
Gets registered extensions.
Definition: GetBounds.h:72
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
virtual void getBounds(Context *context, Cogs::Geometry::BoundingBox &bounds)=0
Expand bounds including bounds of all entities in this system in world coordinates.
virtual bool getBounds(Context *, const ComponentModel::Entity *, Cogs::Geometry::BoundingBox &, bool) const
Definition: GetBounds.h:38
virtual void getBounds(Context *context, Cogs::Geometry::BoundingBox &bounds, float &)
Definition: GetBounds.h:28
RenderLayers
Contains common render layers.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23