mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
More cleanup, and fixed a misunderstanding.
This commit is contained in:
parent
ba05f93aa2
commit
b50c9be4e7
@ -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 VoxelMesherTransvoxel::get_regular_vertex_data_first_vertex(int index1, int index2) const {
|
||||||
int vert1 = regularVertexData[index1][index2] & 0x000F;
|
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 vert1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelMesherTransvoxel::get_regular_vertex_data_second_vertex(int index1, int index2) const {
|
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;
|
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
|
||||||
|
|
||||||
//The paper says, that the smaller vertex index should be considered first
|
return vert2;
|
||||||
if (vert2 > vert1) {
|
|
||||||
return vert2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vert1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 VoxelMesherTransvoxel::get_regular_vertex_start_position(int index1, int index2) const {
|
Vector3 VoxelMesherTransvoxel::get_regular_vertex_start_position(int index1, int index2) const {
|
||||||
int vert1 = regularVertexData[index1][index2] & 0x000F;
|
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];
|
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 vert1 = regularVertexData[index1][index2] & 0x000F;
|
||||||
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
|
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];
|
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 {
|
Vector3 VoxelMesherTransvoxel::get_transition_vertex_start_position(int index1, int index2) const {
|
||||||
int vert1 = regularVertexData[index1][index2] & 0x000F;
|
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];
|
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 vert1 = regularVertexData[index1][index2] & 0x000F;
|
||||||
int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4;
|
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];
|
return transvoxel_vertices[vert2] - transvoxel_vertices[vert1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,6 @@ void VoxelChunk::draw_cross_voxels(Vector3 pos, float fill) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunk::draw_debug_voxels(int max, Color color) {
|
void VoxelChunk::draw_debug_voxels(int max, Color color) {
|
||||||
/*
|
|
||||||
if (_debug_drawer == NULL) {
|
if (_debug_drawer == NULL) {
|
||||||
Node *n = get_node(_debug_drawer_path);
|
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);
|
ERR_FAIL_COND(_debug_drawer == NULL);
|
||||||
|
|
||||||
//if (_debug_drawer->emt)
|
|
||||||
|
|
||||||
_debug_drawer->clear();
|
_debug_drawer->clear();
|
||||||
_debug_drawer->begin(Mesh::PRIMITIVE_LINES);
|
_debug_drawer->begin(Mesh::PRIMITIVE_LINES);
|
||||||
_debug_drawer->set_color(color);
|
_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;
|
int a = 0;
|
||||||
while ((k = map->next(k))) {
|
Vector3i size = _buffer->get_size();
|
||||||
Ref<Voxel> v = map->get(*k);
|
|
||||||
ERR_FAIL_COND(!v.is_valid());
|
|
||||||
|
|
||||||
Vector3i lp = v->get_local_position();
|
for (int y = 0; y < size.y; ++y) {
|
||||||
//print_error(Vector3(lp.x, lp.y, lp.z));
|
for (int z = 0; z < size.z; ++z) {
|
||||||
draw_cross_voxels(Vector3(lp.x + 0.5, lp.y + 0.5, lp.z + 0.5), v->get_fill() / 255.0);
|
for (int x = 0; x < size.x; ++x) {
|
||||||
|
|
||||||
a++;
|
int type = _buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_TYPE);
|
||||||
|
|
||||||
if (a > max) {
|
if (type == 0) {
|
||||||
break;
|
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++) {
|
_debug_drawer->end();
|
||||||
// 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();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelChunk::draw_debug_voxel_lights(int max, bool localPosition) {
|
void VoxelChunk::draw_debug_voxel_lights(int max, bool localPosition) {
|
||||||
|
Loading…
Reference in New Issue
Block a user