Skip to main content

OctreeRegionUtils

Octree implementation utilities. Primarily this utility code should not be used directly and should be considered private to the library.

Use Octree instead of this library directly.

Types

OctreeVector3

type OctreeVector3 = {
[1]number,
[2]number,
[3]number
}

A Vector3 equivalent for octrees. This type is primarily internal and used for faster access than a Vector3.

OctreeRegion<T>

interface OctreeRegion<T> {
subRegions{OctreeRegion<T>}
lowerBoundsOctreeVector3
upperBoundsOctreeVector3
positionOctreeVector3
parentOctreeRegion<T>?
parentIndexnumber
depthnumber
nodes{OctreeNode<T>}
node_countnumber
}

An internal region which stores the data.

Functions

visualize

OctreeRegionUtils.visualize(regionOctreeRegion<T>) → MaidTask

Visualizes the octree region.

create

OctreeRegionUtils.create(
pxnumber,
pynumber,
pznumber,
sxnumber,
synumber,
sznumber,
parentOctreeRegion<T>?,
parentIndexnumber?
) → OctreeRegion<T>

Creates a new OctreeRegion

addNode

OctreeRegionUtils.addNode(
lowestSubregionOctreeRegion<T>,
nodeOctreeNode
) → ()

Adds a node to the lowest subregion

moveNode

OctreeRegionUtils.moveNode(
fromLowestOctreeRegion<T>,
toLowestOctreeRegion<T>,
nodeOctreeNode
) → ()

Moves a node from one region to another

removeNode

OctreeRegionUtils.removeNode(
lowestSubregionOctreeRegion<T>,
nodeOctreeNode
) → ()

Removes a node from the given region

getSearchRadiusSquared

OctreeRegionUtils.getSearchRadiusSquared(
radiusnumber,
diameternumber,
epsilonnumber
) → number

Retrieves the search radius for a given radius given the region diameter

getNeighborsWithinRadius

OctreeRegionUtils.getNeighborsWithinRadius(
regionOctreeRegion<T>,
radiusnumber,
pxnumber,
pynumber,
pznumber,
objectsFound{T},
nodeDistances2{number},
maxDepthnumber
) → ()

getOrCreateSubRegionAtDepth

OctreeRegionUtils.getOrCreateSubRegionAtDepth(
regionOctreeRegion<T>,--

Top level region

pxnumber,
pynumber,
pznumber,
maxDepthnumber
) → OctreeRegion<T>

Recursively ensures that a subregion exists at a given depth, and returns that region for usage.

createSubRegion

OctreeRegionUtils.createSubRegion(
parentRegionOctreeRegion<T>,
parentIndexnumber
) → OctreeRegion<T>

Creates a subregion for an octree.

inRegionBounds

OctreeRegionUtils.inRegionBounds(
regionOctreeRegion<T>,
pxnumber,
pynumber,
pznumber
) → boolean

Computes whether a region is in bounds.

Consider regions to be range [px, y).

getSubRegionIndex

OctreeRegionUtils.getSubRegionIndex(
regionOctreeRegion<T>,
pxnumber,
pynumber,
pznumber
) → number

Gets a subregion's internal index.

getTopLevelRegionHash

OctreeRegionUtils.getTopLevelRegionHash(
cxnumber,
cynumber,
cznumber
) → number

This definitely collides fairly consistently

See: https://stackoverflow.com/questions/5928725/hashing-2d-3d-and-nd-vectors

getTopLevelRegionCellIndex

OctreeRegionUtils.getTopLevelRegionCellIndex(
maxRegionSizeOctreeVector3,
pxnumber,
pynumber,
pznumber
) → (
number,--

rpx

number,--

rpy

number--

rpz

)

Computes the index for a top level cell given a position

getTopLevelRegionPosition

OctreeRegionUtils.getTopLevelRegionPosition(
maxRegionSizeOctreeVector3,
cxnumber,
cynumber,
cznumber
) → (
number,
number,
number
)

Computes a top-level region's position

areEqualTopRegions

OctreeRegionUtils.areEqualTopRegions(
regionOctreeRegion<T>,
rpxnumber,
rpynumber,
rpznumber
) → boolean

Given a top-level region, returns if the region position are equal to this region

findRegion

OctreeRegionUtils.findRegion(
regionHashMap{[number]{OctreeRegion<T>}},
maxRegionSizeOctreeVector3,
pxnumber,
pynumber,
pznumber
) → OctreeRegion3?

Given a world space position, finds the current region in the hashmap

getOrCreateRegion

OctreeRegionUtils.getOrCreateRegion(
regionHashMap{[number]{OctreeRegion<T>}},
maxRegionSizeOctreeVector3,
pxnumber,
pynumber,
pznumber
) → OctreeRegion<T>

Gets the current region for a position, or creates a new one.

