To get the shortest path closer to what you mean, you should stop using fixed points as nodes of an A-star, that is, stop using the center of triangles or the center of triangles.
Try moving the dots as the A-star spreads. For example, use A-star nodes on triangles that:
or the intersection of the triangle edge of the next A-star node with the segment formed by the previous A-star node, and the destination
or the nearest point from the intersection mentioned above at the edge of the triangle of the next A-star node
Or try changing the path nodes after calculating your A-star at the moment, using similar criteria.
Note that this will smooth the final path (like the red line in your drawings). But this will only help reduce revaluation, it does not guarantee the search for the shortest paths, as you had in mind.
Better try changing the nodes of the path after calculating your A-star, using the center of the triangles, using the chain, pulling the funnel algorithm aka This will give you the shortest path through the triangles intersected by the exit path of the A-star.
Brice source share