mirror of
https://github.com/Relintai/godot_voxel.git
synced 2025-03-11 21:53:24 +01:00
Put LodOctree child position calculation in a function
This commit is contained in:
parent
f0089dce8b
commit
8850019dc4
@ -104,6 +104,13 @@ public:
|
||||
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],
|
||||
parent_position.y * 2 + OctreeTables::g_octant_position[i][1],
|
||||
parent_position.z * 2 + OctreeTables::g_octant_position[i][2]);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename A>
|
||||
void foreach_node(A action, Node *node, int lod) {
|
||||
@ -133,10 +140,7 @@ private:
|
||||
|
||||
Node *child = _pool.create();
|
||||
|
||||
child->position.x = node->position.x * 2 + OctreeTables::g_octant_position[i][0];
|
||||
child->position.y = node->position.y * 2 + OctreeTables::g_octant_position[i][1];
|
||||
child->position.z = node->position.z * 2 + OctreeTables::g_octant_position[i][2];
|
||||
|
||||
child->position = get_child_position(node->position, i);
|
||||
child->block = create_action(child, lod - 1);
|
||||
|
||||
node->children[i] = child;
|
||||
|
@ -679,13 +679,7 @@ void VoxelLodTerrain::_process() {
|
||||
|
||||
// Can only subdivide if higher detail meshes are ready to be shown, otherwise it will produce holes
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
|
||||
Vector3i child_pos = node->position;
|
||||
|
||||
child_pos.x = node->position.x * 2 + OctreeTables::g_octant_position[i][0];
|
||||
child_pos.y = node->position.y * 2 + OctreeTables::g_octant_position[i][1];
|
||||
child_pos.z = node->position.z * 2 + OctreeTables::g_octant_position[i][2];
|
||||
|
||||
Vector3i child_pos = LodOctree<bool>::get_child_position(node->position, i);
|
||||
VoxelBlock *block = lod.map->get_block(child_pos);
|
||||
if (block == nullptr || !block->has_been_meshed) {
|
||||
return false;
|
||||
|
@ -110,7 +110,6 @@ private:
|
||||
|
||||
// Members for memory caching
|
||||
std::vector<Vector3i> blocks_to_load;
|
||||
//std::vector<Vector3i> blocks_to_update;
|
||||
};
|
||||
|
||||
Lod _lods[MAX_LOD];
|
||||
|
Loading…
Reference in New Issue
Block a user