Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/rmgen/TileClass.js
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | if (radius >= 27) // Switchover point before RangeOp actually performs better than a straight algorithm | ||||
nonMembers += maxX - minX - newMembers; | nonMembers += maxX - minX - newMembers; | ||||
} | } | ||||
} | } | ||||
else // Simply check the tiles one by one to find the number | else // Simply check the tiles one by one to find the number | ||||
{ | { | ||||
let dy = iy - position.y; | let dy = iy - position.y; | ||||
let xMin = Math.max(Math.floor(position.x - radius), 0); | let xMin = Math.max(Math.floor(position.x - radius), 0); | ||||
let xMax = Math.max(Math.ceil(position.x + radius), this.size - 1); | let xMax = Math.min(Math.ceil(position.x + radius), this.size - 1); | ||||
for (let ix = xMin; ix <= xMax; ++ix) | for (let ix = xMin; ix <= xMax; ++ix) | ||||
{ | { | ||||
let dx = ix - position.x; | let dx = ix - position.x; | ||||
if (Math.square(dx) + Math.square(dy) <= radius2) | if (Math.square(dx) + Math.square(dy) <= radius2) | ||||
{ | { | ||||
if (this.inclusionCount[ix] && this.inclusionCount[ix][iy] && this.inclusionCount[ix][iy] > 0) | if (this.inclusionCount[ix] && this.inclusionCount[ix][iy] && this.inclusionCount[ix][iy] > 0) | ||||
++members; | ++members; | ||||
Show All 22 Lines |
Wildfire Games · Phabricator