Pārlūkot izejas kodu

Fix diagonal paths if we need to use them

Tomasz Zieliński 1 gadu atpakaļ
vecāks
revīzija
7cb17afe7a
1 mainītis faili ar 2 papildinājumiem un 6 dzēšanām
  1. 2 6
      lib/rmg/modificators/RoadPlacer.cpp

+ 2 - 6
lib/rmg/modificators/RoadPlacer.cpp

@@ -121,17 +121,13 @@ bool RoadPlacer::createRoad(const int3 & dst)
 				}
 			}
 
-			auto ret = dst.dist2d(src);
+			float weight = dst.dist2dSQ(src);
+			auto ret =  weight * weight; // Still prefer straight paths
 
 			if (visitableTiles.contains(src) || visitableTiles.contains(dst))
 			{
 				ret *= VISITABLE_PENALTY;
 			}
-			float dist = border.distance(dst);
-			if(dist > 1)
-			{
-				ret /= dist;
-			}
 			return ret;
 		};
 		res = path.search(dst, false, desperateRoutig);