From 2dda0e5ce48ed0d93b4b0fa3098ba08f59a50a0a Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Mon, 21 Sep 2020 17:26:57 +0200 Subject: Complete the WQuadtree construction and ray-cast. --- src/utils.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index 91ce41c..c7cb908 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -11,7 +11,11 @@ use simba::simd::SimdValue; use std::collections::HashMap; use std::ops::{Add, Mul}; #[cfg(feature = "simd-is-enabled")] -use {crate::simd::SimdFloat, na::SimdPartialOrd, num::One}; +use { + crate::simd::{SimdBool, SimdFloat}, + na::SimdPartialOrd, + num::One, +}; // pub(crate) const SIN_10_DEGREES: f32 = 0.17364817766; // pub(crate) const COS_10_DEGREES: f32 = 0.98480775301; @@ -31,6 +35,17 @@ pub(crate) fn inv(val: f32) -> f32 { } } +/// Conditionally swaps each lanes of `a` with those of `b`. +/// +/// For each `i in [0..SIMD_WIDTH[`, if `do_swap.extract(i)` is `true` then +/// `a.extract(i)` is swapped with `b.extract(i)`. +#[cfg(feature = "simd-is-enabled")] +pub fn simd_swap(do_swap: SimdBool, a: &mut SimdFloat, b: &mut SimdFloat) { + let _a = *a; + *a = b.select(do_swap, *a); + *b = _a.select(do_swap, *b); +} + /// Trait to copy the sign of each component of one scalar/vector/matrix to another. pub trait WSign: Sized { // See SIMD implementations of copy_sign there: https://stackoverflow.com/a/57872652 -- cgit From 84bd60e4a5b88c9aa824797c8a444945b46e96b2 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 22 Sep 2020 17:57:29 +0200 Subject: Fix compilation when SIMD is not enabled. --- src/utils.rs | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index c7cb908..ecdd4fd 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,12 +5,10 @@ use crate::dynamics::RigidBodyHandle; use indexmap::IndexMap as HashMap; use na::{Matrix2, Matrix3, Matrix3x2, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3}; use num::Zero; -#[cfg(feature = "simd-is-enabled")] use simba::simd::SimdValue; #[cfg(all(not(feature = "enhanced-determinism"), feature = "serde-serialize"))] use std::collections::HashMap; use std::ops::{Add, Mul}; -#[cfg(feature = "simd-is-enabled")] use { crate::simd::{SimdBool, SimdFloat}, na::SimdPartialOrd, @@ -39,7 +37,6 @@ pub(crate) fn inv(val: f32) -> f32 { /// /// For each `i in [0..SIMD_WIDTH[`, if `do_swap.extract(i)` is `true` then /// `a.extract(i)` is swapped with `b.extract(i)`. -#[cfg(feature = "simd-is-enabled")] pub fn simd_swap(do_swap: SimdBool, a: &mut SimdFloat, b: &mut SimdFloat) { let _a = *a; *a = b.select(do_swap, *a); @@ -92,7 +89,6 @@ impl> WSign> for Vector3 { } } -#[cfg(feature = "simd-is-enabled")] impl WSign for SimdFloat { fn copy_sign_to(self, to: SimdFloat) -> SimdFloat { self.simd_copysign(to) @@ -117,7 +113,6 @@ impl WComponent for f32 { } } -#[cfg(feature = "simd-is-enabled")] impl WComponent for SimdFloat { type Element = f32; @@ -334,7 +329,6 @@ impl WDot for f32 { } } -#[cfg(feature = "simd-is-enabled")] impl WCrossMatrix for Vector3 { type CrossMat = Matrix3; @@ -349,7 +343,6 @@ impl WCrossMatrix for Vector3 { } } -#[cfg(feature = "simd-is-enabled")] impl WCrossMatrix for Vector2 { type CrossMat = Vector2; @@ -359,7 +352,6 @@ impl WCrossMatrix for Vector2 { } } -#[cfg(feature = "simd-is-enabled")] impl WCross> for Vector3 { type Result = Vector3; @@ -368,7 +360,6 @@ impl WCross> for Vector3 { } } -#[cfg(feature = "simd-is-enabled")] impl WCross> for SimdFloat { type Result = Vector2; @@ -377,7 +368,6 @@ impl WCross> for SimdFloat { } } -#[cfg(feature = "simd-is-enabled")] impl WCross> for Vector2 { type Result = SimdFloat; @@ -388,7 +378,6 @@ impl WCross> for Vector2 { } } -#[cfg(feature = "simd-is-enabled")] impl WDot> for Vector3 { type Result = SimdFloat; @@ -397,7 +386,6 @@ impl WDot> for Vector3 { } } -#[cfg(feature = "simd-is-enabled")] impl WDot> for Vector2 { type Result = SimdFloat; @@ -406,7 +394,6 @@ impl WDot> for Vector2 { } } -#[cfg(feature = "simd-is-enabled")] impl WDot for SimdFloat { type Result = SimdFloat; @@ -460,7 +447,6 @@ impl WAngularInertia for f32 { } } -#[cfg(feature = "simd-is-enabled")] impl WAngularInertia for SimdFloat { type AngVector = SimdFloat; type LinVector = Vector2; @@ -875,7 +861,6 @@ impl WAngularInertia for SdpMatrix3 { } } -#[cfg(feature = "simd-is-enabled")] impl WAngularInertia for SdpMatrix3 { type AngVector = Vector3; type LinVector = Vector3; -- cgit