From a01988fb062c7bfd6021484ff8b79f9b2e7d0062 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 9 Feb 2022 12:45:32 +0100 Subject: [PATCH] Update initialization of all 3 VoxelWorld implementations to use the new style. (It is not yet enabled.) --- world/blocky/voxel_world_blocky.cpp | 39 ++++++++++++++---- world/cubic/voxel_world_cubic.cpp | 40 +++++++++++++++---- world/default/voxel_world_default.cpp | 16 +++++--- .../voxel_world_marching_cubes.cpp | 38 +++++++++++++++--- 4 files changed, 106 insertions(+), 27 deletions(-) diff --git a/world/blocky/voxel_world_blocky.cpp b/world/blocky/voxel_world_blocky.cpp index 3bd57fd..c7b2d65 100644 --- a/world/blocky/voxel_world_blocky.cpp +++ b/world/blocky/voxel_world_blocky.cpp @@ -24,33 +24,58 @@ SOFTWARE. #include "voxel_chunk_blocky.h" +#include "../../defines.h" #include "../../meshers/blocky/voxel_mesher_blocky.h" #include "../../meshers/blocky/voxel_mesher_liquid_blocky.h" #include "../jobs/voxel_light_job.h" #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrain_job.h" -#include "../../defines.h" Ref VoxelWorldBlocky::_create_chunk(int x, int y, int z, Ref chunk) { - if (!chunk.is_valid()) { chunk = Ref(memnew(VoxelChunkBlocky)); } if (chunk->job_get_count() == 0) { + Ref lj; + lj.INSTANCE(); + Ref tj; tj.INSTANCE(); - Ref lj; - lj.INSTANCE(); + Ref s; + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_NORMAL); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_DROP_UV2); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_MERGE_VERTS); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_BAKE_TEXTURE); + tj->add_jobs_step(s); + +#ifdef MESH_UTILS_PRESENT + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_SIMPLIFY_MESH); + s->set_simplification_step_ratio(0.8); + s->set_simplification_agressiveness(7); + s->set_simplification_steps(1); + tj->add_jobs_step(s); +#endif + + tj->add_mesher(Ref(memnew(VoxelMesherBlocky()))); + tj->add_liquid_mesher(Ref(memnew(VoxelMesherLiquidBlocky()))); Ref pj; pj.INSTANCE(); pj->set_prop_mesher(Ref(memnew(VoxelMesherBlocky))); - tj->add_mesher(Ref(memnew(VoxelMesherBlocky()))); - tj->add_liquid_mesher(Ref(memnew(VoxelMesherLiquidBlocky()))); - chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); diff --git a/world/cubic/voxel_world_cubic.cpp b/world/cubic/voxel_world_cubic.cpp index 1acfb7a..149f654 100644 --- a/world/cubic/voxel_world_cubic.cpp +++ b/world/cubic/voxel_world_cubic.cpp @@ -30,29 +30,53 @@ SOFTWARE. #include "../jobs/voxel_terrain_job.h" Ref VoxelWorldCubic::_create_chunk(int x, int y, int z, Ref chunk) { - if (!chunk.is_valid()) { chunk = Ref(memnew(VoxelChunkCubic)); } if (chunk->job_get_count() == 0) { - Ref tj; - tj.INSTANCE(); - Ref lj; lj.INSTANCE(); - Ref pj; - pj.INSTANCE(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherCubic))); + Ref tj; + tj.INSTANCE(); + + Ref s; + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_NORMAL); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_DROP_UV2); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_MERGE_VERTS); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_BAKE_TEXTURE); + tj->add_jobs_step(s); + +#ifdef MESH_UTILS_PRESENT + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_SIMPLIFY_MESH); + s->set_simplification_step_ratio(0.8); + s->set_simplification_agressiveness(7); + s->set_simplification_steps(1); + tj->add_jobs_step(s); +#endif Ref m = Ref(memnew(VoxelMesherCubic())); m->set_channel_index_type(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); m->set_channel_index_isolevel(VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - tj->add_mesher(m); //add_liquid_mesher(Ref(memnew(VoxelMesherLiquidMarchingCubes()))); + Ref pj; + pj.INSTANCE(); + pj->set_prop_mesher(Ref(memnew(VoxelMesherCubic))); + chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); diff --git a/world/default/voxel_world_default.cpp b/world/default/voxel_world_default.cpp index 9bf6bf9..afd46b9 100644 --- a/world/default/voxel_world_default.cpp +++ b/world/default/voxel_world_default.cpp @@ -182,15 +182,11 @@ Ref VoxelWorldDefault::_create_chunk(int x, int y, int z, Refjob_get_count() == 0) { - Ref tj; - tj.instance(); - Ref lj; lj.instance(); - Ref pj; - pj.instance(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherDefault))); + Ref tj; + tj.instance(); Ref s; s.instance(); @@ -218,6 +214,14 @@ Ref VoxelWorldDefault::_create_chunk(int x, int y, int z, Refadd_jobs_step(s); #endif + tj->add_mesher(Ref(memnew(VoxelMesherDefault()))); + //tj->add_liquid_mesher(Ref(memnew(VoxelMesherDefault()))); + + Ref pj; + pj.instance(); + pj->set_prop_mesher(Ref(memnew(VoxelMesherDefault))); + + // Order matters! chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); diff --git a/world/marching_cubes/voxel_world_marching_cubes.cpp b/world/marching_cubes/voxel_world_marching_cubes.cpp index 0c6fa25..b949603 100644 --- a/world/marching_cubes/voxel_world_marching_cubes.cpp +++ b/world/marching_cubes/voxel_world_marching_cubes.cpp @@ -35,15 +35,37 @@ Ref VoxelWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref< } if (chunk->job_get_count() == 0) { - Ref tj; - tj.INSTANCE(); - Ref lj; lj.INSTANCE(); - Ref pj; - pj.INSTANCE(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherMarchingCubes))); + Ref tj; + tj.INSTANCE(); + + Ref s; + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_NORMAL); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_DROP_UV2); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_MERGE_VERTS); + tj->add_jobs_step(s); + + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_BAKE_TEXTURE); + tj->add_jobs_step(s); + +#ifdef MESH_UTILS_PRESENT + s.instance(); + s->set_job_type(VoxelMesherJobStep::TYPE_SIMPLIFY_MESH); + s->set_simplification_step_ratio(0.8); + s->set_simplification_agressiveness(7); + s->set_simplification_steps(1); + tj->add_jobs_step(s); +#endif Ref m = Ref(memnew(VoxelMesherMarchingCubes())); m->set_channel_index_type(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); @@ -52,6 +74,10 @@ Ref VoxelWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref< tj->add_mesher(m); //add_liquid_mesher(Ref(memnew(VoxelMesherLiquidMarchingCubes()))); + Ref pj; + pj.INSTANCE(); + pj->set_prop_mesher(Ref(memnew(VoxelMesherMarchingCubes))); + chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj);