Refine stair slab opening placement

This commit is contained in:
sudhir
2026-04-17 13:18:04 +05:30
parent b314a8fbf8
commit 7ca94ce375
@@ -437,16 +437,10 @@ function getStraightOpeningPolygonsForSurface(
const segmentTopElevation = layout.topElevation const segmentTopElevation = layout.topElevation
if (segment.segmentType === 'stair') { if (segment.segmentType === 'stair') {
const minElevation = Math.min(segmentStartElevation, segmentTopElevation) - targetThreshold if (Math.abs(targetElevation - segmentTopElevation) <= targetThreshold) {
const maxElevation = Math.max(segmentStartElevation, segmentTopElevation) + targetThreshold
if (targetElevation >= minElevation && targetElevation <= maxElevation) {
const openingDepth = getStraightFlightOpeningDepth(stair, segment) const openingDepth = getStraightFlightOpeningDepth(stair, segment)
const climbRatio =
segment.height > 1e-6 ? clamp((targetElevation - segmentStartElevation) / segment.height, 0, 1) : 1
const intersectionAlong = climbRatio * segment.length
const flightRect = getAxisAlignedRectFromPolygon( const flightRect = getAxisAlignedRectFromPolygon(
getStraightSegmentLocalSlicePolygon(layout, Math.max(0, intersectionAlong - openingDepth), segment.length), getStraightSegmentLocalSlicePolygon(layout, Math.max(0, segment.length - openingDepth), segment.length),
) )
if (flightRect) openingRects.push(expandRect(flightRect, openingOffset)) if (flightRect) openingRects.push(expandRect(flightRect, openingOffset))
} }
@@ -462,6 +456,8 @@ function getStraightOpeningPolygonsForSurface(
if (landingRect) landingRects.push(expandRect(landingRect, openingOffset)) if (landingRect) landingRects.push(expandRect(landingRect, openingOffset))
const previous = layouts[index - 1] const previous = layouts[index - 1]
if (previous?.segment.segmentType === 'stair') { if (previous?.segment.segmentType === 'stair') {
const previousTopElevation = previous.topElevation
if (Math.abs(targetElevation - previousTopElevation) <= targetThreshold) {
const previousDepth = getStraightFlightOpeningDepth(stair, previous.segment) const previousDepth = getStraightFlightOpeningDepth(stair, previous.segment)
const previousRect = getAxisAlignedRectFromPolygon( const previousRect = getAxisAlignedRectFromPolygon(
getStraightSegmentLocalSlicePolygon( getStraightSegmentLocalSlicePolygon(
@@ -472,14 +468,6 @@ function getStraightOpeningPolygonsForSurface(
) )
if (previousRect) landingRects.push(expandRect(previousRect, openingOffset)) if (previousRect) landingRects.push(expandRect(previousRect, openingOffset))
} }
const next = layouts[index + 1]
if (next?.segment.segmentType === 'stair') {
const nextDepth = getStraightFlightOpeningDepth(stair, next.segment)
const nextRect = getAxisAlignedRectFromPolygon(
getStraightSegmentLocalSlicePolygon(next, 0, Math.min(next.segment.length, nextDepth)),
)
if (nextRect) landingRects.push(expandRect(nextRect, openingOffset))
} }
openingRects.push(...landingRects) openingRects.push(...landingRects)