## Libraries.Game.Collision.DynamicBoundingVolumeTree3D Documentation

DynamicBoundingVolumeTree2D is the tree structure for storing the bounding boxes for 2D objects that are able to collide. The tree is a complete binary tree and stores the bounding boxes in a hierarchal structure with the parent node containing a bounding box that bounds the bounding boxes of both of its children.

*Inherits from: *Libraries.Language.Object

## Summary

### Variable Summary Table

Variables | Description |
---|---|

integer NULL_NODE |

### Actions Summary Table

Actions | Description |
---|---|

Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns a CompareResult. |

ComputeHeight() | This action computes the height of the tree |

CountNodes() | This action returns the number of nodes in the DynamicBoundingVolumeTree3D tree. |

CountNodes(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node) | This action counts the number of nodes in the DynamicBoundingVolumeTree3D recursively. |

CreateNode(Libraries.Game.BoundingBox boundingBox, Libraries.Game.Collision.Item3DNode node) | This action creates a new node for the Dynamic Bounding Volume Tree with the given BoundingBox and given Item and inserts the new node as a leaf for the tree. |

DestroyNode(integer nodeID) | This action removes the node from the Dynamic Bounding Volume Tree with the given node ID |

DestroyNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node) | This action removes the given node from the tree. |

Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |

GetBoundingBox(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node) | This action returns the bounding box contained in the given tree node. |

GetBoundingBox(integer nodeID) | This action returns the bounding box contained in the tree node with the given ID. |

GetHashCode() | This action gets the hash code for an object. |

GetHeight() | extend the bounding b |

GetItemNode(integer nodeID) | This action returns the Item2Dcontained in the tree node with the given ID |

GetItemNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node) | This action returns the Item2Dcontained in the given tree node |

GetMaximumBalance() | This action computes the maximum balance of the tree. |

GetNodeCount() | use the displacement to update the bounding b |

GetPerimeterRatio() | This actoin computes the ratio of the sum of the node perimeters to the root perimeter. |

MoveNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node, Libraries.Game.BoundingBox boundingBox, Libraries.Compute.Vector3 displacement) | This action moves the object. |

MoveNode(integer nodeID, Libraries.Game.BoundingBox boundingBox, Libraries.Compute.Vector3 displacement) | This action moves the object contained in the node with the given node ID by the given displacement vector. |

Query(Libraries.Game.Collision.BroadphaseCollision3D broadphase, Libraries.Game.BoundingBox boundingBox) | This action queries the tree for bounding boxes that overlap with the given bounding box and returns all leafs whose bounding boxes intersect the given bounding box in a list. |

## Actions Documentation

### Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

**Example Code**

```
use Libraries.Language.Support.CompareResult
Object o
Object t
CompareResult result = o:Compare(t)
```

#### Parameters

- Libraries.Language.Object: The object to compare to.

#### Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

### ComputeHeight()

This action computes the height of the tree

#### Return

integer:

### CountNodes()

This action returns the number of nodes in the DynamicBoundingVolumeTree3D tree.

#### Return

integer:

### CountNodes(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node)

This action counts the number of nodes in the DynamicBoundingVolumeTree3D recursively.

#### Parameters

#### Return

integer:

### CreateNode(Libraries.Game.BoundingBox boundingBox, Libraries.Game.Collision.Item3DNode node)

This action creates a new node for the Dynamic Bounding Volume Tree with the given BoundingBox and given Item and inserts the new node as a leaf for the tree.

#### Parameters

#### Return

integer:

### DestroyNode(integer nodeID)

This action removes the node from the Dynamic Bounding Volume Tree with the given node ID

#### Parameters

### DestroyNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node)

This action removes the given node from the tree.

#### Parameters

### 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

- Libraries.Language.Object: The to be compared.

#### Return

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

### GetBoundingBox(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node)

This action returns the bounding box contained in the given tree node. Note that this bounding box is slightly larger than the bounding box of the item contained in this node.

#### Parameters

#### Return

### GetBoundingBox(integer nodeID)

This action returns the bounding box contained in the tree node with the given ID. Note that this bounding box is slightly larger than the bounding box of the item contained in this node

#### Parameters

#### Return

### 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()

extend the bounding b

#### Return

integer:

### GetItemNode(integer nodeID)

This action returns the Item2Dcontained in the tree node with the given ID

#### Parameters

#### Return

Libraries.Game.Collision.Item3DNode:

### GetItemNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node)

This action returns the Item2Dcontained in the given tree node

#### Parameters

#### Return

Libraries.Game.Collision.Item3DNode:

### GetMaximumBalance()

This action computes the maximum balance of the tree. The maximum balance is the maximum difference of the heights of the two children of any node.

#### Return

integer:

### GetNodeCount()

use the displacement to update the bounding b

#### Return

integer:

### GetPerimeterRatio()

This actoin computes the ratio of the sum of the node perimeters to the root perimeter.

#### Return

number:

### MoveNode(Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D node, Libraries.Game.BoundingBox boundingBox, Libraries.Compute.Vector3 displacement)

This action moves the object. If the object moves outside of its existing big bounding box, then the object is removed from the tree, a new bounding box is calculated, and it is reinserted into the tree. Otherwise, the action returns immediately.

#### Parameters

- Libraries.Game.Collision.DynamicBoundingVolumeTreeNode3D
- Libraries.Game.BoundingBox
- Libraries.Compute.Vector3

#### Return

boolean: Whether the item is reinserted into the tree

### MoveNode(integer nodeID, Libraries.Game.BoundingBox boundingBox, Libraries.Compute.Vector3 displacement)

This action moves the object contained in the node with the given node ID by the given displacement vector. If the node moves outside of its existing bounding box, then the object is removed from the tree, a new bounding box is calculated, and it is reinserted into the tree. Otherwise, the node is left where it is in the tree.

#### Parameters

#### Return

boolean: Returns whether the item is reinserted into the tree

### Query(Libraries.Game.Collision.BroadphaseCollision3D broadphase, Libraries.Game.BoundingBox boundingBox)

This action queries the tree for bounding boxes that overlap with the given bounding box and returns all leafs whose bounding boxes intersect the given bounding box in a list.

#### Parameters

- Libraries.Game.Collision.BroadphaseCollision3D
- Libraries.Game.BoundingBox: The BoundingBox2D we are checking for overlap with