Plasma Engine  2.0
Loading...
Searching...
No Matches
DynamicOctree.h
1#pragma once
2
3#include <Utilities/DataStructures/Implementation/DynamicTree.h>
4
31class PL_UTILITIES_DLL plDynamicOctree
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
76 void FindVisibleObjects(const plFrustum& viewfrustum, PL_VISIBLE_OBJ_CALLBACK callback, void* pPassThrough) const;
77
82 void FindObjectsInRange(const plVec3& vPoint, PL_VISIBLE_OBJ_CALLBACK callback, void* pPassThrough = nullptr) const; // [tested]
83
89 void FindObjectsInRange(const plVec3& vPoint, float fRadius, PL_VISIBLE_OBJ_CALLBACK callback,
90 void* pPassThrough = nullptr) const; // [tested]
91
93 void RemoveObject(plInt32 iObjectType, plInt32 iObjectInstance); // [tested]
94
96 void RemoveObject(plDynamicTreeObject obj); // [tested]
97
99 void RemoveObjectsOfType(plInt32 iObjectType); // [tested]
100
103 {
104 m_NodeMap.Clear();
105 m_uiMultiMapCounter = 1;
106 } // [tested]
107
109 const plBoundingBox& GetBoundingBox() const { return m_BBox; } // [tested]
110
111private:
113 bool InsertObject(const plVec3& vCenter, const plVec3& vHalfExtents, const plDynamicTree::plObjectData& Obj, float minx, float maxx, float miny,
114 float maxy, float minz, float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plDynamicTreeObject* out_Object);
115
117 void FindVisibleObjects(const plFrustum& Viewfrustum, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float miny,
118 float maxy, float minz, float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
119
121 bool FindObjectsInRange(const plVec3& vPoint, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float miny, float maxy,
122 float minz, float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
123
125 bool FindObjectsInRange(const plVec3& vPoint, float fRadius, PL_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx,
126 float miny, float maxy, float minz, float maxz, plUInt32 uiNodeID, plUInt32 uiAddID, plUInt32 uiSubAddID, plUInt32 uiNextNodeID) const;
127
129 plUInt32 m_uiMaxTreeDepth = 0;
130
131 // \brief Also used for finding a nodes unique ID
132 plUInt32 m_uiAddIDTopLevel = 0;
133
135 plBoundingBox m_BBox;
136
138 float m_fRealMinX = 0, m_fRealMaxX = 0, m_fRealMinY = 0, m_fRealMaxY = 0, m_fRealMinZ = 0, m_fRealMaxZ = 0;
139
141 plUInt32 m_uiMultiMapCounter = 0;
142
145};
A loose Octree implementation that is very lightweight on RAM.
Definition DynamicOctree.h:32
bool IsEmpty() const
Returns true when there are no objects stored inside the tree.
Definition DynamicOctree.h:59
plUInt32 GetCount() const
Returns the number of objects that have been inserted into the tree.
Definition DynamicOctree.h:62
const plBoundingBox & GetBoundingBox() const
Returns the tree's adjusted (square) AABB.
Definition DynamicOctree.h:109
void RemoveAllObjects()
Removes all Objects, but the tree stays intact.
Definition DynamicOctree.h:102
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