Experiment with a smaller region power basis.

This commit is contained in:
Crozet Sébastien
2021-03-13 19:32:27 +01:00
parent b2c0f62003
commit d82a675b46

View File

@@ -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;