aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-01-04 15:14:25 +0100
committerCrozet Sébastien <developer@crozet.re>2021-01-04 15:14:25 +0100
commitaa61fe65e3ff0289ecab57b4053a3410cf6d4a87 (patch)
treea2ab513f43d779e4eb1c0edcd2a6e734b3fa4470 /src/geometry
parenta1aa8855f76168d8af14244a54c9f28d15696342 (diff)
downloadrapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.tar.gz
rapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.tar.bz2
rapier-aa61fe65e3ff0289ecab57b4053a3410cf6d4a87.zip
Add support of 64-bits reals.
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/broad_phase_multi_sap.rs24
-rw-r--r--src/geometry/contact_pair.rs14
-rw-r--r--src/geometry/narrow_phase.rs4
3 files changed, 21 insertions, 21 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,
) {
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs
index b2ae812..129d444 100644
--- a/src/geometry/contact_pair.rs
+++ b/src/geometry/contact_pair.rs
@@ -20,25 +20,25 @@ pub struct ContactData {
/// The impulse, along the contact normal, applied by this contact to the first collider's rigid-body.
///
/// The impulse applied to the second collider's rigid-body is given by `-impulse`.
- pub impulse: f32,
+ pub impulse: Real,
/// The friction impulse along the vector orthonormal to the contact normal, applied to the first
/// collider's rigid-body.
#[cfg(feature = "dim2")]
- pub tangent_impulse: f32,
+ pub tangent_impulse: Real,
/// The friction impulses along the basis orthonormal to the contact normal, applied to the first
/// collider's rigid-body.
#[cfg(feature = "dim3")]
- pub tangent_impulse: [f32; 2],
+ pub tangent_impulse: [Real; 2],
}
impl ContactData {
#[cfg(feature = "dim2")]
- pub(crate) fn zero_tangent_impulse() -> f32 {
+ pub(crate) fn zero_tangent_impulse() -> Real {
0.0
}
#[cfg(feature = "dim3")]
- pub(crate) fn zero_tangent_impulse() -> [f32; 2] {
+ pub(crate) fn zero_tangent_impulse() -> [Real; 2] {
[0.0, 0.0]
}
}
@@ -87,7 +87,7 @@ pub struct ContactManifoldData {
// The following are set by the narrow-phase.
/// The pair of body involved in this contact manifold.
pub body_pair: BodyPair,
- pub(crate) warmstart_multiplier: f32,
+ pub(crate) warmstart_multiplier: Real,
// The two following are set by the constraints solver.
pub(crate) constraint_index: usize,
pub(crate) position_constraint_index: usize,
@@ -140,7 +140,7 @@ impl ContactManifoldData {
self.solver_contacts.len()
}
- pub(crate) fn min_warmstart_multiplier() -> f32 {
+ pub(crate) fn min_warmstart_multiplier() -> Real {
// Multiplier used to reduce the amount of warm-starting.
// This coefficient increases exponentially over time, until it reaches 1.0.
// This will reduce significant overshoot at the timesteps that
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs
index b94ce6f..3fda8a6 100644
--- a/src/geometry/narrow_phase.rs
+++ b/src/geometry/narrow_phase.rs
@@ -10,7 +10,7 @@ use crate::geometry::{
ProximityPairFilter, RemovedCollider, SolverContact, SolverFlags,
};
use crate::geometry::{ColliderSet, ContactManifold, ContactPair, InteractionGraph};
-use crate::math::Vector;
+use crate::math::{Real, Vector};
use crate::pipeline::EventHandler;
use cdl::query::{DefaultQueryDispatcher, PersistentQueryDispatcher};
use std::collections::HashMap;
@@ -452,7 +452,7 @@ impl NarrowPhase {
pub(crate) fn compute_contacts(
&mut self,
- prediction_distance: f32,
+ prediction_distance: Real,
bodies: &RigidBodySet,
colliders: &ColliderSet,
pair_filter: Option<&dyn ContactPairFilter>,