From 22ba88353a78420e6f523b8293f7e521a22b6b1d Mon Sep 17 00:00:00 2001 From: CAD97 Date: Fri, 9 Jul 2021 15:23:08 -0500 Subject: [PATCH] Fix bounds for bytemuck impls --- src/geometry/dual_quaternion.rs | 14 ++++++++++++-- src/geometry/orthographic.rs | 14 ++++++++++++-- src/geometry/perspective.rs | 14 ++++++++++++-- src/geometry/rotation.rs | 4 ++-- src/geometry/transform.rs | 7 +++++-- src/geometry/translation.rs | 4 ++-- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/geometry/dual_quaternion.rs b/src/geometry/dual_quaternion.rs index d745f1d3..376c5fbb 100644 --- a/src/geometry/dual_quaternion.rs +++ b/src/geometry/dual_quaternion.rs @@ -242,10 +242,20 @@ where } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Zeroable for DualQuaternion where Quaternion: bytemuck::Zeroable {} +unsafe impl bytemuck::Zeroable for DualQuaternion +where + T: Scalar + bytemuck::Zeroable, + Quaternion: bytemuck::Zeroable, +{ +} #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Pod for DualQuaternion where Quaternion: bytemuck::Pod {} +unsafe impl bytemuck::Pod for DualQuaternion +where + T: Scalar + bytemuck::Pod, + Quaternion: bytemuck::Pod, +{ +} #[cfg(feature = "serde-serialize-no-std")] impl Serialize for DualQuaternion diff --git a/src/geometry/orthographic.rs b/src/geometry/orthographic.rs index 836edc93..4f7b909b 100644 --- a/src/geometry/orthographic.rs +++ b/src/geometry/orthographic.rs @@ -46,10 +46,20 @@ impl PartialEq for Orthographic3 { } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Zeroable for Orthographic3 where Matrix4: bytemuck::Zeroable {} +unsafe impl bytemuck::Zeroable for Orthographic3 +where + T: RealField + bytemuck::Zeroable, + Matrix4: bytemuck::Zeroable, +{ +} #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Pod for Orthographic3 where Matrix4: bytemuck::Pod {} +unsafe impl bytemuck::Pod for Orthographic3 +where + T: RealField + bytemuck::Pod, + Matrix4: bytemuck::Pod, +{ +} #[cfg(feature = "serde-serialize-no-std")] impl Serialize for Orthographic3 { diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index 08b2608b..90cf95d8 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -47,10 +47,20 @@ impl PartialEq for Perspective3 { } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Zeroable for Perspective3 where Matrix4: bytemuck::Zeroable {} +unsafe impl bytemuck::Zeroable for Perspective3 +where + T: RealField + bytemuck::Zeroable, + Matrix4: bytemuck::Zeroable, +{ +} #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Pod for Perspective3 where Matrix4: bytemuck::Pod {} +unsafe impl bytemuck::Pod for Perspective3 +where + T: RealField + bytemuck::Pod, + Matrix4: bytemuck::Pod, +{ +} #[cfg(feature = "serde-serialize-no-std")] impl Serialize for Perspective3 { diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 89bc082f..6fd9e803 100755 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -86,7 +86,7 @@ where #[cfg(feature = "bytemuck")] unsafe impl bytemuck::Zeroable for Rotation where - T: Scalar, + T: Scalar + bytemuck::Zeroable, SMatrix: bytemuck::Zeroable, { } @@ -94,7 +94,7 @@ where #[cfg(feature = "bytemuck")] unsafe impl bytemuck::Pod for Rotation where - T: Scalar, + T: Scalar + bytemuck::Pod, SMatrix: bytemuck::Pod, { } diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 051fd3d5..51a8f64d 100755 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -195,8 +195,9 @@ where } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Zeroable for Transform +unsafe impl bytemuck::Zeroable for Transform where + T: RealField + bytemuck::Zeroable, Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, OMatrix, U1>, DimNameSum, U1>>: bytemuck::Zeroable, @@ -204,11 +205,13 @@ where } #[cfg(feature = "bytemuck")] -unsafe impl bytemuck::Pod for Transform +unsafe impl bytemuck::Pod for Transform where + T: RealField + bytemuck::Pod, Const: DimNameAdd, DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, OMatrix, U1>, DimNameSum, U1>>: bytemuck::Pod, + Owned, U1>, DimNameSum, U1>>: Copy, { } diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 758a21ca..7de9bb04 100755 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -53,7 +53,7 @@ where #[cfg(feature = "bytemuck")] unsafe impl bytemuck::Zeroable for Translation where - T: Scalar, + T: Scalar + bytemuck::Zeroable, SVector: bytemuck::Zeroable, { } @@ -61,7 +61,7 @@ where #[cfg(feature = "bytemuck")] unsafe impl bytemuck::Pod for Translation where - T: Scalar, + T: Scalar + bytemuck::Pod, SVector: bytemuck::Pod, { }