Fixed GTC_matrix_inverse affineInverse #192
This commit is contained in:
@@ -35,23 +35,24 @@ namespace glm
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat3x3<T, P> affineInverse(tmat3x3<T, P> const & m)
|
||||
{
|
||||
tmat3x3<T, P> Result(m);
|
||||
Result[2] = tvec3<T, P>(0, 0, 1);
|
||||
Result = transpose(Result);
|
||||
tvec3<T, P> Translation = Result * tvec3<T, P>(-tvec2<T, P>(m[2]), m[2][2]);
|
||||
Result[2] = Translation;
|
||||
return Result;
|
||||
tmat2x2<T, P> const Inv(inverse(tmat2x2<T, P>(m)));
|
||||
|
||||
return tmat3x3<T, P>(
|
||||
tvec3<T, P>(Inv[0], static_cast<T>(0)),
|
||||
tvec3<T, P>(Inv[1], static_cast<T>(0)),
|
||||
tvec3<T, P>(-Inv * tvec2<T, P>(m[2]), static_cast<T>(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P> affineInverse(tmat4x4<T, P> const & m)
|
||||
{
|
||||
tmat4x4<T, P> Result(m);
|
||||
Result[3] = tvec4<T, P>(0, 0, 0, 1);
|
||||
Result = transpose(Result);
|
||||
tvec4<T, P> Translation = Result * tvec4<T, P>(-tvec3<T, P>(m[3]), m[3][3]);
|
||||
Result[3] = Translation;
|
||||
return Result;
|
||||
tmat3x3<T, P> const Inv(inverse(tmat3x3<T, P>(m)));
|
||||
|
||||
return tmat4x4<T, P>(
|
||||
tvec4<T, P>(Inv[0], static_cast<T>(0)),
|
||||
tvec4<T, P>(Inv[1], static_cast<T>(0)),
|
||||
tvec4<T, P>(Inv[2], static_cast<T>(0)),
|
||||
tvec4<T, P>(-Inv * tvec3<T, P>(m[3]), static_cast<T>(1)));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
|
||||
Reference in New Issue
Block a user