PlayRho  2.0.0
An interactive physics engine & library.
playrho::d2::DynamicTree::TreeNode Class Reference

A node in the dynamic tree. More...

#include <playrho/d2/DynamicTree.hpp>

Public Member Functions

constexpr TreeNode (const Contactable &value, const AABB &aabb, Size other=DynamicTree::InvalidSize) noexcept
 Initializing constructor.
 
constexpr TreeNode (const DynamicTreeBranchData &value, const AABB &aabb, Height height, Size other=DynamicTree::InvalidSize) noexcept
 Initializing constructor. More...
 
constexpr TreeNode (const TreeNode &other)=default
 Copy constructor.
 
constexpr TreeNode (Size other=DynamicTree::InvalidSize) noexcept
 Initializing constructor.
 
constexpr TreeNode (TreeNode &&other)=default
 Move constructor.
 
constexpr DynamicTreeBranchData AsBranch () const noexcept
 Gets the node as a "branch" value. More...
 
constexpr Contactable AsLeaf () const noexcept
 Gets the node as a "leaf" value. More...
 
constexpr void Assign (const Contactable &v) noexcept
 Gets the node as a "leaf" value. More...
 
constexpr void Assign (const DynamicTreeBranchData &v, const AABB &bb, Height h) noexcept
 Assigns the node as a "branch" value. More...
 
constexpr void Assign (const DynamicTreeUnusedData &v) noexcept
 Gets the node as an "unused" value. More...
 
constexpr DynamicTreeUnusedData AsUnused () const noexcept
 Gets the node as an "unused" value. More...
 
constexpr AABB GetAABB () const noexcept
 Gets the node's AABB. More...
 
constexpr Height GetHeight () const noexcept
 Gets the node "height".
 
constexpr Size GetOther () const noexcept
 Gets the node's "other" index.
 
TreeNodeoperator= (const TreeNode &other)=default
 Copy assignment operator.
 
constexpr void SetAABB (const AABB &value) noexcept
 Sets the node's AABB. More...
 
constexpr void SetOther (Size other) noexcept
 Sets the node's "other" index to the given value.
 

Related Functions

(Note that these are not member functions.)

constexpr AABB GetAABB (const DynamicTree::TreeNode &node) noexcept
 Gets the AABB of the given dynamic tree node. More...
 
constexpr DynamicTree::Size GetNext (const DynamicTree::TreeNode &node) noexcept
 Gets the next index of the given node. More...
 
constexpr bool IsBranch (const DynamicTree::TreeNode &node) noexcept
 Is branch. More...
 
constexpr bool IsBranch (const DynamicTree::TreeNode &node) noexcept
 Is branch. More...
 
constexpr bool IsLeaf (const DynamicTree::TreeNode &node) noexcept
 Is leaf. More...
 
constexpr bool IsLeaf (const DynamicTree::TreeNode &node) noexcept
 Whether or not this node is a leaf node. More...
 
constexpr bool IsUnused (const DynamicTree::TreeNode &node) noexcept
 Is unused. More...
 
constexpr bool IsUnused (const DynamicTree::TreeNode &node) noexcept
 Whether this node is free (or allocated).
 

Detailed Description

A node in the dynamic tree.

Note
Users do not interact with this directly.
By using indexes to other tree nodes, these don't need to be updated if the memory for other nodes is relocated.
On some 64-bit architectures, pointers are 8-bytes, while indices need only be 4-bytes. So using indices can also save 4-bytes.

Constructor & Destructor Documentation

◆ TreeNode()

constexpr playrho::d2::DynamicTree::TreeNode::TreeNode ( const DynamicTreeBranchData value,
const AABB aabb,
Height  height,
Size  other = DynamicTree::InvalidSize 
)
inlineconstexprnoexcept

Initializing constructor.

Precondition
height is a value such that IsBranch(height) is true.
Neither value.child1 nor value.child2 is equal to InvalidSize.

Member Function Documentation

◆ AsBranch()

constexpr DynamicTreeBranchData playrho::d2::DynamicTree::TreeNode::AsBranch ( ) const
inlineconstexprnoexcept

