diff --git a/packages/math/src/vertice.js b/packages/math/src/vertice.js index 6b6acc7..4f9a3f5 100644 --- a/packages/math/src/vertice.js +++ b/packages/math/src/vertice.js @@ -191,7 +191,7 @@ export function removeCollinear(vs) { return trimmed; } -export function smooth(sorted) { +export function smooth(sorted, angle) { const smoothed = []; if (0 === sorted.length) { return []; @@ -202,17 +202,8 @@ export function smooth(sorted) { const f = Vector.sub(sorted[i + 1], sorted[i]); const g = Vector.sub(sorted[i + 2], sorted[i + 1]); const o = Math.atan2(Vector.cross(f, g), Vector.dot(f, g)); - if (Math.abs(o) === Math.PI / 2 || Math.abs(o) === Math.PI / 4) { - const h = Vector.add(sorted[i + 1], Vector.scale(Vector.sub(g, f), 0.5)); - // eslint-disable-next-line no-use-before-define - if (0 === windingNumber(h, sorted)) { - sorted.splice(i + 1, 1); - i -= 1; - } - else { - smoothed.push(sorted[i]); - i += 1; - } + if (Math.abs(o) === angle) { + sorted.splice(i + 1, 1); } else { smoothed.push(sorted[i]); diff --git a/packages/topdown/src/resources/tiles.js b/packages/topdown/src/resources/tiles.js index fc7ccb1..e3e15b5 100644 --- a/packages/topdown/src/resources/tiles.js +++ b/packages/topdown/src/resources/tiles.js @@ -73,9 +73,15 @@ export default (latus) => { } } const hull = Vertice.removeCollinear( - Vertice.ortho( - Vertice.unique(body), - 2, + Vertice.smooth( + Vertice.smooth( + Vertice.ortho( + Vertice.unique(body), + 2, + ), + Math.PI / 2, + ), + Math.PI / 4, ), ); for (let i = 0; i < hull.length; i++) {