Repository: godot
Issue: Navigation2D.get_simple_path doesn't return shortest path
Labels: bug,topic:navigation,topic:2d

### Godot version

6ecdef84cf36ba9268ccc19b78210b039098eb52

### System information

Windows 10, GLES3, NVidia GeForce GTX 760 2GiB

### Issue description

This issue continues the story started in #28235

Godot uses A* algorithm to calculate the shortest path between two points through navigation mesh of polygons.
To compute the traveling cost to next polygon:
In some revisions it uses sum of lengths of rectangular perpendiculars from enter point of polygon to common side with the next polygon.
In last revision it uses more complex way, where costs calculated earlier have some correction.

But no one way cannot calculate right traveling cost between polygons because polygons are not points. They have minimum and maximum distance between their points but not have a single cost as a number.

To calculate the shortest path we can use points instead polygons because they have no area and distances between them are constant numbers at one moment of time.

One of these methods is described [here](https://www.david-gouveia.com/pathfinding-on-a-2d-polygonal-map). Main idea to use navmesh vertices as A* nodes and create connections between mutually visible vertices. I used this method when I wrote my pathfinding library. It can be improved by creating connections only between those vertices that have both sides pointing in the same side from the line of the connecting segment.
![image](https://user-images.githubusercontent.com/7024016/174119068-a9b342b5-9444-4422-bffe-7a3cb739f5c3.png)

This method have pros and cons:
Pros: Very fast if navmesh is static and if space is indexed by 2D-array of squares with lots of cross-visibility data
Cons: Greater algorithmic complexity of baking map changes on the fly and space reindexing

Algorithm in action (the picture is a link to YouTube):
[![Showcase of pathfinding](https://img.youtube.com/vi/7vq7Gjkpy3Y/0.jpg)](https://www.youtube.com/watch?v=7vq7Gjkpy3Y)

I don't think my way is the best. But if it helps, I can share the source code of the library. It is rather messy and contains only a naive implementation.

This issue may be related to the following: #60277 and #19011

### Steps to reproduce

- Create `Navigation2D` node under root node
- Create `TileMap` node under `Navigation2D` node
- Create `Line2D` node under root node to visualize found path
- Create simple `TileSet` in `TileMap` node with one or two tiles with square navigation polygon in one of them
- Draw some walkable area by tiles in editor window
- Create script in root node with some code:
```gdscript
extends Node2D

var start: Vector2 = Vector2.ZERO
var finish: Vector2 = Vector2.ZERO

func _input(event):
	if event is InputEventMouseButton:
		if event.pressed:
			match event.button_index:
				BUTTON_LEFT:
					start = get_global_mouse_position()
					update_path()
	elif event is InputEventMouseMotion:
		finish = get_global_mouse_position()
		update_path()

func update_path():
	$Line2D.points = $Navigation2D.get_simple_path(start, finish)
```

Result:
![image](https://user-images.githubusercontent.com/7024016/174063877-382f721e-df09-4f89-bf03-a8ce5b5ce20c.png)

### Minimal reproduction project

[TestNavigationFix.zip](https://github.com/godotengine/godot/files/8919625/TestNavigationFix.zip)