From 365cce73f5586981afe741fdfd75fb7545472bab Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Wed, 31 Mar 2021 14:07:32 +0200 Subject: Make the collider shape mutable. --- src/geometry/collider.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs index 11fe5ee..529d2f5 100644 --- a/src/geometry/collider.rs +++ b/src/geometry/collider.rs @@ -228,6 +228,15 @@ impl Collider { &*self.shape.0 } + /// A mutable reference to the geometric shape of this collider. + /// + /// If that shape is shared by multiple colliders, it will be + /// cloned first so that `self` contains a unique copy of that + /// shape that you can modify. + pub fn shape_mut(&mut self) -> &mut dyn Shape { + self.shape.make_mut() + } + /// Sets the shape of this collider. pub fn set_shape(&mut self, shape: SharedShape) { self.changes.insert(ColliderChanges::SHAPE); -- cgit