diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
| commit | 754a48b7ff6d8c58b1ee08651e60112900b60455 (patch) | |
| tree | 7d777a6c003f1f5d8f8d24f533f35a95a88957fe /src/dynamics/solver/categorization.rs | |
| download | rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.gz rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.bz2 rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.zip | |
First public release of Rapier.v0.1.0
Diffstat (limited to 'src/dynamics/solver/categorization.rs')
| -rw-r--r-- | src/dynamics/solver/categorization.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/dynamics/solver/categorization.rs b/src/dynamics/solver/categorization.rs new file mode 100644 index 0000000..9ddf791 --- /dev/null +++ b/src/dynamics/solver/categorization.rs @@ -0,0 +1,70 @@ +use crate::dynamics::{JointGraphEdge, JointIndex, RigidBodySet}; +use crate::geometry::{ContactManifold, ContactManifoldIndex, KinematicsCategory}; + +pub(crate) fn categorize_position_contacts( + bodies: &RigidBodySet, + manifolds: &[&mut ContactManifold], + manifold_indices: &[ContactManifoldIndex], + out_point_point_ground: &mut Vec<ContactManifoldIndex>, + out_plane_point_ground: &mut Vec<ContactManifoldIndex>, + out_point_point: &mut Vec<ContactManifoldIndex>, + out_plane_point: &mut Vec<ContactManifoldIndex>, +) { + for manifold_i in manifold_indices { + let manifold = &manifolds[*manifold_i]; + let rb1 = &bodies[manifold.body_pair.body1]; + let rb2 = &bodies[manifold.body_pair.body2]; + + if !rb1.is_dynamic() || !rb2.is_dynamic() { + match manifold.kinematics.category { + KinematicsCategory::PointPoint => out_point_point_ground.push(*manifold_i), + KinematicsCategory::PlanePoint => out_plane_point_ground.push(*manifold_i), + } + } else { + match manifold.kinematics.category { + KinematicsCategory::PointPoint => out_point_point.push(*manifold_i), + KinematicsCategory::PlanePoint => out_plane_point.push(*manifold_i), + } + } + } +} + +pub(crate) fn categorize_velocity_contacts( + bodies: &RigidBodySet, + manifolds: &[&mut ContactManifold], + manifold_indices: &[ContactManifoldIndex], + out_ground: &mut Vec<ContactManifoldIndex>, + out_not_ground: &mut Vec<ContactManifoldIndex>, +) { + for manifold_i in manifold_indices { + let manifold = &manifolds[*manifold_i]; + let rb1 = &bodies[manifold.body_pair.body1]; + let rb2 = &bodies[manifold.body_pair.body2]; + + if !rb1.is_dynamic() || !rb2.is_dynamic() { + out_ground.push(*manifold_i) + } else { + out_not_ground.push(*manifold_i) + } + } +} + +pub(crate) fn categorize_joints( + bodies: &RigidBodySet, + joints: &[JointGraphEdge], + joint_indices: &[JointIndex], + ground_joints: &mut Vec<JointIndex>, + nonground_joints: &mut Vec<JointIndex>, +) { + for joint_i in joint_indices { + let joint = &joints[*joint_i].weight; + let rb1 = &bodies[joint.body1]; + let rb2 = &bodies[joint.body2]; + + if !rb1.is_dynamic() || !rb2.is_dynamic() { + ground_joints.push(*joint_i); + } else { + nonground_joints.push(*joint_i); + } + } +} |
