refactor: hull scale

This commit is contained in:
cha0s 2021-03-28 10:42:37 -05:00
parent 46cdc32485
commit 3e7233ec46

View File

@ -65,29 +65,33 @@ export default (latus) => {
seen[k] = true;
const xx = k % w;
const yy = Math.floor(k / w);
const [xxs, yys] = [xx * 4, yy * 4];
const u = k - w;
if ((u < 0 || yy < 1) || !indices.has(this.data[u])) {
body.push([xx, yy]);
body.push([xx + 1, yy]);
body.push([xxs, yys]);
body.push([xxs + 4, yys]);
}
const r = k + 1;
if ((r < 0 || xx + 1 >= w) || !indices.has(this.data[r])) {
body.push([xx + 1, yy]);
body.push([xx + 1, yy + 1]);
body.push([xxs + 4, yys]);
body.push([xxs + 4, yys + 4]);
}
const d = k + w;
if ((d < 0 || yy + 1 >= h) || !indices.has(this.data[d])) {
body.push([xx + 1, yy + 1]);
body.push([xx, yy + 1]);
body.push([xxs + 4, yys + 4]);
body.push([xxs, yys + 4]);
}
const l = k - 1;
if ((l < 0 || xx < 1) || !indices.has(this.data[l])) {
body.push([xx, yy + 1]);
body.push([xx, yy]);
body.push([xxs, yys + 4]);
body.push([xxs, yys]);
}
}
}
const hull = Vertice.removeCollinear(Vertice.ortho(Vertice.unique(body), 1));
const hull = Vertice.removeCollinear(Vertice.ortho(Vertice.unique(body), 4));
for (let i = 0; i < hull.length; i++) {
hull[i] = Vector.scale(hull[i], 0.25);
}
if (hull.length > 0) {
hulls.push(hull);
}