Skip to content

Fix KD-tree left subtree dropping points - #43

Merged
RamType0 merged 1 commit into
mainfrom
fix/kdtree-left-subtree-coverage
Nov 4, 2026
Merged

RamType0 merged 1 commit into
mainfrom
fix/kdtree-left-subtree-coverage

Conversation

@RamType0

@RamType0 RamType0 commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix an off-by-one error in UnsafeKdTree.Split: the left subtree must contain [0, mid), not [0, mid - 1).
  • Previously the point immediately before the median was omitted at each non-leaf split, causing sphere queries (and SmartLink candidate collection) to miss valid points.

Scope

  • One algorithmic change: left subtree length mid - 1 → mid.
  • Add regression tests for coincident points at sizes 1, 2, 3, 4, 7, 32, and 99; compare deterministic sphere queries on 127 points against brute force, including a query with no matches.
  • Add the test assembly reference to Unity.Mathematics; the existing test friend-assembly declaration is already on main.
  • Excludes QEM placement, merge behavior, diagnostic instrumentation, model assets, and unrelated local changes. No public API changes.

Validation

  • Existing Windows Unity 2022.3.22f1 PlayMode validation artifacts from November 3: these exact KD-tree source and test files were byte-compared against the validation copy before publication.
  • Before fix: 1/8 KD-tree cases passed, 7/8 failed. After fix: 8/8 passed. The full recorded post-fix diagnostic run passed 30/30 cases; this included temporary diagnostics not included in this PR.
  • git diff --check passes. Unity was not rerun on the isolated PR checkout; repository CI results must be checked separately.
  • This establishes query coverage, not universal visual improvement, watertightness, UV fidelity, or pose quality. Shape-quality measurements were mixed and are not claimed as acceptance criteria here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@RamType0
RamType0 merged commit 3a319bc into main Nov 4, 2026
0 of 13 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.

2 participants