@@ -1,4 +1,4 @@
|
|||||||
use parry::utils::hashmap::HashMap;
|
use parry::utils::hashset::HashSet;
|
||||||
|
|
||||||
use super::ImpulseJoint;
|
use super::ImpulseJoint;
|
||||||
use crate::geometry::{InteractionGraph, RigidBodyGraphIndex, TemporaryInteractionIndex};
|
use crate::geometry::{InteractionGraph, RigidBodyGraphIndex, TemporaryInteractionIndex};
|
||||||
@@ -46,7 +46,7 @@ pub struct ImpulseJointSet {
|
|||||||
joint_ids: Arena<TemporaryInteractionIndex>,
|
joint_ids: Arena<TemporaryInteractionIndex>,
|
||||||
joint_graph: InteractionGraph<RigidBodyHandle, ImpulseJoint>,
|
joint_graph: InteractionGraph<RigidBodyHandle, ImpulseJoint>,
|
||||||
/// A set of rigid-body handles to wake-up during the next timestep.
|
/// A set of rigid-body handles to wake-up during the next timestep.
|
||||||
pub(crate) to_wake_up: HashMap<RigidBodyHandle, ()>,
|
pub(crate) to_wake_up: HashSet<RigidBodyHandle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImpulseJointSet {
|
impl ImpulseJointSet {
|
||||||
@@ -56,7 +56,7 @@ impl ImpulseJointSet {
|
|||||||
rb_graph_ids: Coarena::new(),
|
rb_graph_ids: Coarena::new(),
|
||||||
joint_ids: Arena::new(),
|
joint_ids: Arena::new(),
|
||||||
joint_graph: InteractionGraph::new(),
|
joint_graph: InteractionGraph::new(),
|
||||||
to_wake_up: HashMap::default(),
|
to_wake_up: HashSet::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +158,8 @@ impl ImpulseJointSet {
|
|||||||
let joint = self.joint_graph.graph.edge_weight_mut(*id);
|
let joint = self.joint_graph.graph.edge_weight_mut(*id);
|
||||||
if wake_up_connected_bodies {
|
if wake_up_connected_bodies {
|
||||||
if let Some(joint) = &joint {
|
if let Some(joint) = &joint {
|
||||||
self.to_wake_up.insert(joint.body1, ());
|
self.to_wake_up.insert(joint.body1);
|
||||||
self.to_wake_up.insert(joint.body2, ());
|
self.to_wake_up.insert(joint.body2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
joint
|
joint
|
||||||
@@ -285,8 +285,8 @@ impl ImpulseJointSet {
|
|||||||
self.joint_ids[handle] = self.joint_graph.add_edge(graph_index1, graph_index2, joint);
|
self.joint_ids[handle] = self.joint_graph.add_edge(graph_index1, graph_index2, joint);
|
||||||
|
|
||||||
if wake_up {
|
if wake_up {
|
||||||
self.to_wake_up.insert(body1, ());
|
self.to_wake_up.insert(body1);
|
||||||
self.to_wake_up.insert(body2, ());
|
self.to_wake_up.insert(body2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImpulseJointHandle(handle)
|
ImpulseJointHandle(handle)
|
||||||
@@ -337,10 +337,10 @@ impl ImpulseJointSet {
|
|||||||
|
|
||||||
if wake_up {
|
if wake_up {
|
||||||
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.0) {
|
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.0) {
|
||||||
self.to_wake_up.insert(*rb_handle, ());
|
self.to_wake_up.insert(*rb_handle);
|
||||||
}
|
}
|
||||||
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.1) {
|
if let Some(rb_handle) = self.joint_graph.graph.node_weight(endpoints.1) {
|
||||||
self.to_wake_up.insert(*rb_handle, ());
|
self.to_wake_up.insert(*rb_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,8 +390,8 @@ impl ImpulseJointSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wake up the attached bodies.
|
// Wake up the attached bodies.
|
||||||
self.to_wake_up.insert(h1, ());
|
self.to_wake_up.insert(h1);
|
||||||
self.to_wake_up.insert(h2, ());
|
self.to_wake_up.insert(h2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(other) = self.joint_graph.remove_node(deleted_id) {
|
if let Some(other) = self.joint_graph.remove_node(deleted_id) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use parry::utils::hashmap::HashMap;
|
use parry::utils::hashset::HashSet;
|
||||||
|
|
||||||
use crate::data::{Arena, Coarena, Index};
|
use crate::data::{Arena, Coarena, Index};
|
||||||
use crate::dynamics::joint::MultibodyLink;
|
use crate::dynamics::joint::MultibodyLink;
|
||||||
@@ -96,7 +96,7 @@ pub struct MultibodyJointSet {
|
|||||||
// NOTE: this is mostly for the island extraction. So perhaps we won’t need
|
// NOTE: this is mostly for the island extraction. So perhaps we won’t need
|
||||||
// that any more in the future when we improve our island builder.
|
// that any more in the future when we improve our island builder.
|
||||||
pub(crate) connectivity_graph: InteractionGraph<RigidBodyHandle, ()>,
|
pub(crate) connectivity_graph: InteractionGraph<RigidBodyHandle, ()>,
|
||||||
pub(crate) to_wake_up: HashMap<RigidBodyHandle, ()>,
|
pub(crate) to_wake_up: HashSet<RigidBodyHandle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultibodyJointSet {
|
impl MultibodyJointSet {
|
||||||
@@ -106,7 +106,7 @@ impl MultibodyJointSet {
|
|||||||
multibodies: Arena::new(),
|
multibodies: Arena::new(),
|
||||||
rb2mb: Coarena::new(),
|
rb2mb: Coarena::new(),
|
||||||
connectivity_graph: InteractionGraph::new(),
|
connectivity_graph: InteractionGraph::new(),
|
||||||
to_wake_up: HashMap::default(),
|
to_wake_up: HashSet::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +203,8 @@ impl MultibodyJointSet {
|
|||||||
multibody1.append(mb2, link1.id, MultibodyJoint::new(data.into(), kinematic));
|
multibody1.append(mb2, link1.id, MultibodyJoint::new(data.into(), kinematic));
|
||||||
|
|
||||||
if wake_up {
|
if wake_up {
|
||||||
self.to_wake_up.insert(body1, ());
|
self.to_wake_up.insert(body1);
|
||||||
self.to_wake_up.insert(body2, ());
|
self.to_wake_up.insert(body2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because each rigid-body can only have one parent link,
|
// Because each rigid-body can only have one parent link,
|
||||||
@@ -227,8 +227,8 @@ impl MultibodyJointSet {
|
|||||||
.remove_edge(parent_graph_id, removed.graph_id);
|
.remove_edge(parent_graph_id, removed.graph_id);
|
||||||
|
|
||||||
if wake_up {
|
if wake_up {
|
||||||
self.to_wake_up.insert(RigidBodyHandle(handle.0), ());
|
self.to_wake_up.insert(RigidBodyHandle(handle.0));
|
||||||
self.to_wake_up.insert(parent_rb, ());
|
self.to_wake_up.insert(parent_rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove the node if it no longer has any attached edges?
|
// TODO: remove the node if it no longer has any attached edges?
|
||||||
@@ -270,7 +270,7 @@ impl MultibodyJointSet {
|
|||||||
let rb_handle = link.rigid_body;
|
let rb_handle = link.rigid_body;
|
||||||
|
|
||||||
if wake_up {
|
if wake_up {
|
||||||
self.to_wake_up.insert(rb_handle, ());
|
self.to_wake_up.insert(rb_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the rigid-body <-> multibody mapping for this link.
|
// Remove the rigid-body <-> multibody mapping for this link.
|
||||||
@@ -296,8 +296,8 @@ impl MultibodyJointSet {
|
|||||||
// There is a multibody_joint handle is equal to the second rigid-body’s handle.
|
// There is a multibody_joint handle is equal to the second rigid-body’s handle.
|
||||||
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
|
articulations_to_remove.push(MultibodyJointHandle(rb2.0));
|
||||||
|
|
||||||
self.to_wake_up.insert(rb1, ());
|
self.to_wake_up.insert(rb1);
|
||||||
self.to_wake_up.insert(rb2, ());
|
self.to_wake_up.insert(rb2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for articulation_handle in articulations_to_remove {
|
for articulation_handle in articulations_to_remove {
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ impl PhysicsPipeline {
|
|||||||
.drain()
|
.drain()
|
||||||
.chain(multibody_joints.to_wake_up.drain());
|
.chain(multibody_joints.to_wake_up.drain());
|
||||||
for handle in impulse_joints_iterator {
|
for handle in impulse_joints_iterator {
|
||||||
islands.wake_up(bodies, handle.0, true);
|
islands.wake_up(bodies, handle, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply modifications.
|
// Apply modifications.
|
||||||
|
|||||||
Reference in New Issue
Block a user