From b2c0f620030026a9dc5c586605f3d5bbf8ea8644 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Sat, 13 Mar 2021 19:19:12 +0100 Subject: Some tunning of the way layers are attributed to a collider. --- src/geometry/broad_phase_multi_sap/sap_utils.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/geometry/broad_phase_multi_sap/sap_utils.rs b/src/geometry/broad_phase_multi_sap/sap_utils.rs index 84b4b38..f479afa 100644 --- a/src/geometry/broad_phase_multi_sap/sap_utils.rs +++ b/src/geometry/broad_phase_multi_sap/sap_utils.rs @@ -5,8 +5,8 @@ pub(crate) const NUM_SENTINELS: usize = 1; 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 = 20.0; -pub(crate) const REGION_WIDTH_POWER_BASIS: Real = 8.0; +pub(crate) const REGION_WIDTH_BASE: Real = 1.0; +pub(crate) const REGION_WIDTH_POWER_BASIS: Real = 10.0; pub(crate) fn sort2(a: u32, b: u32) -> (u32, u32) { assert_ne!(a, b); @@ -36,7 +36,12 @@ pub(crate) fn region_width(depth: i8) -> Real { } pub(crate) fn layer_containing_aabb(aabb: &AABB) -> i8 { - let width = 2.0 * aabb.half_extents().norm(); + // 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; + + let width = 2.0 * aabb.half_extents().norm() * NUM_ELEMENTS_PER_DIMENSION; // TODO: handle overflows in the f32 -> i8 conversion. - (width / REGION_WIDTH_BASE).log(REGION_WIDTH_POWER_BASIS) as i8 + (width / REGION_WIDTH_BASE) + .log(REGION_WIDTH_POWER_BASIS) + .round() as i8 } -- cgit