From 930db4020b9af2ccd999cb3a8c980cc9d527f8cf Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 10 May 2008 10:19:16 +0000 Subject: client-side axis interpolation --- src/client/camera.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/client') diff --git a/src/client/camera.cc b/src/client/camera.cc index 573194a..28f60c5 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -170,16 +170,16 @@ void draw(float seconds) set_mode(Track); if (core::localcontrol()->state()) { - // client prediction has not been run yet - target = core::localcontrol()->state()->previouslocation() - + (core::localcontrol()->location() - core::localcontrol()->state()->previouslocation()) * core::game()->timeoffset(); + target.assign(core::localcontrol()->state()->location()); + axis.assign(core::localcontrol()->state()->axis()); + } else { + target.assign(core::localcontrol()->location()); + axis.assign(core::localcontrol()->axis()); } - else - target = core::localcontrol()->location(); - + if (mode == Track) { - if (core::localcontrol()->model()) - target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->axis().forward(); + if (core::localcontrol()->state() && core::localcontrol()->model()) + target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); // make the camera swing while turning target_direction = core::localcontrol()->target_direction; @@ -194,21 +194,21 @@ void draw(float seconds) pitch_target = pitch_current - 90 * target_pitch; } else if (mode == Cockpit) { - if (core::localcontrol()->model()) - target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->axis().forward(); + if (core::localcontrol()->state() && core::localcontrol()->model()) + target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); } - axis.assign(core::localcontrol()->axis()); + if (mode != Cockpit) { // adjust direction d = degrees180f(yaw_current - yaw_target); - yaw_current = degrees360f( yaw_current - 2* d * seconds); + yaw_current = degrees360f( yaw_current - d * seconds); axis.change_direction(yaw_current); // adjust pitch target d = degrees180f(pitch_current - pitch_target); - pitch_current = degrees360f(pitch_current - 2* d *seconds); + pitch_current = degrees360f(pitch_current - d *seconds); axis.change_pitch(pitch_current); if (core::localcontrol()->model()) -- cgit v1.2.3