add Debug, Copy, Clone for all shapes (#1653)
This commit is contained in:
		
							parent
							
								
									ac661188c8
								
							
						
					
					
						commit
						f6ff80c5b1
					
				| @ -5,6 +5,7 @@ use crate::{ | |||||||
| use bevy_math::{Vec2, Vec3}; | use bevy_math::{Vec2, Vec3}; | ||||||
| 
 | 
 | ||||||
| /// A cylinder with hemispheres at the top and bottom
 | /// A cylinder with hemispheres at the top and bottom
 | ||||||
|  | #[derive(Debug, Copy, Clone)] | ||||||
| pub struct Capsule { | pub struct Capsule { | ||||||
|     /// Radius on the xz plane.
 |     /// Radius on the xz plane.
 | ||||||
|     pub radius: f32, |     pub radius: f32, | ||||||
| @ -32,7 +33,7 @@ impl Default for Capsule { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Copy)] | #[derive(Debug, Clone, Copy)] | ||||||
| /// Manner in which UV coordinates are distributed vertically.
 | /// Manner in which UV coordinates are distributed vertically.
 | ||||||
| pub enum CapsuleUvProfile { | pub enum CapsuleUvProfile { | ||||||
|     /// UV space is distributed by how much of the capsule consists of the hemispheres.
 |     /// UV space is distributed by how much of the capsule consists of the hemispheres.
 | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ use crate::{ | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /// A sphere made from a subdivided Icosahedron.
 | /// A sphere made from a subdivided Icosahedron.
 | ||||||
| #[derive(Debug)] | #[derive(Debug, Clone, Copy)] | ||||||
| pub struct Icosphere { | pub struct Icosphere { | ||||||
|     /// The radius of the sphere.
 |     /// The radius of the sphere.
 | ||||||
|     pub radius: f32, |     pub radius: f32, | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ use super::{Indices, Mesh}; | |||||||
| use crate::pipeline::PrimitiveTopology; | use crate::pipeline::PrimitiveTopology; | ||||||
| use bevy_math::*; | use bevy_math::*; | ||||||
| 
 | 
 | ||||||
|  | #[derive(Debug, Copy, Clone)] | ||||||
| pub struct Cube { | pub struct Cube { | ||||||
|     pub size: f32, |     pub size: f32, | ||||||
| } | } | ||||||
| @ -24,6 +25,7 @@ impl From<Cube> for Mesh { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #[derive(Debug, Copy, Clone)] | ||||||
| pub struct Box { | pub struct Box { | ||||||
|     pub min_x: f32, |     pub min_x: f32, | ||||||
|     pub max_x: f32, |     pub max_x: f32, | ||||||
| @ -118,7 +120,7 @@ impl From<Box> for Mesh { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// A rectangle on the XY plane.
 | /// A rectangle on the XY plane.
 | ||||||
| #[derive(Debug)] | #[derive(Debug, Copy, Clone)] | ||||||
| pub struct Quad { | pub struct Quad { | ||||||
|     /// Full width and height of the rectangle.
 |     /// Full width and height of the rectangle.
 | ||||||
|     pub size: Vec2, |     pub size: Vec2, | ||||||
| @ -126,6 +128,12 @@ pub struct Quad { | |||||||
|     pub flip: bool, |     pub flip: bool, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Default for Quad { | ||||||
|  |     fn default() -> Self { | ||||||
|  |         Quad::new(Vec2::ONE) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl Quad { | impl Quad { | ||||||
|     pub fn new(size: Vec2) -> Self { |     pub fn new(size: Vec2) -> Self { | ||||||
|         Self { size, flip: false } |         Self { size, flip: false } | ||||||
| @ -214,12 +222,18 @@ impl From<Quad> for Mesh { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// A square on the XZ plane.
 | /// A square on the XZ plane.
 | ||||||
| #[derive(Debug)] | #[derive(Debug, Copy, Clone)] | ||||||
| pub struct Plane { | pub struct Plane { | ||||||
|     /// The total side length of the square.
 |     /// The total side length of the square.
 | ||||||
|     pub size: f32, |     pub size: f32, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Default for Plane { | ||||||
|  |     fn default() -> Self { | ||||||
|  |         Plane { size: 1.0 } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl From<Plane> for Mesh { | impl From<Plane> for Mesh { | ||||||
|     fn from(plane: Plane) -> Self { |     fn from(plane: Plane) -> Self { | ||||||
|         let extent = plane.size / 2.0; |         let extent = plane.size / 2.0; | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ use crate::{ | |||||||
| use bevy_math::Vec3; | use bevy_math::Vec3; | ||||||
| 
 | 
 | ||||||
| /// A torus (donut) shape.
 | /// A torus (donut) shape.
 | ||||||
| #[derive(Debug)] | #[derive(Debug, Clone, Copy)] | ||||||
| pub struct Torus { | pub struct Torus { | ||||||
|     pub radius: f32, |     pub radius: f32, | ||||||
|     pub ring_radius: f32, |     pub ring_radius: f32, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jakob Hellermann
						Jakob Hellermann