diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-30 15:35:02 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-30 15:35:36 +0100 |
| commit | 715d0fe16eb8ca9df90ff161ade4bf809a780043 (patch) | |
| tree | e73502f764f9b00c05cfce7d41f2e5437e2ffdd2 /src/dynamics | |
| parent | c3e951f896bf59d074771fe89de5b0b55f94f8ed (diff) | |
| download | rapier-715d0fe16eb8ca9df90ff161ade4bf809a780043.tar.gz rapier-715d0fe16eb8ca9df90ff161ade4bf809a780043.tar.bz2 rapier-715d0fe16eb8ca9df90ff161ade4bf809a780043.zip | |
Update the changelog + make the boolean flags more intuitive.
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 70a7200..9832ff7 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -632,61 +632,63 @@ impl RigidBodyBuilder { /// Prevents this rigid-body from translating because of forces. /// - /// This is equivalent to `self.mass(0.0, true)`. See the + /// This is equivalent to `self.mass(0.0, false)`. See the /// documentation of [`RigidBodyBuilder::mass`] for more details. pub fn lock_translations(mut self) -> Self { - self.mass(0.0, true) + self.mass(0.0, false) } /// Prevents this rigid-body from rotating because of forces. /// - /// This is equivalent to `self.principal_inertia(0.0, true)` (in 2D) or - /// `self.principal_inertia(Vector3::zeros(), Vector3::repeat(true))` (in 3D). + /// This is equivalent to `self.principal_inertia(0.0, false)` (in 2D) or + /// `self.principal_inertia(Vector3::zeros(), Vector3::repeat(false))` (in 3D). /// /// See the documentation of [`RigidBodyBuilder::principal_inertia`] for more details. pub fn lock_rotations(mut self) -> Self { #[cfg(feature = "dim2")] - return self.principal_inertia(0.0, true); + return self.principal_inertia(0.0, false); #[cfg(feature = "dim3")] - return self.principal_inertia(Vector::zeros(), Vector::repeat(true)); + return self.principal_inertia(Vector::zeros(), Vector::repeat(false)); } /// Sets the mass of the rigid-body being built. /// /// In order to lock the translations of this rigid-body (by - /// making them kinematic), call `.mass(0.0, true)`. + /// making them kinematic), call `.mass(0.0, false)`. /// - /// If `ignore_colliders` is `true`, then the mass specified here + /// If `colliders_contribution_enabled` is `false`, then the mass specified here /// will be the final mass of the rigid-body created by this builder. - /// If `ignore_colliders` is `false`, then the final mass of the rigid-body + /// If `colliders_contribution_enabled` is `true`, then the final mass of the rigid-body /// will depends on the initial mass set by this method to which is added /// the contributions of all the colliders with non-zero density attached to /// this rigid-body. - pub fn mass(mut self, mass: f32, ignore_colliders: bool) -> Self { + pub fn mass(mut self, mass: f32, colliders_contribution_enabled: bool) -> Self { self.mass_properties.inv_mass = utils::inv(mass); - self.flags - .set(RigidBodyFlags::IGNORE_COLLIDER_MASS, ignore_colliders); + self.flags.set( + RigidBodyFlags::IGNORE_COLLIDER_MASS, + !colliders_contribution_enabled, + ); self } /// Sets the angular inertia of this rigid-body. /// /// In order to lock the rotations of this rigid-body (by - /// making them kinematic), call `.principal_inertia(0.0, true)`. + /// making them kinematic), call `.principal_inertia(0.0, false)`. /// - /// If `ignore_colliders` is `true`, then the principal inertia specified here + /// If `colliders_contribution_enabled` is `false`, then the principal inertia specified here /// will be the final principal inertia of the rigid-body created by this builder. - /// If `ignore_colliders` is `false`, then the final principal of the rigid-body + /// If `colliders_contribution_enabled` is `true`, then the final principal of the rigid-body /// will depend on the initial principal inertia set by this method to which is added /// the contributions of all the colliders with non-zero density attached to this rigid-body. #[cfg(feature = "dim2")] - pub fn principal_inertia(mut self, inertia: f32, ignore_colliders: bool) -> Self { + pub fn principal_inertia(mut self, inertia: f32, colliders_contribution_enabled: bool) -> Self { self.mass_properties.inv_principal_inertia_sqrt = utils::inv(inertia); self.flags.set( RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_X | RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_Y | RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_Z, - ignore_colliders, + !colliders_contribution_enabled, ); self } @@ -696,10 +698,10 @@ impl RigidBodyBuilder { /// In order to lock the rotations of this rigid-body (by /// making them kinematic), call `.principal_inertia(Vector3::zeros(), Vector3::repeat(false))`. /// - /// If `ignore_colliders[i]` is `true`, then the principal inertia specified here + /// If `colliders_contribution_enabled[i]` is `false`, then the principal inertia specified here /// along the `i`-th local axis of the rigid-body, will be the final principal inertia along /// the `i`-th local axis of the rigid-body created by this builder. - /// If `ignore_colliders[i]` is `false`, then the final principal of the rigid-body + /// If `colliders_contribution_enabled[i]` is `true`, then the final principal of the rigid-body /// along its `i`-th local axis will depend on the initial principal inertia set by this method /// to which is added the contributions of all the colliders with non-zero density /// attached to this rigid-body. @@ -707,20 +709,20 @@ impl RigidBodyBuilder { pub fn principal_inertia( mut self, inertia: AngVector<f32>, - ignore_colliders: AngVector<bool>, + colliders_contribution_enabled: AngVector<bool>, ) -> Self { self.mass_properties.inv_principal_inertia_sqrt = inertia.map(utils::inv); self.flags.set( RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_X, - ignore_colliders.x, + !colliders_contribution_enabled.x, ); self.flags.set( RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_Y, - ignore_colliders.y, + !colliders_contribution_enabled.y, ); self.flags.set( RigidBodyFlags::IGNORE_COLLIDER_ANGULAR_INERTIA_Z, - ignore_colliders.z, + !colliders_contribution_enabled.z, ); self } |
