Enabled inlining of some Vec3 functions (this was originally

avoided to decrease recompile time).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7719 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2011-02-16 22:30:25 +00:00
parent 904d058084
commit 85d125fda7
2 changed files with 38 additions and 44 deletions

View File

@@ -19,9 +19,6 @@
#include "utils/vec3.hpp"
#include "utils/constants.hpp"
void Vec3::setHPR(const btQuaternion& q)
{
float W = q.getW();
@@ -38,14 +35,6 @@ void Vec3::setHPR(const btQuaternion& q)
setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
} // setHPR(btQuaternion)
// ----------------------------------------------------------------------------
void Vec3::degreeToRad()
{
m_floats[0]=DEGREE_TO_RAD*m_floats[0];
m_floats[1]=DEGREE_TO_RAD*m_floats[1];
m_floats[2]=DEGREE_TO_RAD*m_floats[2];
} // degreeToRad
// ----------------------------------------------------------------------------
/** Sets the pitch and the roll of this vector to follow the normal given. The
* heading is taken from this vector.
@@ -67,31 +56,3 @@ void Vec3::setPitchRoll(const Vec3 &normal)
setRoll (-acosf(roll) + NINETY_DEGREE_RAD);
} // setPitchRoll
// ----------------------------------------------------------------------------
/** Converts a bullet HPR value into an irrlicht HPR value.
* FIXME: this function should be inlined, but while debugging it's
* easier (compile-time wise) to modify it here :)
*/
const core::vector3df Vec3::toIrrHPR() const
{
core::vector3df r(RAD_TO_DEGREE*(getX()), // pitch
RAD_TO_DEGREE*(getY()), // heading
RAD_TO_DEGREE*(getZ()) ); // roll
return r;
} // toIrrHPR
// ----------------------------------------------------------------------------
/** Converts a vec3 into an irrlicht vector (which is a simple type cast).
*/
const core::vector3df& Vec3::toIrrVector() const
{
return (const core::vector3df&)*this;
} // toIrrVector
// ----------------------------------------------------------------------------
/** Returns the X and Y component as an irrlicht 2d vector. */
const core::vector2df Vec3::toIrrVector2d() const
{
core::vector2df v(m_floats[0], m_floats[2]);
return v;
} // toIrrVector2d

View File

@@ -27,6 +27,8 @@ using namespace irr;
#include "LinearMath/btVector3.h"
#include "LinearMath/btMatrix3x3.h"
#include "utils/constants.hpp"
/** A wrapper around bullets btVector3 to include conventient conversion
* functions (e.g. between btVector3 and the graphics specific 3d vector). */
class Vec3 : public btVector3
@@ -65,25 +67,56 @@ public:
inline const void setHeading(float f) { m_floats[1] = f; }
inline const void setPitch(float f) { m_floats[0] = f; }
inline const void setRoll(float f) { m_floats[2] = f; }
/** Converts a Vec3 to an irrlicht 3d floating point vector. */
const core::vector3df& toIrrVector() const;
const core::vector3df toIrrHPR() const;
const core::vector2df toIrrVector2d() const;
void degreeToRad();
// ------------------------------------------------------------------------
/** Converts a vec3 into an irrlicht vector (which is a simple type cast). */
const core::vector3df& toIrrVector() const
{
return (const core::vector3df&)*this;
} // toIrrVector
// ------------------------------------------------------------------------
/** Converts a bullet HPR value into an irrlicht HPR value. */
const core::vector3df toIrrHPR() const
{
return core::vector3df(RAD_TO_DEGREE*(getX()), // pitch
RAD_TO_DEGREE*(getY()), // heading
RAD_TO_DEGREE*(getZ()) ); // roll
} // toIrrHPR
// ------------------------------------------------------------------------
/** Returns the X and Z component as an irrlicht 2d vector. */
const core::vector2df toIrrVector2d() const
{
return core::vector2df(m_floats[0], m_floats[2]);
} // toIrrVector2d
// ------------------------------------------------------------------------
/** Converts degree values stored in this vec3 to radians. */
void degreeToRad()
{
m_floats[0]*=DEGREE_TO_RAD;
m_floats[1]*=DEGREE_TO_RAD;
m_floats[2]*=DEGREE_TO_RAD;
} // degreeToRad
// ------------------------------------------------------------------------
Vec3& operator=(const btVector3& a) {*(btVector3*)this=a; return *this;}
// ------------------------------------------------------------------------
Vec3& operator=(const btQuaternion& q){setHPR(q); return *this;}
// ------------------------------------------------------------------------
Vec3 operator-(const Vec3& v1) const {return (Vec3)(*(btVector3*)this-(btVector3)v1);}
// ------------------------------------------------------------------------
/** Helper functions to treat this vec3 as a 2d vector. This returns the
* square of the length of the first 2 dimensions. */
float length2_2d() const {return m_floats[0]*m_floats[0] + m_floats[2]*m_floats[2];}
// ------------------------------------------------------------------------
/** Returns the length of this vector in the plane, i.e. the vector is
* used as a 2d vector. */
// ------------------------------------------------------------------------
float length_2d() const {return sqrt(m_floats[0]*m_floats[0] + m_floats[2]*m_floats[2]);}
// ------------------------------------------------------------------------
/** Sets this = max(this, a) componentwise.
* \param Vector to compare with. */
void max(const Vec3& a) {if(a.getX()>m_floats[0]) m_floats[0]=a.getX();
if(a.getY()>m_floats[1]) m_floats[1]=a.getY();
if(a.getZ()>m_floats[2]) m_floats[2]=a.getZ();}
// ------------------------------------------------------------------------
/** Sets this = min(this, a) componentwise.
* \param a Vector to compare with. */
void min(const Vec3& a) {if(a.getX()<m_floats[0]) m_floats[0]=a.getX();