mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:09:16 +00:00
Create the CityPainter placement constraint once per area
It was recreated for every candidate building.
This commit is contained in:
1 parent
28e69c7332
commit
b3bb4a62ad
1 file changed
+7
-2
@@ -40,6 +40,12 @@ CityPainter.prototype.paint = function(area)
|
||||
// if it would use a custom, more fine-grained obstruction grid
|
||||
const tileClass = g_Map.createTileClass();
|
||||
|
||||
const placeConstraint = new AndConstraint([
|
||||
new StayAreasConstraint([area]),
|
||||
avoidClasses(tileClass, 0),
|
||||
new PassableMapAreaConstraint()
|
||||
]);
|
||||
|
||||
const processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize));
|
||||
|
||||
const areaPoints = area.getPoints();
|
||||
@@ -77,8 +83,7 @@ CityPainter.prototype.paint = function(area)
|
||||
const obstructionCorners = template.obstructionCorners.map(obstructionCorner =>
|
||||
Vector2D.add(point, obstructionCorner.clone().rotate(buildingAngle)));
|
||||
|
||||
const obstructionPoints = new ConvexPolygonPlacer(obstructionCorners, 0).place(
|
||||
new AndConstraint([new StayAreasConstraint([area]), avoidClasses(tileClass, 0), new PassableMapAreaConstraint()]));
|
||||
const obstructionPoints = new ConvexPolygonPlacer(obstructionCorners, 0).place(placeConstraint);
|
||||
|
||||
if (!obstructionPoints)
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user