Can you multi thread tilemap tile assignation ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zeludtnecniv

Hi,
Can you use multi-threading for tile assignation in tilemap ?
I work on a infinite map with multiple layer of tiles. I already create a system of chunk who generate in separate thread before drawing.
It is possible to add the drawing part inside the thread ?

thank by advance.
Vincent

:bust_in_silhouette: Reply From: Wakatta

Super bad idea.
Won’t go into all the specifics here but you typically you do all your drawing on the main thread.

As a consequence you’ll have to do locks and unlocks to sync with it. Recommend using

call_deferred("set_cellv", tile_location, tile_id) 

Hi,
I know it’s a bad idea, I read this page before processing and I already do the drawing part in the main thread. But it’s super inefficient. Even by drawing only on chunk par frame (16 x 16 tiles), I drop down from 120 fps to 40 and I only draw in 3 Tilemaps but i think there is something wrong with my code.

zeludtnecniv | 2022-10-31 15:12