ezEngine  Milestone 7
DynamicOctree.h
1 #pragma once
2 
3 #include <CoreUtils/DataStructures/DynamicTree/Implementation/DynamicTree.h>
4 
31 class EZ_COREUTILS_DLL ezDynamicOctree
32 {
34  static const float s_LooseOctreeFactor;
35 
36 public:
38 
56  void CreateTree(const ezVec3& vCenter, const ezVec3& vHalfExtents, float fMinNodeSize); // [tested]
57 
59  bool IsEmpty() const { return m_NodeMap.IsEmpty(); } // [tested]
60 
62  ezUInt32 GetCount() const { return m_NodeMap.GetCount(); } // [tested]
63 
70  ezResult InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, ezInt32 iObjectType, ezInt32 iObjectInstance, ezDynamicTreeObject* out_Object = nullptr, bool bOnlyIfInside = false); // [tested]
71 
73  void FindVisibleObjects (const ezFrustum& Viewfrustum, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough) const;
74 
79  void FindObjectsInRange(const ezVec3& vPoint, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough = nullptr) const; // [tested]
80 
85  void FindObjectsInRange(const ezVec3& vPoint, float fRadius, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough = nullptr) const; // [tested]
86 
88  void RemoveObject(ezInt32 iObjectType, ezInt32 iObjectInstance); // [tested]
89 
91  void RemoveObject(ezDynamicTreeObject obj); // [tested]
92 
94  void RemoveObjectsOfType(ezInt32 iObjectType); // [tested]
95 
97  void RemoveAllObjects() { m_NodeMap.Clear(); m_uiMultiMapCounter = 1; } // [tested]
98 
100  const ezBoundingBox& GetBoundingBox() const { return m_BBox; } // [tested]
101 
102 private:
103 
105  bool InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, const ezDynamicTree::ezObjectData& Obj, float minx, float maxx, float miny, float maxy, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezDynamicTreeObject* out_Object);
106 
108  void FindVisibleObjects (const ezFrustum& Viewfrustum, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float miny, float maxy, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
109 
111  bool FindObjectsInRange(const ezVec3& vPoint, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float miny, float maxy, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
112 
114  bool FindObjectsInRange(const ezVec3& vPoint, float fRadius, EZ_VISIBLE_OBJ_CALLBACK Callback, void* pPassThrough, float minx, float maxx, float miny, float maxy, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezUInt32 uiNextNodeID) const;
115 
118 
119  // \brief Also used for finding a nodes unique ID
120  ezUInt32 m_uiAddIDTopLevel;
121 
124 
126  float m_fRealMinX, m_fRealMaxX, m_fRealMinY, m_fRealMaxY, m_fRealMinZ, m_fRealMaxZ;
127 
130 
133 };
134 
135