diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-02-27 22:04:51 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | 2e6f133b95b614f13445722e54f28105d9664841 (patch) | |
| tree | 364ce4cb1b73614fca0bd8f443385c73e7a64026 /src/dynamics/solver/generic_velocity_constraint.rs | |
| parent | 28cc19d104d986db54d8725e68189070bef31a8a (diff) | |
| download | rapier-2e6f133b95b614f13445722e54f28105d9664841.tar.gz rapier-2e6f133b95b614f13445722e54f28105d9664841.tar.bz2 rapier-2e6f133b95b614f13445722e54f28105d9664841.zip | |
Second round to fix the parallel solver.
Diffstat (limited to 'src/dynamics/solver/generic_velocity_constraint.rs')
| -rw-r--r-- | src/dynamics/solver/generic_velocity_constraint.rs | 63 |
1 files changed, 6 insertions, 57 deletions
diff --git a/src/dynamics/solver/generic_velocity_constraint.rs b/src/dynamics/solver/generic_velocity_constraint.rs index a304008..99dc40e 100644 --- a/src/dynamics/solver/generic_velocity_constraint.rs +++ b/src/dynamics/solver/generic_velocity_constraint.rs @@ -8,65 +8,14 @@ use crate::geometry::{ContactManifold, ContactManifoldIndex}; use crate::math::{Real, DIM, MAX_MANIFOLD_POINTS}; use crate::utils::{WAngularInertia, WCross, WDot}; -use super::{DeltaVel, VelocityConstraintElement, VelocityConstraintNormalPart}; -use crate::dynamics::solver::GenericVelocityGroundConstraint; +use super::{ + AnyVelocityConstraint, DeltaVel, VelocityConstraintElement, VelocityConstraintNormalPart, +}; #[cfg(feature = "dim2")] use crate::utils::WBasis; use na::DVector; #[derive(Copy, Clone, Debug)] -pub(crate) enum AnyGenericVelocityConstraint { - NongroupedGround(GenericVelocityGroundConstraint), - Nongrouped(GenericVelocityConstraint), -} - -impl AnyGenericVelocityConstraint { - pub fn solve( - &mut self, - cfm_factor: Real, - jacobians: &DVector<Real>, - mj_lambdas: &mut [DeltaVel<Real>], - generic_mj_lambdas: &mut DVector<Real>, - solve_restitution: bool, - solve_friction: bool, - ) { - match self { - AnyGenericVelocityConstraint::Nongrouped(c) => c.solve( - cfm_factor, - jacobians, - mj_lambdas, - generic_mj_lambdas, - solve_restitution, - solve_friction, - ), - AnyGenericVelocityConstraint::NongroupedGround(c) => c.solve( - cfm_factor, - jacobians, - generic_mj_lambdas, - solve_restitution, - solve_friction, - ), - } - } - - pub fn writeback_impulses(&self, manifolds_all: &mut [&mut ContactManifold]) { - match self { - AnyGenericVelocityConstraint::Nongrouped(c) => c.writeback_impulses(manifolds_all), - AnyGenericVelocityConstraint::NongroupedGround(c) => { - c.writeback_impulses(manifolds_all) - } - } - } - - pub fn remove_bias_from_rhs(&mut self) { - match self { - AnyGenericVelocityConstraint::Nongrouped(c) => c.remove_bias_from_rhs(), - AnyGenericVelocityConstraint::NongroupedGround(c) => c.remove_bias_from_rhs(), - } - } -} - -#[derive(Copy, Clone, Debug)] pub(crate) struct GenericVelocityConstraint { // We just build the generic constraint on top of the velocity constraint, // adding some information we can use in the generic case. @@ -84,7 +33,7 @@ impl GenericVelocityConstraint { manifold: &ContactManifold, bodies: &Bodies, multibodies: &MultibodyJointSet, - out_constraints: &mut Vec<AnyGenericVelocityConstraint>, + out_constraints: &mut Vec<AnyVelocityConstraint>, jacobians: &mut DVector<Real>, jacobian_id: &mut usize, push: bool, @@ -372,10 +321,10 @@ impl GenericVelocityConstraint { }; if push { - out_constraints.push(AnyGenericVelocityConstraint::Nongrouped(constraint)); + out_constraints.push(AnyVelocityConstraint::NongroupedGeneric(constraint)); } else { out_constraints[manifold.data.constraint_index + _l] = - AnyGenericVelocityConstraint::Nongrouped(constraint); + AnyVelocityConstraint::NongroupedGeneric(constraint); } } } |
