From dc8d58d95caf0c8fa3fca7e61f17e6618d04035b Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Sat, 1 Oct 2022 13:49:11 +0800 Subject: [PATCH 1/7] fix GetMouseWindowPosition() --- SHADE_Engine/src/Input/SHInputManagerSystem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/Input/SHInputManagerSystem.h b/SHADE_Engine/src/Input/SHInputManagerSystem.h index eb40b240..2a8fe052 100644 --- a/SHADE_Engine/src/Input/SHInputManagerSystem.h +++ b/SHADE_Engine/src/Input/SHInputManagerSystem.h @@ -417,8 +417,8 @@ namespace SHADE { POINT p{ mouseScreenX, mouseScreenY }; ScreenToClient(GetActiveWindow(), &p); - if (x) *x = mouseScreenX; - if (y) *y = mouseScreenY; + if (x) *x = p.x; + if (y) *y = p.y; } //Get the mouse velocity From 0360a8bfa145c4773755ff2ba3a4cc36d825d86b Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Sat, 1 Oct 2022 14:34:30 +0800 Subject: [PATCH 2/7] made the Input Manager NOT be a System anymore --- .../src/Application/SBApplication.cpp | 5 +- .../src/Graphics/Windowing/SHWindow.cpp | 7 +- ...utManagerSystem.cpp => SHInputManager.cpp} | 80 +++++++------------ ...HInputManagerSystem.h => SHInputManager.h} | 33 +++----- 4 files changed, 42 insertions(+), 83 deletions(-) rename SHADE_Engine/src/Input/{SHInputManagerSystem.cpp => SHInputManager.cpp} (60%) rename SHADE_Engine/src/Input/{SHInputManagerSystem.h => SHInputManager.h} (93%) diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 3e9b0dce..700b36e3 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -23,7 +23,7 @@ #include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Scene/SHSceneManager.h" #include "Math/Transform/SHTransformSystem.h" -#include "Input/SHInputManagerSystem.h" +#include "Input/SHInputManager.h" #include "FRC/SHFramerateController.h" //#include "AudioSystem/SHAudioSystem.h" @@ -58,7 +58,6 @@ namespace Sandbox // TODO(Diren): Create Physics System here SHADE::SHSystemManager::CreateSystem(); SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem()); - SHADE::SHSystemManager::CreateSystem(); //SHADE::SHSystemManager::CreateSystem(); // Create Routines @@ -80,8 +79,6 @@ namespace Sandbox SHADE::SHComponentManager::CreateComponentSparseSet(); SHADE::SHComponentManager::CreateComponentSparseSet(); - SHADE::SHSystemManager::RegisterRoutine(); - //TODO: REMOVE AFTER PRESENTATION SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds"); diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp index 4d8dae72..3a1deb00 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp @@ -2,7 +2,7 @@ #include "SHWindowMap.h" #include "SHWindow.h" #include "ECS_Base/Managers/SHSystemManager.h" -#include "Input/SHInputManagerSystem.h" +#include "Input/SHInputManager.h" namespace SHADE @@ -343,10 +343,7 @@ namespace SHADE } case WM_MOUSEWHEEL: { - if (auto im = SHSystemManager::GetSystem()) - { - im->PollWheelVerticalDelta(wparam); - } + SHInputManager::PollWheelVerticalDelta(wparam); break; } default: diff --git a/SHADE_Engine/src/Input/SHInputManagerSystem.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp similarity index 60% rename from SHADE_Engine/src/Input/SHInputManagerSystem.cpp rename to SHADE_Engine/src/Input/SHInputManager.cpp index 1beabe3f..619afec0 100644 --- a/SHADE_Engine/src/Input/SHInputManagerSystem.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -1,5 +1,5 @@ /********************************************************************* - * \file SHInputManagerSystem.cpp + * \file SHInputManager.cpp * \author Ryan Wang Nian Jing * \brief Definition of input manager. * Handles input from keyboard and mouse. Soon to include controller. @@ -11,7 +11,8 @@ #pragma once #include -#include "SHInputManagerSystem.h" +#include "SHInputManager.h" +#include "../Tools/SHException.h" namespace SHADE { @@ -19,61 +20,34 @@ namespace SHADE /* Static defines */ /*------------------------------------------------------------------------*/ - unsigned SHInputManagerSystem::keyCount = 0; - bool SHInputManagerSystem::keys[MAX_KEYS]; - bool SHInputManagerSystem::keysLast[MAX_KEYS]; - double SHInputManagerSystem::keysHeldTime[MAX_KEYS]; - double SHInputManagerSystem::keysReleasedTime[MAX_KEYS]; + unsigned SHInputManager::keyCount = 0; + bool SHInputManager::keys[MAX_KEYS]; + bool SHInputManager::keysLast[MAX_KEYS]; + double SHInputManager::keysHeldTime[MAX_KEYS]; + double SHInputManager::keysReleasedTime[MAX_KEYS]; - unsigned SHInputManagerSystem::keyToggleCount = 0; - bool SHInputManagerSystem::keysToggle[MAX_KEYS]; - bool SHInputManagerSystem::keysToggleLast[MAX_KEYS]; - double SHInputManagerSystem::keysToggleOnTime[MAX_KEYS]; - double SHInputManagerSystem::keysToggleOffTime[MAX_KEYS]; + unsigned SHInputManager::keyToggleCount = 0; + bool SHInputManager::keysToggle[MAX_KEYS]; + bool SHInputManager::keysToggleLast[MAX_KEYS]; + double SHInputManager::keysToggleOnTime[MAX_KEYS]; + double SHInputManager::keysToggleOffTime[MAX_KEYS]; - int SHInputManagerSystem::mouseScreenX = 0; - int SHInputManagerSystem::mouseScreenY = 0; - int SHInputManagerSystem::mouseScreenXLast = 0; - int SHInputManagerSystem::mouseScreenYLast = 0; - double SHInputManagerSystem::mouseVelocityX = 0; - double SHInputManagerSystem::mouseVelocityY = 0; - int SHInputManagerSystem::mouseWheelVerticalDelta = 0; - int SHInputManagerSystem::mouseWheelVerticalDeltaPoll = 0; + int SHInputManager::mouseScreenX = 0; + int SHInputManager::mouseScreenY = 0; + int SHInputManager::mouseScreenXLast = 0; + int SHInputManager::mouseScreenYLast = 0; + double SHInputManager::mouseVelocityX = 0; + double SHInputManager::mouseVelocityY = 0; + int SHInputManager::mouseWheelVerticalDelta = 0; + int SHInputManager::mouseWheelVerticalDeltaPoll = 0; - void SHInputManagerSystem::Init() - { - 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 + void SHInputManager::UpdateInput(double dt) noexcept { //Keyboard and Mouse Buttons//////////////////////////////////////////////// //Poll unsigned char keyboardState[MAX_KEYS]; - GetKeyboardState(keyboardState); + //if (GetKeyboardState(keyboardState) == false) return; + SHASSERT(GetKeyboardState(keyboardState), "SHInputManager:GetKeyboardState() failed ({})", GetLastError()); keyCount = 0; keyToggleCount = 0; for (size_t i = 0; i < MAX_KEYS; ++i) @@ -144,7 +118,7 @@ namespace SHADE 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) { @@ -157,7 +131,7 @@ namespace SHADE 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) { @@ -170,7 +144,7 @@ namespace SHADE 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) { diff --git a/SHADE_Engine/src/Input/SHInputManagerSystem.h b/SHADE_Engine/src/Input/SHInputManager.h similarity index 93% rename from SHADE_Engine/src/Input/SHInputManagerSystem.h rename to SHADE_Engine/src/Input/SHInputManager.h index 2a8fe052..d3e31004 100644 --- a/SHADE_Engine/src/Input/SHInputManagerSystem.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -1,5 +1,5 @@ /********************************************************************* - * \file SHInputManagerSystem.h + * \file SHInputManager.h * \author Ryan Wang Nian Jing * \brief Declaration of input manager. * Handles input from keyboard and mouse. Soon to include controller. @@ -13,19 +13,12 @@ //#include //#include "../../SHADE_Managed/src/SHpch.h" #include "SH_API.h" -#include "ECS_Base/System/SHSystem.h" -#include "ECS_Base/System/SHFixedSystemRoutine.h" namespace SHADE { - class SH_API SHInputManagerSystem : public SHSystem + class SH_API SHInputManager { public: - class SH_API InputManagerRoutine : public SHFixedSystemRoutine - { - public: - virtual void FixedExecute(double dt) noexcept override final; - }; public: /*------------------------------------------------------------------------*/ @@ -276,23 +269,21 @@ namespace SHADE }; 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 */ /*------------------------------------------------------------------------*/ - SHInputManagerSystem() noexcept = default; - ~SHInputManagerSystem() noexcept = default; + SHInputManager() noexcept = default; + ~SHInputManager() noexcept = default; - SHInputManagerSystem(const SHInputManagerSystem&) = delete; - SHInputManagerSystem(SHInputManagerSystem&&) = delete; + SHInputManager(const SHInputManager&) = delete; + SHInputManager(SHInputManager&&) = delete; - SHInputManagerSystem& operator= (const SHInputManagerSystem&) = delete; - SHInputManagerSystem& operator= (SHInputManagerSystem&&) = delete; - - /*------------------------------------------------------------------------*/ - /* SHSystem Overrides */ - /*------------------------------------------------------------------------*/ - virtual void Init() override final; - virtual void Exit() override final; + SHInputManager& operator= (const SHInputManager&) = delete; + SHInputManager& operator= (SHInputManager&&) = delete; /*------------------------------------------------------------------------*/ /* Member Functions */ From aef3e4ef1affbcf63f365d426f17bfcfc185850b Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Sat, 1 Oct 2022 17:04:07 +0800 Subject: [PATCH 3/7] Update SBApplication.cpp --- SHADE_Application/src/Application/SBApplication.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 8fbf1858..606ab4e2 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -58,7 +58,6 @@ namespace Sandbox // TODO(Diren): Create Physics System here SHADE::SHSystemManager::CreateSystem(); SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem()); - SHADE::SHSystemManager::CreateSystem(); SHADE::SHSystemManager::CreateSystem(); // Create Routines From 3c58a538ae12afef869eb4129513f56a486db580 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Sat, 1 Oct 2022 18:02:27 +0800 Subject: [PATCH 4/7] Mouse Vel & UpdateInput called from SBApplication --- SHADE_Application/src/Application/SBApplication.cpp | 1 + SHADE_Engine/src/Input/SHInputManager.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 606ab4e2..fc3e02ad 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -118,6 +118,7 @@ namespace Sandbox while (!window.WindowShouldClose()) { SHFrameRateController::UpdateFRC(); + SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime()); SHSceneManager::UpdateSceneManager(); SHSceneManager::SceneUpdate(1/60.0f); //#ifdef SHEDITOR diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index 619afec0..04f2b02e 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -112,6 +112,10 @@ namespace SHADE mouseScreenX = p.x; mouseScreenY = p.y; + //Velocity + mouseVelocityX = static_cast(mouseScreenX - mouseScreenXLast) / dt; + mouseVelocityY = static_cast(mouseScreenY - mouseScreenYLast) / dt; + //Mouse wheel vertical delta updating mouseWheelVerticalDelta = 0; mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll; From a6e17847bf54968818084a5e935b1d01008890cf Mon Sep 17 00:00:00 2001 From: Sri Sham Haran Date: Sat, 1 Oct 2022 18:58:13 +0800 Subject: [PATCH 5/7] Warning disables Remove SDL hint that gave warning (it was unnecessary anyway) --- SHADE_Application/premake5.lua | 9 ++++++++- SHADE_Application/src/Application/SBApplication.cpp | 1 - SHADE_Engine/premake5.lua | 9 ++++++++- SHADE_Managed/premake5.lua | 6 ++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/SHADE_Application/premake5.lua b/SHADE_Application/premake5.lua index 2119808d..a02b7f2a 100644 --- a/SHADE_Application/premake5.lua +++ b/SHADE_Application/premake5.lua @@ -67,9 +67,16 @@ project "SHADE_Application" disablewarnings { - "4251" + "4251", + "26812", + "26439", + "26451", + "26437", + "4275" } + linkoptions { "-IGNORE:4006" } + warnings 'Extra' filter "configurations:Debug" diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index b982557c..5e57e6a5 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -14,7 +14,6 @@ #include #include #include -#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN 1 #include #include "Scripting/SHScriptEngine.h" diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua index f11ccf79..5481fa7d 100644 --- a/SHADE_Engine/premake5.lua +++ b/SHADE_Engine/premake5.lua @@ -76,8 +76,15 @@ project "SHADE_Engine" disablewarnings { - "4251" + "4251", + "26812", + "26439", + "26451", + "26437", + "4275" } + + linkoptions { "-IGNORE:4006" } defines { diff --git a/SHADE_Managed/premake5.lua b/SHADE_Managed/premake5.lua index a7b20144..9724c296 100644 --- a/SHADE_Managed/premake5.lua +++ b/SHADE_Managed/premake5.lua @@ -61,6 +61,12 @@ project "SHADE_Managed" "MultiProcessorCompile" } + disablewarnings + { + "4275" + } + + dependson { "yaml-cpp", From c5efefcf4f3f4140f4226eebbdd01f6b9f830c7e Mon Sep 17 00:00:00 2001 From: Sri Sham Haran Date: Sat, 1 Oct 2022 21:18:54 +0800 Subject: [PATCH 6/7] Editor warning fixes --- .../src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp | 2 +- SHADE_Engine/src/Editor/IconsMaterialDesign.h | 2 +- SHADE_Engine/src/Editor/SHEditorWidgets.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index f787d4db..25cd5a6a 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -114,7 +114,7 @@ namespace SHADE auto* entity = SHEntityManager::GetEntityByID(currentNode->GetEntityID()); //Draw Node - bool isNodeOpen = ImGui::TreeNodeEx((void*)eid, nodeFlags, "%u: %s", EntityHandleGenerator::GetIndex(eid), entity->name.c_str()); + bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast(entity), nodeFlags, "%u: %s", EntityHandleGenerator::GetIndex(eid), entity->name.c_str()); const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); //Check For Begin Drag diff --git a/SHADE_Engine/src/Editor/IconsMaterialDesign.h b/SHADE_Engine/src/Editor/IconsMaterialDesign.h index 68373237..3f15892b 100644 --- a/SHADE_Engine/src/Editor/IconsMaterialDesign.h +++ b/SHADE_Engine/src/Editor/IconsMaterialDesign.h @@ -843,7 +843,7 @@ #define ICON_MD_FLIP_TO_FRONT "\xee\xa2\x83" // U+e883 #define ICON_MD_FLOOD "\xee\xaf\xa6" // U+ebe6 #define ICON_MD_FLOURESCENT "\xee\xb0\xb1" // U+ec31 -#define ICON_MD_FLOURESCENT "\xef\x80\x8d" // U+f00d +#define ICON_MD_FLOURESCENT2 "\xef\x80\x8d" // U+f00d #define ICON_MD_FLUORESCENT "\xee\xb0\xb1" // U+ec31 #define ICON_MD_FLUTTER_DASH "\xee\x80\x8b" // U+e00b #define ICON_MD_FMD_BAD "\xef\x80\x8e" // U+f00e diff --git a/SHADE_Engine/src/Editor/SHEditorWidgets.hpp b/SHADE_Engine/src/Editor/SHEditorWidgets.hpp index 88cea814..8d2adcc6 100644 --- a/SHADE_Engine/src/Editor/SHEditorWidgets.hpp +++ b/SHADE_Engine/src/Editor/SHEditorWidgets.hpp @@ -327,7 +327,7 @@ namespace SHADE ImGui::PushID(fieldLabel.c_str()); ImGui::Text(fieldLabel.c_str()); ImGui::SameLine(); - if (edited = ImGui::Combo("##Combo", &selected, list.data(), list.size())) + if (edited = ImGui::Combo("##Combo", &selected, list.data(), static_cast(list.size()))) { SHCommandManager::PerformCommand(std::reinterpret_pointer_cast(std::make_shared>(get(), selected, set)), false); } From 8a3a08986bd0faa54c01431850c9d5e2404b1eb3 Mon Sep 17 00:00:00 2001 From: Glence Date: Sat, 1 Oct 2022 21:29:40 +0800 Subject: [PATCH 7/7] fix audiosystem warnings --- SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp | 4 ++-- SHADE_Engine/src/AudioSystem/SHAudioSystem.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp index 2482fe8e..c3c7ef03 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp @@ -90,7 +90,7 @@ namespace SHADE //PlayEventOnce("event:/SFX/Dawn/Dawn_Attack"); } - void SHADE::SHAudioSystem::Run(float dt) + void SHADE::SHAudioSystem::Run(double dt) { static_cast(dt); //if (GetKeyState(VK_SPACE) & 0x8000) @@ -417,7 +417,7 @@ namespace SHADE int instanceCount = 0; event.second->getInstanceCount(&instanceCount); std::vector instances(instanceCount); - event.second->getInstanceList(instances.data(), instances.size(), &instanceCount); + event.second->getInstanceList(instances.data(), static_cast(instances.size()), &instanceCount); for (auto const& instance : instances) { instance->setPaused(pause); diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h index 04fad1f0..f19fcc3b 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h @@ -50,7 +50,7 @@ namespace SHADE ~SHAudioSystem(); void Init(); - void Run(float dt); + void Run(double dt); class SH_API AudioRoutine final : public SHSystemRoutine { public: