use crate::nums::{bool32x4, f32x4, i32x4, u32x4, Num};
use crate::{
Mat3, Mat3x4, Quat, Quatx4, UnitQuat, UnitQuatx4, UnitVec3, UnitVec3x4, Vec2, Vec2x4, Vec3,
Vec3x4,
};
pub trait ExtratLaneExternal {
type Output;
fn extract_lane_ext(&self, i: usize) -> Self::Output;
#[inline]
fn first_lane(&self) -> Self::Output {
self.extract_lane_ext(0)
}
}
impl<T, const SIZE: usize> ExtratLaneExternal for [T; SIZE]
where
T: ExtratLaneExternal,
<T as ExtratLaneExternal>::Output: Default + Copy,
{
type Output = [<T as ExtratLaneExternal>::Output; SIZE];
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
let mut result: [<T as ExtratLaneExternal>::Output; SIZE] = [Default::default(); SIZE];
for j in 0..SIZE {
result[j] = self[j].extract_lane_ext(i);
}
result
}
}
impl ExtratLaneExternal for Vec3x4 {
type Output = Vec3;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}
impl ExtratLaneExternal for UnitVec3x4 {
type Output = UnitVec3;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}
impl ExtratLaneExternal for f32x4 {
type Output = f32;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
<f32x4 as Num>::extract(self, i)
}
}
impl ExtratLaneExternal for i32x4 {
type Output = i32;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
<i32x4 as Num>::extract(self, i)
}
}
impl ExtratLaneExternal for u32x4 {
type Output = u32;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
<u32x4 as Num>::extract(self, i)
}
}
impl ExtratLaneExternal for bool32x4 {
type Output = bool;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
<bool32x4 as Num>::extract(self, i)
}
}
impl ExtratLaneExternal for UnitQuatx4 {
type Output = UnitQuat;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}
impl ExtratLaneExternal for Quatx4 {
type Output = Quat;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}
impl ExtratLaneExternal for Vec2x4 {
type Output = Vec2;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}
impl ExtratLaneExternal for Mat3x4 {
type Output = Mat3;
#[inline]
fn extract_lane_ext(&self, i: usize) -> Self::Output {
self.extract_lane(i)
}
}