From d5140aa47650f9a8ec8044d158d1e96b7de648f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 6 Aug 2023 13:45:59 +0200 Subject: [PATCH] Implement Copy for all non-mut shape views --- CHANGELOG.md | 3 +++ src/geometry/shape_views/ball.rs | 1 + src/geometry/shape_views/capsule.rs | 1 + src/geometry/shape_views/collider_view.rs | 1 + src/geometry/shape_views/compound.rs | 1 + src/geometry/shape_views/cone.rs | 1 + src/geometry/shape_views/convex_polygon.rs | 1 + src/geometry/shape_views/convex_polyhedron.rs | 1 + src/geometry/shape_views/cuboid.rs | 1 + src/geometry/shape_views/cylinder.rs | 1 + src/geometry/shape_views/halfspace.rs | 1 + src/geometry/shape_views/heightfield.rs | 1 + src/geometry/shape_views/polyline.rs | 1 + src/geometry/shape_views/round_shape.rs | 1 + src/geometry/shape_views/segment.rs | 1 + src/geometry/shape_views/triangle.rs | 1 + src/geometry/shape_views/trimesh.rs | 1 + 17 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71df4c34..1204da4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased ### Added +- `ColliderView::as_typed_shape` and `::to_shared_shape` to convert a `ColliderView` to a parry’s + `TypedShape` or `SharedShape`. The `From` trait has also been implemented accordingly. +- Implement `Copy` for `ColliderView` and all the other non-mut shape views. - Add `RapierContext::rigid_body_colliders` to retrieve all collider entities attached to this rigid-body. ## 0.22.0 (10 July 2023) diff --git a/src/geometry/shape_views/ball.rs b/src/geometry/shape_views/ball.rs index 3f4878fb..7964cb28 100644 --- a/src/geometry/shape_views/ball.rs +++ b/src/geometry/shape_views/ball.rs @@ -2,6 +2,7 @@ use crate::math::Real; use rapier::parry::shape::Ball; /// Read-only access to the properties of a ball. +#[derive(Copy, Clone)] pub struct BallView<'a> { /// The raw shape from Rapier. pub raw: &'a Ball, diff --git a/src/geometry/shape_views/capsule.rs b/src/geometry/shape_views/capsule.rs index 2391d0d4..8db6f210 100644 --- a/src/geometry/shape_views/capsule.rs +++ b/src/geometry/shape_views/capsule.rs @@ -3,6 +3,7 @@ use crate::math::{Real, Rot, Vect}; use rapier::parry::shape::Capsule; /// Read-only access to the properties of a capsule. +#[derive(Copy, Clone)] pub struct CapsuleView<'a> { /// The raw shape from Rapier. pub raw: &'a Capsule, diff --git a/src/geometry/shape_views/collider_view.rs b/src/geometry/shape_views/collider_view.rs index f69ef842..2cf2107b 100644 --- a/src/geometry/shape_views/collider_view.rs +++ b/src/geometry/shape_views/collider_view.rs @@ -7,6 +7,7 @@ use rapier::parry::either::Either; use rapier::parry::shape::TypedShape; /// Read-only access to the properties of a collider. +#[derive(Copy, Clone)] pub enum ColliderView<'a> { /// A ball shape. Ball(BallView<'a>), diff --git a/src/geometry/shape_views/compound.rs b/src/geometry/shape_views/compound.rs index 96469333..860628eb 100644 --- a/src/geometry/shape_views/compound.rs +++ b/src/geometry/shape_views/compound.rs @@ -3,6 +3,7 @@ use crate::math::{Rot, Vect}; use rapier::parry::shape::Compound; /// Read-only access to the properties of a compound shape. +#[derive(Copy, Clone)] pub struct CompoundView<'a> { /// The raw shape from Rapier. pub raw: &'a Compound, diff --git a/src/geometry/shape_views/cone.rs b/src/geometry/shape_views/cone.rs index 3ffab2ac..3c3b1965 100644 --- a/src/geometry/shape_views/cone.rs +++ b/src/geometry/shape_views/cone.rs @@ -2,6 +2,7 @@ use crate::math::Real; use rapier::parry::shape::Cone; /// Read-only access to the properties of a cone. +#[derive(Copy, Clone)] pub struct ConeView<'a> { /// The raw shape from Rapier. pub raw: &'a Cone, diff --git a/src/geometry/shape_views/convex_polygon.rs b/src/geometry/shape_views/convex_polygon.rs index 547cad52..5cccc800 100644 --- a/src/geometry/shape_views/convex_polygon.rs +++ b/src/geometry/shape_views/convex_polygon.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::parry::shape::ConvexPolygon; /// Read-only access to the properties of a convex polygon. +#[derive(Copy, Clone)] pub struct ConvexPolygonView<'a> { /// The raw shape from Rapier. pub raw: &'a ConvexPolygon, diff --git a/src/geometry/shape_views/convex_polyhedron.rs b/src/geometry/shape_views/convex_polyhedron.rs index 5b977dea..2ea6a751 100644 --- a/src/geometry/shape_views/convex_polyhedron.rs +++ b/src/geometry/shape_views/convex_polyhedron.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::parry::shape::ConvexPolyhedron; /// Read-only access to the properties of a convex polyhedron. +#[derive(Copy, Clone)] pub struct ConvexPolyhedronView<'a> { /// The raw shape from Rapier. pub raw: &'a ConvexPolyhedron, diff --git a/src/geometry/shape_views/cuboid.rs b/src/geometry/shape_views/cuboid.rs index 3bf8c149..443afee6 100644 --- a/src/geometry/shape_views/cuboid.rs +++ b/src/geometry/shape_views/cuboid.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::geometry::Cuboid; /// Read-only access to the properties of a cuboid. +#[derive(Copy, Clone)] pub struct CuboidView<'a> { /// The raw shape from Rapier. pub raw: &'a Cuboid, diff --git a/src/geometry/shape_views/cylinder.rs b/src/geometry/shape_views/cylinder.rs index ab00d260..f7e59ea6 100644 --- a/src/geometry/shape_views/cylinder.rs +++ b/src/geometry/shape_views/cylinder.rs @@ -2,6 +2,7 @@ use crate::math::Real; use rapier::parry::shape::Cylinder; /// Read-only access to the properties of a cylinder. +#[derive(Copy, Clone)] pub struct CylinderView<'a> { /// The raw shape from Rapier. pub raw: &'a Cylinder, diff --git a/src/geometry/shape_views/halfspace.rs b/src/geometry/shape_views/halfspace.rs index 287f3f00..59974b05 100644 --- a/src/geometry/shape_views/halfspace.rs +++ b/src/geometry/shape_views/halfspace.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::parry::shape::HalfSpace; /// Read-only access to the properties of a half-space. +#[derive(Copy, Clone)] pub struct HalfSpaceView<'a> { /// The raw shape from Rapier. pub raw: &'a HalfSpace, diff --git a/src/geometry/shape_views/heightfield.rs b/src/geometry/shape_views/heightfield.rs index 022c084f..8efa4d05 100644 --- a/src/geometry/shape_views/heightfield.rs +++ b/src/geometry/shape_views/heightfield.rs @@ -3,6 +3,7 @@ use rapier::parry::shape::HeightField; pub use rapier::parry::shape::HeightFieldCellStatus; /// Read-only access to the properties of a heightfield. +#[derive(Copy, Clone)] pub struct HeightFieldView<'a> { /// The raw shape from Rapier. pub raw: &'a HeightField, diff --git a/src/geometry/shape_views/polyline.rs b/src/geometry/shape_views/polyline.rs index 57489dd3..eb811d77 100644 --- a/src/geometry/shape_views/polyline.rs +++ b/src/geometry/shape_views/polyline.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::parry::shape::Polyline; /// Read-only access to the properties of a polyline. +#[derive(Copy, Clone)] pub struct PolylineView<'a> { /// The raw shape from Rapier. pub raw: &'a Polyline, diff --git a/src/geometry/shape_views/round_shape.rs b/src/geometry/shape_views/round_shape.rs index 6b569cb9..936a1170 100644 --- a/src/geometry/shape_views/round_shape.rs +++ b/src/geometry/shape_views/round_shape.rs @@ -19,6 +19,7 @@ use { macro_rules! round_shape_view( ($RoundShape: ident, $RoundShapeView: ident, $ShapeView: ident, $RoundShapeViewMut: ident, $ShapeViewMut: ident) => { /// Read-only access to the properties of a round shape. + #[derive(Copy, Clone)] pub struct $RoundShapeView<'a> { /// The raw shape from Rapier. pub raw: &'a $RoundShape, diff --git a/src/geometry/shape_views/segment.rs b/src/geometry/shape_views/segment.rs index 0a4fc855..e3acf3b7 100644 --- a/src/geometry/shape_views/segment.rs +++ b/src/geometry/shape_views/segment.rs @@ -2,6 +2,7 @@ use crate::math::{Real, Vect}; use rapier::parry::shape::Segment; /// Read-only access to the properties of a segment. +#[derive(Copy, Clone)] pub struct SegmentView<'a> { /// The raw shape from Rapier. pub raw: &'a Segment, diff --git a/src/geometry/shape_views/triangle.rs b/src/geometry/shape_views/triangle.rs index 4b0a2f78..d676689b 100644 --- a/src/geometry/shape_views/triangle.rs +++ b/src/geometry/shape_views/triangle.rs @@ -2,6 +2,7 @@ use crate::math::{Real, Vect}; use rapier::parry::shape::Triangle; /// Read-only access to the properties of a triangle. +#[derive(Copy, Clone)] pub struct TriangleView<'a> { /// The raw shape from Rapier. pub raw: &'a Triangle, diff --git a/src/geometry/shape_views/trimesh.rs b/src/geometry/shape_views/trimesh.rs index a935ca80..9a94146e 100644 --- a/src/geometry/shape_views/trimesh.rs +++ b/src/geometry/shape_views/trimesh.rs @@ -2,6 +2,7 @@ use crate::math::Vect; use rapier::parry::shape::{TopologyError, TriMesh, TriMeshFlags}; /// Read-only access to the properties of a triangle mesh. +#[derive(Copy, Clone)] pub struct TriMeshView<'a> { /// The raw shape from Rapier. pub raw: &'a TriMesh,