Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CKDTree3f Class Reference

3D KD-tree for nearest-neighbor lookup of user data. More...

#include <Utils/CKDTree3f.h>

Classes

struct  SKDNode
 Node stored in the KD-tree. More...

Public Member Functions

 CKDTree3f ()
 Construct an empty KD-tree.
virtual ~CKDTree3f ()
 Destroy the KD-tree and release all node blocks.
void insert (const core::vector3df &pos, void *data)
 Insert a point and payload into the tree.
void insert (float x, float y, float z, void *data)
 Insert a point and payload into the tree.
void clear ()
 Remove all nodes from the tree.
SKDNodenearest (const core::vector3df &pos)
 Find the node nearest to a point.
SKDNodenearest (float x, float y, float z)
 Find the node nearest to a point.
SKDNodenearest (const float *pos)
 Find the node nearest to a point.
int nearestRange (const core::vector3df &pos, float range, core::array< SKDNode * > &outResults)
 Find all nodes within a radius of a point.
int nearestRange (const float *pos, float range, core::array< SKDNode * > &outResults)
 Find all nodes within a radius of a point.

Protected Attributes

SKDNodem_root

Detailed Description

3D KD-tree for nearest-neighbor lookup of user data.

The tree stores raw void* payload pointers and does not own or delete the payloads. Nodes are allocated in fixed-size blocks and released when the tree is cleared.

Member Function Documentation

◆ clear()

void Skylicht::CKDTree3f::clear ( )

Remove all nodes from the tree.

Payload pointers are not deleted.

◆ insert() [1/2]

void Skylicht::CKDTree3f::insert ( const core::vector3df & pos,
void * data )
inline

Insert a point and payload into the tree.

Parameters
posPoint position.
dataUser payload pointer. Ownership remains with the caller.

◆ insert() [2/2]

void Skylicht::CKDTree3f::insert ( float x,
float y,
float z,
void * data )

Insert a point and payload into the tree.

Parameters
xX coordinate.
yY coordinate.
zZ coordinate.
dataUser payload pointer. Ownership remains with the caller.

◆ nearest() [1/3]

SKDNode * Skylicht::CKDTree3f::nearest ( const core::vector3df & pos)
inline

Find the node nearest to a point.

Parameters
posQuery position.
Returns
Nearest node, or null when the tree is empty.

◆ nearest() [2/3]

SKDNode * Skylicht::CKDTree3f::nearest ( const float * pos)

Find the node nearest to a point.

Parameters
posPointer to three floats: X, Y, Z.
Returns
Nearest node, or null when the tree is empty.

◆ nearest() [3/3]

SKDNode * Skylicht::CKDTree3f::nearest ( float x,
float y,
float z )

Find the node nearest to a point.

Parameters
xQuery X coordinate.
yQuery Y coordinate.
zQuery Z coordinate.
Returns
Nearest node, or null when the tree is empty.

◆ nearestRange() [1/2]

int Skylicht::CKDTree3f::nearestRange ( const core::vector3df & pos,
float range,
core::array< SKDNode * > & outResults )
inline

Find all nodes within a radius of a point.

Parameters
posQuery position.
rangeSearch radius.
outResultsReceives matching nodes sorted by distance.
Returns
Number of results.

◆ nearestRange() [2/2]

int Skylicht::CKDTree3f::nearestRange ( const float * pos,
float range,
core::array< SKDNode * > & outResults )

Find all nodes within a radius of a point.

Parameters
posPointer to three floats: X, Y, Z.
rangeSearch radius.
outResultsReceives matching nodes sorted by distance.
Returns
Number of results.

The documentation for this class was generated from the following file: