diff --git a/SHADE_Application/premake5.lua b/SHADE_Application/premake5.lua index 27910231..0e1acc05 100644 --- a/SHADE_Application/premake5.lua +++ b/SHADE_Application/premake5.lua @@ -82,4 +82,4 @@ project "SHADE_Application" filter "configurations:Publish" optimize "On" - defines{"_RELEASE"} + defines{"_RELEASE", "_PUBLISH"} diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index fdc933b9..8135a4dc 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -29,6 +29,8 @@ #include "Scripting/SHScriptEngine.h" #include "Physics/SHPhysicsSystem.h" #include "Math/Transform/SHTransformSystem.h" +#include "Input/SHInputManagerSystem.h" +#include "FRC/SHFramerateController.h" // Components #include "Graphics/MiddleEnd/Interface/SHRenderable.h" @@ -105,6 +107,7 @@ namespace Sandbox #endif SHSceneManager::InitSceneManager("TestScene"); + SHFrameRateController::UpdateFRC(); } void SBApplication::Update(void) @@ -113,6 +116,7 @@ namespace Sandbox //TODO: Change true to window is open while (!window.WindowShouldClose()) { + SHFrameRateController::UpdateFRC(); SHSceneManager::UpdateSceneManager(); SHSceneManager::SceneUpdate(1/60.0f); //#ifdef SHEDITOR diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp index a18b4894..0f42b419 100644 --- a/SHADE_Application/src/Scenes/SBTestScene.cpp +++ b/SHADE_Application/src/Scenes/SBTestScene.cpp @@ -42,15 +42,18 @@ namespace Sandbox std::vector> handles; for (auto const& mesh : meshes) { - handles.push_back(graphicsSystem->AddMesh( - mesh.header.vertexCount, - mesh.vertexPosition.data(), - mesh.texCoords.data(), - mesh.vertexTangent.data(), - mesh.vertexNormal.data(), - mesh.header.indexCount, - mesh.indices.data() - )); + if (mesh.meshName == "Cube.012") + { + handles.push_back(graphicsSystem->AddMesh( + mesh.header.vertexCount, + mesh.vertexPosition.data(), + mesh.texCoords.data(), + mesh.vertexTangent.data(), + mesh.vertexNormal.data(), + mesh.header.indexCount, + mesh.indices.data() + )); + } } graphicsSystem->BuildMeshBuffers(); diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua index 7de741b7..444dad12 100644 --- a/SHADE_Engine/premake5.lua +++ b/SHADE_Engine/premake5.lua @@ -113,6 +113,9 @@ project "SHADE_Engine" filter "configurations:Release" postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""} + filter "configurations:Publish" + postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""} + warnings 'Extra' filter "configurations:Debug" @@ -129,7 +132,7 @@ project "SHADE_Engine" filter "configurations:Publish" optimize "On" - defines{"_RELEASE"} + defines{"_RELEASE", "_PUBLISH"} links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"} excludes { diff --git a/SHADE_Engine/src/FRC/SHFramerateController.cpp b/SHADE_Engine/src/FRC/SHFramerateController.cpp index d64c6336..0791d628 100644 --- a/SHADE_Engine/src/FRC/SHFramerateController.cpp +++ b/SHADE_Engine/src/FRC/SHFramerateController.cpp @@ -9,12 +9,31 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ + +//TODO Legacy code. Delete soon + #include #include #include #include "SHFramerateController.h" #include "../Tools/SHLogger.h" +namespace SHADE +{ + double SHFrameRateController::rawDeltaTime = 0.0; + std::chrono::steady_clock::time_point SHFrameRateController::prevFrameTime = std::chrono::high_resolution_clock::now(); + + void SHFrameRateController::UpdateFRC() noexcept + { + std::chrono::duration deltaTime; + deltaTime = std::chrono::high_resolution_clock::now() - prevFrameTime; + prevFrameTime = std::chrono::high_resolution_clock::now(); + rawDeltaTime = deltaTime.count(); + } +} + +//TODO Legacy code. Delete soon +#if 0 namespace SHADE { //Init statics @@ -131,4 +150,5 @@ namespace SHADE currentScene = nextScene; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/SHADE_Engine/src/FRC/SHFramerateController.h b/SHADE_Engine/src/FRC/SHFramerateController.h index 26f276d8..b9637cf2 100644 --- a/SHADE_Engine/src/FRC/SHFramerateController.h +++ b/SHADE_Engine/src/FRC/SHFramerateController.h @@ -13,6 +13,38 @@ #define SH_FRAMERATECONTROLLER_H #pragma once +#include +#include "Tools/SHLogger.h" +#include "SH_API.h" + +namespace SHADE +{ + class SH_API SHFrameRateController + { + private: + //Varying delta time. The actual time it took for every frame + static double rawDeltaTime; + static std::chrono::steady_clock::time_point prevFrameTime; + + + public: + //Gets the raw delta time + static inline double GetRawDeltaTime() noexcept + { + return rawDeltaTime; + } + + //Updates the raw delta time accordingly + static void UpdateFRC() noexcept; + + }; + +} + + + +//TODO Legacy code. Delete soon +#if 0 #include "../Scene/SHScene.h" namespace SHADE @@ -56,7 +88,19 @@ namespace SHADE //halt execution of the current scene and prepare //execution of the next static inline void SetNextScene(SHScene* const next) { nextScene = next; } + + + }; + + + } +#endif + + + + + #endif \ No newline at end of file diff --git a/SHADE_Engine/src/Math/Vector/SHVec2.cpp b/SHADE_Engine/src/Math/Vector/SHVec2.cpp index 2d2eafd2..545492cb 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec2.cpp +++ b/SHADE_Engine/src/Math/Vector/SHVec2.cpp @@ -165,7 +165,7 @@ namespace SHADE return XMVector2NotEqual(V1, V2); } - float SHVec2::operator[](int index) + float& SHVec2::operator[](int index) { if (index >= SIZE || index < 0) throw std::invalid_argument("Index out of range!"); @@ -174,11 +174,10 @@ namespace SHADE { case 0: return x; case 1: return y; - default: return 0.0f; } } - float SHVec2::operator[](size_t index) + float& SHVec2::operator[](size_t index) { if (index >= SIZE) throw std::invalid_argument("Index out of range!"); @@ -187,7 +186,6 @@ namespace SHADE { case 0: return x; case 1: return y; - default: return 0.0f; } } @@ -200,7 +198,6 @@ namespace SHADE { case 0: return x; case 1: return y; - default: return 0.0f; } } @@ -213,7 +210,6 @@ namespace SHADE { case 0: return x; case 1: return y; - default: return 0.0f; } } diff --git a/SHADE_Engine/src/Math/Vector/SHVec2.h b/SHADE_Engine/src/Math/Vector/SHVec2.h index 3e6287aa..17642126 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec2.h +++ b/SHADE_Engine/src/Math/Vector/SHVec2.h @@ -81,8 +81,8 @@ namespace SHADE [[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); + [[nodiscard]] float& operator[] (size_t index); [[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (size_t index) const; diff --git a/SHADE_Engine/src/Math/Vector/SHVec3.cpp b/SHADE_Engine/src/Math/Vector/SHVec3.cpp index 194f7964..1bcb47b3 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec3.cpp +++ b/SHADE_Engine/src/Math/Vector/SHVec3.cpp @@ -171,7 +171,7 @@ namespace SHADE return XMVector3NotEqual(V1, V2); } - float SHVec3::operator[](int index) + float& SHVec3::operator[](int index) { if (index >= SIZE || index < 0) throw std::invalid_argument("Index out of range!"); @@ -181,11 +181,10 @@ namespace SHADE case 0: return x; case 1: return y; case 2: return z; - default: return 0.0f; } } - float SHVec3::operator[](size_t index) + float& SHVec3::operator[](size_t index) { if (index >= SIZE) throw std::invalid_argument("Index out of range!"); @@ -195,7 +194,6 @@ namespace SHADE case 0: return x; case 1: return y; case 2: return z; - default: return 0.0f; } } @@ -209,7 +207,6 @@ namespace SHADE case 0: return x; case 1: return y; case 2: return z; - default: return 0.0f; } } @@ -223,7 +220,6 @@ namespace SHADE case 0: return x; case 1: return y; case 2: return z; - default: return 0.0f; } } diff --git a/SHADE_Engine/src/Math/Vector/SHVec3.h b/SHADE_Engine/src/Math/Vector/SHVec3.h index 476d7b0f..cc0e043e 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec3.h +++ b/SHADE_Engine/src/Math/Vector/SHVec3.h @@ -86,8 +86,8 @@ namespace SHADE [[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); + [[nodiscard]] float& operator[] (size_t index); [[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (size_t index) const; diff --git a/SHADE_Engine/src/Math/Vector/SHVec4.cpp b/SHADE_Engine/src/Math/Vector/SHVec4.cpp index 5d75af33..d1c87865 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec4.cpp +++ b/SHADE_Engine/src/Math/Vector/SHVec4.cpp @@ -161,7 +161,7 @@ namespace SHADE return XMVector4NotEqual(V1, V2); } - float SHVec4::operator[](int index) + float& SHVec4::operator[](int index) { if (index >= SIZE || index < 0) throw std::invalid_argument("Index out of range!"); @@ -172,11 +172,10 @@ namespace SHADE case 1: return y; case 2: return z; case 3: return w; - default: return 0.0f; } } - float SHVec4::operator[](size_t index) + float& SHVec4::operator[](size_t index) { if (index >= SIZE) throw std::invalid_argument("Index out of range!"); @@ -187,7 +186,6 @@ namespace SHADE case 1: return y; case 2: return z; case 3: return w; - default: return 0.0f; } } @@ -202,7 +200,6 @@ namespace SHADE case 1: return y; case 2: return z; case 3: return w; - default: return 0.0f; } } @@ -217,7 +214,6 @@ namespace SHADE case 1: return y; case 2: return z; case 3: return w; - default: return 0.0f; } } diff --git a/SHADE_Engine/src/Math/Vector/SHVec4.h b/SHADE_Engine/src/Math/Vector/SHVec4.h index a4a5208a..59038065 100644 --- a/SHADE_Engine/src/Math/Vector/SHVec4.h +++ b/SHADE_Engine/src/Math/Vector/SHVec4.h @@ -80,8 +80,8 @@ namespace SHADE [[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); + [[nodiscard]] float& operator[] (size_t index); [[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (size_t index) const;