Refine stair slab opening placement
This commit is contained in:
@@ -437,16 +437,10 @@ function getStraightOpeningPolygonsForSurface(
|
||||
const segmentTopElevation = layout.topElevation
|
||||
|
||||
if (segment.segmentType === 'stair') {
|
||||
const minElevation = Math.min(segmentStartElevation, segmentTopElevation) - targetThreshold
|
||||
const maxElevation = Math.max(segmentStartElevation, segmentTopElevation) + targetThreshold
|
||||
|
||||
if (targetElevation >= minElevation && targetElevation <= maxElevation) {
|
||||
if (Math.abs(targetElevation - segmentTopElevation) <= targetThreshold) {
|
||||
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(
|
||||
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))
|
||||
}
|
||||
@@ -462,6 +456,8 @@ function getStraightOpeningPolygonsForSurface(
|
||||
if (landingRect) landingRects.push(expandRect(landingRect, openingOffset))
|
||||
const previous = layouts[index - 1]
|
||||
if (previous?.segment.segmentType === 'stair') {
|
||||
const previousTopElevation = previous.topElevation
|
||||
if (Math.abs(targetElevation - previousTopElevation) <= targetThreshold) {
|
||||
const previousDepth = getStraightFlightOpeningDepth(stair, previous.segment)
|
||||
const previousRect = getAxisAlignedRectFromPolygon(
|
||||
getStraightSegmentLocalSlicePolygon(
|
||||
@@ -472,14 +468,6 @@ function getStraightOpeningPolygonsForSurface(
|
||||
)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user