From f6ff80c5b1ff23d6fffa088fc1d232c05c1fb2be Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Sun, 14 Mar 2021 20:45:00 +0100 Subject: [PATCH] add Debug, Copy, Clone for all shapes (#1653) --- crates/bevy_render/src/mesh/shape/capsule.rs | 3 ++- crates/bevy_render/src/mesh/shape/icosphere.rs | 2 +- crates/bevy_render/src/mesh/shape/mod.rs | 18 ++++++++++++++++-- crates/bevy_render/src/mesh/shape/torus.rs | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/bevy_render/src/mesh/shape/capsule.rs b/crates/bevy_render/src/mesh/shape/capsule.rs index bf01c2b1e9..c4693adddc 100644 --- a/crates/bevy_render/src/mesh/shape/capsule.rs +++ b/crates/bevy_render/src/mesh/shape/capsule.rs @@ -5,6 +5,7 @@ use crate::{ use bevy_math::{Vec2, Vec3}; /// A cylinder with hemispheres at the top and bottom +#[derive(Debug, Copy, Clone)] pub struct Capsule { /// Radius on the xz plane. 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. pub enum CapsuleUvProfile { /// UV space is distributed by how much of the capsule consists of the hemispheres. diff --git a/crates/bevy_render/src/mesh/shape/icosphere.rs b/crates/bevy_render/src/mesh/shape/icosphere.rs index d4356259ca..f3a4736b22 100644 --- a/crates/bevy_render/src/mesh/shape/icosphere.rs +++ b/crates/bevy_render/src/mesh/shape/icosphere.rs @@ -6,7 +6,7 @@ use crate::{ }; /// A sphere made from a subdivided Icosahedron. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Icosphere { /// The radius of the sphere. pub radius: f32, diff --git a/crates/bevy_render/src/mesh/shape/mod.rs b/crates/bevy_render/src/mesh/shape/mod.rs index 5c7213c18d..84ff56098e 100644 --- a/crates/bevy_render/src/mesh/shape/mod.rs +++ b/crates/bevy_render/src/mesh/shape/mod.rs @@ -2,6 +2,7 @@ use super::{Indices, Mesh}; use crate::pipeline::PrimitiveTopology; use bevy_math::*; +#[derive(Debug, Copy, Clone)] pub struct Cube { pub size: f32, } @@ -24,6 +25,7 @@ impl From for Mesh { } } +#[derive(Debug, Copy, Clone)] pub struct Box { pub min_x: f32, pub max_x: f32, @@ -118,7 +120,7 @@ impl From for Mesh { } /// A rectangle on the XY plane. -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] pub struct Quad { /// Full width and height of the rectangle. pub size: Vec2, @@ -126,6 +128,12 @@ pub struct Quad { pub flip: bool, } +impl Default for Quad { + fn default() -> Self { + Quad::new(Vec2::ONE) + } +} + impl Quad { pub fn new(size: Vec2) -> Self { Self { size, flip: false } @@ -214,12 +222,18 @@ impl From for Mesh { } /// A square on the XZ plane. -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] pub struct Plane { /// The total side length of the square. pub size: f32, } +impl Default for Plane { + fn default() -> Self { + Plane { size: 1.0 } + } +} + impl From for Mesh { fn from(plane: Plane) -> Self { let extent = plane.size / 2.0; diff --git a/crates/bevy_render/src/mesh/shape/torus.rs b/crates/bevy_render/src/mesh/shape/torus.rs index e1eedbdeb1..56039f3d18 100644 --- a/crates/bevy_render/src/mesh/shape/torus.rs +++ b/crates/bevy_render/src/mesh/shape/torus.rs @@ -5,7 +5,7 @@ use crate::{ use bevy_math::Vec3; /// A torus (donut) shape. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Torus { pub radius: f32, pub ring_radius: f32,