ezEngine  Milestone 7
DynamicQuadtree.h
1 #pragma once
2 
3 #include <CoreUtils/DataStructures/DynamicTree/Implementation/DynamicTree.h>
4 
31 class EZ_COREUTILS_DLL ezDynamicQuadtree
32 {
34  static const float s_LooseOctreeFactor;
35 
36 public:
37 
39 
57  void CreateTree(const ezVec3& vCenter, const ezVec3& vHalfExtents, float fMinNodeSize); // [tested]
58 
60  bool IsEmpty() const { return m_NodeMap.IsEmpty(); } // [tested]
61 
63  ezUInt32 GetCount() const { return m_NodeMap.GetCount(); } // [tested]
64 
71  ezResult InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, ezInt32 iObjectType, ezInt32 iObjectInstance, ezDynamicTreeObject* out_Object = nullptr, bool bOnlyIfInside = false); // [tested]
72 
74  void FindVisibleObjects(const ezFrustum& Viewfrustum, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough = nullptr) const;
75 
80  void FindObjectsInRange(const ezVec3& vPoint, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough = nullptr) const; // [tested]
81 
86  void FindObjectsInRange(const ezVec3& vPoint, float fRadius, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough = nullptr) const; // [tested]
87 
89  void RemoveObject(ezInt32 iObjectType, ezInt32 iObjectInstance); // [tested]
90 
92  void RemoveObject(ezDynamicTreeObject obj); // [tested]
93 
95  void RemoveObjectsOfType(ezInt32 iObjectType); // [tested]
96 
98  void RemoveAllObjects() { m_NodeMap.Clear(); m_uiMultiMapCounter = 1; } // [tested]
99 
101  const ezBoundingBox& GetBoundingBox() const { return m_BBox; } // [tested]
102 
103 private:
104 
106  bool InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, const ezDynamicTree::ezObjectData& Obj, float minx, float maxx, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezDynamicTreeObject* out_Object);
107 
109  void FindVisibleObjects(const ezFrustum& Viewfrustum, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
110 
112  bool FindObjectsInRange(const ezVec3& vPoint, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
113 
115  bool FindObjectsInRange(const ezVec3& vPoint, float fRadius, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
116 
119 
122 
125 
127  float m_fRealMinX, m_fRealMaxX, m_fRealMinZ, m_fRealMaxZ;
128 
131 
134 };
135