From 9dad69c630c6b02ddb7040308e5ea41a8921536a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 21 Apr 2012 19:45:09 +0000 Subject: [PATCH] math: allow to easily create a 4x4 matrix from a 3x3 matrix, and so on. --- src/lol/math/vector.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 40c9139f..260430d5 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -1434,6 +1434,16 @@ template struct Mat3 v1((T)0, val, (T)0), v2((T)0, (T)0, val) {} + explicit inline Mat3(Mat2 mat) + : v0(mat[0], (T)0), + v1(mat[1], (T)0), + v2((T)0, (T)0, (T)0) {} + + explicit inline Mat3(Mat2 mat, T val) + : v0(Vec3(mat[0], (T)0)), + v1(Vec3(mat[1], (T)0)), + v2((T)0, (T)0, val) {} + explicit inline Mat3(Mat4 const &mat) : v0(mat[0].xyz), v1(mat[1].xyz), @@ -1521,6 +1531,30 @@ template struct Mat4 v2((T)0, (T)0, val, (T)0), v3((T)0, (T)0, (T)0, val) {} + explicit inline Mat4(Mat2 mat) + : v0(mat[0], (T)0, (T)0), + v1(mat[1], (T)0, (T)0), + v2((T)0, (T)0, (T)0, (T)0), + v3((T)0, (T)0, (T)0, (T)0) {} + + explicit inline Mat4(Mat2 mat, T val1, T val2) + : v0(mat[0], (T)0, (T)0), + v1(mat[1], (T)0, (T)0), + v2((T)0, (T)0, val1, (T)0), + v3((T)0, (T)0, (T)0, val2) {} + + explicit inline Mat4(Mat3 mat) + : v0(mat[0], (T)0), + v1(mat[1], (T)0), + v2(mat[2], (T)0), + v3((T)0, (T)0, (T)0, (T)0) {} + + explicit inline Mat4(Mat3 mat, T val) + : v0(mat[0], (T)0), + v1(mat[1], (T)0), + v2(mat[2], (T)0), + v3((T)0, (T)0, (T)0, val) {} + inline Vec4& operator[](size_t n) { return (&v0)[n]; } inline Vec4 const& operator[](size_t n) const { return (&v0)[n]; }