Skip to content
FutureBlitz

    Install

    Import std.collections.spatial

    Octree

    std.collections.spatial

    class

    @DebugElements Public Class Octree<T> Implements Iterable<T>, Cloneable

    Values at 3D points, in bounds it splits in eight where points crowd.

    Examples

    Local tree = Octree<String>(0, 0, 0, 100, 100, 100)
    tree.Add("a", 10, 10, 10)
    tree.Add("b", 90, 90, 90)
    Expect(tree.Near(0, 0, 0, 20) == ["a"])
    Expect(tree.Count == 2)

    std/collections/spatial.fb, line 650

    • @PanicsAtCaller Public New(minX: Float, minY: Float, minZ: Float, maxX: Float, maxY: Float, maxZ: Float) constructor #

      An empty Octree for the points in the box from (minX, minY, minZ) to (maxX, maxY, maxZ), which has to be finite. A box whose max is below its min along an axis panics.

    • Public Property Count: Int property #

      How many values it holds.

    • @PanicsAtCaller Public Method Add(value: T, x: Float, y: Float, z: Float) method #

      Adds the value at (x, y, z). A point outside the Octree's box panics.

    • @PanicsAtCaller Public Method Remove(value: T, x: Float, y: Float, z: Float): Bool method #

      Removes the first value equal to value at (x, y, z), and tells whether there was one.

    • @PanicsAtCaller Public Method Contains(value: T, x: Float, y: Float, z: Float): Bool method #

      Whether a value equal to value is at (x, y, z).

    • @PanicsAtCaller Public Method Move(value: T, x: Float, y: Float, z: Float, toX: Float, toY: Float, toZ: Float): Bool method #

      Moves the first value equal to value at (x, y, z) to (toX, toY, toZ), and tells whether there was one. A point outside the Octree's box panics.

    • Public Method Clear() method #

      Takes every value out.

    • @PanicsAtCaller Public Method Query(minX: Float, minY: Float, minZ: Float, maxX: Float, maxY: Float, maxZ: Float): T[] method #

      The values in the box from (minX, minY, minZ) to (maxX, maxY, maxZ), in a new array.

    • @PanicsAtCaller Public Method Near(x: Float, y: Float, z: Float, radius: Float): T[] method #

      The values no more than radius from (x, y, z), in a new array.

    • Public Method ToArray(): T[] method #

      Every value, in a new array.

    • Public Method Clone(): Octree<T> method #

      A new Octree with the same box and values at the same points.

    • Public Method Iterate(): SpatialIterator<T> method #

      Every value. Adding or removing one while going over them panics.

    Report an issue with this page or with FutureBlitz on GitHub.