Skip to content

feat(wall): add endHeightOffset for sloped top edge - #640

Open
vducasse wants to merge 15 commits into
pascalorg:mainfrom
vducasse:feat/wall-end-height
Open

feat(wall): add endHeightOffset for sloped top edge#640
vducasse wants to merge 15 commits into
pascalorg:mainfrom
vducasse:feat/wall-end-height

Conversation

@vducasse

@vducasse vducasse commented Aug 12, 2026

Copy link
Copy Markdown

What does this PR do?

Adds an endHeightOffset property to the WallNode schema to allow wall extremities to have different heights (e.g., for creating a knee wall following a single-pitch roof slope). This adds an "End height offset" slider to the wall properties panel and updates the geometry generation to apply the slope along the top edge of the wall.

How to test

  1. Open a scene in the editor and draw a standard wall.
  2. Select the wall to open the properties panel.
  3. Under the dimensions/properties, look for the new End height offset slider.
  4. Adjust the slider and verify that the top edge of the wall tilts smoothly between the start and end points.

Screenshots / screen recording

image image image image

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Note

Medium Risk
Touches wall-attached item placement and height resolution used by editor overlays; incorrect min-height sampling could allow invalid placements on sloped walls.

Overview
Spatial grid updates so sloped walls (endHeightOffset) behave correctly for placement, overlays, and cache invalidation.

SpatialGridManager now resolves walls from the live scene store via getWall, and wall height goes through shared getWallEffectiveHeightForNodes with an optional parametric t along the span. canPlaceOnWall uses the minimum effective height at the item’s start, end, and center so tall attachments are rejected where the sloped top is lower.

spatial-grid-sync treats changes to height, endHeightOffset, supportSlabId, and supportOffset like geometry edits, refreshing the manager’s wall map and rendered slab polygon cache when slope or support changes.

Reviewed by Cursor Bugbot for commit cf8f12c. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread packages/nodes/src/wall/panel.tsx
Fixes a bug where negative offset values caused wall geometry to self-intersect and drop below the base. The value is now strictly clamped to 0 at the Zod schema, UI, and geometry generation layers.
Comment thread packages/viewer/src/systems/wall/wall-system.tsx Outdated
# Conflicts:
#	packages/nodes/src/wall/panel.tsx
Comment thread packages/viewer/src/systems/wall/wall-system.tsx
Comment thread packages/viewer/src/systems/wall/wall-system.tsx
Ducasse, Vincent (external) added 2 commits August 13, 2026 11:24
    curved wall sloped geometry

- **Geometry Generation**:
  - `applyWallEndHeightSlope`: Replaced naive X-axis interpolation with exact
  radial angle-based parameterization (`t`) when the wall footprint is curved.
  Implemented robust `getSignedAngleDiff` and angle-unwrapping based on
  expected linear distance to prevent severe Y-axis warping on the wall end
  caps when `Math.atan2` boundaries are crossed on steep semicircular curves.
  - `generateExtrudedWall`: Added `getWallArcData` injection, mapping the arc
  center into wall-local coordinate space, and passing `localArc` down into
  the height slope generator.

- **Height Resolution Core**:
  - `resolveWallTop`: Added an optional `t?: number` (parametric position
  along the chord) to correctly account for the sloped top. It injects
  `endHeightOffset * t` directly into the final top boundary calculation.
  - `resolveWallEffectiveHeight`: Cascaded the optional `t` parameter from
  the caller down into `resolveWallTop` and adjusted elevation offsets.

- **Spatial Grid Placement**:
  - `getWallHeight`: Now accepts an optional parametric position and passes
  it directly to `resolveWallTop`.
  - `canPlaceOnWall`: Computes the exact parametric `tCenter` for wall-hosted
  items based on the projection of the item's position onto the wall chord.
  This allows the placement bounding box constraints to accurately read the
  sloped height of the wall at the item's insertion point, fixing the bug
  where placement validators treated the entire wall as completely flat.

- **UI and Constraints**:
  - `panel.tsx`: Refactored the `SliderControl` minimum constraint for the
  `endHeightOffset` input to explicitly prevent the wall top from dropping
  below a safe minimum height threshold (`0.01m`).
Comment thread packages/viewer/src/systems/wall/wall-system.tsx Outdated
Comment thread packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts Outdated
- Update applyWallEndHeightSlope to clamp against the real extruded
  wall body height.
- Accept parametric t in getWallEffectiveHeightForNodes to resolve
  local ceiling heights along sloped walls.
- Update door and window placement math (clampToWall) and resize handles
  to evaluate ceiling bounds across the full opening span.
- Ensure door handles and readWallLength fall back to parentId when
  wallId is unset.
Comment thread packages/nodes/src/door/floorplan-move.ts
Comment thread packages/nodes/src/window/floorplan-move.ts
Comment thread packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts
- Track lastFits in door and window floorplan move targets and block
  commit when opening exceeds sloped wall bounds.
- Allow clampToWall in window-math and door-math to accept either a
  WallCeilingSceneReader or a Record<AnyNodeId, AnyNode>.
Comment thread packages/viewer/src/systems/wall/wall-system.tsx Outdated
Ducasse, Vincent (external) added 2 commits August 14, 2026 10:52
…e wall cache fallback

- Sample wall heights at tStart, tEnd, and tCenter in canPlaceOnWall to
  prevent wall items from breaching sloped ceilings.
- Add getWall fallback in spatialGridManager to read directly from useScene
  store when walls are not yet cached.
- Calculate localT using getWallCurveLength on curved walls in
  readHostWallCeiling and getWallLength for Bugbot / static analysis compliance.
Comment thread packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts
…gs using chord frame

- Simplify applyWallEndHeightSlope in wall-system to linearly slope
  using wall-local X across the chord frame.
- Keep readHostWallCeiling and getWallLength unified on chord length.
Comment thread packages/core/src/systems/wall/wall-top.ts
…mesh clamp

- Ensure resolveWallTop clamps negative endHeightOffset to -(bodyHeight - 0.01)
  so mathematical ceiling queries match rendered 3D geometry.
Comment thread packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts Outdated
…tiveHeightForNodes

- Ensure all wall heights in spatialGridManager apply slope clamping
  matching 3D mesh extrusion and vertical-model architecture rules.
Comment thread packages/core/src/systems/wall/wall-top.ts
…and handles

- Sample start (t=0) and end (t=1) wall tops for space-detection room ceilings and level height tracking.
- Pass endpoint t to corner handles and midpoint t to height/side handles in wall-move-side-handles.
- Sample tCenter along sloped segments for wall top snap beacon highlights.
- Interpolate 3D measurement guide paths with getWallEffectiveHeightForNodes across wall slope.
- Expose start and end top targets in elevation guides for sloped walls.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f7ce5c. Configure here.

Comment thread packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts
…changes

- Subscribe spatial-grid sync to wall height, endHeightOffset, and support updates.
- Read live scene node in getWall to ensure spatial grid queries always reflect current wall slope.
- Include endHeightOffset in space-detection wallGeometrySignature so room ceilings reactively re-derive on slope edits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant