More cleanup, and fixed a misunderstanding.

This commit is contained in:
Relintai 2019-06-08 01:28:39 +02:00
parent ba05f93aa2
commit b50c9be4e7
2 changed files with 20 additions and 70 deletions

View File

@ -75,36 +75,18 @@ int VoxelMesherTransvoxel::get_regular_vertex_data(int index1, int index2) const
int VoxelMesherTransvoxel::get_regular_vertex_data_first_vertex(int index1, int index2) const {
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 < vert1) {
return vert2;
}
return vert1;
}
int VoxelMesherTransvoxel::get_regular_vertex_data_second_vertex(int index1, int index2) const {
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 > vert1) {
return vert2;
}
return vert1;
return vert2;
}
Vector3 VoxelMesherTransvoxel::get_regular_vertex_start_position(int index1, int index2) const {
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 < vert1) {
return transvoxel_vertices[vert2];
}
return transvoxel_vertices[vert1];
}
@ -113,13 +95,6 @@ Vector3 VoxelMesherTransvoxel::get_regular_vertex_direction(int index1, int inde
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 < vert1) {
int t = vert2;
vert2 = vert1;
vert1 = t;
}
return transvoxel_vertices[vert2] - transvoxel_vertices[vert1];
}
@ -157,12 +132,6 @@ int VoxelMesherTransvoxel::get_transition_vertex_data_second_vertex(int index1,
Vector3 VoxelMesherTransvoxel::get_transition_vertex_start_position(int index1, int index2) const {
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 < vert1) {
return transvoxel_vertices[vert2];
}
return transvoxel_vertices[vert1];
}
@ -171,13 +140,6 @@ Vector3 VoxelMesherTransvoxel::get_transition_vertex_direction(int index1, int i
int vert1 = regularVertexData[index1][index2] & 0x000F;
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
//The paper says, that the smaller vertex index should be considered first
if (vert2 < vert1) {
int t = vert2;
vert2 = vert1;
vert1 = t;
}
return transvoxel_vertices[vert2] - transvoxel_vertices[vert1];
}

View File

@ -202,7 +202,6 @@ void VoxelChunk::draw_cross_voxels(Vector3 pos, float fill) {
}
void VoxelChunk::draw_debug_voxels(int max, Color color) {
/*
if (_debug_drawer == NULL) {
Node *n = get_node(_debug_drawer_path);
@ -213,47 +212,36 @@ void VoxelChunk::draw_debug_voxels(int max, Color color) {
ERR_FAIL_COND(_debug_drawer == NULL);
//if (_debug_drawer->emt)
_debug_drawer->clear();
_debug_drawer->begin(Mesh::PRIMITIVE_LINES);
_debug_drawer->set_color(color);
HashMap<int, Ref<Voxel> > *map = _voxels->get_map();
ERR_FAIL_COND(map == NULL);
const int *k = NULL;
//Vector3 pos = get_transform().get_origin();
int a = 0;
while ((k = map->next(k))) {
Ref<Voxel> v = map->get(*k);
ERR_FAIL_COND(!v.is_valid());
Vector3i size = _buffer->get_size();
Vector3i lp = v->get_local_position();
//print_error(Vector3(lp.x, lp.y, lp.z));
draw_cross_voxels(Vector3(lp.x + 0.5, lp.y + 0.5, lp.z + 0.5), v->get_fill() / 255.0);
for (int y = 0; y < size.y; ++y) {
for (int z = 0; z < size.z; ++z) {
for (int x = 0; x < size.x; ++x) {
a++;
int type = _buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_TYPE);
if (a > max) {
break;
if (type == 0) {
continue;
}
draw_cross_voxels(Vector3(x + 0.5, y + 0.5, z + 0.5), _buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_ISOLEVEL) / 255.0);
++a;
if (a > max) {
break;
}
}
}
}
//for (int x = 0; x < 30; x++) {
// for (int y = 0; y < 30; y++) {
// for (int z = 0; z < 30; z++) {
//draw_cross_voxels(Vector3(x, y, z));
//
// }
// }
//}
//_debug_drawer->add_sphere(4, 4, 0.5, true);
_debug_drawer->end();*/
_debug_drawer->end();
}
void VoxelChunk::draw_debug_voxel_lights(int max, bool localPosition) {