aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/integration_parameters.rs56
-rw-r--r--src/dynamics/joint/ball_joint.rs16
-rw-r--r--src/dynamics/joint/fixed_joint.rs10
-rw-r--r--src/dynamics/joint/prismatic_joint.rs68
-rw-r--r--src/dynamics/joint/revolute_joint.rs24
-rw-r--r--src/dynamics/rigid_body.rs122
-rw-r--r--src/dynamics/solver/delta_vel.rs4
-rw-r--r--src/dynamics/solver/interaction_groups.rs2
-rw-r--r--src/dynamics/solver/joint_constraint/ball_position_constraint.rs32
-rw-r--r--src/dynamics/solver/joint_constraint/ball_position_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs34
-rw-r--r--src/dynamics/solver/joint_constraint/ball_velocity_constraint_wide.rs10
-rw-r--r--src/dynamics/solver/joint_constraint/fixed_position_constraint.rs40
-rw-r--r--src/dynamics/solver/joint_constraint/fixed_velocity_constraint.rs54
-rw-r--r--src/dynamics/solver/joint_constraint/fixed_velocity_constraint_wide.rs12
-rw-r--r--src/dynamics/solver/joint_constraint/joint_constraint.rs5
-rw-r--r--src/dynamics/solver/joint_constraint/joint_position_constraint.rs4
-rw-r--r--src/dynamics/solver/joint_constraint/prismatic_position_constraint.rs38
-rw-r--r--src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs74
-rw-r--r--src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs10
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_position_constraint.rs34
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs44
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs10
-rw-r--r--src/dynamics/solver/parallel_island_solver.rs10
-rw-r--r--src/dynamics/solver/parallel_position_solver.rs4
-rw-r--r--src/dynamics/solver/parallel_velocity_solver.rs2
-rw-r--r--src/dynamics/solver/position_constraint.rs26
-rw-r--r--src/dynamics/solver/position_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/position_ground_constraint.rs20
-rw-r--r--src/dynamics/solver/position_ground_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/position_solver.rs4
-rw-r--r--src/dynamics/solver/solver_constraints.rs7
-rw-r--r--src/dynamics/solver/velocity_constraint.rs28
-rw-r--r--src/dynamics/solver/velocity_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/velocity_ground_constraint.rs20
-rw-r--r--src/dynamics/solver/velocity_ground_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/velocity_solver.rs3
-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
-rw-r--r--src/lib.rs9
-rw-r--r--src/pipeline/collision_pipeline.rs3
-rw-r--r--src/pipeline/physics_pipeline.rs6
-rw-r--r--src/utils.rs93
44 files changed, 514 insertions, 496 deletions
diff --git a/src/dynamics/integration_parameters.rs b/src/dynamics/integration_parameters.rs
index b31c3f6..706fb3f 100644
--- a/src/dynamics/integration_parameters.rs
+++ b/src/dynamics/integration_parameters.rs
@@ -1,11 +1,13 @@
+use crate::math::Real;
+
/// Parameters for a time-step of the physics engine.
#[derive(Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct IntegrationParameters {
/// The timestep length (default: `1.0 / 60.0`)
- dt: f32,
+ dt: Real,
/// The inverse of `dt`.
- inv_dt: f32,
+ inv_dt: Real,
// /// If `true` and if rapier is compiled with the `parallel` feature, this will enable rayon-based multithreading (default: `true`).
// ///
// /// This parameter is ignored if rapier is not compiled with is `parallel` feature.
@@ -19,31 +21,31 @@ pub struct IntegrationParameters {
pub return_after_ccd_substep: bool,
/// The Error Reduction Parameter in `[0, 1]` is the proportion of
/// the positional error to be corrected at each time step (default: `0.2`).
- pub erp: f32,
+ pub erp: Real,
/// The Error Reduction Parameter for joints in `[0, 1]` is the proportion of
/// the positional error to be corrected at each time step (default: `0.2`).
- pub joint_erp: f32,
+ pub joint_erp: Real,
/// Each cached impulse are multiplied by this coefficient in `[0, 1]`
/// when they are re-used to initialize the solver (default `1.0`).
- pub warmstart_coeff: f32,
+ pub warmstart_coeff: Real,
/// Contacts at points where the involved bodies have a relative
/// velocity smaller than this threshold wont be affected by the restitution force (default: `1.0`).
- pub restitution_velocity_threshold: f32,
+ pub restitution_velocity_threshold: Real,
/// Amount of penetration the engine wont attempt to correct (default: `0.001m`).
- pub allowed_linear_error: f32,
+ pub allowed_linear_error: Real,
/// The maximal distance separating two objects that will generate predictive contacts (default: `0.002`).
- pub prediction_distance: f32,
+ pub prediction_distance: Real,
/// Amount of angular drift of joint limits the engine wont
/// attempt to correct (default: `0.001rad`).
- pub allowed_angular_error: f32,
+ pub allowed_angular_error: Real,
/// Maximum linear correction during one step of the non-linear position solver (default: `0.2`).
- pub max_linear_correction: f32,
+ pub max_linear_correction: Real,
/// Maximum angular correction during one step of the non-linear position solver (default: `0.2`).
- pub max_angular_correction: f32,
+ pub max_angular_correction: Real,
/// Maximum nonlinear SOR-prox scaling parameter when the constraint
/// correction direction is close to the kernel of the involved multibody's
/// jacobian (default: `0.2`).
- pub max_stabilization_multiplier: f32,
+ pub max_stabilization_multiplier: Real,
/// Maximum number of iterations performed by the velocity constraints solver (default: `4`).
pub max_velocity_iterations: usize,
/// Maximum number of iterations performed by the position-based constraints solver (default: `1`).
@@ -88,18 +90,18 @@ pub struct IntegrationParameters {
impl IntegrationParameters {
/// Creates a set of integration parameters with the given values.
pub fn new(
- dt: f32,
+ dt: Real,
// multithreading_enabled: bool,
- erp: f32,
- joint_erp: f32,
- warmstart_coeff: f32,
- restitution_velocity_threshold: f32,
- allowed_linear_error: f32,
- allowed_angular_error: f32,
- max_linear_correction: f32,
- max_angular_correction: f32,
- prediction_distance: f32,
- max_stabilization_multiplier: f32,
+ erp: Real,
+ joint_erp: Real,
+ warmstart_coeff: Real,
+ restitution_velocity_threshold: Real,
+ allowed_linear_error: Real,
+ allowed_angular_error: Real,
+ max_linear_correction: Real,
+ max_angular_correction: Real,
+ prediction_distance: Real,
+ max_stabilization_multiplier: Real,
max_velocity_iterations: usize,
max_position_iterations: usize,
max_ccd_position_iterations: usize,
@@ -140,7 +142,7 @@ impl IntegrationParameters {
/// The current time-stepping length.
#[inline(always)]
- pub fn dt(&self) -> f32 {
+ pub fn dt(&self) -> Real {
self.dt
}
@@ -148,7 +150,7 @@ impl IntegrationParameters {
///
/// This is zero if `self.dt` is zero.
#[inline(always)]
- pub fn inv_dt(&self) -> f32 {
+ pub fn inv_dt(&self) -> Real {
self.inv_dt
}
@@ -156,7 +158,7 @@ impl IntegrationParameters {
///
/// This automatically recompute `self.inv_dt`.
#[inline]
- pub fn set_dt(&mut self, dt: f32) {
+ pub fn set_dt(&mut self, dt: Real) {
assert!(dt >= 0.0, "The time-stepping length cannot be negative.");
self.dt = dt;
if dt == 0.0 {
@@ -170,7 +172,7 @@ impl IntegrationParameters {
///
/// This automatically recompute `self.dt`.
#[inline]
- pub fn set_inv_dt(&mut self, inv_dt: f32) {
+ pub fn set_inv_dt(&mut self, inv_dt: Real) {
self.inv_dt = inv_dt;
if inv_dt == 0.0 {
self.dt = 0.0
diff --git a/src/dynamics/joint/ball_joint.rs b/src/dynamics/joint/ball_joint.rs
index ec255d4..82e2a10 100644
--- a/src/dynamics/joint/ball_joint.rs
+++ b/src/dynamics/joint/ball_joint.rs
@@ -1,29 +1,29 @@
-use crate::math::{Point, Vector};
+use crate::math::{Point, Real, Vector};
#[derive(Copy, Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
/// A joint that removes all relative linear motion between a pair of points on two bodies.
pub struct BallJoint {
/// Where the ball joint is attached on the first body, expressed in the first body local frame.
- pub local_anchor1: Point<f32>,
+ pub local_anchor1: Point<Real>,
/// Where the ball joint is attached on the first body, expressed in the first body local frame.
- pub local_anchor2: Point<f32>,
+ pub local_anchor2: Point<Real>,
/// The impulse applied by this joint on the first body.
///
/// The impulse applied to the second body is given by `-impulse`.
- pub impulse: Vector<f32>,
+ pub impulse: Vector<Real>,
}
impl BallJoint {
/// Creates a new Ball joint from two anchors given on the local spaces of the respective bodies.
- pub fn new(local_anchor1: Point<f32>, local_anchor2: Point<f32>) -> Self {
+ pub fn new(local_anchor1: Point<Real>, local_anchor2: Point<Real>) -> Self {
Self::with_impulse(local_anchor1, local_anchor2, Vector::zeros())
}
pub(crate) fn with_impulse(
- local_anchor1: Point<f32>,
- local_anchor2: Point<f32>,
- impulse: Vector<f32>,
+ local_anchor1: Point<Real>,
+ local_anchor2: Point<Real>,
+ impulse: Vector<Real>,
) -> Self {
Self {
local_anchor1,
diff --git a/src/dynamics/joint/fixed_joint.rs b/src/dynamics/joint/fixed_joint.rs
index 0731cfb..359e14a 100644
--- a/src/dynamics/joint/fixed_joint.rs
+++ b/src/dynamics/joint/fixed_joint.rs
@@ -1,4 +1,4 @@
-use crate::math::{Isometry, SpacialVector};
+use crate::math::{Isometry, Real, SpacialVector};
#[derive(Copy, Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
@@ -8,22 +8,22 @@ use crate::math::{Isometry, SpacialVector};
pub struct FixedJoint {
/// The frame of reference for the first body affected by this joint, expressed in the local frame
/// of the first body.
- pub local_anchor1: Isometry<f32>,
+ pub local_anchor1: Isometry<Real>,
/// The frame of reference for the second body affected by this joint, expressed in the local frame
/// of the first body.
- pub local_anchor2: Isometry<f32>,
+ pub local_anchor2: Isometry<Real>,
/// The impulse applied to the first body affected by this joint.
///
/// The impulse applied to the second body affected by this joint is given by `-impulse`.
/// This combines both linear and angular impulses:
/// - In 2D, `impulse.xy()` gives the linear impulse, and `impulse.z` the angular impulse.
/// - In 3D, `impulse.xyz()` gives the linear impulse, and `(impulse[3], impulse[4], impulse[5])` the angular impulse.
- pub impulse: SpacialVector<f32>,
+ pub impulse: SpacialVector<Real>,
}
impl FixedJoint {
/// Creates a new fixed joint from the frames of reference of both bodies.
- pub fn new(local_anchor1: Isometry<f32>, local_anchor2: Isometry<f32>) -> Self {
+ pub fn new(local_anchor1: Isometry<Real>, local_anchor2: Isometry<Real>) -> Self {
Self {
local_anchor1,
local_anchor2,
diff --git a/src/dynamics/joint/prismatic_joint.rs b/src/dynamics/joint/prismatic_joint.rs
index a6fd558..174ce79 100644
--- a/src/dynamics/joint/prismatic_joint.rs
+++ b/src/dynamics/joint/prismatic_joint.rs
@@ -1,4 +1,4 @@
-use crate::math::{Isometry, Point, Vector, DIM};
+use crate::math::{Isometry, Point, Real, Vector, DIM};
use crate::utils::WBasis;
use na::Unit;
#[cfg(feature = "dim2")]
@@ -11,35 +11,35 @@ use na::Vector5;
/// A joint that removes all relative motion between two bodies, except for the translations along one axis.
pub struct PrismaticJoint {
/// Where the prismatic joint is attached on the first body, expressed in the local space of the first attached body.
- pub local_anchor1: Point<f32>,
+ pub local_anchor1: Point<Real>,
/// Where the prismatic joint is attached on the second body, expressed in the local space of the second attached body.
- pub local_anchor2: Point<f32>,
- pub(crate) local_axis1: Unit<Vector<f32>>,
- pub(crate) local_axis2: Unit<Vector<f32>>,
- pub(crate) basis1: [Vector<f32>; DIM - 1],
- pub(crate) basis2: [Vector<f32>; DIM - 1],
+ pub local_anchor2: Point<Real>,
+ pub(crate) local_axis1: Unit<Vector<Real>>,
+ pub(crate) local_axis2: Unit<Vector<Real>>,
+ pub(crate) basis1: [Vector<Real>; DIM - 1],
+ pub(crate) basis2: [Vector<Real>; DIM - 1],
/// The impulse applied by this joint on the first body.
///
/// The impulse applied to the second body is given by `-impulse`.
#[cfg(feature = "dim3")]
- pub impulse: Vector5<f32>,
+ pub impulse: Vector5<Real>,
/// The impulse applied by this joint on the first body.
///
/// The impulse applied to the second body is given by `-impulse`.
#[cfg(feature = "dim2")]
- pub impulse: Vector2<f32>,
+ pub impulse: Vector2<Real>,
/// Whether or not this joint should enforce translational limits along its axis.
pub limits_enabled: bool,
/// The min an max relative position of the attached bodies along this joint's axis.
- pub limits: [f32; 2],
+ pub limits: [Real; 2],
/// The impulse applied by this joint on the first body to enforce the position limit along this joint's axis.
///
/// The impulse applied to the second body is given by `-impulse`.
- pub limits_impulse: f32,
+ pub limits_impulse: Real,
// pub motor_enabled: bool,
- // pub target_motor_vel: f32,
- // pub max_motor_impulse: f32,
- // pub motor_impulse: f32,
+ // pub target_motor_vel: Real,
+ // pub max_motor_impulse: Real,
+ // pub motor_impulse: Real,
}
impl PrismaticJoint {
@@ -47,10 +47,10 @@ impl PrismaticJoint {
/// in the local-space of the affected bodies.
#[cfg(feature = "dim2")]
pub fn new(
- local_anchor1: Point<f32>,
- local_axis1: Unit<Vector<f32>>,
- local_anchor2: Point<f32>,
- local_axis2: Unit<Vector<f32>>,
+ local_anchor1: Point<Real>,
+ local_axis1: Unit<Vector<Real>>,
+ local_anchor2: Point<Real>,
+ local_axis2: Unit<Vector<Real>>,
) -> Self {
Self {
local_anchor1,
@@ -61,11 +61,11 @@ impl PrismaticJoint {
basis2: local_axis2.orthonormal_basis(),
impulse: na::zero(),
limits_enabled: false,
- limits: [-f32::MAX, f32::MAX],
+ limits: [-Real::MAX, Real::MAX],
limits_impulse: 0.0,
// motor_enabled: false,
// target_motor_vel: 0.0,
- // max_motor_impulse: f32::MAX,
+ // max_motor_impulse: Real::MAX,
// motor_impulse: 0.0,
}
}
@@ -78,12 +78,12 @@ impl PrismaticJoint {
/// computed arbitrarily.
#[cfg(feature = "dim3")]
pub fn new(
- local_anchor1: Point<f32>,
- local_axis1: Unit<Vector<f32>>,
- local_tangent1: Vector<f32>,
- local_anchor2: Point<f32>,
- local_axis2: Unit<Vector<f32>>,
- local_tangent2: Vector<f32>,
+ local_anchor1: Point<Real>,
+ local_axis1: Unit<Vector<Real>>,
+ local_tangent1: Vector<Real>,
+ local_anchor2: Point<Real>,
+ local_axis2: Unit<Vector<Real>>,
+ local_tangent2: Vector<Real>,
) -> Self {
let basis1 = if let Some(local_bitangent1) =
Unit::try_new(local_axis1.cross(&local_tangent1), 1.0e-3)
@@ -116,28 +116,28 @@ impl PrismaticJoint {
basis2,
impulse: na::zero(),
limits_enabled: false,
- limits: [-f32::MAX, f32::MAX],
+ limits: [-Real::MAX, Real::MAX],
limits_impulse: 0.0,
// motor_enabled: false,
// target_motor_vel: 0.0,
- // max_motor_impulse: f32::MAX,
+ // max_motor_impulse: Real::MAX,
// motor_impulse: 0.0,
}
}
/// The local axis of this joint, expressed in the local-space of the first attached body.
- pub fn local_axis1(&self) -> Unit<Vector<f32>> {
+ pub fn local_axis1(&self) -> Unit<Vector<Real>> {
self.local_axis1
}
/// The local axis of this joint, expressed in the local-space of the second attached body.
- pub fn local_axis2(&self) -> Unit<Vector<f32>> {
+ pub fn local_axis2(&self) -> Unit<Vector<Real>> {
self.local_axis2
}
// FIXME: precompute this?
#[cfg(feature = "dim2")]
- pub(crate) fn local_frame1(&self) -> Isometry<f32> {
+ pub(crate) fn local_frame1(&self) -> Isometry<Real> {
use na::{Matrix2, Rotation2, UnitComplex};
let mat = Matrix2::from_columns(&[self.local_axis1.into_inner(), self.basis1[0]]);
@@ -149,7 +149,7 @@ impl PrismaticJoint {
// FIXME: precompute this?
#[cfg(feature = "dim2")]
- pub(crate) fn local_frame2(&self) -> Isometry<f32> {
+ pub(crate) fn local_frame2(&self) -> Isometry<Real> {
use na::{Matrix2, Rotation2, UnitComplex};
let mat = Matrix2::from_columns(&[self.local_axis2.into_inner(), self.basis2[0]]);
@@ -161,7 +161,7 @@ impl PrismaticJoint {
// FIXME: precompute this?
#[cfg(feature = "dim3")]
- pub(crate) fn local_frame1(&self) -> Isometry<f32> {
+ pub(crate) fn local_frame1(&self) -> Isometry<Real> {
use na::{Matrix3, Rotation3, UnitQuaternion};
let mat = Matrix3::from_columns(&[
@@ -177,7 +177,7 @@ impl PrismaticJoint {
// FIXME: precompute this?
#[cfg(feature = "dim3")]
- pub(crate) fn local_frame2(&self) -> Isometry<f32> {
+ pub(crate) fn local_frame2(&self) -> Isometry<Real> {
use na::{Matrix3, Rotation3, UnitQuaternion};
let mat = Matrix3::from_columns(&[
diff --git a/src/dynamics/joint/revolute_joint.rs b/src/dynamics/joint/revolute_joint.rs
index cdb424b..ad7db0d 100644
--- a/src/dynamics/joint/revolute_joint.rs
+++ b/src/dynamics/joint/revolute_joint.rs
@@ -1,4 +1,4 @@
-use crate::math::{Point, Vector};
+use crate::math::{Point, Real, Vector};
use crate::utils::WBasis;
use na::{Unit, Vector5};
@@ -7,31 +7,31 @@ use na::{Unit, Vector5};
/// A joint that removes all relative motion between two bodies, except for the rotations along one axis.
pub struct RevoluteJoint {
/// Where the revolute joint is attached on the first body, expressed in the local space of the first attached body.
- pub local_anchor1: Point<f32>,
+ pub local_anchor1: Point<Real>,
/// Where the revolute joint is attached on the second body, expressed in the local space of the second attached body.
- pub local_anchor2: Point<f32>,
+ pub local_anchor2: Point<Real>,
/// The rotation axis of this revolute joint expressed in the local space of the first attached body.
- pub local_axis1: Unit<Vector<f32>>,
+ pub local_axis1: Unit<Vector<Real>>,
/// The rotation axis of this revolute joint expressed in the local space of the second attached body.
- pub local_axis2: Unit<Vector<f32>>,
+ pub local_axis2: Unit<Vector<Real>>,
/// The basis orthonormal to `local_axis1`, expressed in the local space of the first attached body.
- pub basis1: [Vector<f32>; 2],
+ pub basis1: [Vector<Real>; 2],
/// The basis orthonormal to `local_axis2`, expressed in the local space of the second attached body.
- pub basis2: [Vector<f32>; 2],
+ pub basis2: [Vector<Real>; 2],
/// The impulse applied by this joint on the first body.
///
/// The impulse applied to the second body is given by `-impulse`.
- pub impulse: Vector5<f32>,
+ pub impulse: Vector5<Real>,
}
impl RevoluteJoint {
/// Creates a new revolute joint with the given point of applications and axis, all expressed
/// in the local-space of the affected bodies.
pub fn new(
- local_anchor1: Point<f32>,
- local_axis1: Unit<Vector<f32>>,
- local_anchor2: Point<f32>,
- local_axis2: Unit<Vector<f32>>,
+ local_anchor1: Point<Real>,
+ local_axis1: Unit<Vector<Real>>,
+ local_anchor2: Point<Real>,
+ local_axis2: Unit<Vector<Real>>,
) -> Self {
Self {
local_anchor1,
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 5128b6f..683cca8 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -2,7 +2,9 @@ use crate::dynamics::MassProperties;
use crate::geometry::{
Collider, ColliderHandle, ColliderSet, InteractionGraph, RigidBodyGraphIndex,
};
-use crate::math::{AngVector, AngularInertia, Isometry, Point, Rotation, Translation, Vector};
+use crate::math::{
+ AngVector, AngularInertia, Isometry, Point, Real, Rotation, Translation, Vector,
+};
use crate::utils::{self, WCross, WDot};
use num::Zero;
@@ -54,24 +56,24 @@ bitflags::bitflags! {
#[derive(Debug, Clone)]
pub struct RigidBody {
/// The world-space position of the rigid-body.
- pub(crate) position: Isometry<f32>,
- pub(crate) predicted_position: Isometry<f32>,
+ pub(crate) position: Isometry<Real>,
+ pub(crate) predicted_position: Isometry<Real>,
/// The local mass properties of the rigid-body.
pub(crate) mass_properties: MassProperties,
/// The world-space center of mass of the rigid-body.
- pub world_com: Point<f32>,
+ pub world_com: Point<Real>,
/// The square-root of the inverse angular inertia tensor of the rigid-body.
- pub world_inv_inertia_sqrt: AngularInertia<f32>,
+ pub world_inv_inertia_sqrt: AngularInertia<Real>,
/// The linear velocity of the rigid-body.
- pub(crate) linvel: Vector<f32>,
+ pub(crate) linvel: Vector<Real>,
/// The angular velocity of the rigid-body.
- pub(crate) angvel: AngVector<f32>,
+ pub(crate) angvel: AngVector<Real>,
/// Damping factor for gradually slowing down the translational motion of the rigid-body.
- pub linear_damping: f32,
+ pub linear_damping: Real,
/// Damping factor for gradually slowing down the angular motion of the rigid-body.
- pub angular_damping: f32,
- pub(crate) linacc: Vector<f32>,
- pub(crate) angacc: AngVector<f32>,
+ pub angular_damping: Real,
+ pub(crate) linacc: Vector<Real>,
+ pub(crate) angacc: AngVector<Real>,
pub(crate) colliders: Vec<ColliderHandle>,
/// Whether or not this rigid-body is sleeping.
pub activation: ActivationStatus,
@@ -125,7 +127,7 @@ impl RigidBody {
self.active_set_timestamp = 0;
}
- pub(crate) fn integrate_accelerations(&mut self, dt: f32, gravity: Vector<f32>) {
+ pub(crate) fn integrate_accelerations(&mut self, dt: Real, gravity: Vector<Real>) {
if self.mass_properties.inv_mass != 0.0 {
self.linvel += (gravity + self.linacc) * dt;
self.angvel += self.angacc * dt;
@@ -184,7 +186,7 @@ impl RigidBody {
/// The mass of this rigid body.
///
/// Returns zero if this rigid body has an infinite mass.
- pub fn mass(&self) -> f32 {
+ pub fn mass(&self) -> Real {
utils::inv(self.mass_properties.inv_mass)
}
@@ -193,7 +195,7 @@ impl RigidBody {
/// If this rigid-body is kinematic this value is set by the `set_next_kinematic_position`
/// method and is used for estimating the kinematic body velocity at the next timestep.
/// For non-kinematic bodies, this value is currently unspecified.
- pub fn predicted_position(&self) -> &Isometry<f32> {
+ pub fn predicted_position(&self) -> &Isometry<Real> {
&self.predicted_position
}
@@ -311,13 +313,13 @@ impl RigidBody {
!self.linvel.is_zero() || !self.angvel.is_zero()
}
- fn integrate_velocity(&self, dt: f32) -> Isometry<f32> {
+ fn integrate_velocity(&self, dt: Real) -> Isometry<Real> {
let com = &self.position * self.mass_properties.local_com;
let shift = Translation::from(com.coords);
shift * Isometry::new(self.linvel * dt, self.angvel * dt) * shift.inverse()
}
- pub(crate) fn integrate(&mut self, dt: f32) {
+ pub(crate) fn integrate(&mut self, dt: Real) {
// TODO: do we want to apply damping before or after the velocity integration?
self.linvel *= 1.0 / (1.0 + dt * self.linear_damping);
self.angvel *= 1.0 / (1.0 + dt * self.angular_damping);
@@ -326,19 +328,19 @@ impl RigidBody {
}
/// The linear velocity of this rigid-body.
- pub fn linvel(&self) -> &Vector<f32> {
+ pub fn linvel(&self) -> &Vector<Real> {
&self.linvel
}
/// The angular velocity of this rigid-body.
#[cfg(feature = "dim2")]
- pub fn angvel(&self) -> f32 {
+ pub fn angvel(&self) -> Real {
self.angvel
}
/// The angular velocity of this rigid-body.
#[cfg(feature = "dim3")]
- pub fn angvel(&self) -> &Vector<f32> {
+ pub fn angvel(&self) -> &Vector<Real> {
&self.angvel
}
@@ -346,7 +348,7 @@ impl RigidBody {
///
/// If `wake_up` is `true` then the rigid-body will be woken up if it was
/// put to sleep because it did not move for a while.
- pub fn set_linvel(&mut self, linvel: Vector<f32>, wake_up: bool) {
+ pub fn set_linvel(&mut self, linvel: Vector<Real>, wake_up: bool) {
self.linvel = linvel;
if self.is_dynamic() && wake_up {
@@ -359,7 +361,7 @@ impl RigidBody {
/// If `wake_up` is `true` then the rigid-body will be woken up if it was
/// put to sleep because it did not move for a while.
#[cfg(feature = "dim2")]
- pub fn set_angvel(&mut self, angvel: f32, wake_up: bool) {
+ pub fn set_angvel(&mut self, angvel: Real, wake_up: bool) {
self.angvel = angvel;
if self.is_dynamic() && wake_up {
@@ -372,7 +374,7 @@ impl RigidBody {
/// If `wake_up` is `true` then the rigid-body will be woken up if it was
/// put to sleep because it did not move for a while.
#[cfg(feature = "dim3")]
- pub fn set_angvel(&mut self, angvel: Vector<f32>, wake_up: bool) {
+ pub fn set_angvel(&mut self, angvel: Vector<Real>, wake_up: bool) {
self.angvel = angvel;
if self.is_dynamic() && wake_up {
@@ -381,7 +383,7 @@ impl RigidBody {
}
/// The world-space position of this rigid-body.
- pub fn position(&self) -> &Isometry<f32> {
+ pub fn position(&self) -> &Isometry<Real> {
&self.position
}
@@ -394,7 +396,7 @@ impl RigidBody {
///
/// If `wake_up` is `true` then the rigid-body will be woken up if it was
/// put to sleep because it did not move for a while.
- pub fn set_position(&mut self, pos: Isometry<f32>, wake_up: bool) {
+ pub fn set_position(&mut self, pos: Isometry<Real>, wake_up: bool) {
self.changes.insert(RigidBodyChanges::POSITION);
self.set_position_internal(pos);
@@ -404,