From 555d2e1878f264c48d8fedb99eebbad4b4cf6f06 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 28 Jul 2020 22:15:29 +0200 Subject: [PATCH] Let's not call update_lods() in a loop. This fixes the framerate drops on weaker devices, like phones. Also increase the chunk despawn range by one. --- game/voxelman/world/TVVoxelWorld.gd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/game/voxelman/world/TVVoxelWorld.gd b/game/voxelman/world/TVVoxelWorld.gd index 99eb56a1..a026fedc 100644 --- a/game/voxelman/world/TVVoxelWorld.gd +++ b/game/voxelman/world/TVVoxelWorld.gd @@ -90,13 +90,11 @@ func _process(delta): var l : float = (Vector2(cpos.x, cpos.z) - Vector2(c.position_x, c.position_z)).length() - if l > chunk_spawn_range + 2: + if l > chunk_spawn_range + 3: # print("despawn " + str(Vector3(c.position_x, c.position_y, c.position_z))) remove_chunk_index(i) i -= 1 count -= 1 - else: - update_lods() # else: # var dx : int = abs(ppx - c.position_x) # var dy : int = abs(ppy - c.position_y) @@ -115,12 +113,15 @@ func _process(delta): i += 1 + for x in range(-chunk_spawn_range + int(cpos.x), chunk_spawn_range + int(cpos.x)): for z in range(-chunk_spawn_range + int(cpos.z), chunk_spawn_range + int(cpos.z)): for y in range(-1, 2): if not has_chunk(x, y, z): # print("spawn " + str(Vector3(x, y, z))) create_chunk(x, y, z) + + update_lods() #func _process(delta : float) -> void: # if not generation_queue.empty():