Differential D2004 Diff 8673 ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer/noncentered/ConvexPolygonPlacer.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer/noncentered/ConvexPolygonPlacer.js
/** | /** | ||||
* Returns all points on the tilegrid within the convex hull of the given positions. | * Returns all points on the tilegrid within the convex hull of the given positions. | ||||
*/ | */ | ||||
function ConvexPolygonPlacer(points, failFraction = 0) | function ConvexPolygonPlacer(points, failFraction = 0) | ||||
{ | { | ||||
this.polygonVertices = this.getConvexHull(points.map(point => point.clone().round())); | this.polygonVertices = this.getConvexHull(points.map(point => point.clone().round())); | ||||
this.failFraction = failFraction; | this.failFraction = failFraction; | ||||
}; | } | ||||
ConvexPolygonPlacer.prototype.place = function(constraint) | ConvexPolygonPlacer.prototype.place = function(constraint) | ||||
{ | { | ||||
let points = []; | let points = []; | ||||
let count = 0; | let count = 0; | ||||
let failed = 0; | let failed = 0; | ||||
for (let point of getPointsInBoundingBox(getBoundingBox(this.polygonVertices))) | for (let point of getPointsInBoundingBox(getBoundingBox(this.polygonVertices))) | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator