mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Heavier penalty for routing roads behind monoliths
This commit is contained in:
@ -76,25 +76,35 @@ bool RoadPlacer::createRoad(const int3 & destination)
|
|||||||
|
|
||||||
auto simpleRoutig = [this, &border](const int3& src, const int3& dst)
|
auto simpleRoutig = [this, &border](const int3& src, const int3& dst)
|
||||||
{
|
{
|
||||||
if(areaIsolated().contains(dst))
|
if(std::abs((src - dst).y) == 1)
|
||||||
{
|
{
|
||||||
return 1000.0f; //Do not route road behind objects that are not visitable from top, such as Monoliths
|
//Do not allow connections straight up through object not visitable from top
|
||||||
|
if(areaIsolated().contains(dst) || areaIsolated().contains(src))
|
||||||
|
{
|
||||||
|
return 1e12f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float ret = dst.dist2d(src);
|
if(areaIsolated().contains(dst))
|
||||||
|
|
||||||
if (visitableTiles.contains(src) || visitableTiles.contains(dst))
|
|
||||||
{
|
{
|
||||||
ret *= VISITABLE_PENALTY;
|
//Simply do not route road behind objects that are not visitable from top, such as Monoliths
|
||||||
|
return 1e6f;
|
||||||
}
|
}
|
||||||
float dist = border.distanceSqr(dst);
|
|
||||||
if(dist > 1.0f)
|
|
||||||
{
|
|
||||||
ret /= dist;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ret = dst.dist2d(src);
|
||||||
|
|
||||||
|
if (visitableTiles.contains(src) || visitableTiles.contains(dst))
|
||||||
|
{
|
||||||
|
ret *= VISITABLE_PENALTY;
|
||||||
|
}
|
||||||
|
float dist = border.distanceSqr(dst);
|
||||||
|
if(dist > 1.0f)
|
||||||
|
{
|
||||||
|
ret /= dist;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto res = path.search(destination, true, simpleRoutig);
|
auto res = path.search(destination, true, simpleRoutig);
|
||||||
|
Reference in New Issue
Block a user