Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions packages/core/src/agent-operations/move-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,29 @@ function planOpeningMove(
: target.y === undefined
? node.position[1]
: target.y + node.height / 2
const { clampedX, clampedY, fits } =
// Fold transomHeight into cutout.height on purpose so clampDoorToWall slides the full opening instead of shrinking the transom.
const doorClamp =
node.type === 'door'
? clampDoorToWall(
wall,
rawX,
node.width,
node.height,
node,
cutout.height,
{ ...node, transomHeight: undefined },
nodes as Record<AnyNodeId, AnyNode>,
)
: clampWindowToWall(
wall,
rawX,
rawY,
node.width,
node.height,
nodes as Record<AnyNodeId, AnyNode>,
)
if (!fits) refuseOpeningAboveSlope(wall, nodes, node.type, node.width, node.height)
: null
const { clampedX, clampedY, fits } = doorClamp
? { clampedX: doorClamp.clampedX, clampedY: rawY, fits: doorClamp.fits }
: clampWindowToWall(
wall,
rawX,
rawY,
node.width,
node.height,
nodes as Record<AnyNodeId, AnyNode>,
)
if (!fits) refuseOpeningAboveSlope(wall, nodes, node.type, cutout.width, cutout.height)
// Checked where the clamp put the door: under a sloped top it may have slid to the high end.
if (node.type === 'door') {
const wallHeight =
Expand Down
41 changes: 41 additions & 0 deletions packages/core/src/building/wall-openings-slope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,45 @@ describe('agents refuse an opening no stretch of a sloped wall can take', () =>
expect(refusal(() => move(withOpening(sloped, door), 'door_slope'))).toBe('wall_too_low')
expect(refusal(() => move(withOpening({}, door), 'door_slope'))).toBeNull()
})

test('moving a door with a transom along a sloped wall slides until the full opening fits (#1252)', () => {
// 1 m at start rising to 3 m at x = 4 m: a 2.1 m door with a 0.4 m transom (2.5 m cutout)
// needs ceiling >= 2.5 m, which starts at x = 3.0 m (opening centre >= 3.45 m).
const rising = { height: 1, endHeightOffset: 2 }
const transomDoor = DoorNode.parse({
...door,
position: [2.6, 1.05, 0],
width: 0.9,
height: 2.1,
transomHeight: 0.4,
})
const moved = move(withOpening(rising, transomDoor), 'door_slope')
expect(moved.result.clamped).toBe(true)
expect(moved.result.position[0]).toBeCloseTo(3.45, 4)
expect(moved.result.position[1]).toBeCloseTo(1.05, 6)

// With sidelightLeft = 0.2 and transomHeight = 0.2 (1.1 m x 2.3 m cutout, leafOffsetX = +0.1 m):
// ceiling >= 2.3 m starts at x = 2.6 m, so cutout centre clamps to 3.15 m and leaf X lands at 3.25 m.
const sidelightTransomDoor = DoorNode.parse({
...door,
position: [2.6, 1.05, 0],
width: 0.9,
height: 2.1,
sidelightLeft: 0.2,
transomHeight: 0.2,
})
const movedSidelight = move(withOpening(rising, sidelightTransomDoor), 'door_slope')
expect(movedSidelight.result.clamped).toBe(true)
expect(movedSidelight.result.position[0]).toBeCloseTo(3.25, 4)
expect(movedSidelight.result.position[1]).toBeCloseTo(1.05, 6)

// Refused only when no stretch of the sloped wall clears door + transom (2.7 m cutout needs x >= 3.4 m, width 0.9 m needs 3.4 + 0.9 = 4.3 m > 4 m)
const tooTallTransom = DoorNode.parse({
...transomDoor,
transomHeight: 0.6,
})
expect(refusal(() => move(withOpening(rising, tooTallTransom), 'door_slope'))).toBe(
'wall_too_low',
)
})
})