I added multithreading to the world generation in Godot

  Рет қаралды 8,250

Perfoon

Perfoon

Күн бұрын

Пікірлер: 26
@ShiloBuff
@ShiloBuff 10 ай бұрын
What a relatable and discouraging result. I feel your pain.
@AdaLollA
@AdaLollA Жыл бұрын
you just saved me days of coding! thank you so much. i would have gone through the exact same steps as you did, but now i know which work and which don't. you're the man
@Zuriki09
@Zuriki09 3 жыл бұрын
Hi, looking at the code snippets in the video, you have a few major issues: 1. Dictionaries are not ideal for this, they are relatively slow in comparison to other options, you should use PoolIntArray as this is the same as internal data of tilemap (see godot source code for format info) 2. Using set_cell in a loop will kill you on function call overhead, you want to set your tile data in bulk, thankfully you can use set("tile_data",...) method for this Arrays are thread safe so long as they don't change size, so try and collate as many threads into one payload and call the setter as late as possible/as few times as possible. Because the logic of setting each tile is now called within the engine instead of the script interpreter you get very little overhead. I think this should resolve your performance issues.
@Perfoon
@Perfoon 3 жыл бұрын
Thank you for this great feedback! 1. Replacing dictionaries with arrays is a valid point. It was just easier to implement it with dictionaries at first and currently, they are mostly used inside the threads. But if I ever get some results that would improve the performance, I will definitely replace them with arrays. 2. set_cell is indeed what is killing the performance right now. There is some discussion in Godot Github about adding a solution for setting cells via an array, and some people have tried to implement something similar. But it seems that this thread has got a bit stuck recently, so I won't put my hopes too high: github.com/godotengine/godot/issues/31020 I learned about the undocumented feature of setting the tilemap data by using set("tile_data",...) yesterday. Unfortunately, I think it won't help me in this case. Because what it does is that it clears the entire tilemap and adds all the tiles from the array (by calling set_cell internally). But I need to add the tiles iteratively and this means that I would have to rewrite all the tiles every time a thread finishes, which is definitely way slower. github.com/godotengine/godot/blob/3.2/scene/2d/tile_map.cpp#L1204 Thank you very much for your suggestions. All the help is appreciated!
@Zuriki09
@Zuriki09 3 жыл бұрын
@@Perfoon it's possible to write a C++ module to extend the class and strip the call to clear() - a little burdensome but probably worth the headache for you I think. Might even be possible just using a Gdnative plugin, but that will preclude compiling to Web if it matters to you.
@Perfoon
@Perfoon 3 жыл бұрын
@@Zuriki09yep, I also considered forking the Godot source and implementing the set_cell by the array myself. But I'm afraid all those options require a considerable amount of effort, which I could also use to improve the game itself :)
@Zuriki09
@Zuriki09 3 жыл бұрын
​ @Perfoon yes, I totally understand. At the very least I would give a try to: 1. Swap Dictionary for PoolIntArray 2. Queue changes from threads and submit them in bulk once per update Just be aware that threads may finish at any time during process so you will want to make a copy of the queued changes array for processing on the main thread.
@JakubSK
@JakubSK 10 ай бұрын
Pre-generate everything in the level upfront and isolate only what's visible in the viewport. Works for multiplayer.
@roboreck
@roboreck 3 жыл бұрын
Really fun devlog! It’s great to see more technical stuff especially in Godot
@huguinhuok
@huguinhuok 3 жыл бұрын
The game looks amazing, man! Keep it up!
@Sedokun
@Sedokun 5 ай бұрын
Thank you for sharing.
@fille.imgnry
@fille.imgnry 2 жыл бұрын
Thanks for sharing!
@junimeme5626
@junimeme5626 3 жыл бұрын
The game looks great!
@aimarsoots5375
@aimarsoots5375 3 жыл бұрын
Keep it up!
@Tudvari
@Tudvari 3 жыл бұрын
The steam link in the description is broken :\
@Perfoon
@Perfoon 3 жыл бұрын
Yep, I copied it without the tail. Thank you for letting me know!
How I store the game data in Godot
10:58
Perfoon
Рет қаралды 2,7 М.
AutoTiles OpenSimplex Noise Procedural Generation Godot 3.1 Tutorial
16:39
Gingerageous Games
Рет қаралды 37 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
call_deferred, yield & Threads in Godot
10:39
Ombarus
Рет қаралды 15 М.
Making a Raycaster using Godot 4 Compute Shaders!
29:20
binary_soup
Рет қаралды 19 М.
Restarting My Dream Game | Godot Game Devlog
10:21
mz_eth
Рет қаралды 41 М.
Why has Black & White Been Abandoned? - Noclip Greatest Hits
28:44
Noclip - Video Game Documentaries
Рет қаралды 731 М.
How Games Have Worked for 30 Years to Do Less Work
23:40
SimonDev
Рет қаралды 1,4 МЛН
Developing a tactics engine in Godot
11:58
The Shaggy Dev
Рет қаралды 185 М.
How Games Make VFX (Demonstrated in Godot 4)
5:46
PlayWithFurcifer
Рет қаралды 367 М.
The Best New Feature in Godot 4.4*
7:06
Gamefromscratch
Рет қаралды 24 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН