Added Transform, adjusted alignment in math files for better readability on smaller screens

This commit is contained in:
Cocoa 2022-09-19 14:32:01 +08:00
parent 95440b8d26
commit f1e6031d2e
18 changed files with 445 additions and 261 deletions

View File

@ -66,7 +66,7 @@
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -6,6 +6,9 @@
#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR
#include "Math/SHMath.h"
#include "Tools/SHLogger.h"
#include <chrono>
#include <ratio>
#include <ctime>
@ -17,11 +20,14 @@ namespace Sandbox
(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ LPWSTR lpCmdLine,
_In_ INT nCmdShow
)
{
SHADE::SHQuaternion aroundZ20{ SHADE::SHVec3::UnitZ, SHADE::SHMath::DegreesToRadians(20.0f) };
SHLOG_INFO("Angle is {}", SHADE::SHMath::RadiansToDegrees(aroundZ20.GetAngle()))
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
#ifdef SHEDITOR

View File

@ -64,7 +64,7 @@
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -174,8 +174,10 @@
<ClInclude Include="src\Graphics\Windowing\Surface\SHVkSurface.h" />
<ClInclude Include="src\Math\SHMath.h" />
<ClInclude Include="src\Math\SHMathHelpers.h" />
<ClInclude Include="src\Math\SHMathHelpers.hpp" />
<ClInclude Include="src\Math\SHMatrix.h" />
<ClInclude Include="src\Math\SHQuaternion.h" />
<ClInclude Include="src\Math\SHTransform.h" />
<ClInclude Include="src\Math\Vector\SHVec2.h" />
<ClInclude Include="src\Math\Vector\SHVec3.h" />
<ClInclude Include="src\Math\Vector\SHVec4.h" />
@ -250,6 +252,7 @@
<ClCompile Include="src\Math\SHMathHelpers.cpp" />
<ClCompile Include="src\Math\SHMatrix.cpp" />
<ClCompile Include="src\Math\SHQuaternion.cpp" />
<ClCompile Include="src\Math\SHTransform.cpp" />
<ClCompile Include="src\Math\Vector\SHVec2.cpp" />
<ClCompile Include="src\Math\Vector\SHVec3.cpp" />
<ClCompile Include="src\Math\Vector\SHVec4.cpp" />

View File

@ -339,6 +339,9 @@
<ClInclude Include="src\Math\SHQuaternion.h">
<Filter>Math</Filter>
</ClInclude>
<ClInclude Include="src\Math\SHTransform.h">
<Filter>Math</Filter>
</ClInclude>
<ClInclude Include="src\Math\Vector\SHVec2.h">
<Filter>Math\Vector</Filter>
</ClInclude>
@ -382,6 +385,7 @@
<ClInclude Include="src\Tools\SHUtilities.h">
<Filter>Tools</Filter>
</ClInclude>
<ClInclude Include="src\Math\SHMathHelpers.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
@ -555,6 +559,9 @@
<ClCompile Include="src\Math\SHQuaternion.cpp">
<Filter>Math</Filter>
</ClCompile>
<ClCompile Include="src\Math\SHTransform.cpp">
<Filter>Math</Filter>
</ClCompile>
<ClCompile Include="src\Math\Vector\SHVec2.cpp">
<Filter>Math\Vector</Filter>
</ClCompile>

View File

@ -6,4 +6,7 @@
#include "Vector/SHVec3.h"
#include "Vector/SHVec4.h"
#include "SHMatrix.h"
#include "SHQuaternion.h"
#include "SHMatrix.h"
#include "SHTransform.h"

View File

@ -56,25 +56,31 @@ namespace SHADE
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
static void Initialise ();
static void Initialise ();
template <IsArithmetic T>
[[nodiscard]] static constexpr T DegreesToRadians (T angleInDeg);
[[nodiscard]] static T Min (T lhs, T rhs);
template <IsArithmetic T>
[[nodiscard]] static constexpr T RadiansToDegrees (T angleInRad);
[[nodiscard]] static T Max (T lhs, T rhs);
template <IsArithmetic T>
[[nodiscard]] static T Lerp (T a, T b, T alpha);
[[nodiscard]] static T DegreesToRadians (T angleInDeg);
template <IsArithmetic T>
[[nodiscard]] static T ClampedLerp (T a, T b, T alpha, T alphaMin, T alphaMax);
[[nodiscard]] static T RadiansToDegrees (T angleInRad);
template <IsArithmetic T>
[[nodiscard]] static T Wrap (T value, T min, T max);
[[nodiscard]] static T Lerp (T a, T b, T alpha);
template <IsArithmetic T>
[[nodiscard]] static T ClampedLerp (T a, T b, T alpha, T alphaMin, T alphaMax);
template <IsArithmetic T>
[[nodiscard]] static T Wrap (T value, T min, T max);
template <IsArithmetic T = float>
[[nodiscard]] static T GenerateRandomNumber (T lowerBound = 0, T upperBound = 1);
[[nodiscard]] static T GenerateRandomNumber (T lowerBound = 0, T upperBound = 1);
/**
* @brief Compares two floating-point values for equality within given tolerances.
@ -86,7 +92,7 @@ namespace SHADE
* @returns True if the values are equal within the specified tolerances.
*/
template <IsFloatingPoint T = float>
[[nodiscard]] static bool CompareFloat (T lhs, T rhs, T absTolerance = EPSILON, T relTolerance = EPSILON);
[[nodiscard]] static bool CompareFloat (T lhs, T rhs, T absTolerance = EPSILON, T relTolerance = EPSILON);
private:
/*---------------------------------------------------------------------------------*/

View File

@ -13,11 +13,8 @@
// Primary Header
#include "SHMathHelpers.h"
#include <cmath>
#include <algorithm>
// TODOs (Diren): Include pch?
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
@ -25,13 +22,25 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
template <IsArithmetic T>
constexpr T SHMath::DegreesToRadians(T angleInDeg)
T SHMath::Min(T lhs, T rhs)
{
return lhs < rhs ? lhs : rhs;
}
template <IsArithmetic T>
T SHMath::Max(T lhs, T rhs)
{
return lhs > rhs ? lhs : rhs;
}
template <IsArithmetic T>
T SHMath::DegreesToRadians(T angleInDeg)
{
return angleInDeg * static_cast<T>(PI / 180.0f);
}
template <IsArithmetic T>
constexpr T SHMath::RadiansToDegrees(T angleInRad)
T SHMath::RadiansToDegrees(T angleInRad)
{
return angleInRad * static_cast<T>(180.0f / PI);
}
@ -82,9 +91,10 @@ namespace SHADE
template <IsFloatingPoint T>
bool CompareFloat(T lhs, T rhs, T absTolerance, T relTolerance)
bool SHMath::CompareFloat(T lhs, T rhs, T absTolerance, T relTolerance)
{
return std::fabs(lhs - rhs) <= std::max(absTolerance, relTolerance * std::max(abs(lhs), abs(rhs)));
const T RTOL = relTolerance * Max(std::fabs(lhs), std::fabs(rhs));
return std::fabs(lhs - rhs) <= MAX(absTolerance, RTOL);
}
} // namespace SHADE

