diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 1429830a..e9f06b69 100644 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -5,6 +5,9 @@ use approx::ApproxEq; #[cfg(feature = "serde-serialize")] use serde::{Serialize, Serializer, Deserialize, Deserializer}; +#[cfg(feature = "abomonation-serialize")] +use abomonation::Abomonation; + use alga::general::Real; use core::{SquareMatrix, Scalar, OwnedSquareMatrix}; @@ -49,6 +52,25 @@ impl<'de, N, D, S> Deserialize<'de> for RotationBase } } +#[cfg(feature = "abomonation-serialize")] +impl Abomonation for RotationBase + where N: Scalar, + D: DimName, + SquareMatrix: Abomonation +{ + unsafe fn entomb(&self, writer: &mut Vec) { + self.matrix.entomb(writer) + } + + unsafe fn embalm(&mut self) { + self.matrix.embalm() + } + + unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { + self.matrix.exhume(bytes) + } +} + impl> RotationBase where N: Scalar, S: Storage { diff --git a/tests/abomonation.rs b/tests/abomonation.rs index d50091a9..8861342b 100644 --- a/tests/abomonation.rs +++ b/tests/abomonation.rs @@ -4,7 +4,7 @@ extern crate abomonation; use rand::random; use abomonation::{Abomonation, encode, decode}; -use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3}; +use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3, Rotation3}; #[test] fn abomonate_matrix3x4() { @@ -26,6 +26,11 @@ fn abomonate_translation3() { assert_encode_and_decode(&random::>()); } +#[test] +fn abomonate_rotation3() { + assert_encode_and_decode(&random::>()); +} + fn assert_encode_and_decode(data: &T) { let mut bytes = Vec::new(); unsafe { encode(data, &mut bytes); }