Merge branch 'main' into SP3-4-editor_fix
This commit is contained in:
commit
9913e5a68b
|
@ -67,9 +67,16 @@ project "SHADE_Application"
|
||||||
|
|
||||||
disablewarnings
|
disablewarnings
|
||||||
{
|
{
|
||||||
"4251"
|
"4251",
|
||||||
|
"26812",
|
||||||
|
"26439",
|
||||||
|
"26451",
|
||||||
|
"26437",
|
||||||
|
"4275"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkoptions { "-IGNORE:4006" }
|
||||||
|
|
||||||
warnings 'Extra'
|
warnings 'Extra'
|
||||||
|
|
||||||
filter "configurations:Debug"
|
filter "configurations:Debug"
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN 1
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "Scripting/SHScriptEngine.h"
|
#include "Scripting/SHScriptEngine.h"
|
||||||
|
@ -23,7 +22,7 @@
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
#include "Math/Transform/SHTransformSystem.h"
|
#include "Math/Transform/SHTransformSystem.h"
|
||||||
#include "Input/SHInputManagerSystem.h"
|
#include "Input/SHInputManager.h"
|
||||||
#include "FRC/SHFramerateController.h"
|
#include "FRC/SHFramerateController.h"
|
||||||
#include "AudioSystem/SHAudioSystem.h"
|
#include "AudioSystem/SHAudioSystem.h"
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ namespace Sandbox
|
||||||
// TODO(Diren): Create Physics System here
|
// TODO(Diren): Create Physics System here
|
||||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHTransformSystem>();
|
SHADE::SHSystemManager::CreateSystem<SHADE::SHTransformSystem>();
|
||||||
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
||||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHInputManagerSystem>();
|
|
||||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHAudioSystem>();
|
SHADE::SHSystemManager::CreateSystem<SHADE::SHAudioSystem>();
|
||||||
|
|
||||||
// Create Routines
|
// Create Routines
|
||||||
|
@ -80,8 +78,6 @@ namespace Sandbox
|
||||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
|
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
|
||||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>();
|
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>();
|
||||||
|
|
||||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHInputManagerSystem, SHADE::SHInputManagerSystem::InputManagerRoutine>();
|
|
||||||
|
|
||||||
//TODO: REMOVE AFTER PRESENTATION
|
//TODO: REMOVE AFTER PRESENTATION
|
||||||
//SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
|
//SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
|
||||||
SHADE::SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
|
SHADE::SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
|
||||||
|
@ -121,6 +117,7 @@ namespace Sandbox
|
||||||
while (!window.WindowShouldClose())
|
while (!window.WindowShouldClose())
|
||||||
{
|
{
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
|
SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime());
|
||||||
SHSceneManager::UpdateSceneManager();
|
SHSceneManager::UpdateSceneManager();
|
||||||
SHSceneManager::SceneUpdate(1/60.0f);
|
SHSceneManager::SceneUpdate(1/60.0f);
|
||||||
//#ifdef SHEDITOR
|
//#ifdef SHEDITOR
|
||||||
|
|
|
@ -76,8 +76,15 @@ project "SHADE_Engine"
|
||||||
|
|
||||||
disablewarnings
|
disablewarnings
|
||||||
{
|
{
|
||||||
"4251"
|
"4251",
|
||||||
|
"26812",
|
||||||
|
"26439",
|
||||||
|
"26451",
|
||||||
|
"26437",
|
||||||
|
"4275"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkoptions { "-IGNORE:4006" }
|
||||||
|
|
||||||
defines
|
defines
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "SHWindowMap.h"
|
#include "SHWindowMap.h"
|
||||||
#include "SHWindow.h"
|
#include "SHWindow.h"
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
#include "Input/SHInputManagerSystem.h"
|
#include "Input/SHInputManager.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -343,10 +343,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
if (auto im = SHSystemManager::GetSystem<SHInputManagerSystem>())
|
SHInputManager::PollWheelVerticalDelta(wparam);
|
||||||
{
|
|
||||||
im->PollWheelVerticalDelta(wparam);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* \file SHInputManagerSystem.cpp
|
* \file SHInputManager.cpp
|
||||||
* \author Ryan Wang Nian Jing
|
* \author Ryan Wang Nian Jing
|
||||||
* \brief Definition of input manager.
|
* \brief Definition of input manager.
|
||||||
* Handles input from keyboard and mouse. Soon to include controller.
|
* Handles input from keyboard and mouse. Soon to include controller.
|
||||||
|
@ -11,7 +11,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <SHpch.h>
|
#include <SHpch.h>
|
||||||
#include "SHInputManagerSystem.h"
|
#include "SHInputManager.h"
|
||||||
|
#include "../Tools/SHException.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -19,61 +20,34 @@ namespace SHADE
|
||||||
/* Static defines */
|
/* Static defines */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
unsigned SHInputManagerSystem::keyCount = 0;
|
unsigned SHInputManager::keyCount = 0;
|
||||||
bool SHInputManagerSystem::keys[MAX_KEYS];
|
bool SHInputManager::keys[MAX_KEYS];
|
||||||
bool SHInputManagerSystem::keysLast[MAX_KEYS];
|
bool SHInputManager::keysLast[MAX_KEYS];
|
||||||
double SHInputManagerSystem::keysHeldTime[MAX_KEYS];
|
double SHInputManager::keysHeldTime[MAX_KEYS];
|
||||||
double SHInputManagerSystem::keysReleasedTime[MAX_KEYS];
|
double SHInputManager::keysReleasedTime[MAX_KEYS];
|
||||||
|
|
||||||
unsigned SHInputManagerSystem::keyToggleCount = 0;
|
unsigned SHInputManager::keyToggleCount = 0;
|
||||||
bool SHInputManagerSystem::keysToggle[MAX_KEYS];
|
bool SHInputManager::keysToggle[MAX_KEYS];
|
||||||
bool SHInputManagerSystem::keysToggleLast[MAX_KEYS];
|
bool SHInputManager::keysToggleLast[MAX_KEYS];
|
||||||
double SHInputManagerSystem::keysToggleOnTime[MAX_KEYS];
|
double SHInputManager::keysToggleOnTime[MAX_KEYS];
|
||||||
double SHInputManagerSystem::keysToggleOffTime[MAX_KEYS];
|
double SHInputManager::keysToggleOffTime[MAX_KEYS];
|
||||||
|
|
||||||
int SHInputManagerSystem::mouseScreenX = 0;
|
int SHInputManager::mouseScreenX = 0;
|
||||||
int SHInputManagerSystem::mouseScreenY = 0;
|
int SHInputManager::mouseScreenY = 0;
|
||||||
int SHInputManagerSystem::mouseScreenXLast = 0;
|
int SHInputManager::mouseScreenXLast = 0;
|
||||||
int SHInputManagerSystem::mouseScreenYLast = 0;
|
int SHInputManager::mouseScreenYLast = 0;
|
||||||
double SHInputManagerSystem::mouseVelocityX = 0;
|
double SHInputManager::mouseVelocityX = 0;
|
||||||
double SHInputManagerSystem::mouseVelocityY = 0;
|
double SHInputManager::mouseVelocityY = 0;
|
||||||
int SHInputManagerSystem::mouseWheelVerticalDelta = 0;
|
int SHInputManager::mouseWheelVerticalDelta = 0;
|
||||||
int SHInputManagerSystem::mouseWheelVerticalDeltaPoll = 0;
|
int SHInputManager::mouseWheelVerticalDeltaPoll = 0;
|
||||||
|
|
||||||
void SHInputManagerSystem::Init()
|
void SHInputManager::UpdateInput(double dt) noexcept
|
||||||
{
|
|
||||||
keyCount = 0;
|
|
||||||
SecureZeroMemory(keys, sizeof(keys));
|
|
||||||
SecureZeroMemory(keysLast, sizeof(keysLast));
|
|
||||||
SecureZeroMemory(keysHeldTime, sizeof(keysHeldTime));
|
|
||||||
SecureZeroMemory(keysReleasedTime, sizeof(keysReleasedTime));
|
|
||||||
|
|
||||||
keyToggleCount = 0;
|
|
||||||
SecureZeroMemory(keysToggle, sizeof(keysToggle));
|
|
||||||
SecureZeroMemory(keysToggleLast, sizeof(keysToggleLast));
|
|
||||||
SecureZeroMemory(keysToggleOnTime, sizeof(keysToggleOnTime));
|
|
||||||
SecureZeroMemory(keysToggleOffTime, sizeof(keysToggleOffTime));
|
|
||||||
|
|
||||||
mouseScreenX = 0;
|
|
||||||
mouseScreenY = 0;
|
|
||||||
mouseScreenXLast = 0;
|
|
||||||
mouseScreenYLast = 0;
|
|
||||||
mouseWheelVerticalDelta = 0;
|
|
||||||
mouseWheelVerticalDeltaPoll = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SHInputManagerSystem::Exit()
|
|
||||||
{
|
|
||||||
//No dynamically allocated memory. Nothing to do here.
|
|
||||||
}
|
|
||||||
|
|
||||||
void SHInputManagerSystem::InputManagerRoutine::
|
|
||||||
FixedExecute(double dt) noexcept
|
|
||||||
{
|
{
|
||||||
//Keyboard and Mouse Buttons////////////////////////////////////////////////
|
//Keyboard and Mouse Buttons////////////////////////////////////////////////
|
||||||
//Poll
|
//Poll
|
||||||
unsigned char keyboardState[MAX_KEYS];
|
unsigned char keyboardState[MAX_KEYS];
|
||||||
GetKeyboardState(keyboardState);
|
//if (GetKeyboardState(keyboardState) == false) return;
|
||||||
|
SHASSERT(GetKeyboardState(keyboardState), "SHInputManager:GetKeyboardState() failed ({})", GetLastError());
|
||||||
keyCount = 0;
|
keyCount = 0;
|
||||||
keyToggleCount = 0;
|
keyToggleCount = 0;
|
||||||
for (size_t i = 0; i < MAX_KEYS; ++i)
|
for (size_t i = 0; i < MAX_KEYS; ++i)
|
||||||
|
@ -138,13 +112,17 @@ namespace SHADE
|
||||||
mouseScreenX = p.x;
|
mouseScreenX = p.x;
|
||||||
mouseScreenY = p.y;
|
mouseScreenY = p.y;
|
||||||
|
|
||||||
|
//Velocity
|
||||||
|
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
||||||
|
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
||||||
|
|
||||||
//Mouse wheel vertical delta updating
|
//Mouse wheel vertical delta updating
|
||||||
mouseWheelVerticalDelta = 0;
|
mouseWheelVerticalDelta = 0;
|
||||||
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
||||||
mouseWheelVerticalDeltaPoll = 0;
|
mouseWheelVerticalDeltaPoll = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManagerSystem::AnyKeyDown(SH_KEYCODE* firstDetected) noexcept
|
bool SHInputManager::AnyKeyDown(SH_KEYCODE* firstDetected) noexcept
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < MAX_KEYS; ++i)
|
for (size_t i = 0; i < MAX_KEYS; ++i)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +135,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManagerSystem::AnyKey(SH_KEYCODE* firstDetected) noexcept
|
bool SHInputManager::AnyKey(SH_KEYCODE* firstDetected) noexcept
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < MAX_KEYS; ++i)
|
for (size_t i = 0; i < MAX_KEYS; ++i)
|
||||||
{
|
{
|
||||||
|
@ -170,7 +148,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManagerSystem::AnyKeyUp(SH_KEYCODE* firstDetected) noexcept
|
bool SHInputManager::AnyKeyUp(SH_KEYCODE* firstDetected) noexcept
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < MAX_KEYS; ++i)
|
for (size_t i = 0; i < MAX_KEYS; ++i)
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* \file SHInputManagerSystem.h
|
* \file SHInputManager.h
|
||||||
* \author Ryan Wang Nian Jing
|
* \author Ryan Wang Nian Jing
|
||||||
* \brief Declaration of input manager.
|
* \brief Declaration of input manager.
|
||||||
* Handles input from keyboard and mouse. Soon to include controller.
|
* Handles input from keyboard and mouse. Soon to include controller.
|
||||||
|
@ -13,19 +13,12 @@
|
||||||
//#include <Xinput.h>
|
//#include <Xinput.h>
|
||||||
//#include "../../SHADE_Managed/src/SHpch.h"
|
//#include "../../SHADE_Managed/src/SHpch.h"
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
#include "ECS_Base/System/SHSystem.h"
|
|
||||||
#include "ECS_Base/System/SHFixedSystemRoutine.h"
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
class SH_API SHInputManagerSystem : public SHSystem
|
class SH_API SHInputManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class SH_API InputManagerRoutine : public SHFixedSystemRoutine
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void FixedExecute(double dt) noexcept override final;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
@ -276,23 +269,21 @@ namespace SHADE
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//Updates current state of the input, with dt to be fetched from FRC
|
||||||
|
//TODO should dt be fixed or variable?
|
||||||
|
static void UpdateInput(double dt) noexcept;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Constructors & Destructor */
|
/* Constructors & Destructor */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
SHInputManagerSystem() noexcept = default;
|
SHInputManager() noexcept = default;
|
||||||
~SHInputManagerSystem() noexcept = default;
|
~SHInputManager() noexcept = default;
|
||||||
|
|
||||||
SHInputManagerSystem(const SHInputManagerSystem&) = delete;
|
SHInputManager(const SHInputManager&) = delete;
|
||||||
SHInputManagerSystem(SHInputManagerSystem&&) = delete;
|
SHInputManager(SHInputManager&&) = delete;
|
||||||
|
|
||||||
SHInputManagerSystem& operator= (const SHInputManagerSystem&) = delete;
|
SHInputManager& operator= (const SHInputManager&) = delete;
|
||||||
SHInputManagerSystem& operator= (SHInputManagerSystem&&) = delete;
|
SHInputManager& operator= (SHInputManager&&) = delete;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* SHSystem Overrides */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
virtual void Init() override final;
|
|
||||||
virtual void Exit() override final;
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Member Functions */
|
/* Member Functions */
|
||||||
|
@ -417,8 +408,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
POINT p{ mouseScreenX, mouseScreenY };
|
POINT p{ mouseScreenX, mouseScreenY };
|
||||||
ScreenToClient(GetActiveWindow(), &p);
|
ScreenToClient(GetActiveWindow(), &p);
|
||||||
if (x) *x = mouseScreenX;
|
if (x) *x = p.x;
|
||||||
if (y) *y = mouseScreenY;
|
if (y) *y = p.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the mouse velocity
|
//Get the mouse velocity
|
|
@ -61,6 +61,12 @@ project "SHADE_Managed"
|
||||||
"MultiProcessorCompile"
|
"MultiProcessorCompile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disablewarnings
|
||||||
|
{
|
||||||
|
"4275"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
dependson
|
dependson
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
|
|
Loading…
Reference in New Issue