Use named constant

This commit is contained in:
Marc Gilleron 2018-09-25 00:53:12 +01:00
parent a0026dbbeb
commit 085f94579a
3 changed files with 7 additions and 4 deletions

View File

@ -138,7 +138,7 @@ const unsigned int g_edge_corners[EDGE_COUNT][2] = {
}; };
// Order is irrelevant // 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(-1, -1, -1),
Vector3i(0, -1, -1), Vector3i(0, -1, -1),
Vector3i(1, -1, -1), Vector3i(1, -1, -1),

View File

@ -9,6 +9,7 @@ namespace CubeTables {
const unsigned int CORNER_COUNT = 8; const unsigned int CORNER_COUNT = 8;
const unsigned int EDGE_COUNT = 12; const unsigned int EDGE_COUNT = 12;
const unsigned int MOORE_NEIGHBORING_3D_COUNT = 26;
extern const Vector3 g_corner_position[CORNER_COUNT]; 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 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 } // namespace CubeTables

View File

@ -1,7 +1,9 @@
#include "voxel_map.h" #include "voxel_map.h"
#include "core/os/os.h" #include "voxel_block.h"
#include "cube_tables.h" #include "cube_tables.h"
#include "core/os/os.h"
VoxelMap::VoxelMap() VoxelMap::VoxelMap()
: _last_accessed_block(NULL) { : _last_accessed_block(NULL) {
@ -102,7 +104,7 @@ bool VoxelMap::has_block(Vector3i pos) const {
} }
bool VoxelMap::is_block_surrounded(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]; Vector3i bpos = pos + CubeTables::g_moore_neighboring_3d[i];
if (!has_block(bpos)) { if (!has_block(bpos)) {
return false; return false;