Added Matrix * Vec4

This commit is contained in:
Diren D Bharwani 2022-10-30 14:37:30 +08:00
parent 54b7fa7cd3
commit 605ff9710d
4 changed files with 12 additions and 7 deletions

View File

@ -191,7 +191,7 @@ namespace SHADE
SHVec4 SHMatrix::operator*(const SHVec4& rhs) const noexcept
{
return SHVec4::Transform3D(rhs, *this);
return SHVec4::Transform(rhs, *this);
}
SHMatrix SHMatrix::operator*(float rhs) const noexcept

View File

@ -445,9 +445,7 @@ namespace SHADE
{
SHVec3 result;
const XMMATRIX TF = XMLoadFloat4x4(&transformMtx);
XMStoreFloat3(&result, XMVector3TransformCoord(v, TF));
XMStoreFloat3(&result, XMVector3TransformCoord(v, transformMtx));
return result;
}
}

View File

@ -460,13 +460,19 @@ namespace SHADE
return result;
}
SHVec4 SHVec4::Transform(const SHVec4& v, const SHMatrix& transformMtx) noexcept
{
SHVec4 result;
XMStoreFloat4(&result, XMVector4Transform(v, transformMtx));
return result;
}
SHVec4 SHVec4::Transform3D(const SHVec4& v, const SHMatrix& transformMtx) noexcept
{
SHVec4 result;
const XMMATRIX TF = XMLoadFloat4x4(&transformMtx);
XMStoreFloat4(&result, XMVector3TransformCoord(v, TF));
XMStoreFloat4(&result, XMVector3TransformCoord(v, transformMtx));
return result;
}
}

View File

@ -134,6 +134,7 @@ namespace SHADE
[[nodiscard]] static SHVec4 Project3D (const SHVec4& v, const SHVec4& u) noexcept;
[[nodiscard]] static SHVec4 Reflect (const SHVec4& v, const SHVec4& normal) noexcept;
[[nodiscard]] static SHVec4 Reflect3D (const SHVec4& v, const SHVec4& normal) noexcept;
[[nodiscard]] static SHVec4 Transform (const SHVec4& v, const SHMatrix& transformMtx) noexcept;
[[nodiscard]] static SHVec4 Transform3D (const SHVec4& v, const SHMatrix& transformMtx) noexcept;
};