nalgebra/geometry/
transform_simba.rs

1use simba::simd::SimdValue;
2
3use crate::base::allocator::Allocator;
4use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
5use crate::base::{Const, DefaultAllocator, OMatrix, Scalar};
6use crate::RealField;
7
8use crate::geometry::{TCategory, Transform};
9
10impl<T: RealField, C, const D: usize> SimdValue for Transform<T, C, D>
11where
12    T::Element: Scalar,
13    C: TCategory,
14    Const<D>: DimNameAdd<U1>,
15    DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
16{
17    const LANES: usize = T::LANES;
18    type Element = Transform<T::Element, C, D>;
19    type SimdBool = T::SimdBool;
20
21    #[inline]
22    fn splat(val: Self::Element) -> Self {
23        Transform::from_matrix_unchecked(OMatrix::splat(val.into_inner()))
24    }
25
26    #[inline]
27    fn extract(&self, i: usize) -> Self::Element {
28        Transform::from_matrix_unchecked(self.matrix().extract(i))
29    }
30
31    #[inline]
32    unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
33        Transform::from_matrix_unchecked(self.matrix().extract_unchecked(i))
34    }
35
36    #[inline]
37    fn replace(&mut self, i: usize, val: Self::Element) {
38        self.matrix_mut_unchecked().replace(i, val.into_inner())
39    }
40
41    #[inline]
42    unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
43        self.matrix_mut_unchecked()
44            .replace_unchecked(i, val.into_inner())
45    }
46
47    #[inline]
48    fn select(self, cond: Self::SimdBool, other: Self) -> Self {
49        Transform::from_matrix_unchecked(self.into_inner().select(cond, other.into_inner()))
50    }
51}