From f766843b7ab9f01965a82239557359c6bedb719c Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Tue, 16 Apr 2013 18:27:19 -0700 Subject: [PATCH] adjusted the ordering of porcessed in camera update method --- interface/src/Camera.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index bafda75515..ef7943d8f3 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -9,8 +9,7 @@ #include "Camera.h" -Camera::Camera() -{ +Camera::Camera() { _mode = CAMERA_MODE_THIRD_PERSON; _tightness = DEFAULT_CAMERA_TIGHTNESS; _fieldOfView = 60.0; // default @@ -28,26 +27,40 @@ Camera::Camera() _orientation.setToIdentity(); } -void Camera::update( float deltaTime ) + + +void Camera::update( float deltaTime ) { + //---------------------------------------- + // derive t from tightness + //---------------------------------------- + float t = _tightness * deltaTime; + + if ( t > 1.0 ){ + t = 1.0; + } + + //---------------------------------------- + // update _yaw (before position!) + //---------------------------------------- + _yaw += ( _idealYaw - _yaw ) * t; float radian = ( _yaw / 180.0 ) * PIE; + //---------------------------------------- + // update _position + //---------------------------------------- //these need to be checked to make sure they correspond to the coordinate system. double x = _distance * -sin( radian ); double z = _distance * cos( radian ); double y = _up; _idealPosition = _targetPosition + glm::vec3( x, y, z ); - float t = _tightness * deltaTime; - - if ( t > 1.0 ){ - t = 1.0; - } _position += ( _idealPosition - _position ) * t; - _yaw += ( _idealYaw - _yaw ) * t; + //------------------------------------------------------------------------------ // generate the ortho-normals for the orientation based on the Euler angles + //------------------------------------------------------------------------------ _orientation.setToIdentity(); _orientation.yaw ( _yaw ); _orientation.pitch ( _pitch );