diff --git a/terrain/lod_octree.h b/terrain/lod_octree.h index b9624917..3ed74b28 100644 --- a/terrain/lod_octree.h +++ b/terrain/lod_octree.h @@ -3,14 +3,13 @@ #include "../math/vector3i.h" #include "../octree_tables.h" -#include "../util/object_pool.h" // Octree designed to handle level of detail. template class LodOctree { public: static const unsigned int NO_CHILDREN = -1; - static const unsigned int ROOT_INDEX = -1; + static const unsigned int ROOT_INDEX = -1; // Root node isn't stored in pool static const unsigned int MAX_LOD = 32; struct Node { @@ -48,6 +47,7 @@ public: // Warning: the returned pointer may be invalidated later by `allocate_children`. Use with care. inline Node *get_node(unsigned int i) { CRASH_COND(i >= _nodes.size()); + CRASH_COND(i == ROOT_INDEX); return &_nodes[i]; } @@ -155,11 +155,6 @@ public: } } - // template - // void foreach_node(A &action) { - // action(action, &_root, _max_depth); - // } - static inline Vector3i get_child_position(Vector3i parent_position, int i) { return Vector3i( parent_position.x * 2 + OctreeTables::g_octant_position[i][0], @@ -168,16 +163,6 @@ public: } private: - // template - // void foreach_node(A action, Node *node, int lod) { - // action(node, lod); - // if (node->has_children()) { - // for (int i = 0; i < 8; ++i) { - // foreach_node(action, node->children[i], lod - 1); - // } - // } - // } - inline Node *get_node(unsigned int index) { if (index == ROOT_INDEX) { return &_root; diff --git a/terrain/voxel_lod_terrain.cpp b/terrain/voxel_lod_terrain.cpp index 522c4602..f563f7ef 100644 --- a/terrain/voxel_lod_terrain.cpp +++ b/terrain/voxel_lod_terrain.cpp @@ -585,6 +585,7 @@ void VoxelLodTerrain::_process() { // Here we go... // Remove blocks falling out of block region extent + // TODO Obsoleted by octree grid? { // TODO Could it actually be enough to have a rolling update on all blocks? @@ -644,7 +645,7 @@ void VoxelLodTerrain::_process() { // Create and remove octrees in a grid around the viewer { - // TODO Investigate if multi-octree can produce cracks in the terrain + // TODO Investigate if multi-octree can produce cracks in the terrain (so far I haven't noticed) // TODO Need to work when lod count changes at runtime unsigned int octree_size_po2 = get_block_size_pow2() + get_lod_count() - 1; @@ -711,6 +712,7 @@ void VoxelLodTerrain::_process() { CRASH_COND(self->_lod_octrees.has(pos)); // Create new octree + // TODO Use ObjectPool to store them, deletion won't be cheap Map::Element *E = self->_lod_octrees.insert(pos, OctreeItem()); CRASH_COND(E == nullptr); OctreeItem &item = E->value();