diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-12-30 17:30:07 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-12-30 17:30:07 +0100 |
| commit | 43628c8846c8805d2f835dda4182b7240292900c (patch) | |
| tree | c57e262485f9d582861e227182319b7b67125fdf /src/dynamics/solver/position_ground_constraint_wide.rs | |
| parent | 7545e06cb15d6e851e5dee7d3761901e5d40f271 (diff) | |
| download | rapier-43628c8846c8805d2f835dda4182b7240292900c.tar.gz rapier-43628c8846c8805d2f835dda4182b7240292900c.tar.bz2 rapier-43628c8846c8805d2f835dda4182b7240292900c.zip | |
Try using solver contacts again, but in a more cache-coherent way.
Diffstat (limited to 'src/dynamics/solver/position_ground_constraint_wide.rs')
| -rw-r--r-- | src/dynamics/solver/position_ground_constraint_wide.rs | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/dynamics/solver/position_ground_constraint_wide.rs b/src/dynamics/solver/position_ground_constraint_wide.rs index 2531b2e..40d5a68 100644 --- a/src/dynamics/solver/position_ground_constraint_wide.rs +++ b/src/dynamics/solver/position_ground_constraint_wide.rs @@ -15,8 +15,8 @@ pub(crate) struct WPositionGroundConstraint { // NOTE: the points are relative to the center of masses. pub p1: [Point<SimdReal>; MAX_MANIFOLD_POINTS], pub local_p2: [Point<SimdReal>; MAX_MANIFOLD_POINTS], + pub dists: [SimdReal; MAX_MANIFOLD_POINTS], pub n1: Vector<SimdReal>, - pub radius: SimdReal, pub im2: SimdReal, pub ii2: AngularInertia<SimdReal>, pub erp: SimdReal, @@ -49,34 +49,17 @@ impl WPositionGroundConstraint { let sqrt_ii2: AngularInertia<SimdReal> = AngularInertia::from(array![|ii| rbs2[ii].world_inv_inertia_sqrt; SIMD_WIDTH]); - let local_n1 = Vector::from( - array![|ii| if flipped[ii] { manifolds[ii].local_n2 } else { manifolds[ii].local_n1 }; SIMD_WIDTH], - ); - let local_n2 = Vector::from( - array![|ii| if flipped[ii] { manifolds[ii].local_n1 } else { manifolds[ii].local_n2 }; SIMD_WIDTH], - ); - - let delta1 = Isometry::from( - array![|ii| if flipped[ii] { manifolds[ii].data.delta2 } else { manifolds[ii].data.delta1 }; SIMD_WIDTH], - ); - let delta2 = Isometry::from( - array![|ii| if flipped[ii] { manifolds[ii].data.delta1 } else { manifolds[ii].data.delta2 }; SIMD_WIDTH], + let n1 = Vector::from( + array![|ii| if flipped[ii] { -manifolds[ii].data.normal } else { manifolds[ii].data.normal }; SIMD_WIDTH], ); - let radius1 = SimdReal::from(array![|ii| manifolds[ii].kinematics.radius1; SIMD_WIDTH]); - let radius2 = SimdReal::from(array![|ii| manifolds[ii].kinematics.radius2; SIMD_WIDTH]); - - let coll_pos1 = - delta1 * Isometry::from(array![|ii| rbs1[ii].predicted_position; SIMD_WIDTH]); - + let pos2 = Isometry::from(array![|ii| rbs2[ii].position; SIMD_WIDTH]); let rb2 = array![|ii| rbs2[ii].active_set_offset; SIMD_WIDTH]; - let radius = radius1 + radius2 /*- SimdReal::splat(params.allowed_linear_error)*/; - - let n1 = coll_pos1 * local_n1; + let num_active_contacts = manifolds[0].num_active_contacts(); - for l in (0..manifolds[0].num_active_contacts()).step_by(MAX_MANIFOLD_POINTS) { - let manifold_points = array![|ii| &manifolds[ii].active_contacts()[l..]; SIMD_WIDTH]; + for l in (0..num_active_contacts).step_by(MAX_MANIFOLD_POINTS) { + let manifold_points = array![|ii| &manifolds[ii].data.solver_contacts[l..num_active_contacts]; SIMD_WIDTH]; let num_points = manifold_points[0].len().min(MAX_MANIFOLD_POINTS); let mut constraint = WPositionGroundConstraint { @@ -84,7 +67,7 @@ impl WPositionGroundConstraint { p1: [Point::origin(); MAX_MANIFOLD_POINTS], local_p2: [Point::origin(); MAX_MANIFOLD_POINTS], n1, - radius, + dists: [SimdReal::zero(); MAX_MANIFOLD_POINTS], im2, ii2: sqrt_ii2.squared(), erp: SimdReal::splat(params.erp), @@ -93,15 +76,11 @@ impl WPositionGroundConstraint { }; for i in 0..num_points { - let local_p1 = Point::from( - array![|ii| if flipped[ii] { manifold_points[ii][i].local_p2 } else { manifold_points[ii][i].local_p1 }; SIMD_WIDTH], - ); - let local_p2 = Point::from( - array![|ii| if flipped[ii] { manifold_points[ii][i].local_p1 } else { manifold_points[ii][i].local_p2 }; SIMD_WIDTH], - ); - - constraint.p1[i] = coll_pos1 * local_p1 - n1 * radius1; - constraint.local_p2[i] = delta2 * (local_p2 - local_n2 * radius2); + let point = Point::from(array![|ii| manifold_points[ii][i].point; SIMD_WIDTH]); + let dist = SimdReal::from(array![|ii| manifold_points[ii][i].dist; SIMD_WIDTH]); + constraint.p1[i] = point; + constraint.local_p2[i] = pos2.inverse_transform_point(&point); + constraint.dists[i] = dist; } if push { @@ -132,9 +111,9 @@ impl WPositionGroundConstraint { // Compute jacobians. let mut pos2 = Isometry::from(array![|ii| positions[self.rb2[ii]]; SIMD_WIDTH]); let allowed_err = SimdReal::splat(params.allowed_linear_error); - let target_dist = self.radius - allowed_err; for k in 0..self.num_contacts as usize { + let target_dist = -self.dists[k] - allowed_err; let p1 = self.p1[k]; let p2 = pos2 * self.local_p2[k]; @@ -174,9 +153,9 @@ impl WPositionGroundConstraint { // Compute jacobians. let mut pos2 = Isometry::from(array![|ii| positions[self.rb2[ii]]; SIMD_WIDTH]); let allowed_err = SimdReal::splat(params.allowed_linear_error); - let target_dist = self.radius - allowed_err; for k in 0..self.num_contacts as usize { + let target_dist = -self.dists[k] - allowed_err; let n1 = self.n1; let p1 = self.p1[k]; let p2 = pos2 * self.local_p2[k]; |
