I'm working with a navmesh of an existing game. There are two components of the navmesh data: rectangles (min corner and max corner) which represent the cells and edges (min point, max point, src cell, dest cell, and whether the edge is walkable or not) which represent portals between cells. I'm not sure how to find the shortest path between two points generally in this navmesh.
I had an impression that the steps of finding the path were quite easy after reading this article: https://www.gamedev.net/tutorials/programming/artificial-intelligence/navigation-meshes-and-pathfinding-r4880/
I expected that I could: 1. Find the sequence of cells which contain the shortest path. 2. Use a string-pulling algorithm to take some unnecessary steps out of the path.
However after a lot of trial an error, step 1 it turning out to be quite difficult. I have completed a couple different iterations where I get suboptimal paths. In both cases, I'm creating a graph based on the cells' geometry and the connectivity between cells. I then search this graph using Dijkstra's algorithm and the physical distances between the nodes I've created.
https://imgur.com/a/Rt3jZRu In this first case, I connect the midpoint of every cell to the midpoint of every portal from/to that cell.
https://imgur.com/a/ULIeEta In this other case, I connect the min and max point of a portal to the min and max point of every other portal in the same cell. In both cases I'm ending up with a suboptimal sequence of cells. I'm at the point where I don't have any ideas how to find a more accurate sequence of cells or if this two-part high level algorithm I've described is even the right approach.