fiix adjacent walls pushed up

This commit is contained in:
wass08
2026-02-23 08:22:06 +09:00
parent b9c28a627e
commit 16ba5bf9c6
@@ -183,11 +183,24 @@ export function wallOverlapsPolygon(
end: [number, number],
polygon: Array<[number, number]>,
): boolean {
const startInside = pointInPolygon(start[0], start[1], polygon)
const endInside = pointInPolygon(end[0], end[1], polygon)
const dx = end[0] - start[0]
const dz = end[1] - start[1]
const len = Math.sqrt(dx * dx + dz * dz)
// At least one endpoint strictly inside the polygon
if (startInside || endInside) return true
// Nudge endpoint test points a tiny step inward along the wall direction before
// testing containment. pointInPolygon (ray casting) produces false positives for
// points exactly on polygon vertices or edges — specifically the minimum-z corner
// of an axis-aligned polygon returns "inside" because the ray hits the opposite
// vertical edge exactly at its base. Nudging by 1e-6 m avoids this: a wall that
// merely starts at a slab corner and extends outward will have its nudged point
// clearly outside, while a wall that genuinely starts inside stays inside.
if (len > 1e-10) {
const step = Math.min(1e-6, len * 0.01)
const nx = (dx / len) * step
const nz = (dz / len) * step
if (pointInPolygon(start[0] + nx, start[1] + nz, polygon)) return true
if (pointInPolygon(end[0] - nx, end[1] - nz, polygon)) return true
}
// Check if midpoint is inside (catches walls crossing through)
const midX = (start[0] + end[0]) / 2