| 340 | } |
| 341 | |
| 342 | void HPPApiVulkanSample::handle_mouse_move(int32_t x, int32_t y) |
| 343 | { |
| 344 | int32_t dx = static_cast<int32_t>(mouse_pos.x) - x; |
| 345 | int32_t dy = static_cast<int32_t>(mouse_pos.y) - y; |
| 346 | |
| 347 | bool handled = false; |
| 348 | |
| 349 | if (has_gui()) |
| 350 | { |
| 351 | ImGuiIO &io = ImGui::GetIO(); |
| 352 | handled = io.WantCaptureMouse; |
| 353 | } |
| 354 | mouse_moved(static_cast<float>(x), static_cast<float>(y), handled); |
| 355 | |
| 356 | if (handled) |
| 357 | { |
| 358 | mouse_pos = glm::vec2(static_cast<float>(x), static_cast<float>(y)); |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | if (mouse_buttons.left) |
| 363 | { |
| 364 | rotation.x += dy * 1.25f * rotation_speed; |
| 365 | rotation.y -= dx * 1.25f * rotation_speed; |
| 366 | camera.rotate(glm::vec3(dy * camera.rotation_speed, -dx * camera.rotation_speed, 0.0f)); |
| 367 | view_updated = true; |
| 368 | } |
| 369 | if (mouse_buttons.right) |
| 370 | { |
| 371 | zoom += dy * .005f * zoom_speed; |
| 372 | camera.translate(glm::vec3(-0.0f, 0.0f, dy * .005f * zoom_speed)); |
| 373 | view_updated = true; |
| 374 | } |
| 375 | if (mouse_buttons.middle) |
| 376 | { |
| 377 | camera_pos.x -= dx * 0.01f; |
| 378 | camera_pos.y -= dy * 0.01f; |
| 379 | camera.translate(glm::vec3(-dx * 0.01f, -dy * 0.01f, 0.0f)); |
| 380 | view_updated = true; |
| 381 | } |
| 382 | mouse_pos = glm::vec2(static_cast<float>(x), static_cast<float>(y)); |
| 383 | } |
| 384 | |
| 385 | void HPPApiVulkanSample::mouse_moved(double x, double y, bool &handled) |
| 386 | {} |