godotengine / godotengine/godot
TileMap getters for cell `TileData` ignore runtime changes stored in `runtime_tile_data_cache`
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
4.2.1.stable
### System information
Windows 10
### Issue description
If you overwrite a tilemaps's navigation data, for example using the _tile_data_runtime_update() function, you can remove navigation from a tilemap tile. This works fine when using the Tilemap navigation. However, when you attempt to use the NavigationRegion2D (linked to the tilemap) and programmatically bake the navigation polygon using bake_navigation_polygon(), these changes are not accounted for.
### Steps to reproduce
1. Create a simple 2d scene with a TileMap and a NavigationRegion2D set to retrieve navigation information from that TileMap.
2. Attach a script to the TileMap and write the following (as an example):
```
func _use_tile_data_runtime_update(layer, coords):
if layer == 0 and coords.x == 1:
return true
return false
func _tile_data_runtime_update(layer, coords, tile_data):
tile_data.set_navigation_polygon(0, null)
return true
```
3. Attach a script to your Root node and write the following:
```
func _ready():
$TileMap.notify_runtime_tile_data_update(0)
$NavigationRegion2D.call_deferred("bake_navigation_polygon")
```
4. From the Debug Menu, enable "Visible Navigation"
5. Run the project. You will see both the tilemap's nav mesh (with column 1 excluded, as expected) and the NavigationRegion2D's nav mesh (without column 1 excluded).
### Minimal reproduction project (MRP)
[Test Navigation.zip](https://github.com/godotengine/godot/files/14610520/Test.Navigation.zip)
Contributor guide
Research direction
Reproduce the issue with the linked minimal reproduction project, starting from TileMap runtime tile data updates and NavigationRegion2D.bake_navigation_polygon(). Compare the TileMap navigation mesh with the region's baked mesh; done means runtime removal of a tile's navigation polygon is reflected in the NavigationRegion2D result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100