31#include <boost/range/algorithm/partition.hpp>
32#include <boost/range/algorithm/nth_element.hpp>
44 std::lock_guard<std::mutex> lock(
m_lock );
119#define BVH_CONTAINER2D_MAX_OBJ_PER_LEAF 4
139 for( LIST_OBJECT2D::const_iterator ii =
m_objects.begin(); ii !=
m_objects.end(); ++ii )
175 wxASSERT( aNodeParent !=
nullptr );
177 wxASSERT( aNodeParent->
m_LeafList.size() > 0 );
196 switch( axis_to_split )
205 for( CONST_LIST_OBJECT2D::const_iterator ii = aNodeParent->
m_LeafList.begin();
211 if( i < (aNodeParent->
m_LeafList.size() / 2 ) )
237 wxASSERT( aNodeParent->
m_LeafList.size() == 0 );
246 wxASSERT( aNodeParent !=
nullptr );
265 wxASSERT( aNode !=
nullptr );
280 obj->
Intersect( aSegRay,
nullptr,
nullptr ) )
319 wxASSERT( aNode !=
nullptr );
330 for( CONST_LIST_OBJECT2D::const_iterator ii = aNode->
m_LeafList.begin();
337 aOutList.push_back( obj );
void GetIntersectingObjects(const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const override
Get a list of objects that intersects a bounding box.
BVH_CONTAINER_NODE_2D * m_tree
void recursiveGetListObjectsIntersects(const BVH_CONTAINER_NODE_2D *aNode, const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const
void recursiveBuild_MIDDLE_SPLIT(BVH_CONTAINER_NODE_2D *aNodeParent)
bool recursiveIntersectAny(const BVH_CONTAINER_NODE_2D *aNode, const RAYSEG2D &aSegRay) const
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
std::list< BVH_CONTAINER_NODE_2D * > m_elementsToDelete
CONTAINER_2D_BASE(OBJECT_2D_TYPE aObjType)
virtual ~CONTAINER_2D_BASE()
void GetIntersectingObjects(const BBOX_2D &aBBox, CONST_LIST_OBJECT2D &aOutList) const override
Get a list of objects that intersects a bounding box.
bool IntersectAny(const RAYSEG2D &aSegRay) const override
Intersect and check if a segment ray hits a object or is inside it.
virtual bool Intersects(const BBOX_2D &aBBox) const =0
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
const SFVEC2F & GetCentroid() const
const BBOX_2D & GetBBox() const
virtual bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const =0
virtual bool IsPointInside(const SFVEC2F &aPoint) const =0
#define BVH_CONTAINER2D_MAX_OBJ_PER_LEAF
static bool sortByCentroidX(const OBJECT_2D *a, const OBJECT_2D *b)
static bool sortByCentroidY(const OBJECT_2D *a, const OBJECT_2D *b)
static bool sortByCentroidZ(const OBJECT_2D *a, const OBJECT_2D *b)
std::list< const OBJECT_2D * > CONST_LIST_OBJECT2D
Manage a bounding box defined by two SFVEC2F min max points.
bool Intersects(const BBOX_2D &aBBox) const
Test if a bounding box intersects this box.
unsigned int MaxDimension() const
void Union(const SFVEC2F &aPoint)
Recalculate the bounding box adding a point.
bool IsInitialized() const
Check if this bounding box is already initialized.
bool Inside(const SFVEC2F &aPoint) const
Check is a point is inside this bounding box.
void Reset()
Reset the bounding box to zero and uninitialize it.
bool Intersect(const RAY2D &aRay, float *t) const
CONST_LIST_OBJECT2D m_LeafList
Store the list of objects if that node is a Leaf.
BVH_CONTAINER_NODE_2D * m_Children[2]