aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-02-22 14:20:06 +0100
committerCrozet Sébastien <developer@crozet.re>2021-02-22 14:20:06 +0100
commit0eec28325ecf192f386a6894526e97a462e68802 (patch)
tree3d5a08cc2a0569df703f5e03c7ccbeeab5e30eaa
parent4c9138fd2b8413a44ea665a2db5d245370ff54fe (diff)
downloadrapier-0eec28325ecf192f386a6894526e97a462e68802.tar.gz
rapier-0eec28325ecf192f386a6894526e97a462e68802.tar.bz2
rapier-0eec28325ecf192f386a6894526e97a462e68802.zip
Fix warnings.
-rw-r--r--src/dynamics/joint/ball_joint.rs6
-rw-r--r--src/dynamics/joint/generic_joint.rs2
-rw-r--r--src/dynamics/joint/joint.rs1
-rw-r--r--src/dynamics/joint/prismatic_joint.rs4
-rw-r--r--src/dynamics/joint/revolute_joint.rs4
-rw-r--r--src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs6
-rw-r--r--src/dynamics/solver/joint_constraint/joint_position_constraint.rs1
-rw-r--r--src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs24
-rw-r--r--src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs6
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_position_constraint.rs2
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs11
-rw-r--r--src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs2
-rw-r--r--src/lib.rs6
13 files changed, 45 insertions, 30 deletions
diff --git a/src/dynamics/joint/ball_joint.rs b/src/dynamics/joint/ball_joint.rs
index 47c90ab..8481961 100644
--- a/src/dynamics/joint/ball_joint.rs
+++ b/src/dynamics/joint/ball_joint.rs
@@ -74,20 +74,24 @@ impl BallJoint {
self.motor_max_impulse == 0.0 || (self.motor_stiffness == 0.0 && self.motor_damping == 0.0)
}
+ /// Set the spring-like model used by the motor to reach the desired target velocity and position.
pub fn configure_motor_model(&mut self, model: SpringModel) {
self.motor_model = model;
}
+ /// Sets the target velocity and velocity correction factor this motor.
#[cfg(feature = "dim2")]
pub fn configure_motor_velocity(&mut self, target_vel: Real, factor: Real) {
self.configure_motor(self.motor_target_pos, target_vel, 0.0, factor)
}
+ /// Sets the target velocity and velocity correction factor this motor.
#[cfg(feature = "dim3")]
pub fn configure_motor_velocity(&mut self, target_vel: Vector<Real>, factor: Real) {
self.configure_motor(self.motor_target_pos, target_vel, 0.0, factor)
}
+ /// Sets the target orientation this motor needs to reach.
pub fn configure_motor_position(
&mut self,
target_pos: Rotation<Real>,
@@ -97,6 +101,7 @@ impl BallJoint {
self.configure_motor(target_pos, na::zero(), stiffness, damping)
}
+ /// Sets the target orientation this motor needs to reach.
#[cfg(feature = "dim2")]
pub fn configure_motor(
&mut self,
@@ -111,6 +116,7 @@ impl BallJoint {
self.motor_damping = damping;
}
+ /// Configure both the target orientation and target velocity of the motor.
#[cfg(feature = "dim3")]
pub fn configure_motor(
&mut self,
diff --git a/src/dynamics/joint/generic_joint.rs b/src/dynamics/joint/generic_joint.rs
index 5d776b0..c1549ff 100644
--- a/src/dynamics/joint/generic_joint.rs
+++ b/src/dynamics/joint/generic_joint.rs
@@ -1,5 +1,5 @@
use crate::dynamics::{BallJoint, FixedJoint, PrismaticJoint, RevoluteJoint};
-use crate::math::{Isometry, Real, SpacialVector, SPATIAL_DIM};
+use crate::math::{Isometry, Real, SpacialVector};
use crate::na::{Rotation3, UnitQuaternion};
#[derive(Copy, Clone, Debug)]
diff --git a/src/dynamics/joint/joint.rs b/src/dynamics/joint/joint.rs
index 290c34c..e0a9d38 100644
--- a/src/dynamics/joint/joint.rs
+++ b/src/dynamics/joint/joint.rs
@@ -130,6 +130,7 @@ pub struct Joint {
}
impl Joint {
+ /// Can this joint use SIMD-accelerated constraint formulations?
pub fn supports_simd_constraints(&self) -> bool {
match &self.params {
JointParams::PrismaticJoint(joint) => joint.supports_simd_constraints(),
diff --git a/src/dynamics/joint/prismatic_joint.rs b/src/dynamics/joint/prismatic_joint.rs
index 4f5c984..3736b7f 100644
--- a/src/dynamics/joint/prismatic_joint.rs
+++ b/src/dynamics/joint/prismatic_joint.rs
@@ -217,18 +217,22 @@ impl PrismaticJoint {
Isometry::from_parts(translation, rotation)
}
+ /// Set the spring-like model used by the motor to reach the desired target velocity and position.
pub fn configure_motor_model(&mut self, model: SpringModel) {
self.motor_model = model;
}
+ /// Sets the target velocity this motor needs to reach.
pub fn configure_motor_velocity(&mut self, target_vel: Real, factor: Real) {
self.configure_motor(self.motor_target_pos, target_vel, 0.0, factor)
}
+ /// Sets the target position this motor needs to reach.
pub fn configure_motor_position(&mut self, target_pos: Real, stiffness: Real, damping: Real) {
self.configure_motor(target_pos, 0.0, stiffness, damping)
}
+ /// Configure both the target position and target velocity of the motor.
pub fn configure_motor(
&mut self,
target_pos: Real,
diff --git a/src/dynamics/joint/revolute_joint.rs b/src/dynamics/joint/revolute_joint.rs
index 6895d3d..d1181e9 100644
--- a/src/dynamics/joint/revolute_joint.rs
+++ b/src/dynamics/joint/revolute_joint.rs
@@ -85,18 +85,22 @@ impl RevoluteJoint {
self.motor_max_impulse == 0.0 || (self.motor_stiffness == 0.0 && self.motor_damping == 0.0)
}
+ /// Set the spring-like model used by the motor to reach the desired target velocity and position.
pub fn configure_motor_model(&mut self, model: SpringModel) {
self.motor_model = model;
}
+ /// Sets the target velocity this motor needs to reach.
pub fn configure_motor_velocity(&mut self, target_vel: Real, factor: Real) {
self.configure_motor(self.motor_target_pos, target_vel, 0.0, factor)
}
+ /// Sets the target angle this motor needs to reach.
pub fn configure_motor_position(&mut self, target_pos: Real, stiffness: Real, damping: Real) {
self.configure_motor(target_pos, 0.0, stiffness, damping)
}
+ /// Configure both the target angle and target velocity of the motor.
pub fn configure_motor(
&mut self,
target_pos: Real,
diff --git a/src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs b/src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs
index cb95532..a110fbb 100644
--- a/src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/ball_velocity_constraint.rs
@@ -210,7 +210,8 @@ impl BallVelocityConstraint {
let new_impulse = self.motor_impulse + motor_inv_lhs.transform_vector(dangvel);
#[cfg(feature = "dim2")]
- let clamped_impulse = na::clamp(new_impulse, -motor_max_impulse, motor_max_impulse);
+ let clamped_impulse =
+ na::clamp(new_impulse, -self.motor_max_impulse, self.motor_max_impulse);
#[cfg(feature = "dim3")]
let clamped_impulse = new_impulse.cap_magnitude(self.motor_max_impulse);
@@ -418,7 +419,8 @@ impl BallVelocityGroundConstraint {
let new_impulse = self.motor_impulse + motor_inv_lhs.transform_vector(dangvel);
#[cfg(feature = "dim2")]
- let clamped_impulse = na::clamp(new_impulse, -motor_max_impulse, motor_max_impulse);
+ let clamped_impulse =
+ na::clamp(new_impulse, -self.motor_max_impulse, self.motor_max_impulse);
#[cfg(feature = "dim3")]
let clamped_impulse = new_impulse.cap_magnitude(self.motor_max_impulse);
diff --git a/src/dynamics/solver/joint_constraint/joint_position_constraint.rs b/src/dynamics/solver/joint_constraint/joint_position_constraint.rs
index f0c374e..635e0b1 100644
--- a/src/dynamics/solver/joint_constraint/joint_position_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/joint_position_constraint.rs
@@ -13,7 +13,6 @@ use super::{
WFixedPositionGroundConstraint, WPrismaticPositionConstraint,
WPrismaticPositionGroundConstraint,
};
-use crate::dynamics::solver::DeltaVel;
use crate::dynamics::{IntegrationParameters, Joint, JointParams, RigidBodySet};
#[cfg(feature = "simd-is-enabled")]
use crate::math::SIMD_WIDTH;
diff --git a/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs b/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs
index 227338a..ae3f3e2 100644
--- a/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint.rs
@@ -3,7 +3,7 @@ use crate::dynamics::{
IntegrationParameters, JointGraphEdge, JointIndex, JointParams, PrismaticJoint, RigidBody,
};
use crate::math::{AngularInertia, Real, Vector};
-use crate::utils::{WAngularInertia, WCross, WCrossMatrix};
+use crate::utils::{WAngularInertia, WCross, WCrossMatrix, WDot};
#[cfg(feature = "dim3")]
use na::{Cholesky, Matrix3x2, Matrix5, Vector5, U2, U3};
#[cfg(feature = "dim2")]
@@ -148,7 +148,6 @@ impl PrismaticVelocityConstraint {
*/
let mut motor_rhs = 0.0;
let mut motor_inv_lhs = 0.0;
- let mut motor_max_impulse = joint.motor_max_impulse;
let (stiffness, damping, gamma, keep_lhs) = joint.motor_model.combine_coefficients(
params.dt,
@@ -171,7 +170,11 @@ impl PrismaticVelocityConstraint {
motor_rhs /= gamma;
}
- let motor_impulse = na::clamp(joint.motor_impulse, -motor_max_impulse, motor_max_impulse);
+ let motor_impulse = na::clamp(
+ joint.motor_impulse,
+ -joint.motor_max_impulse,
+ joint.motor_max_impulse,
+ );
/*
* Setup limit constraint.
@@ -202,8 +205,8 @@ impl PrismaticVelocityConstraint {
let gcross2 = r2.gcross(*axis2);
limits_inv_lhs = crate::utils::inv(
im1 + im2
- + gcross1.dot(&ii1.transform_vector(gcross1))
- + gcross2.dot(&ii2.transform_vector(gcross2)),
+ + gcross1.gdot(ii1.transform_vector(gcross1))
+ + gcross2.gdot(ii2.transform_vector(gcross2)),
);
}
}
@@ -226,7 +229,7 @@ impl PrismaticVelocityConstraint {
motor_impulse,
motor_axis1: *axis1,
motor_axis2: *axis2,
- motor_max_impulse,
+ motor_max_impulse: joint.motor_max_impulse,
basis1,
inv_lhs,
rhs,
@@ -530,7 +533,6 @@ impl PrismaticVelocityGroundConstraint {
*/
let mut motor_rhs = 0.0;
let mut motor_inv_lhs = 0.0;
- let mut motor_max_impulse = joint.motor_max_impulse;
let (stiffness, damping, gamma, keep_lhs) = joint.motor_model.combine_coefficients(
params.dt,
@@ -553,7 +555,11 @@ impl PrismaticVelocityGroundConstraint {
motor_rhs /= gamma;
}
- let motor_impulse = na::clamp(joint.motor_impulse, -motor_max_impulse, motor_max_impulse);
+ let motor_impulse = na::clamp(
+ joint.motor_impulse,
+ -joint.motor_max_impulse,
+ joint.motor_max_impulse,
+ );
/*
* Setup limit constraint.
@@ -590,7 +596,7 @@ impl PrismaticVelocityGroundConstraint {
motor_rhs,
motor_inv_lhs,
motor_impulse,
- motor_max_impulse,
+ motor_max_impulse: joint.motor_max_impulse,
basis1,
inv_lhs,
rhs,
diff --git a/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs b/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs
index be85024..442393d 100644
--- a/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs
+++ b/src/dynamics/solver/joint_constraint/prismatic_velocity_constraint_wide.rs
@@ -7,7 +7,7 @@ use crate::dynamics::{
use crate::math::{
AngVector, AngularInertia, Isometry, Point, Real, SimdBool, SimdReal, Vector, SIMD_WIDTH,
};
-use crate::utils::{WAngularInertia, WCross, WCrossMatrix};
+use crate::utils::{WAngularInertia, WCross, WCrossMatrix, WDot};
#[cfg(feature = "dim3")]
use na::{Cholesky, Matrix3x2, Matrix5, Vector5, U2, U3};
#[cfg(feature = "dim2")]
@@ -223,8 +223,8 @@ impl WPrismaticVelocityConstraint {
limits_inv_lhs = SimdReal::splat(1.0)
/ (im1
+ im2
- + gcross1.dot(&ii1.transform_vector(gcross1))
- + gcross2.dot(&ii2.transform_vector(gcross2)));
+ + gcross1.gdot(ii1.transform_vector(gcross1))
+ + gcross2.gdot(ii2.transform_vector(gcross2)));
}
}
diff --git a/src/dynamics/solver/joint_constraint/revolute_position_constraint.rs b/src/dynamics/solver/joint_constraint/revolute_position_constraint.rs
index 9075ed7..2da49e6 100644
--- a/src/dynamics/solver/joint_constraint/revolute_position_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/revolute_position_constraint.rs
@@ -1,7 +1,7 @@
use crate::dynamics::{IntegrationParameters, RevoluteJoint, RigidBody};
use crate::math::{AngularInertia, Isometry, Point, Real, Rotation, Vector};
use crate::utils::{WAngularInertia, WCross, WCrossMatrix};
-use na::{Matrix3x2, Matrix5, Unit};
+use na::Unit;
#[derive(Debug)]
pub(crate) struct RevolutePositionConstraint {
diff --git a/src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs b/src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs
index c1975da..61cb720 100644
--- a/src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/revolute_velocity_constraint.rs
@@ -1,12 +1,11 @@
-use crate::dynamics::solver::{AnyJointVelocityConstraint, AnyVelocityConstraint, DeltaVel};
+use crate::dynamics::solver::{AnyJointVelocityConstraint, DeltaVel};
use crate::dynamics::{
IntegrationParameters, JointGraphEdge, JointIndex, JointParams, RevoluteJoint, RigidBody,
};
use crate::math::{AngularInertia, Real, Rotation, Vector};
use crate::na::UnitQuaternion;
use crate::utils::{WAngularInertia, WCross, WCrossMatrix};
-use downcast_rs::Downcast;
-use na::{Cholesky, Matrix3, Matrix3x2, Matrix5, RealField, Vector5, U2, U3};
+use na::{Cholesky, Matrix3x2, Matrix5, Vector5, U2, U3};
#[derive(Debug)]
pub(crate) struct RevoluteVelocityConstraint {
@@ -93,7 +92,7 @@ impl RevoluteVelocityConstraint {
let lin_rhs = (rb2.linvel + rb2.angvel.gcross(r2)) - (rb1.linvel + rb1.angvel.gcross(r1));
let ang_rhs = basis2.tr_mul(&rb2.angvel) - basis1.tr_mul(&rb1.angvel);
- let mut rhs = Vector5::new(lin_rhs.x, lin_rhs.y, lin_rhs.z, ang_rhs.x, ang_rhs.y);
+ let rhs = Vector5::new(lin_rhs.x, lin_rhs.y, lin_rhs.z, ang_rhs.x, ang_rhs.y);
/*
* Motor.
@@ -102,8 +101,8 @@ impl RevoluteVelocityConstraint {
let motor_axis2 = rb2.position * *joint.local_axis2;
let mut motor_rhs = 0.0;
let mut motor_inv_lhs = 0.0;
- let mut motor_max_impulse = joint.motor_max_impulse;
let mut motor_angle = 0.0;
+ let motor_max_impulse = joint.motor_max_impulse;
let (stiffness, damping, gamma, keep_lhs) = joint.motor_model.combine_coefficients(
params.dt,
@@ -381,8 +380,8 @@ impl RevoluteVelocityGroundConstraint {
*/
let mut motor_rhs = 0.0;
let mut motor_inv_lhs = 0.0;
- let mut motor_max_impulse = joint.motor_max_impulse;
let mut motor_angle = 0.0;
+ let motor_max_impulse = joint.motor_max_impulse;
let (stiffness, damping, gamma, keep_lhs) = joint.motor_model.combine_coefficients(
params.dt,
diff --git a/src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs b/src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs
index d229457..7750d98 100644
--- a/src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs
+++ b/src/dynamics/solver/joint_constraint/revolute_velocity_constraint_wide.rs
@@ -8,7 +8,7 @@ use crate::math::{
AngVector, AngularInertia, Isometry, Point, Real, Rotation, SimdReal, Vector, SIMD_WIDTH,
};
use crate::utils::{WAngularInertia, WCross, WCrossMatrix};
-use na::{Cholesky, Matrix3, Matrix3x2, Matrix5, Vector5, U2, U3};
+use na::{Cholesky, Matrix3x2, Matrix5, Vector5, U2, U3};
#[derive(Debug)]
pub(crate) struct WRevoluteVelocityConstraint {
diff --git a/src/lib.rs b/src/lib.rs
index b3ca3d4..564a758 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -148,10 +148,4 @@ pub mod math {
/// single contact constraint.
#[cfg(feature = "dim3")]
pub const MAX_MANIFOLD_POINTS: usize = 4;
-
- #[cfg(feature = "dim2")]
- pub const SPATIAL_DIM: usize = 3;
-
- #[cfg(feature = "dim3")]
- pub const SPATIAL_DIM: usize = 6;
}