Skip to content

Refactor wall opening attachment to support batch operations#46

Open
bhairaav wants to merge 1 commit into
beta2.0from
claude/fix-polyline-wall-openings-BjRAl
Open

Refactor wall opening attachment to support batch operations#46
bhairaav wants to merge 1 commit into
beta2.0from
claude/fix-polyline-wall-openings-BjRAl

Conversation

@bhairaav
Copy link
Copy Markdown
Collaborator

Description/Context/What Does Your PR Do

This PR refactors the opening attachment pipeline in SingleWall and PolyWall to:

  1. Introduce batch attachment methods (attachDoors, attachWindows, attachOpenings) that register multiple openings and resolve geometry only once, instead of once per opening. This significantly improves performance when attaching many openings at once.

  2. Centralize opening registration logic via a new private registerOpening() method that:

    • Prevents duplicate registrations by tracking opening listeners in a Map<string, () => void>
    • Properly manages event listener lifecycle (add on register, remove on detach)
    • Returns a boolean indicating whether the opening was newly added
    • Handles property set updates consistently
  3. Fix opening detachment to properly clean up event listeners and dispose of resolved geometry resources via a new disposeResolvedEntry() helper.

  4. Refactor resolveOpenings() to be more robust:

    • Only performs boolean operations when openings exist
    • Properly disposes previous resolved geometry before creating new results
    • Handles both 2D and 3D resolution with consistent null-safety
  5. Extract door/window opening logic in PolyWall into extractDoorOpening() and extractWindowOpening() helpers to reduce duplication.

  6. Add kernel spec debt documentation (wall-openings-spec-debt.md) outlining gaps in the OpenGeometry kernel that affect correctness of multi-opening boolean operations, with prioritized recommendations for kernel maintainers.

  7. Remove debug console.log statements from Door, Window, and PolyWall.

Steps To Run/Review for Other Devs

  • Review the new registerOpening() private method to understand the listener lifecycle management pattern
  • Check that attachOpenings([...]) now batches resolution (single resolveOpenings() call vs. N calls)
  • Verify detachOpening() properly cleans up listeners and disposes geometry
  • Review the kernel spec debt doc for context on why certain workarounds exist in the current code
  • Existing tests should pass; the refactor maintains API compatibility while improving internal structure

Production Log Message

[ ] - Internal refactor: wall opening attachment now supports efficient batch operations and properly manages event listener lifecycle.

https://claude.ai/code/session_01Fkhu5s2YSqr2wDZk4y8CRH

…batch

- SingleWall.detachOpening now disposes stale BooleanResult and re-runs
  resolveOpenings so multi-opening cuts stay consistent; previously the
  array shrank but the old cut mesh lingered.
- SingleWall.resolveOpenings no longer returns early from the whole
  function when the 2D opening set is empty, so the 3D pass always runs.
- Opening update callbacks on both SingleWall and PolyWall now call
  resolveOpenings instead of setOPGeometry, so editing an opening no
  longer tears down and rebuilds the host wall base geometry.
- Attach listeners are tracked per ogid and removed on detach to stop
  accumulating stale handlers across attach/detach cycles.
- Add attachOpenings / attachDoors / attachWindows batch APIs on both
  walls so callers can amortise the kernel boolean into a single resolve.
- Drop stray runtime console.log calls in door, window, and poly-wall.

Tracked remaining kernel gaps in docs/wall-openings-spec-debt.md.
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.

2 participants