OctreeNode
Basic node interacting with the octree. See Octree for usage.
local octree = Octree.new()
local node = octree:CreateNode(Vector3.new(0, 0, 0), "A")
print(octree:RadiusSearch(Vector3.new(0, 0, 0), 100)) --> { "A" }
node:Destroy() -- Remove node from octree
print(octree:RadiusSearch(Vector3.new(0, 0, 0), 100)) --> { }
Functions
KNearestNeighborsSearch
OctreeNode:
KNearestNeighborsSearch
(
k:
number
,
--
The number to retrieve
radius:
number
--
The radius to search in
) →
(
{
T
}
,
--
Objects found, including self
{
number
}
--
Distances squared
)
Finds the nearest neighbors to this node within the radius
local octree = Octree.new()
local node = octree:CreateNode(Vector3.new(0, 0, 0), "A")
octree:CreateNode(Vector3.new(0, 0, 5), "B")
print(octree:KNearestNeighborsSearch(10, 100)) --> { "A", "B" } { 0, 25 }
GetObject
OctreeNode:
GetObject
(
) →
T
Returns the object stored in the octree
local octree = Octree.new()
local node = octree:CreateNode(Vector3.new(0, 0, 0), "A")
print(octree:GetObject()) --> "A"
RadiusSearch
OctreeNode:
RadiusSearch
(
radius:
number
--
The radius to search in
) →
(
{
any
}
,
--
Objects found
{
number
}
--
Distances squared
)
Finds the nearest neighbors to the octree node
GetPosition
Retrieves the position
GetRawPosition
OctreeNode:
GetRawPosition
(
) →
(
number
,
--
px
number
,
--
py
number
--
pz
)
Retrieves the as px, py, pz
SetPosition
Sets the position of the octree nodes and updates the octree accordingly
local octree = Octree.new()
local node = octree:CreateNode(Vector3.new(0, 0, 0), "A")
print(octree:RadiusSearch(Vector3.new(0, 0, 0), 100)) --> { "A" }
node:SetPosition(Vector3.new(1000, 0, 0))
print(octree:RadiusSearch(Vector3.new(0, 0, 0), 100)) --> {}
Destroy
OctreeNode:
Destroy
(
) →
(
)
Removes the OctreeNode from the octree