diff --git a/cube_tables.cpp b/cube_tables.cpp index 2e2484e..bfcb976 100644 --- a/cube_tables.cpp +++ b/cube_tables.cpp @@ -137,5 +137,38 @@ const unsigned int g_edge_corners[EDGE_COUNT][2] = { { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 } }; +// Order is irrelevant +const Vector3i g_moore_neighboring_3d[26] = { + Vector3i(-1, -1, -1), + Vector3i(0, -1, -1), + Vector3i(1, -1, -1), + Vector3i(-1, -1, 0), + Vector3i(0, -1, 0), + Vector3i(1, -1, 0), + Vector3i(-1, -1, 1), + Vector3i(0, -1, 1), + Vector3i(1, -1, 1), + + Vector3i(-1, 0, -1), + Vector3i(0, 0, -1), + Vector3i(1, 0, -1), + Vector3i(-1, 0, 0), + //Vector3i(0,0,0), + Vector3i(1, 0, 0), + Vector3i(-1, 0, 1), + Vector3i(0, 0, 1), + Vector3i(1, 0, 1), + + Vector3i(-1, 1, -1), + Vector3i(0, 1, -1), + Vector3i(1, 1, -1), + Vector3i(-1, 1, 0), + Vector3i(0, 1, 0), + Vector3i(1, 1, 0), + Vector3i(-1, 1, 1), + Vector3i(0, 1, 1), + Vector3i(1, 1, 1), +}; + } // namespace CubeTables diff --git a/cube_tables.h b/cube_tables.h index 88285b7..a7abc5c 100644 --- a/cube_tables.h +++ b/cube_tables.h @@ -28,6 +28,8 @@ extern const Vector3i g_edge_inormals[EDGE_COUNT]; extern const unsigned int g_edge_corners[EDGE_COUNT][2]; +extern const Vector3i g_moore_neighboring_3d[26]; + } // namespace CubeTables diff --git a/voxel_map.cpp b/voxel_map.cpp index 16b6dad..5b22a3e 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -1,5 +1,6 @@ #include "voxel_map.h" #include "core/os/os.h" +#include "cube_tables.h" //---------------------------------------------------------------------------- // VoxelBlock @@ -134,41 +135,9 @@ bool VoxelMap::has_block(Vector3i pos) const { return /*(_last_accessed_block != NULL && _last_accessed_block->pos == pos) ||*/ _blocks.has(pos); } -Vector3i g_moore_neighboring_3d[26] = { - Vector3i(-1, -1, -1), - Vector3i(0, -1, -1), - Vector3i(1, -1, -1), - Vector3i(-1, -1, 0), - Vector3i(0, -1, 0), - Vector3i(1, -1, 0), - Vector3i(-1, -1, 1), - Vector3i(0, -1, 1), - Vector3i(1, -1, 1), - - Vector3i(-1, 0, -1), - Vector3i(0, 0, -1), - Vector3i(1, 0, -1), - Vector3i(-1, 0, 0), - //Vector3i(0,0,0), - Vector3i(1, 0, 0), - Vector3i(-1, 0, 1), - Vector3i(0, 0, 1), - Vector3i(1, 0, 1), - - Vector3i(-1, 1, -1), - Vector3i(0, 1, -1), - Vector3i(1, 1, -1), - Vector3i(-1, 1, 0), - Vector3i(0, 1, 0), - Vector3i(1, 1, 0), - Vector3i(-1, 1, 1), - Vector3i(0, 1, 1), - Vector3i(1, 1, 1), -}; - bool VoxelMap::is_block_surrounded(Vector3i pos) const { for (unsigned int i = 0; i < 26; ++i) { - Vector3i bpos = pos + g_moore_neighboring_3d[i]; + Vector3i bpos = pos + CubeTables::g_moore_neighboring_3d[i]; if (!has_block(bpos)) { return false; }