Moved the VoxelNeighbours enum from the old voxel, to the new mesher, also bound it.

This commit is contained in:
Relintai 2019-07-14 02:18:18 +02:00
parent ecfcf79f07
commit 3d550a0772
3 changed files with 85 additions and 43 deletions

View File

@ -23,48 +23,7 @@ class Voxel : public Reference {
GDCLASS(Voxel, Reference);
public:
enum VoxelNeighbours {
NEIGHBOUR_NONE = 0,
NEIGHBOUR_LEFT = 1 << 0,
NEIGHBOUR_RIGHT = 1 << 1,
NEIGHBOUR_FRONT = 1 << 2,
NEIGHBOUR_BACK = 1 << 3,
NEIGHBOUR_TOP = 1 << 4,
NEIGHBOUR_DOWN = 1 << 5,
NEIGHBOUR_LEFT_FRONT = 1 << 6,
NEIGHBOUR_LEFT_BACK = 1 << 7,
NEIGHBOUR_RIGHT_FRONT = 1 << 8,
NEIGHBOUR_RIGHT_BACK = 1 << 9,
NEIGHBOUR_TOP_LEFT = 1 << 10,
NEIGHBOUR_TOP_RIGHT = 1 << 11,
NEIGHBOUR_TOP_FRONT = 1 << 12,
NEIGHBOUR_TOP_BACK = 1 << 13,
NEIGHBOUR_BOTTOM_LEFT = 1 << 14,
NEIGHBOUR_BOTTOM_RIGHT = 1 << 15,
NEIGHBOUR_BOTTOM_FRONT = 1 << 16,
NEIGHBOUR_BOTTOM_BACK = 1 << 17,
NEIGHBOUR_BOTTOM_LEFT_FRONT = 1 << 18,
NEIGHBOUR_BOTTOM_LEFT_BACK = 1 << 19,
NEIGHBOUR_BOTTOM_RIGHT_FRONT = 1 << 20,
NEIGHBOUR_BOTTOM_RIGHT_BACK = 1 << 21,
NEIGHBOUR_TOP_LEFT_FRONT = 1 << 22,
NEIGHBOUR_TOP_LEFT_BACK = 1 << 23,
NEIGHBOUR_TOP_RIGHT_FRONT = 1 << 24,
NEIGHBOUR_TOP_RIGHT_BACK = 1 << 25,
FULL_NEIGHBOURS_CROSS = NEIGHBOUR_LEFT | NEIGHBOUR_RIGHT | NEIGHBOUR_BACK | NEIGHBOUR_FRONT | NEIGHBOUR_TOP | NEIGHBOUR_DOWN, // | NEIGHBOUR_LEFT_BACK | NEIGHBOUR_LEFT_FRONT | NEIGHBOUR_RIGHT_BACK | NEIGHBOUR_RIGHT_FRONT;
FULL_SIDE_NEIGHBOURS = NEIGHBOUR_LEFT | NEIGHBOUR_RIGHT | NEIGHBOUR_BACK | NEIGHBOUR_FRONT,
FULL_SIDE_NEIGHBOURS_TOP = NEIGHBOUR_LEFT | NEIGHBOUR_RIGHT | NEIGHBOUR_BACK | NEIGHBOUR_FRONT | NEIGHBOUR_TOP,
FULL_SIDE_NEIGHBOURS_DOWN = NEIGHBOUR_LEFT | NEIGHBOUR_RIGHT | NEIGHBOUR_BACK | NEIGHBOUR_FRONT | NEIGHBOUR_DOWN,
};
static const unsigned int FACE_COUNT = 6;
int get_neighbours();

View File

@ -6,5 +6,44 @@ VoxelMesherCubic::VoxelMesherCubic() {
void VoxelMesherCubic::_bind_methods() {
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_NONE);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT_BACK);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT);
BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT_BACK);
BIND_ENUM_CONSTANT(VOXEL_FULL_NEIGHBOURS_CROSS);
BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS);
BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS_TOP);
BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS_DOWN);
}

View File

@ -7,6 +7,48 @@ class VoxelMesherCubic : public VoxelMesher {
GDCLASS(VoxelMesherCubic, VoxelMesher);
public:
enum VoxelNeighbours {
VOXEL_NEIGHBOUR_NONE = 0,
VOXEL_NEIGHBOUR_LEFT = 1 << 0,
VOXEL_NEIGHBOUR_RIGHT = 1 << 1,
VOXEL_NEIGHBOUR_FRONT = 1 << 2,
VOXEL_NEIGHBOUR_BACK = 1 << 3,
VOXEL_NEIGHBOUR_TOP = 1 << 4,
VOXEL_NEIGHBOUR_BOTTOM = 1 << 5,
VOXEL_NEIGHBOUR_LEFT_FRONT = 1 << 6,
VOXEL_NEIGHBOUR_LEFT_BACK = 1 << 7,
VOXEL_NEIGHBOUR_RIGHT_FRONT = 1 << 8,
VOXEL_NEIGHBOUR_RIGHT_BACK = 1 << 9,
VOXEL_NEIGHBOUR_TOP_LEFT = 1 << 10,
VOXEL_NEIGHBOUR_TOP_RIGHT = 1 << 11,
VOXEL_NEIGHBOUR_TOP_FRONT = 1 << 12,
VOXEL_NEIGHBOUR_TOP_BACK = 1 << 13,
VOXEL_NEIGHBOUR_BOTTOM_LEFT = 1 << 14,
VOXEL_NEIGHBOUR_BOTTOM_RIGHT = 1 << 15,
VOXEL_NEIGHBOUR_BOTTOM_FRONT = 1 << 16,
VOXEL_NEIGHBOUR_BOTTOM_BACK = 1 << 17,
VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT = 1 << 18,
VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK = 1 << 19,
VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT = 1 << 20,
VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK = 1 << 21,
VOXEL_NEIGHBOUR_TOP_LEFT_FRONT = 1 << 22,
VOXEL_NEIGHBOUR_TOP_LEFT_BACK = 1 << 23,
VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT = 1 << 24,
VOXEL_NEIGHBOUR_TOP_RIGHT_BACK = 1 << 25,
VOXEL_FULL_NEIGHBOURS_CROSS = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_TOP | VOXEL_NEIGHBOUR_BOTTOM, // | VOXEL_NEIGHBOUR_LEFT_BACK | VOXEL_NEIGHBOUR_LEFT_FRONT | VOXEL_NEIGHBOUR_RIGHT_BACK | VOXEL_NEIGHBOUR_RIGHT_FRONT;
VOXEL_FULL_SIDE_NEIGHBOURS = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT,
VOXEL_FULL_SIDE_NEIGHBOURS_TOP = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_TOP,
VOXEL_FULL_SIDE_NEIGHBOURS_DOWN = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_BOTTOM,
};
VoxelMesherCubic();
protected:
@ -14,4 +56,6 @@ protected:
};
VARIANT_ENUM_CAST(VoxelMesherCubic::VoxelNeighbours);
#endif