Add methods and signal in GridMap for multithreading #63201
+92
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #42917. Fixes #63106.
This PR adds two methods and a signal in GridMap for for multithreading:
[1 ] The first method called "set_cell_item_thread_safe" has the same parameters as "set_cell_item" . However, it does not let the main thread execute rendering and physical processing, and is only responsible for writing data and creating basic rendering and physical objects .
[ 2] The second method called "update" can let the main thread refresh the 3D rendering, physics and navgation of cells later according to the data in the GridMap.
[ 3] The siganl called "update_finished" will be emitted after the main thread finishes its work .And It is very useful for thread synchronization .
When the "set_cell_map" method is executed, the update operation of gridmap will be automatically executed by the main thread, and the user cannot control it. When the main thread executes the update operation, the "set_cell_map" method executed by other threads will still write data to the gridmap, which destroys the thread synchronization and causes an error message, making the program skip the update of octant.
In order to achieve thread synchronization, I think it is important for users to control the timing of updates. This is necessary when making sandbox games.