Repository navigation
Conversation
cell_at_point quantizes the scaled point, which can round to the cell on the other side of a cell line from the triangles that contain it. a ray parallel to that line, like a vertical ray, never steps into the neighbor cell, so it missed the heightfield on whole lines whenever the cell count was not a power of two. adjust the starting cell with the same x_at/z_at bounds the triangles are built from, and add a regression test for dimforge/rapier#1069. Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
Author
|
@sebcrozet fix for dimforge/rapier#1069; the heightfield ray cast now starts in the cell whose triangles actually contain the clip point, so vertical rays on cell lines stop missing. regression test reproduces the report's counts on master. would appreciate a look when you have time. |
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 dimforge/rapier#1069
what
a ray parallel to a cell line of a 3d
HeightField(the report uses straight down) that lands exactly on that line missed the heightfield on whole lines whenever the cell count along that axis was not a power of two.cell_at_pointcomputes the cell from(scaled + 0.5) / unit_cell_width, while the cell's triangles are built from-0.5 + unit_cell_width * j. the two roundings disagree right on a line, so the ray can start in the cell on the other side of the line from the triangles that contain it; both triangles miss, and sincedir.x == 0(ordir.z == 0) the traversal never steps into the neighbor. power-of-two counts divide exactly, which is why 64 x 64 never missed.this nudges the starting cell by one when the clip point lies outside its
x_at/z_atbounds, so the cell matches the triangles. rays that do cross cells still step as before.tests
crates/parry3d/tests/issue_1069_heightfield_ray_cell_line.rs, mirroring the report's repro: vertical rays at every quarter-cell point of several heightfields (64 x 64, 48 x 48, 24 x 24, 16 x 48, 48 x 16, 16 x 17, plus 1 m and 0.5 m cells). on master it fails with48 x 48 (cell size 2): 4488 rays missed, the same count as the report; with the fix every ray hits.cargo test -p parry3dpasses (lib, integration and doc tests).not included
HeightFieldray cast has a related miss when a vertical ray lands on a vertex; it needs a separate fix (segment parameter tolerance), so i left it for a follow-up.