From 28a82acbf7a3abae70f3c6ea4f507ad7641e59e3 Mon Sep 17 00:00:00 2001 From: numzero Date: Mon, 27 May 2024 12:38:36 +0300 Subject: [PATCH] Remove unused code --- src/bin/flat.rs | 84 +++---------------------------------------------- 1 file changed, 4 insertions(+), 80 deletions(-) diff --git a/src/bin/flat.rs b/src/bin/flat.rs index a21a882..3e33dfb 100644 --- a/src/bin/flat.rs +++ b/src/bin/flat.rs @@ -170,7 +170,8 @@ struct Ray { mod basic_shapes { use glam::{Vec2, vec2}; - use crate::{Ray, shape}; + use crate::Ray; + use crate::shape::Shape; pub struct Rect { pub size: Vec2, @@ -183,7 +184,7 @@ mod basic_shapes { } } - impl shape::Shape for Rect { + impl Shape for Rect { fn is_inside(&self, pt: Vec2) -> bool { pt.abs().cmplt(self.size).all() } @@ -212,9 +213,6 @@ mod basic_shapes { } } - #[cfg(test)] - use crate::shape::Shape; - #[test] fn test_rect() { assert_eq!(Rect::flip_ray(Ray { pos: vec2(2.0, 3.0), dir: vec2(4.0, 5.0) }), Ray { pos: vec2(2.0, 3.0), dir: vec2(4.0, 5.0) }); @@ -244,7 +242,7 @@ mod basic_shapes { } mod shape { - use glam::{Affine2, Vec2}; + use glam::Vec2; use crate::Ray; pub trait Shape { @@ -258,66 +256,6 @@ mod shape { /// Возвращает визуальное представление контура, для отладки. fn visualise(&self) -> Vec; } - - pub struct MovedShape { - pub shape: S, - pub transform: Affine2, // transform(координаты контура) = 0 - } - - impl MovedShape { - fn pt_to_inner(&self, pt: Vec2) -> Vec2 { - self.transform.transform_point2(pt) - } - fn pt_to_outer(&self, pt: Vec2) -> Vec2 { - self.transform.inverse().transform_point2(pt) - } - fn vec_to_inner(&self, vec: Vec2) -> Vec2 { - self.transform.transform_vector2(vec) - } - fn vec_to_outer(&self, vec: Vec2) -> Vec2 { - self.transform.inverse().transform_vector2(vec) - } - fn ray_to_inner(&self, ray: Ray) -> Ray { - Ray { pos: self.pt_to_inner(ray.pos), dir: self.vec_to_inner(ray.dir) } - } - fn ray_to_outer(&self, ray: Ray) -> Ray { - Ray { pos: self.pt_to_outer(ray.pos), dir: self.vec_to_outer(ray.dir) } - } - } - - impl Shape for MovedShape { - fn is_inside(&self, pt: Vec2) -> bool { - self.shape.is_inside(self.pt_to_inner(pt)) - } - fn trace_into(&self, ray: Ray) -> Option { - self.shape.trace_into(self.ray_to_inner(ray)) - } - fn trace_out_of(&self, ray: Ray) -> Option { - self.shape.trace_out_of(self.ray_to_inner(ray)) - } - fn visualise(&self) -> Vec { - self.shape.visualise().iter().map(|pt| self.pt_to_outer(*pt)).collect() - } - } - - pub struct InvertedShape { - pub shape: S, - } - - impl Shape for InvertedShape { - fn is_inside(&self, pt: Vec2) -> bool { - !self.shape.is_inside(pt) - } - fn trace_into(&self, ray: Ray) -> Option { - self.shape.trace_out_of(ray) - } - fn trace_out_of(&self, ray: Ray) -> Option { - self.shape.trace_into(ray) - } - fn visualise(&self) -> Vec { - self.shape.visualise() - } - } } trait FlatCell: std::fmt::Debug { @@ -357,20 +295,6 @@ trait FlatCell: std::fmt::Debug { } } -#[derive(Debug)] -struct FlatRect { - min: Vec2, - max: Vec2, -} - -impl FlatCell for FlatRect { - fn pos_to_global(&self, pos: Vec2) -> Vec2 { pos } - fn pos_to_local(&self, pos: Vec2) -> Vec2 { pos } - fn ray_to_global(&self, ray: Ray) -> Ray { ray } - fn ray_to_local(&self, ray: Ray) -> Ray { ray } - fn local_bounds(&self) -> (Vec2, Vec2) { (self.min, self.max) } -} - #[derive(Debug)] struct RectInside { rect: Rect,