| 39 | //------------------------------------------------------------------------------ |
| 40 | |
| 41 | void LuxCoreApp::GLFW_MousePositionCallBack(GLFWwindow *window, double x, double y) { |
| 42 | LuxCoreApp *app = (LuxCoreApp *)glfwGetWindowUserPointer(window); |
| 43 | |
| 44 | if (!app->session || ImGui::GetIO().WantCaptureMouse) { |
| 45 | app->mouseButton0 = false; |
| 46 | app->mouseButton2 = false; |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | const double minInterval = 0.2; |
| 51 | |
| 52 | if (app->mouseButton0) { |
| 53 | // Check elapsed time since last update |
| 54 | if (app->optRealTimeMode || (WallClockTime() - app->lastMouseUpdate > minInterval)) { |
| 55 | const int distX = x - app->mouseGrabLastX; |
| 56 | const int distY = y - app->mouseGrabLastY; |
| 57 | |
| 58 | switch(app->currentTool) { |
| 59 | case TOOL_CAMERA_EDIT: { |
| 60 | app->session->BeginSceneEdit(); |
| 61 | |
| 62 | if (app->optMouseGrabMode) { |
| 63 | app->config->GetScene().GetCamera().RotateUp(.04f * distY * app->optRotateStep); |
| 64 | app->config->GetScene().GetCamera().RotateLeft(.04f * distX * app->optRotateStep); |
| 65 | } |
| 66 | else { |
| 67 | app->config->GetScene().GetCamera().RotateDown(.04f * distY * app->optRotateStep); |
| 68 | app->config->GetScene().GetCamera().RotateRight(.04f * distX * app->optRotateStep); |
| 69 | }; |
| 70 | |
| 71 | app->session->EndSceneEdit(); |
| 72 | break; |
| 73 | } |
| 74 | default: |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | app->mouseGrabLastX = x; |
| 79 | app->mouseGrabLastY = y; |
| 80 | |
| 81 | app->lastMouseUpdate = WallClockTime(); |
| 82 | } |
| 83 | } else if (app->mouseButton2) { |
| 84 | // Check elapsed time since last update |
| 85 | if (app->optRealTimeMode || (WallClockTime() - app->lastMouseUpdate > minInterval)) { |
| 86 | const int distX = x - app->mouseGrabLastX; |
| 87 | const int distY = y - app->mouseGrabLastY; |
| 88 | |
| 89 | switch(app->currentTool) { |
| 90 | case TOOL_CAMERA_EDIT: { |
| 91 | app->session->BeginSceneEdit(); |
| 92 | |
| 93 | if (app->optMouseGrabMode) { |
| 94 | app->config->GetScene().GetCamera().TranslateLeft(.04f * distX * app->optMoveStep); |
| 95 | app->config->GetScene().GetCamera().TranslateForward(.04f * distY * app->optMoveStep); |
| 96 | } |
| 97 | else { |
| 98 | app->config->GetScene().GetCamera().TranslateRight(.04f * distX * app->optMoveStep); |
nothing calls this directly
no test coverage detected