diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-08-05 04:51:44 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-08-05 04:51:44 +0000 |
| commit | a060ade1249f08054cc86013da851a84d85a28fd (patch) | |
| tree | 398101aa11bda45d53dbd7151c9b3db46226863f /Common/interface | |
| parent | Fixed File2String c++11 build error (diff) | |
| download | DiligentCore-a060ade1249f08054cc86013da851a84d85a28fd.tar.gz DiligentCore-a060ade1249f08054cc86013da851a84d85a28fd.zip | |
Added Matrix4x4::RemoveTranslation method
Diffstat (limited to 'Common/interface')
| -rw-r--r-- | Common/interface/BasicMath.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Common/interface/BasicMath.h b/Common/interface/BasicMath.h index 8e720034..f2712eb0 100644 --- a/Common/interface/BasicMath.h +++ b/Common/interface/BasicMath.h @@ -174,12 +174,12 @@ template <class T> struct Vector2 y /= s; return *this; } - + bool operator == (const Vector2 &right)const { return x == right.x && y == right.y; } - + bool operator != (const Vector2 &right)const { return !(*this == right); @@ -274,7 +274,7 @@ template <class T> struct Vector3 }; }; - + Vector3 operator-( const Vector3 &right )const { return Vector3(x - right.x, y - right.y, z - right.z); @@ -284,7 +284,7 @@ template <class T> struct Vector3 { return Vector3(-x, -y, -z); } - + Vector3& operator-=(const Vector3<T> &right) { x -= right.x; @@ -297,7 +297,7 @@ template <class T> struct Vector3 { return Vector3(x + right.x, y + right.y, z + right.z); } - + Vector3& operator+=(const Vector3<T> &right) { x += right.x; @@ -323,7 +323,7 @@ template <class T> struct Vector3 { return Vector3(x * right.x, y * right.y, z * right.z); } - + Vector3 operator* (const Matrix4x4<T>& m)const { Vector4<T> out4 = Vector4<T>(x, y, z, 1) * m; @@ -377,7 +377,7 @@ template <class T> struct Vector3 { return x == right.x && y == right.y && z == right.z; } - + bool operator != (const Vector3 &right)const { return !(*this == right); @@ -569,7 +569,7 @@ template <class T> struct Vector4 { return x == right.x && y == right.y && z == right.z && w == right.w; } - + bool operator != (const Vector4 &right)const { return !(*this == right); @@ -1419,13 +1419,20 @@ template <class T> struct Matrix4x4 Matrix3x3<T>(_11, _12, _13, _21, _22, _23, _31, _32, _33).Determinant(); - + auto det = _11 * inv._11 + _12 * inv._12 + _13 * inv._13 + _14 * inv._14; inv = inv.Transpose(); inv *= static_cast<T>(1) / det; return inv; } + + Matrix4x4 RemoveTranslation()const + { + Matrix4x4 m(*this); + m._41 = m._42 = m._43 = 0; + return m; + } }; // Template Vector Operations |
