diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-06-01 17:59:07 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-06-01 17:59:07 +0200 |
| commit | 7153eb7779a29853289df90f28efaac738620386 (patch) | |
| tree | 561a81b65609b60c4429c134ea474a160d70d80e /src/dynamics | |
| parent | 1839f61d816af37c95889caf592b5a7cf8d89412 (diff) | |
| download | rapier-7153eb7779a29853289df90f28efaac738620386.tar.gz rapier-7153eb7779a29853289df90f28efaac738620386.tar.bz2 rapier-7153eb7779a29853289df90f28efaac738620386.zip | |
Add ActiveCollisionTypes to easily enable collision-detection between two non-static rigid-body.
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/ccd/ccd_solver.rs | 18 | ||||
| -rw-r--r-- | src/dynamics/ccd/toi_entry.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/rigid_body_components.rs | 8 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/dynamics/ccd/ccd_solver.rs b/src/dynamics/ccd/ccd_solver.rs index dab4f73..7e95f08 100644 --- a/src/dynamics/ccd/ccd_solver.rs +++ b/src/dynamics/ccd/ccd_solver.rs @@ -10,7 +10,7 @@ use crate::geometry::{ use crate::math::Real; use crate::parry::utils::SortedPair; use crate::pipeline::{EventHandler, QueryPipeline, QueryPipelineMode}; -use crate::prelude::{ActiveEvents, ColliderFlags, ColliderGroups}; +use crate::prelude::{ActiveEvents, ColliderFlags}; use parry::query::{DefaultQueryDispatcher, QueryDispatcher}; use parry::utils::hashmap::HashMap; use std::collections::BinaryHeap; @@ -141,7 +141,7 @@ impl CCDSolver { + ComponentSet<ColliderPosition> + ComponentSet<ColliderShape> + ComponentSet<ColliderType> - + ComponentSet<ColliderGroups>, + + ComponentSet<ColliderFlags>, { // Update the query pipeline. self.query_pipeline.update_with_mode( @@ -202,8 +202,8 @@ impl CCDSolver { { let co_parent1: Option<&ColliderParent> = colliders.get(ch1.0); let co_parent2: Option<&ColliderParent> = colliders.get(ch2.0); - let c1: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch1.0); - let c2: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch2.0); + let c1: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch1.0); + let c2: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch2.0); let co_type1: &ColliderType = colliders.index(ch1.0); let co_type2: &ColliderType = colliders.index(ch1.0); @@ -281,7 +281,7 @@ impl CCDSolver { + ComponentSet<ColliderShape> + ComponentSet<ColliderType> + ComponentSet<ColliderFlags> - + ComponentSet<ColliderGroups>, + + ComponentSet<ColliderFlags>, { let mut frozen = HashMap::<_, Real>::default(); let mut all_toi = BinaryHeap::new(); @@ -343,8 +343,8 @@ impl CCDSolver { { let co_parent1: Option<&ColliderParent> = colliders.get(ch1.0); let co_parent2: Option<&ColliderParent> = colliders.get(ch2.0); - let c1: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch1.0); - let c2: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch2.0); + let c1: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch1.0); + let c2: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch2.0); let bh1 = co_parent1.map(|p| p.handle); let bh2 = co_parent2.map(|p| p.handle); @@ -470,8 +470,8 @@ impl CCDSolver { .colliders_with_aabb_intersecting_aabb(&aabb, |ch2| { let co_parent1: Option<&ColliderParent> = colliders.get(ch1.0); let co_parent2: Option<&ColliderParent> = colliders.get(ch2.0); - let c1: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch1.0); - let c2: (_, _, _, &ColliderGroups) = colliders.index_bundle(ch2.0); + let c1: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch1.0); + let c2: (_, _, _, &ColliderFlags) = colliders.index_bundle(ch2.0); let bh1 = co_parent1.map(|p| p.handle); let bh2 = co_parent2.map(|p| p.handle); diff --git a/src/dynamics/ccd/toi_entry.rs b/src/dynamics/ccd/toi_entry.rs index 918e7c4..f937979 100644 --- a/src/dynamics/ccd/toi_entry.rs +++ b/src/dynamics/ccd/toi_entry.rs @@ -2,7 +2,7 @@ use crate::dynamics::{ RigidBodyCcd, RigidBodyHandle, RigidBodyMassProps, RigidBodyPosition, RigidBodyVelocity, }; use crate::geometry::{ - ColliderGroups, ColliderHandle, ColliderParent, ColliderPosition, ColliderShape, ColliderType, + ColliderFlags, ColliderHandle, ColliderParent, ColliderPosition, ColliderShape, ColliderType, }; use crate::math::Real; use parry::query::{NonlinearRigidMotion, QueryDispatcher}; @@ -49,14 +49,14 @@ impl TOIEntry { &ColliderType, &ColliderShape, &ColliderPosition, - &ColliderGroups, + &ColliderFlags, Option<&ColliderParent>, ), c2: ( &ColliderType, &ColliderShape, &ColliderPosition, - &ColliderGroups, + &ColliderFlags, Option<&ColliderParent>, ), b1: Option<( @@ -82,8 +82,8 @@ impl TOIEntry { return None; } - let (co_type1, co_shape1, co_pos1, co_groups1, co_parent1) = c1; - let (co_type2, co_shape2, co_pos2, co_groups2, co_parent2) = c2; + let (co_type1, co_shape1, co_pos1, co_flags1, co_parent1) = c1; + let (co_type2, co_shape2, co_pos2, co_flags2, co_parent2) = c2; let linvel1 = frozen1.is_none() as u32 as Real * b1.map(|b| b.1.linvel).unwrap_or(na::zero()); @@ -110,7 +110,7 @@ impl TOIEntry { + smallest_contact_dist.max(0.0); let is_pseudo_intersection_test = co_type1.is_sensor() || co_type2.is_sensor() - || !co_groups1.solver_groups.test(co_groups2.solver_groups); + || !co_flags1.solver_groups.test(co_flags2.solver_groups); if (end_time - start_time) * vel12 < thickness { return None; diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs index d1a00ce..ec67b66 100644 --- a/src/dynamics/rigid_body_components.rs +++ b/src/dynamics/rigid_body_components.rs @@ -54,23 +54,23 @@ pub type BodyStatus = RigidBodyType; /// The status of a body, governing the way it is affected by external forces. pub enum RigidBodyType { /// A `RigidBodyType::Dynamic` body can be affected by all external forces. - Dynamic, + Dynamic = 0, /// A `RigidBodyType::Static` body cannot be affected by external forces. - Static, + Static = 1, /// A `RigidBodyType::KinematicPositionBased` body cannot be affected by any external forces but can be controlled /// by the user at the position level while keeping realistic one-way interaction with dynamic bodies. /// /// One-way interaction means that a kinematic body can push a dynamic body, but a kinematic body /// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be /// modified by the user and is independent from any contact or joint it is involved in. - KinematicPositionBased, + KinematicPositionBased = 2, /// A `RigidBodyType::KinematicVelocityBased` body cannot be affected by any external forces but can be controlled /// by the user at the velocity level while keeping realistic one-way interaction with dynamic bodies. /// /// One-way interaction means that a kinematic body can push a dynamic body, but a kinematic body /// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be /// modified by the user and is independent from any contact or joint it is involved in. - KinematicVelocityBased, + KinematicVelocityBased = 3, // Semikinematic, // A kinematic that performs automatic CCD with the static environment to avoid traversing it? // Disabled, } |
