1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

Fixed main issue with custom path routing

This commit is contained in:
Tomasz Zieliński 2024-11-21 22:30:21 +01:00
parent 855ab0f0e9
commit 9277c5f4e7
2 changed files with 4 additions and 8 deletions

View File

@ -116,8 +116,7 @@ Path Path::search(const Tileset & dst, bool straight, std::function<float(const
if(!result.dArea->contains(pos))
return;
float movementCost = moveCostFunction(currentNode, pos) + currentNode.dist2d(pos);
float movementCost = moveCostFunction(currentNode, pos);
float distance = distances[currentNode] + movementCost; //we prefer to use already free paths
int bestDistanceSoFar = std::numeric_limits<int>::max();
auto it = distances.find(pos);
@ -196,15 +195,12 @@ Path::MoveCostFunction Path::createCurvedCostFunction(const Area & border)
return [border = border](const int3& src, const int3& dst) -> float
{
// Route main roads far from border
//float ret = dst.dist2d(src);
float ret = dst.dist2d(src);
float dist = border.distanceSqr(dst);
//int3 closestTile = border.nearest(dst);
//float dist = dst.chebdist2d(closestTile);
if(dist > 1.0f)
{
ret /= dist * dist;
ret /= dist;
}
return ret;
};

View File

@ -91,7 +91,7 @@ bool RoadPlacer::createRoad(const int3 & destination)
float dist = border.distanceSqr(dst);
if(dist > 1.0f)
{
ret /= dist * dist;
ret /= dist;
}
return ret;
}