feat: improved ray tracing to preserve floors#2275
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
r u ready 2 suffer #2283 |
🥲😅 |
Greptile SummaryThis PR fixes floor-point erasure in the ray-tracing voxel mapper by adding a z-slab protection rule: when a ray crosses z-levels, any voxel that shares the endpoint's Z index is skipped (not marked as a miss), preserving horizontal surfaces like floors.
Confidence Score: 5/5The change is safe to merge; the z-slab skip and t_max early exit are internally consistent and the new regression test with an assertion guards against future breakage. The core logic is sound: the DDA loop terminates through the t_max exit when z-slab voxels are continuously skipped before the shadow-distance check can fire, parametric t_enter correctly identifies shadow territory, and the endpoint voxel is always visited before the z-slab filter applies. No defects in the changed paths were found. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Loop start] --> B["t_enter = min(tx, ty, tz)"]
B --> C{t_enter > t_max?}
C -- Yes --> D[return — shadow zone exceeded]
C -- No --> E{t_enter >= 1.0?}
E -- Yes --> F[past_endpoint = true]
E -- No --> G[Step DDA to next voxel]
F --> G
G --> H{x,y,z == endpoint?}
H -- Yes --> I[past_endpoint = true; continue]
H -- No --> J{"origin_voxel.z ≠ endpoint.z AND z == endpoint.z?"}
J -- Yes --> K[skip — z-slab floor protection]
J -- No --> L{past_endpoint?}
L -- Yes --> M{dist_sq > shadow_sq?}
M -- Yes --> D
M -- No --> N[mark as miss if in map]
L -- No --> O{dist_sq < grace_sq?}
O -- Yes --> K
O -- No --> N
N --> A
K --> A
I --> A
Reviews (2): Last reviewed commit: "Enforce planar condition in test" | Re-trigger Greptile |
Problem
Floors and other horizontal surfaces lose points due to ray clipping when more than ~1 meter from sensor.
Closes DIM-XXX
Solution
Ignore points on the same xy plane as the lidar hit from clipping. This preserves floors much better than without.
With fix:

Before fix:

How to Test
cargo testadded test to ensure same plane points aren't removedContributor License Agreement