Show raw api
{
    "functions": [
        {
            "name": "visualize",
            "desc": "Visualizes the octree region.",
            "params": [
                {
                    "name": "region",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "MaidTask"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 37,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "create",
            "desc": "Creates a new OctreeRegion<T>",
            "params": [
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "sx",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "sy",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "sz",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>?"
                },
                {
                    "name": "parentIndex",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 88,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "addNode",
            "desc": "Adds a node to the lowest subregion",
            "params": [
                {
                    "name": "lowestSubregion",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "OctreeNode"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 125,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "moveNode",
            "desc": "Moves a node from one region to another",
            "params": [
                {
                    "name": "fromLowest",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "toLowest",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "OctreeNode"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 145,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "removeNode",
            "desc": "Removes a node from the given region",
            "params": [
                {
                    "name": "lowestSubregion",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "node",
                    "desc": "",
                    "lua_type": "OctreeNode"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 186,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getSearchRadiusSquared",
            "desc": "Retrieves the search radius for a given radius given the region\ndiameter",
            "params": [
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "diameter",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "epsilon",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 218,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getNeighborsWithinRadius",
            "desc": "Adds all octree nod values to objectsFound\n\nSee basic algorithm:\nhttps://github.com/PointCloudLibrary/pcl/blob/29f192af57a3e7bdde6ff490669b211d8148378f/octree/include/pcl/octree/impl/octree_search.hpp#L309",
            "params": [
                {
                    "name": "region",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "radius",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "objectsFound",
                    "desc": "",
                    "lua_type": "{ T }"
                },
                {
                    "name": "nodeDistances2",
                    "desc": "",
                    "lua_type": "{ number }"
                },
                {
                    "name": "maxDepth",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 240,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getOrCreateSubRegionAtDepth",
            "desc": "Recursively ensures that a subregion exists at a given depth, and returns\nthat region for usage.",
            "params": [
                {
                    "name": "region",
                    "desc": "Top level region",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "maxDepth",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 288,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "createSubRegion",
            "desc": "Creates a subregion for an octree.",
            "params": [
                {
                    "name": "parentRegion",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "parentIndex",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 312,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "inRegionBounds",
            "desc": "Computes whether a region is in bounds.\n\nConsider regions to be range [px, y).",
            "params": [
                {
                    "name": "region",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 336,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getSubRegionIndex",
            "desc": "Gets a subregion's internal index.",
            "params": [
                {
                    "name": "region",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 355,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getTopLevelRegionHash",
            "desc": "This definitely collides fairly consistently\n\nSee: https://stackoverflow.com/questions/5928725/hashing-2d-3d-and-nd-vectors",
            "params": [
                {
                    "name": "cx",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "cy",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "cz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 377,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getTopLevelRegionCellIndex",
            "desc": "Computes the index for a top level cell given a position",
            "params": [
                {
                    "name": "maxRegionSize",
                    "desc": "",
                    "lua_type": "OctreeVector3"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "rpx",
                    "lua_type": "number"
                },
                {
                    "desc": "rpy",
                    "lua_type": "number"
                },
                {
                    "desc": "rpz",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 393,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getTopLevelRegionPosition",
            "desc": "Computes a top-level region's position",
            "params": [
                {
                    "name": "maxRegionSize",
                    "desc": "",
                    "lua_type": "OctreeVector3"
                },
                {
                    "name": "cx",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "cy",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "cz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 410,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "areEqualTopRegions",
            "desc": "Given a top-level region, returns if the region position are equal\nto this region",
            "params": [
                {
                    "name": "region",
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                },
                {
                    "name": "rpx",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "rpy",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "rpz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 426,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "findRegion",
            "desc": "Given a world space position, finds the current region in the hashmap",
            "params": [
                {
                    "name": "regionHashMap",
                    "desc": "",
                    "lua_type": "{ [number]: { OctreeRegion<T> } }"
                },
                {
                    "name": "maxRegionSize",
                    "desc": "",
                    "lua_type": "OctreeVector3"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeRegion3?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 443,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "getOrCreateRegion",
            "desc": "Gets the current region for a position, or creates a new one.",
            "params": [
                {
                    "name": "regionHashMap",
                    "desc": "",
                    "lua_type": "{ [number]: { OctreeRegion<T> } }"
                },
                {
                    "name": "maxRegionSize",
                    "desc": "",
                    "lua_type": "OctreeVector3"
                },
                {
                    "name": "px",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "py",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "pz",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OctreeRegion<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 472,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "OctreeVector3",
            "desc": "A Vector3 equivalent for octrees. This type is primarily internal and\nused for faster access than a Vector3.",
            "lua_type": "{ [1]: number, [2]: number, [3]: number }",
            "source": {
                "line": 57,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        },
        {
            "name": "OctreeRegion<T>",
            "desc": "An internal region which stores the data.",
            "fields": [
                {
                    "name": "subRegions",
                    "lua_type": "{ OctreeRegion<T> }",
                    "desc": ""
                },
                {
                    "name": "lowerBounds",
                    "lua_type": "OctreeVector3",
                    "desc": ""
                },
                {
                    "name": "upperBounds",
                    "lua_type": "OctreeVector3",
                    "desc": ""
                },
                {
                    "name": "position",
                    "lua_type": "OctreeVector3",
                    "desc": ""
                },
                {
                    "name": "size",
                    "lua_type": "OctreeVector3",
                    "desc": ""
                },
                {
                    "name": "parent",
                    "lua_type": "OctreeRegion<T>?",
                    "desc": ""
                },
                {
                    "name": "parentIndex",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "depth",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "nodes",
                    "lua_type": "{ OctreeNode<T> }",
                    "desc": ""
                },
                {
                    "name": "node_count",
                    "lua_type": "number",
                    "desc": ""
                }
            ],
            "source": {
                "line": 74,
                "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
            }
        }
    ],
    "name": "OctreeRegionUtils",
    "desc": "Octree implementation utilities. Primarily this utility code\nshould not be used directly and should be considered private to\nthe library.\n\nUse [Octree](/api/Octree) instead of this library directly.",
    "source": {
        "line": 11,
        "path": "src/octree/src/Shared/OctreeRegionUtils.lua"
    }
}