diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index eb2a35ac..0937ef46 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -1632,6 +1632,8 @@ template struct Mat2 } Vec2 v0, v1; + + static const Mat2 identity; }; /* @@ -1756,6 +1758,8 @@ template struct Mat3 } Vec3 v0, v1, v2; + + static const Mat3 identity; }; /* @@ -1927,6 +1931,8 @@ template struct Mat4 } Vec4 v0, v1, v2, v3; + + static const Mat4 identity; }; template T determinant(Mat2 const &); diff --git a/src/math/constants.cpp b/src/math/constants.cpp index c0dcde56..80b847d6 100644 --- a/src/math/constants.cpp +++ b/src/math/constants.cpp @@ -28,7 +28,17 @@ namespace lol { template<> \ Vec4 const Vec4::name = Vec4((type)a, (type)b, (type)c, (type)d); -#define LOL_ALL_VECTOR_CONST_INNER(type) \ +#define LOL_MAT_CONST(type, name, a) \ + template<> \ + Mat2 const Mat2::name = Mat2((type)a); \ + \ + template<> \ + Mat3 const Mat3::name = Mat3((type)a); \ + \ + template<> \ + Mat4 const Mat4::name = Mat4((type)a); + +#define LOL_ALL_CONST_INNER(type) \ LOL_VEC_2_CONST(type, one, 1, 1) \ LOL_VEC_2_CONST(type, mone,-1,-1) \ LOL_VEC_2_CONST(type, zero, 0, 0) \ @@ -48,22 +58,24 @@ namespace lol { LOL_VEC_4_CONST(type, axis_x, 1, 0, 0, 0) \ LOL_VEC_4_CONST(type, axis_y, 0, 1, 0, 0) \ LOL_VEC_4_CONST(type, axis_z, 0, 0, 1, 0) \ - LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1) + LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1) \ + \ + LOL_MAT_CONST(type, identity, 1) -LOL_ALL_VECTOR_CONST_INNER(half) -LOL_ALL_VECTOR_CONST_INNER(float) -LOL_ALL_VECTOR_CONST_INNER(double) -LOL_ALL_VECTOR_CONST_INNER(ldouble) -LOL_ALL_VECTOR_CONST_INNER(real) +LOL_ALL_CONST_INNER(half) +LOL_ALL_CONST_INNER(float) +LOL_ALL_CONST_INNER(double) +LOL_ALL_CONST_INNER(ldouble) +LOL_ALL_CONST_INNER(real) -LOL_ALL_VECTOR_CONST_INNER(int8_t) -LOL_ALL_VECTOR_CONST_INNER(uint8_t) -LOL_ALL_VECTOR_CONST_INNER(int16_t) -LOL_ALL_VECTOR_CONST_INNER(uint16_t) -LOL_ALL_VECTOR_CONST_INNER(int32_t) -LOL_ALL_VECTOR_CONST_INNER(uint32_t) -LOL_ALL_VECTOR_CONST_INNER(int64_t) -LOL_ALL_VECTOR_CONST_INNER(uint64_t) +LOL_ALL_CONST_INNER(int8_t) +LOL_ALL_CONST_INNER(uint8_t) +LOL_ALL_CONST_INNER(int16_t) +LOL_ALL_CONST_INNER(uint16_t) +LOL_ALL_CONST_INNER(int32_t) +LOL_ALL_CONST_INNER(uint32_t) +LOL_ALL_CONST_INNER(int64_t) +LOL_ALL_CONST_INNER(uint64_t) }; /* namespace lol */