diff --git a/.gitignore b/.gitignore index 9dbd6d8c0..bea497a45 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ test/gtc/*.dds Makefile *.cbp *.user +.idea/ # Misc. *.log diff --git a/glm/gtx/transform2.hpp b/glm/gtx/transform2.hpp index 9604a9231..9724a426f 100644 --- a/glm/gtx/transform2.hpp +++ b/glm/gtx/transform2.hpp @@ -57,9 +57,10 @@ namespace glm // Identity + tan(angle) * cross(Normal, OnPlaneVector) 0 // - dot(PointOnPlane, normal) * OnPlaneVector 1 - // Reflect functions seem to don't work - //template mat<3, 3, T, Q> reflect2D(const mat<3, 3, T, Q> & m, const vec<3, T, Q>& normal){return reflect2DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension) - //template mat<4, 4, T, Q> reflect3D(const mat<4, 4, T, Q> & m, const vec<3, T, Q>& normal){return reflect3DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension) + //! Build a reflection matrix. + //! From GLM_GTX_transform2 extension. + template + GLM_FUNC_DECL mat<4, 4, T, Q> reflect3D(vec<3, T, Q> const& normal, T distance); //! Build planar projection matrix along normal axis. //! From GLM_GTX_transform2 extension. diff --git a/glm/gtx/transform2.inl b/glm/gtx/transform2.inl index 0118ab096..e2bf386e8 100644 --- a/glm/gtx/transform2.inl +++ b/glm/gtx/transform2.inl @@ -45,33 +45,34 @@ namespace glm return m * r; } - template - GLM_FUNC_QUALIFIER mat<3, 3, T, Q> reflect2D(mat<3, 3, T, Q> const& m, vec<3, T, Q> const& normal) - { - mat<3, 3, T, Q> r(static_cast(1)); - r[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; - r[0][1] = -static_cast(2) * normal.x * normal.y; - r[1][0] = -static_cast(2) * normal.x * normal.y; - r[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; - return m * r; - } + // template + // GLM_FUNC_QUALIFIER mat<3, 3, T, Q> reflect2D(mat<3, 3, T, Q> const& m, vec<3, T, Q> const& normal) + // { + // mat<3, 3, T, Q> r(static_cast(1)); + // r[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; + // r[0][1] = -static_cast(2) * normal.x * normal.y; + // r[1][0] = -static_cast(2) * normal.x * normal.y; + // r[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; + // return m * r; + // } template - GLM_FUNC_QUALIFIER mat<4, 4, T, Q> reflect3D(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& normal) + GLM_FUNC_DECL mat<4, 4, T, Q> reflect3D(vec<3, T, Q> const& normal, T distance) { - mat<4, 4, T, Q> r(static_cast(1)); - r[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; - r[0][1] = -static_cast(2) * normal.x * normal.y; - r[0][2] = -static_cast(2) * normal.x * normal.z; - - r[1][0] = -static_cast(2) * normal.x * normal.y; - r[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; - r[1][2] = -static_cast(2) * normal.y * normal.z; - - r[2][0] = -static_cast(2) * normal.x * normal.z; - r[2][1] = -static_cast(2) * normal.y * normal.z; - r[2][2] = static_cast(1) - static_cast(2) * normal.z * normal.z; - return m * r; + mat<4, 4, T, Q> result(static_cast(1)); + result[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; + result[0][1] = -static_cast(2) * normal.y * normal.x; + result[0][2] = -static_cast(2) * normal.z * normal.x; + result[1][0] = -static_cast(2) * normal.x * normal.y; + result[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; + result[1][2] = -static_cast(2) * normal.z * normal.y; + result[2][0] = -static_cast(2) * normal.x * normal.z; + result[2][1] = -static_cast(2) * normal.y * normal.z; + result[2][2] = static_cast(1) - static_cast(2) * normal.z * normal.z; + result[3][0] = -static_cast(2) * normal.x * distance; + result[3][1] = -static_cast(2) * normal.y * distance; + result[3][2] = -static_cast(2) * normal.z * distance; + return result; } template