forked from M-Labs/nalgebra
Merge pull request #925 from CAD97/bytemuck
Impl bytemuck traits for geometry types
This commit is contained in:
commit
99a79d51f5
@ -250,6 +250,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Zeroable for DualQuaternion<T>
|
||||
where
|
||||
T: Scalar + bytemuck::Zeroable,
|
||||
Quaternion<T>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Pod for DualQuaternion<T>
|
||||
where
|
||||
T: Scalar + bytemuck::Pod,
|
||||
Quaternion<T>: bytemuck::Pod,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T: SimdRealField> Serialize for DualQuaternion<T>
|
||||
where
|
||||
|
@ -18,6 +18,7 @@ use crate::base::{Matrix4, Vector, Vector3};
|
||||
use crate::geometry::{Point3, Projective3};
|
||||
|
||||
/// A 3D orthographic projection stored as a homogeneous 4x4 matrix.
|
||||
#[repr(C)]
|
||||
pub struct Orthographic3<T> {
|
||||
matrix: Matrix4<T>,
|
||||
}
|
||||
@ -44,6 +45,22 @@ impl<T: RealField> PartialEq for Orthographic3<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Zeroable for Orthographic3<T>
|
||||
where
|
||||
T: RealField + bytemuck::Zeroable,
|
||||
Matrix4<T>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Pod for Orthographic3<T>
|
||||
where
|
||||
T: RealField + bytemuck::Pod,
|
||||
Matrix4<T>: bytemuck::Pod,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T: RealField + Serialize> Serialize for Orthographic3<T> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
@ -19,6 +19,7 @@ use crate::base::{Matrix4, Vector, Vector3};
|
||||
use crate::geometry::{Point3, Projective3};
|
||||
|
||||
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
||||
#[repr(C)]
|
||||
pub struct Perspective3<T> {
|
||||
matrix: Matrix4<T>,
|
||||
}
|
||||
@ -45,6 +46,22 @@ impl<T: RealField> PartialEq for Perspective3<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Zeroable for Perspective3<T>
|
||||
where
|
||||
T: RealField + bytemuck::Zeroable,
|
||||
Matrix4<T>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T> bytemuck::Pod for Perspective3<T>
|
||||
where
|
||||
T: RealField + bytemuck::Pod,
|
||||
Matrix4<T>: bytemuck::Pod,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T: RealField + Serialize> Serialize for Perspective3<T> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
@ -83,6 +83,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, const D: usize> bytemuck::Zeroable for Rotation<T, D>
|
||||
where
|
||||
T: Scalar + bytemuck::Zeroable,
|
||||
SMatrix<T, D, D>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, const D: usize> bytemuck::Pod for Rotation<T, D>
|
||||
where
|
||||
T: Scalar + bytemuck::Pod,
|
||||
SMatrix<T, D, D>: bytemuck::Pod,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
impl<T, const D: usize> Abomonation for Rotation<T, D>
|
||||
where
|
||||
|
@ -197,6 +197,27 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, C: TCategory, const D: usize> bytemuck::Zeroable for Transform<T, C, D>
|
||||
where
|
||||
T: RealField + bytemuck::Zeroable,
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, C: TCategory, const D: usize> bytemuck::Pod for Transform<T, C, D>
|
||||
where
|
||||
T: RealField + bytemuck::Pod,
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: bytemuck::Pod,
|
||||
Owned<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>: Copy,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde-serialize-no-std")]
|
||||
impl<T: RealField, C: TCategory, const D: usize> Serialize for Transform<T, C, D>
|
||||
where
|
||||
|
@ -50,6 +50,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, const D: usize> bytemuck::Zeroable for Translation<T, D>
|
||||
where
|
||||
T: Scalar + bytemuck::Zeroable,
|
||||
SVector<T, D>: bytemuck::Zeroable,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "bytemuck")]
|
||||
unsafe impl<T, const D: usize> bytemuck::Pod for Translation<T, D>
|
||||
where
|
||||
T: Scalar + bytemuck::Pod,
|
||||
SVector<T, D>: bytemuck::Pod,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(feature = "abomonation-serialize")]
|
||||
impl<T, const D: usize> Abomonation for Translation<T, D>
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user