From 72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 18:51:37 +0000 Subject: Added separate event handlers for mouse button clicks and mouse wheel movement. --- src/render/camera.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/render/camera.cc') diff --git a/src/render/camera.cc b/src/render/camera.cc index 881d9ae..d6cf562 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -328,12 +328,21 @@ void Camera::frame(float seconds) distance = math::max(FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + camera_zoom * core::localcontrol()->radius()) + 0.001f; } else if (mode() == Cockpit) { + + camera_scene_axis.assign(target_axis); + + direction_target = + 90 * target_direction; + pitch_target = + 90 * target_pitch; - // freelook target - target_axis.change_direction(90 * target_direction); - target_axis.change_pitch(90 * target_pitch); + // adjust direction + d = degrees180f(direction_current - direction_target); + direction_current = degrees360f(direction_current - d * seconds); + camera_scene_axis.change_direction(direction_current); - camera_scene_axis.assign(target_axis); + // adjust pitch + d = degrees180f(pitch_current - pitch_target); + pitch_current = degrees360f(pitch_current - d * seconds); + camera_scene_axis.change_pitch(pitch_current); if (core::localcontrol()->model()) { const float modelscale = core::localcontrol()->radius() / core::localcontrol()->model()->radius(); -- cgit v1.2.3