From b7cef4d4c76acc66830dc947872a763a32c1a9e1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 12 Apr 2026 16:09:10 +0200 Subject: refactor(engine): remove VecN trait --- engine/src/data_types/matrix.rs | 10 +++++----- engine/src/data_types/vector.rs | 39 +++------------------------------------ 2 files changed, 8 insertions(+), 41 deletions(-) (limited to 'engine') diff --git a/engine/src/data_types/matrix.rs b/engine/src/data_types/matrix.rs index 39aeea0..486ab24 100644 --- a/engine/src/data_types/matrix.rs +++ b/engine/src/data_types/matrix.rs @@ -1,6 +1,6 @@ use std::ops::Mul; -use crate::vector::{Vec3, Vec4, VecN}; +use crate::vector::{Vec3, Vec4}; #[derive(Debug, Clone)] pub struct Matrix @@ -22,12 +22,12 @@ impl Matrix(columns: [ColumnVec; COLUMNS]) -> Self + pub fn from_columns(columns: [Column; COLUMNS]) -> Self where - ColumnVec: VecN, + Column: Into<[Value; ROWS]>, { Self { - items: columns.map(|column| column.into_array()), + items: columns.map(|column| column.into()), } } @@ -276,7 +276,7 @@ impl Mul for Matrix Self { items: self .items - .map(|column| (Vec4::from(column) * scalar).into_array()), + .map(|column| (Vec4::from(column) * scalar).into()), } } } diff --git a/engine/src/data_types/vector.rs b/engine/src/data_types/vector.rs index adbdfff..8567af5 100644 --- a/engine/src/data_types/vector.rs +++ b/engine/src/data_types/vector.rs @@ -2,12 +2,6 @@ use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub, SubAssign}; use crate::color::Color; -/// A vector of `Value`s with `N` number of elements. -pub trait VecN: sealed::Sealed -{ - fn into_array(self) -> [Value; N]; -} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec2 { @@ -119,16 +113,6 @@ impl From> for [Value; 2] } } -impl VecN for Vec2 -{ - fn into_array(self) -> [Value; 2] - { - [self.x, self.y] - } -} - -impl sealed::Sealed for Vec2 {} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec3 { @@ -408,16 +392,6 @@ impl From> for [Value; 3] } } -impl VecN for Vec3 -{ - fn into_array(self) -> [Value; 3] - { - [self.x, self.y, self.z] - } -} - -impl sealed::Sealed for Vec3 {} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec4 { @@ -518,17 +492,10 @@ impl From<[Value; 4]> for Vec4 } } -impl VecN for Vec4 +impl From> for [Value; 4] { - fn into_array(self) -> [Value; 4] + fn from(vec: Vec4) -> Self { - [self.x, self.y, self.z, self.w] + [vec.x, vec.y, vec.z, vec.w] } } - -impl sealed::Sealed for Vec4 {} - -mod sealed -{ - pub trait Sealed {} -} -- cgit v1.2.3-18-g5258