From 6247b0d48ac36d826b7da0cbdca2d6e73f281de3 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Wed, 3 Mar 2021 10:19:19 +0100 Subject: Fix testbed compilation after the nalgebra release 0.6.1 --- build/rapier_testbed2d/Cargo.toml | 2 +- build/rapier_testbed3d/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/rapier_testbed2d/Cargo.toml b/build/rapier_testbed2d/Cargo.toml index 4c3872f..d31cdff 100644 --- a/build/rapier_testbed2d/Cargo.toml +++ b/build/rapier_testbed2d/Cargo.toml @@ -26,7 +26,7 @@ other-backends = [ "wrapped2d", "nphysics2d" ] [dependencies] -nalgebra = "0.25" +nalgebra = { version = "0.25", features = [ "rand" ] } kiss3d = { version = "0.30", features = [ "conrod" ] } rand = "0.8" rand_pcg = "0.3" diff --git a/build/rapier_testbed3d/Cargo.toml b/build/rapier_testbed3d/Cargo.toml index d14a1de..2a599a4 100644 --- a/build/rapier_testbed3d/Cargo.toml +++ b/build/rapier_testbed3d/Cargo.toml @@ -25,7 +25,7 @@ parallel = [ "rapier3d/parallel", "num_cpus" ] other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ] [dependencies] -nalgebra = "0.25" +nalgebra = { version = "0.25", features = [ "rand" ] } kiss3d = { version = "0.30", features = [ "conrod" ] } rand = "0.8" rand_pcg = "0.3" -- cgit From 1609d93243a74af6666e8b284969faa389f61677 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Wed, 3 Mar 2021 10:20:14 +0100 Subject: Fix missing sqrt when setting the angular inertia of a rigid-body. --- src/dynamics/rigid_body.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 32c0cca..88f4069 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -6,6 +6,7 @@ use crate::math::{ AngVector, AngularInertia, Isometry, Point, Real, Rotation, Translation, Vector, }; use crate::utils::{self, WCross, WDot}; +use na::ComplexField; use num::Zero; #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -804,7 +805,8 @@ impl RigidBodyBuilder { /// Sets the angular inertia of this rigid-body. #[cfg(feature = "dim2")] pub fn principal_angular_inertia(mut self, inertia: Real) -> Self { - self.mass_properties.inv_principal_inertia_sqrt = utils::inv(inertia); + self.mass_properties.inv_principal_inertia_sqrt = + utils::inv(ComplexField::sqrt(inertia.max(0.0))); self } @@ -829,7 +831,8 @@ impl RigidBodyBuilder { /// attached to this rigid-body. #[cfg(feature = "dim3")] pub fn principal_angular_inertia(mut self, inertia: AngVector) -> Self { - self.mass_properties.inv_principal_inertia_sqrt = inertia.map(utils::inv); + self.mass_properties.inv_principal_inertia_sqrt = + inertia.map(|e| utils::inv(ComplexField::sqrt(e.max(0.0)))); self } -- cgit