Merge pull request #136 from dimforge/inertia_sqrt
Fix missing sqrt when setting the angular inertia of a RigidBodyBuilder
This commit is contained in:
@@ -26,7 +26,7 @@ other-backends = [ "wrapped2d", "nphysics2d" ]
|
|||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = "0.25"
|
nalgebra = { version = "0.25", features = [ "rand" ] }
|
||||||
kiss3d = { version = "0.30", features = [ "conrod" ] }
|
kiss3d = { version = "0.30", features = [ "conrod" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ parallel = [ "rapier3d/parallel", "num_cpus" ]
|
|||||||
other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ]
|
other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = "0.25"
|
nalgebra = { version = "0.25", features = [ "rand" ] }
|
||||||
kiss3d = { version = "0.30", features = [ "conrod" ] }
|
kiss3d = { version = "0.30", features = [ "conrod" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::math::{
|
|||||||
AngVector, AngularInertia, Isometry, Point, Real, Rotation, Translation, Vector,
|
AngVector, AngularInertia, Isometry, Point, Real, Rotation, Translation, Vector,
|
||||||
};
|
};
|
||||||
use crate::utils::{self, WCross, WDot};
|
use crate::utils::{self, WCross, WDot};
|
||||||
|
use na::ComplexField;
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
@@ -804,7 +805,8 @@ impl RigidBodyBuilder {
|
|||||||
/// Sets the angular inertia of this rigid-body.
|
/// Sets the angular inertia of this rigid-body.
|
||||||
#[cfg(feature = "dim2")]
|
#[cfg(feature = "dim2")]
|
||||||
pub fn principal_angular_inertia(mut self, inertia: Real) -> Self {
|
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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -829,7 +831,8 @@ impl RigidBodyBuilder {
|
|||||||
/// attached to this rigid-body.
|
/// attached to this rigid-body.
|
||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
pub fn principal_angular_inertia(mut self, inertia: AngVector<Real>) -> Self {
|
pub fn principal_angular_inertia(mut self, inertia: AngVector<Real>) -> 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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user