diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-03-19 16:23:09 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | a9e3441ecd64d50b478ab5370fabe187ec9a5c39 (patch) | |
| tree | 92b2e4ee3d3599a446f15551cc74e8e71b9c6150 /src | |
| parent | db6a8c526d939a125485c89cfb6e540422fe6b4b (diff) | |
| download | rapier-a9e3441ecd64d50b478ab5370fabe187ec9a5c39.tar.gz rapier-a9e3441ecd64d50b478ab5370fabe187ec9a5c39.tar.bz2 rapier-a9e3441ecd64d50b478ab5370fabe187ec9a5c39.zip | |
Rename rigid-body `static` to `fixed`
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynamics/ccd/ccd_solver.rs | 2 | ||||
| -rw-r--r-- | src/dynamics/island_manager.rs | 2 | ||||
| -rw-r--r-- | src/dynamics/rigid_body.rs | 50 | ||||
| -rw-r--r-- | src/dynamics/rigid_body_components.rs | 12 | ||||
| -rw-r--r-- | src/dynamics/solver/interaction_groups.rs | 42 | ||||
| -rw-r--r-- | src/geometry/broad_phase_multi_sap/broad_phase.rs | 4 | ||||
| -rw-r--r-- | src/geometry/collider_components.rs | 8 | ||||
| -rw-r--r-- | src/geometry/narrow_phase.rs | 14 | ||||
| -rw-r--r-- | src/pipeline/physics_pipeline.rs | 20 | ||||
| -rw-r--r-- | src/pipeline/user_changes.rs | 2 |
10 files changed, 86 insertions, 70 deletions
diff --git a/src/dynamics/ccd/ccd_solver.rs b/src/dynamics/ccd/ccd_solver.rs index b3a1608..d15b28c 100644 --- a/src/dynamics/ccd/ccd_solver.rs +++ b/src/dynamics/ccd/ccd_solver.rs @@ -412,7 +412,7 @@ impl CCDSolver { return PredictedImpacts::ImpactsAfterEndTime(min_overstep); } - // NOTE: all static bodies (and kinematic bodies?) should be considered as "frozen", this + // NOTE: all fixed bodies (and kinematic bodies?) should be considered as "frozen", this // may avoid some resweeps. let mut pseudo_intersections_to_check = vec![]; diff --git a/src/dynamics/island_manager.rs b/src/dynamics/island_manager.rs index 7cf16d6..06f3820 100644 --- a/src/dynamics/island_manager.rs +++ b/src/dynamics/island_manager.rs @@ -259,7 +259,7 @@ impl IslandManager { if rb_ids.active_set_timestamp == self.active_set_timestamp || !rb_status.is_dynamic() { // We already visited this body and its neighbors. - // Also, we don't propagate awake state through static bodies. + // Also, we don't propagate awake state through fixed bodies. continue; } diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 1bfdf48..695b256 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -112,7 +112,7 @@ impl RigidBody { self.changes.insert(RigidBodyChanges::TYPE); self.rb_type = status; - if status == RigidBodyType::Static { + if status == RigidBodyType::Fixed { self.rb_vels = RigidBodyVelocity::zero(); } } @@ -372,11 +372,11 @@ impl RigidBody { self.rb_type.is_kinematic() } - /// Is this rigid body static? + /// Is this rigid body fixed? /// - /// A static body cannot move and is not affected by forces. - pub fn is_static(&self) -> bool { - self.rb_type == RigidBodyType::Static + /// A fixed body cannot move and is not affected by forces. + pub fn is_fixed(&self) -> bool { + self.rb_type == RigidBodyType::Fixed } /// The mass of this rigid body. @@ -487,7 +487,7 @@ impl RigidBody { /// Is this rigid body sleeping? pub fn is_sleeping(&self) -> bool { // TODO: should we: - // - return false for static bodies. + // - return false for fixed bodies. // - return true for non-sleeping dynamic bodies. // - return true only for kinematic bodies with non-zero velocity? self.rb_activation.sleeping @@ -531,7 +531,7 @@ impl RigidBody { RigidBodyType::KinematicVelocityBased => { self.rb_vels.linvel = linvel; } - RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {} + RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {} } } } @@ -553,7 +553,7 @@ impl RigidBody { RigidBodyType::KinematicVelocityBased => { self.rb_vels.angvel = angvel; } - RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {} + RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {} } } } @@ -575,7 +575,7 @@ impl RigidBody { RigidBodyType::KinematicVelocityBased => { self.rb_vels.angvel = angvel; } - RigidBodyType::Static | RigidBodyType::KinematicPositionBased => {} + RigidBodyType::Fixed | RigidBodyType::KinematicPositionBased => {} } } } @@ -905,7 +905,7 @@ pub struct RigidBodyBuilder { } impl RigidBodyBuilder { - /// Initialize a new builder for a rigid body which is either static, dynamic, or kinematic. + /// Initialize a new builder for a rigid body which is either fixed, dynamic, or kinematic. pub fn new(rb_type: RigidBodyType) -> Self { Self { position: Isometry::identity(), @@ -925,23 +925,39 @@ impl RigidBodyBuilder { } } - /// Initializes the builder of a new static rigid body. + /// Initializes the builder of a new fixed rigid body. + #[deprecated(note = "use `RigidBodyBuilder::fixed()` instead")] pub fn new_static() -> Self { - Self::new(RigidBodyType::Static) + Self::fixed() } - - /// Initializes the builder of a new kinematic rigid body. + /// Initializes the builder of a new velocity-based kinematic rigid body. + #[deprecated(note = "use `RigidBodyBuilder::kinematic_velocity_based()` instead")] pub fn new_kinematic_velocity_based() -> Self { + Self::kinematic_velocity_based() + } + /// Initializes the builder of a new position-based kinematic rigid body. + #[deprecated(note = "use `RigidBodyBuilder::kinematic_position_based()` instead")] + pub fn new_kinematic_position_based() -> Self { + Self::kinematic_position_based() + } + + /// Initializes the builder of a new fixed rigid body. + pub fn fixed() -> Self { + Self::new(RigidBodyType::Fixed) + } + + /// Initializes the builder of a new velocity-based kinematic rigid body. + pub fn kinematic_velocity_based() -> Self { Self::new(RigidBodyType::KinematicVelocityBased) } - /// Initializes the builder of a new kinematic rigid body. - pub fn new_kinematic_position_based() -> Self { + /// Initializes the builder of a new position-based kinematic rigid body. + pub fn kinematic_position_based() -> Self { Self::new(RigidBodyType::KinematicPositionBased) } /// Initializes the builder of a new dynamic rigid body. - pub fn new_dynamic() -> Self { + pub fn dynamic() -> Self { Self::new(RigidBodyType::Dynamic) } diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs index 52072ea..cac0600 100644 --- a/src/dynamics/rigid_body_components.rs +++ b/src/dynamics/rigid_body_components.rs @@ -57,8 +57,8 @@ pub type BodyStatus = RigidBodyType; pub enum RigidBodyType { /// A `RigidBodyType::Dynamic` body can be affected by all external forces. Dynamic = 0, - /// A `RigidBodyType::Static` body cannot be affected by external forces. - Static = 1, + /// A `RigidBodyType::Fixed` body cannot be affected by external forces. + Fixed = 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. /// @@ -73,14 +73,14 @@ pub enum RigidBodyType { /// 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 = 3, - // Semikinematic, // A kinematic that performs automatic CCD with the static environment to avoid traversing it? + // Semikinematic, // A kinematic that performs automatic CCD with the fixed environment to avoid traversing it? // Disabled, } impl RigidBodyType { - /// Is this rigid-body static (i.e. cannot move)? - pub fn is_static(self) -> bool { - self == RigidBodyType::Static + /// Is this rigid-body fixed (i.e. cannot move)? + pub fn is_fixed(self) -> bool { + self == RigidBodyType::Fixed } /// Is this rigid-body dynamic (i.e. can move and be affected by forces)? diff --git a/src/dynamics/solver/interaction_groups.rs b/src/dynamics/solver/interaction_groups.rs index 451f930..d806251 100644 --- a/src/dynamics/solver/interaction_groups.rs +++ b/src/dynamics/solver/interaction_groups.rs @@ -93,20 +93,20 @@ impl ParallelInteractionGroups { .zip(self.interaction_colors.iter_mut()) { let mut body_pair = interactions[*interaction_id].body_pair(); - let is_static1 = body_pair + let is_fixed1 = body_pair .0 - .map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_static()) + .map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_fixed()) .unwrap_or(true); - let is_static2 = body_pair + let is_fixed2 = body_pair .1 - .map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_static()) + .map(|b| ComponentSet::<RigidBodyType>::index(bodies, b.0).is_fixed()) .unwrap_or(true); let representative = |handle: RigidBodyHandle| { if let Some(link) = multibodies.rigid_body_link(handle).copied() { let multibody = multibodies.get_multibody(link.multibody).unwrap(); multibody - .link(1) // Use the link 1 to cover the case where the multibody root is static. + .link(1) // Use the link 1 to cover the case where the multibody root is fixed. .or(multibody.link(0)) // TODO: Never happens? .map(|l| l.rigid_body) .unwrap() @@ -120,7 +120,7 @@ impl ParallelInteractionGroups { body_pair.1.map(representative), ); - match (is_static1, is_static2) { + match (is_fixed1, is_fixed2) { (false, false) => { let rb_ids1: &RigidBodyIds = bodies.index(body_pair.0.unwrap().0); let rb_ids2: &RigidBodyIds = bodies.index(body_pair.1.unwrap().0); @@ -268,10 +268,10 @@ impl InteractionGroups { let (status2, ids2): (&RigidBodyType, &RigidBodyIds) = bodies.index_bundle(interaction.body2.0); - let is_static1 = !status1.is_dynamic(); - let is_static2 = !status2.is_dynamic(); + let is_fixed1 = !status1.is_dynamic(); + let is_fixed2 = !status2.is_dynamic(); - if is_static1 && is_static2 { + if is_fixed1 && is_fixed2 { continue; } @@ -334,13 +334,13 @@ impl InteractionGroups { } } - // NOTE: static bodies don't transmit forces. Therefore they don't + // NOTE: fixed bodies don't transmit forces. Therefore they don't // imply any interaction conflicts. - if !is_static1 { + if !is_fixed1 { self.body_masks[i1] |= target_mask_bit; } - if !is_static2 { + if !is_fixed2 { self.body_masks[i2] |= target_mask_bit; } } @@ -431,21 +431,21 @@ impl InteractionGroups { let data: (_, &RigidBodyIds) = bodies.index_bundle(rb1.0); (*data.0, data.1.active_set_offset) } else { - (RigidBodyType::Static, 0) + (RigidBodyType::Fixed, 0) }; let (status2, active_set_offset2) = if let Some(rb2) = interaction.data.rigid_body2 { let data: (_, &RigidBodyIds) = bodies.index_bundle(rb2.0); (*data.0, data.1.active_set_offset) } else { - (RigidBodyType::Static, 0) + (RigidBodyType::Fixed, 0) }; - let is_static1 = !status1.is_dynamic(); - let is_static2 = !status2.is_dynamic(); + let is_fixed1 = !status1.is_dynamic(); + let is_fixed2 = !status2.is_dynamic(); - // TODO: don't generate interactions between static bodies in the first place. - if is_static1 && is_static2 { + // TODO: don't generate interactions between fixed bodies in the first place. + if is_fixed1 && is_fixed2 { continue; } @@ -489,13 +489,13 @@ impl InteractionGroups { occupied_mask = occupied_mask | target_mask_bit; } - // NOTE: static bodies don't transmit forces. Therefore they don't + // NOTE: fixed bodies don't transmit forces. Therefore they don't // imply any interaction conflicts. - if !is_static1 { + if !is_fixed1 { self.body_masks[i1] |= target_mask_bit; } - if !is_static2 { + if !is_fixed2 { self.body_masks[i2] |= target_mask_bit; } } diff --git a/src/geometry/broad_phase_multi_sap/broad_phase.rs b/src/geometry/broad_phase_multi_sap/broad_phase.rs index d2b0076..0149adf 100644 --- a/src/geometry/broad_phase_multi_sap/broad_phase.rs +++ b/src/geometry/broad_phase_multi_sap/broad_phase.rs @@ -634,7 +634,7 @@ mod test { let mut multibody_joints = MultibodyJointSet::new(); let mut islands = IslandManager::new(); - let rb = RigidBodyBuilder::new_dynamic().build(); + let rb = RigidBodyBuilder::dynamic().build(); let co = ColliderBuilder::ball(0.5).build(); let hrb = bodies.insert(rb); let coh = colliders.insert_with_parent(co, hrb, &mut bodies); @@ -652,7 +652,7 @@ mod test { broad_phase.update(0.0, &mut colliders, &[], &[coh], &mut events); // Create another body. - let rb = RigidBodyBuilder::new_dynamic().build(); + let rb = RigidBodyBuilder::dynamic().build(); let co = ColliderBuilder::ball(0.5).build(); let hrb = bodies.insert(rb); let coh = colliders.insert_with_parent(co, hrb, &mut bodies); diff --git a/src/geometry/collider_components.rs b/src/geometry/collider_components.rs index fe2961f..5f27823 100644 --- a/src/geometry/collider_components.rs +++ b/src/geometry/collider_components.rs @@ -285,18 +285,18 @@ bitflags::bitflags! { /// and another collider attached to a kinematic body. const DYNAMIC_KINEMATIC = 0b0000_0000_0000_1100; /// Enable collision-detection between a collider attached to a dynamic body - /// and another collider attached to a static body (or not attached to any body). + /// and another collider attached to a fixed body (or not attached to any body). const DYNAMIC_STATIC = 0b0000_0000_0000_0010; /// Enable collision-detection between a collider attached to a kinematic body /// and another collider attached to a kinematic body. const KINEMATIC_KINEMATIC = 0b1100_1100_0000_0000; /// Enable collision-detection between a collider attached to a kinematic body - /// and another collider attached to a static body (or not attached to any body). + /// and another collider attached to a fixed body (or not attached to any body). const KINEMATIC_STATIC = 0b0010_0010_0000_0000; - /// Enable collision-detection between a collider attached to a static body (or - /// not attached to any body) and another collider attached to a static body (or + /// Enable collision-detection between a collider attached to a fixed body (or + /// not attached to any body) and another collider attached to a fixed body (or /// not attached to any body). const STATIC_STATIC = 0b0000_0000_0010_0000; } diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index 400c635..cf78b81 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -392,7 +392,7 @@ impl NarrowPhase { // For each modified colliders, we need to wake-up the bodies it is in contact with // so that the narrow-phase properly takes into account the change in, e.g., // collision groups. Waking up the modified collider's parent isn't enough because - // it could be a static or kinematic body which don't propagate the wake-up state. + // it could be a fixed or kinematic body which don't propagate the wake-up state. let co_parent: Option<&ColliderParent> = colliders.get(handle.0); let (co_changes, co_type): (&ColliderChanges, &ColliderType) = @@ -740,8 +740,8 @@ impl NarrowPhase { } // TODO: avoid lookup into bodies. - let mut rb_type1 = RigidBodyType::Static; - let mut rb_type2 = RigidBodyType::Static; + let mut rb_type1 = RigidBodyType::Fixed; + let mut rb_type2 = RigidBodyType::Fixed; if let Some(co_parent1) = co_parent1 { rb_type1 = *bodies.index(co_parent1.handle.0); @@ -865,8 +865,8 @@ impl NarrowPhase { } // TODO: avoid lookup into bodies. - let mut rb_type1 = RigidBodyType::Static; - let mut rb_type2 = RigidBodyType::Static; + let mut rb_type1 = RigidBodyType::Fixed; + let mut rb_type2 = RigidBodyType::Fixed; if let Some(co_parent1) = co_parent1 { rb_type1 = *bodies.index(co_parent1.handle.0); @@ -1076,7 +1076,7 @@ impl NarrowPhase { bodies.index_bundle(handle1.0); (data.0.active_island_id, *data.1, data.2.sleeping) } else { - (0, RigidBodyType::Static, true) + (0, RigidBodyType::Fixed, true) }; let (active_island_id2, rb_type2, sleeping2) = @@ -1085,7 +1085,7 @@ impl NarrowPhase { bodies.index_bundle(handle2.0); (data.0.active_island_id, *data.1, data.2.sleeping) } else { - (0, RigidBodyType::Static, true) + (0, RigidBodyType::Fixed, true) }; if (rb_type1.is_dynamic() || rb_type2.is_dynamic()) diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs index ba172c4..3f74b48 100644 --- a/src/pipeline/physics_pipeline.rs +++ b/src/pipeline/physics_pipeline.rs @@ -688,7 +688,7 @@ mod test { use crate::prelude::MultibodyJointSet; #[test] - fn kinematic_and_static_contact_crash() { + fn kinematic_and_fixed_contact_crash() { let mut colliders = ColliderSet::new(); let mut impulse_joints = ImpulseJointSet::new(); let mut multibody_joints = MultibodyJointSet::new(); @@ -698,13 +698,13 @@ mod test { let mut bodies = RigidBodySet::new(); let mut islands = IslandManager::new(); - let rb = RigidBodyBuilder::new_static().build(); + let rb = RigidBodyBuilder::fixed().build(); let h1 = bodies.insert(rb.clone()); let co = ColliderBuilder::ball(10.0).build(); colliders.insert_with_parent(co.clone(), h1, &mut bodies); // The same but with a kinematic body. - let rb = RigidBodyBuilder::new_kinematic_position_based().build(); + let rb = RigidBodyBuilder::kinematic_position_based().build(); let h2 = bodies.insert(rb.clone()); colliders.insert_with_parent(co, h2, &mut bodies); @@ -737,18 +737,18 @@ mod test { let mut bodies = RigidBodySet::new(); // Check that removing the body right after inserting it works. - // We add two dynamic bodies, one kinematic body and one static body before removing + // We add two dynamic bodies, one kinematic body and one fixed body before removing // them. This include a non-regression test where deleting a kimenatic body crashes. - let rb = RigidBodyBuilder::new_dynamic().build(); + let rb = RigidBodyBuilder::dynamic().build(); let h1 = bodies.insert(rb.clone()); let h2 = bodies.insert(rb.clone()); // The same but with a kinematic body. - let rb = RigidBodyBuilder::new_kinematic_position_based().build(); + let rb = RigidBodyBuilder::kinematic_position_based().build(); let h3 = bodies.insert(rb.clone()); - // The same but with a static body. - let rb = RigidBodyBuilder::new_static().build(); + // The same but with a fixed body. + let rb = RigidBodyBuilder::fixed().build(); let h4 = bodies.insert(rb.clone()); let to_delete = [h1, h2, h3, h4]; @@ -787,7 +787,7 @@ mod test { let mut islands = IslandManager::new(); let mut bodies = RigidBodySet::new(); - let rb = RigidBodyBuilder::new_dynamic().build(); + let rb = RigidBodyBuilder::dynamic().build(); let h1 = bodies.insert(rb.clone()); let h2 = bodies.insert(rb.clone()); let h3 = bodies.insert(rb.clone()); @@ -846,7 +846,7 @@ mod test { let physics_hooks = (); let event_handler = (); - let body = RigidBodyBuilder::new_dynamic().build(); + let body = RigidBodyBuilder::dynamic().build(); let b_handle = bodies.insert(body); let collider = ColliderBuilder::ball(1.0).build(); let c_handle = colliders.insert_with_parent(collider, b_handle, &mut bodies); diff --git a/src/pipeline/user_changes.rs b/src/pipeline/user_changes.rs index b9c57bd..bd69bb2 100644 --- a/src/pipeline/user_changes.rs +++ b/src/pipeline/user_changes.rs @@ -117,7 +117,7 @@ pub(crate) fn handle_user_changes_to_rigid_bodies<Bodies, Colliders>( islands.active_kinematic_set.push(*handle); } } - RigidBodyType::Static => {} + RigidBodyType::Fixed => {} } } |
