summaryrefslogtreecommitdiff
path: root/engine/src/data_types
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/data_types')
-rw-r--r--engine/src/data_types/matrix.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/engine/src/data_types/matrix.rs b/engine/src/data_types/matrix.rs
index 85a3721..c5cc63a 100644
--- a/engine/src/data_types/matrix.rs
+++ b/engine/src/data_types/matrix.rs
@@ -1,7 +1,6 @@
use crate::vector::Vec3;
#[derive(Debug, Clone)]
-#[repr(C)]
pub struct Matrix<Value, const ROWS: usize, const COLUMNS: usize>
{
/// Items must be layed out this way for it to work with OpenGL shaders.
@@ -10,6 +9,8 @@ pub struct Matrix<Value, const ROWS: usize, const COLUMNS: usize>
impl<Value, const ROWS: usize, const COLUMNS: usize> Matrix<Value, ROWS, COLUMNS>
{
+ /// Creates a new `ROWS` * `COLUMNS` matrix.
+ #[must_use]
pub fn new() -> Self
where
Value: Default + Copy,
@@ -25,6 +26,7 @@ impl<Value, const ROWS: usize, const COLUMNS: usize> Matrix<Value, ROWS, COLUMNS
self.items[column][row] = value;
}
+ /// Returns the internal 2D array as a pointer.
#[must_use]
pub fn as_ptr(&self) -> *const Value
{
@@ -32,6 +34,17 @@ impl<Value, const ROWS: usize, const COLUMNS: usize> Matrix<Value, ROWS, COLUMNS
}
}
+impl<Value, const ROWS: usize, const COLUMNS: usize> Default
+ for Matrix<Value, ROWS, COLUMNS>
+where
+ Value: Copy + Default,
+{
+ fn default() -> Self
+ {
+ Self::new()
+ }
+}
+
impl<const ROWS_COLS: usize> Matrix<f32, ROWS_COLS, ROWS_COLS>
{
/// Creates a new identity matrix.