Fixed pitch and roll for bubble gums ... again :)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5212 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-04-19 13:12:03 +00:00
parent 468507af8b
commit c38da65c16
2 changed files with 7 additions and 7 deletions

View File

@ -53,18 +53,18 @@ void Vec3::degreeToRad()
*/
void Vec3::setPitchRoll(const Vec3 &normal)
{
const float X = sin(m_x);
const float Z = cos(m_x);
const float X = sin(getHeading());
const float Z = cos(getHeading());
// Compute the angle between the normal of the plane and the line to
// (x,y,0). (x,y,0) is normalised, so are the coordinates of the plane,
// simplifying the computation of the scalar product.
// (x,0,z). (x,0,z) is normalised, so are the coordinates of the plane,
// which simplifies the computation of the scalar product.
float pitch = ( normal.getX()*X + normal.getZ()*Z ); // use ( x,0,z)
float roll = (-normal.getX()*Z + normal.getZ()*X ); // use (-z,0,x)
// The actual angle computed above is between the normal and the (x,y,0)
// line, so to compute the actual angles 90 degrees must be subtracted.
m_y = acosf(pitch) - NINETY_DEGREE_RAD;
m_z =-acosf(roll) + NINETY_DEGREE_RAD;
setPitch(-acosf(pitch) + NINETY_DEGREE_RAD);
setRoll (-acosf(roll) + NINETY_DEGREE_RAD);
} // setPitchRoll
// ----------------------------------------------------------------------------

View File

@ -50,7 +50,7 @@ public:
* \param heading The heading to set.
* \param normal The normal from which pitch and roll should be computed. */
inline Vec3(float heading, const Vec3& normal)
{m_x=heading;
{setHeading(heading);
setPitchRoll(normal);}
void setHPR(const btQuaternion& q);