Also add the new lod generation code to the prop job.

This commit is contained in:
Relintai 2020-10-20 17:10:26 +02:00
parent 6e68267bd0
commit 50701f1740
2 changed files with 28 additions and 25 deletions

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include "../../world/default/voxel_world_default.h" #include "../../world/default/voxel_world_default.h"
#ifdef MESH_UTILS_PRESENT
#include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h"
#endif
Ref<VoxelMesher> VoxelPropJob::get_prop_mesher() const { Ref<VoxelMesher> VoxelPropJob::get_prop_mesher() const {
return _prop_mesher; return _prop_mesher;
} }
@ -283,33 +287,34 @@ void VoxelPropJob::phase_prop() {
} }
} }
/* #ifdef MESH_UTILS_PRESENT
if (should_do()) { if (should_do()) {
if (chunk->get_lod_num() > 4) { if (chunk->get_lod_num() > 4) {
Ref<FastQuadraticMeshSimplifier> fqms; Ref<FastQuadraticMeshSimplifier> fqms;
fqms.instance(); fqms.instance();
fqms->set_preserve_border_edges(true);
fqms->initialize(temp_mesh_arr); fqms->initialize(temp_mesh_arr);
Array arr_merged_simplified;
for (int i = 4; i < chunk->get_lod_num(); ++i) { for (int i = 4; i < chunk->get_lod_num(); ++i) {
fqms->simplify_mesh(arr_merged_simplified[0].size() * 0.8, 7); fqms->simplify_mesh(temp_mesh_arr.size() * 0.8, 7);
arr_merged_simplified = fqms->get_arrays(); temp_mesh_arr = fqms->get_arrays();
if (arr_merged_simplified[0].size() == 0) VisualServer::get_singleton()->mesh_add_surface_from_arrays(
break; chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i),
VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(get_mesh_rid_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH, i), VisualServer::PRIMITIVE_TRIANGLES, arr_merged_simplified); if (chunk->get_library()->get_material(i).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(
if (get_library()->get_material(i).is_valid()) chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0,
VisualServer::get_singleton()->mesh_surface_set_material(get_mesh_rid_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH, i), 0, get_library()->get_material(i)->get_rid()); chunk->get_library()->get_material(i)->get_rid());
} }
} }
if (should_return()) { if (should_return()) {
return; return;
} }
} }
*/ #endif
} }
} }

View File

@ -30,8 +30,6 @@ SOFTWARE.
#include "../default/voxel_chunk_default.h" #include "../default/voxel_chunk_default.h"
//#define MESH_UTILS_PRESENT 1
#ifdef MESH_UTILS_PRESENT #ifdef MESH_UTILS_PRESENT
#include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h" #include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h"
#endif #endif