mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Math module refactored.
--HG-- branch : dev
This commit is contained in:
@@ -19,7 +19,7 @@ extern EE_API easingCbFunc easingCb[];
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double LinearInterpolation( double t, double b, double c, double d ) {
|
||||
inline double linearInterpolation( double t, double b, double c, double d ) {
|
||||
return b + t * c / d;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ inline double LinearInterpolation( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double QuadraticIn( double t, double b, double c, double d ) {
|
||||
inline double quadraticIn( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return c * t * t + b;
|
||||
@@ -48,7 +48,7 @@ inline double QuadraticIn( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double QuadraticOut( double t, double b, double c, double d ) {
|
||||
inline double quadraticOut( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return -c * t * ( t - 2 ) + b;
|
||||
@@ -66,7 +66,7 @@ inline double QuadraticOut( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double QuadraticInOut( double t, double b, double c, double d ) {
|
||||
inline double quadraticInOut( double t, double b, double c, double d ) {
|
||||
t /= d / 2;
|
||||
|
||||
if ( t < 1 )
|
||||
@@ -87,7 +87,7 @@ inline double QuadraticInOut( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double SineIn( double t, double b, double c, double d ) {
|
||||
inline double sineIn( double t, double b, double c, double d ) {
|
||||
return -c * eecos( t / d * ( EE_PI / 2 ) ) + c + b;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ inline double SineIn( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double SineOut( double t, double b, double c, double d ) {
|
||||
inline double sineOut( double t, double b, double c, double d ) {
|
||||
return c * eesin( t / d * ( EE_PI / 2 ) ) + b;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ inline double SineOut( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double SineInOut( double t, double b, double c, double d ) {
|
||||
inline double sineInOut( double t, double b, double c, double d ) {
|
||||
return -c / 2 * ( eecos( EE_PI * t / d ) - 1 ) + b;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ inline double SineInOut( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the effect, in milliseconds.
|
||||
* @return Number corresponding to the position of the component.
|
||||
*/
|
||||
inline double ExponentialIn( double t, double b, double c, double d ) {
|
||||
inline double exponentialIn( double t, double b, double c, double d ) {
|
||||
return t == 0 ? b : c * eepow( 2, 10 * ( t / d - 1 ) ) + b;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ inline double ExponentialIn( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double ExponentialOut( double t, double b, double c, double d ) {
|
||||
inline double exponentialOut( double t, double b, double c, double d ) {
|
||||
return t == d ? b + c : c * ( -eepow( 2, -10 * t / d ) + 1 ) + b;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ inline double ExponentialOut( double t, double b, double c, double d ) {
|
||||
* @param d Specifies the duration of the motion.
|
||||
* @return The value of the interpolated property at the specified time.
|
||||
*/
|
||||
inline double ExponentialInOut( double t, double b, double c, double d ) {
|
||||
inline double exponentialInOut( double t, double b, double c, double d ) {
|
||||
if (t == 0)
|
||||
return b;
|
||||
|
||||
@@ -174,19 +174,19 @@ inline double ExponentialInOut( double t, double b, double c, double d ) {
|
||||
return c / 2 * ( -eepow( 2, -10 * --t ) + 2 ) + b;
|
||||
}
|
||||
|
||||
inline double QuarticIn( double t, double b, double c, double d ) {
|
||||
inline double quarticIn( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return c * t * t * t * t + b;
|
||||
}
|
||||
|
||||
inline double QuarticOut( double t, double b, double c, double d ) {
|
||||
inline double quarticOut( double t, double b, double c, double d ) {
|
||||
t = t / d - 1;
|
||||
|
||||
return -c * ( t * t * t * t - 1 ) + b;
|
||||
}
|
||||
|
||||
inline double QuarticInOut( double t, double b, double c, double d ) {
|
||||
inline double quarticInOut( double t, double b, double c, double d ) {
|
||||
t /= d / 2;
|
||||
|
||||
if ( t < 1)
|
||||
@@ -197,19 +197,19 @@ inline double QuarticInOut( double t, double b, double c, double d ) {
|
||||
return -c / 2 * ( t * t * t * t - 2 ) + b;
|
||||
}
|
||||
|
||||
inline double QuinticIn( double t, double b, double c, double d ) {
|
||||
inline double quinticIn( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return c * t * t * t * t * t + b;
|
||||
}
|
||||
|
||||
inline double QuinticOut( double t, double b, double c, double d ) {
|
||||
inline double quinticOut( double t, double b, double c, double d ) {
|
||||
t = t / d - 1;
|
||||
|
||||
return c * ( t * t * t * t * t + 1) + b;
|
||||
}
|
||||
|
||||
inline double QuinticInOut( double t, double b, double c, double d ) {
|
||||
inline double quinticInOut( double t, double b, double c, double d ) {
|
||||
t /= d / 2;
|
||||
|
||||
if ( t < 1 )
|
||||
@@ -220,19 +220,19 @@ inline double QuinticInOut( double t, double b, double c, double d ) {
|
||||
return c / 2 * ( t * t * t * t * t + 2) + b;
|
||||
}
|
||||
|
||||
inline double CircularIn( double t, double b, double c, double d ) {
|
||||
inline double circularIn( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return -c * ( eesqrt( 1 - t * t ) - 1) + b;
|
||||
}
|
||||
|
||||
inline double CircularOut( double t, double b, double c, double d ) {
|
||||
inline double circularOut( double t, double b, double c, double d ) {
|
||||
t = t / d - 1;
|
||||
|
||||
return c * eesqrt( 1 - t * t ) + b;
|
||||
}
|
||||
|
||||
inline double CircularInOut( double t, double b, double c, double d ) {
|
||||
inline double circularInOut( double t, double b, double c, double d ) {
|
||||
t /= d / 2;
|
||||
|
||||
if ( t < 1 )
|
||||
@@ -243,19 +243,19 @@ inline double CircularInOut( double t, double b, double c, double d ) {
|
||||
return c / 2 * ( eesqrt( 1 - t * t ) + 1) + b;
|
||||
}
|
||||
|
||||
inline double CubicIn( double t, double b, double c, double d ) {
|
||||
inline double cubicIn( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
return c * t * t * t + b;
|
||||
}
|
||||
|
||||
inline double CubicOut( double t, double b, double c, double d ) {
|
||||
inline double cubicOut( double t, double b, double c, double d ) {
|
||||
t = t / d - 1;
|
||||
|
||||
return c * ( t * t * t + 1) + b;
|
||||
}
|
||||
|
||||
inline double CubicInOut( double t, double b, double c, double d ) {
|
||||
inline double cubicInOut( double t, double b, double c, double d ) {
|
||||
t /= d / 2;
|
||||
|
||||
if ( t < 1 )
|
||||
@@ -266,7 +266,7 @@ inline double CubicInOut( double t, double b, double c, double d ) {
|
||||
return c / 2 * ( t * t * t + 2 ) + b;
|
||||
}
|
||||
|
||||
inline double BackIn( double t, double b, double c, double d ) {
|
||||
inline double backIn( double t, double b, double c, double d ) {
|
||||
double s = 1.70158f;
|
||||
|
||||
t /= d;
|
||||
@@ -274,7 +274,7 @@ inline double BackIn( double t, double b, double c, double d ) {
|
||||
return c * t * t * ( ( s + 1 ) * t - s) + b;
|
||||
}
|
||||
|
||||
inline double BackOut( double t, double b, double c, double d ) {
|
||||
inline double backOut( double t, double b, double c, double d ) {
|
||||
double s = 1.70158f;
|
||||
|
||||
t = t / d - 1;
|
||||
@@ -282,7 +282,7 @@ inline double BackOut( double t, double b, double c, double d ) {
|
||||
return c * ( t * t * ( ( s + 1 ) * t + s ) + 1 ) + b;
|
||||
}
|
||||
|
||||
inline double BackInOut( double t, double b, double c, double d ) {
|
||||
inline double backInOut( double t, double b, double c, double d ) {
|
||||
float s = 1.70158f;
|
||||
|
||||
t /= d / 2;
|
||||
@@ -296,7 +296,7 @@ inline double BackInOut( double t, double b, double c, double d ) {
|
||||
return c / 2 * ( t * t * ( ( s + 1 ) * t + s ) + 2) + b;
|
||||
}
|
||||
|
||||
inline double BounceOut( double t, double b, double c, double d ) {
|
||||
inline double bounceOut( double t, double b, double c, double d ) {
|
||||
t /= d;
|
||||
|
||||
if ( t < ( 1.f / 2.75f ) ) {
|
||||
@@ -316,18 +316,18 @@ inline double BounceOut( double t, double b, double c, double d ) {
|
||||
}
|
||||
}
|
||||
|
||||
inline double BounceIn( double t, double b, double c, double d ) {
|
||||
return c - BounceOut( d - t, 0, c, d ) + b;
|
||||
inline double bounceIn( double t, double b, double c, double d ) {
|
||||
return c - bounceOut( d - t, 0, c, d ) + b;
|
||||
}
|
||||
|
||||
inline double BounceInOut( double t, double b, double c, double d ) {
|
||||
inline double bounceInOut( double t, double b, double c, double d ) {
|
||||
if ( t < d * 0.5f )
|
||||
return BounceIn( t * 2.f, 0.f, c, d ) * 0.5f + b;
|
||||
return bounceIn( t * 2.f, 0.f, c, d ) * 0.5f + b;
|
||||
|
||||
return BounceOut( t * 2.f - d, 0.f, c, d ) * 0.5f + c * 0.5f + b;
|
||||
return bounceOut( t * 2.f - d, 0.f, c, d ) * 0.5f + c * 0.5f + b;
|
||||
}
|
||||
|
||||
inline double ElasticIn( double t, double b, double c, double d ) {
|
||||
inline double elasticIn( double t, double b, double c, double d ) {
|
||||
if ( t == 0.f )
|
||||
return b;
|
||||
|
||||
@@ -345,7 +345,7 @@ inline double ElasticIn( double t, double b, double c, double d ) {
|
||||
return -( a * eepow( 2.f , 10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) ) + b;
|
||||
}
|
||||
|
||||
inline double ElasticOut( double t, double b, double c, double d ) {
|
||||
inline double elasticOut( double t, double b, double c, double d ) {
|
||||
if ( t == 0.f )
|
||||
return b;
|
||||
|
||||
@@ -361,7 +361,7 @@ inline double ElasticOut( double t, double b, double c, double d ) {
|
||||
return ( a * eepow( 2.f, -10.f * t ) * eesin( ( t * d - s ) * ( 2.f * EE_PI ) / p ) + c + b );
|
||||
}
|
||||
|
||||
inline double ElasticInOut( double t, double b, double c, double d ) {
|
||||
inline double elasticInOut( double t, double b, double c, double d ) {
|
||||
if ( t == 0 )
|
||||
return b;
|
||||
|
||||
|
||||
@@ -32,84 +32,84 @@ class EE_API Interpolation {
|
||||
typedef cb::Callback0<void> OnStepCallback;
|
||||
|
||||
/** Add a new point */
|
||||
void AddWaypoint( const Float Pos, const Float Time = 0 );
|
||||
void addWaypoint( const Float Pos, const Float Time = 0 );
|
||||
|
||||
/** Edit a point */
|
||||
bool EditWaypoint( const unsigned int& PointNum, const Float& NewPos, const Float NewTime = 0 );
|
||||
bool editWaypoint( const unsigned int& PointNum, const Float& NewPos, const Float NewTime = 0 );
|
||||
|
||||
/** Erase a point */
|
||||
bool EraseWaypoint( const unsigned int& PointNum );
|
||||
bool eraseWaypoint( const unsigned int& PointNum );
|
||||
|
||||
/** Start the animation */
|
||||
void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() );
|
||||
void start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() );
|
||||
|
||||
/** Stop the animation */
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
/** Sets a path end callback */
|
||||
void SetPathEndCallback( OnPathEndCallback PathEndCallback );
|
||||
void setPathEndCallback( OnPathEndCallback PathEndCallback );
|
||||
|
||||
/** Sets a step callback */
|
||||
void SetStepCallback( OnStepCallback StepCallback );
|
||||
void setStepCallback( OnStepCallback StepCallback );
|
||||
|
||||
/** Update the movement interpolation */
|
||||
void Update( const Time& Elapsed );
|
||||
void update( const Time& Elapsed );
|
||||
|
||||
/** Reset the class */
|
||||
void Reset();
|
||||
void reset();
|
||||
|
||||
/** @return The Current Position */
|
||||
const Float& GetPos();
|
||||
const Float& getPos();
|
||||
|
||||
/** @return The Current Real Position */
|
||||
const Float& GetRealPos() const;
|
||||
const Float& getRealPos() const;
|
||||
|
||||
/** @return If movement interpolation is a loop */
|
||||
const bool& Loop() const;
|
||||
const bool& loop() const;
|
||||
|
||||
/** Set if loop the movement interpolation */
|
||||
void Loop( const bool& loop );
|
||||
void loop( const bool& loop );
|
||||
|
||||
/** Clear all the points */
|
||||
void ClearWaypoints();
|
||||
void clearWaypoints();
|
||||
|
||||
/** @return If the animation ended */
|
||||
const bool& Ended() const;
|
||||
const bool& ended() const;
|
||||
|
||||
/** Set the current interpolation speed */
|
||||
void Speed( const Float Speed );
|
||||
void speed( const Float speed );
|
||||
|
||||
/** Get the current interpolation speed */
|
||||
const Float& Speed() const;
|
||||
const Float& speed() const;
|
||||
|
||||
/** @return If enabled */
|
||||
const bool& Enabled() const;
|
||||
const bool& enabled() const;
|
||||
|
||||
void Enabled( const bool& Enabled );
|
||||
void enabled( const bool& enabled );
|
||||
|
||||
/** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */
|
||||
void SetTotalTime( const Time& TotTime );
|
||||
void setTotalTime( const Time& TotTime );
|
||||
|
||||
/** @return the vector of points */
|
||||
const std::vector<Point1d>& GetPoints() const;
|
||||
const std::vector<Point1d>& getPoints() const;
|
||||
|
||||
/** @return The Current Node */
|
||||
Point1d* GetCurrentActual() const;
|
||||
Point1d* getCurrentActual() const;
|
||||
|
||||
/** @return The Next Node */
|
||||
Point1d* GetCurrentNext() const;
|
||||
Point1d* getCurrentNext() const;
|
||||
|
||||
/** @return The Current Position in the vector */
|
||||
const unsigned int& GetCurrentPos() const;
|
||||
const unsigned int& getCurrentPos() const;
|
||||
|
||||
/** @return The path end position */
|
||||
const Float& GetEndPos();
|
||||
const Float& getEndPos();
|
||||
|
||||
/** Set the type of interpolation to be used */
|
||||
void Type( Ease::Interpolation InterpolationType );
|
||||
void type( Ease::Interpolation InterpolationType );
|
||||
|
||||
/** @return The type of the interpolation */
|
||||
const int& Type() const;
|
||||
const int& type() const;
|
||||
protected:
|
||||
int mType;
|
||||
bool mEnable;
|
||||
|
||||
@@ -18,12 +18,12 @@ class Line2 {
|
||||
|
||||
Vector2<T>& p2() { return V[1]; }
|
||||
|
||||
Vector2<T> GetNormal();
|
||||
Vector2<T> getNormal();
|
||||
|
||||
/** @return The angle of the line against the x axis-aligned line */
|
||||
T GetAngle();
|
||||
T getAngle();
|
||||
|
||||
bool Intersect( Line2<T>& line, T* X = NULL, T* Y = NULL );
|
||||
bool intersect( Line2<T>& line, T* X = NULL, T* Y = NULL );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -39,14 +39,14 @@ Line2<T>::Line2( const Vector2<T>& v1, const Vector2<T>& v2 ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Line2<T>::GetNormal() {
|
||||
Vector2<T> Line2<T>::getNormal() {
|
||||
Vector2<T> tV = Vector2<T>( -(V[1].y - V[0].y) , V[1].x - V[0].x );
|
||||
tV.Normalize();
|
||||
tV.normalize();
|
||||
return tV;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Line2<T>::GetAngle() {
|
||||
T Line2<T>::getAngle() {
|
||||
return eeatan2( (V[1].y - V[0].y), (V[1].x - V[0].x) ) * EE_180_PI;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ T Line2<T>::GetAngle() {
|
||||
* @return True if the lines are intersecting
|
||||
*/
|
||||
template <typename T>
|
||||
bool Line2<T>::Intersect( Line2<T>& line, T* X, T* Y ) {
|
||||
bool Line2<T>::intersect( Line2<T>& line, T* X, T* Y ) {
|
||||
T distAB, theCos, theSin, newX, ABpos;
|
||||
|
||||
if ( ( V[0].x==V[1].x && V[0].y==V[1].y ) || ( line.V[0].x==line.V[1].x && line.V[0].y==line.V[1].y ) ) return false;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace EE { namespace Math {
|
||||
|
||||
/** Set a Random Seed to the Randomizer */
|
||||
inline Uint32 SetRandomSeed( Uint32 seed ) {
|
||||
inline Uint32 setRandomSeed( Uint32 seed ) {
|
||||
srand(seed);
|
||||
return seed;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ inline Uint32 SetRandomSeed( Uint32 seed ) {
|
||||
* @param fMax the maximun value
|
||||
* @return The random number generated
|
||||
*/
|
||||
inline Float Randf( const Float& fMin = 0.0f, const Float& fMax = 1.0f ) {
|
||||
inline Float randf( const Float& fMin = 0.0f, const Float& fMax = 1.0f ) {
|
||||
return (fMin + (fMax - fMin) * ( rand() / ( (Float) RAND_MAX + 1) ) );
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ inline Float Randf( const Float& fMin = 0.0f, const Float& fMax = 1.0f ) {
|
||||
* @param fMax the maximun value
|
||||
* @return The random number generated
|
||||
*/
|
||||
inline int Randi( const int& fMin = 0, const int& fMax = 1 ) {
|
||||
inline int randi( const int& fMin = 0, const int& fMax = 1 ) {
|
||||
return (int)(fMin + (fMax - fMin + 1) * ( rand() / ( (Float) RAND_MAX + 1) ) );
|
||||
}
|
||||
|
||||
@@ -46,18 +46,18 @@ inline Float tanAng( const Float& Ang ) {
|
||||
}
|
||||
|
||||
/** Convert an Angle from Degrees to Radians */
|
||||
inline Float Radians( const Float& Ang ) {
|
||||
inline Float radians( const Float& Ang ) {
|
||||
return Ang * EE_PI_180;
|
||||
}
|
||||
|
||||
/** Convert an Angle from Math::Radians to Degrees */
|
||||
inline Float Degrees( const Float& Radians ) {
|
||||
inline Float degrees( const Float& Radians ) {
|
||||
return Radians * EE_180_PI;
|
||||
}
|
||||
|
||||
/** @return The next power of two of the given Size */
|
||||
template <typename T>
|
||||
T NextPowOfTwo( T Size ) {
|
||||
T nextPowOfTwo( T Size ) {
|
||||
T p = 1;
|
||||
|
||||
while ( p < Size )
|
||||
@@ -68,19 +68,19 @@ T NextPowOfTwo( T Size ) {
|
||||
|
||||
/** @return If the number given is power of two */
|
||||
template <typename T>
|
||||
T IsPow2( T v ) {
|
||||
T isPow2( T v ) {
|
||||
return ( ( v & ( v - 1 ) ) == 0 );
|
||||
}
|
||||
|
||||
/** Round the number */
|
||||
template <typename T>
|
||||
inline T Round( T r ) {
|
||||
inline T round( T r ) {
|
||||
return (r > 0.0f) ? floor(r + 0.5f) : ceil(r - 0.5f);
|
||||
}
|
||||
|
||||
/** Round the number always to the upper value */
|
||||
template <typename T >
|
||||
inline T RoundUp( T r ) {
|
||||
inline T roundUp( T r ) {
|
||||
return (r > 0.0f) ? ceil(r) : ceil(r - 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,48 +84,48 @@ class EE_API MTRand {
|
||||
MTRand& operator=( const MTRand& o );
|
||||
|
||||
/** @return integer in [0,2^32-1] */
|
||||
Uint32 Randi();
|
||||
Uint32 randi();
|
||||
|
||||
/** @return integer in [0,n] for n < 2^32 */
|
||||
Uint32 Randi( const Uint32 n );
|
||||
Uint32 randi( const Uint32 n );
|
||||
|
||||
/** @return real number in [0,1] */
|
||||
double Rand();
|
||||
double rand();
|
||||
|
||||
/** @return real number in [0,n] */
|
||||
double Rand( const double n );
|
||||
double rand( const double n );
|
||||
|
||||
/** Set a new seed */
|
||||
void Seed( const Uint32 oneSeed );
|
||||
void seed( const Uint32 oneSeed );
|
||||
|
||||
/** Set the default seed */
|
||||
void Seed();
|
||||
void seed();
|
||||
|
||||
/** @return float number in [0,1] */
|
||||
Float Randf();
|
||||
Float randf();
|
||||
|
||||
/** @return float number in [0,n] */
|
||||
Float Randf( const Float n );
|
||||
Float randf( const Float n );
|
||||
|
||||
/** @return int number in [Min,Max] */
|
||||
int RandRange( int Min, int Max );
|
||||
int randRange( int Min, int Max );
|
||||
|
||||
/** @return float number in [Min,Max] */
|
||||
Float RandRange( Float Min, Float Max );
|
||||
Float randRange( Float Min, Float Max );
|
||||
|
||||
/** Save the state to an allocated array */
|
||||
void Save( Uint32* saveArray ) const;
|
||||
void save( Uint32* saveArray ) const;
|
||||
|
||||
/** Load state from an array */
|
||||
void Load( Uint32 *const loadArray );
|
||||
void load( Uint32 *const loadArray );
|
||||
protected:
|
||||
Uint32 mState[N];
|
||||
Uint32 * mNext;
|
||||
int mLeft;
|
||||
|
||||
void Initialize( const Uint32 oneSeed );
|
||||
void initialize( const Uint32 oneSeed );
|
||||
|
||||
void Reload();
|
||||
void reload();
|
||||
|
||||
Uint32 hiBit( const Uint32 u ) const;
|
||||
|
||||
@@ -133,11 +133,11 @@ class EE_API MTRand {
|
||||
|
||||
Uint32 loBits( const Uint32 u ) const;
|
||||
|
||||
Uint32 MixBits( const Uint32 u, const Uint32 v ) const;
|
||||
Uint32 mixBits( const Uint32 u, const Uint32 v ) const;
|
||||
|
||||
Uint32 Magic( const Uint32 u ) const;
|
||||
Uint32 magic( const Uint32 u ) const;
|
||||
|
||||
Uint32 Twist( const Uint32 m, const Uint32 s0, const Uint32 s1 ) const;
|
||||
Uint32 twist( const Uint32 m, const Uint32 s0, const Uint32 s1 ) const;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -20,42 +20,42 @@ class EE_API PerlinNoise {
|
||||
~PerlinNoise();
|
||||
|
||||
/** Reset the initial values */
|
||||
void Init();
|
||||
void init();
|
||||
|
||||
/** @return The noise value for the 2D coordinates */
|
||||
Float PerlinNoise2D(Float x, Float y);
|
||||
Float perlinNoise2D(Float x, Float y);
|
||||
|
||||
void Octaves( const int& octaves ) { mOctaves = octaves; }
|
||||
void octaves( const int& octaves ) { mOctaves = octaves; }
|
||||
|
||||
void Persistence( const Float& pers) { mPersistence = pers; }
|
||||
void persistence( const Float& pers) { mPersistence = pers; }
|
||||
|
||||
void Frequency( const Float& freq ) { mFrequency = freq; }
|
||||
void frequency( const Float& freq ) { mFrequency = freq; }
|
||||
|
||||
void Amplitude( const Float& amp ) { mAmplitude = amp; }
|
||||
void amplitude( const Float& amp ) { mAmplitude = amp; }
|
||||
|
||||
void FrequencyOctaveDep( const bool& dep ) { mFreqOctaveDep = dep; }
|
||||
void frequencyOctaveDep( const bool& dep ) { mFreqOctaveDep = dep; }
|
||||
|
||||
void AmplitudeOctaveDep( const bool& dep ) { mAmpOctaveDep = dep; }
|
||||
void amplitudeOctaveDep( const bool& dep ) { mAmpOctaveDep = dep; }
|
||||
|
||||
int Octaves() const { return mOctaves; }
|
||||
int octaves() const { return mOctaves; }
|
||||
|
||||
Float Persistence() const { return mPersistence; }
|
||||
Float persistence() const { return mPersistence; }
|
||||
|
||||
Float Frequency() const { return mFrequency; }
|
||||
Float frequency() const { return mFrequency; }
|
||||
|
||||
Float Amplitude() const { return mAmplitude; }
|
||||
Float amplitude() const { return mAmplitude; }
|
||||
|
||||
bool FrequencyOctaveDep() const { return mFreqOctaveDep; }
|
||||
bool frequencyOctaveDep() const { return mFreqOctaveDep; }
|
||||
|
||||
bool AmplitudeOctaveDep() const { return mAmpOctaveDep; }
|
||||
bool amplitudeOctaveDep() const { return mAmpOctaveDep; }
|
||||
protected:
|
||||
Float Noise2D(Int32 x, Int32 y);
|
||||
Float noise2D(Int32 x, Int32 y);
|
||||
|
||||
Float SmoothedNoise2D(Float x, Float y);
|
||||
Float smoothedNoise2D(Float x, Float y);
|
||||
|
||||
Float Interpolate(Float a, Float b, Float x);
|
||||
Float interpolate(Float a, Float b, Float x);
|
||||
|
||||
Float InterpolatedNoise2D(Float x, Float y);
|
||||
Float interpolatedNoise2D(Float x, Float y);
|
||||
|
||||
Float mCurrSeed;
|
||||
Float mPersistence;
|
||||
|
||||
@@ -34,75 +34,75 @@ class Polygon2 {
|
||||
Polygon2( const std::vector< Vector2<T> >& theVecs );
|
||||
|
||||
/** Adds a new Vector2 to the polygon */
|
||||
Uint32 PushBack( const Vector2<T>& V );
|
||||
Uint32 pushBack( const Vector2<T>& V );
|
||||
|
||||
/** Removes the las Vector2 from the polygon */
|
||||
void PopBack();
|
||||
void popBack();
|
||||
|
||||
/** Clear the polygon vectors */
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
/** @return The polygon Vector2 from the position ( from 0 to polygon size -1 ) */
|
||||
const Vector2<T>& operator[] ( const Uint32& Pos ) const;
|
||||
|
||||
/** @return The polygon Vector2 from the position ( from 0 to polygon size -1 ) */
|
||||
Vector2<T>& GetAt( const Uint32& Pos )
|
||||
Vector2<T>& getAt( const Uint32& Pos )
|
||||
{
|
||||
return Vector[Pos];
|
||||
}
|
||||
|
||||
/** Change the polygon vector in the position specified
|
||||
** @return The Vector2 changed */
|
||||
Vector2<T>& SetAt( const Uint32& Pos, Vector2<T> newPos )
|
||||
Vector2<T>& setAt( const Uint32& Pos, Vector2<T> newPos )
|
||||
{
|
||||
Vector[Pos] = newPos;
|
||||
return Vector[Pos];
|
||||
}
|
||||
|
||||
/** @return The number of vectors of the polygon */
|
||||
std::size_t Size() const;
|
||||
std::size_t size() const;
|
||||
|
||||
/** @return The position of the polygon ( also known as the offset of the polygon ) */
|
||||
Vector2<T> Position() { return Vector2<T>(OffsetX, OffsetY); }
|
||||
Vector2<T> position() { return Vector2<T>(OffsetX, OffsetY); }
|
||||
|
||||
/** Move the polygon Vector2s, add to every point the distance specified */
|
||||
void Move( Vector2<T> dist );
|
||||
void move( Vector2<T> dist );
|
||||
|
||||
/** @return The X position of the polygon ( the X-axis Offset ) */
|
||||
T X() const { return OffsetX; }
|
||||
T x() const { return OffsetX; }
|
||||
|
||||
/** @return The Y position of the polygon ( the Y-axis Offset ) */
|
||||
T Y() const { return OffsetY; }
|
||||
T y() const { return OffsetY; }
|
||||
|
||||
/** @return The position of the polygon ( the offset )*/
|
||||
void Position( const Vector2<T>& V ) { OffsetX = V.x; OffsetY = V.y; }
|
||||
void position( const Vector2<T>& V ) { OffsetX = V.x; OffsetY = V.y; }
|
||||
|
||||
/** Set the new position of the x-axis ( the x-axis offset ) */
|
||||
T X( const T& x ) { OffsetX = x; }
|
||||
T x( const T& x ) { OffsetX = x; }
|
||||
|
||||
/** Set the new position of the y-axis ( the y-axis offset ) */
|
||||
T Y( const T& y ) { OffsetY = y; }
|
||||
T y( const T& y ) { OffsetY = y; }
|
||||
|
||||
/** @return True if the polygons intersect */
|
||||
bool Intersect( const Polygon2<T>& p1 );
|
||||
bool intersect( const Polygon2<T>& p1 );
|
||||
|
||||
/** Rotates the polygon from a rotation center */
|
||||
void Rotate( const T& Angle, const Vector2<T>& Center );
|
||||
void rotate( const T& angle, const Vector2<T>& center );
|
||||
|
||||
/** Scale the polygon from a center point */
|
||||
void Scale( const T& scale, const Vector2<T>& Center );
|
||||
void scale( const T& scale, const Vector2<T>& center );
|
||||
|
||||
/** Scale the polygon from a center point */
|
||||
void Scale( const Vector2<T>& scale, const Vector2<T>& Center );
|
||||
void scale( const Vector2<T>& scale, const Vector2<T>& center );
|
||||
|
||||
/** @return True if the point is inside the polygon */
|
||||
bool PointInside( const Vector2<T>& point );
|
||||
bool pointInside( const Vector2<T>& point );
|
||||
|
||||
/** @return The polygon axis-aligned bounding box */
|
||||
tRECT<T> ToAABB();
|
||||
tRECT<T> toAABB();
|
||||
|
||||
/** Creates a rounded rectangle polygon */
|
||||
static Polygon2<T> CreateRoundedRectangle( const T& x, const T& y, const T& width, const T& height, const unsigned int& Radius = 8 );
|
||||
static Polygon2<T> createRoundedRectangle( const T& x, const T& y, const T& width, const T& height, const unsigned int& Radius = 8 );
|
||||
|
||||
/** @brief Intersect to Quads
|
||||
** Convert the two quads in two polygons, and execute a polygon to polygon collition.
|
||||
@@ -110,12 +110,12 @@ class Polygon2 {
|
||||
** @param q1 Second quad
|
||||
** @param q0Pos The q0 quad polygon offset
|
||||
** @param q1Pos The q1 quad polygon offset */
|
||||
static bool IntersectQuad2( const Quad2<T>& q0, const Quad2<T>& q1, const Vector2<T>& q0Pos = Vector2<T>(0,0), const Vector2<T>& q1Pos = Vector2<T>(0,0) );
|
||||
static bool intersectQuad2( const Quad2<T>& q0, const Quad2<T>& q1, const Vector2<T>& q0Pos = Vector2<T>(0,0), const Vector2<T>& q1Pos = Vector2<T>(0,0) );
|
||||
|
||||
/** @return Th closest polygon point to the point (to).
|
||||
** @param to The point
|
||||
** @param distance A pointer that returns the distance between the point and the closest point to the point */
|
||||
Uint32 ClosestPoint( const Vector2<T> &to, T * distance = NULL );
|
||||
Uint32 closestPoint( const Vector2<T> &to, T * distance = NULL );
|
||||
private:
|
||||
std::vector< Vector2<T> > Vector;
|
||||
T OffsetX, OffsetY;
|
||||
@@ -126,7 +126,7 @@ Polygon2<T>::Polygon2() :
|
||||
OffsetX(0),
|
||||
OffsetY(0)
|
||||
{
|
||||
Clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -140,19 +140,19 @@ Polygon2<T>::Polygon2( const Polygon2<T>& fromPoly ) :
|
||||
template <typename T>
|
||||
Polygon2<T>::Polygon2( const std::vector< Vector2<T> >& theVecs ) : OffsetX(0), OffsetY(0) {
|
||||
for (Uint32 i = 0; i < theVecs.size(); i++)
|
||||
PushBack ( theVecs[i] );
|
||||
pushBack ( theVecs[i] );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Polygon2<T>::Polygon2( const Triangle2<T>& fromTrig ) : OffsetX(0), OffsetY(0) {
|
||||
for (Uint8 i = 0; i < 3; i++)
|
||||
PushBack ( fromTrig.V[i] );
|
||||
pushBack ( fromTrig.V[i] );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Polygon2<T>::Polygon2( const Quad2<T>& fromQuad ) : OffsetX(0), OffsetY(0) {
|
||||
for (Uint8 i = 0; i < 4; i++)
|
||||
PushBack ( fromQuad.V[i] );
|
||||
pushBack ( fromQuad.V[i] );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -165,22 +165,22 @@ Polygon2<T>::Polygon2( const tRECT<T>& fromRect ) : OffsetX(0), OffsetY(0) {
|
||||
|
||||
template <typename T>
|
||||
Polygon2<T>::~Polygon2() {
|
||||
Clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::Clear() {
|
||||
void Polygon2<T>::clear() {
|
||||
Vector.clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Uint32 Polygon2<T>::PushBack( const Vector2<T>& V ) {
|
||||
Uint32 Polygon2<T>::pushBack( const Vector2<T>& V ) {
|
||||
Vector.push_back( V );
|
||||
return (Uint32)Vector.size() - 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::PopBack() {
|
||||
void Polygon2<T>::popBack() {
|
||||
Vector.pop_back();
|
||||
}
|
||||
|
||||
@@ -192,44 +192,44 @@ const Vector2<T>& Polygon2<T>::operator[] ( const Uint32& Pos ) const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t Polygon2<T>::Size() const {
|
||||
std::size_t Polygon2<T>::size() const {
|
||||
return Vector.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::Rotate( const T& Angle, const Vector2<T>& Center ) {
|
||||
if ( Angle == 0.f )
|
||||
void Polygon2<T>::rotate(const T& angle, const Vector2<T>& center ) {
|
||||
if ( angle == 0.f )
|
||||
return;
|
||||
|
||||
for ( unsigned int i = 0; i < Vector.size(); i++ )
|
||||
Vector[ i ].Rotate( Angle, Center );
|
||||
Vector[ i ].rotate( angle, center );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::Scale( const Vector2<T>& scale, const Vector2<T>& Center ) {
|
||||
void Polygon2<T>::scale(const Vector2<T>& scale, const Vector2<T>& center ) {
|
||||
if ( scale == 1.0f )
|
||||
return;
|
||||
|
||||
for ( Uint32 i = 0; i < Vector.size(); i++ ) {
|
||||
if ( Vector[i].x < Center.x )
|
||||
Vector[i].x = Center.x - eeabs( Center.x - Vector[i].x ) * scale.x;
|
||||
if ( Vector[i].x < center.x )
|
||||
Vector[i].x = center.x - eeabs( center.x - Vector[i].x ) * scale.x;
|
||||
else
|
||||
Vector[i].x = Center.x + eeabs( Center.x - Vector[i].x ) * scale.x;
|
||||
Vector[i].x = center.x + eeabs( center.x - Vector[i].x ) * scale.x;
|
||||
|
||||
if ( Vector[i].y < Center.y )
|
||||
Vector[i].y = Center.y - eeabs( Center.y - Vector[i].y ) * scale.y;
|
||||
if ( Vector[i].y < center.y )
|
||||
Vector[i].y = center.y - eeabs( center.y - Vector[i].y ) * scale.y;
|
||||
else
|
||||
Vector[i].y = Center.y + eeabs( Center.y - Vector[i].y ) * scale.y;
|
||||
Vector[i].y = center.y + eeabs( center.y - Vector[i].y ) * scale.y;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::Scale( const T& scale, const Vector2<T>& Center ) {
|
||||
Scale( Vector2<T>( scale, scale ), Center );
|
||||
void Polygon2<T>::scale(const T& scale, const Vector2<T>& center ) {
|
||||
scale( Vector2<T>( scale, scale ), center );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Polygon2<T> Polygon2<T>::CreateRoundedRectangle( const T& x, const T& y, const T& width, const T& height, const unsigned int& Radius ) {
|
||||
Polygon2<T> Polygon2<T>::createRoundedRectangle( const T& x, const T& y, const T& width, const T& height, const unsigned int& Radius ) {
|
||||
T PI05 = (T)EE_PI * 0.5f;
|
||||
T PI15 = (T)EE_PI * 1.5f;
|
||||
T PI20 = (T)EE_PI2;
|
||||
@@ -238,44 +238,44 @@ Polygon2<T> Polygon2<T>::CreateRoundedRectangle( const T& x, const T& y, const T
|
||||
|
||||
Polygon2<T> Poly;
|
||||
|
||||
Poly.PushBack( Vector2<T>( x, y + height - Radius) );
|
||||
Poly.PushBack( Vector2<T>( x, y + Radius ) );
|
||||
Poly.pushBack( Vector2<T>( x, y + height - Radius) );
|
||||
Poly.pushBack( Vector2<T>( x, y + Radius ) );
|
||||
|
||||
for( t = (T)EE_PI; t < PI15; t += 0.1f ) {
|
||||
sx = x + Radius + (Float)cosf(t) * Radius;
|
||||
sy = y + Radius + (Float)sinf(t) * Radius;
|
||||
|
||||
Poly.PushBack( Vector2<T> (sx, sy) );
|
||||
Poly.pushBack( Vector2<T> (sx, sy) );
|
||||
}
|
||||
|
||||
Poly.PushBack( Vector2<T>( x + Radius, y ) );
|
||||
Poly.PushBack( Vector2<T>( x + width - Radius, y ) );
|
||||
Poly.pushBack( Vector2<T>( x + Radius, y ) );
|
||||
Poly.pushBack( Vector2<T>( x + width - Radius, y ) );
|
||||
|
||||
for( t = PI15; t < PI20; t += 0.1f ) {
|
||||
sx = x + width - Radius + (Float)cosf(t) * Radius;
|
||||
sy = y + Radius + (Float)sinf(t) * Radius;
|
||||
|
||||
Poly.PushBack( Vector2<T> (sx, sy) );
|
||||
Poly.pushBack( Vector2<T> (sx, sy) );
|
||||
}
|
||||
|
||||
Poly.PushBack( Vector2<T> ( x + width, y + Radius ) );
|
||||
Poly.PushBack( Vector2<T> ( x + width, y + height - Radius ) );
|
||||
Poly.pushBack( Vector2<T> ( x + width, y + Radius ) );
|
||||
Poly.pushBack( Vector2<T> ( x + width, y + height - Radius ) );
|
||||
|
||||
for( t = 0; t < PI05; t += 0.1f ){
|
||||
sx = x + width - Radius + (Float)cosf(t) * Radius;
|
||||
sy = y + height -Radius + (Float)sinf(t) * Radius;
|
||||
|
||||
Poly.PushBack( Vector2<T> (sx, sy) );
|
||||
Poly.pushBack( Vector2<T> (sx, sy) );
|
||||
}
|
||||
|
||||
Poly.PushBack( Vector2<T> ( x + width - Radius, y + height ) );
|
||||
Poly.PushBack( Vector2<T> ( x + Radius, y + height ) );
|
||||
Poly.pushBack( Vector2<T> ( x + width - Radius, y + height ) );
|
||||
Poly.pushBack( Vector2<T> ( x + Radius, y + height ) );
|
||||
|
||||
for( t = PI05; t < (T)EE_PI; t += 0.1f ) {
|
||||
sx = x + Radius + (Float)cosf(t) * Radius;
|
||||
sy = y + height - Radius + (Float)sinf(t) * Radius;
|
||||
|
||||
Poly.PushBack( Vector2<T> (sx, sy) );
|
||||
Poly.pushBack( Vector2<T> (sx, sy) );
|
||||
}
|
||||
|
||||
return Poly;
|
||||
@@ -293,9 +293,9 @@ The name of W. Randolph Franklin may not be used to endorse or promote products
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
template<typename T>
|
||||
bool Polygon2<T>::PointInside( const Vector2<T>& point ) {
|
||||
bool Polygon2<T>::pointInside( const Vector2<T>& point ) {
|
||||
int i, j, c = 0;
|
||||
int nvert = (int)Size();
|
||||
int nvert = (int)size();
|
||||
|
||||
for ( i = 0, j = nvert - 1; i < nvert; j = i++ ) {
|
||||
if ( ( ( Vector[i].y > point.y ) != ( Vector[j].y > point.y ) ) &&
|
||||
@@ -310,22 +310,22 @@ bool Polygon2<T>::PointInside( const Vector2<T>& point ) {
|
||||
|
||||
/** Polygon Polygon Collision ( SAT ) */
|
||||
template <typename T>
|
||||
bool Polygon2<T>::Intersect( const Polygon2<T>& p1 ) {
|
||||
bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
T min0, max0, min1, max1, sOffset, t;
|
||||
Vector2<T> vAxis, vOffset;
|
||||
unsigned int i = 0, j = 0, n, size = Size();
|
||||
unsigned int i = 0, j = 0, n, size = this->size();
|
||||
|
||||
vOffset = Vector2<T>( X() - p1.X(), Y() - p1.Y() );
|
||||
vOffset = Vector2<T>( x() - p1.x(), y() - p1.y() );
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
n = i + 1;
|
||||
if ( n >= Size() ) n = 0;
|
||||
if ( n >= this->size() ) n = 0;
|
||||
|
||||
vAxis = Line2<T>( Vector[i], Vector[n] ).GetNormal();
|
||||
vAxis = Line2<T>( Vector[i], Vector[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < Size(); j++) {
|
||||
for (j = 1; j < this->size(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
@@ -333,7 +333,7 @@ bool Polygon2<T>::Intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.Size(); j++) {
|
||||
for (j = 1; j < p1.size(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
@@ -348,15 +348,15 @@ bool Polygon2<T>::Intersect( const Polygon2<T>& p1 ) {
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < p1.Size(); i++) {
|
||||
for (i = 0; i < p1.size(); i++) {
|
||||
n = i + 1;
|
||||
if ( n >= p1.Size() ) n = 0;
|
||||
if ( n >= p1.size() ) n = 0;
|
||||
|
||||
vAxis = Line2<T>( p1[i], p1[n] ).GetNormal();
|
||||
vAxis = Line2<T>( p1[i], p1[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < Size(); j++) {
|
||||
for (j = 1; j < this->size(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
@@ -364,7 +364,7 @@ bool Polygon2<T>::Intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.Size(); j++) {
|
||||
for (j = 1; j < p1.size(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
@@ -385,18 +385,18 @@ bool Polygon2<T>::Intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
/** Quad Quad Collision */
|
||||
template <typename T>
|
||||
bool Polygon2<T>::IntersectQuad2( const Quad2<T>& q0, const Quad2<T>& q1, const Vector2<T>& q0Pos, const Vector2<T>& q1Pos ) {
|
||||
bool Polygon2<T>::intersectQuad2( const Quad2<T>& q0, const Quad2<T>& q1, const Vector2<T>& q0Pos, const Vector2<T>& q1Pos ) {
|
||||
Polygon2<T> Tmp1 = Polygon2<T>( q0 );
|
||||
Polygon2<T> Tmp2 = Polygon2<T>( q1 );
|
||||
|
||||
Tmp1.Position( q0Pos );
|
||||
Tmp1.Position( q1Pos );
|
||||
Tmp1.position( q0Pos );
|
||||
Tmp1.position( q1Pos );
|
||||
|
||||
return Tmp1.Intersect( Tmp2 );
|
||||
return Tmp1.intersect( Tmp2 );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T> Polygon2<T>::ToAABB() {
|
||||
tRECT<T> Polygon2<T>::toAABB() {
|
||||
tRECT<T> TmpR;
|
||||
|
||||
if ( Vector.size() < 4 ) {
|
||||
@@ -421,14 +421,14 @@ tRECT<T> Polygon2<T>::ToAABB() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Polygon2<T>::Move( Vector2<T> dist ) {
|
||||
void Polygon2<T>::move( Vector2<T> dist ) {
|
||||
for ( Uint32 i = 0; i < Vector.size(); i++ ) {
|
||||
Vector[i] += dist;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Uint32 Polygon2<T>::ClosestPoint( const Vector2<T>& to, T * distance ) {
|
||||
Uint32 Polygon2<T>::closestPoint( const Vector2<T>& to, T * distance ) {
|
||||
Uint32 Index = 0;
|
||||
T Dist = (T)99999999;
|
||||
T tDist;
|
||||
@@ -438,7 +438,7 @@ Uint32 Polygon2<T>::ClosestPoint( const Vector2<T>& to, T * distance ) {
|
||||
}
|
||||
|
||||
for ( Uint32 i = 0; i < Vector.size(); i++ ) {
|
||||
tDist = Vector[i].Distance( to );
|
||||
tDist = Vector[i].distance( to );
|
||||
|
||||
if ( tDist < Dist ) {
|
||||
Index = i;
|
||||
|
||||
@@ -31,37 +31,37 @@ class Quad2 {
|
||||
Vector2<T> V[3]; //! Right - Top Vector2
|
||||
@return The center point of the quad
|
||||
*/
|
||||
Vector2<T> GetCenter();
|
||||
Vector2<T> getCenter();
|
||||
|
||||
/** @return The Vector2 from the position index ( from 0 to 3 ) */
|
||||
Vector2<T>& GetAt( Uint32 Index ) { return V[Index]; }
|
||||
Vector2<T>& getAt( Uint32 Index ) { return V[Index]; }
|
||||
|
||||
/** Creates a quad from a rectangle */
|
||||
static Quad2<T> FromAABB( const tRECT<T>& R );
|
||||
static Quad2<T> fromAABB( const tRECT<T>& R );
|
||||
|
||||
/** @return The Axis-Aligned bounding box of the Quad */
|
||||
tRECT<T> ToAABB( const T& OffsetX = 0, const T& OffsetY = 0 );
|
||||
tRECT<T> toAABB( const T& OffsetX = 0, const T& OffsetY = 0 );
|
||||
|
||||
/** Rotates the quad from a rotation center */
|
||||
void Rotate( const T& Angle, const Vector2<T>& Center );
|
||||
void rotate( const T& Angle, const Vector2<T>& Center );
|
||||
|
||||
/** Rotates the quad from its rotation center */
|
||||
void Rotate( const T& Angle );
|
||||
void rotate( const T& Angle );
|
||||
|
||||
/** Scale the quad from its rotation center */
|
||||
void Scale( const T& scale );
|
||||
void scale( const T& scale );
|
||||
|
||||
/** Scale the quad from an specified center */
|
||||
void Scale( const T& scale, const Vector2<T>& Center );
|
||||
void scale(const T& scale, const Vector2<T>& center );
|
||||
|
||||
/** Scale the quad from its rotation center */
|
||||
void Scale( const Vector2<T>& scale );
|
||||
void scale( const Vector2<T>& scale );
|
||||
|
||||
/** Scale the quad from an specified center */
|
||||
void Scale( const Vector2<T>& scale, const Vector2<T>& Center );
|
||||
void scale( const Vector2<T>& scale, const Vector2<T>& center );
|
||||
|
||||
/** Move the polygon Vector2s, add to every point the distance specified */
|
||||
void Move( Vector2<T> dist );
|
||||
void move( Vector2<T> dist );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -89,57 +89,57 @@ Quad2<T>::Quad2( const tRECT<T>& R ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Rotate( const T& Angle ) {
|
||||
Rotate( Angle, GetCenter() );
|
||||
void Quad2<T>::rotate( const T& Angle ) {
|
||||
rotate( Angle, getCenter() );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Rotate( const T& Angle, const Vector2<T>& Center ) {
|
||||
void Quad2<T>::rotate( const T& Angle, const Vector2<T>& Center ) {
|
||||
if ( Angle == 0.f )
|
||||
return;
|
||||
|
||||
V[0].Rotate( Angle, Center );
|
||||
V[1].Rotate( Angle, Center );
|
||||
V[2].Rotate( Angle, Center );
|
||||
V[3].Rotate( Angle, Center );
|
||||
V[0].rotate( Angle, Center );
|
||||
V[1].rotate( Angle, Center );
|
||||
V[2].rotate( Angle, Center );
|
||||
V[3].rotate( Angle, Center );
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Scale( const Vector2<T>& scale, const Vector2<T>& Center ) {
|
||||
void Quad2<T>::scale(const Vector2<T>& scale, const Vector2<T>& center ) {
|
||||
if ( scale == 1.0f )
|
||||
return;
|
||||
|
||||
for ( Uint32 i = 0; i < 4; i++ ) {
|
||||
if ( V[i].x < Center.x )
|
||||
V[i].x = Center.x - eeabs( Center.x - V[i].x ) * scale.x;
|
||||
if ( V[i].x < center.x )
|
||||
V[i].x = center.x - eeabs( center.x - V[i].x ) * scale.x;
|
||||
else
|
||||
V[i].x = Center.x + eeabs( Center.x - V[i].x ) * scale.x;
|
||||
V[i].x = center.x + eeabs( center.x - V[i].x ) * scale.x;
|
||||
|
||||
if ( V[i].y < Center.y )
|
||||
V[i].y = Center.y - eeabs( Center.y - V[i].y ) * scale.y;
|
||||
if ( V[i].y < center.y )
|
||||
V[i].y = center.y - eeabs( center.y - V[i].y ) * scale.y;
|
||||
else
|
||||
V[i].y = Center.y + eeabs( Center.y - V[i].y ) * scale.y;
|
||||
V[i].y = center.y + eeabs( center.y - V[i].y ) * scale.y;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Scale( const Vector2<T>& scale ) {
|
||||
Scale( scale, GetCenter() );
|
||||
void Quad2<T>::scale( const Vector2<T>& scale ) {
|
||||
this->scale( scale, getCenter() );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Scale( const T& scale, const Vector2<T>& Center ) {
|
||||
Scale( Vector2<T>( scale, scale ), Center );
|
||||
void Quad2<T>::scale( const T& scale, const Vector2<T>& center ) {
|
||||
this->scale( Vector2<T>( scale, scale ), center );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Scale( const T& scale ) {
|
||||
Scale( scale, GetCenter() );
|
||||
void Quad2<T>::scale( const T& scale ) {
|
||||
this->scale( scale, getCenter() );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Quad2<T>::GetCenter() {
|
||||
Vector2<T> Quad2<T>::getCenter() {
|
||||
Float MinX = V[0].x, MaxX = V[0].x, MinY = V[0].y, MaxY = V[0].y;
|
||||
|
||||
for (Uint8 i = 1; i < 4; i++ ) {
|
||||
@@ -153,12 +153,12 @@ Vector2<T> Quad2<T>::GetCenter() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Quad2<T> Quad2<T>::FromAABB( const tRECT<T>& R ) {
|
||||
Quad2<T> Quad2<T>::fromAABB( const tRECT<T>& R ) {
|
||||
return Quad2<T>( Vector2<T>( R.Left, R.Top ), Vector2<T>( R.Left, R.Bottom ), Vector2<T>( R.Right, R.Bottom ), Vector2<T>( R.Right, R.Top ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T> Quad2<T>::ToAABB( const T& OffsetX, const T& OffsetY ) {
|
||||
tRECT<T> Quad2<T>::toAABB( const T& OffsetX, const T& OffsetY ) {
|
||||
tRECT<T> TmpR;
|
||||
|
||||
Float MinX = V[0].x, MaxX = V[0].x, MinY = V[0].y, MaxY = V[0].y;
|
||||
@@ -187,7 +187,7 @@ const Vector2<T>& Quad2<T>::operator[] ( const Uint32& Pos ) const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Quad2<T>::Move( Vector2<T> dist ) {
|
||||
void Quad2<T>::move( Vector2<T> dist ) {
|
||||
if ( dist.x == 0 && dist.y == 0 )
|
||||
return;
|
||||
|
||||
|
||||
@@ -13,59 +13,59 @@ class tRECT {
|
||||
|
||||
tRECT( T left, T top, T right, T bottom );
|
||||
|
||||
tRECT( const Vector2<T>& Pos, const tSize<T>& Size );
|
||||
tRECT( const Vector2<T>& pos, const tSize<T>& size );
|
||||
|
||||
tRECT();
|
||||
|
||||
tRECT<T> Copy();
|
||||
tRECT<T> copy();
|
||||
|
||||
bool Intersect( const tRECT<T>& Rect );
|
||||
bool intersect( const tRECT<T>& Rect );
|
||||
|
||||
bool Contains( const tRECT<T>& Rect );
|
||||
bool contains( const tRECT<T>& Rect );
|
||||
|
||||
bool Contains( const Vector2<T>& Vect );
|
||||
bool contains( const Vector2<T>& Vect );
|
||||
|
||||
void Merge( const tRECT<T>& Rect );
|
||||
void merge( const tRECT<T>& Rect );
|
||||
|
||||
void Expand( const Vector2<T>& Vect );
|
||||
void expand( const Vector2<T>& Vect );
|
||||
|
||||
T Area();
|
||||
T area();
|
||||
|
||||
T MergedArea( const tRECT<T>& Rect );
|
||||
T mergedArea( const tRECT<T>& Rect );
|
||||
|
||||
bool IntersectsSegment( const Vector2<T>& a, const Vector2<T>& b );
|
||||
bool intersectsSegment( const Vector2<T>& a, const Vector2<T>& b );
|
||||
|
||||
/** Determine if a RECT and a Circle are intersecting
|
||||
* @param pos Circle position
|
||||
* @param radius Circle Radius
|
||||
* @return True if are intersecting
|
||||
*/
|
||||
bool IntersectCircle( Vector2<T> pos, const T& radius );
|
||||
bool intersectCircle( Vector2<T> pos, const T& radius );
|
||||
|
||||
/** Determine if a RECT ( representing a circle ) is intersecting another RECT ( also representing a circle ) */
|
||||
bool IntersectCircles( const tRECT<T>& b );
|
||||
bool intersectCircles( const tRECT<T>& b );
|
||||
|
||||
Vector2<T> ClampVector( const Vector2<T>& Vect );
|
||||
Vector2<T> clampVector( const Vector2<T>& Vect );
|
||||
|
||||
Vector2<T> WrapVector( const Vector2<T>& Vect );
|
||||
Vector2<T> wrapVector( const Vector2<T>& Vect );
|
||||
|
||||
Vector2<T> Pos();
|
||||
Vector2<T> pos();
|
||||
|
||||
Vector2<T> Center();
|
||||
Vector2<T> center();
|
||||
|
||||
tSize<T> Size();
|
||||
tSize<T> size();
|
||||
|
||||
T Width();
|
||||
T width();
|
||||
|
||||
T Height();
|
||||
T height();
|
||||
|
||||
void Scale( T scale, const Vector2<T>& center );
|
||||
void scale( T scale, const Vector2<T>& center );
|
||||
|
||||
void Scale( T scale );
|
||||
void scale( T scale );
|
||||
|
||||
void Scale( Vector2<T> scale, const Vector2<T>& center );
|
||||
void scale( Vector2<T> scale, const Vector2<T>& center );
|
||||
|
||||
void Scale( Vector2<T> scale );
|
||||
void scale( Vector2<T> scale );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -140,7 +140,7 @@ tRECT<T>::tRECT(T left, T top, T right, T bottom) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T> tRECT<T>::Copy() {
|
||||
tRECT<T> tRECT<T>::copy() {
|
||||
return tRECT<T>( Left, Top, Right, Bottom );
|
||||
}
|
||||
|
||||
@@ -148,55 +148,55 @@ template <typename T>
|
||||
tRECT<T>::tRECT( const Vector2<T>& Pos, const tSize<T>& Size ) {
|
||||
Left = Pos.x;
|
||||
Top = Pos.y;
|
||||
Right = Left + Size.Width();
|
||||
Bottom = Top + Size.Height();
|
||||
Right = Left + Size.width();
|
||||
Bottom = Top + Size.height();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T>::tRECT() : Left(0), Right(0), Top(0), Bottom(0) {}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::Contains( const tRECT<T>& Rect ) {
|
||||
bool tRECT<T>::contains( const tRECT<T>& Rect ) {
|
||||
return ( Left <= Rect.Left && Right >= Rect.Right && Top <= Rect.Top && Bottom >= Rect.Bottom );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::Intersect( const tRECT<T>& Rect ) {
|
||||
bool tRECT<T>::intersect( const tRECT<T>& Rect ) {
|
||||
return !( Left > Rect.Right || Right < Rect.Left || Top > Rect.Bottom || Bottom < Rect.Top );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::Contains( const Vector2<T>& Vect ) {
|
||||
bool tRECT<T>::contains( const Vector2<T>& Vect ) {
|
||||
return ( Left <= Vect.x && Right >= Vect.x && Top <= Vect.y && Bottom >= Vect.y );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::Pos() {
|
||||
Vector2<T> tRECT<T>::pos() {
|
||||
return Vector2<T>( Left, Top );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::Center() {
|
||||
Vector2<T> tRECT<T>::center() {
|
||||
return Vector2<T>( Left + ( ( Right - Left ) * 0.5 ), Top + ( ( Bottom - Top ) * 0.5 ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tSize<T> tRECT<T>::Size() {
|
||||
tSize<T> tRECT<T>::size() {
|
||||
return tSize<T>( eeabs( Right - Left ), eeabs( Bottom - Top ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::Width() {
|
||||
T tRECT<T>::width() {
|
||||
return eeabs( Right - Left );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::Height() {
|
||||
T tRECT<T>::height() {
|
||||
return eeabs( Bottom - Top );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Merge( const tRECT<T>& Rect ) {
|
||||
void tRECT<T>::merge( const tRECT<T>& Rect ) {
|
||||
Left = eemin( Left , Rect.Left );
|
||||
Bottom = eemin( Bottom , Rect.Bottom );
|
||||
Right = eemax( Right , Rect.Right );
|
||||
@@ -204,7 +204,7 @@ void tRECT<T>::Merge( const tRECT<T>& Rect ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Expand( const Vector2<T>& Vect ) {
|
||||
void tRECT<T>::expand( const Vector2<T>& Vect ) {
|
||||
Left = eemin( Left , Vect.x );
|
||||
Bottom = eemin( Bottom , Vect.y );
|
||||
Right = eemax( Right , Vect.x );
|
||||
@@ -212,17 +212,17 @@ void tRECT<T>::Expand( const Vector2<T>& Vect ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::Area() {
|
||||
T tRECT<T>::area() {
|
||||
return ( Right - Left ) * ( Bottom - Top );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::MergedArea( const tRECT<T>& Rect ) {
|
||||
T tRECT<T>::mergedArea( const tRECT<T>& Rect ) {
|
||||
return ( eemax( Right, Rect.Right ) - eemin( Left, Rect.Left ) ) * ( eemin( Bottom, Rect.Bottom ) - eemax( Top, Rect.Top ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::IntersectsSegment( const Vector2<T>& a, const Vector2<T>& b ) {
|
||||
bool tRECT<T>::intersectsSegment( const Vector2<T>& a, const Vector2<T>& b ) {
|
||||
tRECT<T> seg_bb = tRECT<T>( eemin( a.x, b.x ), eemin( a.y, b.y ), eemax( a.x, b.x ), eemax( a.y, b.y ) );
|
||||
|
||||
if( Intersects( seg_bb ) ){
|
||||
@@ -237,7 +237,7 @@ bool tRECT<T>::IntersectsSegment( const Vector2<T>& a, const Vector2<T>& b ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::IntersectCircle( Vector2<T> pos, const T& radius ) {
|
||||
bool tRECT<T>::intersectCircle( Vector2<T> pos, const T& radius ) {
|
||||
Vector2<T> tPos( pos );
|
||||
|
||||
if (tPos.x < Left) tPos.x = Left;
|
||||
@@ -245,14 +245,14 @@ bool tRECT<T>::IntersectCircle( Vector2<T> pos, const T& radius ) {
|
||||
if (tPos.y < Top) tPos.y = Top;
|
||||
if (tPos.y > Bottom) tPos.y = Bottom;
|
||||
|
||||
if ( pos.Distance( tPos ) < radius )
|
||||
if ( pos.distance( tPos ) < radius )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool tRECT<T>::IntersectCircles( const tRECT<T>& b ) {
|
||||
bool tRECT<T>::intersectCircles( const tRECT<T>& b ) {
|
||||
Float ra = (Float)(Right - Left) * 0.5f;
|
||||
Float rb = (Float)(b.Right - b.Left) * 0.5f;
|
||||
Float dist = ra + rb;
|
||||
@@ -266,7 +266,7 @@ bool tRECT<T>::IntersectCircles( const tRECT<T>& b ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::ClampVector( const Vector2<T>& Vect ) {
|
||||
Vector2<T> tRECT<T>::clampVector( const Vector2<T>& Vect ) {
|
||||
T x = eemin( eemax( Left , Vect.x ), Right );
|
||||
T y = eemin( eemax( Top , Vect.y ), Bottom );
|
||||
|
||||
@@ -274,7 +274,7 @@ Vector2<T> tRECT<T>::ClampVector( const Vector2<T>& Vect ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::WrapVector( const Vector2<T>& Vect ) {
|
||||
Vector2<T> tRECT<T>::wrapVector( const Vector2<T>& Vect ) {
|
||||
T ix = eeabs( Right - Left );
|
||||
T modx = eemod( Vect.x - Left, ix );
|
||||
T x = ( modx > 0 ) ? modx : modx + ix;
|
||||
@@ -287,7 +287,7 @@ Vector2<T> tRECT<T>::WrapVector( const Vector2<T>& Vect ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Scale( Vector2<T> scale, const Vector2<T>& center ) {
|
||||
void tRECT<T>::scale( Vector2<T> scale, const Vector2<T>& center ) {
|
||||
if ( scale != 1.0f ) {
|
||||
Left = center.x + ( Left - center.x ) * scale.x;
|
||||
Top = center.y + ( Top - center.y ) * scale.y;
|
||||
@@ -297,18 +297,18 @@ void tRECT<T>::Scale( Vector2<T> scale, const Vector2<T>& center ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Scale( T scale, const Vector2<T>& center ) {
|
||||
Scale( Vector2f( scale, scale ), center );
|
||||
void tRECT<T>::scale( T scale, const Vector2<T>& center ) {
|
||||
scale( Vector2f( scale, scale ), center );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Scale( T scale ) {
|
||||
Scale( scale, Center() );
|
||||
void tRECT<T>::scale( T scale ) {
|
||||
scale( scale, center() );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::Scale( Vector2<T> scale ) {
|
||||
Scale( scale, Center() );
|
||||
void tRECT<T>::scale( Vector2<T> scale ) {
|
||||
scale( scale, center() );
|
||||
}
|
||||
|
||||
typedef tRECT<unsigned int> Rectu;
|
||||
|
||||
@@ -14,7 +14,7 @@ class tSize : public Vector2<T>
|
||||
tSize();
|
||||
|
||||
/** Creates a tSize of the width and height */
|
||||
tSize( const T& Width, const T& Height );
|
||||
tSize( const T& width, const T& height );
|
||||
|
||||
/** Creates a copy of a size */
|
||||
tSize( const tSize<T>& Size );
|
||||
@@ -23,16 +23,16 @@ class tSize : public Vector2<T>
|
||||
tSize( const Vector2<T>& Vec );
|
||||
|
||||
/** @return The size width */
|
||||
const T& Width() const;
|
||||
const T& width() const;
|
||||
|
||||
/** @return The size height */
|
||||
const T& Height() const;
|
||||
const T& height() const;
|
||||
|
||||
/** Set a new width */
|
||||
void Width( const T& width );
|
||||
void width( const T& width );
|
||||
|
||||
/** Set a new height */
|
||||
void Height( const T& height );
|
||||
void height( const T& height );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -49,7 +49,7 @@ tSize<T>::tSize( const T& Width, const T& Height ) :
|
||||
|
||||
template <typename T>
|
||||
tSize<T>::tSize( const tSize<T>& Size ) :
|
||||
Vector2<T>( Size.Width(), Size.Height() )
|
||||
Vector2<T>( Size.width(), Size.height() )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,22 +60,22 @@ tSize<T>::tSize( const Vector2<T>& Vec ) :
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& tSize<T>::Width() const {
|
||||
const T& tSize<T>::width() const {
|
||||
return this->x;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& tSize<T>::Height() const {
|
||||
const T& tSize<T>::height() const {
|
||||
return this->y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tSize<T>::Width( const T& width ) {
|
||||
void tSize<T>::width( const T& width ) {
|
||||
this->x = width;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tSize<T>::Height( const T& height ) {
|
||||
void tSize<T>::height( const T& height ) {
|
||||
this->y = height;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Triangle2 {
|
||||
Vector2<T> V[3];
|
||||
|
||||
/** @return The vector index ( between 0 and 2 ) */
|
||||
Vector2<T>& GetAt( Uint32 Index ) { return V[Index]; }
|
||||
Vector2<T>& getAt( Uint32 Index ) { return V[Index]; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -21,7 +21,7 @@ class Vector2 {
|
||||
Vector2(T X, T Y);
|
||||
|
||||
/** @return A copy of the Vector2 */
|
||||
Vector2<T> Copy();
|
||||
Vector2<T> copy();
|
||||
|
||||
/** @return The Dot product of the 2D vectors. */
|
||||
T Dot( const Vector2<T>& V2 );
|
||||
@@ -30,67 +30,67 @@ class Vector2 {
|
||||
T Cross( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The perpendicular vector */
|
||||
Vector2<T> Perp();
|
||||
Vector2<T> perp();
|
||||
|
||||
/** @return The reveser perpendicular vector */
|
||||
Vector2<T> RPerp();
|
||||
Vector2<T> rPerp();
|
||||
|
||||
/** Uses complex multiplication to rotate self by vec. Scaling will occur if self is not a unit vector. */
|
||||
Vector2<T> Rotate( const Vector2<T>& V2 );
|
||||
Vector2<T> rotate( const Vector2<T>& V2 );
|
||||
|
||||
/** Inverse of Vector2::Rotate */
|
||||
Vector2<T> UnRotate( const Vector2<T>& V2 );
|
||||
/** Inverse of Vector2::rotate */
|
||||
Vector2<T> unrotate( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The vector Length */
|
||||
T Length();
|
||||
T length();
|
||||
|
||||
/** @return The square of the length of the 2D vector. */
|
||||
T LengthSq();
|
||||
T lengthSq();
|
||||
|
||||
/** Normalize the vector */
|
||||
void Normalize();
|
||||
void normalize();
|
||||
|
||||
/** @return Clamp the vector to a magnitude length. */
|
||||
void Clamp( T len );
|
||||
void clamp( T len );
|
||||
|
||||
/** @return The unit length vector for the given angle (radians) */
|
||||
Vector2<T> ForAngle( const T& a );
|
||||
Vector2<T> forAngle( const T& a );
|
||||
|
||||
/** @return The angular direction vector is pointing in (radians). */
|
||||
T ToAngle();
|
||||
T toAngle();
|
||||
|
||||
/** Rotates the vector */
|
||||
void Rotate( const T& Angle );
|
||||
void rotate( const T& Angle );
|
||||
|
||||
/** Rotates the vector against a defined rotation center */
|
||||
void Rotate( const T& Angle, const Vector2<T>& RotationCenter );
|
||||
void rotate( const T& Angle, const Vector2<T>& RotationCenter );
|
||||
|
||||
/** @return The distance between two vectors */
|
||||
T Distance( const Vector2<T>& Vec );
|
||||
T distance( const Vector2<T>& Vec );
|
||||
|
||||
/** @return The square of the distance between two vectors */
|
||||
T DistanceSq( const Vector2<T>& Vec );
|
||||
T distanceSq( const Vector2<T>& Vec );
|
||||
|
||||
/** @return True if the distance between the two vectors is less than Dist */
|
||||
bool Near( const Vector2<T>& Vec, T Dist );
|
||||
bool near( const Vector2<T>& Vec, T Dist );
|
||||
|
||||
/** @return The spherical linear interpolation between two 2D vectors. */
|
||||
Vector2<T> SphericalLerp( const Vector2<T>& Vec, T Time );
|
||||
Vector2<T> sphericalLerp( const Vector2<T>& Vec, T Time );
|
||||
|
||||
/** Spherical linear interpolation between two vectors */
|
||||
Vector2<T> SphericalLerpConst( const Vector2<T>& Vec, T Angle );
|
||||
Vector2<T> sphericalLerpConst( const Vector2<T>& Vec, T Angle );
|
||||
|
||||
/** Performs a linear interpolation between two 2D vectors. */
|
||||
Vector2<T> Lerp( const Vector2<T>& Vec, T Time );
|
||||
Vector2<T> lerp( const Vector2<T>& Vec, T Time );
|
||||
|
||||
/** @return A vector interpolated from self towards Vec with length Dist. */
|
||||
Vector2<T> LerpConst( const Vector2<T>& Vec, T Dist );
|
||||
Vector2<T> lerpConst( const Vector2<T>& Vec, T Dist );
|
||||
|
||||
/** Scales the vector position against another vector */
|
||||
void Scale( const Vector2<T>& scale, const Vector2<T>& Center );
|
||||
void scale( const Vector2<T>& scale, const Vector2<T>& Center );
|
||||
|
||||
/** Scales the vector position against another vector */
|
||||
void Scale( const T& scale, const Vector2<T>& Center );
|
||||
void scale( const T& scale, const Vector2<T>& Center );
|
||||
|
||||
T x;
|
||||
T y;
|
||||
@@ -106,19 +106,19 @@ template <typename T>
|
||||
const Vector2<T> Vector2<T>::Zero = Vector2<T>(0,0);
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::Lerp( const Vector2<T>& Vec, T Time ) {
|
||||
Vector2<T> Vector2<T>::lerp( const Vector2<T>& Vec, T Time ) {
|
||||
return *this * ( 1 - Time ) + Vec * Time;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::LerpConst( const Vector2<T>& Vec, T Dist ) {
|
||||
Vector2<T> Vector2<T>::lerpConst( const Vector2<T>& Vec, T Dist ) {
|
||||
Vector2<T> t( *this + ( Vec - *this ) );
|
||||
t.Clamp( Dist );
|
||||
t.clamp( Dist );
|
||||
return t;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::SphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
Vector2<T> Vector2<T>::sphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
T omega = eeacos( Dot( Vec ) );
|
||||
|
||||
if( omega ) {
|
||||
@@ -131,9 +131,9 @@ Vector2<T> Vector2<T>::SphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::SphericalLerpConst( const Vector2<T>& Vec, T Angle ) {
|
||||
Vector2<T> Vector2<T>::sphericalLerpConst( const Vector2<T>& Vec, T Angle ) {
|
||||
T angle = eeacos( Dot( Vec ) );
|
||||
return Lerp( Vec, ( ( Angle < angle ) ? Angle : angle ) / angle );
|
||||
return lerp( Vec, ( ( Angle < angle ) ? Angle : angle ) / angle );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -273,19 +273,19 @@ T Vector2<T>::sinAng( const T& Ang ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Rotate( const T& Angle ) {
|
||||
void Vector2<T>::rotate( const T& Angle ) {
|
||||
T nx = x * cosAng(Angle) - y * sinAng(Angle);
|
||||
y = y * cosAng(Angle) + x * sinAng(Angle);
|
||||
x = nx;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Rotate( const T& Angle, const Vector2<T>& RotationCenter ) {
|
||||
void Vector2<T>::rotate( const T& Angle, const Vector2<T>& RotationCenter ) {
|
||||
if ( 1.f != Angle ) {
|
||||
x -= RotationCenter.x;
|
||||
y -= RotationCenter.y;
|
||||
|
||||
Rotate( Angle );
|
||||
rotate( Angle );
|
||||
|
||||
x += RotationCenter.x;
|
||||
y += RotationCenter.y;
|
||||
@@ -293,7 +293,7 @@ void Vector2<T>::Rotate( const T& Angle, const Vector2<T>& RotationCenter ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Scale( const Vector2<T>& scale, const Vector2<T>& Center ) {
|
||||
void Vector2<T>::scale( const Vector2<T>& scale, const Vector2<T>& Center ) {
|
||||
if ( 1.f != scale ) {
|
||||
if ( x < Center.x )
|
||||
x = Center.x - eeabs( Center.x - x ) * scale.x;
|
||||
@@ -308,8 +308,8 @@ void Vector2<T>::Scale( const Vector2<T>& scale, const Vector2<T>& Center ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Scale( const T& scale, const Vector2<T>& Center ) {
|
||||
Scale( Vector2<T>( scale, scale ), Center );
|
||||
void Vector2<T>::scale( const T& scale, const Vector2<T>& Center ) {
|
||||
scale( Vector2<T>( scale, scale ), Center );
|
||||
}
|
||||
|
||||
|
||||
@@ -324,37 +324,37 @@ T Vector2<T>::Cross( const Vector2<T>& V2 ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::Perp() {
|
||||
Vector2<T> Vector2<T>::perp() {
|
||||
return Vector2<T>( -y, x );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::RPerp() {
|
||||
Vector2<T> Vector2<T>::rPerp() {
|
||||
return Vector2<T>( y, -x );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::Rotate( const Vector2<T>& V2 ) {
|
||||
Vector2<T> Vector2<T>::rotate( const Vector2<T>& V2 ) {
|
||||
return Vector2<T>( x * V2.x - y * V2.y , x * V2.y + y * V2.x );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::UnRotate( const Vector2<T>& V2 ) {
|
||||
Vector2<T> Vector2<T>::unrotate( const Vector2<T>& V2 ) {
|
||||
return Vector2<T>( x * V2.x - y * V2.y , x * V2.x + y * V2.y );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Length() {
|
||||
T Vector2<T>::length() {
|
||||
return eesqrt( Dot( Vector2<T>( x , y ) ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::LengthSq() {
|
||||
T Vector2<T>::lengthSq() {
|
||||
return Dot( Vector2<T>( x , y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Normalize() {
|
||||
void Vector2<T>::normalize() {
|
||||
T s = eesqrt(x * x + y * y);
|
||||
if (s == 0) {
|
||||
x = 0;
|
||||
@@ -366,29 +366,29 @@ void Vector2<T>::Normalize() {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::ForAngle( const T& a ) {
|
||||
Vector2<T> Vector2<T>::forAngle( const T& a ) {
|
||||
return Vector2<T>( eecos(a), eesin(a) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::ToAngle() {
|
||||
T Vector2<T>::toAngle() {
|
||||
return eeatan2( y, x );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Distance( const Vector2<T>& Vec ) {
|
||||
T Vector2<T>::distance( const Vector2<T>& Vec ) {
|
||||
return eesqrt( ( x - Vec.x ) * ( x - Vec.x ) + ( y - Vec.y ) * ( y - Vec.y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::DistanceSq( const Vector2<T>& Vec ) {
|
||||
return ( *this - Vec ).LengthSq();
|
||||
T Vector2<T>::distanceSq( const Vector2<T>& Vec ) {
|
||||
return ( *this - Vec ).lengthSq();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::Clamp( T len ) {
|
||||
void Vector2<T>::clamp( T len ) {
|
||||
if ( Dot( Vector2<T>( x, y ) ) > len * len ) {
|
||||
Normalize();
|
||||
normalize();
|
||||
|
||||
x *= len;
|
||||
y *= len;
|
||||
@@ -396,12 +396,12 @@ void Vector2<T>::Clamp( T len ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Vector2<T>::Near( const Vector2<T>& Vec, T Dist ) {
|
||||
return 0 != ( DistanceSq( Vec ) < Dist * Dist );
|
||||
bool Vector2<T>::near( const Vector2<T>& Vec, T Dist ) {
|
||||
return 0 != ( distanceSq( Vec ) < Dist * Dist );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::Copy() {
|
||||
Vector2<T> Vector2<T>::copy() {
|
||||
return Vector2<T>( x, y );
|
||||
}
|
||||
|
||||
|
||||
@@ -33,82 +33,82 @@ class EE_API Waypoints {
|
||||
typedef cb::Callback0<void> OnStepCallback;
|
||||
|
||||
/** Add a new waypoint */
|
||||
void AddWaypoint( const Vector2f& Pos, const Float& Time = 0.f );
|
||||
void addWaypoint( const Vector2f& Pos, const Float& Time = 0.f );
|
||||
|
||||
/** Edit a waypoint */
|
||||
bool EditWaypoint( const unsigned int& PointNum, const Vector2f& NewPos, const Float& NewTime );
|
||||
bool editWaypoint( const unsigned int& PointNum, const Vector2f& NewPos, const Float& NewTime );
|
||||
|
||||
/** Erase a waypoint */
|
||||
bool EraseWaypoint( const unsigned int& PointNum );
|
||||
bool eraseWaypoint( const unsigned int& PointNum );
|
||||
|
||||
/** Start the animation ( will reset the current state, and start from the beginning )
|
||||
* @param PathEndCallback An optional callback fired when the animation ends.
|
||||
* @param StepCallback An optional callback that is fired every time that a step is completed.
|
||||
*/
|
||||
void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() );
|
||||
void start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() );
|
||||
|
||||
/** Stop the animation ( Enable = false ) */
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
/** Sets a path end callback */
|
||||
void SetPathEndCallback( OnPathEndCallback PathEndCallback );
|
||||
void setPathEndCallback( OnPathEndCallback PathEndCallback );
|
||||
|
||||
/** Sets a step callback */
|
||||
void SetStepCallback( OnStepCallback StepCallback );
|
||||
void setStepCallback( OnStepCallback StepCallback );
|
||||
|
||||
/** Update the movement interpolation */
|
||||
void Update( const Time& Elapsed );
|
||||
void update( const Time& Elapsed );
|
||||
|
||||
/** Reset the class */
|
||||
void Reset();
|
||||
void reset();
|
||||
|
||||
/** @return The Current Position */
|
||||
const Vector2f& GetPos();
|
||||
const Vector2f& getPos();
|
||||
|
||||
/** @return If movement interpolation is a loop */
|
||||
bool Loop() const;
|
||||
bool loop() const;
|
||||
|
||||
/** Set if loop the movement interpolation */
|
||||
void Loop( const bool& loop );
|
||||
void loop( const bool& loop );
|
||||
|
||||
/** Clear all the waypoints */
|
||||
void ClearWaypoints();
|
||||
void clearWaypoints();
|
||||
|
||||
/** @return If the animation ended */
|
||||
bool Ended() const;
|
||||
bool ended() const;
|
||||
|
||||
/** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */
|
||||
void SetTotalTime( const Time & TotTime );
|
||||
void setTotalTime( const Time & TotTime );
|
||||
|
||||
/** @return The Current Node */
|
||||
Waypoint * GetCurrentActual() const;
|
||||
Waypoint * getCurrentActual() const;
|
||||
|
||||
/** @return The Next Node */
|
||||
Waypoint * GetCurrentNext() const;
|
||||
Waypoint * getCurrentNext() const;
|
||||
|
||||
/** @return The Current Position in the vector */
|
||||
const Uint32& GetCurrentPos() const;
|
||||
const Uint32& getCurrentPos() const;
|
||||
|
||||
/** @return the vector of waypoints */
|
||||
const std::vector<Waypoint>& GetWaypoints() const;
|
||||
const std::vector<Waypoint>& getWaypoints() const;
|
||||
|
||||
/** Set the current interpolation speed ( This will destroy the time of the interpolation and create one depending on the speed ) ( pixels per second ) */
|
||||
void Speed( const Float& Speed );
|
||||
void speed( const Float& speed );
|
||||
|
||||
/** Get the current interpolation speed */
|
||||
const Float& Speed() const;
|
||||
const Float& speed() const;
|
||||
|
||||
/** @return If enabled */
|
||||
const bool& Enabled() const;
|
||||
const bool& enabled() const;
|
||||
|
||||
/** Set it enabled or not */
|
||||
void Enabled( const bool& Enabled );
|
||||
void enabled( const bool& enabled );
|
||||
|
||||
/** Set the type of interpolation to be used */
|
||||
void Type( Ease::Interpolation InterpolationType );
|
||||
void type( Ease::Interpolation InterpolationType );
|
||||
|
||||
/** @return The type of the interpolation */
|
||||
const int& Type() const;
|
||||
const int& type() const;
|
||||
protected:
|
||||
int mType;
|
||||
bool mEnable;
|
||||
|
||||
@@ -62,7 +62,7 @@ UIControl * UIItemContainer<TContainer>::OverFind( const Vector2f& Point ) {
|
||||
if ( mEnabled && mVisible && tParent->mItems.size() ) {
|
||||
UpdateQuad();
|
||||
|
||||
if ( mPoly.PointInside( Point ) ) {
|
||||
if ( mPoly.pointInside( Point ) ) {
|
||||
WriteCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 1 );
|
||||
|
||||
for ( Uint32 i = tParent->mVisibleFirst; i <= tParent->mVisibleLast; i++ ) {
|
||||
|
||||
Reference in New Issue
Block a user