View File

@ -362,7 +362,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixTranslation(x, y, z));
result.Transpose();
return result;
}
@ -371,7 +370,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixTranslation(pos.x, pos.y, pos.z));
result.Transpose();
return result;
}
@ -382,7 +380,6 @@ namespace SHADE
const XMVECTOR A = XMLoadFloat3(&axis);
XMStoreFloat4x4(&result, XMMatrixRotationAxis(A, angleInRad));
result.Transpose();
return result;
}
@ -391,7 +388,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixRotationRollPitchYaw(pitch, yaw, roll));
result.Transpose();
return result;
}
@ -400,7 +396,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixRotationRollPitchYaw(eulerAngles.x, eulerAngles.y, eulerAngles.z));
result.Transpose();
return result;
}
@ -411,7 +406,6 @@ namespace SHADE
const XMVECTOR Q = XMLoadFloat4(&q);
XMStoreFloat4x4(&result, XMMatrixRotationQuaternion(Q));
result.Transpose();
return result;
}
@ -420,7 +414,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixRotationX(angleInRad));
result.Transpose();
return result;
}
@ -429,7 +422,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixRotationY(angleInRad));
result.Transpose();
return result;
}
@ -438,7 +430,6 @@ namespace SHADE
SHMatrix result;
XMStoreFloat4x4(&result, XMMatrixRotationZ(angleInRad));
result.Transpose();
return result;
}
@ -476,7 +467,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixLookAtRH(EYE, TGT, UP));
result.Transpose();
return result;
}
@ -490,7 +480,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixLookAtLH(EYE, TGT, UP));
result.Transpose();
return result;
}
@ -512,7 +501,6 @@ namespace SHADE
result._42 = pos.y;
result._43 = pos.z;
result.Transpose();
return result;
}
@ -534,7 +522,6 @@ namespace SHADE
result._42 = pos.x;
result._43 = pos.x;
result.Transpose();
return result;
}
@ -544,7 +531,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixPerspectiveFovRH(fov, aspectRatio, nearPlane, farPlane));
result.Transpose();
return result;
}
@ -554,7 +540,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixPerspectiveFovLH(fov, aspectRatio, nearPlane, farPlane));
result.Transpose();
return result;
}
@ -564,7 +549,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixPerspectiveRH(width, height, nearPlane, farPlane));
result.Transpose();
return result;
}
@ -574,7 +558,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixPerspectiveLH(width, height, nearPlane, farPlane));
result.Transpose();
return result;
}
@ -584,7 +567,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixOrthographicRH(width, height, nearPlane, farPlane));
result.Transpose();
return result;
}
@ -594,7 +576,6 @@ namespace SHADE
XMStoreFloat4x4(&result, XMMatrixOrthographicLH(width, height, nearPlane, farPlane));
result.Transpose();
return result;
}

