More work on the build, and more api breakages.

This commit is contained in:
Relintai 2019-11-18 20:16:29 +01:00
parent 4a5a903a7a
commit b60b8a96d6
6 changed files with 227 additions and 212 deletions

View File

@ -176,25 +176,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
int z = _z;
//000
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
/*
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT;*/
_point_neighbours[P000] = neighbours;
@ -205,25 +205,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z;
//100
if (buffer->get_voxel(x + 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
/*
if (buffer->get_voxel(x + 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
if (buffer->get_voxel(x + 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT;
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
if (buffer->get_voxel(x + 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT;*/
_point_neighbours[P100] = neighbours;
@ -234,25 +234,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z;
//010
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
if (buffer->get_voxel(x, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
/*
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
if (buffer->get_voxel(x - 1, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
if (buffer->get_voxel(x, y + 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
if (buffer->get_voxel(x - 1, y + 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_FRONT;*/
_point_neighbours[P010] = neighbours;
@ -263,25 +263,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z;
//110
if (buffer->get_voxel(x + 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
if (buffer->get_voxel(x, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
/*
if (buffer->get_voxel(x + 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
if (buffer->get_voxel(x + 1, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT;
if (buffer->get_voxel(x, y + 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
if (buffer->get_voxel(x + 1, y + 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT;*/
_point_neighbours[P110] = neighbours;
@ -292,25 +292,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z + 1;
//001
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
if (buffer->get_voxel(x, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
/*
if (buffer->get_voxel(x - 1, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
if (buffer->get_voxel(x, y - 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
if (buffer->get_voxel(x - 1, y - 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK;*/
_point_neighbours[P001] = neighbours;
@ -322,25 +322,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z + 1;
//101
if (buffer->get_voxel(x + 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
if (buffer->get_voxel(x, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
/*
if (buffer->get_voxel(x + 1, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
if (buffer->get_voxel(x + 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT;
if (buffer->get_voxel(x, y - 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
if (buffer->get_voxel(x + 1, y - 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK;*/
_point_neighbours[P101] = neighbours;
@ -351,25 +351,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z + 1;
//011
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
if (buffer->get_voxel(x, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
if (buffer->get_voxel(x, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
/*
if (buffer->get_voxel(x - 1, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
if (buffer->get_voxel(x - 1, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
if (buffer->get_voxel(x, y + 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
if (buffer->get_voxel(x - 1, y + 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x - 1, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_BACK;*/
_point_neighbours[P011] = neighbours;
@ -381,25 +381,25 @@ void VoxelCubePoints::refresh_neighbours(const VoxelChunk *buffer) {
z = _z + 1;
//111
if (buffer->get_voxel(x + 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
if (buffer->get_voxel(x, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
if (buffer->get_voxel(x, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
/*
if (buffer->get_voxel(x + 1, y, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
if (buffer->get_voxel(x + 1, y + 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT;
if (buffer->get_voxel(x, y + 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
if (buffer->get_voxel(x + 1, y + 1, z + 1, VoxelBuffer::CHANNEL_TYPE) != 0)
if (buffer->get_voxel(x + 1, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_BACK;*/
_point_neighbours[P111] = neighbours;
@ -416,44 +416,44 @@ void VoxelCubePoints::setup(const VoxelChunk *buffer, int x, int y, int z, int s
_z = z;
_size = size;
_point_types[P000] = buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_TYPE);
_point_types[P100] = buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_TYPE);
_point_types[P010] = buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_TYPE);
_point_types[P001] = buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_TYPE);
_point_types[P110] = buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_TYPE);
_point_types[P011] = buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_TYPE);
_point_types[P101] = buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_TYPE);
_point_types[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_TYPE);
_point_types[P000] = buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P100] = buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P010] = buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P001] = buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P110] = buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P011] = buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P101] = buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
_point_types[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
if (!has_points())
return;
_point_fills[P000] = buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P100] = buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P010] = buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P001] = buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P110] = buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P011] = buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P101] = buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
_point_fills[P000] = buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P100] = buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P010] = buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P001] = buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P110] = buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P011] = buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P101] = buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_fills[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
_point_aos[P000] = buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_AO);
_point_aos[P100] = buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_AO);
_point_aos[P010] = buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_AO);
_point_aos[P001] = buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_AO);
_point_aos[P110] = buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_AO);
_point_aos[P011] = buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_AO);
_point_aos[P101] = buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_AO);
_point_aos[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_AO);
_point_aos[P000] = buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P100] = buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P010] = buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P001] = buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P110] = buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P011] = buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P101] = buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_aos[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
_point_colors[P000] = Color(buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P100] = Color(buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P010] = Color(buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P001] = Color(buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P110] = Color(buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y + size, z, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P011] = Color(buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P101] = Color(buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P111] = Color(buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P000] = Color(buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P100] = Color(buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P010] = Color(buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P001] = Color(buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P110] = Color(buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P011] = Color(buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P101] = Color(buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
_point_colors[P111] = Color(buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
refresh_neighbours(buffer);

View File

@ -4,6 +4,8 @@
#include "core/reference.h"
#include "core/vector.h"
#include "../../world/voxel_chunk.h"
class SubVoxelFacePointsHelper;
class VoxelCubePoints : public Reference {

View File

@ -1,13 +1,12 @@
#include "voxel_mesher_cubic.h"
void VoxelMesherCubic::_add_buffer(VoxelChunk *buffer) {
buffer->generate_ao();
void VoxelMesherCubic::_add_buffer(VoxelChunk *chunk) {
chunk->generate_ao();
Vector3i bfs = buffer->get_size();
int x_size = bfs.x - 1;
int y_size = bfs.y - 1;
int z_size = bfs.z - 1;
int x_size = chunk->get_size_x() - 1;
int y_size = chunk->get_size_x() - 1;
int z_size = chunk->get_size_x() - 1;
float lod_size = get_lod_size();
float voxel_size = get_lod_size();
@ -23,7 +22,7 @@ void VoxelMesherCubic::_add_buffer(VoxelChunk *buffer) {
for (int z = 1; z < z_size - 1; z += lod_size) {
for (int x = 1; x < x_size - 1; x += lod_size) {
cube_points->setup(buffer, x, y, z, lod_size);
cube_points->setup(chunk, x, y, z, lod_size);
if (!cube_points->has_points())
continue;

View File

@ -13,7 +13,7 @@ class VoxelMesherCubic : public VoxelMesher {
GDCLASS(VoxelMesherCubic, VoxelMesher);
public:
void _add_buffer(VoxelChunk *buffer);
void _add_buffer(VoxelChunk *chunk);
VoxelMesherCubic();
~VoxelMesherCubic();

View File

@ -16,46 +16,46 @@ _FORCE_INLINE_ void VoxelChunk::set_state(int value) {
_state = value;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_x() {
return _chunk_position_x;
_FORCE_INLINE_ int VoxelChunk::get_position_x() {
return _position_x;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_y() {
return _chunk_position_y;
_FORCE_INLINE_ int VoxelChunk::get_position_y() {
return _position_y;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_position_z() {
return _chunk_position_z;
_FORCE_INLINE_ int VoxelChunk::get_position_z() {
return _position_z;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_position() const {
return Vector3(_chunk_position_x, _chunk_position_y, _chunk_position_z);
_FORCE_INLINE_ Vector3 VoxelChunk::get_position() const {
return Vector3(_position_x, _position_y, _position_z);
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_x() {
return _chunk_size_x;
_FORCE_INLINE_ int VoxelChunk::get_size_x() {
return _size_x;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_y() {
return _chunk_size_y;
_FORCE_INLINE_ int VoxelChunk::get_size_y() {
return _size_y;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_size_z() {
return _chunk_size_z;
_FORCE_INLINE_ int VoxelChunk::get_size_z() {
return _size_z;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_size() const {
return Vector3(_chunk_size_x, _chunk_size_y, _chunk_size_z);
_FORCE_INLINE_ Vector3 VoxelChunk::get_size() const {
return Vector3(_size_x, _size_y, _size_z);
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_x() {
return _chunk_data_size_x;
_FORCE_INLINE_ int VoxelChunk::get_data_size_x() {
return _data_size_x;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_y() {
return _chunk_data_size_y;
_FORCE_INLINE_ int VoxelChunk::get_data_size_y() {
return _data_size_y;
}
_FORCE_INLINE_ int VoxelChunk::get_chunk_data_size_z() {
return _chunk_data_size_z;
_FORCE_INLINE_ int VoxelChunk::get_data_size_z() {
return _data_size_z;
}
_FORCE_INLINE_ Vector3 VoxelChunk::get_chunk_data_size() const {
return Vector3(_chunk_data_size_x, _chunk_data_size_y, _chunk_data_size_z);
_FORCE_INLINE_ Vector3 VoxelChunk::get_data_size() const {
return Vector3(_data_size_x, _data_size_y, _data_size_z);
}
_FORCE_INLINE_ int VoxelChunk::get_margin_start() const {
@ -178,45 +178,45 @@ RID VoxelChunk::get_clutter_mesh_instance_rid() {
}
//Voxel Data
void VoxelBuffer::set_size(int size_x, int size_y, int siye_z, int margin_start = 0, int margin_end = 0) {
void VoxelChunk::set_size(int size_x, int size_y, int siye_z, int margin_start = 0, int margin_end = 0) {
}
void VoxelBuffer::set_channel_count(int value) {
void VoxelChunk::set_channel_count(int value) {
}
void VoxelBuffer::validate_channel_index(int x, int y, int z, int channel_index) {
void VoxelChunk::validate_channel_index(int x, int y, int z, int channel_index) {
}
uint8_t VoxelBuffer::get_voxel(int x, int y, int z, int channel_index) {
uint8_t VoxelChunk::get_voxel(int x, int y, int z, int channel_index) {
}
void VoxelBuffer::set_voxel(uint8_t value, int x, int y, int z, int channel_index) {
void VoxelChunk::set_voxel(uint8_t value, int x, int y, int z, int channel_index) {
}
void VoxelBuffer::set_channel_count(int count) {
void VoxelChunk::set_channel_count(int count) {
}
void VoxelBuffer::allocate_channel(int channel_index, uint8_t value = 0) {
void VoxelChunk::allocate_channel(int channel_index, uint8_t value = 0) {
}
void VoxelBuffer::fill_channel(int channel_index) {
void VoxelChunk::fill_channel(int channel_index) {
}
void VoxelBuffer::dealloc_channel(int channel_index) {
void VoxelChunk::dealloc_channel(int channel_index) {
}
uint8_t *VoxelBuffer::get_channel(int channel_index) {
uint8_t *VoxelChunk::get_channel(int channel_index) {
}
uint8_t *VoxelBuffer::get_valid_channel(int channel_index) {
uint8_t *VoxelChunk::get_valid_channel(int channel_index) {
}
//Data Management functions
void VoxelBuffer::generate_ao() {
void VoxelChunk::generate_ao() {
unsigned int size_x = _actual_size_x;
unsigned int size_y = _actual_size_y;
unsigned int size_z = _actual_size_z;
@ -248,7 +248,7 @@ void VoxelBuffer::generate_ao() {
}
}
void VoxelBuffer::add_light(int local_x, int local_y, int local_z, int size, Color color) {
void VoxelChunk::add_light(int local_x, int local_y, int local_z, int size, Color color) {
ERR_FAIL_COND(size < 0);
int size_x = _actual_size_actual_size_xx;
@ -306,7 +306,7 @@ void VoxelBuffer::add_light(int local_x, int local_y, int local_z, int size, Col
}
}
}
void VoxelBuffer::clear_lights() {
void VoxelChunk::clear_lights() {
fill_channel(0, CHANNEL_LIGHT_COLOR_R);
fill_channel(0, CHANNEL_LIGHT_COLOR_G);
fill_channel(0, CHANNEL_LIGHT_COLOR_B);
@ -456,7 +456,7 @@ void VoxelChunk::create_colliders() {
PhysicsServer::get_singleton()->body_add_shape(_body_rid, _shape_rid);
PhysicsServer::get_singleton()->body_set_state(_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
PhysicsServer::get_singleton()->body_set_state(_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
PhysicsServer::get_singleton()->body_set_space(_body_rid, get_voxel_world()->get_world()->get_space());
}
@ -495,8 +495,8 @@ void VoxelChunk::create_voxel_light(const Color color, const int size, const int
Ref<VoxelLight> light;
light.instance();
Vector3i pos = get_chunk_position();
Vector3i csize = get_chunk_size();
Vector3i pos = get_position();
Vector3i csize = get_size();
light->set_world_position(pos.x * csize.x + x, pos.y * csize.y + y, pos.z * csize.z + z);
light->set_color(color);
@ -567,13 +567,13 @@ void VoxelChunk::bake_light(Ref<VoxelLight> light) {
Vector3i wp = light->get_world_position();
int wpx = wp.x - (_chunk_position_x * _chunk_size_x);
int wpy = wp.y - (_chunk_position_y * _chunk_size_y);
int wpz = wp.z - (_chunk_position_z * _chunk_size_z);
int wpx = wp.x - (_position_x * _size_x);
int wpy = wp.y - (_position_y * _size_y);
int wpz = wp.z - (_position_z * _size_z);
//int wpx = (int)(wp.x / _chunk_size.x) - _chunk_position.x;
//int wpy = (int)(wp.y / _chunk_size.y) - _chunk_position.y;
//int wpz = (int)(wp.z / _chunk_size.z) - _chunk_position.z;
//int wpx = (int)(wp.x / _size.x) - _position.x;
//int wpy = (int)(wp.y / _size.y) - _position.y;
//int wpz = (int)(wp.z / _size.z) - _position.z;
_buffer->add_light(wpx, wpy, wpz, light->get_size(), light->get_color());
}
@ -648,7 +648,7 @@ void VoxelChunk::allocate_main_mesh() {
VS::get_singleton()->instance_set_base(_mesh_instance_rid, _mesh_rid);
VS::get_singleton()->instance_set_transform(_mesh_instance_rid, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
VS::get_singleton()->instance_set_transform(_mesh_instance_rid, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
}
void VoxelChunk::free_main_mesh() {
@ -679,7 +679,7 @@ void VoxelChunk::allocate_prop_mesh() {
VS::get_singleton()->instance_set_base(_prop_mesh_instance_rid, _prop_mesh_rid);
VS::get_singleton()->instance_set_transform(_prop_mesh_instance_rid, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
VS::get_singleton()->instance_set_transform(_prop_mesh_instance_rid, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
}
@ -704,7 +704,7 @@ void VoxelChunk::allocate_prop_colliders() {
PhysicsServer::get_singleton()->body_add_shape(_prop_body_rid, _prop_shape_rid);
PhysicsServer::get_singleton()->body_set_state(_prop_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
PhysicsServer::get_singleton()->body_set_state(_prop_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
PhysicsServer::get_singleton()->body_set_space(_prop_body_rid, get_voxel_world()->get_world()->get_space());
}
void VoxelChunk::build_prop_collider() {
@ -744,7 +744,7 @@ void VoxelChunk::allocate_liquid_mesh() {
VS::get_singleton()->instance_set_base(_liquid_mesh_instance_rid, _liquid_mesh_rid);
VS::get_singleton()->instance_set_transform(_liquid_mesh_instance_rid, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
VS::get_singleton()->instance_set_transform(_liquid_mesh_instance_rid, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
}
void VoxelChunk::free_liquid_mesh() {
@ -777,7 +777,7 @@ void VoxelChunk::allocate_clutter_mesh() {
VS::get_singleton()->instance_set_base(_clutter_mesh_instance_rid, _clutter_mesh_rid);
VS::get_singleton()->instance_set_transform(_clutter_mesh_instance_rid, Transform(Basis(), Vector3(_chunk_position_x * _chunk_size_x * _voxel_scale, _chunk_position_y * _chunk_size_y * _voxel_scale, _chunk_position_z * _chunk_size_z * _voxel_scale)));
VS::get_singleton()->instance_set_transform(_clutter_mesh_instance_rid, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale)));
}
void VoxelChunk::free_clutter_mesh() {
@ -809,8 +809,8 @@ void VoxelChunk::create_debug_immediate_geometry() {
if (Engine::get_singleton()->is_editor_hint())
_debug_drawer->set_owner(get_tree()->get_edited_scene_root());
//_debug_drawer->set_transform(Transform(Basis(), Vector3(_chunk_position.x * _chunk_size.x * _voxel_scale, _chunk_position.y * _chunk_size.y * _voxel_scale, _chunk_position.z * _chunk_size.z * _voxel_scale)));
//_debug_drawer->set_transform(Transform(Basis(), Vector3(_chunk_position.x * _chunk_size.x * _voxel_scale, _chunk_position.y * _chunk_size.y * _voxel_scale, _chunk_position.z * _chunk_size.z * _voxel_scale)));
//_debug_drawer->set_transform(Transform(Basis(), Vector3(_position.x * _size.x * _voxel_scale, _position.y * _size.y * _voxel_scale, _position.z * _size.z * _voxel_scale)));
//_debug_drawer->set_transform(Transform(Basis(), Vector3(_position.x * _size.x * _voxel_scale, _position.y * _size.y * _voxel_scale, _position.z * _size.z * _voxel_scale)));
}
void VoxelChunk::free_debug_immediate_geometry() {
@ -859,19 +859,18 @@ void VoxelChunk::draw_debug_voxels(int max, Color color) {
_debug_drawer->set_color(color);
int a = 0;
Vector3i size = _buffer->get_size();
for (int y = 0; y < size.y; ++y) {
for (int z = 0; z < size.z; ++z) {
for (int x = 0; x < size.x; ++x) {
for (int y = 0; y < _size_y; ++y) {
for (int z = 0; z < _size_z; ++z) {
for (int x = 0; x < _size_x; ++x) {
int type = _buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_TYPE);
int type = get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
if (type == 0) {
continue;
}
draw_cross_voxels_fill(Vector3(x, y, z), _buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL) / 255.0);
draw_cross_voxels_fill(Vector3(x, y, z), get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL) / 255.0);
++a;
@ -901,9 +900,9 @@ void VoxelChunk::draw_debug_voxel_lights() {
Vector3i pos = v->get_world_position();
int pos_x = pos.x - (_chunk_size_x * _chunk_position_x);
int pos_y = pos.y - (_chunk_size_y * _chunk_position_y);
int pos_z = pos.z - (_chunk_size_z * _chunk_position_z);
int pos_x = pos.x - (_size_x * _position_x);
int pos_y = pos.y - (_size_y * _position_y);
int pos_z = pos.z - (_size_z * _position_z);
draw_cross_voxels_fill(Vector3(pos_x, pos_y, pos_z), 1.0);
}
@ -987,33 +986,33 @@ void VoxelChunk::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_state", "value"), &VoxelChunk::set_state);
ADD_PROPERTY(PropertyInfo(Variant::INT, "state"), "set_state", "get_state");
ClassDB::bind_method(D_METHOD("get_chunk_position_x"), &VoxelChunk::get_chunk_position_x);
ClassDB::bind_method(D_METHOD("set_chunk_position_x", "value"), &VoxelChunk::set_chunk_position_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_x"), "set_chunk_position_x", "get_chunk_position_x");
ClassDB::bind_method(D_METHOD("get_position_x"), &VoxelChunk::get_position_x);
ClassDB::bind_method(D_METHOD("set_position_x", "value"), &VoxelChunk::set_position_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_x"), "set_position_x", "get_position_x");
ClassDB::bind_method(D_METHOD("get_chunk_position_y"), &VoxelChunk::get_chunk_position_y);
ClassDB::bind_method(D_METHOD("set_chunk_position_y", "value"), &VoxelChunk::set_chunk_position_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_y"), "set_chunk_position_y", "get_chunk_position_y");
ClassDB::bind_method(D_METHOD("get_position_y"), &VoxelChunk::get_position_y);
ClassDB::bind_method(D_METHOD("set_position_y", "value"), &VoxelChunk::set_position_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_y"), "set_position_y", "get_position_y");
ClassDB::bind_method(D_METHOD("get_chunk_position_z"), &VoxelChunk::get_chunk_position_z);
ClassDB::bind_method(D_METHOD("set_chunk_position_z", "value"), &VoxelChunk::set_chunk_position_z);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_z"), "set_chunk_position_x", "get_chunk_position_z");
ClassDB::bind_method(D_METHOD("get_position_z"), &VoxelChunk::get_position_z);
ClassDB::bind_method(D_METHOD("set_position_z", "value"), &VoxelChunk::set_position_z);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_position_z"), "set_position_x", "get_position_z");
ClassDB::bind_method(D_METHOD("set_chunk_position", "x", "y", "z"), &VoxelChunk::set_chunk_position);
ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &VoxelChunk::set_position);
ClassDB::bind_method(D_METHOD("get_chunk_size_x"), &VoxelChunk::get_chunk_size_x);
ClassDB::bind_method(D_METHOD("set_chunk_size_x", "value"), &VoxelChunk::set_chunk_size_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_x"), "set_chunk_size_x", "get_chunk_size_x");
ClassDB::bind_method(D_METHOD("get_size_x"), &VoxelChunk::get_size_x);
ClassDB::bind_method(D_METHOD("set_size_x", "value"), &VoxelChunk::set_size_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_x"), "set_size_x", "get_size_x");
ClassDB::bind_method(D_METHOD("get_chunk_size_y"), &VoxelChunk::get_chunk_size_y);
ClassDB::bind_method(D_METHOD("set_chunk_size_y", "value"), &VoxelChunk::set_chunk_size_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_y"), "set_chunk_size_y", "get_chunk_size_y");
ClassDB::bind_method(D_METHOD("get_size_y"), &VoxelChunk::get_size_y);
ClassDB::bind_method(D_METHOD("set_size_y", "value"), &VoxelChunk::set_size_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_y"), "set_size_y", "get_size_y");
ClassDB::bind_method(D_METHOD("get_chunk_size_z"), &VoxelChunk::get_chunk_size_z);
ClassDB::bind_method(D_METHOD("set_chunk_size_z", "value"), &VoxelChunk::set_chunk_size_z);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_z"), "set_chunk_size_x", "get_chunk_size_z");
ClassDB::bind_method(D_METHOD("get_size_z"), &VoxelChunk::get_size_z);
ClassDB::bind_method(D_METHOD("set_size_z", "value"), &VoxelChunk::set_size_z);
ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_z"), "set_size_x", "get_size_z");
ClassDB::bind_method(D_METHOD("set_chunk_size", "x", "y", "z"), &VoxelChunk::set_chunk_size);
ClassDB::bind_method(D_METHOD("set_size", "x", "y", "z"), &VoxelChunk::set_size);
ClassDB::bind_method(D_METHOD("get_library"), &VoxelChunk::get_library);
ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelChunk::set_library);
@ -1156,4 +1155,17 @@ void VoxelChunk::_bind_methods() {
BIND_CONSTANT(VOXEL_CHUNK_STATE_MESH_GENERATION_QUEUED);
BIND_CONSTANT(VOXEL_CHUNK_STATE_MESH_GENERATION);
BIND_CONSTANT(VOXEL_CHUNK_STATE_MAX);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_TYPE);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_ISOLEVEL);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_R);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_G);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIGHT_COLOR_B);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_AO);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_RANDOM_AO);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_TYPES);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FILL);
BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FLOW);
BIND_ENUM_CONSTANT(MAX_DEFAULT_CHANNELS);
}

View File

@ -60,18 +60,18 @@ public:
BUILD_PHASE_MAX = 10
};
enum ChannelId {
CHANNEL_TYPE = 0,
CHANNEL_ISOLEVEL,
CHANNEL_LIGHT_COLOR_R,
CHANNEL_LIGHT_COLOR_G,
CHANNEL_LIGHT_COLOR_B,
CHANNEL_AO,
CHANNEL_RANDOM_AO,
CHANNEL_LIQUID_TYPES,
CHANNEL_LIQUID_FILL,
CHANNEL_LIQUID_FLOW,
MAX_CHANNELS
enum DefaultChannels {
DEFAULT_CHANNEL_TYPE = 0,
DEFAULT_CHANNEL_ISOLEVEL,
DEFAULT_CHANNEL_LIGHT_COLOR_R,
DEFAULT_CHANNEL_LIGHT_COLOR_G,
DEFAULT_CHANNEL_LIGHT_COLOR_B,
DEFAULT_CHANNEL_AO,
DEFAULT_CHANNEL_RANDOM_AO,
DEFAULT_CHANNEL_LIQUID_TYPES,
DEFAULT_CHANNEL_LIQUID_FILL,
DEFAULT_CHANNEL_LIQUID_FLOW,
MAX_DEFAULT_CHANNELS
};
public:
@ -81,21 +81,21 @@ public:
int get_state() const;
void set_state(int value);
int get_chunk_position_x();
int get_chunk_position_y();
int get_chunk_position_z();
int get_position_x();
int get_position_y();
int get_position_z();
int get_chunk_size_x();
int get_chunk_size_y();
int get_chunk_size_z();
int get_size_x();
int get_size_y();
int get_size_z();
int get_chunk_data_size_x();
int get_chunk_data_size_y();
int get_chunk_data_size_z();
int get_data_size_x();
int get_data_size_y();
int get_data_size_z();
Vector3 get_chunk_position() const;
Vector3 get_chunk_size() const;
Vector3 get_chunk_data_size() const;
Vector3 get_position() const;
Vector3 get_size() const;
Vector3 get_data_size() const;
int get_margin_start() const;
int get_margin_end() const;
@ -253,17 +253,17 @@ protected:
VoxelWorld *_voxel_world;
int _chunk_position_x;
int _chunk_position_y;
int _chunk_position_z;
int _position_x;
int _position_y;
int _position_z;
uint32_t _chunk_size_x;
uint32_t _chunk_size_y;
uint32_t _chunk_size_z;
uint32_t _size_x;
uint32_t _size_y;
uint32_t _size_z;
uint32_t _chunk_data_size_x;
uint32_t _chunk_data_size_y;
uint32_t _chunk_data_size_z;
uint32_t _data_size_x;
uint32_t _data_size_y;
uint32_t _data_size_z;
uint32_t _margin_start;
uint32_t _margin_end;
@ -315,4 +315,6 @@ protected:
bool _bake_lights;
};
VARIANT_ENUM_CAST(VoxelChunk::DefaultChannels);
#endif