rapier icon indicating copy to clipboard operation
rapier copied to clipboard

Using `HalfSpace` collider shape stalls broad phase in rapier3d-f64

Open jsatka opened this issue 3 years ago • 0 comments

Using HalfSpace collider shape in rapier3d-f64 (on a fixed rigid body) leads to three nested loops, each covering range of i32::MIN .. i32::MAX in the broad phase collision detection (of the first physics timestep) here:

https://github.com/dimforge/rapier/blob/053cb22a85fe71452ce2972cd525956e0d736437/src/geometry/broad_phase_multi_sap/sap_layer.rs#L223-L234

Halfspace collider shape AABB half extents are always 0.5 * Real::MAX, and thus the start and end variables in the above referenced lines end up equaling Point<i32>::min_value() and Point<i32>::max_value() with halfspaces.

The issue can seemingly be fixed by changing the constant in

https://github.com/dimforge/rapier/blob/aaf80bfa872c6f29b248cab8eb5658ab0d73cb4a/src/geometry/broad_phase_multi_sap/sap_utils.rs#L6

to

pub(crate) const SENTINEL_VALUE: Real = f32::MAX as Real;

but I am unsure about potential unwanted possible side-effects of the change in other use cases and if better approaches to fix the issue exist. More educated thoughts on the fix would be most welcome!

jsatka avatar Oct 03 '22 12:10 jsatka