From bfd41efd2e64092b68b995cf1afb596a927de577 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 6 Oct 2020 20:10:30 +0200 Subject: [PATCH] Updated voxelman to the latest. Mesher/job creation now have to be handled by the world's _create_chunk. --- HEADS | 2 +- game/voxelman/world/TVVoxelChunk.gd | 8 ++++- game/voxelman/world/TVVoxelWorld.gd | 52 ++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/HEADS b/HEADS index 03852858..1462f7e5 100644 --- a/HEADS +++ b/HEADS @@ -1 +1 @@ -{"engine": {"3.2": "4162df439727fad01b0d1240df69f59ba97ed422", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "cdc8b7830daf3341871be1c9b38eceeed947f4a1"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "3add3daef4c4f90a435ffff68a5714c3921634f5"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}} \ No newline at end of file +{"engine": {"3.2": "4162df439727fad01b0d1240df69f59ba97ed422", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "cdc8b7830daf3341871be1c9b38eceeed947f4a1"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "90fe105b54c85b80735df4544e980fcc5e5fe32b"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}} \ No newline at end of file diff --git a/game/voxelman/world/TVVoxelChunk.gd b/game/voxelman/world/TVVoxelChunk.gd index 9cf03dae..b57377dd 100644 --- a/game/voxelman/world/TVVoxelChunk.gd +++ b/game/voxelman/world/TVVoxelChunk.gd @@ -37,6 +37,13 @@ var _prop_mesh_rid : RID # add_mesh_data_resource(get_transform().scaled(Vector3(10, 10, 10)), ResourceLoader.load("res://modules/species/Human/Female/character_models/huf_calf_left.gltf")) # add_mesh_data_resource(get_transform().translated(Vector3(0, 4, 0)), ResourceLoader.load("res://modules/species/Human/Female/character_models/huf_calf_left.gltf")) +#func _init(): +# _prop_texture_packer = TexturePacker.new() +# _prop_texture_packer.max_atlas_size = 1024 +# _prop_texture_packer.margin = 1 +# _prop_texture_packer.background_color = Color(0, 0, 0, 1) +# _prop_texture_packer.texture_flags = Texture.FLAG_MIPMAPS + func _create_meshers(): var tj : VoxelTerrarinJob = VoxelTerrarinJob.new() @@ -64,7 +71,6 @@ func _create_meshers(): mesher.channel_index_isolevel = VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL tj.add_mesher(mesher) - var cmesher : VoxelMesherBlocky = VoxelMesherBlocky.new() cmesher.texture_scale = 3 cmesher.base_light_value = 0.45 diff --git a/game/voxelman/world/TVVoxelWorld.gd b/game/voxelman/world/TVVoxelWorld.gd index 62f43557..452ab316 100644 --- a/game/voxelman/world/TVVoxelWorld.gd +++ b/game/voxelman/world/TVVoxelWorld.gd @@ -202,12 +202,56 @@ func get_chunk_lod_level(x : int, y : int, z : int, default : int) -> int: return ch.lod_size func _create_chunk(x : int, y : int, z : int, pchunk : VoxelChunk) -> VoxelChunk: - var chunk : VoxelChunk = TVVoxelChunk.new() + if !pchunk: + pchunk = TVVoxelChunk.new() - #chunk.meshing_create_collider = false + var tj : VoxelTerrarinJob = VoxelTerrarinJob.new() + var lj : VoxelLightJob = VoxelLightJob.new() + var pj : VoxelPropJob = VoxelPropJob.new() + + var prop_mesher = TVVoxelMesher.new() + prop_mesher.base_light_value = 0.45 + prop_mesher.ao_strength = 0.2 + prop_mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034) + prop_mesher.voxel_scale = voxel_scale + prop_mesher.build_flags = build_flags + prop_mesher.texture_scale = 3 + + pj.set_prop_mesher(prop_mesher); -# print("added " + str(Vector3(x, y, z))) - return ._create_chunk(x, y, z, chunk) + var mesher : TVVoxelMesher = TVVoxelMesher.new() + mesher.base_light_value = 0.45 + mesher.ao_strength = 0.2 + mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034) + mesher.voxel_scale = voxel_scale + mesher.build_flags = build_flags + mesher.texture_scale = 3 + mesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE + mesher.channel_index_isolevel = VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL + tj.add_mesher(mesher) + + var cmesher : VoxelMesherBlocky = VoxelMesherBlocky.new() + cmesher.texture_scale = 3 + cmesher.base_light_value = 0.45 + cmesher.ao_strength = 0.2 + cmesher.voxel_scale = voxel_scale + cmesher.build_flags = build_flags + + if cmesher.build_flags & VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING != 0: + cmesher.build_flags = cmesher.build_flags ^ VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING + + cmesher.always_add_colors = true + + # cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE + cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE + tj.add_mesher(cmesher) + + pchunk.add_job(lj) + pchunk.add_job(tj) + pchunk.add_job(pj) + + + return ._create_chunk(x, y, z, pchunk) func spawn(start_x : int, start_y : int, start_z : int) -> void: if not Engine.editor_hint: