aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-03-13 19:19:12 +0100
committerCrozet Sébastien <developer@crozet.re>2021-03-13 19:19:12 +0100
commitb2c0f620030026a9dc5c586605f3d5bbf8ea8644 (patch)
tree62554f2f6d16ba69f153a32610687a9029263148 /src
parent3a1502be74901f3df96a05a7d479f15bd4f8b507 (diff)
downloadrapier-b2c0f620030026a9dc5c586605f3d5bbf8ea8644.tar.gz
rapier-b2c0f620030026a9dc5c586605f3d5bbf8ea8644.tar.bz2
rapier-b2c0f620030026a9dc5c586605f3d5bbf8ea8644.zip
Some tunning of the way layers are attributed to a collider.
Diffstat (limited to 'src')
-rw-r--r--src/geometry/broad_phase_multi_sap/sap_utils.rs13
1 files changed, 9 insertions, 4 deletions
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
}