Gets the node as a "branch" value.

Precondition
This node is a branch, i.e.: IsBranch(GetHeight()) is true.

◆ AsLeaf()

constexpr Contactable playrho::d2::DynamicTree::TreeNode::AsLeaf ( ) const
inlineconstexprnoexcept

Gets the node as a "leaf" value.

Precondition
This node is a leaf, i.e.: IsLeaf(GetHeight()) is true.

◆ Assign() [1/3]

constexpr void playrho::d2::DynamicTree::TreeNode::Assign ( const Contactable v)
inlineconstexprnoexcept

Gets the node as a "leaf" value.

Precondition
This node is a leaf, i.e.: IsLeaf(GetHeight()) is true.

◆ Assign() [2/3]

constexpr void playrho::d2::DynamicTree::TreeNode::Assign ( const DynamicTreeBranchData v,
const AABB bb,
Height  h 
)
inlineconstexprnoexcept

Assigns the node as a "branch" value.

Precondition
This node is a branch, i.e.: IsBranch(GetHeight()) is true.
Neither v.child1 nor v.child2 is equal to InvalidSize.

◆ Assign() [3/3]

constexpr void playrho::d2::DynamicTree::TreeNode::Assign ( const DynamicTreeUnusedData v)
inlineconstexprnoexcept

Gets the node as an "unused" value.

Precondition
This node is unused, i.e.: IsUnused(GetHeight()) is true.

◆ AsUnused()

constexpr DynamicTreeUnusedData playrho::d2::DynamicTree::TreeNode::AsUnused ( ) const
inlineconstexprnoexcept

Gets the node as an "unused" value.

Precondition
This node is unused, i.e.: IsUnused(GetHeight()) is true.

◆ GetAABB()

constexpr AABB playrho::d2::DynamicTree::TreeNode::GetAABB ( ) const
inlineconstexprnoexcept

Gets the node's AABB.

Precondition
This node is not unused, i.e.: IsUnused(GetHeight()) is false.

Referenced by playrho::d2::DynamicTree::RebuildBottomUp().

◆ SetAABB()

constexpr void playrho::d2::DynamicTree::TreeNode::SetAABB ( const AABB value)
inlineconstexprnoexcept

Sets the node's AABB.

Precondition
This node is not unused, i.e.: IsUnused(GetHeight()) is false.

Referenced by playrho::d2::DynamicTree::UpdateLeaf().

Friends And Related Function Documentation

◆ GetAABB()

constexpr AABB GetAABB ( const DynamicTree::TreeNode node)
related

Gets the AABB of the given dynamic tree node.

Precondition
node must be a used node. I.e. IsUnused(node) must be false.

◆ GetNext()

constexpr DynamicTree::Size GetNext ( const DynamicTree::TreeNode node)
related

Gets the next index of the given node.

Precondition
The given node is unused, i.e.: IsUnused(node) is true.

◆ IsBranch() [1/2]

constexpr bool IsBranch ( const DynamicTree::TreeNode node)
related

Is branch.

Determines whether the given dynamic tree node is a branch node. Branch nodes have 2 indices to child nodes.

Referenced by AsBranch(), and Assign().

◆ IsBranch() [2/2]

constexpr bool IsBranch ( const DynamicTree::TreeNode node)
related

Is branch.

Determines whether the given node is a "branch" node.

◆ IsLeaf() [1/2]

constexpr bool IsLeaf ( const DynamicTree::TreeNode node)
related

Is leaf.

Determines whether the given dynamic tree node is a leaf node.

Referenced by AsLeaf(), and Assign().

◆ IsLeaf() [2/2]

constexpr bool IsLeaf ( const DynamicTree::TreeNode node)
related

Whether or not this node is a leaf node.

Note
This has constant complexity.
Returns
true if this is a leaf node, false otherwise.

◆ IsUnused()

constexpr bool IsUnused ( const DynamicTree::TreeNode node)
related

Is unused.

Determines whether the given dynamic tree node is an unused node.

Referenced by Assign(), AsUnused(), GetAABB(), and SetAABB().


The documentation for this class was generated from the following file: