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<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
16 + Allocator<T::Element, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
17{
18 type Element = Transform<T::Element, C, D>;
19 type SimdBool = T::SimdBool;
20
21 #[inline]
22 fn lanes() -> usize {
23 T::lanes()
24 }
25
26 #[inline]
27 fn splat(val: Self::Element) -> Self {
28 Transform::from_matrix_unchecked(OMatrix::splat(val.into_inner()))
29 }
30
31 #[inline]
32 fn extract(&self, i: usize) -> Self::Element {
33 Transform::from_matrix_unchecked(self.matrix().extract(i))
34 }
35
36 #[inline]
37 unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
38 Transform::from_matrix_unchecked(self.matrix().extract_unchecked(i))
39 }
40
41 #[inline]
42 fn replace(&mut self, i: usize, val: Self::Element) {
43 self.matrix_mut_unchecked().replace(i, val.into_inner())
44 }
45
46 #[inline]
47 unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
48 self.matrix_mut_unchecked()
49 .replace_unchecked(i, val.into_inner())
50 }
51
52 #[inline]
53 fn select(self, cond: Self::SimdBool, other: Self) -> Self {
54 Transform::from_matrix_unchecked(self.into_inner().select(cond, other.into_inner()))
55 }
56}