Remove code related to point-point kinematics.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use super::AnyPositionConstraint;
|
||||
use crate::dynamics::{IntegrationParameters, RigidBodySet};
|
||||
use crate::geometry::{ContactManifold, KinematicsCategory};
|
||||
use crate::geometry::ContactManifold;
|
||||
use crate::math::{
|
||||
AngularInertia, Isometry, Point, Rotation, SimdReal, Translation, Vector, MAX_MANIFOLD_POINTS,
|
||||
SIMD_WIDTH,
|
||||
@@ -86,82 +86,15 @@ impl WPositionConstraint {
|
||||
}
|
||||
|
||||
if push {
|
||||
if manifolds[0].kinematics.category == KinematicsCategory::PointPoint {
|
||||
out_constraints.push(AnyPositionConstraint::GroupedPointPoint(constraint));
|
||||
} else {
|
||||
out_constraints.push(AnyPositionConstraint::GroupedPlanePoint(constraint));
|
||||
}
|
||||
out_constraints.push(AnyPositionConstraint::GroupedNonGround(constraint));
|
||||
} else {
|
||||
if manifolds[0].kinematics.category == KinematicsCategory::PointPoint {
|
||||
out_constraints[manifolds[0].data.constraint_index + l / MAX_MANIFOLD_POINTS] =
|
||||
AnyPositionConstraint::GroupedPointPoint(constraint);
|
||||
} else {
|
||||
out_constraints[manifolds[0].data.constraint_index + l / MAX_MANIFOLD_POINTS] =
|
||||
AnyPositionConstraint::GroupedPlanePoint(constraint);
|
||||
}
|
||||
out_constraints[manifolds[0].data.constraint_index + l / MAX_MANIFOLD_POINTS] =
|
||||
AnyPositionConstraint::GroupedNonGround(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn solve_point_point(
|
||||
&self,
|
||||
params: &IntegrationParameters,
|
||||
positions: &mut [Isometry<f32>],
|
||||
) {
|
||||
// FIXME: can we avoid most of the multiplications by pos1/pos2?
|
||||
// Compute jacobians.
|
||||
let mut pos1 = Isometry::from(array![|ii| positions[self.rb1[ii]]; SIMD_WIDTH]);
|
||||
let mut pos2 = Isometry::from(array![|ii| positions[self.rb2[ii]]; SIMD_WIDTH]);
|
||||
let allowed_err = SimdReal::splat(params.allowed_linear_error);
|
||||
|
||||
for k in 0..self.num_contacts as usize {
|
||||
let target_dist = -self.dists[k] - allowed_err;
|
||||
let p1 = pos1 * self.local_p1[k];
|
||||
let p2 = pos2 * self.local_p2[k];
|
||||
|
||||
let dpos = p2 - p1;
|
||||
let sqdist = dpos.norm_squared();
|
||||
|
||||
if sqdist.simd_lt(target_dist * target_dist).any() {
|
||||
let dist = sqdist.simd_sqrt();
|
||||
let n = dpos / dist;
|
||||
let err = ((dist - target_dist) * self.erp)
|
||||
.simd_clamp(-self.max_linear_correction, SimdReal::zero());
|
||||
let dp1 = p1.coords - pos1.translation.vector;
|
||||
let dp2 = p2.coords - pos2.translation.vector;
|
||||
|
||||
let gcross1 = dp1.gcross(n);
|
||||
let gcross2 = -dp2.gcross(n);
|
||||
let ii_gcross1 = self.ii1.transform_vector(gcross1);
|
||||
let ii_gcross2 = self.ii2.transform_vector(gcross2);
|
||||
|
||||
// Compute impulse.
|
||||
let inv_r =
|
||||
self.im1 + self.im2 + gcross1.gdot(ii_gcross1) + gcross2.gdot(ii_gcross2);
|
||||
let impulse = err / inv_r;
|
||||
|
||||
// Apply impulse.
|
||||
pos1.translation = Translation::from(n * (impulse * self.im1)) * pos1.translation;
|
||||
pos1.rotation = Rotation::new(ii_gcross1 * impulse) * pos1.rotation;
|
||||
pos2.translation = Translation::from(n * (-impulse * self.im2)) * pos2.translation;
|
||||
pos2.rotation = Rotation::new(ii_gcross2 * impulse) * pos2.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
for ii in 0..SIMD_WIDTH {
|
||||
positions[self.rb1[ii]] = pos1.extract(ii);
|
||||
}
|
||||
|
||||
for ii in 0..SIMD_WIDTH {
|
||||
positions[self.rb2[ii]] = pos2.extract(ii);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn solve_plane_point(
|
||||
&self,
|
||||
params: &IntegrationParameters,
|
||||
positions: &mut [Isometry<f32>],
|
||||
) {
|
||||
pub fn solve(&self, params: &IntegrationParameters, positions: &mut [Isometry<f32>]) {
|
||||
// FIXME: can we avoid most of the multiplications by pos1/pos2?
|
||||
// Compute jacobians.
|
||||
let mut pos1 = Isometry::from(array![|ii| positions[self.rb1[ii]]; SIMD_WIDTH]);
|
||||
|
||||
Reference in New Issue
Block a user