From 32b98c0b458cde977636c04fe1b92c9f00aa53e9 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 9 Feb 2022 13:50:19 +0100 Subject: [PATCH] Removed now obsolete old code. By the way with the previous commit #6 should be fixed now. Thanks. --- world/jobs/voxel_prop_job.cpp | 253 ---------------------------------- world/jobs/voxel_prop_job.h | 2 - 2 files changed, 255 deletions(-) diff --git a/world/jobs/voxel_prop_job.cpp b/world/jobs/voxel_prop_job.cpp index d3a9f06..fb495b7 100644 --- a/world/jobs/voxel_prop_job.cpp +++ b/world/jobs/voxel_prop_job.cpp @@ -135,231 +135,6 @@ void VoxelPropJob::phase_physics_process() { next_phase(); } -void VoxelPropJob::old_phase_prop() { -#ifdef MESH_DATA_RESOURCE_PRESENT - Ref chunk = _chunk; - - if (!get_prop_mesher().is_valid()) { - set_complete(true); //So threadpool knows it's done - next_job(); - return; - } - - if (should_do()) { - if (chunk->mesh_data_resource_get_count() == 0) { - set_complete(true); //So threadpool knows it's done - next_job(); - return; - } - - for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { - if (chunk->mesh_data_resource_get_is_inside(i)) { - get_prop_mesher()->add_mesh_data_resource_transform(chunk->mesh_data_resource_get(i), chunk->mesh_data_resource_get_transform(i), chunk->mesh_data_resource_get_uv_rect(i)); - } - } - - if (get_prop_mesher()->get_vertex_count() == 0) { - //reset_stages(); - - set_complete(true); //So threadpool knows it's done - next_job(); - return; - } - - if (should_return()) { - return; - } - } - - if (should_do()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { - get_prop_mesher()->bake_colors(_chunk); - } - - if (should_return()) { - return; - } - } - - if (should_do()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { - VoxelWorldDefault *world = Object::cast_to(chunk->get_voxel_world()); - - if (world) { - for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { - if (!chunk->mesh_data_resource_get_is_inside(i)) { - Ref mdr = chunk->mesh_data_resource_get(i); - - ERR_CONTINUE(!mdr.is_valid()); - - Transform trf = chunk->mesh_data_resource_get_transform(i); - - Array arr = mdr->get_array(); - - if (arr.size() <= Mesh::ARRAY_VERTEX) { - continue; - } - - PoolVector3Array varr = arr[Mesh::ARRAY_VERTEX]; - - if (varr.size() == 0) { - continue; - } - - PoolColorArray carr = world->get_vertex_colors(trf, varr); - - get_prop_mesher()->add_mesh_data_resource_transform_colored(mdr, trf, carr, chunk->mesh_data_resource_get_uv_rect(i)); - } - } - } - } - - if (should_return()) { - return; - } - } - - // OK UP - - if (get_prop_mesher()->get_vertex_count() != 0) { - if (should_do()) { - temp_mesh_arr = get_prop_mesher()->build_mesh(); - - if (should_return()) { - return; - } - } - - RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); - - if (should_do()) { - if (mesh_rid == RID()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, chunk->get_lod_num() + 1); - else - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, 1); - - mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); - } - - if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) -#if !GODOT4 - VS::get_singleton()->mesh_remove_surface(mesh_rid, 0); -#else - VS::get_singleton()->mesh_clear(mesh_rid); -#endif - - if (should_return()) { - return; - } - } - - if (should_do()) { - VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); - - if (chunk->get_library()->prop_material_get(0).is_valid()) - VS::get_singleton()->mesh_surface_set_material(mesh_rid, 0, chunk->get_library()->prop_material_get(0)->get_rid()); - - if (should_return()) { - return; - } - } - - // OK UP - - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { - if (should_do()) { - if (chunk->get_lod_num() >= 1) { - //for lod 1 just remove uv2 - temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant(); - - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); - - if (chunk->get_library()->prop_material_get(1).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->prop_material_get(1)->get_rid()); - } - - if (should_return()) { - return; - } - } - // OK UP - if (should_do()) { - if (chunk->get_lod_num() >= 2) { - Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); - temp_mesh_arr = temp_mesh_arr2; - - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2); - - if (chunk->get_library()->prop_material_get(2).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->prop_material_get(2)->get_rid()); - } - if (should_return()) { - return; - } - } - // OK UP - // if (should_do()) { - if (chunk->get_lod_num() >= 3) { - Ref mat = chunk->get_library()->prop_material_get(0); - Ref spmat = chunk->get_library()->prop_material_get(0); - Ref tex; - - if (mat.is_valid()) { - tex = mat->get_shader_param("texture_albedo"); - } else if (spmat.is_valid()) { - tex = spmat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); - } - - if (tex.is_valid()) { - temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex); - temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant(); - - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); - - if (chunk->get_library()->prop_material_get(3).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->prop_material_get(3)->get_rid()); - } - } - - // OK UP -#ifdef MESH_UTILS_PRESENT - if (should_do()) { - if (chunk->get_lod_num() > 4) { - Ref fqms; - fqms.INSTANCE(); - fqms->set_preserve_border_edges(true); - fqms->initialize(temp_mesh_arr); - - for (int i = 4; i < chunk->get_lod_num(); ++i) { - fqms->simplify_mesh(temp_mesh_arr.size() * 0.8, 7); - temp_mesh_arr = fqms->get_arrays(); - - VisualServer::get_singleton()->mesh_add_surface_from_arrays( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRAIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), - VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); - - if (chunk->get_library()->prop_material_get(i).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRAIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0, - chunk->get_library()->prop_material_get(i)->get_rid()); - } - } - - if (should_return()) { - return; - } - } -#endif - } - } - -#endif - - set_complete(true); //So threadpool knows it's done - next_job(); -} - void VoxelPropJob::phase_prop() { #ifdef MESH_DATA_RESOURCE_PRESENT Ref chunk = _chunk; @@ -452,34 +227,6 @@ void VoxelPropJob::_physics_process(float delta) { phase_physics_process(); } -void VoxelPropJob::old_execute_phase() { - ERR_FAIL_COND(!_chunk.is_valid()); - - Ref library = _chunk->get_library(); - - ERR_FAIL_COND(!library.is_valid()); - - Ref chunk = _chunk; - - if (!chunk.is_valid() -#ifdef MESH_DATA_RESOURCE_PRESENT - || chunk->mesh_data_resource_get_count() == 0 -#endif - ) { - set_complete(true); - next_job(); - return; - } - - if (_phase == 1) { - old_phase_prop(); - } else if (_phase > 1) { - set_complete(true); //So threadpool knows it's done - next_job(); - ERR_FAIL_MSG("VoxelPropJob: _phase is too high!"); - } -} - void VoxelPropJob::_execute_phase() { ERR_FAIL_COND(!_chunk.is_valid()); diff --git a/world/jobs/voxel_prop_job.h b/world/jobs/voxel_prop_job.h index 8c0f468..48474a3 100644 --- a/world/jobs/voxel_prop_job.h +++ b/world/jobs/voxel_prop_job.h @@ -43,11 +43,9 @@ public: int get_jobs_step_count() const; void phase_physics_process(); - void old_phase_prop(); void phase_prop(); void _physics_process(float delta); - void old_execute_phase(); void _execute_phase(); void _reset();