diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index dd3cfe80..6645aa1b 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -798,17 +798,45 @@ namespace SHADE //Get cursor position, even when it is outside window POINT p; - GetCursorPos(&p); + GetCursorPos(&p); //This point is WRT the screen, not the window + //ScreenToClient(GetActiveWindow(), &p); mouseScreenX = p.x; mouseScreenY = p.y; + //SHLOGV_INFO("MouseScreenY = {}", mouseScreenY); - //Velocity - mouseVelocityX = static_cast(mouseScreenX - mouseScreenXLast) / dt; - mouseVelocityY = static_cast(mouseScreenY - mouseScreenYLast) / dt; + if (!mouseCentering) + { + //Velocity + mouseVelocityX = static_cast(mouseScreenX - mouseScreenXLast) / dt; + mouseVelocityY = static_cast(mouseScreenY - mouseScreenYLast) / dt; + } + else + { + //Mouse centering + //uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth(); + //uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight(); + int mouseCenterX = 0; + int mouseCenterY = 0; + RECT wndRect = { NULL }; //4th quadrant + if (GetWindowRect(GetActiveWindow(), &wndRect)) + { + mouseCenterX = wndRect.left + (wndRect.right - wndRect.left) / 2; + mouseCenterY = wndRect.top + (wndRect.bottom - wndRect.top) / 2; + //SHLOGV_INFO("W: {0}, H: {1}", (wndRect.right - wndRect.left), (wndRect.bottom - wndRect.top)); + } + //Velocity + mouseVelocityX = static_cast(mouseScreenX - mouseCenterX) / dt; + mouseVelocityY = static_cast(mouseScreenY - mouseCenterY) / dt; + //SHLOGV_INFO("mouseScreenY = {0:0}, mouseCenterY = {1:0}", mouseScreenY, mouseCenterY); + //SHLOGV_INFO("{0.0}", mouseVelocityY); + + SetMouseScreenPosition(mouseCenterX, mouseCenterY); + } + //Mouse Centering - if (mouseCentering) + /*if (mouseCentering) { uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth(); uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight(); @@ -819,7 +847,7 @@ namespace SHADE GetCursorPos(&p); mouseVelocityX -= static_cast(p.x - mouseScreenX) / dt; mouseVelocityY -= static_cast(p.y - mouseScreenY) / dt; - } + }*/ if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0) controllerInUse = false; diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index 5d3a3bac..9ef447bf 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -882,6 +882,11 @@ namespace SHADE System::Collections::Generic::IEnumerable^ selectorFunc(System::Reflection::Assembly^ assembly) { + if (assembly == nullptr) + { + Debug::LogError("[ScriptStore] Received null assembly while collecting Script types. This should not happen!"); + return nullptr; + } return assembly->GetExportedTypes(); } Pair^ resultSelectorFunc(System::Reflection::Assembly^ assembly, System::Type^ type)