Properly take initial sleeping state set by the user when creating a rigid-body
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::counters::Counters;
|
||||
use crate::dynamics::IslandSolver;
|
||||
use crate::dynamics::{
|
||||
CCDSolver, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointSet,
|
||||
RigidBodyPosition, RigidBodyType,
|
||||
RigidBodyChanges, RigidBodyHandle, RigidBodyPosition, RigidBodyType,
|
||||
};
|
||||
#[cfg(feature = "parallel")]
|
||||
use crate::dynamics::{JointGraphEdge, ParallelIslandSolver as IslandSolver};
|
||||
@@ -77,6 +77,18 @@ impl PhysicsPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_modified_bodies(
|
||||
&mut self,
|
||||
bodies: &mut RigidBodySet,
|
||||
modified_bodies: &mut Vec<RigidBodyHandle>,
|
||||
) {
|
||||
for handle in modified_bodies.drain(..) {
|
||||
if let Some(rb) = bodies.get_mut_internal(handle) {
|
||||
rb.changes = RigidBodyChanges::empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_collisions(
|
||||
&mut self,
|
||||
integration_parameters: &IntegrationParameters,
|
||||
@@ -430,7 +442,7 @@ impl PhysicsPipeline {
|
||||
&modified_colliders[..],
|
||||
);
|
||||
|
||||
let modified_bodies = bodies.take_modified();
|
||||
let mut modified_bodies = bodies.take_modified();
|
||||
super::user_changes::handle_user_changes_to_rigid_bodies(
|
||||
Some(islands),
|
||||
bodies,
|
||||
@@ -481,6 +493,7 @@ impl PhysicsPipeline {
|
||||
}
|
||||
|
||||
self.clear_modified_colliders(colliders, &mut modified_colliders);
|
||||
self.clear_modified_bodies(bodies, &mut modified_bodies);
|
||||
removed_colliders.clear();
|
||||
|
||||
let mut remaining_time = integration_parameters.dt;
|
||||
|
||||
@@ -86,14 +86,6 @@ pub(crate) fn handle_user_changes_to_rigid_bodies(
|
||||
ids.active_set_id,
|
||||
));
|
||||
}
|
||||
|
||||
// Add to the active dynamic set.
|
||||
activation.wake_up(true);
|
||||
// Make sure the sleep change flag is set (even if for some
|
||||
// reasons the rigid-body was already awake) to make
|
||||
// sure the code handling sleeping change adds the body to
|
||||
// the active_dynamic_set.
|
||||
changes.set(RigidBodyChanges::SLEEP, true);
|
||||
}
|
||||
RigidBodyType::KinematicVelocityBased
|
||||
| RigidBodyType::KinematicPositionBased => {
|
||||
@@ -216,7 +208,6 @@ pub(crate) fn handle_user_changes_to_rigid_bodies(
|
||||
}
|
||||
}
|
||||
|
||||
rb.changes = RigidBodyChanges::empty();
|
||||
rb.ids = ids;
|
||||
rb.activation = activation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user