From faec3d5d46c88e2949179dd2789899e5cf26ed48 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 12 Oct 2020 18:33:58 +0200 Subject: Start adding cylinders. --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index ecdd4fd..04e6a3a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -91,7 +91,7 @@ impl> WSign> for Vector3 { impl WSign for SimdFloat { fn copy_sign_to(self, to: SimdFloat) -> SimdFloat { - self.simd_copysign(to) + to.simd_copysign(self) } } -- cgit From 947c4813c9666fd8215743de298fe17780fa3ef2 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 19 Oct 2020 16:51:40 +0200 Subject: Complete the pfm/pfm contact generator. --- src/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index 04e6a3a..bd972b8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -19,8 +19,9 @@ use { // pub(crate) const COS_10_DEGREES: f32 = 0.98480775301; // pub(crate) const COS_45_DEGREES: f32 = 0.70710678118; // pub(crate) const SIN_45_DEGREES: f32 = COS_45_DEGREES; +pub(crate) const COS_1_DEGREES: f32 = 0.99984769515; pub(crate) const COS_5_DEGREES: f32 = 0.99619469809; -#[cfg(feature = "dim2")] +// #[cfg(feature = "dim2")] pub(crate) const COS_FRAC_PI_8: f32 = 0.92387953251; #[cfg(feature = "dim2")] pub(crate) const SIN_FRAC_PI_8: f32 = 0.38268343236; -- cgit From 865ce8a8e5301b23ca474adaaffe8b43e725803e Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 20 Oct 2020 11:55:33 +0200 Subject: Collider shape: use a trait-object instead of an enum. --- src/utils.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index bd972b8..48f4ef7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,7 @@ //! Miscellaneous utilities. use crate::dynamics::RigidBodyHandle; +use crate::math::{Isometry, Point, Rotation, Vector}; #[cfg(all(feature = "enhanced-determinism", feature = "serde-serialize"))] use indexmap::IndexMap as HashMap; use na::{Matrix2, Matrix3, Matrix3x2, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3}; @@ -1332,3 +1333,28 @@ pub(crate) fn other_handle( pair.0 } } + +/// Returns the rotation that aligns the y axis to the segment direction. +pub(crate) fn rotation_wrt_y(a: &Point, b: &Point) -> Rotation { + let mut dir = b - a; + + if dir.y < 0.0 { + dir = -dir; + } + + #[cfg(feature = "dim2")] + return Rotation::rotation_between(&Vector::y(), &dir); + + #[cfg(feature = "dim3")] + return Rotation::rotation_between(&Vector::y(), &dir).unwrap_or(Rotation::identity()); +} + +// Return the transform that aligns the y axis to the segment and move the origin to the segment middle, +// and the capsule's half-height. +pub(crate) fn segment_to_capsule(a: &Point, b: &Point) -> (Isometry, f32) { + let rot = rotation_wrt_y(a, b); + let half_height = (b - a).norm() / 2.0; + let center = na::center(a, b); + let pos = Isometry::from_parts(center.coords.into(), rot); + (pos, half_height) +} -- cgit From 949e3f5384a366c3bff5415c5db4635e811a580e Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 20 Oct 2020 16:22:53 +0200 Subject: Fix many warnings. --- src/utils.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index 48f4ef7..0bc9e17 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -20,6 +20,7 @@ use { // pub(crate) const COS_10_DEGREES: f32 = 0.98480775301; // pub(crate) const COS_45_DEGREES: f32 = 0.70710678118; // pub(crate) const SIN_45_DEGREES: f32 = COS_45_DEGREES; +#[cfg(feature = "dim3")] pub(crate) const COS_1_DEGREES: f32 = 0.99984769515; pub(crate) const COS_5_DEGREES: f32 = 0.99619469809; // #[cfg(feature = "dim2")] -- cgit From 08930b1238c90bec16db84c50ac4ea7c9a1e0a5b Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 26 Oct 2020 16:36:07 +0100 Subject: Fix multiple warnings. --- src/utils.rs | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index 0bc9e17..a398a02 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,6 @@ //! Miscellaneous utilities. use crate::dynamics::RigidBodyHandle; -use crate::math::{Isometry, Point, Rotation, Vector}; #[cfg(all(feature = "enhanced-determinism", feature = "serde-serialize"))] use indexmap::IndexMap as HashMap; use na::{Matrix2, Matrix3, Matrix3x2, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3}; @@ -1334,28 +1333,3 @@ pub(crate) fn other_handle( pair.0 } } - -/// Returns the rotation that aligns the y axis to the segment direction. -pub(crate) fn rotation_wrt_y(a: &Point, b: &Point) -> Rotation { - let mut dir = b - a; - - if dir.y < 0.0 { - dir = -dir; - } - - #[cfg(feature = "dim2")] - return Rotation::rotation_between(&Vector::y(), &dir); - - #[cfg(feature = "dim3")] - return Rotation::rotation_between(&Vector::y(), &dir).unwrap_or(Rotation::identity()); -} - -// Return the transform that aligns the y axis to the segment and move the origin to the segment middle, -// and the capsule's half-height. -pub(crate) fn segment_to_capsule(a: &Point, b: &Point) -> (Isometry, f32) { - let rot = rotation_wrt_y(a, b); - let half_height = (b - a).norm() / 2.0; - let center = na::center(a, b); - let pos = Isometry::from_parts(center.coords.into(), rot); - (pos, half_height) -} -- cgit