| 23 | } |
| 24 | |
| 25 | void OrbitCameraController::Update(Core::TimeStep dt) { |
| 26 | static Maths::Vector2 last_mouse_cursor_pos; |
| 27 | |
| 28 | if (IDevice::As<Inputs::Mouse>()->IsKeyPressed(ZENGINE_KEY_MOUSE_RIGHT, m_window.lock())) { |
| 29 | auto camera = reinterpret_cast<Rendering::Cameras::OrbitCamera*>(m_perspective_camera.get()); |
| 30 | float yaw_angle_degree = (m_mouse_cursor_pos.x - last_mouse_cursor_pos.x) * m_rotation_speed * dt; |
| 31 | float pitch_angle_degree = (m_mouse_cursor_pos.y - last_mouse_cursor_pos.y) * m_rotation_speed * dt; |
| 32 | camera->SetPosition(yaw_angle_degree, pitch_angle_degree); |
| 33 | } |
| 34 | last_mouse_cursor_pos = m_mouse_cursor_pos; |
| 35 | } |
| 36 | |
| 37 | bool OrbitCameraController::OnEvent(Event::CoreEvent& e) { |
| 38 | Event::EventDispatcher dispatcher(e); |
nothing calls this directly
no test coverage detected