|
From: <axl...@us...> - 2009-06-04 02:14:34
|
Revision: 307
http://hgengine.svn.sourceforge.net/hgengine/?rev=307&view=rev
Author: axlecrusher
Date: 2009-06-04 01:43:22 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
fix camera doing funky things at exactly PI/2
it would flip a translation axis and possibly disappear into a void
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-06-04 01:02:38 UTC (rev 306)
+++ Mercury2/src/Camera.cpp 2009-06-04 01:43:22 UTC (rev 307)
@@ -18,7 +18,7 @@
MercuryMatrix local, parent(GetParentMatrix());
- MQuaternion r( GetRotation().normalize() );
+ MQuaternion r( GetRotation() );
//compute the world space look vector (broken if camera is in transform node)
m_lookAt = MercuryVector(0,0,-1); //by default camera looks down world Z
@@ -50,14 +50,18 @@
m_y += m->dy/1200.0f;
m_x += m->dx/1200.0f;
- m_y = Clamp(-Q_PI/2, Q_PI/2, m_y);
+ m_y = Clamp((-Q_PI/2.0f)+0.00001f, (Q_PI/2.0f)-0.00001f, m_y);
MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
MercuryVector LocalX = MercuryVector( 1, 0, 0 );
LocalX = LocalX.Rotate( qLeftRight );
MQuaternion qUpDown = MQuaternion::CreateFromAxisAngle(LocalX, m_y);
+
+// qLeftRight.Print();
+
SetRotation(qUpDown*qLeftRight);
+// GetRotation().Print();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|