rapier2d/utils/
simd_select.rs1#[cfg(feature = "simd-is-enabled")]
4use crate::math::SimdReal;
5use crate::math::{Real, Vector};
6use crate::utils::ScalarType;
7
8pub trait SimdSelect<N: ScalarType> {
10 fn select(self, condition: N::SimdBool, if_false: Self) -> Self;
12}
13
14impl SimdSelect<Real> for Vector {
15 #[inline]
16 fn select(self, condition: bool, if_false: Self) -> Self {
17 if condition { self } else { if_false }
18 }
19}
20
21#[cfg(feature = "simd-is-enabled")]
22impl SimdSelect<SimdReal> for na::Vector3<SimdReal> {
23 #[inline]
24 fn select(self, condition: <SimdReal as na::SimdValue>::SimdBool, if_false: Self) -> Self {
25 na::SimdValue::select(self, condition, if_false)
26 }
27}