diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-09-19 06:28:21 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-09-19 06:28:21 -0400 |
commit | 9bc2a0767e15d4dde7fd6231b07882d6456af71e (patch) | |
tree | 1cc9b88eadf86c7df16ed01418cf64d0c8b92d3b /world/chunk/ChunkLoader.gd | |
parent | 354287265bda1448935c05e76455cff18d57f5da (diff) | |
download | game_jam49-9bc2a0767e15d4dde7fd6231b07882d6456af71e.tar.gz game_jam49-9bc2a0767e15d4dde7fd6231b07882d6456af71e.zip |
Use MultiMesh to dramatically increase performance of generated world
Diffstat (limited to 'world/chunk/ChunkLoader.gd')
-rw-r--r-- | world/chunk/ChunkLoader.gd | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/world/chunk/ChunkLoader.gd b/world/chunk/ChunkLoader.gd index 9f1d9b3..2e01bca 100644 --- a/world/chunk/ChunkLoader.gd +++ b/world/chunk/ChunkLoader.gd @@ -24,6 +24,14 @@ func _exit_tree(): func add_chunk(coords:Vector2): chunks[coords] = coords.length() +func free_chunk(coords:Vector2): + if !loaded_chunks.has(coords): + return + var c = loaded_chunks[coords].get_ref() + if c != null: + c.queue_free() + loaded_chunks.erase(coords) + func chunk_update(): var closest_unloaded_chunk = null var closest_len = 0.0 @@ -40,10 +48,7 @@ func chunk_update(): mtx.unlock() for chunk in loaded_chunks.keys(): if !chunks.has(chunk): - var c = loaded_chunks[chunk].get_ref() - if c != null: - c.queue_free() - loaded_chunks.erase(chunk) + free_chunk(chunk) chunks = {} func chunk_loader(): |