diff --git a/src/Actor.cpp b/src/Actor.cpp index 1173ea82c8..fd48a0564f 100644 --- a/src/Actor.cpp +++ b/src/Actor.cpp @@ -470,7 +470,7 @@ void Actor::PreDraw() // calculate actor properties ssprintf("PercentThroughEffect: %f", fPercentThroughEffect) ); bool bBlinkOn = fPercentThroughEffect > 0.5f; - float fPercentBetweenColors = RageFastSin( (fPercentThroughEffect + 0.25f) * 2 * PI ) / 2 + 0.5f; + float fPercentBetweenColors = std::sin( (fPercentThroughEffect + 0.25f) * 2 * PI ) / 2 + 0.5f; ASSERT_M( fPercentBetweenColors >= 0 && fPercentBetweenColors <= 1, ssprintf("PercentBetweenColors: %f, PercentThroughEffect: %f", fPercentBetweenColors, fPercentThroughEffect) ); float fOriginalAlpha = tempState.diffuse[0].a; @@ -516,15 +516,15 @@ void Actor::PreDraw() // calculate actor properties break; case rainbow: tempState.diffuse[0] = RageColor( - RageFastCos( fPercentBetweenColors*2*PI ) * 0.5f + 0.5f, - RageFastCos( fPercentBetweenColors*2*PI + PI * 2.0f / 3.0f ) * 0.5f + 0.5f, - RageFastCos( fPercentBetweenColors*2*PI + PI * 4.0f / 3.0f) * 0.5f + 0.5f, + std::cos( fPercentBetweenColors*2*PI ) * 0.5f + 0.5f, + std::cos( fPercentBetweenColors*2*PI + PI * 2.0f / 3.0f ) * 0.5f + 0.5f, + std::cos( fPercentBetweenColors*2*PI + PI * 4.0f / 3.0f) * 0.5f + 0.5f, fOriginalAlpha ); for( int i=1; im_PlayerNumber]; - float fExpandMultiplier = SCALE( RageFastCos(data.m_fExpandSeconds*EXPAND_MULTIPLIER_FREQUENCY), + float fExpandMultiplier = SCALE( std::cos(data.m_fExpandSeconds*EXPAND_MULTIPLIER_FREQUENCY), EXPAND_MULTIPLIER_SCALE_FROM_LOW, EXPAND_MULTIPLIER_SCALE_FROM_HIGH, EXPAND_MULTIPLIER_SCALE_TO_LOW, EXPAND_MULTIPLIER_SCALE_TO_HIGH ); fScrollSpeed *= SCALE( fAccels[PlayerOptions::ACCEL_EXPAND], @@ -495,7 +495,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float float fRads = acosf( fPositionBetween ); fRads += fYOffset * TORNADO_OFFSET_FREQUENCY / SCREEN_HEIGHT; - const float fAdjustedPixelOffset = SCALE( RageFastCos(fRads), TORNADO_OFFSET_SCALE_FROM_LOW, TORNADO_OFFSET_SCALE_FROM_HIGH, + const float fAdjustedPixelOffset = SCALE( std::cos(fRads), TORNADO_OFFSET_SCALE_FROM_LOW, TORNADO_OFFSET_SCALE_FROM_HIGH, data.m_fMinTornadoX[iColNum], data.m_fMaxTornadoX[iColNum] ); fPixelOffsetFromCenter += (fAdjustedPixelOffset - fRealPixelOffset) * fEffects[PlayerOptions::EFFECT_TORNADO]; @@ -503,7 +503,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float if( fEffects[PlayerOptions::EFFECT_DRUNK] != 0 ) fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_DRUNK] * - ( RageFastCos( RageTimer::GetTimeSinceStartFast() + iColNum*DRUNK_COLUMN_FREQUENCY + ( std::cos( RageTimer::GetTimeSinceStartFast() + iColNum*DRUNK_COLUMN_FREQUENCY + fYOffset*DRUNK_OFFSET_FREQUENCY/SCREEN_HEIGHT) * ARROW_SIZE*DRUNK_ARROW_MAGNITUDE ); if( fEffects[PlayerOptions::EFFECT_FLIP] != 0 ) { @@ -520,7 +520,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float if( fEffects[PlayerOptions::EFFECT_BEAT] != 0 ) { - const float fShift = data.m_fBeatFactor*RageFastSin( fYOffset / BEAT_OFFSET_HEIGHT + PI/BEAT_PI_HEIGHT ); + const float fShift = data.m_fBeatFactor*std::sin( fYOffset / BEAT_OFFSET_HEIGHT + PI/BEAT_PI_HEIGHT ); fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BEAT] * fShift; } @@ -715,7 +715,7 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse) fVisibleAdjust -= fAppearances[PlayerOptions::APPEARANCE_STEALTH]; if( fAppearances[PlayerOptions::APPEARANCE_BLINK] != 0 ) { - float f = RageFastSin(RageTimer::GetTimeSinceStartFast()*10); + float f = std::sin(RageTimer::GetTimeSinceStartFast()*10); f = Quantize( f, BLINK_MOD_FREQUENCY ); fVisibleAdjust += SCALE( f, 0, 1, -1, 0 ); } @@ -783,7 +783,7 @@ float ArrowEffects::GetZPos(int iCol, float fYOffset) const float* fEffects = curr_options->m_fEffects; if( fEffects[PlayerOptions::EFFECT_BUMPY] != 0 ) - fZPos += fEffects[PlayerOptions::EFFECT_BUMPY] * 40*RageFastSin( fYOffset/16.0f ); + fZPos += fEffects[PlayerOptions::EFFECT_BUMPY] * 40*std::sin( fYOffset/16.0f ); return fZPos; } diff --git a/src/CubicSpline.cpp b/src/CubicSpline.cpp index 443d995f10..d4dce0ccc6 100644 --- a/src/CubicSpline.cpp +++ b/src/CubicSpline.cpp @@ -413,8 +413,8 @@ void CubicSpline::p_and_tfrac_from_t(float t, bool loop, size_t& p, float& tfrac if(loop) { float max_t= static_cast(m_points.size()); - while(t >= max_t) { t-= max_t; } - while(t < 0.0f) { t+= max_t; } + t= std::fmod(t, max_t); + if(t < 0.0f) { t+= max_t; } p= static_cast(t); tfrac= t - static_cast(p); } diff --git a/src/GraphDisplay.cpp b/src/GraphDisplay.cpp index a5b8ee4c73..11100a30cb 100644 --- a/src/GraphDisplay.cpp +++ b/src/GraphDisplay.cpp @@ -51,8 +51,8 @@ public: for( int i = 0; i < iSubdivisions+1; ++i ) { const float fRotation = float(i) / iSubdivisions * 2*PI; - const float fX = RageFastCos(fRotation) * fRadius; - const float fY = -RageFastSin(fRotation) * fRadius; + const float fX = std::cos(fRotation) * fRadius; + const float fY = -std::sin(fRotation) * fRadius; pVerts[1+i] = v; pVerts[1+i].p.x += fX; pVerts[1+i].p.y += fY; diff --git a/src/GrooveRadar.cpp b/src/GrooveRadar.cpp index 93deafef8a..28b3e18a44 100644 --- a/src/GrooveRadar.cpp +++ b/src/GrooveRadar.cpp @@ -170,8 +170,8 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives() const float fDistFromCenter = ( m_fValuesOld[c] * (1-m_PercentTowardNew) + m_fValuesNew[c] * m_PercentTowardNew + 0.07f ) * fRadius; const float fRotation = RADAR_VALUE_ROTATION(i); - const float fX = RageFastCos(fRotation) * fDistFromCenter; - const float fY = -RageFastSin(fRotation) * fDistFromCenter; + const float fX = std::cos(fRotation) * fDistFromCenter; + const float fY = -std::sin(fRotation) * fDistFromCenter; v[1+i].p = RageVector3( fX, fY, 0 ); v[1+i].c = v[1].c; @@ -186,8 +186,8 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives() const float fDistFromCenter = ( m_fValuesOld[c] * (1-m_PercentTowardNew) + m_fValuesNew[c] * m_PercentTowardNew + 0.07f ) * fRadius; const float fRotation = RADAR_VALUE_ROTATION(i); - const float fX = RageFastCos(fRotation) * fDistFromCenter; - const float fY = -RageFastSin(fRotation) * fDistFromCenter; + const float fX = std::cos(fRotation) * fDistFromCenter; + const float fY = -std::sin(fRotation) * fDistFromCenter; v[i].p = RageVector3( fX, fY, 0 ); v[i].c = this->m_pTempState->diffuse[0]; diff --git a/src/NoteField.cpp b/src/NoteField.cpp index a7836695a4..cf73dfe11c 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -830,7 +830,7 @@ void NoteField::DrawPrimitives() ASSERT(GAMESTATE->m_pCurSong != NULL); const TimingData &timing = *pTiming; - const RageColor text_glow= RageColor(1,1,1,RageFastCos(RageTimer::GetTimeSinceStartFast()*2)/2+0.5f); + const RageColor text_glow= RageColor(1,1,1,std::cos(RageTimer::GetTimeSinceStartFast()*2)/2+0.5f); float horiz_align= align_right; float side_sign= 1; @@ -1014,7 +1014,7 @@ void NoteField::DrawPrimitives() *m_FieldRenderArgs.selection_end_marker != -1) { m_FieldRenderArgs.selection_glow= SCALE( - RageFastCos(RageTimer::GetTimeSinceStartFast()*2), -1, 1, 0.1f, 0.3f); + std::cos(RageTimer::GetTimeSinceStartFast()*2), -1, 1, 0.1f, 0.3f); } m_FieldRenderArgs.fade_before_targets= FADE_BEFORE_TARGETS_PERCENT; diff --git a/src/RageDisplay.cpp b/src/RageDisplay.cpp index 292d00e35c..e593a4f82a 100644 --- a/src/RageDisplay.cpp +++ b/src/RageDisplay.cpp @@ -233,8 +233,8 @@ void RageDisplay::DrawCircleInternal( const RageSpriteVertex &p, float radius ) for(int i = 0; i < subdivisions+1; ++i) { const float fRotation = float(i) / subdivisions * 2*PI; - const float fX = RageFastCos(fRotation) * radius; - const float fY = -RageFastSin(fRotation) * radius; + const float fX = std::cos(fRotation) * radius; + const float fY = -std::sin(fRotation) * radius; v[1+i] = v[0]; v[1+i].p.x += fX; v[1+i].p.y += fY; diff --git a/src/RageMath.cpp b/src/RageMath.cpp index 4f403e34d5..a014831c2b 100644 --- a/src/RageMath.cpp +++ b/src/RageMath.cpp @@ -246,10 +246,10 @@ void RageMatrixRotationX( RageMatrix* pOut, float theta ) theta *= PI/180; RageMatrixIdentity(pOut); - pOut->m[1][1] = RageFastCos(theta); + pOut->m[1][1] = std::cos(theta); pOut->m[2][2] = pOut->m[1][1]; - pOut->m[2][1] = RageFastSin(theta); + pOut->m[2][1] = std::sin(theta); pOut->m[1][2] = -pOut->m[2][1]; } @@ -258,10 +258,10 @@ void RageMatrixRotationY( RageMatrix* pOut, float theta ) theta *= PI/180; RageMatrixIdentity(pOut); - pOut->m[0][0] = RageFastCos(theta); + pOut->m[0][0] = std::cos(theta); pOut->m[2][2] = pOut->m[0][0]; - pOut->m[0][2] = RageFastSin(theta); + pOut->m[0][2] = std::sin(theta); pOut->m[2][0] = -pOut->m[0][2]; } @@ -270,10 +270,10 @@ void RageMatrixRotationZ( RageMatrix* pOut, float theta ) theta *= PI/180; RageMatrixIdentity(pOut); - pOut->m[0][0] = RageFastCos(theta); + pOut->m[0][0] = std::cos(theta); pOut->m[1][1] = pOut->m[0][0]; - pOut->m[0][1] = RageFastSin(theta); + pOut->m[0][1] = std::sin(theta); pOut->m[1][0] = -pOut->m[0][1]; } @@ -286,12 +286,12 @@ void RageMatrixRotationXYZ( RageMatrix* pOut, float rX, float rY, float rZ ) rY *= PI/180; rZ *= PI/180; - const float cX = RageFastCos(rX); - const float sX = RageFastSin(rX); - const float cY = RageFastCos(rY); - const float sY = RageFastSin(rY); - const float cZ = RageFastCos(rZ); - const float sZ = RageFastSin(rZ); + const float cX = std::cos(rX); + const float sX = std::sin(rX); + const float cY = std::cos(rY); + const float sY = std::sin(rY); + const float cZ = std::cos(rZ); + const float sZ = std::sin(rZ); /* * X*Y: @@ -333,8 +333,8 @@ void RageMatrixRotationXYZ( RageMatrix* pOut, float rX, float rY, float rZ ) void RageAARotate(RageVector3* inret, RageVector3 const* axis, float angle) { float ha= angle/2.0f; - float ca2= RageFastCos(ha); - float sa2= RageFastSin(ha); + float ca2= std::cos(ha); + float sa2= std::sin(ha); RageVector4 quat(axis->x * sa2, axis->y * sa2, axis->z * sa2, ca2); RageVector4 quatc(-quat.x, -quat.y, -quat.z, ca2); RageVector4 point(inret->x, inret->y, inret->z, 0.0f); @@ -374,8 +374,8 @@ RageVector4 RageQuatFromH(float theta ) theta *= PI/180.0f; theta /= 2.0f; theta *= -1; - const float c = RageFastCos(theta); - const float s = RageFastSin(theta); + const float c = std::cos(theta); + const float s = std::sin(theta); return RageVector4(0, s, 0, c); } @@ -385,8 +385,8 @@ RageVector4 RageQuatFromP(float theta ) theta *= PI/180.0f; theta /= 2.0f; theta *= -1; - const float c = RageFastCos(theta); - const float s = RageFastSin(theta); + const float c = std::cos(theta); + const float s = std::sin(theta); return RageVector4(s, 0, 0, c); } @@ -396,8 +396,8 @@ RageVector4 RageQuatFromR(float theta ) theta *= PI/180.0f; theta /= 2.0f; theta *= -1; - const float c = RageFastCos(theta); - const float s = RageFastSin(theta); + const float c = std::cos(theta); + const float s = std::sin(theta); return RageVector4(0, 0, s, c); } @@ -412,12 +412,12 @@ void RageQuatFromHPR(RageVector4* pOut, RageVector3 hpr ) hpr /= 180.0f; hpr /= 2.0f; - const float sX = RageFastSin(hpr.x); - const float cX = RageFastCos(hpr.x); - const float sY = RageFastSin(hpr.y); - const float cY = RageFastCos(hpr.y); - const float sZ = RageFastSin(hpr.z); - const float cZ = RageFastCos(hpr.z); + const float sX = std::sin(hpr.x); + const float cX = std::cos(hpr.x); + const float sY = std::sin(hpr.y); + const float cY = std::cos(hpr.y); + const float sZ = std::sin(hpr.z); + const float cZ = std::cos(hpr.z); pOut->w = cX * cY * cZ + sX * sY * sZ; pOut->x = sX * cY * cZ - cX * sY * sZ; @@ -440,12 +440,12 @@ void RageQuatFromPRH(RageVector4* pOut, RageVector3 prh ) /* Set cX to the cosine of the angle we want to rotate on the X axis, * and so on. Here, hpr.z (roll) rotates on the Z axis, hpr.x (heading) * on Y, and hpr.y (pitch) on X. */ - const float sX = RageFastSin(prh.y); - const float cX = RageFastCos(prh.y); - const float sY = RageFastSin(prh.x); - const float cY = RageFastCos(prh.x); - const float sZ = RageFastSin(prh.z); - const float cZ = RageFastCos(prh.z); + const float sX = std::sin(prh.y); + const float cX = std::cos(prh.y); + const float sY = std::sin(prh.x); + const float cY = std::cos(prh.x); + const float sZ = std::sin(prh.z); + const float cZ = std::cos(prh.z); pOut->w = cX * cY * cZ + sX * sY * sZ; pOut->x = sX * cY * cZ - cX * sY * sZ; @@ -506,9 +506,9 @@ void RageQuatSlerp(RageVector4 *pOut, const RageVector4 &from, const RageVector4 { // standard case (slerp) float omega = acosf(cosom); - float sinom = RageFastSin(omega); - scale0 = RageFastSin((1.0f - t) * omega) / sinom; - scale1 = RageFastSin(t * omega) / sinom; + float sinom = std::sin(omega); + scale0 = std::sin((1.0f - t) * omega) / sinom; + scale1 = std::sin(t * omega) / sinom; } else { @@ -566,12 +566,12 @@ void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles ) { const RageVector3 angles_radians( angles * 2*PI / 360 ); - const float sy = RageFastSin( angles_radians[2] ); - const float cy = RageFastCos( angles_radians[2] ); - const float sp = RageFastSin( angles_radians[1] ); - const float cp = RageFastCos( angles_radians[1] ); - const float sr = RageFastSin( angles_radians[0] ); - const float cr = RageFastCos( angles_radians[0] ); + const float sy = std::sin( angles_radians[2] ); + const float cy = std::cos( angles_radians[2] ); + const float sp = std::sin( angles_radians[1] ); + const float cp = std::cos( angles_radians[1] ); + const float sr = std::sin( angles_radians[0] ); + const float cr = std::cos( angles_radians[0] ); RageMatrixIdentity( pOut ); @@ -595,67 +595,6 @@ void RageMatrixTranspose( RageMatrix* pOut, const RageMatrix* pIn ) pOut->m[j][i] = pIn->m[i][j]; } -float RageFastSin( float x ) -{ - // from 0 to PI - // sizeof(table) == 4096 == one page of memory in Windows - static float table[1024]; - - static bool bInited = false; - if( !bInited ) - { - bInited = true; - for( unsigned i=0; i=0 && fRemainder<=1 ); - - float fValue[ARRAYLEN(iSampleIndex)]; - for( unsigned i=0; i= int(ARRAYLEN(table)) ) // PI <= iSample < 2*PI - { - // sin(x) == -sin(PI+x) - iSample -= ARRAYLEN(table); - DEBUG_ASSERT( iSample>=0 && iSample