Browse Source

Fix TileMaps with origin offset placing NavPolygons wrong without a Navigation2D node

The legacy navigation was positioning baked TileMap navpolygons relative to the current Navigation2D node assuming that it is usually one of the parent nodes.

Without the deprecated Navigation2D node the default navigation map of the world_2d is used. This navigation map has no relative Node2D so it needs to use the global_transform of the TileMap to place navregions with the correct offset in case the TileMap is moved from the origin.

(cherry picked from commit 881e49c375f126987aa57528d6f8ef70462869c6)
smix8 3 năm trước cách đây
mục cha
commit
3b9355be3f
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      scene/2d/tile_map.cpp

+ 2 - 2
scene/2d/tile_map.cpp

@@ -160,7 +160,7 @@ void TileMap::_update_quadrant_transform() {
 		if (navigation) {
 			nav_rel = get_relative_transform_to_parent(navigation);
 		} else {
-			nav_rel = get_transform();
+			nav_rel = get_global_transform();
 		}
 	}
 
@@ -346,7 +346,7 @@ void TileMap::update_dirty_quadrants() {
 		if (navigation) {
 			nav_rel = get_relative_transform_to_parent(navigation);
 		} else {
-			nav_rel = get_transform();
+			nav_rel = get_global_transform();
 		}
 	}