From 085f94579ab14ddcede9396871fc126a480e71cb Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Tue, 25 Sep 2018 00:53:12 +0100 Subject: [PATCH] Use named constant --- cube_tables.cpp | 2 +- cube_tables.h | 3 ++- voxel_map.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cube_tables.cpp b/cube_tables.cpp index bfcb976..ca1f146 100644 --- a/cube_tables.cpp +++ b/cube_tables.cpp @@ -138,7 +138,7 @@ const unsigned int g_edge_corners[EDGE_COUNT][2] = { }; // Order is irrelevant -const Vector3i g_moore_neighboring_3d[26] = { +const Vector3i g_moore_neighboring_3d[MOORE_NEIGHBORING_3D_COUNT] = { Vector3i(-1, -1, -1), Vector3i(0, -1, -1), Vector3i(1, -1, -1), diff --git a/cube_tables.h b/cube_tables.h index 904ee99..2c8ba04 100644 --- a/cube_tables.h +++ b/cube_tables.h @@ -9,6 +9,7 @@ namespace CubeTables { const unsigned int CORNER_COUNT = 8; const unsigned int EDGE_COUNT = 12; +const unsigned int MOORE_NEIGHBORING_3D_COUNT = 26; extern const Vector3 g_corner_position[CORNER_COUNT]; @@ -28,7 +29,7 @@ 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]; +extern const Vector3i g_moore_neighboring_3d[MOORE_NEIGHBORING_3D_COUNT]; } // namespace CubeTables diff --git a/voxel_map.cpp b/voxel_map.cpp index 4c1ee28..50c2cc6 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -1,7 +1,9 @@ #include "voxel_map.h" -#include "core/os/os.h" +#include "voxel_block.h" #include "cube_tables.h" +#include "core/os/os.h" + VoxelMap::VoxelMap() : _last_accessed_block(NULL) { @@ -102,7 +104,7 @@ bool VoxelMap::has_block(Vector3i pos) const { } bool VoxelMap::is_block_surrounded(Vector3i pos) const { - for (unsigned int i = 0; i < 26; ++i) { + for (unsigned int i = 0; i < CubeTables::MOORE_NEIGHBORING_3D_COUNT; ++i) { Vector3i bpos = pos + CubeTables::g_moore_neighboring_3d[i]; if (!has_block(bpos)) { return false;