From 927f060aadd9170e8cedc327b1dd73ebbd99587a Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 30 Nov 2018 14:21:23 +0000 Subject: [PATCH] bug fix on matrix multiplication scalar * mat3/4 didn't implement, so it was: `mat3 * scalar != scalar * mat3` and now: `mat3 * scalar == scalar * mat3` applied the similar fix to Matrix4 class too. --- ORUtils/Matrix.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ORUtils/Matrix.h b/ORUtils/Matrix.h index 6c9831b7f..1656c37ca 100644 --- a/ORUtils/Matrix.h +++ b/ORUtils/Matrix.h @@ -108,6 +108,11 @@ namespace ORUtils { return r; } + // scalar * mat4 + _CPU_AND_GPU_CODE_ inline friend Matrix4 operator * (const T &scalar, const Matrix4 &rhs) { + return rhs * scalar; + } + _CPU_AND_GPU_CODE_ inline friend Matrix4 operator / (const Matrix4 &lhs, const T &rhs) { Matrix4 r; for (int i = 0; i < 16; i++) r.m[i] = lhs.m[i] / rhs; @@ -297,6 +302,11 @@ namespace ORUtils { return r; } + // scalar * mat3 + _CPU_AND_GPU_CODE_ inline friend Matrix3 operator * (const T &scalar, const Matrix3 &rhs) { + return rhs * scalar; + } + _CPU_AND_GPU_CODE_ inline friend Matrix3 operator + (const Matrix3 &lhs, const Matrix3 &rhs) { Matrix3 res(lhs.m); return res += rhs;