Skip to content

Add capsule navigation simplification for voxel output#192

Merged
slimbuck merged 22 commits intoplaycanvas:mainfrom
slimbuck:nav-dev
Mar 24, 2026
Merged

Add capsule navigation simplification for voxel output#192
slimbuck merged 22 commits intoplaycanvas:mainfrom
slimbuck:nav-dev

Conversation

@slimbuck
Copy link
Copy Markdown
Member

@slimbuck slimbuck commented Mar 23, 2026

Summary

Adds a nav simplification pass to the voxel pipeline that carves away geometry unreachable by an upright capsule, reducing voxel data size for navigation use cases.

Algorithm

  1. Build a dense bitfield grid from the sparse block accumulator
  2. Dilate solid by the capsule shape (Minkowski sum via 3 separable 1D sliding-window passes)
  3. BFS flood fill from a seed point to find all reachable capsule-center positions
  4. Invert unreachable space to solid (negative space carving)
  5. Erode back by capsule shape (Minkowski subtraction) to restore correct surface positions
  6. Crop to bounding box of navigable cells

Changes

  • New simplifyForCapsule function in src/lib/voxel/nav-simplify.ts with bitfield storage (1 bit/voxel) and ping-ponged buffers for memory efficiency
  • Integrated into writeVoxel pipeline, gated by navCapsule/navSeed options
  • CLI flags: --no-nav-simplify, --nav-capsule <height,radius>, --nav-seed <x,y,z>
  • ProgressNode.depth property for nested progress indentation
  • Exported simplifyForCapsule, NavSeed, and NavSimplifyResult from the public API
  • Unit tests covering hollow boxes, seed validation, empty accumulators, single blocks, and unreachable regions

CLI defaults

  • Navigation simplification is enabled by default for voxel output
  • Capsule: height 1.6, radius 0.2
  • Seed: origin (0, 0, 0)
  • Disable with -n / --no-nav-simplify

@slimbuck slimbuck requested a review from Copilot March 23, 2026 18:54
@slimbuck slimbuck self-assigned this Mar 23, 2026
@slimbuck slimbuck added the enhancement New feature or request label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a capsule-based navigation simplification pass to the voxel output pipeline, aiming to carve away unreachable space (from a capsule-center flood fill) to reduce voxel data size for navigation use cases.

Changes:

  • Introduces simplifyForCapsule (dense 1-bit voxel grid + dilation/BFS/invert/erosion + cropping) and exports it publicly.
  • Integrates nav simplification into voxel writing, controlled via new options and CLI flags (--no-nav-simplify, --nav-capsule, --nav-seed).
  • Adds unit tests covering several representative navigation/cropping scenarios.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/nav-simplify.test.mjs New unit tests for capsule-based nav simplification behavior.
src/lib/writers/write-voxel.ts Hooks nav simplification into the voxel write pipeline and adjusts progress step counting.
src/lib/write.ts Wires library Options into writeVoxel including nav defaults/enablement.
src/lib/voxel/nav-simplify.ts New implementation of the capsule navigation simplification algorithm.
src/lib/types.ts Adds navSimplify, navCapsule, navSeed to public options type.
src/lib/index.ts Exports simplifyForCapsule and related types from the public API.
src/cli/index.ts Adds CLI flags + parsing for nav simplification; updates help text and Node logger wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slimbuck slimbuck marked this pull request as ready for review March 24, 2026 11:35
@slimbuck slimbuck requested a review from a team March 24, 2026 11:35
@slimbuck slimbuck merged commit 6bdb790 into playcanvas:main Mar 24, 2026
7 checks passed
@slimbuck slimbuck deleted the nav-dev branch March 24, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants