rapier icon indicating copy to clipboard operation
rapier copied to clipboard

Downward raycasts sometimes go through heightfield

Open mpartel opened this issue 3 years ago • 1 comments

When I cast rays against a heightfield, they sometimes fail to hit.

Repro here: https://github.com/dimforge/rapier/compare/master...mpartel:heightfield-bug?expand=1

Output:

$ cargo run --release --bin all_examples3 -- --example Heightfield
[...]
Failed to hit ground on attempt 6170 with ray Ray { origin: Point { coords: Matrix { data: [5.0, 10.0, 2.63113] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 11725 with ray Ray { origin: Point { coords: Matrix { data: [9.50162, 10.0, 5.0] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 12340 with ray Ray { origin: Point { coords: Matrix { data: [10.0, 10.0, 5.26226] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 23450 with ray Ray { origin: Point { coords: Matrix { data: [19.00324, 10.0, 10.0] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 37020 with ray Ray { origin: Point { coords: Matrix { data: [30.0, 10.0, 15.78678] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 43190 with ray Ray { origin: Point { coords: Matrix { data: [35.0, 10.0, 18.41791] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }
Failed to hit ground on attempt 49360 with ray Ray { origin: Point { coords: Matrix { data: [40.0, 10.0, 21.04904] } }, dir: Matrix { data: [0.0, -1.0, 0.0] } }

Note that each case has a coordinate divisible by 5 = the subdivision side length.

mpartel avatar Apr 04 '21 11:04 mpartel

Converting the HeightField to a TriMesh seems to work around the problem.

HeightField also doesn't seem to support any shapecasts yet, but TriMesh does.

mpartel avatar Apr 05 '21 03:04 mpartel