Skip to content

Recompute mesh world bounds and grid intersections after changes - #148

Merged
mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/stale-geometry-caches
Nov 12, 2026
Merged

mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/stale-geometry-caches

Conversation

@menes97

@menes97 menes97 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #100

Following the issue's suggested fix:

  • NwcMesh.Transform now has a backing field, and its setter clears _cachedWorldBounds. NwcTransform is init-only, so reassignment is the only way the transform changes. GetWorldBoundingBox() therefore reflects a replaced or removed transform.
  • NwcGridSystem no longer caches GetIntersections(). The cache went stale after Start/End edits or direct changes to Lines, and recomputing is a small O(n²) pass over the grid lines. Lines stays a List<NwcGridLine>, so there is no API change.

Tests

  • GridSystemTests:
    • GridSystem_AfterEndpointEdit_UpdatesIntersectionsAndLocation, for Start and for End.
    • GridSystem_AfterDirectLineAddition_UpdatesIntersectionsAndLocation.
    • GridSystem_AfterDirectLineRemoval_UpdatesIntersectionsAndLocation.
    • These check GetIntersections() and FormatLocation after each change.
  • MeshParserTests:
    • Mesh_GetWorldBoundingBox_AfterTransformAssignment_UsesCurrentTransform.
    • Mesh_GetWorldBoundingBox_AfterTransformRemoval_UsesLocalBounds.

All 7 cases fail without the src change. dotnet build NwcIO.slnx succeeds, and NwcIO.Tests passes locally: 246 passed, and 2 skipped because they need private Navisworks files (.NET 10.0.400 on Windows, with global.json pinned down to it temporarily; not committed).

The change was drafted with OpenAI Codex, then reviewed and verified with Claude Code.

🤖 Generated with Claude Code

NwcMesh kept its cached world bounds when Transform was replaced or
removed, and NwcGridSystem kept its cached intersections after line
endpoints were edited or Lines was changed directly, so bounds, grid
intersections and location labels went stale. The Transform setter now
clears the cached bounds, and the intersection cache, a small O(n²) pass
over the grid lines, is removed.

Fixes IOExtend#100

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mahach666
mahach666 merged commit 8885de0 into IOExtend:main Nov 12, 2026
4 checks passed
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.

Stale caches: NwcMesh world bounds and NwcGridSystem intersections ignore later mutation

2 participants