View File

@ -49,96 +49,99 @@ namespace SHADE
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHMatrix (const SHMatrix& rhs) = default;
SHMatrix (SHMatrix&& rhs) = default;
~SHMatrix () = default;
SHMatrix (const SHMatrix& rhs) = default;
SHMatrix (SHMatrix&& rhs) = default;
~SHMatrix () = default;
SHMatrix () noexcept;
SHMatrix ( const SHVec4& r0,
const SHVec4& r1,
const SHVec4& r2,
const SHVec4& r3 = SHVec4::UnitW
) noexcept;
SHMatrix (
float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30 = 0.0f, float m31 = 0.0f, float m32 = 0.0f, float m33 = 1.0f
) noexcept;
SHMatrix () noexcept;
SHMatrix
(
const SHVec4& r0,
const SHVec4& r1,
const SHVec4& r2,
const SHVec4& r3 = SHVec4::UnitW
) noexcept;
SHMatrix
(
float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30 = 0.0f, float m31 = 0.0f, float m32 = 0.0f, float m33 = 1.0f
) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
SHMatrix& operator= (const SHMatrix& rhs) = default;
SHMatrix& operator= (SHMatrix&& rhs) = default;
SHMatrix& operator= (const SHMatrix& rhs) = default;
SHMatrix& operator= (SHMatrix&& rhs) = default;
SHMatrix& operator+= (const SHMatrix& rhs) noexcept;
SHMatrix& operator-= (const SHMatrix& rhs) noexcept;
SHMatrix& operator*= (const SHMatrix& rhs) noexcept;
SHMatrix& operator*= (float rhs) noexcept;
SHMatrix& operator/= (const SHMatrix& rhs) noexcept;
SHMatrix& operator/= (float rhs) noexcept;
SHMatrix& operator+= (const SHMatrix& rhs) noexcept;
SHMatrix& operator-= (const SHMatrix& rhs) noexcept;
SHMatrix& operator*= (const SHMatrix& rhs) noexcept;
SHMatrix& operator*= (float rhs) noexcept;
SHMatrix& operator/= (const SHMatrix& rhs) noexcept;
SHMatrix& operator/= (float rhs) noexcept;
SHMatrix operator+ (const SHMatrix& rhs) const noexcept;
SHMatrix operator- (const SHMatrix& rhs) const noexcept;
SHMatrix operator- () const noexcept;
SHMatrix operator* (const SHMatrix& rhs) const noexcept;
SHVec3 operator* (const SHVec3& rhs) const noexcept;
SHVec4 operator* (const SHVec4& rhs) const noexcept;
SHMatrix operator* (float rhs) const noexcept;
SHMatrix operator/ (const SHMatrix& rhs) const noexcept;
SHMatrix operator/ (float rhs) const noexcept;
[[nodiscard]] SHMatrix operator+ (const SHMatrix& rhs) const noexcept;
[[nodiscard]] SHMatrix operator- (const SHMatrix& rhs) const noexcept;
[[nodiscard]] SHMatrix operator- () const noexcept;
[[nodiscard]] SHMatrix operator* (const SHMatrix& rhs) const noexcept;
[[nodiscard]] SHVec3 operator* (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec4 operator* (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHMatrix operator* (float rhs) const noexcept;
[[nodiscard]] SHMatrix operator/ (const SHMatrix& rhs) const noexcept;
[[nodiscard]] SHMatrix operator/ (float rhs) const noexcept;
bool operator== (const SHMatrix& rhs) const noexcept;
bool operator!= (const SHMatrix& rhs) const noexcept;
[[nodiscard]] bool operator== (const SHMatrix& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHMatrix& rhs) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
void Transpose () noexcept;
void Invert () noexcept;
void Transpose () noexcept;
void Invert () noexcept;
[[nodiscard]] float Determinant () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Determinant () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] static SHMatrix Transpose (const SHMatrix& matrix) noexcept;
[[nodiscard]] static SHMatrix Inverse (const SHMatrix& matrix) noexcept;
[[nodiscard]] static SHMatrix Transpose (const SHMatrix& matrix) noexcept;
[[nodiscard]] static SHMatrix Inverse (const SHMatrix& matrix) noexcept;
[[nodiscard]] static SHMatrix Translate (float x, float y, float z) noexcept;
[[nodiscard]] static SHMatrix Translate (const SHVec3& pos) noexcept;
[[nodiscard]] static SHMatrix Translate (float x, float y, float z) noexcept;
[[nodiscard]] static SHMatrix Translate (const SHVec3& pos) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHVec3& axis, float angleInRad) noexcept;
[[nodiscard]] static SHMatrix Rotate (float yaw, float pitch, float roll) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHVec3& eulerAngles) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHMatrix RotateX (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix RotateY (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix RotateZ (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHVec3& axis, float angleInRad) noexcept;
[[nodiscard]] static SHMatrix Rotate (float yaw, float pitch, float roll) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHVec3& eulerAngles) noexcept;
[[nodiscard]] static SHMatrix Rotate (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHMatrix RotateX (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix RotateY (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix RotateZ (float angleInRad) noexcept;
[[nodiscard]] static SHMatrix Scale (float uniformScaleFactor) noexcept;
[[nodiscard]] static SHMatrix Scale (float x, float y, float z) noexcept;
[[nodiscard]] static SHMatrix Scale (const SHVec3& scale) noexcept;
[[nodiscard]] static SHMatrix Scale (float uniformScaleFactor) noexcept;
[[nodiscard]] static SHMatrix Scale (float x, float y, float z) noexcept;
[[nodiscard]] static SHMatrix Scale (const SHVec3& scale) noexcept;
[[nodiscard]] static SHMatrix LookAtRH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix LookAtLH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix CamToWorldRH (const SHVec3& pos, const SHVec3& forward, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix CamToWorldLH (const SHVec3& pos, const SHVec3& forward, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix PerspectiveFovRH (float fov, float aspectRatio, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveFovLH (float fov, float aspectRatio, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveRH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveLH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix OrthographicRH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix OrthographicLH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix LookAtRH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix LookAtLH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix CamToWorldRH (const SHVec3& pos, const SHVec3& forward, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix CamToWorldLH (const SHVec3& pos, const SHVec3& forward, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix PerspectiveFovRH (float fov, float aspectRatio, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveFovLH (float fov, float aspectRatio, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveRH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix PerspectiveLH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix OrthographicRH (float width, float height, float nearPlane, float farPlane) noexcept;
[[nodiscard]] static SHMatrix OrthographicLH (float width, float height, float nearPlane, float farPlane) noexcept;
// TODO(Diren): Billboard, Shadow, Projection & Reflection
};
SHMatrix operator*(float lhs, const SHMatrix& rhs) noexcept;
SHMatrix operator*(float lhs, const SHMatrix& rhs) noexcept;
} // namespace SHADE

View File

@ -180,6 +180,34 @@ namespace SHADE
return rhs * lhs;
}
/*-----------------------------------------------------------------------------------*/
/* Getter Function Definitions */
/*-----------------------------------------------------------------------------------*/
float SHQuaternion::GetAngle() const noexcept
{
XMVECTOR axis;
float angle;
const XMVECTOR Q = XMLoadFloat4(this);
XMQuaternionToAxisAngle(&axis, &angle, Q);
return angle;
}
SHVec4 SHQuaternion::GetAxisAngle() const noexcept
{
XMVECTOR axis;
float angle;
const XMVECTOR Q = XMLoadFloat4(this);
XMQuaternionToAxisAngle(&axis, &angle, Q);
return SHVec4{XMVectorGetX(axis), XMVectorGetY(axis), XMVectorGetZ(axis), angle};
}
/*-----------------------------------------------------------------------------------*/
/* Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
@ -230,7 +258,7 @@ namespace SHADE
{
std::stringstream ss;
ss << std::fixed << std::setprecision(3);
ss << "<" << x << ", " << y << ", " << z << ", " << w <<">";
ss << "<" << w << ", " << x << ", " << y << ", " << z <<">";
return ss.str();
}

View File

@ -20,6 +20,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
class SHVec3;
class SHVec4;
class SHMatrix;
/*-----------------------------------------------------------------------------------*/
@ -39,68 +40,75 @@ namespace SHADE
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHQuaternion (const SHQuaternion& rhs) = default;
SHQuaternion (SHQuaternion&& rhs) = default;
SHQuaternion (const SHQuaternion& rhs) = default;
SHQuaternion (SHQuaternion&& rhs) = default;
SHQuaternion () noexcept;
SHQuaternion (float x, float y, float z, float w) noexcept;
SHQuaternion (float yaw, float pitch, float roll) noexcept;
SHQuaternion (const SHVec3& eulerAngles) noexcept;
SHQuaternion (const SHVec3& axis, float angleInRad) noexcept;
SHQuaternion (const SHMatrix& rotationMatrix) noexcept;
SHQuaternion () noexcept;
SHQuaternion (float x, float y, float z, float w) noexcept;
SHQuaternion (float yaw, float pitch, float roll) noexcept;
SHQuaternion (const SHVec3& eulerAngles) noexcept;
SHQuaternion (const SHVec3& axis, float angleInRad) noexcept;
SHQuaternion (const SHMatrix& rotationMatrix) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHQuaternion& operator= (const SHQuaternion& rhs) = default;
[[nodiscard]] SHQuaternion& operator= (SHQuaternion&& rhs) = default;
SHQuaternion& operator= (const SHQuaternion& rhs) = default;
SHQuaternion& operator= (SHQuaternion&& rhs) = default;
SHQuaternion& operator+= (const SHQuaternion& rhs) noexcept;
SHQuaternion& operator-= (const SHQuaternion& rhs) noexcept;
SHQuaternion& operator*= (const SHQuaternion& rhs) noexcept;
SHQuaternion& operator*= (float rhs) noexcept;
SHQuaternion& operator/= (const SHQuaternion& rhs) noexcept;
[[nodiscard]] SHQuaternion& operator+= (const SHQuaternion& rhs) noexcept;
[[nodiscard]] SHQuaternion& operator-= (const SHQuaternion& rhs) noexcept;
[[nodiscard]] SHQuaternion& operator*= (const SHQuaternion& rhs) noexcept;
[[nodiscard]] SHQuaternion& operator*= (float rhs) noexcept;
[[nodiscard]] SHQuaternion& operator/= (const SHQuaternion& rhs) noexcept;
[[nodiscard]] SHQuaternion operator+ (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator- (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator- () const noexcept;
[[nodiscard]] SHQuaternion operator* (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator* (float rhs) const noexcept;
[[nodiscard]] SHQuaternion operator/ (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator+ (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator- (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator- () const noexcept;
[[nodiscard]] SHQuaternion operator* (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion operator* (float rhs) const noexcept;
[[nodiscard]] SHQuaternion operator/ (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] bool operator== (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] bool operator== (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHQuaternion& rhs) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] float GetAngle () const noexcept;
[[nodiscard]] SHVec4 GetAxisAngle () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
void Invert () noexcept;
void Invert () noexcept;
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] float Dot (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion RotateTowards (const SHQuaternion& target, float maxAngleInRad) const noexcept;
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] float Dot (const SHQuaternion& rhs) const noexcept;
[[nodiscard]] SHQuaternion RotateTowards (const SHQuaternion& target, float maxAngleInRad) const noexcept;
[[nodiscard]] SHVec3 ToEuler () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] SHVec3 ToEuler () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] static SHQuaternion Normalise (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Conjugate (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Inverse (const SHQuaternion& q) noexcept;
[[nodiscard]] static float Angle (const SHQuaternion& q1, const SHQuaternion& q2) noexcept;
[[nodiscard]] static SHQuaternion Normalise (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Conjugate (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Inverse (const SHQuaternion& q) noexcept;
[[nodiscard]] static float Angle (const SHQuaternion& q1, const SHQuaternion& q2) noexcept;
[[nodiscard]] static SHQuaternion Lerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Slerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Lerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Slerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Rotate (const SHVec3& from, const SHVec3& to) noexcept;
[[nodiscard]] static SHQuaternion Rotate (const SHVec3& from, const SHVec3& to) noexcept;
};
SHQuaternion operator*(float lhs, const SHQuaternion& rhs) noexcept;
SHQuaternion operator*(float lhs, const SHQuaternion& rhs) noexcept;
} // namespace SHADE

View File

@ -0,0 +1,60 @@
/****************************************************************************************
* \file SHTransform.cpp
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Implementation for a Transform.
*
* \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or
* disclosure of this file or its contents without the prior written consent
* of DigiPen Institute of Technology is prohibited.
****************************************************************************************/
#include <SHpch.h>
// Primary Header
#include "SHTransform.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Stai Definitions */
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/
SHTransform::SHTransform() noexcept
: position { SHVec3::Zero }
, rotation { SHVec3::Zero }
, scale { SHVec3::One }
{}
/*-----------------------------------------------------------------------------------*/
/* Getter Function Definitions */
/*-----------------------------------------------------------------------------------*/
const SHMatrix& SHTransform::GetTRS() const
{
return trs;
}
/*-----------------------------------------------------------------------------------*/
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
const SHMatrix& SHTransform::ComputeTRS()
{
const SHMatrix T = SHMatrix::Translate(position);
const SHMatrix R = SHMatrix::Rotate(rotation);
const SHMatrix S = SHMatrix::Scale(scale);
trs = S * R * T;
return trs;
}
} // namespace SHADE

View File

@ -0,0 +1,64 @@
/****************************************************************************************
* \file SHTransform.h
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Interface for a Transform.
*
* \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or
* disclosure of this file or its contents without the prior written consent
* of DigiPen Institute of Technology is prohibited.
****************************************************************************************/
#pragma once
#include "SHMath.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
struct SHTransform
{
public:
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
static const SHTransform Identity;
SHVec3 position;
SHVec3 rotation;
SHVec3 scale;
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHTransform (const SHTransform&) = default;
SHTransform (SHTransform&&) = default;
SHTransform& operator= (const SHTransform&) = default;
SHTransform& operator= (SHTransform&&) = default;
~SHTransform () = default;
SHTransform () noexcept;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] const SHMatrix& GetTRS() const;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
const SHMatrix& ComputeTRS();
private:
SHMatrix trs;
};
} // namespace SHADE

View File

@ -45,53 +45,53 @@ namespace SHADE
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHVec2 (const SHVec2& rhs) = default;
SHVec2 (SHVec2&& rhs) = default;
~SHVec2 () = default;
SHVec2 (const SHVec2& rhs) = default;
SHVec2 (SHVec2&& rhs) = default;
~SHVec2 () = default;
SHVec2 () noexcept;
SHVec2 (float x, float y) noexcept;
SHVec2 () noexcept;
SHVec2 (float x, float y) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHVec2& operator= (const SHVec2& rhs) = default;
[[nodiscard]] SHVec2& operator= (SHVec2&& rhs) = default;
SHVec2& operator= (const SHVec2& rhs) = default;
SHVec2& operator= (SHVec2&& rhs) = default;
[[nodiscard]] SHVec2& operator+= (const SHVec2& rhs) noexcept;
[[nodiscard]] SHVec2& operator-= (const SHVec2& rhs) noexcept;
[[nodiscard]] SHVec2& operator*= (const SHVec2& rhs) noexcept;
[[nodiscard]] SHVec2& operator*= (float rhs) noexcept;
[[nodiscard]] SHVec2& operator/= (const SHVec2& rhs) noexcept;
[[nodiscard]] SHVec2& operator/= (float rhs) noexcept;
SHVec2& operator+= (const SHVec2& rhs) noexcept;
SHVec2& operator-= (const SHVec2& rhs) noexcept;
SHVec2& operator*= (const SHVec2& rhs) noexcept;
SHVec2& operator*= (float rhs) noexcept;
SHVec2& operator/= (const SHVec2& rhs) noexcept;
SHVec2& operator/= (float rhs) noexcept;
[[nodiscard]] SHVec2 operator+ (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator- (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator- () const noexcept;
[[nodiscard]] SHVec2 operator* (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec2 operator/ (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator/ (float rhs) const noexcept;
[[nodiscard]] SHVec2 operator+ (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator- (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator- () const noexcept;
[[nodiscard]] SHVec2 operator* (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec2 operator/ (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 operator/ (float rhs) const noexcept;
[[nodiscard]] bool operator== (const SHVec2& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec2& rhs) const noexcept;
[[nodiscard]] bool operator== (const SHVec2& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec2& rhs) const noexcept;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Dot (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 Cross (const SHVec2& rhs) const noexcept;
[[nodiscard]] float Dot (const SHVec2& rhs) const noexcept;
[[nodiscard]] SHVec2 Cross (const SHVec2& rhs) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
@ -117,6 +117,6 @@ namespace SHADE
[[nodiscard]] static float Cross (const SHVec2& lhs, const SHVec2& rhs) noexcept;
};
SHVec2 operator* (float lhs, const SHVec2& rhs) noexcept;
SHVec2 operator* (float lhs, const SHVec2& rhs) noexcept;
} // namespace SHADE

View File

@ -50,62 +50,62 @@ namespace SHADE
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHVec3 (const SHVec3& rhs) = default;
SHVec3 (SHVec3&& rhs) = default;
~SHVec3 () = default;
SHVec3 (const SHVec3& rhs) = default;
SHVec3 (SHVec3&& rhs) = default;
~SHVec3 () = default;
SHVec3 () noexcept;
SHVec3 (float x, float y, float z) noexcept;
SHVec3 () noexcept;
SHVec3 (float x, float y, float z) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHVec3& operator= (const SHVec3& rhs) = default;
[[nodiscard]] SHVec3& operator= (SHVec3&& rhs) = default;
SHVec3& operator= (const SHVec3& rhs) = default;
SHVec3& operator= (SHVec3&& rhs) = default;
[[nodiscard]] SHVec3& operator+= (const SHVec3& rhs) noexcept;
[[nodiscard]] SHVec3& operator-= (const SHVec3& rhs) noexcept;
[[nodiscard]] SHVec3& operator*= (const SHVec3& rhs) noexcept;
[[nodiscard]] SHVec3& operator*= (float rhs) noexcept;
[[nodiscard]] SHVec3& operator/= (const SHVec3& rhs) noexcept;
[[nodiscard]] SHVec3& operator/= (float rhs) noexcept;
SHVec3& operator+= (const SHVec3& rhs) noexcept;
SHVec3& operator-= (const SHVec3& rhs) noexcept;
SHVec3& operator*= (const SHVec3& rhs) noexcept;
SHVec3& operator*= (float rhs) noexcept;
SHVec3& operator/= (const SHVec3& rhs) noexcept;
SHVec3& operator/= (float rhs) noexcept;
[[nodiscard]] SHVec3 operator+ (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator- (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator- () const noexcept;
[[nodiscard]] SHVec3 operator* (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec3 operator/ (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator/ (float rhs) const noexcept;
[[nodiscard]] SHVec3 operator+ (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator- (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator- () const noexcept;
[[nodiscard]] SHVec3 operator* (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec3 operator/ (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 operator/ (float rhs) const noexcept;
[[nodiscard]] bool operator== (const SHVec3& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec3& rhs) const noexcept;
[[nodiscard]] bool operator== (const SHVec3& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec3& rhs) const noexcept;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Dot (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 Cross (const SHVec3& rhs) const noexcept;
[[nodiscard]] float Dot (const SHVec3& rhs) const noexcept;
[[nodiscard]] SHVec3 Cross (const SHVec3& rhs) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] static SHVec3 Normalise (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Abs (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Min (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Max (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Normalise (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Abs (const SHVec3& v) noexcept;
[[nodiscard]] static SHVec3 Min (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Max (const std::initializer_list<SHVec3>& vs) noexcept;
[[nodiscard]] static SHVec3 Clamp (const SHVec3& v, const SHVec3& vMin, const SHVec3& vMax) noexcept;
[[nodiscard]] static SHVec3 Lerp (const SHVec3& a, const SHVec3& b, float t) noexcept;
[[nodiscard]] static SHVec3 ClampedLerp (const SHVec3& a, const SHVec3& b, float t, float tMin = 0.0f, float tMax = 1.0f) noexcept;
@ -124,6 +124,6 @@ namespace SHADE
[[nodiscard]] static SHVec3 Transform (const SHVec3& v, const SHMatrix& transformMtx) noexcept;
};
SHVec3 operator* (float lhs, const SHVec3& rhs) noexcept;
SHVec3 operator* (float lhs, const SHVec3& rhs) noexcept;
} // namespace SHADE

View File

@ -45,57 +45,57 @@ namespace SHADE
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHVec4 (const SHVec4& rhs) = default;
SHVec4 (SHVec4&& rhs) = default;
~SHVec4 () = default;
SHVec4 (const SHVec4& rhs) = default;
SHVec4 (SHVec4&& rhs) = default;
~SHVec4 () = default;
SHVec4 () noexcept;
SHVec4 (float x, float y, float z, float w) noexcept;
SHVec4 () noexcept;
SHVec4 (float x, float y, float z, float w) noexcept;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] SHVec4& operator= (const SHVec4& rhs) = default;
[[nodiscard]] SHVec4& operator= (SHVec4&& rhs) = default;
[[nodiscard]] SHVec4& operator+= (const SHVec4& rhs) noexcept;
[[nodiscard]] SHVec4& operator-= (const SHVec4& rhs) noexcept;
[[nodiscard]] SHVec4& operator*= (const SHVec4& rhs) noexcept;
[[nodiscard]] SHVec4& operator*= (float rhs) noexcept;
[[nodiscard]] SHVec4& operator/= (const SHVec4& rhs) noexcept;
[[nodiscard]] SHVec4& operator/= (float rhs) noexcept;
SHVec4& operator= (const SHVec4& rhs) = default;
SHVec4& operator= (SHVec4&& rhs) = default;
[[nodiscard]] SHVec4 operator+ (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator- (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator- () const noexcept;
[[nodiscard]] SHVec4 operator* (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec4 operator/ (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator/ (float rhs) const noexcept;
SHVec4& operator+= (const SHVec4& rhs) noexcept;
SHVec4& operator-= (const SHVec4& rhs) noexcept;
SHVec4& operator*= (const SHVec4& rhs) noexcept;
SHVec4& operator*= (float rhs) noexcept;
SHVec4& operator/= (const SHVec4& rhs) noexcept;
SHVec4& operator/= (float rhs) noexcept;
[[nodiscard]] bool operator== (const SHVec4& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator+ (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator- (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator- () const noexcept;
[[nodiscard]] SHVec4 operator* (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator* (float rhs) const noexcept;
[[nodiscard]] SHVec4 operator/ (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 operator/ (float rhs) const noexcept;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
[[nodiscard]] bool operator== (const SHVec4& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec4& rhs) const noexcept;
[[nodiscard]] float operator[] (int index);
[[nodiscard]] float operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const;
/*---------------------------------------------------------------------------------*/
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float Length3D () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] float LengthSquared3D () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Length () const noexcept;
[[nodiscard]] float Length3D () const noexcept;
[[nodiscard]] float LengthSquared () const noexcept;
[[nodiscard]] float LengthSquared3D () const noexcept;
[[nodiscard]] std::string ToString () const noexcept;
[[nodiscard]] float Dot (const SHVec4& rhs) const noexcept;
[[nodiscard]] float Dot3D (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 Cross3D (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 Cross (const SHVec4& v1, const SHVec4& v2) const noexcept;
[[nodiscard]] float Dot (const SHVec4& rhs) const noexcept;
[[nodiscard]] float Dot3D (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 Cross3D (const SHVec4& rhs) const noexcept;
[[nodiscard]] SHVec4 Cross (const SHVec4& v1, const SHVec4& v2) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Static Function Members */
@ -128,6 +128,6 @@ namespace SHADE
};
SHVec4 operator* (float lhs, const SHVec4& rhs) noexcept;
SHVec4 operator* (float lhs, const SHVec4& rhs) noexcept;
} // namespace SHADE

View File

@ -9,7 +9,10 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX
// Windows Header Files
#include <Windows.h>
// C RunTime Header Files
@ -30,3 +33,5 @@
#include <functional>
#include <sstream>
#include <iomanip>
#include "Tools/SHLogger.h"

View File

@ -70,33 +70,33 @@ namespace SHADE
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] static const std::string& GetTrivialPattern () noexcept { return trivialPattern; }
[[nodiscard]] static const std::string& GetVerbosePattern () noexcept { return verbosePattern; }
[[nodiscard]] static const std::string& GetTrivialPattern () noexcept { return trivialPattern; }
[[nodiscard]] static const std::string& GetVerbosePattern () noexcept { return verbosePattern; }
/*---------------------------------------------------------------------------------*/
/* Setter Functions */
/*---------------------------------------------------------------------------------*/
static void SetTrivialPattern (const std::string& pattern) noexcept { trivialPattern = pattern; }
static void SetVerbosePattern (const std::string& pattern) noexcept { verbosePattern = pattern; }
static void SetTrivialPattern (const std::string& pattern) noexcept { trivialPattern = pattern; }
static void SetVerbosePattern (const std::string& pattern) noexcept { verbosePattern = pattern; }
static void SetConfig (const Config& config) noexcept;
static void SetConfig (const Config& config) noexcept;
static void SetShowTime (bool showTime) noexcept;
static void SetShowDate (bool showDate) noexcept;
static void SetShowFunctionFileName (bool showFunctionFileName) noexcept;
static void SetShowFunctionLineNumber (bool showFunctionLineNumber) noexcept;
static void SetShowTime (bool showTime) noexcept;
static void SetShowDate (bool showDate) noexcept;
static void SetShowFunctionFileName (bool showFunctionFileName) noexcept;
static void SetShowFunctionLineNumber (bool showFunctionLineNumber) noexcept;
static void SetClockFormat (ClockFormat newClockFormat) noexcept;
static void SetDateFormat (DateFormat newDateFormat) noexcept;
static void SetClockFormat (ClockFormat newClockFormat) noexcept;
static void SetDateFormat (DateFormat newDateFormat) noexcept;
static void SetFileName (const std::string& logFileName) noexcept;
static void SetDirectoryPath (const std::filesystem::path& logDirectoryPath) noexcept;
static void SetFileName (const std::string& logFileName) noexcept;
static void SetDirectoryPath (const std::filesystem::path& logDirectoryPath) noexcept;
static void SetFlushTime (int seconds) noexcept;
static void SetFlushTime (size_t seconds) noexcept { spdlog::flush_every(std::chrono::seconds(seconds)); }
static void SetFlushTime (int seconds) noexcept;
static void SetFlushTime (size_t seconds) noexcept { spdlog::flush_every(std::chrono::seconds(seconds)); }
/*---------------------------------------------------------------------------------*/
/* Function Members */