various implementations
This commit is contained in:
parent
a725faaf6a
commit
9a98b0cf24
|
@ -71,7 +71,7 @@ nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
|
|||
typenum = "1.12"
|
||||
rand-package = { package = "rand", version = "0.8", optional = true, default-features = false }
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
num-complex = { version = "0.4", default-features = false }
|
||||
num-complex = { version = "0.4", default-features = false } # { version = "0.4", default-features = false }
|
||||
num-rational = { version = "0.4", default-features = false }
|
||||
approx = { version = "0.5", default-features = false }
|
||||
simba = { version = "0.7", default-features = false }
|
||||
|
@ -80,7 +80,7 @@ rand_distr = { version = "0.4", default-features = false, optional = true }
|
|||
matrixmultiply = { version = "0.3", optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
||||
rkyv = { version = "0.7", optional = true }
|
||||
rkyv_wrappers = { git = "https://github.com/rkyv/rkyv_contrib", optional = true }
|
||||
rkyv_wrappers = { git = "https://github.com/rkyv/rkyv_contrib", optional = true }
|
||||
bytecheck = { version = "~0.6.1", optional = true }
|
||||
mint = { version = "0.5", optional = true }
|
||||
quickcheck = { version = "1", optional = true }
|
||||
|
|
|
@ -30,9 +30,9 @@ use std::mem;
|
|||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Self", bound(archive = "
|
||||
T: rkyv::Archive<Archived = T>,
|
||||
[[T; R]; C]: rkyv::Archive<Archived = [[T; R]; C]>
|
||||
archive(as = "ArrayStorage<T::Archived, R, C>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
[[T; R]; C]: rkyv::Archive<Archived = [[T::Archived; R]; C]>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
|
|
|
@ -21,11 +21,14 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
|||
/// in their documentation, read their dedicated pages directly.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Unit<T::Archived>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Unit<T> {
|
||||
pub(crate) value: T,
|
||||
|
|
|
@ -43,7 +43,11 @@ use simba::scalar::{ClosedNeg, RealField};
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "DualQuaternion<T::Archived>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
Quaternion<T>: rkyv::Archive<Archived = Quaternion<T::Archived>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct DualQuaternion<T> {
|
||||
|
|
|
@ -68,7 +68,12 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
|||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Isometry<T::Archived, R::Archived, D>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
R: rkyv::Archive,
|
||||
Translation<T, D>: rkyv::Archive<Archived = Translation<T::Archived, D>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
pub struct Isometry<T, R, const D: usize> {
|
||||
|
|
|
@ -22,7 +22,11 @@ use crate::geometry::{Point3, Projective3};
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Orthographic3<T::Archived>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
Matrix4<T>: rkyv::Archive<Archived = Matrix4<T::Archived>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
@ -23,7 +23,11 @@ use crate::geometry::{Point3, Projective3};
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Perspective3<T::Archived>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
Matrix4<T>: rkyv::Archive<Archived = Matrix4<T::Archived>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
@ -26,7 +26,11 @@ use crate::geometry::{Point3, Rotation};
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Quaternion<T::Archived>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
Vector4<T>: rkyv::Archive<Archived = Vector4<T::Archived>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Quaternion<T> {
|
||||
|
|
|
@ -52,7 +52,11 @@ use crate::geometry::Point;
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Rotation<T::Archived, D>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
SMatrix<T, D, D>: rkyv::Archive<Archived = SMatrix<T::Archived, D, D>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
@ -20,7 +20,11 @@ use crate::geometry::Point;
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Scale<T::Archived, D>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
SVector<T, D>: rkyv::Archive<Archived = SVector<T::Archived, D>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
@ -36,7 +36,12 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation};
|
|||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Similarity<T::Archived, R::Archived, D>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
R: rkyv::Archive,
|
||||
Isometry<T, R, D>: rkyv::Archive<Archived = Isometry<T::Archived, R::Archived, D>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
pub struct Similarity<T, R, const D: usize> {
|
||||
|
|
|
@ -20,7 +20,11 @@ use crate::geometry::Point;
|
|||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(as = "Translation<T::Archived, D>", bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
SVector<T, D>: rkyv::Archive<Archived = SVector<T::Archived, D>>
|
||||
"))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
@ -6,9 +6,9 @@ use na::{
|
|||
SimilarityMatrix3, Translation2, Translation3, Unit, Vector2,
|
||||
};
|
||||
use rand;
|
||||
use rkyv::{Archive, Serialize, Deserialize};
|
||||
use rkyv::{Archive, Serialize, Deserialize, Infallible};
|
||||
|
||||
macro_rules! test_rkyv(
|
||||
macro_rules! test_rkyv_archived_impls(
|
||||
($($test: ident, $ty: ident);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $test() {
|
||||
|
@ -22,20 +22,36 @@ macro_rules! test_rkyv(
|
|||
}
|
||||
)*}
|
||||
);
|
||||
macro_rules! test_rkyv(
|
||||
($($test: ident, $ty: ident);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $test() {
|
||||
let value: $ty<f32> = rand::random();
|
||||
let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap();
|
||||
|
||||
let archived = rkyv::check_archived_root::<$ty<f32>>(&bytes[..]).unwrap();
|
||||
let deserialized: $ty<f32> = archived.deserialize(&mut Infallible).unwrap();
|
||||
assert_eq!(deserialized, value);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
test_rkyv_archived_impls!(
|
||||
rkyv_matrix3x4, Matrix3x4;
|
||||
);
|
||||
|
||||
test_rkyv!(
|
||||
rkyv_matrix3x4, Matrix3x4;
|
||||
// rkyv_point3, Point3;
|
||||
/* rkyv_translation3, Translation3;
|
||||
rkyv_rotation3, Rotation3;
|
||||
rkyv_translation3, Translation3;
|
||||
/* rkyv_rotation3, Rotation3;
|
||||
rkyv_isometry3, Isometry3;
|
||||
rkyv_isometry_matrix3, IsometryMatrix3;
|
||||
rkyv_similarity3, Similarity3;
|
||||
rkyv_similarity_matrix3, SimilarityMatrix3;
|
||||
rkyv_quaternion, Quaternion;
|
||||
rkyv_point2, Point2;
|
||||
rkyv_quaternion, Quaternion; */
|
||||
// rkyv_point2, Point2;
|
||||
rkyv_translation2, Translation2;
|
||||
rkyv_rotation2, Rotation2;
|
||||
/* rkyv_rotation2, Rotation2;
|
||||
rkyv_isometry2, Isometry2;
|
||||
rkyv_isometry_matrix2, IsometryMatrix2;
|
||||
rkyv_similarity2, Similarity2;
|
||||
|
|
Loading…
Reference in New Issue