diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-03-19 14:19:13 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-03-20 21:49:16 +0100 |
| commit | e2e6fc787112ab35a3d4858aa2cf83fcf41c16a2 (patch) | |
| tree | ecf41f5ef0f820fe104a937c47a19cdf73066a5e /src/dynamics | |
| parent | a041e0d31455c1a41aa93f5c0ec1945306779c7f (diff) | |
| download | rapier-e2e6fc787112ab35a3d4858aa2cf83fcf41c16a2.tar.gz rapier-e2e6fc787112ab35a3d4858aa2cf83fcf41c16a2.tar.bz2 rapier-e2e6fc787112ab35a3d4858aa2cf83fcf41c16a2.zip | |
Add a method to propagate collider transforms with the RigidBodySet
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/rigid_body_set.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body_set.rs b/src/dynamics/rigid_body_set.rs index d033839..8f5d8ef 100644 --- a/src/dynamics/rigid_body_set.rs +++ b/src/dynamics/rigid_body_set.rs @@ -259,6 +259,19 @@ impl RigidBodySet { (RigidBodyHandle(h), b) }) } + + pub fn propagate_modified_body_positions_to_colliders(&self, colliders: &mut ColliderSet) { + for body in self.modified_bodies.iter().filter_map(|h| self.get(*h)) { + if body.changes.contains(RigidBodyChanges::POSITION) { + for handle in body.colliders() { + if let Some(collider) = colliders.get_mut(*handle) { + let new_pos = body.position() * collider.position_wrt_parent().unwrap(); + collider.set_position(new_pos); + } + } + } + } + } } impl Index<RigidBodyHandle> for RigidBodySet { |
