Merge pull request #333 from dimforge/misc-changes
Rename STATIC -> FIXED and joints_with -> attached_joints
This commit is contained in:
@@ -256,7 +256,7 @@ impl IslandManager {
|
||||
// in contact or joined with this collider.
|
||||
push_contacting_bodies(&rb.colliders, colliders, narrow_phase, &mut self.stack);
|
||||
|
||||
for inter in impulse_joints.joints_with(handle) {
|
||||
for inter in impulse_joints.attached_joints(handle) {
|
||||
let other = crate::utils::select_other((inter.0, inter.1), handle);
|
||||
self.stack.push(other);
|
||||
}
|
||||
|
||||
@@ -69,15 +69,23 @@ impl ImpulseJointSet {
|
||||
&self.joint_graph
|
||||
}
|
||||
|
||||
/// Iterates through all the impulse_joints attached to the given rigid-body.
|
||||
pub fn joints_with<'a>(
|
||||
/// Iterates through all the impulse joints attached to the given rigid-body.
|
||||
pub fn attached_joints<'a>(
|
||||
&'a self,
|
||||
body: RigidBodyHandle,
|
||||
) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, &'a ImpulseJoint)> {
|
||||
) -> impl Iterator<
|
||||
Item = (
|
||||
RigidBodyHandle,
|
||||
RigidBodyHandle,
|
||||
ImpulseJointHandle,
|
||||
&'a ImpulseJoint,
|
||||
),
|
||||
> {
|
||||
self.rb_graph_ids
|
||||
.get(body.0)
|
||||
.into_iter()
|
||||
.flat_map(move |id| self.joint_graph.interactions_with(*id))
|
||||
.map(|inter| (inter.0, inter.1, inter.2.handle, inter.2))
|
||||
}
|
||||
|
||||
/// Is the given joint handle valid?
|
||||
|
||||
@@ -252,14 +252,8 @@ impl MultibodyJointSet {
|
||||
.connectivity_graph
|
||||
.interactions_with(link_to_remove.graph_id)
|
||||
{
|
||||
// There is an multibody_joint that we need to remove between these two bodies.
|
||||
// If this is an outbound edge, then the multibody_joint’s handle is equal to the
|
||||
// second body handle.
|
||||
if rb1 == rb_to_remove {
|
||||
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
|
||||
} else {
|
||||
articulations_to_remove.push(MultibodyJointHandle(rb1.0));
|
||||
}
|
||||
// There is a multibody_joint handle is equal to the second rigid-body’s handle.
|
||||
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
|
||||
|
||||
islands.wake_up(bodies, rb1, true);
|
||||
islands.wake_up(bodies, rb2, true);
|
||||
@@ -338,6 +332,21 @@ impl MultibodyJointSet {
|
||||
))
|
||||
}
|
||||
|
||||
/// Iterates through all the joints attached to the given rigid-body.
|
||||
pub fn attached_joints(
|
||||
&self,
|
||||
rb: RigidBodyHandle,
|
||||
) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, MultibodyJointHandle)> + '_ {
|
||||
self.rb2mb
|
||||
.get(rb.0)
|
||||
.into_iter()
|
||||
.flat_map(move |link| self.connectivity_graph.interactions_with(link.graph_id))
|
||||
.map(|inter| {
|
||||
// NOTE: the joint handle is always equal to the handle of the second rigid-body.
|
||||
(inter.0, inter.1, MultibodyJointHandle(inter.1 .0))
|
||||
})
|
||||
}
|
||||
|
||||
/// Iterate through the handles of all the rigid-bodies attached to this rigid-body
|
||||
/// by an multibody_joint.
|
||||
pub fn attached_bodies<'a>(
|
||||
|
||||
@@ -286,19 +286,19 @@ bitflags::bitflags! {
|
||||
const DYNAMIC_KINEMATIC = 0b0000_0000_0000_1100;
|
||||
/// Enable collision-detection between a collider attached to a dynamic body
|
||||
/// and another collider attached to a fixed body (or not attached to any body).
|
||||
const DYNAMIC_STATIC = 0b0000_0000_0000_0010;
|
||||
const DYNAMIC_FIXED = 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 fixed body (or not attached to any body).
|
||||
const KINEMATIC_STATIC = 0b0010_0010_0000_0000;
|
||||
const KINEMATIC_FIXED = 0b0010_0010_0000_0000;
|
||||
|
||||
/// 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;
|
||||
const FIXED_FIXED = 0b0000_0000_0010_0000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,20 +308,20 @@ impl ActiveCollisionTypes {
|
||||
// NOTE: This test is quite complicated so here is an explanation.
|
||||
// First, we associate the following bit masks:
|
||||
// - DYNAMIC = 0001
|
||||
// - STATIC = 0010
|
||||
// - FIXED = 0010
|
||||
// - KINEMATIC = 1100
|
||||
// These are equal to the bits indexed by `RigidBodyType as u32`.
|
||||
// The bit masks defined by ActiveCollisionTypes are defined is such a way
|
||||
// that the first part of the variant name (e.g. DYNAMIC_*) indicates which
|
||||
// groups of four bits should be considered:
|
||||
// - DYNAMIC_* = the first group of four bits.
|
||||
// - STATIC_* = the second group of four bits.
|
||||
// - FIXED_* = the second group of four bits.
|
||||
// - KINEMATIC_* = the third and fourth groups of four bits.
|
||||
// The second part of the variant name (e.g. *_DYNAMIC) indicates the value
|
||||
// of the aforementioned groups of four bits.
|
||||
// For example, DYNAMIC_STATIC means that the first group of four bits (because
|
||||
// of DYNAMIC_*) must have the value 0010 (because of *_STATIC). That gives
|
||||
// us 0b0000_0000_0000_0010 for the DYNAMIC_STATIC_VARIANT.
|
||||
// For example, DYNAMIC_FIXED means that the first group of four bits (because
|
||||
// of DYNAMIC_*) must have the value 0010 (because of *_FIXED). That gives
|
||||
// us 0b0000_0000_0000_0010 for the DYNAMIC_FIXED_VARIANT.
|
||||
//
|
||||
// The KINEMATIC_* is special because it occupies two groups of four bits. This is
|
||||
// because it combines both KinematicPositionBased and KinematicVelocityBased.
|
||||
@@ -347,7 +347,7 @@ impl Default for ActiveCollisionTypes {
|
||||
fn default() -> Self {
|
||||
ActiveCollisionTypes::DYNAMIC_DYNAMIC
|
||||
| ActiveCollisionTypes::DYNAMIC_KINEMATIC
|
||||
| ActiveCollisionTypes::DYNAMIC_STATIC
|
||||
| ActiveCollisionTypes::DYNAMIC_FIXED
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user