Skip to main content

OctoTree

Types

Node<T>

type Node<T> = {
PositionVector3,
ObjectT
}

A container for an object that is stored in the octree. These are the public properties of the node, you should never modify these manually.

Functions

new

Constructor
OctoTree.new(topRegionSizenumber?) → Octree

CreateNode

OctoTree:CreateNode(
positionVector3,
objectT
) → Node<T>

RemoveNode

OctoTree:RemoveNode(nodeNodeInternal<T>) → boolean

Removes the given node if it resides within the octree, otherwise does nothing.

Returns true if the node was removed, false otherwise.

ChangeNodePosition

OctoTree:ChangeNodePosition(
nodeNodeInternal<T>,
positionVector3
) → ()

ClearAllNodes

OctoTree:ClearAllNodes() → ()

GetAllNodes

OctoTree:GetAllNodes() → {Node<T>}

CountNodes

OctoTree:CountNodes() → number

SearchRadius

OctoTree:SearchRadius(
positionVector3,
radiusnumber
) → {Node<T>}

ForEachInRadius

OctoTree:ForEachInRadius(
positionVector3,
radiusnumber
) → () → Node<T>?

Returns an iterator that can be used to traverse all nodes within the given radius.

for node: Node<any> in octree:ForEachInRadius(position, radius) do

ForEachNode

OctoTree:ForEachNode() → () → Node<T>?

Returns an iterator that can be used to traverse all nodes within the octree. The __iter metamethod is set to this method and thus can be used as follows:

for node: Node<any> in octree do

FindFirstNode

OctoTree:FindFirstNode(objectT) → Node<T>?

Returns the first node that has the given object if one resides within the octree.

GetNearest

OctoTree:GetNearest(
positionVector3,
radiusnumber,
maxNodesnumber?
) → {Node<T>}
Show raw api
{
    "functions": [
        {
            "name": "CreateNode",
            "desc": "",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Node<T>\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 189,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "RemoveNode",
            "desc": "Removes the given node if it resides within the octree, otherwise does nothing.\n\nReturns true if the node was removed, false otherwise.",
            "params": [
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "NodeInternal<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 210,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "ChangeNodePosition",
            "desc": "",
            "params": [
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "NodeInternal<T>"
                },
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 245,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "ClearAllNodes",
            "desc": "",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 259,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "GetAllNodes",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ Node<T> }\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 266,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "CountNodes",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 286,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "SearchRadius",
            "desc": "",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ Node<T> }\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 294,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "ForEachInRadius",
            "desc": "Returns an iterator that can be used to traverse all nodes within the given radius.\n\n```lua\nfor node: Node<any> in octree:ForEachInRadius(position, radius) do\n```",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> Node<T>?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 317,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "ForEachNode",
            "desc": "Returns an iterator that can be used to traverse all nodes within the octree.\nThe __iter metamethod is set to this method and thus can be used as follows:\n\n```lua\nfor node: Node<any> in octree do\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> Node<T>?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 341,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "FindFirstNode",
            "desc": "Returns the first node that has the given object if one resides within the octree.",
            "params": [
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Node<T>?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 361,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "GetNearest",
            "desc": "",
            "params": [
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "maxNodes",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ Node<T> }\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 373,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "_getRegion",
            "desc": "",
            "params": [
                {
                    "name": "maxLevel",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "position",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Region<T>\n"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 390,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "topRegionSize",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Octree"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 450,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Node<T>",
            "desc": "A container for an object that is stored in the octree.\nThese are the public properties of the node, you should\nnever modify these manually.",
            "lua_type": "{Position: Vector3, Object: T}",
            "source": {
                "line": 41,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        },
        {
            "name": "NodeInternal<T>",
            "desc": "Equivalent to Node<T> for end user purposes.",
            "lua_type": "Node<T> & {Region: Region<T>?}",
            "private": true,
            "source": {
                "line": 53,
                "path": "src/octotree/src/OctoTree/init.lua"
            }
        }
    ],
    "name": "OctoTree",
    "desc": "",
    "source": {
        "line": 176,
        "path": "src/octotree/src/OctoTree/init.lua"
    }
}