Merge remote-tracking branch 'origin/main' into SP3-2-Physics

This commit is contained in:
Diren D Bharwani 2022-09-28 17:52:02 +08:00
commit c698bac731
12 changed files with 98 additions and 36 deletions

View File

@ -82,4 +82,4 @@ project "SHADE_Application"
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
defines{"_RELEASE", "_PUBLISH"}

View File

@ -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<SBTestScene>("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

View File

@ -42,15 +42,18 @@ namespace Sandbox
std::vector<Handle<SHMesh>> 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();

View File

@ -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
{

View File

@ -9,12 +9,31 @@
consent of DigiPen Institute of Technology is prohibited.
*********************************************************************/
//TODO Legacy code. Delete soon
#include <chrono>
#include <cassert>
#include <SHpch.h>
#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<double> 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;
}
}
}
}
#endif

View File

@ -13,6 +13,38 @@
#define SH_FRAMERATECONTROLLER_H
#pragma once
#include <chrono>
#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

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;