From 787511f8a6a82752e6f1fdef42b9b7e0adef2090 Mon Sep 17 00:00:00 2001 From: Pascal <engelerp@phys.ethz.ch> Date: Wed, 26 Jul 2023 13:55:46 +0200 Subject: [PATCH] Added zooming to mouse cursor (odd behaviour via remote desktop) --- gui/src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gui/src/main.cpp b/gui/src/main.cpp index 728c8ca..a0ae730 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -139,6 +139,13 @@ int main(int argc, char** argv) { #ifndef NDEBUG std::cout << "Zooming" << std::endl; #endif + //calculate position of mouse cursor in real world + glm::vec2 m_real_world = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y); + //move camera to position pointed to by cursor + camera.MoveTo(m_real_world); + //move mouse to screen center (doesn't visually work in remote desktop) + SDL_WarpMouseInWindow(infra.window(), WIDTH/2, HEIGHT/2); + //process zoom (keep only this for central zoom) camera.ProcessMouseZoom(InputState::mwheelmot_y); } SelectionManager::hoveredIndex = bottom_metal.selectObject(InputState::umpos_x, HEIGHT - InputState::umpos_y, projection, view, model); -- GitLab