Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D Documentation

The DynamicBoundingVolumeTreeNode2D represents a node in the DynamicBoundingVolumeTree2D class. A DynamicBoundingVolumeTreeNode2D represents a BoundingBox2D which represents an item in the game. This node stores its parent in the tree as well as any children of the node. Additionally, the node's height in the tree and ID in integer are stored. By default, the node's treeParent, itemNode, leftChild, and rightChild are undefined. The node id and height are, by default, -1. This class is used internally by DynamicBoundingVolumeTree2D.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
use Libraries.Game.Collision.BoundingBox2D
use Libraries.Compute.Vector2
use Libraries.Game.Collision.Item2DNode

        DynamicBoundingVolumeTreeNode2D newNode
        Item2DNode node
        BoundingBox2D boundingBox
        Vector2 boxMinimum
        Vector2 boxMaximum
        boxMinimum:Set(-1, -1)
        boxMaximum:Set(1, 1)
        newNode:SetID(0) 
        BoundingBox2D nodeBoundingBox = newNode:GetBoundingBox()
        Vector2 minimum
        Vector2 maximum
        minimum:Set(boundingBox:GetMinimum())
        maximum:Set(boundingBox:GetMaximum())
        nodeBoundingBox:Set(minimum, maximum)
        newNode:SetItemNode(node)

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetBoundingBox()This action returns the BoundingBox2D which this node represents.
GetHashCode()This action gets the hash code for an object.
GetHeight()This action returns the integer height of this node in the DynamicBoundingVolumeTree2D.
GetID()This action gets the id of this node.
GetItemNode()This action returns the Item2DNode in the Dynamic Bounding Volume Tree Node (2D), which has among its data members a BoundingBox2D and an Item2D.
GetLeftChild()This action returns the DynamicBoundingVolumeTreeNode2D which is the left child of this node.
GetParent()This action returns the DynamicBoundingVolumeTreeNode2D which is the parent of this node.
GetRightChild()This action returns the DynamicBoundingVolumeTreeNode2D which is the right child of this node.
IsLeaf()This action returns true if this node is a leaf (i.
SetBoundingBox(Libraries.Game.Collision.BoundingBox2D boundingBox)This action sets the BoundingBox2D which this node is to represent.
SetHeight(integer height)This action sets the height of the Dynamic Bounding Volume Tree Node (2D) in the DynamicBoundingVolumeTree2D.
SetID(integer id)This action sets the id of the Dynamic Bounding Volume Tree Node (2D).
SetItemNode(Libraries.Game.Collision.Item2DNode itemNode)This action sets the Item2DNode of the Dynamic Bounding Volume Tree Node (2D), which has among its data members a BoundingBox2D and an Item2D.
SetLeftChild(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D leftChild)This action sets the DynamicBoundingVolumeTreeNode2D which is to be the left child of this node.
SetParent(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D treeParent)This action sets the DynamicBoundingVolumeTreeNode2D which is to be the parent of this node.
SetRightChild(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D rightChild)This action sets the DynamicBoundingVolumeTreeNode2D which is to be the right child of this node.

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GetBoundingBox()

This action returns the BoundingBox2D which this node represents. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.BoundingBox2D

            DynamicBoundingVolumeTreeNode2D node
            BoundingBox2D boundingBox
            boundingBox = node:GetBoundingBox()

Return

Libraries.Game.Collision.BoundingBox2D: The BoundingBox2D represented by this tree node.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetHeight()

This action returns the integer height of this node in the DynamicBoundingVolumeTree2D. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        
            DynamicBoundingVolumeTreeNode2D node
            output "Node " + node:GetID() + " is at height " + node:GetHeight()

Return

integer: The integer height of this tree node.

GetID()

This action gets the id of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.DynamicBoundingVolumeTree2D

            DynamicBoundingVolumeTree2D tree
            DynamicBoundingVolumeTreeNode2D newNode
            newNode:SetID(0)
            integer id = newNode:GetID()

Return

integer: The id of this node.

GetItemNode()

This action returns the Item2DNode in the Dynamic Bounding Volume Tree Node (2D), which has among its data members a BoundingBox2D and an Item2D. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.Item2DNode

            DynamicBoundingVolumeTreeNode2D node
            Item2DNode itemNode
            itemNode = node:GetItemNode

Return

Libraries.Game.Collision.Item2DNode: The item2DNode in this tree node.

GetLeftChild()

This action returns the DynamicBoundingVolumeTreeNode2D which is the left child of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D leftNode
            leftNode:SetID(1)
            node:SetLeftChild(leftNode)
            output "The left child of this node is node " + node:GetLeftChild():GetID()

Return

Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D: The DynamicBoundingVolumeTreeNode2D left child of this node.

GetParent()

This action returns the DynamicBoundingVolumeTreeNode2D which is the parent of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D parentNode
            parentNode:SetID(1)
            node:SetParent(parentNode)
            output "The parent of this node is node " + node:GetParent():GetID()

Return

Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D: The DynamicBoundingVolumeTreeNode2D parent of this node.

GetRightChild()

This action returns the DynamicBoundingVolumeTreeNode2D which is the right child of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D rightNode
            rightNode:SetID(1)
            node:SetRightChild(rightNode)
            output "The right child of this node is node " + node:GetRightChild():GetID()

Return

Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D: The DynamicBoundingVolumeTreeNode2D right child of this node.

IsLeaf()

This action returns true if this node is a leaf (i.e. has no children) and false if this node has children. Attribute Returns boolean The boolean that indicates whether or not this node is a leaf

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D leftNode
            node:SetLeftChild(leftNode)
            if node:IsLeaf() 
                output "This node is a leaf."
            else
                output "This node is not a leaf."
            end

Return

boolean:

SetBoundingBox(Libraries.Game.Collision.BoundingBox2D boundingBox)

This action sets the BoundingBox2D which this node is to represent. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.BoundingBox2D

            DynamicBoundingVolumeTreeNode2D node
            BoundingBox2D boundingBox
            node:SetBoundingBox(boundingBox)

Parameters

SetHeight(integer height)

This action sets the height of the Dynamic Bounding Volume Tree Node (2D) in the DynamicBoundingVolumeTree2D. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.Item2DNode

            DynamicBoundingVolumeTreeNode2D node
            Item2DNode itemNode
            node:SetHeight(1)

Parameters

SetID(integer id)

This action sets the id of the Dynamic Bounding Volume Tree Node (2D). This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            node:Set(0)

Parameters

SetItemNode(Libraries.Game.Collision.Item2DNode itemNode)

This action sets the Item2DNode of the Dynamic Bounding Volume Tree Node (2D), which has among its data members a BoundingBox2D and an Item2D. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D
        use Libraries.Game.Collision.Item2DNode

            DynamicBoundingVolumeTreeNode2D node
            Item2DNode itemNode
            node:SetItemNode(itemNode)

Parameters

SetLeftChild(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D leftChild)

This action sets the DynamicBoundingVolumeTreeNode2D which is to be the left child of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D leftNode
            node:SetLeftChild(leftNode)

Parameters

SetParent(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D treeParent)

This action sets the DynamicBoundingVolumeTreeNode2D which is to be the parent of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D parentNode
            node:SetParent(parentNode)

Parameters

SetRightChild(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D rightChild)

This action sets the DynamicBoundingVolumeTreeNode2D which is to be the right child of this node. This action is used internally.

Example Code

use Libraries.Game.Collision.DynamicBoundingVolumeTreeNode2D

            DynamicBoundingVolumeTreeNode2D node
            DynamicBoundingVolumeTreeNode2D rightNode
            node:SetRightChild(rightNode)

Parameters