From 6427edb050b49e6559f6ea69b86aa35a1eab2173 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 21 Feb 2021 16:32:14 -0800 Subject: [PATCH] mark matrix functions as const --- src/Matrix4x4.cpp | 4 ++-- src/Matrix4x4.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Matrix4x4.cpp b/src/Matrix4x4.cpp index 8013f50..71d95da 100644 --- a/src/Matrix4x4.cpp +++ b/src/Matrix4x4.cpp @@ -21,7 +21,7 @@ namespace rgbcx { -Matrix4x4 operator*(Matrix4x4& lhs, Matrix4x4& rhs) { +Matrix4x4 operator*(const Matrix4x4& lhs, const Matrix4x4& rhs) { Matrix4x4 trans_rhs = rhs.Transpose(); // 🏳️‍⚧️ Matrix4x4 result; for (unsigned r = 0; r < 4; r++) { @@ -31,7 +31,7 @@ Matrix4x4 operator*(Matrix4x4& lhs, Matrix4x4& rhs) { return result; } -Vector4 operator*(Matrix4x4& lhs, Vector4& rhs) { +Vector4 operator*(const Matrix4x4& lhs, const Vector4& rhs) { Vector4 result; for (unsigned r = 0; r < 4; r++) { result[r] = rhs.Dot(lhs[r]); } diff --git a/src/Matrix4x4.h b/src/Matrix4x4.h index aa70c32..cb4729c 100644 --- a/src/Matrix4x4.h +++ b/src/Matrix4x4.h @@ -34,7 +34,7 @@ class Matrix4x4 { return result; } - static Matrix4x4 Transpose(Matrix4x4 &val) { + static Matrix4x4 Transpose(const Matrix4x4 &val) { Matrix4x4 result; for (unsigned r = 0; r < 3; r++) { for (unsigned c = 0; c < 3; c++) { result[r][c] = val[c][r]; } @@ -71,7 +71,7 @@ class Matrix4x4 { friend Matrix4x4 &operator*=(Matrix4x4 &lhs, const float &rhs) { return lhs = lhs * rhs; } friend Matrix4x4 &operator/=(Matrix4x4 &lhs, const float &rhs) { return lhs = lhs / rhs; } - Matrix4x4 Transpose() { return Transpose(*this); } + Matrix4x4 Transpose() const { return Transpose(*this); } void Mirror();