From: <axl...@us...> - 2009-05-31 22:46:43
|
Revision: 299 http://hgengine.svn.sourceforge.net/hgengine/?rev=299&view=rev Author: axlecrusher Date: 2009-05-31 22:46:35 +0000 (Sun, 31 May 2009) Log Message: ----------- just clamp values Modified Paths: -------------- Mercury2/src/Camera.cpp Mercury2/src/MercuryUtil.h Modified: Mercury2/src/Camera.cpp =================================================================== --- Mercury2/src/Camera.cpp 2009-05-31 22:29:07 UTC (rev 298) +++ Mercury2/src/Camera.cpp 2009-05-31 22:46:35 UTC (rev 299) @@ -46,17 +46,10 @@ { MouseInput* m = (MouseInput*)data; - //keep m_y within [-PI -> PI] - if( m_y < -Q_PI ) m_y += Q_PI*2.; - if( m_y > Q_PI ) m_y -= Q_PI*2.; - //if m_y is < -PI/2 or m_y > PI/2 one must invert the axes - m_y += m->dy/1200.0f; + m_x += m->dx/1200.0f; - if (ABS(m_y) > Q_PI/2) - m_x -= m->dx/1200.0f; - else - m_x += m->dx/1200.0f; + m_y = Clamp(-Q_PI/2, Q_PI/2, m_y); MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x); MercuryVector LocalX = MercuryVector( 1, 0, 0 ); Modified: Mercury2/src/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-05-31 22:29:07 UTC (rev 298) +++ Mercury2/src/MercuryUtil.h 2009-05-31 22:46:35 UTC (rev 299) @@ -45,6 +45,14 @@ return t1<t2?t1:t2; } +template<typename T> +const T& Clamp(const T& min, const T& max, const T& value) +{ + if (value > max) return max; + if (value < min) return min; + return value; +} + //This counter is used with singletons to //ensure proper destruction order of the //singleton This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |