Fix narrow-band unit confusion in IntersectImplicit and ProjectZSlice (#26) - #28
Open
Borderliner wants to merge 1 commit into
Open
Fix narrow-band unit confusion in IntersectImplicit and ProjectZSlice (#26)#28Borderliner wants to merge 1 commit into
Borderliner wants to merge 1 commit into
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withm_nSdfNarrowBandinstead offBackgroundMM(). TheVoxels(VoxelSize, int nNarrowBand)ctor's 2nd arg is a voxel count, butfBackgroundMM()returns millimetres (narrowBand × voxelSize). Below ~0.33 mm this truncated toint 0→ a grid with background 0 →csgIntersectionthrewexpected grid A outside value > 0, got 0, so every implicit intersect at a fine voxel size failed.ProjectZSliceDn/ProjectZSliceUp— seal the end cap by iteratingm_nSdfNarrowBandslices 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:ProjectZSliceof 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.Leaves the two lower-severity candidates from #26 (imported-grid hardcoded narrow band;
vecToMMfractional truncation) for separate discussion.Reported & fixed via PicoPie, a Pythonic binding of PicoGK.