|
Kemena3D
|
Loose octree that spatially indexes scene meshes for frustum culling. More...
#include <koctree.h>
Public Member Functions | |
| kOctree (int maxDepth=6, int maxObjectsPerNode=8) | |
| Construct an empty octree with the given subdivision limits. | |
| ~kOctree () | |
| Destroy the octree and release all nodes. | |
| void | build (kScene *scene) |
| Rebuild the tree from all loaded meshes in the scene. | |
| std::vector< kMesh * > | queryVisible (const kFrustum &frustum) const |
| Return all meshes whose world AABB intersects the frustum. | |
| void | clear () |
| Discard all nodes and mesh references. | |
| int | getNodeCount () const |
| Get the total number of nodes currently in the tree. | |
| int | getMeshCount () const |
| Get the total number of meshes indexed by the tree. | |
| void | traverse (const std::function< void(const kAABB &, int, bool)> &visitor) const |
| Visit every node in the tree top-down. | |
Loose octree that spatially indexes scene meshes for frustum culling.
Usage per frame:
| kemena::kOctree::kOctree | ( | int | maxDepth = 6, |
| int | maxObjectsPerNode = 8 ) |
Construct an empty octree with the given subdivision limits.
| maxDepth | Maximum recursion depth (default 6). |
| maxObjectsPerNode | Meshes per leaf before subdivision (default 8). |
| kemena::kOctree::~kOctree | ( | ) |
Destroy the octree and release all nodes.
| void kemena::kOctree::build | ( | kScene * | scene | ) |
Rebuild the tree from all loaded meshes in the scene.
Computes world-space AABBs, derives world bounds, then inserts every mesh into the appropriate octree node. Call once per frame (or whenever the scene changes).
| void kemena::kOctree::clear | ( | ) |
Discard all nodes and mesh references.
|
inline |
Get the total number of meshes indexed by the tree.
| int kemena::kOctree::getNodeCount | ( | ) | const |
Get the total number of nodes currently in the tree.
Return all meshes whose world AABB intersects the frustum.
Traverses the tree top-down; entire subtrees whose bounds are outside the frustum are skipped, and subtrees fully inside are collected without further plane tests.
| void kemena::kOctree::traverse | ( | const std::function< void(const kAABB &, int, bool)> & | visitor | ) | const |
Visit every node in the tree top-down.
The callback receives the node's world-space AABB, its depth (root = 0), and whether it is a leaf node. Useful for debug visualization.
| visitor | Callable: void(const kAABB &bounds, int depth, bool isLeaf) |

