nalgebra/src/geometry/transform_simba.rs

57 lines
1.6 KiB
Rust
Raw Normal View History

2020-03-21 19:16:46 +08:00
use simba::simd::SimdValue;
use crate::base::allocator::Allocator;
use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
2021-04-11 17:00:38 +08:00
use crate::base::{Const, DefaultAllocator, OMatrix, Scalar};
2020-03-21 19:16:46 +08:00
use crate::RealField;
use crate::geometry::{TCategory, Transform};
2021-04-11 17:00:38 +08:00
impl<T: RealField, C, const D: usize> SimdValue for Transform<T, C, D>
2020-03-21 19:16:46 +08:00
where
2021-04-11 17:00:38 +08:00
T::Element: Scalar,
2020-03-21 19:16:46 +08:00
C: TCategory,
Const<D>: DimNameAdd<U1>,
2021-04-11 17:00:38 +08:00
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
+ Allocator<T::Element, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
2020-03-21 19:16:46 +08:00
{
2021-04-11 17:00:38 +08:00
type Element = Transform<T::Element, C, D>;
type SimdBool = T::SimdBool;
2020-03-21 19:16:46 +08:00
#[inline]
fn lanes() -> usize {
2021-04-11 17:00:38 +08:00
T::lanes()
2020-03-21 19:16:46 +08:00
}
#[inline]
fn splat(val: Self::Element) -> Self {
2021-04-11 17:00:38 +08:00
Transform::from_matrix_unchecked(OMatrix::splat(val.into_inner()))
2020-03-21 19:16:46 +08:00
}
#[inline]
fn extract(&self, i: usize) -> Self::Element {
Transform::from_matrix_unchecked(self.matrix().extract(i))
}
#[inline]
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
Transform::from_matrix_unchecked(self.matrix().extract_unchecked(i))
}
#[inline]
fn replace(&mut self, i: usize, val: Self::Element) {
self.matrix_mut_unchecked().replace(i, val.into_inner())
}
#[inline]
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
self.matrix_mut_unchecked()
.replace_unchecked(i, val.into_inner())
}
#[inline]
fn select(self, cond: Self::SimdBool, other: Self) -> Self {
Transform::from_matrix_unchecked(self.into_inner().select(cond, other.into_inner()))
}
}