29 #ifndef DynamicAABBTree_hpp
30 #define DynamicAABBTree_hpp
69 static AABB new_lonely_aabb(
double minPoint[3],
double maxPoint[3],
double fatness,
unsigned int primtiveIndex = -1);
182 void PrimitivesList(std::vector<unsigned int> &primitivesList)
const;
209 void saveAABBs(std::vector<unsigned int> primitivesList);
240 unsigned int new_aabb(
double minPoint[3],
double maxPoint[3],
unsigned int primitiveIndex = -1);
292 unsigned int rotate_left(
unsigned int rootNodeIndex);
326 const bool aabb_do_overlap(
unsigned int aabb1,
unsigned int aabb2)
const;
340 static const unsigned int NotInList = (
unsigned int)(-1);
Definition: DynamicAABBTree.hpp:37
std::vector< AABBNode > _nodes
The leaves AABB nodes container.
Definition: DynamicAABBTree.hpp:386
const unsigned int node_number() const
Definition: DynamicAABBTree.hpp:135
void clear()
Clears the AABB tree.
Definition: DynamicAABBTree.cpp:487
void saveAABBs()
Definition: DynamicAABBTree.cpp:911
void delete_aabb(unsigned int anAABBIndex)
Deletes an AABB and updates the first available space in the AABBs list.
Definition: DynamicAABBTree.cpp:263
unsigned int rotate_left(unsigned int rootNodeIndex)
Performs a left-side rotation of a sub tree rooted at rootNodeIndex.
Definition: DynamicAABBTree.cpp:341
const AABBNode node_at_index(unsigned int nodeIndex) const
Definition: DynamicAABBTree.hpp:142
void update_node_aabb(unsigned int aNode)
Updates the dimensions of a node aabb, according to its childen.
Definition: DynamicAABBTree.cpp:435
void remove_node(unsigned int leafNode)
Removes a leaf node from the AABB tree.
Definition: DynamicAABBTree.cpp:173
bool update_primitive(unsigned int primitiveIndex, AABB tightAABB)
Updates the primitive in case it is out of its bounding box.
Definition: DynamicAABBTree.cpp:456
unsigned int _aabbsCount
The current number of AABBs in the tree.
Definition: DynamicAABBTree.hpp:351
void collidersPairs(std::vector< std::pair< unsigned int, unsigned int > > &collidersPairs) const
Queries the AABB tree to find all AABBs overlapping themselves.
Definition: DynamicAABBTree.cpp:585
static AABB merged_lonely_aabb(AABB aabb1, AABB aabb2, unsigned int primtiveIndex=-1)
Creates a new AABB which is a combination of two AABB.
Definition: DynamicAABBTree.cpp:784
DynamicAABBTree()
instanciates a new empty DynamicAABBTree object.
Definition: DynamicAABBTree.cpp:41
void insert_node(AABB anAABB)
Inserts a new AABB in the AABB tree.
Definition: DynamicAABBTree.cpp:56
std::vector< AABB > _aabbs
The AABBs container.
Definition: DynamicAABBTree.hpp:381
void set_fatness(double fatness)
Allows to define the expansion factor for fat AABBs.
Definition: DynamicAABBTree.hpp:102
unsigned int balance_node(unsigned int rootNodeIndex)
Balances a node according to its height.
Definition: DynamicAABBTree.cpp:287
const bool aabb_do_overlap(unsigned int aabb1, unsigned int aabb2) const
Checks if two AABBs overlap themselves.
Definition: DynamicAABBTree.cpp:837
const AABB aabb_at_index(unsigned int aabbIndex) const
Definition: DynamicAABBTree.hpp:156
unsigned int _firstFreeNodeIndex
The index of the first free node in the _nodes list.
Definition: DynamicAABBTree.hpp:366
void delete_node(unsigned int aNodeIndex)
Deletes a node and updates the first available space in the AABB nodes list.
Definition: DynamicAABBTree.cpp:235
unsigned int _firstFreeAABBIndex
The index of the first free aabb in the _aabbs list.
Definition: DynamicAABBTree.hpp:371
unsigned int _node_count
The current number of AABB nodes in the tree.
Definition: DynamicAABBTree.hpp:356
void printAABBNodes()
Definition: DynamicAABBTree.cpp:873
void remove_primitive(unsigned int primitiveIndex)
Removes an AABB from the AABB tree.
Definition: DynamicAABBTree.cpp:160
static AABB new_lonely_aabb(double minPoint[3], double maxPoint[3], double fatness, unsigned int primtiveIndex=-1)
Creates a new 'lonely' AABB with given extreme points.
Definition: DynamicAABBTree.cpp:749
~DynamicAABBTree()
Default destructor.
Definition: DynamicAABBTree.cpp:49
const int NodeBalance(unsigned int nodeIndex) const
Definition: DynamicAABBTree.hpp:170
unsigned int new_aabb(double minPoint[3], double maxPoint[3], unsigned int primitiveIndex=-1)
Creates a new AABB with given extreme points and, optionally, the primitive index.
Definition: DynamicAABBTree.cpp:795
std::vector< unsigned int > _primitivesToNode
stores the relationship from primitives to nodes indices.
Definition: DynamicAABBTree.hpp:376
void update_node_height(unsigned int aNode)
Updates the height of a node, according to its childen.
Definition: DynamicAABBTree.cpp:447
static const unsigned int NotInList
A flag to determine if an index is in a list.
Definition: DynamicAABBTree.hpp:340
double _fatness
The factor by which the AABBs dimensions are expanded.
Definition: DynamicAABBTree.hpp:346
const unsigned int aabb_number() const
Definition: DynamicAABBTree.hpp:149
void PrimitivesList(std::vector< unsigned int > &primitivesList) const
Populates the primitivesList vector with indices of all primitives contained in the tree.
Definition: DynamicAABBTree.cpp:515
const bool Primitiveexists(unsigned int primitiveIndex) const
Definition: DynamicAABBTree.cpp:499
const bool is_aabb_contain_aabb(unsigned int anAABBIndex, AABB anAABB) const
Checks if an AABB is contained inside another one.
Definition: DynamicAABBTree.cpp:853
unsigned int new_aabb_node()
Creates a new AABBNode.
Definition: DynamicAABBTree.cpp:703
void collidersList(unsigned int primitiveIndex, std::vector< unsigned int > &collidersList) const
Queries the AABB tree to find all AABBs overlapping with the AABB that stores a given primitive.
Definition: DynamicAABBTree.cpp:528
const bool is_node_leaf(unsigned int nodeIndex) const
Definition: DynamicAABBTree.hpp:163
unsigned int _rootNodeIndex
The root node of the AABB tree, necessary when the tree is dynamic.
Definition: DynamicAABBTree.hpp:361
unsigned int rotate_right(unsigned int rootNodeIndex)
Performs a right-side rotation of a sub tree rooted at rootNodeIndex.
Definition: DynamicAABBTree.cpp:388
Definition: StaticAABBTree.hpp:38
Definition: StaticAABBTree.hpp:54