diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index 1580bcb7..9c4d26e1 100644 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.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, ClosedNeg}; use core::{Scalar, ColumnVector, OwnedSquareMatrix}; @@ -50,6 +53,25 @@ impl<'de, N, D, S> Deserialize<'de> for TranslationBase } } +#[cfg(feature = "abomonation-serialize")] +impl Abomonation for TranslationBase + where N: Scalar, + D: DimName, + ColumnVector: Abomonation +{ + unsafe fn entomb(&self, writer: &mut Vec) { + self.vector.entomb(writer) + } + + unsafe fn embalm(&mut self) { + self.vector.embalm() + } + + unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> { + self.vector.exhume(bytes) + } +} + impl TranslationBase where N: Scalar, S: Storage { diff --git a/tests/abomonation.rs b/tests/abomonation.rs index 1fd694cd..d50091a9 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}; +use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3}; #[test] fn abomonate_matrix3x4() { @@ -21,6 +21,11 @@ fn abomonate_dmatrix() { assert_encode_and_decode(&DMatrix::::new_random(3, 5)); } +#[test] +fn abomonate_translation3() { + assert_encode_and_decode(&random::>()); +} + fn assert_encode_and_decode(data: &T) { let mut bytes = Vec::new(); unsafe { encode(data, &mut bytes); }