diff --git a/crates/parry2d-f64/Cargo.toml b/crates/parry2d-f64/Cargo.toml index 075304cf..46bf144e 100644 --- a/crates/parry2d-f64/Cargo.toml +++ b/crates/parry2d-f64/Cargo.toml @@ -24,6 +24,7 @@ dim2 = [ ] f64 = [ ] serde-serialize = [ "serde", "nalgebra/serde-serialize", "arrayvec/serde" ] rkyv-serialize = [ "rkyv", "nalgebra/rkyv-serialize", "simba/rkyv-serialize" ] +rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ] bytemuck-serialize = [ "bytemuck", "nalgebra/convert-bytemuck" ] simd-stable = [ "simba/wide", "simd-is-enabled" ] simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ] @@ -52,7 +53,7 @@ simba = { version = "0.8", default-features = false } nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -rkyv = { version = "0.7", optional = true } +rkyv = { version = "0.7.41", optional = true } num-derive = "0.3" indexmap = { version = "1", features = [ "serde-1" ], optional = true } rustc-hash = { version = "1", optional = true } diff --git a/crates/parry2d/Cargo.toml b/crates/parry2d/Cargo.toml index 0b970dc5..0ea08601 100644 --- a/crates/parry2d/Cargo.toml +++ b/crates/parry2d/Cargo.toml @@ -24,6 +24,7 @@ dim2 = [ ] f32 = [ ] serde-serialize = [ "serde", "nalgebra/serde-serialize", "arrayvec/serde" ] rkyv-serialize = [ "rkyv", "nalgebra/rkyv-serialize", "simba/rkyv-serialize" ] +rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ] bytemuck-serialize = [ "bytemuck", "nalgebra/convert-bytemuck" ] simd-stable = [ "simba/wide", "simd-is-enabled" ] simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ] @@ -52,7 +53,7 @@ simba = { version = "0.8", default-features = false } nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -rkyv = { version = "0.7", optional = true } +rkyv = { version = "0.7.41", optional = true } num-derive = "0.3" indexmap = { version = "1", features = [ "serde-1" ], optional = true } rustc-hash = { version = "1", optional = true } diff --git a/crates/parry3d-f64/Cargo.toml b/crates/parry3d-f64/Cargo.toml index 32e46a4e..d8cea1b5 100644 --- a/crates/parry3d-f64/Cargo.toml +++ b/crates/parry3d-f64/Cargo.toml @@ -24,6 +24,7 @@ dim3 = [ ] f64 = [ ] serde-serialize = [ "serde", "nalgebra/serde-serialize" ] rkyv-serialize = [ "rkyv", "nalgebra/rkyv-serialize", "simba/rkyv-serialize" ] +rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ] bytemuck-serialize = [ "bytemuck", "nalgebra/convert-bytemuck" ] simd-stable = [ "simba/wide", "simd-is-enabled" ] simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ] @@ -52,7 +53,7 @@ simba = { version = "0.8", default-features = false } nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive", "rc"]} -rkyv = { version = "0.7", optional = true } +rkyv = { version = "0.7.41", optional = true } num-derive = "0.3" indexmap = { version = "1", features = [ "serde-1" ], optional = true } rustc-hash = { version = "1", optional = true } diff --git a/crates/parry3d/Cargo.toml b/crates/parry3d/Cargo.toml index 0bbeeac7..c4dea4f3 100644 --- a/crates/parry3d/Cargo.toml +++ b/crates/parry3d/Cargo.toml @@ -24,6 +24,7 @@ dim3 = [ ] f32 = [ ] serde-serialize = [ "serde", "nalgebra/serde-serialize" ] rkyv-serialize = [ "rkyv", "nalgebra/rkyv-serialize", "simba/rkyv-serialize" ] +rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ] bytemuck-serialize = [ "bytemuck", "nalgebra/convert-bytemuck" ] simd-stable = [ "simba/wide", "simd-is-enabled" ] @@ -53,7 +54,7 @@ simba = { version = "0.8", default-features = false } nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive", "rc"]} -rkyv = { version = "0.7", optional = true } +rkyv = { version = "0.7.41", optional = true } num-derive = "0.3" indexmap = { version = "1", features = [ "serde-1" ], optional = true } rustc-hash = { version = "1", optional = true } diff --git a/src/bounding_volume/aabb.rs b/src/bounding_volume/aabb.rs index c559a6f4..59443bf2 100644 --- a/src/bounding_volume/aabb.rs +++ b/src/bounding_volume/aabb.rs @@ -19,6 +19,7 @@ use na::ComplexField; // for .abs() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Debug, PartialEq, Copy, Clone)] #[repr(C)] diff --git a/src/bounding_volume/bounding_sphere.rs b/src/bounding_volume/bounding_sphere.rs index 25743296..26cb0699 100644 --- a/src/bounding_volume/bounding_sphere.rs +++ b/src/bounding_volume/bounding_sphere.rs @@ -13,6 +13,7 @@ use num::Zero; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Debug, PartialEq, Copy, Clone)] #[repr(C)] pub struct BoundingSphere { diff --git a/src/bounding_volume/simd_aabb.rs b/src/bounding_volume/simd_aabb.rs index 15a7c090..400a40d2 100644 --- a/src/bounding_volume/simd_aabb.rs +++ b/src/bounding_volume/simd_aabb.rs @@ -11,6 +11,7 @@ use simba::simd::{SimdPartialOrd, SimdValue}; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct SimdAabb { /// The min coordinates of the Aabbs. diff --git a/src/mass_properties/mass_properties.rs b/src/mass_properties/mass_properties.rs index 725731c3..82eeb933 100644 --- a/src/mass_properties/mass_properties.rs +++ b/src/mass_properties/mass_properties.rs @@ -15,6 +15,7 @@ const EPSILON: Real = f32::EPSILON as Real; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] /// The local mass properties of a rigid-body. pub struct MassProperties { /// The center of mass of a rigid-body expressed in its local-space. diff --git a/src/partitioning/qbvh/qbvh.rs b/src/partitioning/qbvh/qbvh.rs index 7c52c44c..26a310c7 100644 --- a/src/partitioning/qbvh/qbvh.rs +++ b/src/partitioning/qbvh/qbvh.rs @@ -62,6 +62,7 @@ pub type SimdNodeIndex = u32; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] /// The index of one specific node of a Qbvh. pub struct NodeIndex { @@ -117,6 +118,7 @@ bitflags! { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] pub struct QbvhNode { /// The Aabbs of the qbvh nodes represented by this node. @@ -190,6 +192,7 @@ impl QbvhNode { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] /// Combination of a leaf data and its associated node’s index. pub struct QbvhProxy { @@ -230,6 +233,7 @@ impl QbvhProxy { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[repr(C)] // Needed for Cuda. #[derive(Debug)] pub struct GenericQbvh> { diff --git a/src/query/closest_points/closest_points.rs b/src/query/closest_points/closest_points.rs index 991d360a..ec0b6e48 100644 --- a/src/query/closest_points/closest_points.rs +++ b/src/query/closest_points/closest_points.rs @@ -9,6 +9,7 @@ use std::mem; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub enum ClosestPoints { /// The two objects are intersecting. Intersecting, diff --git a/src/query/contact/contact.rs b/src/query/contact/contact.rs index d49bd380..93f1d08b 100644 --- a/src/query/contact/contact.rs +++ b/src/query/contact/contact.rs @@ -10,6 +10,7 @@ use std::mem; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct Contact { /// Position of the contact on the first object. pub point1: Point, diff --git a/src/query/contact_manifolds/contact_manifold.rs b/src/query/contact_manifolds/contact_manifold.rs index 1a3f25fd..06022204 100644 --- a/src/query/contact_manifolds/contact_manifold.rs +++ b/src/query/contact_manifolds/contact_manifold.rs @@ -7,6 +7,7 @@ use crate::shape::PackedFeatureId; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] /// A single contact between two shape. pub struct TrackedContact { /// The contact point in the local-space of the first shape. diff --git a/src/query/contact_manifolds/contact_manifolds_composite_shape_composite_shape.rs b/src/query/contact_manifolds/contact_manifolds_composite_shape_composite_shape.rs index f3680bbb..09355dcb 100644 --- a/src/query/contact_manifolds/contact_manifolds_composite_shape_composite_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_composite_shape_composite_shape.rs @@ -16,6 +16,7 @@ use crate::utils::IsometryOpt; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone)] struct SubDetector { manifold_id: usize, diff --git a/src/query/contact_manifolds/contact_manifolds_composite_shape_shape.rs b/src/query/contact_manifolds/contact_manifolds_composite_shape_shape.rs index 1f3ca8f6..9e15e7df 100644 --- a/src/query/contact_manifolds/contact_manifolds_composite_shape_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_composite_shape_shape.rs @@ -16,6 +16,7 @@ use crate::utils::IsometryOpt; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone)] struct SubDetector { manifold_id: usize, diff --git a/src/query/contact_manifolds/contact_manifolds_heightfield_composite_shape.rs b/src/query/contact_manifolds/contact_manifolds_heightfield_composite_shape.rs index c9a104d2..cad79210 100644 --- a/src/query/contact_manifolds/contact_manifolds_heightfield_composite_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_heightfield_composite_shape.rs @@ -21,6 +21,7 @@ use crate::query::contact_manifolds::InternalEdgesFixer; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone)] struct SubDetector { manifold_id: usize, diff --git a/src/query/contact_manifolds/contact_manifolds_heightfield_shape.rs b/src/query/contact_manifolds/contact_manifolds_heightfield_shape.rs index ad62e24e..e7b35910 100644 --- a/src/query/contact_manifolds/contact_manifolds_heightfield_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_heightfield_shape.rs @@ -19,6 +19,7 @@ use crate::query::contact_manifolds::InternalEdgesFixer; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone)] struct SubDetector { manifold_id: usize, diff --git a/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs b/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs index 26c09206..c8932b18 100644 --- a/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs +++ b/src/query/contact_manifolds/contact_manifolds_trimesh_shape.rs @@ -13,6 +13,7 @@ use crate::shape::{Shape, TriMesh}; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone)] pub struct TriMeshShapeContactManifoldsWorkspace { interferences: Vec, diff --git a/src/query/contact_manifolds/internal_edges_fixer.rs b/src/query/contact_manifolds/internal_edges_fixer.rs index 3dd066e2..168dbb55 100644 --- a/src/query/contact_manifolds/internal_edges_fixer.rs +++ b/src/query/contact_manifolds/internal_edges_fixer.rs @@ -10,6 +10,7 @@ use crate::math::Real; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Default, Clone)] #[allow(dead_code)] // We will need these for 2D too in the future. pub struct InternalEdgesFixer { diff --git a/src/query/point/point_query.rs b/src/query/point/point_query.rs index d1c4b8be..4c03da42 100644 --- a/src/query/point/point_query.rs +++ b/src/query/point/point_query.rs @@ -10,6 +10,7 @@ use na; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct PointProjection { /// Whether or not the point to project was inside of the shape. pub is_inside: bool, diff --git a/src/query/ray/ray.rs b/src/query/ray/ray.rs index 6876f08a..8a374afa 100644 --- a/src/query/ray/ray.rs +++ b/src/query/ray/ray.rs @@ -11,6 +11,7 @@ use crate::shape::FeatureId; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] pub struct Ray { @@ -64,6 +65,7 @@ impl Ray { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct RayIntersection { /// The time of impact of the ray with the object. The exact contact point can be computed /// with: `ray.point_at(toi)` or equivalently `origin + dir * toi` where `origin` is the origin of the ray; diff --git a/src/shape/ball.rs b/src/shape/ball.rs index 5f3e2461..8481bab7 100644 --- a/src/shape/ball.rs +++ b/src/shape/ball.rs @@ -8,10 +8,11 @@ use crate::shape::SupportMap; /// A Ball shape. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] -// #[cfg_attr( -// feature = "rkyv", -// derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) -// )] +#[cfg_attr( + feature = "rkyv", + derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) +)] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone)] #[repr(C)] diff --git a/src/shape/capsule.rs b/src/shape/capsule.rs index 93390be8..14d36572 100644 --- a/src/shape/capsule.rs +++ b/src/shape/capsule.rs @@ -13,6 +13,7 @@ use either::Either; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] /// A capsule shape defined as a round segment. diff --git a/src/shape/cone.rs b/src/shape/cone.rs index 1109b863..be6f50f1 100644 --- a/src/shape/cone.rs +++ b/src/shape/cone.rs @@ -19,6 +19,7 @@ use na::RealField; // for .copysign() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone)] #[repr(C)] diff --git a/src/shape/convex_polygon.rs b/src/shape/convex_polygon.rs index adb6ee41..40dbe9c7 100644 --- a/src/shape/convex_polygon.rs +++ b/src/shape/convex_polygon.rs @@ -9,6 +9,7 @@ use na::{self, ComplexField, RealField, Unit}; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Clone, Debug)] pub struct ConvexPolygon { points: Vec>, diff --git a/src/shape/convex_polyhedron.rs b/src/shape/convex_polyhedron.rs index 81c553a9..21ef641e 100644 --- a/src/shape/convex_polyhedron.rs +++ b/src/shape/convex_polyhedron.rs @@ -15,6 +15,7 @@ use na::ComplexField; // for .abs() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(PartialEq, Debug, Copy, Clone)] pub struct Vertex { pub first_adj_face_or_edge: u32, @@ -27,6 +28,7 @@ pub struct Vertex { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(PartialEq, Debug, Copy, Clone)] pub struct Edge { pub vertices: Point2, @@ -51,6 +53,7 @@ impl Edge { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(PartialEq, Debug, Copy, Clone)] pub struct Face { pub first_vertex_or_edge: u32, @@ -63,6 +66,7 @@ pub struct Face { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(PartialEq, Debug, Copy, Clone)] struct Triangle { vertices: [u32; 3], @@ -89,6 +93,7 @@ impl Triangle { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(PartialEq, Debug, Clone)] /// A convex polyhedron without degenerate faces. pub struct ConvexPolyhedron { diff --git a/src/shape/cuboid.rs b/src/shape/cuboid.rs index 06c43c1e..d1d54ee4 100644 --- a/src/shape/cuboid.rs +++ b/src/shape/cuboid.rs @@ -18,6 +18,7 @@ use na::RealField; // for .copysign() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone)] #[repr(C)] diff --git a/src/shape/cylinder.rs b/src/shape/cylinder.rs index b15a7267..adefe969 100644 --- a/src/shape/cylinder.rs +++ b/src/shape/cylinder.rs @@ -19,6 +19,7 @@ use na::RealField; // for .copysign() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone)] #[repr(C)] diff --git a/src/shape/feature_id.rs b/src/shape/feature_id.rs index 86a823c4..0b125d94 100644 --- a/src/shape/feature_id.rs +++ b/src/shape/feature_id.rs @@ -9,6 +9,7 @@ derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub enum FeatureId { /// Shape-dependent identifier of a vertex. @@ -62,6 +63,7 @@ impl FeatureId { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] /// A feature id where the feature type is packed into the same value as the feature index. pub struct PackedFeatureId(pub u32); diff --git a/src/shape/half_space.rs b/src/shape/half_space.rs index 8ce341e8..91055571 100644 --- a/src/shape/half_space.rs +++ b/src/shape/half_space.rs @@ -10,6 +10,7 @@ use na::Unit; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] pub struct HalfSpace { diff --git a/src/shape/heightfield2.rs b/src/shape/heightfield2.rs index 5bafbae6..06f462e8 100644 --- a/src/shape/heightfield2.rs +++ b/src/shape/heightfield2.rs @@ -55,6 +55,7 @@ impl HeightFieldStorage for CudaStoragePtr { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Debug)] #[repr(C)] // Needed for Cuda. /// A 2D heightfield with a generic storage buffer for its heights. diff --git a/src/shape/heightfield3.rs b/src/shape/heightfield3.rs index 303106b0..0179b8df 100644 --- a/src/shape/heightfield3.rs +++ b/src/shape/heightfield3.rs @@ -24,6 +24,7 @@ bitflags! { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] + #[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Default)] /// The status of the cell of an heightfield. @@ -70,6 +71,7 @@ impl HeightFieldStorage for CudaStoragePtr { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Debug)] #[repr(C)] // Needed for Cuda. /// A 3D heightfield with a generic storage buffer for its height grid. diff --git a/src/shape/polygon.rs b/src/shape/polygon.rs index 9796b534..fafbdbaa 100644 --- a/src/shape/polygon.rs +++ b/src/shape/polygon.rs @@ -9,6 +9,7 @@ use parry::bounding_volume::Aabb; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] /// A convex planar polygon. pub struct Polygon { pub(crate) vertices: Vec>, diff --git a/src/shape/polyline.rs b/src/shape/polyline.rs index 3e20c188..6eb1576b 100644 --- a/src/shape/polyline.rs +++ b/src/shape/polyline.rs @@ -15,6 +15,7 @@ use na::ComplexField; // for .abs() feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] /// A polyline. pub struct Polyline { qbvh: Qbvh, diff --git a/src/shape/round_shape.rs b/src/shape/round_shape.rs index ecaf9889..e11ce593 100644 --- a/src/shape/round_shape.rs +++ b/src/shape/round_shape.rs @@ -7,6 +7,7 @@ use na::Unit; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone, Debug)] #[repr(C)] diff --git a/src/shape/segment.rs b/src/shape/segment.rs index f31f58bd..a89170d8 100644 --- a/src/shape/segment.rs +++ b/src/shape/segment.rs @@ -14,6 +14,7 @@ use std::mem; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone)] #[repr(C)] diff --git a/src/shape/tetrahedron.rs b/src/shape/tetrahedron.rs index b2adf321..7cccbb9b 100644 --- a/src/shape/tetrahedron.rs +++ b/src/shape/tetrahedron.rs @@ -17,6 +17,7 @@ use na::ComplexField; // for .abs() derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(Copy, Clone, Debug)] #[repr(C)] diff --git a/src/shape/triangle.rs b/src/shape/triangle.rs index 4431cad9..3d4367f0 100644 --- a/src/shape/triangle.rs +++ b/src/shape/triangle.rs @@ -22,6 +22,7 @@ use crate::shape::PackedFeatureId; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[derive(PartialEq, Debug, Copy, Clone, Default)] #[repr(C)] diff --git a/src/shape/trimesh.rs b/src/shape/trimesh.rs index faa38080..efa9e00f 100644 --- a/src/shape/trimesh.rs +++ b/src/shape/trimesh.rs @@ -71,6 +71,7 @@ impl std::error::Error for TopologyError {} feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[repr(C)] // Needed for Cuda. #[cfg(feature = "dim3")] pub struct TriMeshPseudoNormals { @@ -108,6 +109,7 @@ impl TriMeshPseudoNormals { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[repr(C)] // Needed for Cuda. pub struct TriMeshConnectedComponents { /// The `face_colors[i]` gives the connected-component index @@ -158,6 +160,7 @@ impl TriMeshConnectedComponents { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] // Needed for Cuda. pub struct TopoVertex { @@ -173,6 +176,7 @@ pub struct TopoVertex { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] // Needed for Cuda. pub struct TopoFace { @@ -189,6 +193,7 @@ pub struct TopoFace { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] // Needed for Cuda. pub struct TopoHalfEdge { @@ -211,6 +216,7 @@ pub struct TopoHalfEdge { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[repr(C)] // Needed for Cuda. pub struct TriMeshTopology { /// The vertices of this half-edge representation. @@ -265,6 +271,7 @@ bitflags::bitflags! { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self") )] + #[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))] #[repr(C)] // Needed for Cuda. #[derive(Default)] @@ -338,6 +345,7 @@ bitflags::bitflags! { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[repr(C)] // Needed for Cuda. /// A triangle mesh. pub struct GenericTriMesh { diff --git a/src/utils/array.rs b/src/utils/array.rs index e0739c3b..e4672463 100644 --- a/src/utils/array.rs +++ b/src/utils/array.rs @@ -85,6 +85,7 @@ impl Array2 for DMatrix { feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] /// Default data storage based on `Vec`, `DVector`, and `DMatrix`. pub struct DefaultStorage; diff --git a/src/utils/sdp_matrix.rs b/src/utils/sdp_matrix.rs index b0f5e07e..8cffc868 100644 --- a/src/utils/sdp_matrix.rs +++ b/src/utils/sdp_matrix.rs @@ -10,6 +10,7 @@ use std::ops::{Add, Mul}; derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self", bound(archive = "N: rkyv::Archive")) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct SdpMatrix2 { /// The component at the first row and first column of this matrix. pub m11: N, @@ -116,6 +117,7 @@ impl Mul for SdpMatrix2 { derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize), archive(as = "Self", bound(archive = "N: rkyv::Archive")) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct SdpMatrix3 { /// The component at the first row and first column of this matrix. pub m11: N, diff --git a/src/utils/sorted_pair.rs b/src/utils/sorted_pair.rs index f87c86f2..f9358201 100644 --- a/src/utils/sorted_pair.rs +++ b/src/utils/sorted_pair.rs @@ -9,6 +9,7 @@ use std::ops::Deref; feature = "rkyv", derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize) )] +#[cfg_attr(feature = "rkyv-safe-deser", archive(check_bytes))] pub struct SortedPair([T; 2]); impl SortedPair {