Hello!
I'm just learning Redot, and wanted to start easy with a Minecraft knock-off to get the hang of the environment. Instead of developing my own system with chunks generating meshes, I decide to have the chunks send information to a GridMap object that all chunks can interact with. The chunk handles adding and removing cell items to the GridMap. The chunks are processed on a secondary thread, while the calls to modify the GridMap are deferred to the main thread, since it can't be edited from the secondary thread.
Here's the problem I'm encountering:
While testing edge cases with high speed, it seems that the command to unload a chunk (remove all cells in the area) can cause a crash. It seems that the GridMap can recognize that the cell exists but says that the octant does not. It would seem that the octant is removed in the main thread, before the command to unload the chunk is sent to the secondary thread, leading the second thread to try removing cells in octants that don't exist.
While this is a bug caused by testing the edge case, it still seems like unintended behavior. Is there a more thread-safe approach to doing something like this? I'd appreciate any input on this. Creating my own system for handling block meshes in the chunks is certainly a solution, but I'd like to hear if there are alternatives that use the GridMap, if for no other reason than to make use of existing features in the engine.