Skip to content

Fix narrow-band unit confusion in IntersectImplicit and ProjectZSlice (#26) - #28

Open
Borderliner wants to merge 1 commit into
leap71:mainfrom
Borderliner:fix/narrow-band-voxel-count
Open

Fix narrow-band unit confusion in IntersectImplicit and ProjectZSlice (#26)#28
Borderliner wants to merge 1 commit into
leap71:mainfrom
Borderliner:fix/narrow-band-voxel-count

Conversation

@Borderliner

Copy link
Copy Markdown

Fixes the two confirmed instances of #26 — a background value in mm used as an integer voxel/narrow-band count, which truncates at fine voxel sizes.

Changes (Source/PicoGKVdbVoxels.h, 3 lines)

  • IntersectImplicit — build the temp grid with m_nSdfNarrowBand instead of fBackgroundMM(). The Voxels(VoxelSize, int nNarrowBand) ctor's 2nd arg is a voxel count, but fBackgroundMM() returns millimetres (narrowBand × voxelSize). Below ~0.33 mm this truncated to int 0 → a grid with background 0 → csgIntersection threw expected grid A outside value > 0, got 0, so every implicit intersect at a fine voxel size failed.
  • ProjectZSliceDn / ProjectZSliceUp — seal the end cap by iterating m_nSdfNarrowBand slices instead of (int)(0.5f + background()). Below ~0.167 mm that was 0 → the cap was never sealed → a non-watertight result, produced silently (no error).

No behavioural change near 1 mm voxel size (where 3 × voxelSize ≈ 1); correct at all voxel sizes now.

Verification

Verified through PicoPie (which currently applies these exact edits as a build-time patch). At voxel_size = 0.1 mm:

  • ProjectZSlice of a solid into empty space: was ~22 mm³ (non-watertight) → 828.9 mm³, matching the 0.5 mm baseline (818 mm³, modulo discretisation).
  • IntersectImplicit (e.g. sphere ∩ gyroid): no longer throws; produces the expected non-empty volume.
  • Full downstream test suite green, including a voxel-size sweep (0.1–1.0 mm).

Leaves the two lower-severity candidates from #26 (imported-grid hardcoded narrow band; vecToMM fractional truncation) for separate discussion.


Reported & fixed via PicoPie, a Pythonic binding of PicoGK.

…n-mm

IntersectImplicit and ProjectZSliceDn/Up passed a background distance in
millimetres (narrowBand * voxelSize) where an integer voxel/narrow-band
count is expected, which truncates at fine voxel sizes:

- IntersectImplicit built its temp grid with fBackgroundMM() in the
  Voxels(VoxelSize, int nNarrowBand) ctor slot. Below ~0.33 mm,
  3*voxelSize < 1 truncates to 0 -> a grid with background 0 ->
  csgIntersection throws "expected grid A outside value > 0, got 0", so
  any implicit intersect at a fine voxel size fails.

- ProjectZSliceDn/Up sealed the end cap by iterating
  (int)(0.5f + background()) slices. Below ~0.167 mm that is 0, the cap is
  never sealed, and the projected solid is non-watertight (silently).

Use m_nSdfNarrowBand directly in all three places (the default band is 3).

Addresses leap71#26 (instances 1 and 2).
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