From 9e431fb392fe85228b695fd5e58c61da7bef1dd2 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Fri, 24 Jun 2022 11:56:12 +0200 Subject: Address rounding errors resulting in AABBProxy being added to a disjoint region. --- src/geometry/broad_phase_multi_sap/sap_layer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/geometry/broad_phase_multi_sap/sap_layer.rs b/src/geometry/broad_phase_multi_sap/sap_layer.rs index 216ea05..4316ecd 100644 --- a/src/geometry/broad_phase_multi_sap/sap_layer.rs +++ b/src/geometry/broad_phase_multi_sap/sap_layer.rs @@ -240,6 +240,13 @@ impl SAPLayer { let region_proxy = &mut proxies[region_id]; let region = region_proxy.data.as_region_mut(); + // NOTE: sometimes, rounding errors will generate start/end indices + // that lie outside of the actual region’s AABB. + // TODO: is there a smarter, more efficient way of dealing with this? + if !region_proxy.aabb.intersects(aabb_to_discretize) { + continue; + } + if let Some(actual_aabb) = actual_aabb { // NOTE: if the actual AABB doesn't intersect the // region’s AABB, then we need to delete the -- cgit From be5b6813a9675089f6ea0ee02a1e6eefed831e49 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Fri, 24 Jun 2022 11:56:28 +0200 Subject: Broad-phase: discard NAN/Inf AABBs. --- src/geometry/broad_phase_multi_sap/broad_phase.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/geometry/broad_phase_multi_sap/broad_phase.rs b/src/geometry/broad_phase_multi_sap/broad_phase.rs index 2c8c5e3..60a28bd 100644 --- a/src/geometry/broad_phase_multi_sap/broad_phase.rs +++ b/src/geometry/broad_phase_multi_sap/broad_phase.rs @@ -8,7 +8,7 @@ use crate::geometry::{ }; use crate::math::Real; use crate::utils::IndexMut2; -use parry::bounding_volume::BoundingVolume; +use parry::bounding_volume::{BoundingVolume, AABB}; use parry::utils::hashmap::HashMap; /// A broad-phase combining a Hierarchical Grid and Sweep-and-Prune. @@ -352,8 +352,16 @@ impl BroadPhase { .compute_aabb(co_pos) .loosened(prediction_distance / 2.0); + if aabb.mins.coords.iter().any(|e| !e.is_finite()) + || aabb.maxs.coords.iter().any(|e| !e.is_finite()) + { + // Reject AABBs with non-finite values. + return false; + } + aabb.mins = super::clamp_point(aabb.mins); aabb.maxs = super::clamp_point(aabb.maxs); + let prev_aabb; let layer_id = if let Some(proxy) = self.proxies.get_mut(*proxy_index) { -- cgit From 2e19eb2e54a4cbe22f82b5d7fda266dce6b6ab4d Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Fri, 24 Jun 2022 12:11:14 +0200 Subject: Fix warning --- src/geometry/broad_phase_multi_sap/broad_phase.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geometry/broad_phase_multi_sap/broad_phase.rs b/src/geometry/broad_phase_multi_sap/broad_phase.rs index 60a28bd..8f47396 100644 --- a/src/geometry/broad_phase_multi_sap/broad_phase.rs +++ b/src/geometry/broad_phase_multi_sap/broad_phase.rs @@ -8,7 +8,7 @@ use crate::geometry::{ }; use crate::math::Real; use crate::utils::IndexMut2; -use parry::bounding_volume::{BoundingVolume, AABB}; +use parry::bounding_volume::BoundingVolume; use parry::utils::hashmap::HashMap; /// A broad-phase combining a Hierarchical Grid and Sweep-and-Prune. -- cgit