Inlined math functions.

Removed using namespace EE::Math inside eepp ( i'm not sure why yet... :) )
This commit is contained in:
spartanj@gmail.com
2012-11-30 01:37:15 -03:00
parent 6638ff2be9
commit 8e1988a392
22 changed files with 213 additions and 272 deletions

View File

@@ -3,18 +3,17 @@
#include <eepp/base.hpp>
#include <eepp//utils/utils.hpp>
#include <eepp//utils/vector2.hpp>
#include <eepp//utils/colors.hpp>
#include <eepp//utils/rect.hpp>
#include <eepp/utils/utils.hpp>
#include <eepp/utils/vector2.hpp>
#include <eepp/utils/colors.hpp>
#include <eepp/utils/rect.hpp>
using namespace EE::Utils;
#include <eepp//math/math.hpp>
using namespace EE::Math;
#include <eepp/math/math.hpp>
#include <eepp//system/ciostream.hpp>
#include <eepp//system/ciostreamfile.hpp>
#include <eepp//system/ciostreammemory.hpp>
#include <eepp/system/ciostream.hpp>
#include <eepp/system/ciostreamfile.hpp>
#include <eepp/system/ciostreammemory.hpp>
#include <eepp/system/filesystem.hpp>
using namespace EE::System;

View File

@@ -29,7 +29,7 @@ class EE_API cMapEditor {
cUIControl * mWinContainer;
cUIListBox * mSubTextureList;
cUIGfx * mGfxPreview;
cTextureAtlas * mCurSG;
cTextureAtlas * mCurSG;
cUIScrollBar * mMapHScroll;
cUIScrollBar * mMapVScroll;
cUIDropDownList * mGOTypeList;

View File

@@ -245,7 +245,6 @@
using namespace EE::Utils;
#include <eepp/math/math.hpp>
using namespace EE::Math;
#include <eepp/system/ctimeelapsed.hpp>
#include <eepp/system/tsingleton.hpp>

View File

@@ -9,34 +9,47 @@ namespace EE { namespace Math {
/** Set a Random Seed to the Randomizer */
Uint32 EE_API SetRandomSeed();
/** Generate a eeFloating point random number
/** Generate a floating point random number
* @param fMin The minimun value
* @param fMax the maximun value
* @return The random number generated
*/
eeFloat EE_API eeRandf( const eeFloat& fMin = 0.0f, const eeFloat& fMax = 1.0f );
inline eeFloat Randf( const eeFloat& fMin = 0.0f, const eeFloat& fMax = 1.0f ) {
return (fMin + (fMax - fMin) * ( rand() / ( (eeFloat) RAND_MAX + 1) ) );
}
/** Generate a integer random number
* @param fMin The minimun value
* @param fMax the maximun value
* @return The random number generated
*/
eeInt EE_API eeRandi( const eeInt& fMin = 0, const eeInt& fMax = 1 );
inline eeInt Randi( const eeInt& fMin = 0, const eeInt& fMax = 1 ) {
return (eeInt)(fMin + (fMax - fMin + 1) * ( rand() / ( (eeFloat) RAND_MAX + 1) ) );
}
/** Cosine from an Angle in Degress */
eeFloat EE_API cosAng( const eeFloat& Ang );
inline eeFloat cosAng( const eeFloat& Ang ) {
return eecos(Ang * EE_PI_180);
}
/** Sinus from an Angle in Degress */
eeFloat EE_API sinAng( const eeFloat& Ang );
inline eeFloat sinAng( const eeFloat& Ang ) {
return eesin(Ang * EE_PI_180);
}
/** Tangen from an Angle in Degress */
eeFloat EE_API tanAng( const eeFloat& Ang );
inline eeFloat tanAng( const eeFloat& Ang ) {
return tan(Ang * EE_PI_180);
}
/** Convert an Angle from Degrees to Radians */
eeFloat EE_API Radians( const eeFloat& Ang );
inline eeFloat Radians( const eeFloat& Ang ) {
return Ang * EE_PI_180;
}
/** Convert an Angle from Radians to Degrees */
eeFloat EE_API Degrees( const eeFloat& Radians );
/** Convert an Angle from Math::Radians to Degrees */
inline eeFloat Degrees( const eeFloat& Radians ) {
return Radians * EE_180_PI;
}
template <typename T>
T NextPowOfTwo( T Size ) {
@@ -59,46 +72,114 @@ T LineAngle( const T& X1, const T& Y1, const T& X2, const T& Y2 ) {
}
#ifndef EE_64BIT
eeDouble EE_API eeRound( eeDouble r );
inline eeDouble Round( eeDouble r ) {
return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
#endif
eeFloat EE_API eeRound( eeFloat r );
inline eeFloat Round( eeFloat r ) {
return (r > 0.0f) ? floor(r + 0.5f) : ceil(r - 0.5f);
}
#ifndef EE_64BIT
eeDouble EE_API eeRoundUp( eeDouble r );
inline eeDouble RoundUp( eeDouble r ) {
return (r > 0.0) ? ceil(r) : ceil(r - 0.5);
}
#endif
eeFloat EE_API eeRoundUp( eeFloat r );
inline eeFloat RoundUp( eeFloat r ) {
return (r > 0.0f) ? ceil(r) : ceil(r - 0.5f);
}
eeFloat EE_API LineAngle( const eeVector2f& p1, const eeVector2f& p2 );
inline eeFloat RotatePointFromX ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle ) {
return x * cosAng(Angle) - y * sinAng(Angle);
}
eeFloat EE_API RotatePointFromX ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle );
inline eeFloat RotatePointFromY ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle ) {
return y * cosAng(Angle) + x * sinAng(Angle);
}
eeFloat EE_API RotatePointFromY ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle );
inline eeFloat RotatePointFromX ( const eeVector2f& p, const eeFloat& Angle ) {
return RotatePointFromX( p.x, p.y, Angle );
}
eeFloat EE_API RotatePointFromX ( const eeVector2f& p, const eeFloat& Angle );
inline eeFloat RotatePointFromY ( const eeVector2f& p, const eeFloat& Angle ) {
return RotatePointFromY( p.x, p.y, Angle );
}
eeFloat EE_API RotatePointFromY ( const eeVector2f& p, const eeFloat& Angle );
inline eeVector2f RotateVector( const eeVector2f& p, const eeFloat& Angle ) {
return eeVector2f( RotatePointFromX( p, Angle ), RotatePointFromY( p, Angle ) );
}
eeVector2f EE_API RotateVector( const eeVector2f& p, const eeFloat& Angle );
inline void RotateVector( eeVector2f* p, const eeFloat& Angle ) {
eeFloat x = p->x;
x = p->x * cosAng(Angle) - p->y * sinAng(Angle);
p->y = p->y * cosAng(Angle) + p->x * sinAng(Angle);
p->x = x;
}
eeVector2f EE_API RotateVectorCentered( const eeVector2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter );
inline void RotateVectorCentered( eeVector2f* p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
*p -= RotationCenter;
RotateVector( p, Angle );
*p += RotationCenter;
}
eeVector2f EE_API GetQuadCenter( const eeQuad2f& Q );
inline eeVector2f RotateVectorCentered( const eeVector2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
return RotationCenter + RotateVector( (p - RotationCenter), Angle );
}
eeQuad2f EE_API RotateQuadCentered( const eeQuad2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter );
eeQuad2f EE_API ScaleQuadCentered( const eeQuad2f& Quad, const eeFloat& Scale, const eeVector2f& RotationCenter );
void EE_API RotateVector( eeVector2f* p, const eeFloat& Angle );
void EE_API RotateVectorCentered( eeVector2f* p, const eeFloat& Angle, const eeVector2f& RotationCenter );
inline eeQuad2f RotateQuadCentered( const eeQuad2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
return eeQuad2f( RotateVectorCentered( p.V[0], Angle, RotationCenter ), RotateVectorCentered( p.V[1], Angle, RotationCenter ), RotateVectorCentered( p.V[2], Angle, RotationCenter ), RotateVectorCentered( p.V[3], Angle, RotationCenter ) );
}
template <typename T>
T Distance( T x1, T y1, T x2, T y2 ) {
return eesqrt( (eeFloat)( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) ) );
}
eeFloat EE_API Distance( const eeVector2f& p1, const eeVector2f& p2);
inline eeVector2f GetQuadCenter( const eeQuad2f& Q ) {
eeVector2f QCenter;
eeFloat MinX = Q.V[0].x, MaxX = Q.V[0].x, MinY = Q.V[0].y, MaxY = Q.V[0].y;
for (Uint8 i = 1; i < 4; i++ ) {
if ( MinX > Q.V[i].x ) MinX = Q.V[i].x;
if ( MaxX < Q.V[i].x ) MaxX = Q.V[i].x;
if ( MinY > Q.V[i].y ) MinY = Q.V[i].y;
if ( MaxY < Q.V[i].y ) MaxY = Q.V[i].y;
}
QCenter.x = MinX + ( MaxX - MinX ) * 0.5f;
QCenter.y = MinY + ( MaxY - MinY ) * 0.5f;
return QCenter;
}
inline eeQuad2f ScaleQuadCentered( const eeQuad2f& Quad, const eeFloat& Scale, const eeVector2f& RotationCenter ) {
eeQuad2f mQ = Quad;
eeVector2f QCenter = RotationCenter;
for (Uint8 i = 0; i < 4; i++ ) {
if ( mQ.V[i].x < QCenter.x )
mQ.V[i].x = QCenter.x - eeabs(QCenter.x - mQ.V[i].x) * Scale;
else
mQ.V[i].x = QCenter.x + eeabs(QCenter.x - mQ.V[i].x) * Scale;
if ( mQ.V[i].y < QCenter.y )
mQ.V[i].y = QCenter.y - eeabs(QCenter.y - mQ.V[i].y) * Scale;
else
mQ.V[i].y = QCenter.y + eeabs(QCenter.y - mQ.V[i].y) * Scale;
}
return mQ;
}
inline eeFloat LineAngle( const eeVector2f& p1, const eeVector2f& p2 ) {
return LineAngle( p1.x, p1.y, p2.x, p2.y );
}
inline eeFloat Distance( const eeVector2f& p1, const eeVector2f& p2 ) {
return Distance( p1.x, p1.y, p2.x, p2.y );
}
template <typename T>
bool Intersect( const tRECT<T>& a, const tRECT<T>& b ) {
@@ -202,9 +283,13 @@ bool IntersectLines( T Ax, T Ay, T Bx, T By, T Cx, T Cy, T Dx, T Dy, T* X, T* Y
return true;
}
bool EE_API IntersectLines( const eeFloat& Ax, const eeFloat& Ay, const eeFloat& Bx, const eeFloat& By, const eeFloat& Cx, const eeFloat& Cy, const eeFloat& Dx, const eeFloat& Dy, eeFloat *X = NULL, eeFloat *Y = NULL);
inline bool IntersectLines( const eeFloat& Ax, const eeFloat& Ay, const eeFloat& Bx, const eeFloat& By, const eeFloat& Cx, const eeFloat& Cy, const eeFloat& Dx, const eeFloat& Dy, eeFloat * X = NULL, eeFloat * Y = NULL ) {
return IntersectLines<eeFloat> (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, X, Y);
}
bool EE_API IntersectLines( const eeVector2f& l1p1, const eeVector2f& l1p2, const eeVector2f& l2p1, const eeVector2f& l2p2, eeFloat *X = NULL, eeFloat *Y = NULL);
inline bool IntersectLines( const eeVector2f& l1p1, const eeVector2f& l1p2, const eeVector2f& l2p1, const eeVector2f& l2p2, eeFloat * X = NULL, eeFloat * Y = NULL ) {
return IntersectLines<eeFloat> (l1p1.x, l1p1.y, l1p2.x, l1p2.y, l2p1.x, l2p1.y, l2p2.x, l2p2.y, X, Y);
}
/** @return The Dot Product of two Vectors */
template <typename T>

View File

@@ -13,7 +13,6 @@
using namespace EE::Utils;
#include <eepp/math/math.hpp>
using namespace EE::Math;
#include <eepp/system/tsingleton.hpp>
#include <eepp/system/sys.hpp>

View File

@@ -62,7 +62,7 @@ cUIControl * tUIItemContainer<TContainer>::OverFind( const eeVector2f& Point ) {
if ( mEnabled && mVisible && tParent->mItems.size() ) {
UpdateQuad();
if ( PointInsidePolygon2( mPoly, Point ) ) {
if ( Math::PointInsidePolygon2( mPoly, Point ) ) {
WriteCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 1 );
for ( Uint32 i = tParent->mVisibleFirst; i <= tParent->mVisibleLast; i++ ) {

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.6.0, 2012-11-29T18:20:15. -->
<!-- Written by Qt Creator 2.6.0, 2012-11-30T01:36:05. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@@ -56,7 +56,7 @@ void cIsoMap::CreateBaseVertexBuffer() {
T->Layers.resize( mMapLayers );
T->Q = TileQBaseCoords( x, y );
T->Box = Quad2toAABB( T->Q );
T->Box = Math::Quad2toAABB( T->Q );
T->TilePosStr = String::toStr( x) + " - " + String::toStr( y );
for ( i = 0; i < 4; i++ )
@@ -128,10 +128,10 @@ void cIsoMap::Draw() {
if ( L == 0 ) {
TileAABB = T->Box;
if ( Intersect( mScreenAABB, TileAABB ) ) {
if ( Math::Intersect( mScreenAABB, TileAABB ) ) {
T->Color[0] = T->Color[1] = T->Color[2] = T->Color[3] = mMapAmbientColor;
if ( Intersect( mLight.GetAABB(), TileAABB ) ) {
if ( Math::Intersect( mLight.GetAABB(), TileAABB ) ) {
T->Color[0] = mLight.ProcessVertex( T->Q.V[0].x, T->Q.V[0].y, T->Color[0], T->Color[0] ); // Left - Top Vertex
T->Color[1] = mLight.ProcessVertex( T->Q.V[1].x, T->Q.V[1].y, T->Color[1], T->Color[1] ); // Left - Bottom Vertex
T->Color[2] = mLight.ProcessVertex( T->Q.V[2].x, T->Q.V[2].y, T->Color[2], T->Color[2] ); // Right - Bottom Vertex
@@ -141,7 +141,7 @@ void cIsoMap::Draw() {
T->Layers[L]->Draw( T->Q, 0.f, 0.f, 0.f, 1.f, T->Color[0], T->Color[1], T->Color[2], T->Color[3] );
if ( TileAABB.Contains( mMouseMapPos ) ) {
if ( IntersectQuad2( T->Q, eeQuad2f( mMouseMapPos, mMouseMapPos, mMouseMapPos, mMouseMapPos ) ) ) {
if ( Math::IntersectQuad2( T->Q, eeQuad2f( mMouseMapPos, mMouseMapPos, mMouseMapPos, mMouseMapPos ) ) ) {
mMouseTilePos.x = x;
mMouseTilePos.y = y;
}
@@ -158,11 +158,11 @@ void cIsoMap::Draw() {
eeAABB LayerAABB( TileCenter.x - SubTexture->DestWidth() * 0.5f, TileCenter.y - SubTexture->DestHeight(), TileCenter.x + SubTexture->DestWidth() * 0.5f, TileCenter.y );
eeAABB ShadowAABB( ObjPos.x, TileCenter.y - SubTexture->DestHeight(), TileCenter.x + SubTexture->DestWidth(), TileCenter.y );
if ( Intersect( mScreenAABB, ShadowAABB ) ) {
if ( Math::Intersect( mScreenAABB, ShadowAABB ) ) {
SubTexture->Draw( mOffsetX + ObjPos.x, mOffsetY + ObjPos.y, 0, 1, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC );
}
if ( Intersect( mScreenAABB, LayerAABB ) ) {
if ( Math::Intersect( mScreenAABB, LayerAABB ) ) {
SubTexture->Draw( mOffsetX + TileCenter.x - (eeFloat)SubTexture->DestWidth() * 0.5f, mOffsetY + TileCenter.y - (eeFloat)SubTexture->DestHeight(), 0, 1, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) );
}
}
@@ -270,7 +270,7 @@ void cIsoMap::VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY,
if ( ( JointUp && T->Q.V[JointNum].y >= NewJointHeight ) || ( !JointUp && T->Q.V[JointNum].y <= NewJointHeight ) ) {
T->Q.V[JointNum].y += Height;
T->Box = Quad2toAABB( T->Q );
T->Box = Math::Quad2toAABB( T->Q );
}
}
}

View File

@@ -32,7 +32,7 @@ eeColor cLight::ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, con
if ( mActive ) {
if ( mType == LIGHT_NORMAL )
VertexDist = eeabs( Distance( mPos.x, mPos.y, PointX, PointY ) );
VertexDist = eeabs( Math::Distance( mPos.x, mPos.y, PointX, PointY ) );
else {
eeFloat XDist = eeabs(mPos.x - PointX) * 0.5f;
eeFloat YDist = eeabs(mPos.y - PointY);
@@ -72,7 +72,7 @@ eeColorA cLight::ProcessVertex( const eeFloat& PointX, const eeFloat& PointY, co
if ( mActive ) {
if ( mType == LIGHT_NORMAL )
VertexDist = eeabs( Distance( mPos.x, mPos.y, PointX, PointY ) );
VertexDist = eeabs( Math::Distance( mPos.x, mPos.y, PointX, PointY ) );
else {
eeFloat XDist = eeabs(mPos.x - PointX) * 0.5f;
eeFloat YDist = eeabs(mPos.y - PointY);

View File

@@ -49,7 +49,7 @@ void cLightManager::UpdateByVertex() {
for ( LightsList::iterator it = mLights.begin(); it != mLights.end(); it++ ) {
cLight * Light = (*it);
if ( firstLight || Intersect( VisibleArea, Light->GetAABB() ) ) {
if ( firstLight || Math::Intersect( VisibleArea, Light->GetAABB() ) ) {
for ( Int32 x = start.x; x < end.x; x++ ) {
for ( Int32 y = start.y; y < end.y; y++ ) {
if ( firstLight ) {
@@ -63,7 +63,7 @@ void cLightManager::UpdateByVertex() {
eeAABB TileAABB( Pos.x, Pos.y, Pos.x + TileSize.x, Pos.y + TileSize.y );
if ( Intersect( TileAABB, Light->GetAABB() ) ) {
if ( Math::Intersect( TileAABB, Light->GetAABB() ) ) {
if ( y > 0 )
mTileColors[x][y][0]->Assign( *mTileColors[x][y - 1][1] );
else
@@ -102,7 +102,7 @@ void cLightManager::UpdateByTile() {
for ( LightsList::iterator it = mLights.begin(); it != mLights.end(); it++ ) {
cLight * Light = (*it);
if ( firstLight || Intersect( VisibleArea, Light->GetAABB() ) ) {
if ( firstLight || Math::Intersect( VisibleArea, Light->GetAABB() ) ) {
for ( Int32 x = start.x; x < end.x; x++ ) {
for ( Int32 y = start.y; y < end.y; y++ ) {
if ( firstLight ) {
@@ -116,7 +116,7 @@ void cLightManager::UpdateByTile() {
eeAABB TileAABB( Pos.x, Pos.y, Pos.x + TileSize.x, Pos.y + TileSize.y );
if ( Intersect( TileAABB, Light->GetAABB() ) ) {
if ( Math::Intersect( TileAABB, Light->GetAABB() ) ) {
mTileColors[x][y][0]->Assign( Light->ProcessVertex( Pos.x + HalfTileSize.Width(), Pos.y + HalfTileSize.Height(), *(mTileColors[x][y][0]), *(mTileColors[x][y][0]) ) );
}
}
@@ -136,7 +136,7 @@ eeColorA cLightManager::GetColorFromPos( const eeVector2f& Pos ) {
for ( LightsList::iterator it = mLights.begin(); it != mLights.end(); it++ ) {
cLight * Light = (*it);
if ( Contains( Light->GetAABB(), Pos ) ) {
if ( Math::Contains( Light->GetAABB(), Pos ) ) {
Col = Light->ProcessVertex( Pos, Col, Col );
}
}
@@ -159,7 +159,7 @@ void cLightManager::RemoveLight( const eeVector2f& OverPos ) {
for ( LightsList::reverse_iterator it = mLights.rbegin(); it != mLights.rend(); it++ ) {
cLight * Light = (*it);
if ( Contains( Light->GetAABB(), OverPos ) ) {
if ( Math::Contains( Light->GetAABB(), OverPos ) ) {
mLights.remove( Light );
eeSAFE_DELETE( Light );
break;
@@ -243,7 +243,7 @@ cLight * cLightManager::GetLightOver( const eeVector2f& OverPos, cLight * LightC
for ( LightsList::reverse_iterator it = mLights.rbegin(); it != mLights.rend(); it++ ) {
cLight * Light = (*it);
if ( Contains( Light->GetAABB(), OverPos ) ) {
if ( Math::Contains( Light->GetAABB(), OverPos ) ) {
if ( NULL == FirstLight ) {
FirstLight = Light;
}
@@ -268,7 +268,7 @@ cLight * cLightManager::GetLightOver( const eeVector2f& OverPos, cLight * LightC
return FirstLight;
}
if ( NULL == PivotLight && NULL != LightCurrent && Contains( LightCurrent->GetAABB(), OverPos ) ) {
if ( NULL == PivotLight && NULL != LightCurrent && Math::Contains( LightCurrent->GetAABB(), OverPos ) ) {
return LightCurrent;
}

View File

@@ -330,8 +330,8 @@ void cMap::CalcTilesClip() {
if ( mStartTile.y < 0 )
mStartTile.y = 0;
mEndTile.x = mStartTile.x + eeRoundUp( (eeFloat)mViewSize.x / ( (eeFloat)mTileSize.x * mScale ) ) + 1 + mExtraTiles.x;
mEndTile.y = mStartTile.y + eeRoundUp( (eeFloat)mViewSize.y / ( (eeFloat)mTileSize.y * mScale ) ) + 1 + mExtraTiles.y;
mEndTile.x = mStartTile.x + Math::RoundUp( (eeFloat)mViewSize.x / ( (eeFloat)mTileSize.x * mScale ) ) + 1 + mExtraTiles.x;
mEndTile.y = mStartTile.y + Math::RoundUp( (eeFloat)mViewSize.y / ( (eeFloat)mTileSize.y * mScale ) ) + 1 + mExtraTiles.y;
if ( mEndTile.x > mSize.x )
mEndTile.x = mSize.x;

View File

@@ -94,7 +94,7 @@ cGameObject * cObjectLayer::GetObjectOver( const eeVector2i& pos ) {
tPos = tObj->Pos();
tSize = tObj->Size();
if ( Contains( eeRecti( tPos.x, tPos.y, tPos.x + tSize.x, tPos.y + tSize.y ), pos ) )
if ( Math::Contains( eeRecti( tPos.x, tPos.y, tPos.x + tSize.x, tPos.y + tSize.y ), pos ) )
return tObj;
}

View File

@@ -68,7 +68,7 @@ void cUIMap::Update() {
mSelLight = NULL;
} else if ( NULL != mSelLight ) {
if ( Contains( mSelLight->GetAABB(), mMap->GetMouseMapPosf() ) ) {
if ( Math::Contains( mSelLight->GetAABB(), mMap->GetMouseMapPosf() ) ) {
mMap->GetLightManager()->RemoveLight( mSelLight );
eeSAFE_DELETE( mSelLight );

View File

@@ -476,7 +476,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
}
if ( Angle != 0 )
mQ = RotateQuadCentered( mQ, Angle, QCenter );
mQ = Math::RotateQuadCentered( mQ, Angle, QCenter );
SetBlendMode( DM_QUADS, mForceBlendMode );
@@ -581,8 +581,8 @@ void cBatchRenderer::Rotate( const eeVector2f& center, eeVector2f* point, const
if ( angle ) {
eeFloat x = point->x - center.x;
eeFloat y = point->y - center.y;
point->x = x * cosAng(angle) - y * sinAng(angle) + center.x;
point->y = x * sinAng(angle) + y * cosAng(angle) + center.y;
point->x = x * Math::cosAng(angle) - y * Math::sinAng(angle) + center.x;
point->y = x * Math::sinAng(angle) + y * Math::cosAng(angle) + center.y;
}
}

View File

@@ -102,60 +102,60 @@ void cParticleSystem::Reset( cParticle * P ) {
}
case PSE_BlueBall:
{
P->Reset( mPos.x, mPos.y, -10, ( -1 * eeRandf() ), 0.01f, eeRandf(), mSize );
P->Color( eeColorAf( 0.25f ,0.25f ,1 ,1 ), 0.1f + ( 0.1f * eeRandf() ) );
P->Reset( mPos.x, mPos.y, -10, ( -1 * Math::Randf() ), 0.01f, Math::Randf(), mSize );
P->Color( eeColorAf( 0.25f ,0.25f ,1 ,1 ), 0.1f + ( 0.1f * Math::Randf() ) );
break;
}
case PSE_Fire:
{
x = ( mPos2.x - mPos.x + 1 ) * eeRandf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * eeRandf() + mPos.y;
x = ( mPos2.x - mPos.x + 1 ) * Math::Randf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * Math::Randf() + mPos.y;
P->Reset( mPos.x, mPos.y, eeRandf() - 0.5f, ( eeRandf() - 1.1f ) * 8.5f, 0.f, 0.05f, mSize );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, ( eeRandf() * 0.5f ) ), eeRandf() * 0.4f + 0.01f );
P->Reset( mPos.x, mPos.y, Math::Randf() - 0.5f, ( Math::Randf() - 1.1f ) * 8.5f, 0.f, 0.05f, mSize );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, ( Math::Randf() * 0.5f ) ), Math::Randf() * 0.4f + 0.01f );
break;
}
case PSE_Smoke:
{
x = ( mPos2.x - mPos.x + 1 ) * eeRandf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * eeRandf() + mPos.y;
x = ( mPos2.x - mPos.x + 1 ) * Math::Randf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * Math::Randf() + mPos.y;
P->Reset( x, y, -( eeRandf() / 3.f + 0.1f ), ( ( eeRandf() * 0.5f ) - 0.7f ) * 3, ( eeRandf() / 200.f ), ( eeRandf() - 0.5f ) / 200.f );
P->Color( eeColorAf( 0.8f, 0.8f, 0.8f, 0.3f ), ( eeRandf() * 0.005f ) + 0.005f );
P->Reset( x, y, -( Math::Randf() / 3.f + 0.1f ), ( ( Math::Randf() * 0.5f ) - 0.7f ) * 3, ( Math::Randf() / 200.f ), ( Math::Randf() - 0.5f ) / 200.f );
P->Color( eeColorAf( 0.8f, 0.8f, 0.8f, 0.3f ), ( Math::Randf() * 0.005f ) + 0.005f );
break;
}
case PSE_Snow:
{
x = ( mPos2.x - mPos.x + 1 ) * eeRandf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * eeRandf() + mPos.y;
w = ( eeRandf() + 0.3f ) * 4;
x = ( mPos2.x - mPos.x + 1 ) * Math::Randf() + mPos.x;
y = ( mPos2.y - mPos.y + 1 ) * Math::Randf() + mPos.y;
w = ( Math::Randf() + 0.3f ) * 4;
P->Reset( x, y, eeRandf() - 0.5f, w, 0.f, 0.f, w * 3 );
P->Reset( x, y, Math::Randf() - 0.5f, w, 0.f, 0.f, w * 3 );
P->Color( eeColorAf( 1.f, 1.f, 1.f, 0.5f ), 0 );
break;
}
case PSE_MagicFire:
{
P->Reset( mPos.x + eeRandf() , mPos.y, -0.4f + eeRandf() * 0.8f, -0.5f - eeRandf() * 0.4f, 0.f, -( eeRandf() * 0.3f ) );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, 0.7f + 0.2f * eeRandf() ), 0.01f + eeRandf() * 0.05f );
P->Reset( mPos.x + Math::Randf() , mPos.y, -0.4f + Math::Randf() * 0.8f, -0.5f - Math::Randf() * 0.4f, 0.f, -( Math::Randf() * 0.3f ) );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, 0.7f + 0.2f * Math::Randf() ), 0.01f + Math::Randf() * 0.05f );
break;
}
case PSE_LevelUp:
{
P->Reset( mPos.x, mPos.y, eeRandf() * 1.5f - 0.75f, eeRandf() * 1.5f - 0.75f, eeRandf() * 4 - 2, eeRandf() * -4 + 2 );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, 1.f ), 0.07f + eeRandf() * 0.01f );
P->Reset( mPos.x, mPos.y, Math::Randf() * 1.5f - 0.75f, Math::Randf() * 1.5f - 0.75f, Math::Randf() * 4 - 2, Math::Randf() * -4 + 2 );
P->Color( eeColorAf( 1.f, 0.5f, 0.1f, 1.f ), 0.07f + Math::Randf() * 0.01f );
break;
}
case PSE_LevelUp2:
{
P->Reset( mPos.x + eeRandf() * 32 - 16, mPos.y + eeRandf() * 64 - 32, eeRandf() - 0.5f, eeRandf() - 0.5f, eeRandf() - 0.5f, eeRandf() * -0.9f + 0.45f );
P->Color( eeColorAf( 0.1f + eeRandf() * 0.1f, 0.1f + eeRandf() * 0.1f, 0.8f + eeRandf() * 0.3f, 1 ), 0.07f + eeRandf() * 0.01f );
P->Reset( mPos.x + Math::Randf() * 32 - 16, mPos.y + Math::Randf() * 64 - 32, Math::Randf() - 0.5f, Math::Randf() - 0.5f, Math::Randf() - 0.5f, Math::Randf() * -0.9f + 0.45f );
P->Color( eeColorAf( 0.1f + Math::Randf() * 0.1f, 0.1f + Math::Randf() * 0.1f, 0.8f + Math::Randf() * 0.3f, 1 ), 0.07f + Math::Randf() * 0.01f );
break;
}
case PSE_Heal:
{
P->Reset( mPos.x, mPos.y, eeRandf() * 1.4f - 0.7f, eeRandf() * -0.4f - 1.5f, eeRandf() - 0.5f, eeRandf() * -0.2f + 0.1f );
P->Color( eeColorAf( 0.2f, 0.3f, 0.9f, 0.4f ), 0.01f + eeRandf() * 0.01f );
P->Reset( mPos.x, mPos.y, Math::Randf() * 1.4f - 0.7f, Math::Randf() * -0.4f - 1.5f, Math::Randf() - 0.5f, Math::Randf() * -0.2f + 0.1f );
P->Color( eeColorAf( 0.2f, 0.3f, 0.9f, 0.4f ), 0.01f + Math::Randf() * 0.01f );
break;
}
case PSE_WormHole:
@@ -164,20 +164,20 @@ void cParticleSystem::Reset( cParticle * P ) {
eeFloat VarB[4];
for ( lo = 0; lo <= 3; lo++ ) {
VarB[lo] = eeRandf() * 5;
la = (int)( eeRandf() * 8 );
VarB[lo] = Math::Randf() * 5;
la = (int)( Math::Randf() * 8 );
if ( ( la * 0.5f ) != (int)( la * 0.5f ) )
VarB[lo] = -VarB[lo];
}
mProgression = (int) eeRandf() * 10;
mProgression = (int) Math::Randf() * 10;
radio = ( P->Id() * 0.125f ) * mProgression;
x = mPos.x + ( radio * eecos( (eeFloat)P->Id() ) );
y = mPos.y + ( radio * eesin( (eeFloat)P->Id() ) );
P->Reset( x, y, VarB[0], VarB[1], VarB[2], VarB[3] );
P->Color( eeColorAf( 1.f, 0.6f, 0.3f, 1.f ), 0.02f + eeRandf() * 0.3f );
P->Color( eeColorAf( 1.f, 0.6f, 0.3f, 1.f ), 0.02f + Math::Randf() * 0.3f );
break;
}
case PSE_Twirl:
@@ -197,7 +197,7 @@ void cParticleSystem::Reset( cParticle * P ) {
y = mPos.y - z * eecos( q );
P->Reset( x, y, 1, 1, 0, 0 );
P->Color( eeColorAf( 1.f, 0.25f, 0.25f, 1 ), 0.6f + eeRandf() * 0.3f );
P->Color( eeColorAf( 1.f, 0.25f, 0.25f, 1 ), 0.6f + Math::Randf() * 0.3f );
break;
}
case PSE_Flower:
@@ -207,17 +207,17 @@ void cParticleSystem::Reset( cParticle * P ) {
y = mPos.y + radio * eesin( (eeFloat)P->Id() * 0.1f );
P->Reset( x, y, 1, 1, 0, 0 );
P->Color( eeColorAf( 1.f, 0.25f, 0.1f, 0.1f ), 0.3f + ( 0.2f * eeRandf()) + eeRandf() * 0.3f );
P->Color( eeColorAf( 1.f, 0.25f, 0.1f, 0.1f ), 0.3f + ( 0.2f * Math::Randf()) + Math::Randf() * 0.3f );
break;
}
case PSE_Galaxy:
{
radio = ( eeRandf( 1.f, 1.2f ) + eesin( 20.f / (eeFloat)P->Id() ) ) * 60;
radio = ( Math::Randf( 1.f, 1.2f ) + eesin( 20.f / (eeFloat)P->Id() ) ) * 60;
x = mPos.x + radio * eecos( (eeFloat)P->Id() );
y = mPos.y + radio * eesin( (eeFloat)P->Id() );
P->Reset( x, y, 0, 0, 0, 0 );
P->Color( eeColorAf( 0.2f, 0.2f, 0.6f + 0.4f * eeRandf(), 1.f ), eeRandf( 0.05f, 0.15f ) );
P->Color( eeColorAf( 0.2f, 0.2f, 0.6f + 0.4f * Math::Randf(), 1.f ), Math::Randf( 0.05f, 0.15f ) );
break;
}
case PSE_Heart:
@@ -226,8 +226,8 @@ void cParticleSystem::Reset( cParticle * P ) {
x = mPos.x - 50 * eesin( q * 2 ) * eesqrt( eeabs( eecos( q ) ) );
y = mPos.y - 50 * eecos( q * 2 ) * eesqrt( eeabs( eesin( q ) ) );
P->Reset( x, y, 0.f, 0.f, 0.f, -( eeRandf() * 0.2f ) );
P->Color( eeColorAf( 1.f, 0.5f, 0.2f, 0.6f + 0.2f * eeRandf() ), 0.01f + eeRandf() * 0.08f );
P->Reset( x, y, 0.f, 0.f, 0.f, -( Math::Randf() * 0.2f ) );
P->Color( eeColorAf( 1.f, 0.5f, 0.2f, 0.6f + 0.2f * Math::Randf() ), 0.01f + Math::Randf() * 0.08f );
break;
}
case PSE_BlueExplosion:
@@ -245,12 +245,12 @@ void cParticleSystem::Reset( cParticle * P ) {
}
case PSE_GP:
{
radio = 50 + eeRandf() * 15 * eecos( (eeFloat)P->Id() * 3.5f );
radio = 50 + Math::Randf() * 15 * eecos( (eeFloat)P->Id() * 3.5f );
x = mPos.x + ( radio * eecos( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) );
y = mPos.y + ( radio * eesin( (eeFloat)P->Id() * (eeFloat)0.01428571428 ) );
P->Reset( x, y, 0, 0, 0, 0 );
P->Color( eeColorAf( 0.2f, 0.8f, 0.4f, 0.5f ), eeRandf() * 0.3f );
P->Color( eeColorAf( 0.2f, 0.8f, 0.4f, 0.5f ), Math::Randf() * 0.3f );
break;
}
case PSE_BTwirl:
@@ -269,7 +269,7 @@ void cParticleSystem::Reset( cParticle * P ) {
y = mPos.y - w * eecos( q );
P->Reset( x, y, 1, 1, 0, 0 );
P->Color( eeColorAf( 0.25f, 0.25f, 1.f, 1.f ), 0.1f + eeRandf() * 0.3f + eeRandf() * 0.3f );
P->Color( eeColorAf( 0.25f, 0.25f, 1.f, 1.f ), 0.1f + Math::Randf() * 0.3f + Math::Randf() * 0.3f );
break;
}
case PSE_BT:
@@ -287,8 +287,8 @@ void cParticleSystem::Reset( cParticle * P ) {
x = mPos.x + w * eesin( q );
y = mPos.y - w * eecos( q );
P->Reset( x, y, -10, -1 * eeRandf(), 0, eeRandf() );
P->Color( eeColorAf( 0.25f, 0.25f, 1.f, 1.f ), 0.1f + eeRandf() * 0.1f + eeRandf() * 0.3f );
P->Reset( x, y, -10, -1 * Math::Randf(), 0, Math::Randf() );
P->Color( eeColorAf( 0.25f, 0.25f, 1.f, 1.f ), 0.1f + Math::Randf() * 0.1f + Math::Randf() * 0.3f );
break;
}
case PSE_Atomic:
@@ -298,7 +298,7 @@ void cParticleSystem::Reset( cParticle * P ) {
y = mPos.y + radio * eesin( (eeFloat)P->Id() * 0.033333 );
P->Reset( x, y, 1, 1, 0, 0 );
P->Color( eeColorAf( 0.4f, 0.25f, 1.f, 1.f ), 0.3f + eeRandf() * 0.2f + eeRandf() * 0.3f );
P->Color( eeColorAf( 0.4f, 0.25f, 1.f, 1.f ), 0.3f + Math::Randf() * 0.2f + Math::Randf() * 0.3f );
break;
}
case PSE_Callback:

View File

@@ -22,7 +22,7 @@ void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const
eeVector2f poly;
eeVector2f Center( x + width * 0.5f + xscalediff, y + height * 0.5f + yscalediff );
eePolygon2f Poly = CreateRoundedPolygon( x - xscalediff, y - yscalediff, width + xscalediff, height + yscalediff, Corners );
eePolygon2f Poly = Math::CreateRoundedPolygon( x - xscalediff, y - yscalediff, width + xscalediff, height + yscalediff, Corners );
Poly.Rotate( Angle, Center );
switch(fillmode) {
@@ -170,7 +170,7 @@ void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat&
mBR->LineLoopSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift ) )
mBR->BatchLineLoop( x + radius * sinAng(i), y + radius * cosAng(i), x + radius * sinAng( i + angle_shift ), y + radius * cosAng( i + angle_shift ) );
mBR->BatchLineLoop( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ) );
break;
case EE_DRAW_FILL:
@@ -178,7 +178,7 @@ void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat&
mBR->TriangleFanSetColor( mColor );
for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift + angle_shift ) )
mBR->BatchTriangleFan( x + radius * sinAng(i), y + radius * cosAng(i), x + radius * sinAng( i + angle_shift ), y + radius * cosAng( i + angle_shift ), x + radius * sinAng( i + angle_shift + angle_shift ), y + radius * cosAng( i + angle_shift + angle_shift ) );
mBR->BatchTriangleFan( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ), x + radius * Math::sinAng( i + angle_shift + angle_shift ), y + radius * Math::cosAng( i + angle_shift + angle_shift ) );
break;
}

View File

@@ -292,7 +292,7 @@ eeUint cTextureFactory::GetValidTextureSize( const eeUint& Size ) {
if ( GLi->IsExtension( EEGL_ARB_texture_non_power_of_two ) )
return Size;
else
return NextPowOfTwo(Size);
return Math::NextPowOfTwo(Size);
}
bool cTextureFactory::SaveImage( const std::string& filepath, const EE_SAVE_TYPE& Format, const eeUint& Width, const eeUint& Height, const eeUint& Channels, const unsigned char* data ) {

View File

@@ -76,11 +76,11 @@ void cTexturePacker::SetOptions( const Uint32& MaxWidth, const Uint32& MaxHeight
mWidth = MaxWidth;
mHeight = MaxHeight;
if ( ForcePowOfTwo && !IsPow2( mWidth ) )
mWidth = NextPowOfTwo( mWidth );
if ( ForcePowOfTwo && !Math::IsPow2( mWidth ) )
mWidth = Math::NextPowOfTwo( mWidth );
if ( ForcePowOfTwo && !IsPow2( mHeight ) )
mHeight = NextPowOfTwo( mHeight );
if ( ForcePowOfTwo && !Math::IsPow2( mHeight ) )
mHeight = Math::NextPowOfTwo( mHeight );
mForcePowOfTwo = ForcePowOfTwo;
mAllowFlipping = AllowFlipping;

View File

@@ -10,145 +10,4 @@ Uint32 SetRandomSeed() {
return Seed;
}
eeFloat eeRandf( const eeFloat& fMin, const eeFloat& fMax ) {
return (fMin + (fMax - fMin) * ( rand() / ( (eeFloat) RAND_MAX + 1) ) );
}
eeInt eeRandi( const eeInt& fMin, const eeInt& fMax ) {
return (eeInt)(fMin + (fMax - fMin + 1) * ( rand() / ( (eeFloat) RAND_MAX + 1) ) );
}
#ifndef EE_64BIT
eeDouble eeRound( eeDouble r ) {
return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}
#endif
eeFloat eeRound( eeFloat r ) {
return (r > 0.0f) ? floor(r + 0.5f) : ceil(r - 0.5f);
}
#ifndef EE_64BIT
eeDouble eeRoundUp( eeDouble r ) {
return (r > 0.0) ? ceil(r) : ceil(r - 0.5);
}
#endif
eeFloat eeRoundUp( eeFloat r ) {
return (r > 0.0f) ? ceil(r) : ceil(r - 0.5f);
}
eeFloat cosAng( const eeFloat& Ang ) {
return eecos(Ang * EE_PI_180);
}
eeFloat sinAng( const eeFloat& Ang ) {
return eesin(Ang * EE_PI_180);
}
eeFloat tanAng( const eeFloat& Ang ) {
return tan(Ang * EE_PI_180);
}
eeFloat Radians( const eeFloat& Ang ) {
return Ang * EE_PI_180;
}
eeFloat Degrees( const eeFloat& Radians ) {
return Radians * EE_180_PI;
}
eeFloat RotatePointFromX ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle ) {
return x * cosAng(Angle) - y * sinAng(Angle);
}
eeFloat RotatePointFromY ( const eeFloat& x, const eeFloat& y, const eeFloat& Angle ) {
return y * cosAng(Angle) + x * sinAng(Angle);
}
eeFloat RotatePointFromX ( const eeVector2f& p, const eeFloat& Angle ) {
return RotatePointFromX( p.x, p.y, Angle );
}
eeFloat RotatePointFromY ( const eeVector2f& p, const eeFloat& Angle ) {
return RotatePointFromY( p.x, p.y, Angle );
}
eeVector2f RotateVector( const eeVector2f& p, const eeFloat& Angle ) {
return eeVector2f( RotatePointFromX( p, Angle ), RotatePointFromY( p, Angle ) );
}
void RotateVector( eeVector2f* p, const eeFloat& Angle ) {
eeFloat x = p->x;
x = p->x * cosAng(Angle) - p->y * sinAng(Angle);
p->y = p->y * cosAng(Angle) + p->x * sinAng(Angle);
p->x = x;
}
void RotateVectorCentered( eeVector2f* p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
*p -= RotationCenter;
RotateVector( p, Angle );
*p += RotationCenter;
}
eeVector2f RotateVectorCentered( const eeVector2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
return RotationCenter + RotateVector( (p - RotationCenter), Angle );
}
eeQuad2f RotateQuadCentered( const eeQuad2f& p, const eeFloat& Angle, const eeVector2f& RotationCenter ) {
return eeQuad2f( RotateVectorCentered( p.V[0], Angle, RotationCenter ), RotateVectorCentered( p.V[1], Angle, RotationCenter ), RotateVectorCentered( p.V[2], Angle, RotationCenter ), RotateVectorCentered( p.V[3], Angle, RotationCenter ) );
}
eeVector2f GetQuadCenter( const eeQuad2f& Q ) {
eeVector2f QCenter;
eeFloat MinX = Q.V[0].x, MaxX = Q.V[0].x, MinY = Q.V[0].y, MaxY = Q.V[0].y;
for (Uint8 i = 1; i < 4; i++ ) {
if ( MinX > Q.V[i].x ) MinX = Q.V[i].x;
if ( MaxX < Q.V[i].x ) MaxX = Q.V[i].x;
if ( MinY > Q.V[i].y ) MinY = Q.V[i].y;
if ( MaxY < Q.V[i].y ) MaxY = Q.V[i].y;
}
QCenter.x = MinX + ( MaxX - MinX ) * 0.5f;
QCenter.y = MinY + ( MaxY - MinY ) * 0.5f;
return QCenter;
}
eeQuad2f ScaleQuadCentered( const eeQuad2f& Quad, const eeFloat& Scale, const eeVector2f& RotationCenter ) {
eeQuad2f mQ = Quad;
eeVector2f QCenter = RotationCenter;
for (Uint8 i = 0; i < 4; i++ ) {
if ( mQ.V[i].x < QCenter.x )
mQ.V[i].x = QCenter.x - eeabs(QCenter.x - mQ.V[i].x) * Scale;
else
mQ.V[i].x = QCenter.x + eeabs(QCenter.x - mQ.V[i].x) * Scale;
if ( mQ.V[i].y < QCenter.y )
mQ.V[i].y = QCenter.y - eeabs(QCenter.y - mQ.V[i].y) * Scale;
else
mQ.V[i].y = QCenter.y + eeabs(QCenter.y - mQ.V[i].y) * Scale;
}
return mQ;
}
eeFloat LineAngle( const eeVector2f& p1, const eeVector2f& p2 ) {
return LineAngle( p1.x, p1.y, p2.x, p2.y );
}
eeFloat Distance( const eeVector2f& p1, const eeVector2f& p2) {
return Distance( p1.x, p1.y, p2.x, p2.y );
}
bool IntersectLines( const eeFloat& Ax, const eeFloat& Ay, const eeFloat& Bx, const eeFloat& By, const eeFloat& Cx, const eeFloat& Cy, const eeFloat& Dx, const eeFloat& Dy, eeFloat *X, eeFloat *Y) {
return IntersectLines<eeFloat> (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, X, Y);
}
bool IntersectLines( const eeVector2f& l1p1, const eeVector2f& l1p2, const eeVector2f& l2p1, const eeVector2f& l2p2, eeFloat *X, eeFloat *Y) {
return IntersectLines<eeFloat> (l1p1.x, l1p1.y, l1p2.x, l1p2.y, l2p1.x, l2p1.y, l2p2.x, l2p2.y, X, Y);
}
}}

View File

@@ -733,7 +733,7 @@ cUIControl * cUIControl::OverFind( const eeVector2f& Point ) {
if ( mEnabled && mVisible ) {
UpdateQuad();
if ( PointInsidePolygon2( mPoly, Point ) ) {
if ( Math::PointInsidePolygon2( mPoly, Point ) ) {
WriteCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 1 );
cUIControl * ChildLoop = mChildLast;

View File

@@ -119,7 +119,7 @@ EE_MAIN_FUNC int main (int argc, char * argv [])
/// Since fixed-pipeline OpenGL use gl_FrontColor for glColorPointer, we need to replace the color attribute
/// This is all to show how it works, in a real world scenario, you will choose to work fixed-pipeline or programmable-pipeline.
if ( GLi->Version() == GLv_2 ) {
ReplaceSubStr( fs, "gl_FragColor = dgl_Color", "gl_FragColor = gl_FrontColor" );
String::ReplaceSubStr( fs, "gl_FragColor = dgl_Color", "gl_FragColor = gl_FrontColor" );
}
/// Create the new shader program
@@ -140,8 +140,8 @@ EE_MAIN_FUNC int main (int argc, char * argv [])
for (i = 0; i < ParticlesNum; i++ )
{
vertices[i] = eeVector3ff( 0, 0, 1.83 );
velocities[i] = eeVector3ff( (eeRandf() * 2 - 1)*.05, (eeRandf() * 2 - 1)*.05, .93 + eeRandf()*.02 );
colors[i] = eeColorAf( eeRandf() * 0.5, 0.1, 0.8, 0.5 );
velocities[i] = eeVector3ff( (Randf() * 2 - 1)*.05, (Randf() * 2 - 1)*.05, .93 + Randf()*.02 );
colors[i] = eeColorAf( Randf() * 0.5, 0.1, 0.8, 0.5 );
}
while ( win->Running() )
@@ -213,8 +213,8 @@ EE_MAIN_FUNC int main (int argc, char * argv [])
if ( d < 2.f ) {
if ( d < 0.03f ) {
vertices[i+1].x = eeRandf( -1, 1 ) * aspectRatio;
vertices[i+1].y = eeRandf( -1, 1 );
vertices[i+1].x = Randf( -1, 1 ) * aspectRatio;
vertices[i+1].y = Randf( -1, 1 );
velocities[i].x = 0;
velocities[i].y = 0;
} else {

View File

@@ -762,7 +762,7 @@ void cEETest::ButtonClick( const cUIEvent * Event ) {
Gfx->Enabled( false );
Gfx->StartRotation( 0, 2500, 2500 );
Gfx->StartMovement( eeVector2i( eeRandi( 0, mWindow->GetWidth() ), -64 ), eeVector2i( eeRandi( 0, mWindow->GetWidth() ), mWindow->GetHeight() + 64 ), 2500 );
Gfx->StartMovement( eeVector2i( Math::Randi( 0, mWindow->GetWidth() ), -64 ), eeVector2i( Math::Randi( 0, mWindow->GetWidth() ), mWindow->GetHeight() + 64 ), 2500 );
Gfx->CloseFadeOut( 3500 );
mListBox->AddListBoxItem( "Test ListBox " + String::toStr( mListBox->Count() + 1 ) + " testing it right now!" );
@@ -871,9 +871,9 @@ void cEETest::LoadTextures() {
eeColorA C = Tex->GetPixel(x, y);
if ( C.R() > 200 && C.G() > 200 && C.B() > 200 )
Tex->SetPixel(x, y, eeColorA( eeRandi(0, 255), eeRandi(0, 255), eeRandi(0, 255), C.A() ) );
Tex->SetPixel(x, y, eeColorA( Math::Randi(0, 255), Math::Randi(0, 255), Math::Randi(0, 255), C.A() ) );
else
Tex->SetPixel(x, y, eeColorA( eeRandi(200, 255), eeRandi(200, 255), eeRandi(200, 255), C.A() ) );
Tex->SetPixel(x, y, eeColorA( Math::Randi(200, 255), Math::Randi(200, 255), Math::Randi(200, 255), C.A() ) );
}
}
@@ -1567,11 +1567,11 @@ void cEETest::ParticlesCallback( cParticle * P, cParticleSystem * Me ) {
eeFloat x, y, radio;
eeVector2f MePos( Me->Position() );
radio = (eeRandf(1.f, 1.2f) + sin( 20.0f / P->Id() )) * 24;
radio = (Math::Randf(1.f, 1.2f) + sin( 20.0f / P->Id() )) * 24;
x = MePos.x + radio * cos( (eeFloat)P->Id() );
y = MePos.y + radio * sin( (eeFloat)P->Id() );
P->Reset(x, y, eeRandf(-10.f, 10.f), eeRandf(-10.f, 10.f), eeRandf(-10.f, 10.f), eeRandf(-10.f, 10.f));
P->Color( eeColorAf(1.f, 0.6f, 0.3f, 1.f), 0.02f + eeRandf() * 0.3f );
P->Reset(x, y, Math::Randf(-10.f, 10.f), Math::Randf(-10.f, 10.f), Math::Randf(-10.f, 10.f), Math::Randf(-10.f, 10.f));
P->Color( eeColorAf(1.f, 0.6f, 0.3f, 1.f), 0.02f + Math::Randf() * 0.3f );
}
void cEETest::Particles() {
@@ -1581,8 +1581,8 @@ void cEETest::Particles() {
PS[1].Position( Mousef );
PS[2].Position( HWidth, HHeight );
PS[3].Position( cosAng(Ang) * 220.f + HWidth + eeRandf(0.f, 10.f), sinAng(Ang) * 220.f + HHeight + eeRandf(0.f, 10.f) );
PS[4].Position( -cosAng(Ang) * 220.f + HWidth + eeRandf(0.f, 10.f), -sinAng(Ang) * 220.f + HHeight + eeRandf(0.f, 10.f) );
PS[3].Position( cosAng(Ang) * 220.f + HWidth + Math::Randf(0.f, 10.f), sinAng(Ang) * 220.f + HHeight + Math::Randf(0.f, 10.f) );
PS[4].Position( -cosAng(Ang) * 220.f + HWidth + Math::Randf(0.f, 10.f), -sinAng(Ang) * 220.f + HHeight + Math::Randf(0.f, 10.f) );
for ( Uint32 i = 0; i < PS.size(); i++ )
PS[i].Draw();
@@ -1783,7 +1783,7 @@ void cEETest::Demo2Update() {
cBody * body = mSpace->AddBody( cBody::New( 1.0f, Moment::ForCircle(1.0f, 15.0f, 0.0f, cVectZero ) ) );
body->Pos( emitterInstance.position );
body->Vel( cVectNew( eeRandf(-1,1), eeRandf(-1,1) ) * (cpFloat)100 );
body->Vel( cVectNew( Math::Randf(-1,1), Math::Randf(-1,1) ) * (cpFloat)100 );
cShape *shape = mSpace->AddShape( cShapeCircle::New( body, 15.0f, cVectZero ) );
shape->CollisionType( BALL_TYPE );