Тёмный

I added multithreading to the world generation in Godot 

Perfoon
Подписаться 830
Просмотров 8 тыс.
50% 1

Try the Blastronaut Game!
Steam: store.steampow...
WebGL: perfoon.itch.i...

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@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.
@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
@roboreck
@roboreck 3 года назад
Really fun devlog! It’s great to see more technical stuff especially in Godot
@ShiloBuff
@ShiloBuff 6 месяцев назад
What a relatable and discouraging result. I feel your pain.
@JakubSK
@JakubSK 6 месяцев назад
Pre-generate everything in the level upfront and isolate only what's visible in the viewport. Works for multiplayer.
@huguinhuok
@huguinhuok 3 года назад
The game looks amazing, man! Keep it up!
@Sedokun
@Sedokun Месяц назад
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!
@IngresaElNombreDelCanal
@IngresaElNombreDelCanal 3 года назад
El juego se ve entretenido. Suerte.
Далее
They Dared Me To Make A Game...
12:08
Просмотров 799 тыс.
How I store the game data in Godot
10:58
Просмотров 2,7 тыс.
Дежавю, прескевю и жамевю!
00:59
Просмотров 122 тыс.
Пришёл к другу на ночёвку 😂
01:00
Китайка и Зеленый Слайм😂😆
00:20
call_deferred, yield & Threads in Godot
10:39
Просмотров 14 тыс.
A new way to generate worlds (stitched WFC)
10:51
Просмотров 528 тыс.
Making a Raycaster using Godot 4 Compute Shaders!
29:20
I Made My First Game in Godot in 3 Weeks...
26:21
Просмотров 345 тыс.
I Made Minecraft in Godot
28:36
Просмотров 31 тыс.
Random Level Generation with a Walker - Godot Tutorial
26:56
Someone Made Pay 2 Win: The Game And Its Hilarious
14:11
How do non-euclidean games work? | Bitwise
14:19
Просмотров 2,4 млн
The Best Game You'll Never Play - Steel Battalion
28:59
Дежавю, прескевю и жамевю!
00:59
Просмотров 122 тыс.