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.

This commit is contained in:
Relintai 2020-07-28 22:15:29 +02:00
parent 445896d23c
commit 555d2e1878

View File

@ -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,6 +113,7 @@ 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):
@ -122,6 +121,8 @@ func _process(delta):
# print("spawn " + str(Vector3(x, y, z)))
create_chunk(x, y, z)
update_lods()
#func _process(delta : float) -> void:
# if not generation_queue.empty():
# var chunk : VoxelChunk = generation_queue.front()