Plasma Engine  2.0
Loading...
Searching...
No Matches
SpatialSystem.h
1#pragma once
2
3#include <Core/World/SpatialData.h>
4#include <Foundation/Math/Frustum.h>
5#include <Foundation/Memory/CommonAllocators.h>
6#include <Foundation/SimdMath/SimdBBoxSphere.h>
7#include <Foundation/Types/TagSet.h>
8
9class PL_CORE_DLL plSpatialSystem : public plReflectedClass
10{
11 PL_ADD_DYNAMIC_REFLECTION(plSpatialSystem, plReflectedClass);
12
13public:
16
17 virtual void StartNewFrame();
18
21
22 virtual plSpatialDataHandle CreateSpatialData(const plSimdBBoxSphere& bounds, plGameObject* pObject, plUInt32 uiCategoryBitmask, const plTagSet& tags) = 0;
23 virtual plSpatialDataHandle CreateSpatialDataAlwaysVisible(plGameObject* pObject, plUInt32 uiCategoryBitmask, const plTagSet& tags) = 0;
24
25 virtual void DeleteSpatialData(const plSpatialDataHandle& hData) = 0;
26
27 virtual void UpdateSpatialDataBounds(const plSpatialDataHandle& hData, const plSimdBBoxSphere& bounds) = 0;
28 virtual void UpdateSpatialDataObject(const plSpatialDataHandle& hData, plGameObject* pObject) = 0;
29
33
35
36#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
37 struct QueryStats
38 {
39 plUInt32 m_uiTotalNumObjects = 0;
40 plUInt32 m_uiNumObjectsTested = 0;
41 plUInt32 m_uiNumObjectsPassed = 0;
42 plTime m_TimeTaken;
43 };
44#endif
45
47 {
48 plUInt32 m_uiCategoryBitmask = 0;
49 const plTagSet* m_pIncludeTags = nullptr;
50 const plTagSet* m_pExcludeTags = nullptr;
51#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
52 QueryStats* m_pStats = nullptr;
53#endif
54 };
55
56 virtual void FindObjectsInSphere(const plBoundingSphere& sphere, const QueryParams& queryParams, plDynamicArray<plGameObject*>& out_objects) const;
57 virtual void FindObjectsInSphere(const plBoundingSphere& sphere, const QueryParams& queryParams, QueryCallback callback) const = 0;
58
59 virtual void FindObjectsInBox(const plBoundingBox& box, const QueryParams& queryParams, plDynamicArray<plGameObject*>& out_objects) const;
60 virtual void FindObjectsInBox(const plBoundingBox& box, const QueryParams& queryParams, QueryCallback callback) const = 0;
61
65
66 using IsOccludedFunc = plDelegate<bool(const plSimdBBox&)>;
67
68 virtual void FindVisibleObjects(const plFrustum& frustum, const QueryParams& queryParams, plDynamicArray<const plGameObject*>& out_objects, IsOccludedFunc isOccluded, plVisibilityState visType) const = 0;
69
75 virtual plVisibilityState GetVisibilityState(const plSpatialDataHandle& hData, plUInt32 uiNumFramesBeforeInvisible) const = 0;
76
78
79#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
80 virtual void GetInternalStats(plStringBuilder& ref_sSb) const;
81#endif
82
83protected:
84 plProxyAllocator m_Allocator;
85
86 plUInt64 m_uiFrameCounter = 0;
87};
Definition DynamicArray.h:81
Represents the frustum of some camera and can be used for culling objects.
Definition Frustum.h:32
This class represents an object inside the world.
Definition GameObject.h:32
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition SimdBBox.h:6
Definition SimdBBoxSphere.h:6
Definition Declarations.h:353
Definition SpatialSystem.h:10
virtual plVisibilityState GetVisibilityState(const plSpatialDataHandle &hData, plUInt32 uiNumFramesBeforeInvisible) const =0
Retrieves a state describing how visible the object is.
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
A dynamic collection of tags featuring fast lookups.
Definition TagSet.h:23
Definition SpatialSystem.h:47
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Enum
Definition Declarations.h:344