diff options
| -rw-r--r-- | src/geometry/broad_phase_multi_sap/sap_utils.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/geometry/broad_phase_multi_sap/sap_utils.rs b/src/geometry/broad_phase_multi_sap/sap_utils.rs index f479afa..b471b4d 100644 --- a/src/geometry/broad_phase_multi_sap/sap_utils.rs +++ b/src/geometry/broad_phase_multi_sap/sap_utils.rs @@ -6,7 +6,7 @@ pub(crate) const NEXT_FREE_SENTINEL: u32 = u32::MAX; pub(crate) const SENTINEL_VALUE: Real = Real::MAX; pub(crate) const DELETED_AABB_VALUE: Real = SENTINEL_VALUE / 2.0; pub(crate) const REGION_WIDTH_BASE: Real = 1.0; -pub(crate) const REGION_WIDTH_POWER_BASIS: Real = 10.0; +pub(crate) const REGION_WIDTH_POWER_BASIS: Real = 5.0; pub(crate) fn sort2(a: u32, b: u32) -> (u32, u32) { assert_ne!(a, b); @@ -35,6 +35,15 @@ pub(crate) fn region_width(depth: i8) -> Real { REGION_WIDTH_BASE * REGION_WIDTH_POWER_BASIS.powi(depth as i32) } +/// Computes the depth of the layer the given AABB should be part of. +/// +/// The idea here is that an AABB should be part of a layer which has +/// regions large enough so that one AABB doesn't crosses too many +/// regions. But the regions must also not bee too large, otherwise +/// we are loosing the benefits of Multi-SAP. +/// +/// If the code bellow, we select a layer such that each region can +/// contain at least a chain of 10 contiguous objects with that AABB. pub(crate) fn layer_containing_aabb(aabb: &AABB) -> i8 { // Max number of elements of this size we would like one region to be able to contain. const NUM_ELEMENTS_PER_DIMENSION: Real = 10.0; |
