diff options
| author | HampusM <hampus@hampusmat.com> | 2026-04-12 16:09:10 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-04-12 16:09:10 +0200 |
| commit | b7cef4d4c76acc66830dc947872a763a32c1a9e1 (patch) | |
| tree | f8150f411f24222404746fc1139cc7157a8652d3 /engine/src | |
| parent | b8e77e54c874c6f47e574d554e04fa8bd8939b54 (diff) | |
refactor(engine): remove VecN trait
Diffstat (limited to 'engine/src')
| -rw-r--r-- | engine/src/data_types/matrix.rs | 10 | ||||
| -rw-r--r-- | engine/src/data_types/vector.rs | 39 |
2 files changed, 8 insertions, 41 deletions
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<Value, const ROWS: usize, const COLUMNS: usize> @@ -22,12 +22,12 @@ impl<Value, const ROWS: usize, const COLUMNS: usize> Matrix<Value, ROWS, COLUMNS } } - pub fn from_columns<ColumnVec>(columns: [ColumnVec; COLUMNS]) -> Self + pub fn from_columns<Column>(columns: [Column; COLUMNS]) -> Self where - ColumnVec: VecN<Value, ROWS>, + Column: Into<[Value; ROWS]>, { Self { - items: columns.map(|column| column.into_array()), + items: columns.map(|column| column.into()), } } @@ -276,7 +276,7 @@ impl Mul<f32> for Matrix<f32, 4, 4> 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<Value, const N: usize>: sealed::Sealed -{ - fn into_array(self) -> [Value; N]; -} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec2<Value> { @@ -119,16 +113,6 @@ impl<Value> From<Vec2<Value>> for [Value; 2] } } -impl<Value> VecN<Value, 2> for Vec2<Value> -{ - fn into_array(self) -> [Value; 2] - { - [self.x, self.y] - } -} - -impl<Value> sealed::Sealed for Vec2<Value> {} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec3<Value> { @@ -408,16 +392,6 @@ impl<Value> From<Vec3<Value>> for [Value; 3] } } -impl<Value> VecN<Value, 3> for Vec3<Value> -{ - fn into_array(self) -> [Value; 3] - { - [self.x, self.y, self.z] - } -} - -impl<Value> sealed::Sealed for Vec3<Value> {} - #[derive(Debug, Default, Clone, Copy, PartialEq)] pub struct Vec4<Value> { @@ -518,17 +492,10 @@ impl<Value> From<[Value; 4]> for Vec4<Value> } } -impl<Value> VecN<Value, 4> for Vec4<Value> +impl<Value> From<Vec4<Value>> for [Value; 4] { - fn into_array(self) -> [Value; 4] + fn from(vec: Vec4<Value>) -> Self { - [self.x, self.y, self.z, self.w] + [vec.x, vec.y, vec.z, vec.w] } } - -impl<Value> sealed::Sealed for Vec4<Value> {} - -mod sealed -{ - pub trait Sealed {} -} |
