@@ -80,7 +80,8 @@ impl std::ops::Neg for Direction2d {
8080}
8181
8282/// A circle primitive
83- #[ derive( Clone , Copy , Debug ) ]
83+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
84+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
8485pub struct Circle {
8586 /// The radius of the circle
8687 pub radius : f32 ,
@@ -115,7 +116,8 @@ impl Circle {
115116}
116117
117118/// An ellipse primitive
118- #[ derive( Clone , Copy , Debug ) ]
119+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
120+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
119121pub struct Ellipse {
120122 /// Half of the width and height of the ellipse.
121123 ///
@@ -160,7 +162,8 @@ impl Ellipse {
160162
161163/// An unbounded plane in 2D space. It forms a separating surface through the origin,
162164/// stretching infinitely far
163- #[ derive( Clone , Copy , Debug ) ]
165+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
166+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
164167pub struct Plane2d {
165168 /// The normal of the plane. The plane will be placed perpendicular to this direction
166169 pub normal : Direction2d ,
@@ -184,7 +187,8 @@ impl Plane2d {
184187/// An infinite line along a direction in 2D space.
185188///
186189/// For a finite line: [`Segment2d`]
187- #[ derive( Clone , Copy , Debug ) ]
190+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
191+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
188192pub struct Line2d {
189193 /// The direction of the line. The line extends infinitely in both the given direction
190194 /// and its opposite direction
@@ -194,7 +198,8 @@ impl Primitive2d for Line2d {}
194198
195199/// A segment of a line along a direction in 2D space.
196200#[ doc( alias = "LineSegment2d" ) ]
197- #[ derive( Clone , Debug ) ]
201+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
202+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
198203pub struct Segment2d {
199204 /// The direction of the line segment
200205 pub direction : Direction2d ,
@@ -241,9 +246,11 @@ impl Segment2d {
241246/// A series of connected line segments in 2D space.
242247///
243248/// For a version without generics: [`BoxedPolyline2d`]
244- #[ derive( Clone , Debug ) ]
249+ #[ derive( Clone , Debug , PartialEq ) ]
250+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
245251pub struct Polyline2d < const N : usize > {
246252 /// The vertices of the polyline
253+ #[ cfg_attr( feature = "serialize" , serde( with = "super::serde::array" ) ) ]
247254 pub vertices : [ Vec2 ; N ] ,
248255}
249256impl < const N : usize > Primitive2d for Polyline2d < N > { }
@@ -270,7 +277,8 @@ impl<const N: usize> Polyline2d<N> {
270277/// in a `Box<[Vec2]>`.
271278///
272279/// For a version without alloc: [`Polyline2d`]
273- #[ derive( Clone , Debug ) ]
280+ #[ derive( Clone , Debug , PartialEq ) ]
281+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
274282pub struct BoxedPolyline2d {
275283 /// The vertices of the polyline
276284 pub vertices : Box < [ Vec2 ] > ,
@@ -294,7 +302,8 @@ impl BoxedPolyline2d {
294302}
295303
296304/// A triangle in 2D space
297- #[ derive( Clone , Debug , PartialEq ) ]
305+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
306+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
298307pub struct Triangle2d {
299308 /// The vertices of the triangle
300309 pub vertices : [ Vec2 ; 3 ] ,
@@ -367,7 +376,8 @@ impl Triangle2d {
367376
368377/// A rectangle primitive
369378#[ doc( alias = "Quad" ) ]
370- #[ derive( Clone , Copy , Debug ) ]
379+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
380+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
371381pub struct Rectangle {
372382 /// Half of the width and height of the rectangle
373383 pub half_size : Vec2 ,
@@ -400,9 +410,11 @@ impl Rectangle {
400410/// A polygon with N vertices.
401411///
402412/// For a version without generics: [`BoxedPolygon`]
403- #[ derive( Clone , Debug ) ]
413+ #[ derive( Clone , Debug , PartialEq ) ]
414+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
404415pub struct Polygon < const N : usize > {
405416 /// The vertices of the `Polygon`
417+ #[ cfg_attr( feature = "serialize" , serde( with = "super::serde::array" ) ) ]
406418 pub vertices : [ Vec2 ; N ] ,
407419}
408420impl < const N : usize > Primitive2d for Polygon < N > { }
@@ -429,7 +441,8 @@ impl<const N: usize> Polygon<N> {
429441/// in a `Box<[Vec2]>`.
430442///
431443/// For a version without alloc: [`Polygon`]
432- #[ derive( Clone , Debug ) ]
444+ #[ derive( Clone , Debug , PartialEq ) ]
445+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
433446pub struct BoxedPolygon {
434447 /// The vertices of the `BoxedPolygon`
435448 pub vertices : Box < [ Vec2 ] > ,
@@ -453,7 +466,8 @@ impl BoxedPolygon {
453466}
454467
455468/// A polygon where all vertices lie on a circle, equally far apart.
456- #[ derive( Clone , Copy , Debug ) ]
469+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
470+ #[ cfg_attr( feature = "serialize" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
457471pub struct RegularPolygon {
458472 /// The circumcircle on which all vertices lie
459473 pub circumcircle : Circle ,
0 commit comments