Skip to content

Using HalfSpace collider shape stalls broad phase in rapier3d-f64 #396

Description

@jsatka

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:

let start = super::point_key(aabb_to_discretize.mins, self.region_width);
let end = super::point_key(aabb_to_discretize.maxs, self.region_width);
// Discretize the aabb.
#[cfg(feature = "dim2")]
let k_range = 0..1;
#[cfg(feature = "dim3")]
let k_range = start.z..=end.z;
for i in start.x..=end.x {
for j in start.y..=end.y {
for _k in k_range.clone() {

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

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

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions