playrho::d2::DynamicTree::TreeNode Class Reference

A node in the dynamic tree. More...

#include <DynamicTree.hpp>

Public Member Functions

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

Related Functions

(Note that these are not member functions.)

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

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.
This data structure is 48-bytes large on at least one 64-bit platform.

Definition at line 395 of file DynamicTree.hpp.

Constructor & Destructor Documentation

◆ ~TreeNode()

playrho::d2::DynamicTree::TreeNode::~TreeNode ( )
default

◆ TreeNode() [1/5]

PLAYRHO_CONSTEXPR playrho::d2::DynamicTree::TreeNode::TreeNode ( const TreeNode other)
inlinedefault

Copy constructor.

◆ TreeNode() [2/5]

PLAYRHO_CONSTEXPR playrho::d2::DynamicTree::TreeNode::TreeNode ( TreeNode &&  other)
inlinedefault

Move constructor.

◆ TreeNode() [3/5]

PLAYRHO_CONSTEXPR playrho::d2::DynamicTree::TreeNode::TreeNode ( Size  other = DynamicTree::GetInvalidSize())
inlineexplicitnoexcept

Initializing constructor.

Definition at line 407 of file DynamicTree.hpp.

◆ TreeNode() [4/5]

PLAYRHO_CONSTEXPR playrho::d2::DynamicTree::TreeNode::TreeNode ( const LeafData value,
AABB  aabb,
Size  other = DynamicTree::GetInvalidSize() 
)
inlinenoexcept

Initializing constructor.

Definition at line 414 of file DynamicTree.hpp.

◆ TreeNode() [5/5]

PLAYRHO_CONSTEXPR playrho::d2::DynamicTree::TreeNode::TreeNode ( const BranchData value,
AABB  aabb,
Height  height,
Size  other = DynamicTree::GetInvalidSize() 
)
inlinenoexcept

Initializing constructor.

Definition at line 422 of file DynamicTree.hpp.

Member Function Documentation

◆ operator=()

TreeNode& playrho::d2::DynamicTree::TreeNode::operator= ( const TreeNode other)
default

Copy assignment operator.

◆ GetHeight()

PLAYRHO_CONSTEXPR Height playrho::d2::DynamicTree::TreeNode::GetHeight ( ) const
inlinenoexcept

Gets the node "height".

Definition at line 435 of file DynamicTree.hpp.

◆ GetOther()

PLAYRHO_CONSTEXPR Size playrho::d2::DynamicTree::TreeNode::GetOther ( ) const
inlinenoexcept

Gets the node's "other" index.

Definition at line 441 of file DynamicTree.hpp.

◆ SetOther()

PLAYRHO_CONSTEXPR void playrho::d2::DynamicTree::TreeNode::SetOther ( Size  other)
inlinenoexcept

Sets the node's "other" index to the given value.

Definition at line 447 of file DynamicTree.hpp.

◆ GetAABB()

PLAYRHO_CONSTEXPR AABB playrho::d2::DynamicTree::TreeNode::GetAABB ( ) const
inlinenoexcept

Gets the node's AABB.

Warning
Behavior is undefined if called on a free/unused node!

Definition at line 454 of file DynamicTree.hpp.

◆ SetAABB()

PLAYRHO_CONSTEXPR void playrho::d2::DynamicTree::TreeNode::SetAABB ( AABB  value)
inlinenoexcept

Sets the node's AABB.

Warning
Behavior is undefined if called on a free/unused node!

Definition at line 462 of file DynamicTree.hpp.

◆ AsUnused()

PLAYRHO_CONSTEXPR UnusedData playrho::d2::DynamicTree::TreeNode::AsUnused ( ) const
inlinenoexcept

Gets the node as an "unused" value.

Warning
Behavior is undefined unless called on a free/unused node!

Definition at line 470 of file DynamicTree.hpp.

◆ AsLeaf()

PLAYRHO_CONSTEXPR LeafData playrho::d2::DynamicTree::TreeNode::AsLeaf ( ) const
inlinenoexcept

Gets the node as a "leaf" value.

Warning
Behavior is undefined unless called on a leaf node!

Definition at line 478 of file DynamicTree.hpp.

◆ AsBranch()

PLAYRHO_CONSTEXPR BranchData playrho::d2::DynamicTree::TreeNode::AsBranch ( ) const
inlinenoexcept

Gets the node as a "branch" value.

Warning
Behavior is undefined unless called on a branch node!

Definition at line 486 of file DynamicTree.hpp.

◆ Assign() [1/3]

PLAYRHO_CONSTEXPR void playrho::d2::DynamicTree::TreeNode::Assign ( const UnusedData v)
inlinenoexcept

Gets the node as an "unused" value.

Definition at line 493 of file DynamicTree.hpp.

◆ Assign() [2/3]

PLAYRHO_CONSTEXPR void playrho::d2::DynamicTree::TreeNode::Assign ( const LeafData v)
inlinenoexcept

Gets the node as a "leaf" value.

Definition at line 500 of file DynamicTree.hpp.

◆ Assign() [3/3]

PLAYRHO_CONSTEXPR void playrho::d2::DynamicTree::TreeNode::Assign ( const BranchData v,
const AABB bb,
Height  h 
)
inlinenoexcept

Assigns the node as a "branch" value.

Definition at line 507 of file DynamicTree.hpp.

Friends And Related Function Documentation

◆ IsUnused() [1/2]

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

Is unused.

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

Definition at line 631 of file DynamicTree.hpp.

◆ IsLeaf() [1/2]

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

Is leaf.

Determines whether the given dynamic tree node is a leaf node. Leaf nodes have a pointer to user data.

Definition at line 640 of file DynamicTree.hpp.

◆ IsBranch() [1/2]

PLAYRHO_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.

Definition at line 648 of file DynamicTree.hpp.

◆ IsUnused() [2/2]

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

Whether this node is free (or allocated).

Definition at line 631 of file DynamicTree.hpp.

◆ IsLeaf() [2/2]

PLAYRHO_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.

Definition at line 640 of file DynamicTree.hpp.

◆ IsBranch() [2/2]

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

Is branch.

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

Definition at line 648 of file DynamicTree.hpp.

◆ GetAABB()

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

Gets the AABB of the given dynamic tree node.

Definition at line 655 of file DynamicTree.hpp.

◆ GetNext()

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

Gets the next index of the given node.

Warning
Behavior is undefined if the given node is not an "unused" node.

Definition at line 664 of file DynamicTree.hpp.


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