Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Clone, Copy and Debug on possible structs and enums #715

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion particles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl From<&ColorSerializable> for Color {
}

#[cfg_attr(feature = "nanoserde", derive(DeJson, SerJson))]
#[derive(Clone, Copy, Debug)]
pub struct Vec2Serializable {
x: f32,
y: f32,
Expand Down Expand Up @@ -415,7 +416,7 @@ impl BlendMode {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "nanoserde", derive(DeJson, SerJson))]
pub struct AtlasConfig {
n: u16,
Expand Down Expand Up @@ -484,13 +485,15 @@ impl Default for EmitterConfig {
}

#[repr(C)]
#[derive(Clone, Debug)]
struct GpuParticle {
pos: Vec4,
uv: Vec4,
data: Vec4,
color: Vec4,
}

#[derive(Clone, Debug)]
struct CpuParticle {
velocity: Vec2,
angular_velocity: f32,
Expand All @@ -500,6 +503,7 @@ struct CpuParticle {
initial_size: f32,
}

#[derive(Clone, Debug)]
pub struct Emitter {
pipeline: Pipeline,
bindings: Bindings,
Expand Down Expand Up @@ -995,6 +999,7 @@ impl Emitter {
/// Multiple emitters drawn simultaneously.
/// Will reuse as much GPU resources as possible, so should be more efficient than
/// just Vec<Emitter>
#[derive(Clone, Debug)]
pub struct EmittersCache {
emitter: Emitter,
emitters_cache: Vec<Emitter>,
Expand Down Expand Up @@ -1112,6 +1117,7 @@ mod shader {
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Uniforms {
pub mvp: Mat4,
pub local_coords: f32,
Expand Down
2 changes: 2 additions & 0 deletions physics-platformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl Tile {
}
}
}
#[derive(Clone, Debug)]
pub struct StaticTiledLayer {
static_colliders: Vec<Tile>,
tile_width: f32,
Expand All @@ -29,6 +30,7 @@ pub struct StaticTiledLayer {
tag: u8,
}

#[derive(Clone, Debug)]
pub struct World {
static_tiled_layers: Vec<StaticTiledLayer>,
solids: Vec<(Solid, Collider)>,
Expand Down
2 changes: 2 additions & 0 deletions profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use macroquad::prelude::*;

use macroquad::ui::{hash, root_ui, widgets::Window, Ui};

#[derive(Clone, Debug)]
pub struct ProfilerState {
fps_buffer: Vec<f32>,
frames_buffer: Vec<telemetry::Frame>,
Expand All @@ -12,6 +13,7 @@ pub struct ProfilerState {
paused: bool,
}

#[derive(Clone, Copy, Debug)]
pub struct ProfilerParams {
pub fps_counter_pos: Vec2,
}
Expand Down
4 changes: 4 additions & 0 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub use quad_snd::PlaySoundParams;
mod dummy_audio {
use crate::audio::PlaySoundParams;

#[derive(Clone, Copy, Debug)]
pub struct AudioContext {}

impl AudioContext {
Expand All @@ -27,6 +28,7 @@ mod dummy_audio {
pub fn resume(&mut self) {}
}

#[derive(Clone, Copy, Debug)]
pub struct Sound {}

impl Sound {
Expand Down Expand Up @@ -54,11 +56,13 @@ mod dummy_audio {
use dummy_audio::{AudioContext as QuadSndContext, Sound as QuadSndSound};

#[cfg(not(feature = "audio"))]
#[derive(Clone, Copy, Debug)]
pub struct PlaySoundParams {
pub looped: bool,
pub volume: f32,
}

#[derive(Clone, Copy, Debug)]
pub struct AudioContext {
native_ctx: QuadSndContext,
}
Expand Down
4 changes: 2 additions & 2 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait Camera {
fn viewport(&self) -> Option<(i32, i32, i32, i32)>;
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Camera2D {
/// Rotation in degrees.
pub rotation: f32,
Expand Down Expand Up @@ -151,7 +151,7 @@ pub enum Projection {
Orthographics,
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Camera3D {
/// Camera position.
pub position: Vec3,
Expand Down
3 changes: 2 additions & 1 deletion src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
use crate::Error;

// Returns Pending as long as its inner bool is false.
#[derive(Default)]
#[derive(Default, Clone, Copy, Debug)]
musjj marked this conversation as resolved.
Show resolved Hide resolved
pub struct FrameFuture {
done: bool,
}
Expand All @@ -27,6 +27,7 @@ impl Future for FrameFuture {
}
}

#[derive(Clone, Debug)]
pub struct FileLoadingFuture {
pub contents: Arc<Mutex<Option<Result<Vec<u8>, Error>>>>,
}
Expand Down
3 changes: 2 additions & 1 deletion src/experimental/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub struct Animation {
}

/// Specific animation frame
#[derive(Clone, Copy, Debug)]
pub struct AnimationFrame {
/// Area of current frame in source image
pub source_rect: Rect,
Expand All @@ -79,7 +80,7 @@ pub struct AnimationFrame {
}

/// Main definition of all animations for specific image
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct AnimatedSprite {
tile_width: f32,
tile_height: f32,
Expand Down
2 changes: 2 additions & 0 deletions src/experimental/coroutines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub fn stop_coroutine(coroutine: Coroutine) {
context.coroutines.free(coroutine.id);
}

#[derive(Clone, Copy, Debug)]
pub struct TimerDelayFuture {
pub(crate) remaining_time: f32,
}
Expand Down Expand Up @@ -272,6 +273,7 @@ pub mod tweens {
task::{Context, Poll},
};

#[derive(Clone, Copy, Debug)]
pub struct LinearTweenFuture<T>
where
T: Copy + Add<Output = T> + Sub<Output = T> + Mul<f32, Output = T>,
Expand Down
3 changes: 3 additions & 0 deletions src/experimental/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl<T> Handle<T> {
pub fn as_trait<T1: ?Sized>(&self) {}
}

#[derive(Clone, Copy, Debug)]
pub(crate) struct Lens<T> {
handle: HandleUntyped,
offset: isize,
Expand Down Expand Up @@ -181,6 +182,7 @@ impl<T: 'static> Drop for RefMut<T> {
}
}

#[derive(Clone, Debug)]
pub struct RefMutAny<'a> {
data: *mut (),
used: *mut bool,
Expand Down Expand Up @@ -568,6 +570,7 @@ impl Scene {
}
}

#[derive(Clone, Copy, Debug)]
pub struct MagicVecIterator {
n: usize,
len: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl From<miniquad::TouchPhase> for TouchPhase {
}
}

#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Touch {
pub id: u64,
pub phase: TouchPhase,
Expand Down
1 change: 1 addition & 0 deletions src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl Material {
/// Params used for material loading.
/// It is not possible to change material params at runtime, so this
/// struct is used only once - at "load_material".
#[derive(Clone, Debug)]
pub struct MaterialParams {
/// miniquad pipeline configuration for this material.
/// Things like blending, culling, depth dest
Expand Down
3 changes: 2 additions & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl From<Vertex> for crate::quad_gl::VertexInterop {
}
}

#[derive(Clone, Debug)]
pub struct Mesh {
pub vertices: Vec<Vertex>,
pub indices: Vec<u16>,
Expand Down Expand Up @@ -453,7 +454,7 @@ pub fn draw_cube_wires(position: Vec3, size: Vec3, color: Color) {
);
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct DrawSphereParams {
pub rings: usize,
pub slices: usize,
Expand Down
9 changes: 7 additions & 2 deletions src/quad_gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum DrawMode {
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct GlPipeline(usize);

#[derive(Clone, Debug)]
struct DrawCall {
vertices: Vec<Vertex>,
indices: Vec<u16>,
Expand Down Expand Up @@ -131,6 +132,7 @@ impl DrawCall {
}
}

#[derive(Clone, Debug)]
struct MagicSnapshotter {
pipeline: Pipeline,
bindings: Bindings,
Expand Down Expand Up @@ -200,7 +202,7 @@ mod snapshotter_shader {
}

#[repr(C)]
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Uniforms {}
}

Expand Down Expand Up @@ -323,6 +325,7 @@ impl MagicSnapshotter {
}
}

#[derive(Clone, Debug)]
struct GlState {
texture: Option<miniquad::TextureId>,
draw_mode: DrawMode,
Expand Down Expand Up @@ -352,7 +355,7 @@ struct Uniform {
byte_offset: usize,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
struct PipelineExt {
pipeline: miniquad::Pipeline,
wants_screen_texture: bool,
Expand Down Expand Up @@ -406,6 +409,7 @@ impl PipelineExt {
}
}

#[derive(Clone, Debug)]
struct PipelinesStorage {
pipelines: [Option<PipelineExt>; Self::MAX_PIPELINES],
pipelines_amount: usize,
Expand Down Expand Up @@ -586,6 +590,7 @@ impl PipelinesStorage {
}
}

#[derive(Clone, Debug)]
pub struct QuadGl {
pipelines: PipelinesStorage,

Expand Down
2 changes: 1 addition & 1 deletion src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn draw_rectangle_lines(x: f32, y: f32, w: f32, h: f32, thickness: f32, colo
context.gl.geometry(&vertices, &indices);
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct DrawRectangleParams {
/// Adds an offset to the position
/// E.g. offset (0,0) positions the rectangle at the top left corner of the screen, while offset
Expand Down
5 changes: 4 additions & 1 deletion src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl Zone {
}
}

#[derive(Clone, Debug)]
musjj marked this conversation as resolved.
Show resolved Hide resolved
pub struct ZoneGuard {
_marker: (),
}
Expand Down Expand Up @@ -272,6 +273,7 @@ impl Profiler {
}
}

#[derive(Clone, Copy)]
pub struct GpuQuery {
pub query: miniquad::graphics::ElapsedQuery,
pub in_progress: bool,
Expand All @@ -293,6 +295,7 @@ pub fn scene_allocated_memory() -> usize {
/// ```
/// Will add "Time query: Atlas build time, 0.5s" string to
/// `telemetry::strings()`
#[derive(Clone, Debug)]
pub struct LogTimeGuard<'a> {
name: &'a str,
start_time: f64,
Expand Down Expand Up @@ -342,7 +345,7 @@ pub fn capture_frame() {
get_profiler().capture_request = true;
}

#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct DrawCallTelemetry {
pub indices_count: usize,
pub texture: miniquad::TextureId,
Expand Down
2 changes: 1 addition & 1 deletion src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Font {
}

/// Arguments for "draw_text_ex" function such as font, font_size etc
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct TextParams<'a> {
pub font: Option<&'a Font>,
/// Base size for character height. The size in pixel used during font rasterizing.
Expand Down
1 change: 1 addition & 0 deletions src/text/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum SpriteKey {
Texture(miniquad::TextureId),
Id(u64),
}
#[derive(Clone, Debug)]
pub struct Atlas {
texture: miniquad::TextureId,
image: Image,
Expand Down
3 changes: 1 addition & 2 deletions src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub fn render_target(width: u32, height: u32) -> RenderTarget {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct DrawTextureParams {
pub dest_size: Option<Vec2>,

Expand Down Expand Up @@ -671,7 +671,6 @@ impl Texture2D {
ctx.texture_update(self.raw_miniquad_id(), bytes);
}


/// Uploads [Image] data to part of this texture.
pub fn update_part(
&self,
Expand Down
1 change: 1 addition & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ use input::{InputCharacter, Key};
/// These should be unique per window and ideally not change in between frames.
pub type Id = u64;

#[derive(Clone, Debug)]
pub enum UiContent<'a> {
Label(Cow<'a, str>),
Texture(crate::texture::Texture2D),
Expand Down
Loading
Loading