mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-25 15:09:18 +01:00
Broke up VoxelChunk into VoxelChunk and VoxelChunkDefault.
This commit is contained in:
parent
9154009250
commit
080e8f2437
1
SCsub
1
SCsub
@ -34,6 +34,7 @@ sources = [
|
||||
|
||||
"world/voxel_world.cpp",
|
||||
"world/voxel_chunk.cpp",
|
||||
"world/voxel_chunk_default.cpp",
|
||||
"world/voxel_structure.cpp",
|
||||
"world/environment_data.cpp",
|
||||
"world/voxel_chunk_prop_data.cpp",
|
||||
|
@ -21,6 +21,8 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "voxel_cube_points.h"
|
||||
#include "../../world/voxel_chunk.h"
|
||||
#include "../../world/voxel_chunk_default.h"
|
||||
|
||||
const unsigned int VoxelCubePoints::index_table[6][4] = {
|
||||
{ P000, P010, P110, P100 }, //VOXEL_FACE_FRONT 0
|
||||
@ -200,25 +202,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
int z = _z;
|
||||
|
||||
//000
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
/*
|
||||
if (chunk->get_voxel(x - 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y - 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT;*/
|
||||
|
||||
_point_neighbours[P000] = neighbours;
|
||||
@ -229,25 +231,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z;
|
||||
|
||||
//100
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
/*
|
||||
if (chunk->get_voxel(x + 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y - 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y - 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT;*/
|
||||
|
||||
_point_neighbours[P100] = neighbours;
|
||||
@ -258,25 +260,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z;
|
||||
|
||||
//010
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
/*
|
||||
if (chunk->get_voxel(x - 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y + 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_FRONT;*/
|
||||
|
||||
_point_neighbours[P010] = neighbours;
|
||||
@ -287,25 +289,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z;
|
||||
|
||||
//110
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
/*
|
||||
if (chunk->get_voxel(x + 1, y, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y + 1, z - 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y + 1, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT;*/
|
||||
|
||||
_point_neighbours[P110] = neighbours;
|
||||
@ -316,25 +318,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z + 1;
|
||||
|
||||
//001
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
/*
|
||||
if (chunk->get_voxel(x - 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y - 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK;*/
|
||||
|
||||
_point_neighbours[P001] = neighbours;
|
||||
@ -345,25 +347,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z + 1;
|
||||
|
||||
//101
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
/*
|
||||
if (chunk->get_voxel(x + 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y - 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y - 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y - 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y - 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK;*/
|
||||
|
||||
_point_neighbours[P101] = neighbours;
|
||||
@ -374,25 +376,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z + 1;
|
||||
|
||||
//011
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
/*
|
||||
if (chunk->get_voxel(x - 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
|
||||
|
||||
if (chunk->get_voxel(x - 1, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x - 1, y + 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_BACK;*/
|
||||
|
||||
_point_neighbours[P011] = neighbours;
|
||||
@ -403,25 +405,25 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) {
|
||||
z = _z + 1;
|
||||
|
||||
//111
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
/*
|
||||
if (chunk->get_voxel(x + 1, y, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y + 1, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT;
|
||||
|
||||
if (chunk->get_voxel(x, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
|
||||
|
||||
if (chunk->get_voxel(x + 1, y + 1, z + 1, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + 1, y + 1, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_BACK;*/
|
||||
|
||||
_point_neighbours[P111] = neighbours;
|
||||
@ -443,44 +445,44 @@ void VoxelCubePoints::setup(VoxelChunk *chunk, int x, int y, int z, int size) {
|
||||
_z = z;
|
||||
_size = size;
|
||||
|
||||
_point_types[P000] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P100] = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P010] = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P001] = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P000] = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P100] = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P010] = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P001] = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
_point_types[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (!has_points())
|
||||
return;
|
||||
|
||||
_point_fills[P000] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P100] = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P010] = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P001] = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P000] = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P100] = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P010] = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P001] = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
_point_fills[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
|
||||
_point_aos[P000] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P100] = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P010] = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P001] = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P000] = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P100] = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P010] = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P001] = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
_point_aos[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO);
|
||||
|
||||
_point_colors[P000] = Color(chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P100] = Color(chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P010] = Color(chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P001] = Color(chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P110] = Color(chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P011] = Color(chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P101] = Color(chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P111] = Color(chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P000] = Color(chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P100] = Color(chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P010] = Color(chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P001] = Color(chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P110] = Color(chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P011] = Color(chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P101] = Color(chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
_point_colors[P111] = Color(chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
|
||||
refresh_neighbours(chunk);
|
||||
|
||||
|
@ -26,8 +26,7 @@ SOFTWARE.
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "../../world/voxel_chunk.h"
|
||||
|
||||
class VoxelChunk;
|
||||
class SubVoxelFacePointsHelper;
|
||||
|
||||
class VoxelCubePoints : public Reference {
|
||||
|
@ -22,8 +22,10 @@ SOFTWARE.
|
||||
|
||||
#include "voxel_mesher_cubic.h"
|
||||
|
||||
#include "../../world/voxel_chunk_default.h"
|
||||
|
||||
void VoxelMesherCubic::_add_chunk(Node *p_chunk) {
|
||||
VoxelChunk *chunk = Object::cast_to<VoxelChunk>(p_chunk);
|
||||
VoxelChunkDefault *chunk = Object::cast_to<VoxelChunkDefault>(p_chunk);
|
||||
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
|
||||
|
||||
|
@ -23,6 +23,7 @@ SOFTWARE.
|
||||
#include "voxel_mesher_transvoxel.h"
|
||||
|
||||
#include "../../world/voxel_chunk.h"
|
||||
#include "../../world/voxel_chunk_default.h"
|
||||
#include "core/array.h"
|
||||
#include "core/dictionary.h"
|
||||
#include "servers/visual_server.h"
|
||||
@ -35,14 +36,14 @@ void VoxelMesherTransvoxel::set_texture_scale(const int value) {
|
||||
}
|
||||
|
||||
void VoxelMesherTransvoxel::get_voxel_type_array(int *arr, VoxelChunk *chunk, const int x, const int y, const int z, const int size) {
|
||||
arr[0] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[1] = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[2] = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[3] = chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[4] = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[5] = chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[6] = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[7] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
arr[0] = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[1] = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[2] = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[3] = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[4] = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[5] = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[6] = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
arr[7] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
}
|
||||
int VoxelMesherTransvoxel::get_case_code_from_arr(const int *data) {
|
||||
int case_code = 0;
|
||||
@ -76,28 +77,28 @@ int VoxelMesherTransvoxel::get_case_code_from_arr(const int *data) {
|
||||
int VoxelMesherTransvoxel::get_case_code(VoxelChunk *chunk, const int x, const int y, const int z, const int size) {
|
||||
int case_code = 0;
|
||||
|
||||
if (chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_000;
|
||||
|
||||
if (chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_010;
|
||||
|
||||
if (chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_001;
|
||||
|
||||
if (chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_011;
|
||||
|
||||
if (chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_100;
|
||||
|
||||
if (chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_110;
|
||||
|
||||
if (chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_101;
|
||||
|
||||
if (chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
if (chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE) != 0)
|
||||
case_code = case_code | VOXEL_ENTRY_MASK_111;
|
||||
|
||||
return case_code;
|
||||
@ -106,48 +107,48 @@ int VoxelMesherTransvoxel::get_case_code(VoxelChunk *chunk, const int x, const i
|
||||
int VoxelMesherTransvoxel::get_voxel_type(VoxelChunk *chunk, const int x, const int y, const int z, const int size) {
|
||||
int type = 0;
|
||||
|
||||
type = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x + size, y + size, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
if (type != 0)
|
||||
return type;
|
||||
|
||||
type = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
type = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
void VoxelMesherTransvoxel::_add_chunk(Node *p_chunk) {
|
||||
VoxelChunk *chunk = Object::cast_to<VoxelChunk>(p_chunk);
|
||||
VoxelChunkDefault *chunk = Object::cast_to<VoxelChunkDefault>(p_chunk);
|
||||
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(chunk));
|
||||
|
||||
@ -259,7 +260,7 @@ void VoxelMesherTransvoxel::_add_chunk(Node *p_chunk) {
|
||||
Vector3 offs0 = corner_id_to_vertex(fv) * lod_size;
|
||||
Vector3 offs1 = corner_id_to_vertex(sv) * lod_size;
|
||||
|
||||
int type = chunk->get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk::DEFAULT_CHANNEL_TYPE);
|
||||
int type = chunk->get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunkDefault::DEFAULT_CHANNEL_TYPE);
|
||||
|
||||
int fill = 0;
|
||||
|
||||
@ -267,12 +268,12 @@ void VoxelMesherTransvoxel::_add_chunk(Node *p_chunk) {
|
||||
Vector3 vert_dir;
|
||||
|
||||
if (type == 0) {
|
||||
fill = chunk->get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
fill = chunk->get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
|
||||
vert_pos = get_regular_vertex_second_position(case_code, i);
|
||||
vert_dir = get_regular_vertex_first_position(case_code, i);
|
||||
} else {
|
||||
fill = chunk->get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
fill = chunk->get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL);
|
||||
|
||||
vert_pos = get_regular_vertex_first_position(case_code, i);
|
||||
vert_dir = get_regular_vertex_second_position(case_code, i);
|
||||
|
@ -23,6 +23,7 @@ SOFTWARE.
|
||||
#include "voxel_mesher.h"
|
||||
|
||||
#include "../world/voxel_chunk.h"
|
||||
#include "../world/voxel_chunk_default.h"
|
||||
|
||||
bool VoxelMesher::Vertex::operator==(const Vertex &p_vertex) const {
|
||||
|
||||
@ -603,12 +604,12 @@ void VoxelMesher::_bake_colors(Node *p_chunk) {
|
||||
|
||||
if (chunk->validate_channel_data_position(x, y, z)) {
|
||||
Color light = Color(
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
|
||||
float ao = (chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength;
|
||||
float rao = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_RANDOM_AO) / 255.0;
|
||||
float ao = (chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength;
|
||||
float rao = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0;
|
||||
|
||||
ao += rao;
|
||||
|
||||
@ -672,12 +673,12 @@ void VoxelMesher::_bake_liquid_colors(Node *p_chunk) {
|
||||
|
||||
if (chunk->validate_channel_data_position(x, y, z)) {
|
||||
Color light = Color(
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0,
|
||||
chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0);
|
||||
|
||||
float ao = (chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength;
|
||||
float rao = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_RANDOM_AO) / 255.0;
|
||||
float ao = (chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength;
|
||||
float rao = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0;
|
||||
|
||||
ao += rao;
|
||||
|
||||
@ -858,11 +859,11 @@ void VoxelMesher::add_vertex(const Vector3 &vertex) {
|
||||
vtx.normal = _last_normal;
|
||||
vtx.uv = _last_uv;
|
||||
vtx.uv2 = _last_uv2;
|
||||
// Todo?
|
||||
// vtx.weights = _last_weights;
|
||||
// vtx.bones = _last_bones;
|
||||
// vtx.tangent = _last_tangent.normal;
|
||||
// vtx.binormal = _last_normal.cross(_last_tangent.normal).normalized() * _last_tangent.d;
|
||||
// Todo?
|
||||
// vtx.weights = _last_weights;
|
||||
// vtx.bones = _last_bones;
|
||||
// vtx.tangent = _last_tangent.normal;
|
||||
// vtx.binormal = _last_normal.cross(_last_tangent.normal).normalized() * _last_tangent.d;
|
||||
|
||||
_vertices.push_back(vtx);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ SOFTWARE.
|
||||
|
||||
#include "world/environment_data.h"
|
||||
#include "world/voxel_chunk.h"
|
||||
#include "world/voxel_chunk_default.h"
|
||||
#include "world/voxel_chunk_prop_data.h"
|
||||
#include "world/voxel_structure.h"
|
||||
#include "world/voxel_world.h"
|
||||
@ -92,6 +93,7 @@ void register_voxelman_types() {
|
||||
|
||||
ClassDB::register_class<VoxelWorld>();
|
||||
ClassDB::register_class<VoxelChunk>();
|
||||
ClassDB::register_class<VoxelChunkDefault>();
|
||||
ClassDB::register_class<VoxelStructure>();
|
||||
ClassDB::register_class<EnvironmentData>();
|
||||
ClassDB::register_class<VoxelChunkPropData>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -66,65 +66,14 @@ class VoxelChunk : public Spatial {
|
||||
_THREAD_SAFE_CLASS_
|
||||
|
||||
public:
|
||||
static const String BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE;
|
||||
|
||||
enum {
|
||||
VOXEL_CHUNK_STATE_OK = 0,
|
||||
VOXEL_CHUNK_STATE_GENERATION_QUEUED,
|
||||
VOXEL_CHUNK_STATE_GENERATION,
|
||||
VOXEL_CHUNK_STATE_MESH_GENERATION_QUEUED,
|
||||
VOXEL_CHUNK_STATE_MESH_GENERATION,
|
||||
VOXEL_CHUNK_STATE_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
BUILD_PHASE_DONE = 0,
|
||||
BUILD_PHASE_SETUP,
|
||||
BUILD_PHASE_TERRARIN_MESH_SETUP,
|
||||
BUILD_PHASE_TERRARIN_MESH_COLLIDER,
|
||||
BUILD_PHASE_LIGHTS,
|
||||
BUILD_PHASE_TERRARIN_MESH,
|
||||
BUILD_PHASE_PROP_MESH,
|
||||
BUILD_PHASE_PROP_COLLIDER,
|
||||
//BUILD_PHASE_LIQUID,
|
||||
//BUILD_PHASE_CLUTTER,
|
||||
BUILD_PHASE_FINALIZE,
|
||||
BUILD_PHASE_MAX
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
enum ActiveBuildPhaseType {
|
||||
BUILD_PHASE_TYPE_NORMAL = 0,
|
||||
BUILD_PHASE_TYPE_PROCESS,
|
||||
BUILD_PHASE_TYPE_PHYSICS_PROCESS,
|
||||
};
|
||||
|
||||
public:
|
||||
bool get_is_generating() const;
|
||||
void set_is_generating(bool value);
|
||||
|
||||
bool get_is_build_threaded() const;
|
||||
void set_is_build_threaded(bool value);
|
||||
|
||||
ActiveBuildPhaseType get_active_build_phase_type() const;
|
||||
void set_active_build_phase_type(const ActiveBuildPhaseType value);
|
||||
|
||||
bool get_build_phase_done() const;
|
||||
void set_build_phase_done(bool value);
|
||||
|
||||
bool get_dirty() const;
|
||||
void set_dirty(bool value);
|
||||
|
||||
@ -162,55 +111,24 @@ public:
|
||||
void set_margin_end(int value);
|
||||
|
||||
Ref<VoxelmanLibrary> get_library();
|
||||
void set_library(Ref<VoxelmanLibrary> value);
|
||||
|
||||
int get_lod_size() const;
|
||||
void set_lod_size(int lod_size);
|
||||
void set_library(const Ref<VoxelmanLibrary> &value);
|
||||
|
||||
float get_voxel_scale() const;
|
||||
void set_voxel_scale(float value);
|
||||
|
||||
int get_current_build_phase();
|
||||
void set_current_build_phase(int value);
|
||||
|
||||
int get_max_build_phase();
|
||||
void set_max_build_phase(int value);
|
||||
VoxelWorld *get_voxel_world() const;
|
||||
void set_voxel_world(VoxelWorld *world);
|
||||
void set_voxel_world_bind(Node *world);
|
||||
|
||||
//Meshers
|
||||
Ref<VoxelMesher> get_mesher(int index) const;
|
||||
void set_mesher(int index, Ref<VoxelMesher> mesher);
|
||||
void remove_mesher(int index);
|
||||
void add_mesher(Ref<VoxelMesher> mesher);
|
||||
int get_mesher_count();
|
||||
|
||||
VoxelWorld *get_voxel_world() const;
|
||||
void set_voxel_world(VoxelWorld *world);
|
||||
void set_voxel_world_bind(Node *world);
|
||||
|
||||
bool get_create_collider() const;
|
||||
void set_create_collider(bool value);
|
||||
|
||||
bool get_bake_lights() const;
|
||||
void set_bake_lights(bool value);
|
||||
|
||||
RID get_mesh_rid();
|
||||
RID get_mesh_instance_rid();
|
||||
RID get_shape_rid();
|
||||
RID get_body_rid();
|
||||
|
||||
RID get_prop_mesh_rid();
|
||||
RID get_prop_mesh_instance_rid();
|
||||
RID get_prop_shape_rid();
|
||||
RID get_prop_body_rid();
|
||||
|
||||
RID get_liquid_mesh_rid();
|
||||
RID get_liquid_mesh_instance_rid();
|
||||
|
||||
RID get_clutter_mesh_rid();
|
||||
RID get_clutter_mesh_instance_rid();
|
||||
|
||||
//Voxel Data
|
||||
//Channels
|
||||
void setup_channels();
|
||||
void _setup_channels();
|
||||
|
||||
void set_size(uint32_t size_x, uint32_t size_y, uint32_t size_z, uint32_t margin_start = 0, uint32_t margin_end = 0);
|
||||
|
||||
@ -235,40 +153,13 @@ public:
|
||||
uint32_t get_data_index(uint32_t x, uint32_t y, uint32_t z) const;
|
||||
uint32_t get_data_size() const;
|
||||
|
||||
//Data Management functions
|
||||
void generate_ao();
|
||||
|
||||
void add_light(int local_x, int local_y, int local_z, int size, Color color);
|
||||
void clear_baked_lights();
|
||||
|
||||
//Meshing
|
||||
void create_meshers();
|
||||
void _create_meshers();
|
||||
|
||||
void build_deferred();
|
||||
void build_prioritized();
|
||||
static void _build_step_threaded(void *_userdata);
|
||||
|
||||
void build_step();
|
||||
|
||||
void build_phase();
|
||||
void _build_phase(int phase);
|
||||
|
||||
void build_phase_process();
|
||||
void _build_phase_process(int phase);
|
||||
|
||||
void build_phase_physics_process();
|
||||
void _build_phase_physics_process(int phase);
|
||||
|
||||
bool has_next_phase();
|
||||
void next_phase();
|
||||
void build(bool immediate = false);
|
||||
|
||||
void clear();
|
||||
|
||||
//Colliders
|
||||
void create_colliders();
|
||||
void remove_colliders();
|
||||
|
||||
//lights
|
||||
void add_lights(Array lights);
|
||||
void add_voxel_light(Ref<VoxelLight> light);
|
||||
@ -282,6 +173,9 @@ public:
|
||||
|
||||
void bake_lights();
|
||||
void bake_light(Ref<VoxelLight> light);
|
||||
void clear_baked_lights();
|
||||
|
||||
void add_light(int local_x, int local_y, int local_z, int size, Color color);
|
||||
|
||||
void add_prop_light(Ref<VoxelLight> light);
|
||||
|
||||
@ -294,56 +188,19 @@ public:
|
||||
|
||||
void free_spawn_props();
|
||||
|
||||
//Meshes
|
||||
void allocate_main_mesh();
|
||||
void free_main_mesh();
|
||||
|
||||
void allocate_prop_mesh();
|
||||
void free_prop_mesh();
|
||||
|
||||
void allocate_prop_colliders();
|
||||
void free_prop_colliders();
|
||||
|
||||
void allocate_liquid_mesh();
|
||||
void free_liquid_mesh();
|
||||
|
||||
void allocate_clutter_mesh();
|
||||
void free_clutter_mesh();
|
||||
|
||||
//Debug
|
||||
void create_debug_immediate_geometry();
|
||||
void free_debug_immediate_geometry();
|
||||
|
||||
void draw_cross_voxels(Vector3 pos);
|
||||
void draw_cross_voxels_fill(Vector3 pos, float fill);
|
||||
void draw_debug_voxels(int max, Color color = Color(1, 1, 1));
|
||||
void draw_debug_voxel_lights();
|
||||
|
||||
//free
|
||||
void free_chunk();
|
||||
|
||||
VoxelChunk();
|
||||
~VoxelChunk();
|
||||
|
||||
protected:
|
||||
void wait_and_finish_thread();
|
||||
|
||||
void _notification(int p_what);
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
static void _bind_methods();
|
||||
|
||||
bool _is_generating;
|
||||
bool _is_build_threaded;
|
||||
bool _abort_build;
|
||||
bool _dirty;
|
||||
int _state;
|
||||
|
||||
int _current_build_phase;
|
||||
int _max_build_phases;
|
||||
bool _enabled;
|
||||
|
||||
VoxelWorld *_voxel_world;
|
||||
|
||||
int _position_x;
|
||||
@ -365,61 +222,16 @@ protected:
|
||||
|
||||
Vector<Ref<VoxelLight> > _voxel_lights;
|
||||
|
||||
int _lod_size;
|
||||
float _voxel_scale;
|
||||
|
||||
NodePath _library_path;
|
||||
Ref<VoxelmanLibrary> _library;
|
||||
Vector<Ref<VoxelMesher> > _meshers;
|
||||
|
||||
//voxel mesh
|
||||
RID _mesh_rid;
|
||||
RID _mesh_instance_rid;
|
||||
|
||||
RID _shape_rid;
|
||||
RID _body_rid;
|
||||
|
||||
//mergeable props
|
||||
Vector<Ref<VoxelChunkPropData> > _props;
|
||||
|
||||
RID _prop_mesh_rid;
|
||||
RID _prop_mesh_instance_rid;
|
||||
|
||||
RID _prop_shape_rid;
|
||||
RID _prop_body_rid;
|
||||
|
||||
//liquids
|
||||
RID _liquid_mesh_rid;
|
||||
RID _liquid_mesh_instance_rid;
|
||||
|
||||
//clutter
|
||||
RID _clutter_mesh_rid;
|
||||
RID _clutter_mesh_instance_rid;
|
||||
|
||||
//spawned props
|
||||
Vector<Node *> _spawned_props;
|
||||
|
||||
//debug
|
||||
ImmediateGeometry *_debug_drawer;
|
||||
|
||||
bool _build_mesh;
|
||||
bool _create_collider;
|
||||
|
||||
bool _bake_lights;
|
||||
|
||||
bool _build_prioritized;
|
||||
Mutex *_build_phase_done_mutex;
|
||||
bool _build_phase_done;
|
||||
Thread *_build_thread;
|
||||
bool _build_step_in_progress;
|
||||
|
||||
Array temp_array;
|
||||
PoolVector<Vector3> temp_arr_collider;
|
||||
|
||||
ActiveBuildPhaseType _active_build_phase_type;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelChunk::DefaultChannels);
|
||||
VARIANT_ENUM_CAST(VoxelChunk::ActiveBuildPhaseType);
|
||||
|
||||
#endif
|
||||
|
1251
world/voxel_chunk_default.cpp
Normal file
1251
world/voxel_chunk_default.cpp
Normal file
File diff suppressed because it is too large
Load Diff
281
world/voxel_chunk_default.h
Normal file
281
world/voxel_chunk_default.h
Normal file
@ -0,0 +1,281 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef VOXEL_CHUNK_DEFAULT_H
|
||||
#define VOXEL_CHUNK_DEFAULT_H
|
||||
|
||||
#include "voxel_chunk.h"
|
||||
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/thread.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "core/array.h"
|
||||
#include "core/pool_vector.h"
|
||||
#include "scene/3d/collision_shape.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
#include "scene/resources/concave_polygon_shape.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "voxel_world.h"
|
||||
|
||||
#include "../data/voxel_light.h"
|
||||
|
||||
#include "../meshers/cubic_mesher/voxel_mesher_cubic.h"
|
||||
#include "../meshers/voxel_mesher.h"
|
||||
|
||||
#include "../library/voxel_surface.h"
|
||||
#include "../library/voxelman_library.h"
|
||||
|
||||
#include "../../mesh_data_resource/mesh_data_resource.h"
|
||||
#include "../props/prop_data.h"
|
||||
#include "../props/prop_data_entry.h"
|
||||
#include "../props/prop_data_light.h"
|
||||
#include "../props/prop_data_mesh.h"
|
||||
#include "../props/prop_data_scene.h"
|
||||
#include "voxel_chunk_prop_data.h"
|
||||
|
||||
class VoxelWorld;
|
||||
|
||||
class VoxelChunkDefault : public VoxelChunk {
|
||||
GDCLASS(VoxelChunkDefault, VoxelChunk);
|
||||
|
||||
_THREAD_SAFE_CLASS_
|
||||
|
||||
public:
|
||||
static const String BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE;
|
||||
|
||||
enum {
|
||||
VOXEL_CHUNK_STATE_GENERATION_QUEUED = 1,
|
||||
VOXEL_CHUNK_STATE_GENERATION,
|
||||
VOXEL_CHUNK_STATE_MESH_GENERATION_QUEUED,
|
||||
VOXEL_CHUNK_STATE_MESH_GENERATION,
|
||||
VOXEL_CHUNK_STATE_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
BUILD_PHASE_DONE = 0,
|
||||
BUILD_PHASE_SETUP,
|
||||
BUILD_PHASE_TERRARIN_MESH_SETUP,
|
||||
BUILD_PHASE_TERRARIN_MESH_COLLIDER,
|
||||
BUILD_PHASE_LIGHTS,
|
||||
BUILD_PHASE_TERRARIN_MESH,
|
||||
BUILD_PHASE_PROP_MESH,
|
||||
BUILD_PHASE_PROP_COLLIDER,
|
||||
//BUILD_PHASE_LIQUID,
|
||||
//BUILD_PHASE_CLUTTER,
|
||||
BUILD_PHASE_FINALIZE,
|
||||
BUILD_PHASE_MAX
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
enum ActiveBuildPhaseType {
|
||||
BUILD_PHASE_TYPE_NORMAL = 0,
|
||||
BUILD_PHASE_TYPE_PROCESS,
|
||||
BUILD_PHASE_TYPE_PHYSICS_PROCESS,
|
||||
};
|
||||
|
||||
public:
|
||||
bool get_is_build_threaded() const;
|
||||
void set_is_build_threaded(bool value);
|
||||
|
||||
ActiveBuildPhaseType get_active_build_phase_type() const;
|
||||
void set_active_build_phase_type(const ActiveBuildPhaseType value);
|
||||
|
||||
bool get_build_phase_done() const;
|
||||
void set_build_phase_done(bool value);
|
||||
|
||||
int get_lod_size() const;
|
||||
void set_lod_size(int lod_size);
|
||||
|
||||
int get_current_build_phase();
|
||||
void set_current_build_phase(int value);
|
||||
|
||||
int get_max_build_phase();
|
||||
void set_max_build_phase(int value);
|
||||
|
||||
bool get_create_collider() const;
|
||||
void set_create_collider(bool value);
|
||||
|
||||
bool get_bake_lights() const;
|
||||
void set_bake_lights(bool value);
|
||||
|
||||
RID get_mesh_rid();
|
||||
RID get_mesh_instance_rid();
|
||||
RID get_shape_rid();
|
||||
RID get_body_rid();
|
||||
|
||||
RID get_prop_mesh_rid();
|
||||
RID get_prop_mesh_instance_rid();
|
||||
RID get_prop_shape_rid();
|
||||
RID get_prop_body_rid();
|
||||
|
||||
RID get_liquid_mesh_rid();
|
||||
RID get_liquid_mesh_instance_rid();
|
||||
|
||||
RID get_clutter_mesh_rid();
|
||||
RID get_clutter_mesh_instance_rid();
|
||||
|
||||
//Data Management functions
|
||||
void generate_ao();
|
||||
|
||||
//Meshing
|
||||
void build_deferred();
|
||||
void build_prioritized();
|
||||
static void _build_step_threaded(void *_userdata);
|
||||
|
||||
void build_step();
|
||||
|
||||
void build_phase();
|
||||
void build_phase_process();
|
||||
void build_phase_physics_process();
|
||||
|
||||
bool has_next_phase();
|
||||
void next_phase();
|
||||
|
||||
void clear();
|
||||
|
||||
//Colliders
|
||||
void create_colliders();
|
||||
void remove_colliders();
|
||||
|
||||
//Meshes
|
||||
void allocate_main_mesh();
|
||||
void free_main_mesh();
|
||||
|
||||
void allocate_prop_mesh();
|
||||
void free_prop_mesh();
|
||||
|
||||
void allocate_prop_colliders();
|
||||
void free_prop_colliders();
|
||||
|
||||
void allocate_liquid_mesh();
|
||||
void free_liquid_mesh();
|
||||
|
||||
void allocate_clutter_mesh();
|
||||
void free_clutter_mesh();
|
||||
|
||||
//Debug
|
||||
void create_debug_immediate_geometry();
|
||||
void free_debug_immediate_geometry();
|
||||
|
||||
void draw_cross_voxels(Vector3 pos);
|
||||
void draw_cross_voxels_fill(Vector3 pos, float fill);
|
||||
void draw_debug_voxels(int max, Color color = Color(1, 1, 1));
|
||||
void draw_debug_voxel_lights();
|
||||
|
||||
//free
|
||||
void free_chunk();
|
||||
|
||||
VoxelChunkDefault();
|
||||
~VoxelChunkDefault();
|
||||
|
||||
protected:
|
||||
virtual void _setup_channels();
|
||||
virtual void _build_phase(int phase);
|
||||
virtual void _build_phase_process(int phase);
|
||||
virtual void _build_phase_physics_process(int phase);
|
||||
|
||||
virtual void _add_light(int local_x, int local_y, int local_z, int size, Color color);
|
||||
virtual void _clear_baked_lights();
|
||||
virtual void _create_meshers();
|
||||
virtual void _build(bool immediate);
|
||||
|
||||
void wait_and_finish_thread();
|
||||
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
bool _is_build_threaded;
|
||||
bool _abort_build;
|
||||
|
||||
int _current_build_phase;
|
||||
int _max_build_phases;
|
||||
bool _enabled;
|
||||
|
||||
int _lod_size;
|
||||
|
||||
//voxel mesh
|
||||
RID _mesh_rid;
|
||||
RID _mesh_instance_rid;
|
||||
|
||||
RID _shape_rid;
|
||||
RID _body_rid;
|
||||
|
||||
RID _prop_mesh_rid;
|
||||
RID _prop_mesh_instance_rid;
|
||||
|
||||
RID _prop_shape_rid;
|
||||
RID _prop_body_rid;
|
||||
|
||||
//liquids
|
||||
RID _liquid_mesh_rid;
|
||||
RID _liquid_mesh_instance_rid;
|
||||
|
||||
//clutter
|
||||
RID _clutter_mesh_rid;
|
||||
RID _clutter_mesh_instance_rid;
|
||||
|
||||
//debug
|
||||
ImmediateGeometry *_debug_drawer;
|
||||
|
||||
bool _build_mesh;
|
||||
bool _create_collider;
|
||||
|
||||
bool _bake_lights;
|
||||
|
||||
bool _build_prioritized;
|
||||
Mutex *_build_phase_done_mutex;
|
||||
bool _build_phase_done;
|
||||
Thread *_build_thread;
|
||||
bool _build_step_in_progress;
|
||||
|
||||
Array temp_array;
|
||||
PoolVector<Vector3> temp_arr_collider;
|
||||
|
||||
ActiveBuildPhaseType _active_build_phase_type;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelChunkDefault::DefaultChannels);
|
||||
VARIANT_ENUM_CAST(VoxelChunkDefault::ActiveBuildPhaseType);
|
||||
|
||||
#endif
|
@ -121,7 +121,7 @@ void VoxelStructure::clear() {
|
||||
}
|
||||
|
||||
VoxelStructure::VoxelStructure() {
|
||||
_channel_count = VoxelChunk::MAX_DEFAULT_CHANNELS;
|
||||
_channel_count = 0;
|
||||
|
||||
_world_position_x = 0;
|
||||
_world_position_y = 0;
|
||||
|
@ -307,7 +307,11 @@ VoxelChunk *VoxelWorld::_create_chunk(int x, int y, int z, Node *p_chunk) {
|
||||
chunk->set_owner(get_tree()->get_edited_scene_root());
|
||||
|
||||
chunk->set_voxel_world(this);
|
||||
chunk->set_is_build_threaded(_use_threads);
|
||||
|
||||
//TODO this will need to be changed
|
||||
if (chunk->has_method("set_is_build_threaded"))
|
||||
chunk->call("set_is_build_threaded", _use_threads);
|
||||
|
||||
chunk->set_position(x, y, z);
|
||||
chunk->set_library(_library);
|
||||
chunk->set_voxel_scale(_voxel_scale);
|
||||
@ -334,7 +338,7 @@ void VoxelWorld::generate_chunk(VoxelChunk *p_chunk) {
|
||||
|
||||
call("_generate_chunk", p_chunk);
|
||||
|
||||
p_chunk->build_deferred();
|
||||
p_chunk->build();
|
||||
}
|
||||
|
||||
bool VoxelWorld::can_chunk_do_build_step() {
|
||||
|
Loading…
Reference in New Issue
Block a user