diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-01-04 15:14:25 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-01-04 15:14:25 +0100 |
| commit | aa61fe65e3ff0289ecab57b4053a3410cf6d4a87 (patch) | |
| tree | a2ab513f43d779e4eb1c0edcd2a6e734b3fa4470 /src/geometry/broad_phase_multi_sap.rs | |
| parent | a1aa8855f76168d8af14244a54c9f28d15696342 (diff) | |
| download | rapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.tar.gz rapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.tar.bz2 rapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.zip | |
Add support of 64-bits reals.
Diffstat (limited to 'src/geometry/broad_phase_multi_sap.rs')
| -rw-r--r-- | src/geometry/broad_phase_multi_sap.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/geometry/broad_phase_multi_sap.rs b/src/geometry/broad_phase_multi_sap.rs index dbcc271..1ec4372 100644 --- a/src/geometry/broad_phase_multi_sap.rs +++ b/src/geometry/broad_phase_multi_sap.rs @@ -1,7 +1,7 @@ use crate::data::pubsub::Subscription; use crate::dynamics::RigidBodySet; use crate::geometry::{ColliderHandle, ColliderSet, RemovedCollider}; -use crate::math::{Point, Vector, DIM}; +use crate::math::{Point, Real, Vector, DIM}; use bit_vec::BitVec; use cdl::bounding_volume::{BoundingVolume, AABB}; use cdl::utils::hashmap::HashMap; @@ -10,8 +10,8 @@ use std::ops::{Index, IndexMut}; const NUM_SENTINELS: usize = 1; const NEXT_FREE_SENTINEL: u32 = u32::MAX; -const SENTINEL_VALUE: f32 = f32::MAX; -const CELL_WIDTH: f32 = 20.0; +const SENTINEL_VALUE: Real = Real::MAX; +const CELL_WIDTH: Real = 20.0; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] @@ -63,12 +63,12 @@ fn sort2(a: u32, b: u32) -> (u32, u32) { } } -fn point_key(point: Point<f32>) -> Point<i32> { +fn point_key(point: Point<Real>) -> Point<i32> { (point / CELL_WIDTH).coords.map(|e| e.floor() as i32).into() } fn region_aabb(index: Point<i32>) -> AABB { - let mins = index.coords.map(|i| i as f32 * CELL_WIDTH).into(); + let mins = index.coords.map(|i| i as Real * CELL_WIDTH).into(); let maxs = mins + Vector::repeat(CELL_WIDTH); AABB::new(mins, maxs) } @@ -76,7 +76,7 @@ fn region_aabb(index: Point<i32>) -> AABB { #[derive(Copy, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] struct Endpoint { - value: f32, + value: Real, packed_flag_proxy: u32, } @@ -86,14 +86,14 @@ const START_SENTINEL_TAG: u32 = u32::MAX; const END_SENTINEL_TAG: u32 = u32::MAX ^ START_FLAG_MASK; impl Endpoint { - pub fn start_endpoint(value: f32, proxy: u32) -> Self { + pub fn start_endpoint(value: Real, proxy: u32) -> Self { Self { value, packed_flag_proxy: proxy | START_FLAG_MASK, } } - pub fn end_endpoint(value: f32, proxy: u32) -> Self { + pub fn end_endpoint(value: Real, proxy: u32) -> Self { Self { value, packed_flag_proxy: proxy & PROXY_MASK, @@ -134,15 +134,15 @@ impl Endpoint { #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Clone)] struct SAPAxis { - min_bound: f32, - max_bound: f32, + min_bound: Real, + max_bound: Real, endpoints: Vec<Endpoint>, #[cfg_attr(feature = "serde-serialize", serde(skip))] new_endpoints: Vec<(Endpoint, usize)>, // Workspace } impl SAPAxis { - fn new(min_bound: f32, max_bound: f32) -> Self { + fn new(min_bound: Real, max_bound: Real) -> Self { assert!(min_bound <= max_bound); Self { @@ -620,7 +620,7 @@ impl BroadPhase { pub(crate) fn update_aabbs( &mut self, - prediction_distance: f32, + prediction_distance: Real, bodies: &RigidBodySet, colliders: &mut ColliderSet, ) { |
