Commit c288689c authored by JP Dinger's avatar JP Dinger
Browse files

Skins2: Move method bodies with inline tags to before where they're needed....

Skins2: Move method bodies with inline tags to before where they're needed. Drop const in favour of static on power() and instead of recursing(!) make it use powf().
parent 4e7c493e
......@@ -194,6 +194,23 @@ int Bezier::findNearestPoint( int x, int y ) const
}
inline float Bezier::power( float x, int n )
{
#if 0
return n <= 0 ? 1 : x * power( x, n - 1 );
#else
return powf( x, n );
#endif
}
inline float Bezier::computeCoeff( int i, int n, float t ) const
{
return (power( t, i ) * power( 1 - t, (n - i) ) *
(m_ft[n] / m_ft[i] / m_ft[n - i]));
}
void Bezier::computePoint( float t, int &x, int &y ) const
{
// See http://astronomy.swin.edu.au/~pbourke/curves/bezier/ for a simple
......@@ -212,18 +229,3 @@ void Bezier::computePoint( float t, int &x, int &y ) const
y = lrintf(yPos);
}
inline float Bezier::computeCoeff( int i, int n, float t ) const
{
return (power( t, i ) * power( 1 - t, (n - i) ) *
(m_ft[n] / m_ft[i] / m_ft[n - i]));
}
inline float Bezier::power( float x, int n ) const
{
if( n > 0 )
return x * power( x, n - 1);
else
return 1;
}
......@@ -98,7 +98,7 @@ private:
/// Helper function to compute a coefficient of the curve
inline float computeCoeff( int i, int n, float t ) const;
/// x^n
inline float power( float x, int n ) const;
static inline float power( float x, int n );
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment