### Godot version

4.1.beta1

### System information

Godot v4.1.beta1 - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.2802) - 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz (12 Threads)

### Issue description

The agent finds the correct path between a and b.

Then the scene is rotated 180 degress.

Now the agent is taking a longer path than it needs to.

https://github.com/godotengine/godot/assets/6430599/3fa04c4f-49a0-468d-9d4c-4a12dee3cb5b



### Steps to reproduce

Download project. Press "a" and "d" to rotate the scene around the z axis.

### Minimal reproduction project

[movenav.zip](https://github.com/godotengine/godot/files/11725682/movenav.zip)

#include "nav_region.h"
#include "nav_map.h"
void NavRegion::set_map(NavMap *p_map) {
	if (map == p_map) {
		return;
	}
	map = p_map;
	polygons_dirty = true;
	if (!map) {
		connections.clear();
	}
}
void NavRegion::set_use_edge_connections(bool p_enabled) {
	if (use_edge_connections != p_enabled) {
		use_edge_connections = p_enabled;
		polygons_dirty = true;
	}
}
void NavRegion::set_transform(Transform3D p_transform) {
	if (transform == p_transform) {
		return;
	}
	transform = p_transform;
	polygons_dirty = true;
}
void NavRegion::set_mesh(Ref<NavigationMesh> p_mesh) {