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(+) (limited to 'src/geometry') 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