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

*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 an integer. |

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

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

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

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

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

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

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() | This action computes the height of the tr |

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

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

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

GetNodeCount() | This action returns the bounding box contained in the given tree node. |

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

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 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 (smalle
```

#### Parameters

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

#### Return

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

### ComputeHeight()

This action computes the height of the tr

#### Return

integer:

### CountNodes()

This action returns the number of nodes in the DynamicBoundingVolumeTree3D tre

#### Return

integer:

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

This action counts the number of nodes in the DynamicBoundingVolumeTree3D recursivel

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

#### Parameters

#### Return

integer:

### DestroyNode(integer nodeID)

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

#### Parameters

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

This action removes the given node from the tre

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

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

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

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

This action computes the height of the tr

#### Return

integer:

### GetItemNode(integer nodeID)

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

#### Parameters

#### Return

Libraries.Game.Collision.Item3DNode:

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

This action returns the Item2Dcontained in the given tree no

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

#### Return

integer:

### GetNodeCount()

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 nod

#### Return

integer:

### GetPerimeterRatio()

This actoin computes the ratio of the sum of the node perimeters to the root perimete

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

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

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