Skip to content

[codex] fix adapter mesh bounds overflow - #126

Merged
madawei2699 merged 1 commit into
mainfrom
codex/adapter-mesh-bounds-overflow
Sep 30, 2026
Merged

madawei2699 merged 1 commit into
mainfrom
codex/adapter-mesh-bounds-overflow

Conversation

@madawei2699

Copy link
Copy Markdown
Contributor

Summary

Fixes #125.

The mesh adapter now computes global XYZ bounds in a bounded iterative pass over parsed triangle vertices. It no longer flattens the entire triangle list or passes every mesh reference to Math.min and Math.max. The parser, fan triangulation, normalization, voxelization, ordering, deduplication, and VoxelPlan behavior remain unchanged.

Cause and fix

The Sydney Opera House input reported by MinePilot #106 contains 82,144 vertices and 129,780 triangles (389,340 triangle-vertex references, about 7.5 MiB). The former global bounds calculation spread all references into Math.min/Math.max; on Node v22.22.3, argument counts at this scale throw RangeError: Maximum call stack size exceeded before voxelization. computeMeshBounds now updates three minima and maxima while visiting each triangle vertex and avoids the extra flattened array.

Regression and acceptance evidence

  • Added a generated OBJ with 50,000 repeated triangular faces (150,000 vertex references). With target height 1 and a 1×1×1 output budget, conversion succeeds with the correct size and one in-bounds block. A direct 150,000-argument spread probe on Node v22.22.3 reproduces the prior RangeError.
  • Ran the available normalized Sydney OBJ (5,750,809 bytes) with the requested settings: targetHeight 64, surface mode, maxBlocks 10,000,000, and minecraft:quartz_block. It passed bounds and produced a VoxelPlan sized 167×64×113 with 103,811 blocks.
  • Existing exact fixture checks pass unchanged.

Validation

  • pnpm --filter @i365dev/craftdag-adapter-mesh test — 7 passed.
  • pnpm --filter @i365dev/craftdag-adapter-mesh typecheck — passed.
  • pnpm build — passed.
  • pnpm test — 219 passed.
  • pnpm typecheck — passed.
  • pnpm lint — passed.
  • git diff --check — passed.

@madawei2699
madawei2699 marked this pull request as ready for review September 30, 2026 02:59
@madawei2699
madawei2699 merged commit 1f4ba3e into main Sep 30, 2026
1 check passed
@madawei2699
madawei2699 deleted the codex/adapter-mesh-bounds-overflow branch September 30, 2026 02:59
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.

adapter-mesh: avoid spread-based bounds overflow on large OBJ inputs

2 participants