Plasma Engine  2.0
Loading...
Searching...
No Matches
DynamicQuadtree.h
1#pragma once
2
3#include <Utilities/DataStructures/Implementation/DynamicTree.h>
4
31class PL_UTILITIES_DLL plDynamicQuadtree
32{
34 static const float s_fLooseOctreeFactor;
35
36public:
38
56 void CreateTree(const plVec3& vCenter, const plVec3& vHalfExtents, float fMinNodeSize); // [tested]
57
59 bool IsEmpty() const { return m_NodeMap.IsEmpty(); } // [tested]
60
62 plUInt32 GetCount() const { return m_NodeMap.GetCount(); } // [tested]
63
71 plResult InsertObject(const plVec3& vCenter, const plVec3& vHalfExtents, plInt32 iObjectType, plInt32 iObjectInstance,
72 plDynamicTreeObject* out_pObject = nullptr, bool bOnlyIfInside = false); // [tested]
73
75 void FindVisibleObjects(const plFrustum& viewfrustum, PL_VISIBLE_OBJ_CALLBACK callback, void* pPassThrough = nullptr) const;
76
81 void FindObjectsInRange(const plVec3& vPoint, PL_VISIBLE_OBJ_CALLBACK callback, void* pPassThrough = nullptr) const; // [tested]
82
88 void FindObjectsInRange(const plVec3& vPoint, float fRadius, PL_VISIBLE_OBJ_CALLBACK callback,
89 void* pPassThrough = nullptr) const; // [tested]
90
92 void RemoveObject(plInt32 iObjectType, plInt32 iObjectInstance); // [tested]
93
95 void RemoveObject(plDynamicTreeObject obj); // [tested]
96
98 void RemoveObjectsOfType(plInt32 iObjectType); // [tested]
99
102 {
103 m_NodeMap.Clear();
104 m_uiMultiMapCounter = 1;
105 } // [tested]
106
108 const plBoundingBox& GetBoundingBox() const { return m_BBox; } // [tested]
109
110private:
112 bool InsertObject(const plVec3& vCenter, const plVec3& vHalfExtents, const plDynamicTree::plObjectData& Obj, float minx, float maxx, float minz,
113 float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plDynamicTreeObject* out_Object);
114
116 void FindVisibleObjects(const plFrustum& Viewfrustum, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float minz,
117 float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
118
120 bool FindObjectsInRange(const plVec3& vPoint, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float minz, float maxz,
121 plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
122
124 bool FindObjectsInRange(const plVec3& vPoint, float fRadius, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx,
125 float minz, float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
126
128 plUInt32 m_uiMaxTreeDepth = 0;
129
131 plUInt32 m_uiAddIDTopLevel = 0;
132
134 plBoundingBox m_BBox;
135
137 float m_fRealMinX = 0, m_fRealMaxX = 0, m_fRealMinZ = 0, m_fRealMaxZ = 0;
138
140 plUInt32 m_uiMultiMapCounter = 0;
141
144};
A loose Quadtree implementation that is very lightweight on RAM.
Definition DynamicQuadtree.h:32
const plBoundingBox & GetBoundingBox() const
Returns the tree's adjusted (square) AABB.
Definition DynamicQuadtree.h:108
plUInt32 GetCount() const
Returns the number of objects that have been inserted into the tree.
Definition DynamicQuadtree.h:62
void RemoveAllObjects()
Removes all Objects, but the tree stays intact.
Definition DynamicQuadtree.h:101
bool IsEmpty() const
Returns true when there are no objects stored inside the tree.
Definition DynamicQuadtree.h:59
Represents the frustum of some camera and can be used for culling objects.
Definition Frustum.h:32
Definition Map.h:408
Definition DynamicTree.h:12
Forward Iterator to iterate over all elements in sorted order.
Definition Map.h:103
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54