mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-11-19 02:47:18 +01:00
Moved moore neighboring to cube tables
This commit is contained in:
parent
cb548234fc
commit
aa4d04d1a0
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user