diff --git a/source/simulation2/components/CCmpPathfinder_Vertex.cpp b/source/simulation2/components/CCmpPathfinder_Vertex.cpp
index 5ab11b6..e9f46c2 100644
a
|
b
|
struct SquareSort
|
556 | 556 | } |
557 | 557 | }; |
558 | 558 | |
| 559 | static const u8 LAZINESS = 2; // Maximum tradeoff: improvement to distance from goal <-> path length |
| 560 | |
559 | 561 | void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter, |
560 | 562 | entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance, |
561 | 563 | entity_pos_t range, const PathGoal& goal, pass_class_t passClass, WaypointPath& path) |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
791 | 793 | open.push(qiStart); |
792 | 794 | |
793 | 795 | u16 idBest = START_VERTEX_ID; |
794 | | fixed hBest = start.h; |
| 796 | fixed hBest = start.h.Multiply(start.h); |
795 | 797 | |
796 | 798 | while (!open.empty()) |
797 | 799 | { |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
799 | 801 | VertexPriorityQueue::Item curr = open.pop(); |
800 | 802 | vertexes[curr.id].status = Vertex::CLOSED; |
801 | 803 | |
| 804 | |
| 805 | // The following trick selects the end point using a different criterion. |
| 806 | // This is mostly done because by the time the unit has traversed the path much could have changed, |
| 807 | // e.g. in case of lots of units swarming around a point. |
| 808 | |
| 809 | if (vertexes[curr.id].h.Multiply(vertexes[curr.id].h) + (vertexes[curr.id].g << LAZINESS) < hBest) |
| 810 | { |
| 811 | idBest = curr.id; |
| 812 | hBest = vertexes[curr.id].h.Multiply(vertexes[curr.id].h) + (vertexes[curr.id].g << LAZINESS); |
| 813 | } |
| 814 | |
802 | 815 | // If we've reached the destination, stop |
803 | 816 | if (curr.id == GOAL_VERTEX_ID) |
804 | 817 | { |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
910 | 923 | |
911 | 924 | VertexPriorityQueue::Item t = { (u16)n, g + vertexes[n].h, vertexes[n].h }; |
912 | 925 | open.push(t); |
913 | | |
914 | | // Remember the heuristically best vertex we've seen so far, in case we never actually reach the target |
915 | | if (vertexes[n].h < hBest) |
916 | | { |
917 | | idBest = (u16)n; |
918 | | hBest = vertexes[n].h; |
919 | | } |
920 | 926 | } |
921 | 927 | else // must be OPEN |
922 | 928 | { |