RenderTreePart3D

Package: Libraries.Game.Graphics.Trees · Inherits from: Libraries.Language.Object

RenderTreePart3D is one half of a StaticDynamicRenderTree3D: the static half or the dynamic half. It holds leaves, one for each item, and finds the ones inside a view, a box or a sphere. The leaves belong to the render tree, which moves them between its two halves. This class has blank actions. Each kind of render tree uses a different kind of part: - RenderBoundingVolumeTree3D, a tree of boxes, for DynamicVolumeRenderTree3D. - RenderCellTree3D, a grid of cells that splits into smaller cells, for QuadTree3D and Octree3D. Every part has a margin, kept here. The box calculations a part needs, such as giving a leaf its box with the margin, are actions on the leaf, RenderTreeNode3D.

Example Code

use Libraries.Game.Graphics.Trees.RenderTreePart3D
use Libraries.Game.Graphics.Trees.RenderBoundingVolumeTree3D

RenderBoundingVolumeTree3D volumes
RenderTreePart3D part = volumes
part:SetMargin(0.25)
output part:GetMargin()

Actions

Add(Libraries.Game.Graphics.Trees.RenderTreeNode3D leaf, Libraries.Game.BoundingBox itemBounds)

This action adds a leaf, with a box around the given bounds of its item.

Parameters

Collect(Libraries.Game.Graphics.Trees.CullingVolume3D volume, Libraries.Game.Graphics.Trees.RenderTree3DResult result)

This action adds to the result every item whose box is at least partly inside the volume. The result decides which of its lists each item goes in, and skips items it already has.

Parameters

Collect(number x, number y, number z, number radius, Libraries.Containers.Array<Libraries.Interface.Item3D> results)

This action adds to the results every item whose box overlaps the sphere with the given center and radius.

Parameters

  • x number: The x coordinate of the sphere's center.
  • y number: The y coordinate of the sphere's center.
  • z number: The z coordinate of the sphere's center.
  • radius number: The sphere's radius.
  • results Libraries.Containers.Array<Libraries.Interface.Item3D>: The array to add the items to.

Collect(Libraries.Game.BoundingBox box, Libraries.Containers.Array<Libraries.Interface.Item3D> results)

This action adds to the results every item whose box overlaps the box.

Parameters

Collect(number x, number y, number z, number radius, Libraries.Game.Graphics.Trees.RenderTree3DResult result)

This action adds to the result every item whose box overlaps the sphere with the given center and radius, such as a point light's reach. The result decides which of its lists each item goes in, and skips items it already has.

Parameters

  • x number: The x coordinate of the sphere's center.
  • y number: The y coordinate of the sphere's center.
  • z number: The z coordinate of the sphere's center.
  • radius number: The sphere's radius.
  • result Libraries.Game.Graphics.Trees.RenderTree3DResult: The result to add the items to.

Empty()

This action removes every leaf. The leaves themselves are not changed.

GetFirstLeaf()

This action returns the first leaf in the part's own order, or undefined when the part is empty. With GetNextLeaf, it visits every leaf once. The order depends on how the part is built, not on when leaves were added.

Returns

Libraries.Game.Graphics.Trees.RenderTreeNode3D: The first leaf, or undefined.

GetHeight()

This action returns how many levels the part has below its top, or -1 when it is empty. What a level is depends on the kind of part.

Returns

integer: The number of levels.

GetMargin()

This action returns how much bigger than its item a leaf's box is made.

Returns

number: The margin.

GetNextLeaf(Libraries.Game.Graphics.Trees.RenderTreeNode3D leaf)

This action returns the leaf after the given one in the part's own order, or undefined after the last leaf. It finds it by following the links between the part's nodes, so it takes a few steps however many leaves there are, and it makes no new objects. A leaf that is no longer in the part has no leaf after it.

Parameters

Returns

Libraries.Game.Graphics.Trees.RenderTreeNode3D: The next leaf, or undefined.

GetSize()

This action returns how many leaves the part holds.

Returns

integer: The number of leaves.

Move(Libraries.Game.Graphics.Trees.RenderTreeNode3D leaf, Libraries.Game.BoundingBox itemBounds)

This action updates a leaf whose item has moved.

Parameters

Returns

boolean: True if the leaf changed place in the part.

Remove(Libraries.Game.Graphics.Trees.RenderTreeNode3D leaf)

This action removes a leaf. The leaf itself is not reused, since it belongs to the render tree.

Parameters

SetMargin(number value)

This action sets how much bigger than its item a leaf's box is made, on every side. A bigger margin means fewer changes as items move, but more items found just outside a view.

Parameters

  • value number: The margin.

Inherited Actions

3 actions from Libraries.Language.Object