Replace RageFastSin and RageFastCos with standard library versions because the standard library is faster. Use fmod in spline evaluation.
This commit is contained in:
+8
-8
@@ -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; i<NUM_DIFFUSE_COLORS; i++ )
|
||||
tempState.diffuse[i] = tempState.diffuse[0];
|
||||
break;
|
||||
case wag:
|
||||
tempState.rotation += m_vEffectMagnitude * RageFastSin( fPercentThroughEffect * 2.0f * PI );
|
||||
tempState.rotation += m_vEffectMagnitude * std::sin( fPercentThroughEffect * 2.0f * PI );
|
||||
break;
|
||||
case spin:
|
||||
// nothing needs to be here
|
||||
@@ -536,13 +536,13 @@ void Actor::PreDraw() // calculate actor properties
|
||||
break;
|
||||
case bounce:
|
||||
{
|
||||
float fPercentOffset = RageFastSin( fPercentThroughEffect*PI );
|
||||
float fPercentOffset = std::sin( fPercentThroughEffect*PI );
|
||||
tempState.pos += m_vEffectMagnitude * fPercentOffset;
|
||||
}
|
||||
break;
|
||||
case bob:
|
||||
{
|
||||
float fPercentOffset = RageFastSin( fPercentThroughEffect*PI*2 );
|
||||
float fPercentOffset = std::sin( fPercentThroughEffect*PI*2 );
|
||||
tempState.pos += m_vEffectMagnitude * fPercentOffset;
|
||||
}
|
||||
break;
|
||||
@@ -550,7 +550,7 @@ void Actor::PreDraw() // calculate actor properties
|
||||
{
|
||||
float fMinZoom = m_vEffectMagnitude[0];
|
||||
float fMaxZoom = m_vEffectMagnitude[1];
|
||||
float fPercentOffset = RageFastSin( fPercentThroughEffect*PI );
|
||||
float fPercentOffset = std::sin( fPercentThroughEffect*PI );
|
||||
float fZoom = SCALE( fPercentOffset, 0.f, 1.f, fMinZoom, fMaxZoom );
|
||||
tempState.scale *= fZoom;
|
||||
|
||||
|
||||
@@ -193,10 +193,10 @@ void ArrowEffects::Update()
|
||||
TIPSY_OFFSET_ARROW_MAGNITUDE;
|
||||
for(int col= 0; col < MAX_COLS_PER_PLAYER; ++col)
|
||||
{
|
||||
data.m_tipsy_result[col]= RageFastCos(
|
||||
data.m_tipsy_result[col]= std::cos(
|
||||
time_times_timer + (col * TIPSY_COLUMN_FREQUENCY)) *
|
||||
arrow_times_mag;
|
||||
data.m_tipsy_offset_result[col]= RageFastCos(
|
||||
data.m_tipsy_offset_result[col]= std::cos(
|
||||
time_times_offset_timer + (col * TIPSY_OFFSET_COLUMN_FREQUENCY)) *
|
||||
arrow_times_offset_mag;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
|
||||
fYAdjust += fBrakeYAdjust;
|
||||
}
|
||||
if( fAccels[PlayerOptions::ACCEL_WAVE] != 0 )
|
||||
fYAdjust += fAccels[PlayerOptions::ACCEL_WAVE] * WAVE_MOD_MAGNITUDE *RageFastSin( fYOffset/WAVE_MOD_HEIGHT );
|
||||
fYAdjust += fAccels[PlayerOptions::ACCEL_WAVE] * WAVE_MOD_MAGNITUDE *std::sin( fYOffset/WAVE_MOD_HEIGHT );
|
||||
|
||||
fYOffset += fYAdjust;
|
||||
|
||||
@@ -396,7 +396,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
|
||||
// TODO: Don't index by PlayerNumber.
|
||||
PerPlayerData &data = g_EffectData[pPlayerState->m_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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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<float>(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<size_t>(t);
|
||||
tfrac= t - static_cast<float>(p);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+4
-4
@@ -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];
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+41
-102
@@ -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<ARRAYLEN(table); i++ )
|
||||
{
|
||||
float z = SCALE(i,0,ARRAYLEN(table),0.0f,PI);
|
||||
table[i] = sinf(z);
|
||||
}
|
||||
}
|
||||
|
||||
// optimization
|
||||
if( x == 0 )
|
||||
return 0;
|
||||
|
||||
float fIndex = SCALE( x, 0.0f, PI*2, 0, ARRAYLEN(table)*2 );
|
||||
|
||||
// lerp using samples from the table
|
||||
int iSampleIndex[2];
|
||||
iSampleIndex[0] = (int)floorf(fIndex);
|
||||
iSampleIndex[1] = iSampleIndex[0]+1;
|
||||
|
||||
float fRemainder = fIndex - iSampleIndex[0];
|
||||
for( unsigned i=0; i<ARRAYLEN(iSampleIndex); i++ )
|
||||
iSampleIndex[i] %= ARRAYLEN(table) * 2;
|
||||
|
||||
DEBUG_ASSERT( fRemainder>=0 && fRemainder<=1 );
|
||||
|
||||
float fValue[ARRAYLEN(iSampleIndex)];
|
||||
for( unsigned i=0; i<ARRAYLEN(iSampleIndex); i++ )
|
||||
{
|
||||
int &iSample = iSampleIndex[i];
|
||||
float &fVal = fValue[i];
|
||||
|
||||
if( iSample >= int(ARRAYLEN(table)) ) // PI <= iSample < 2*PI
|
||||
{
|
||||
// sin(x) == -sin(PI+x)
|
||||
iSample -= ARRAYLEN(table);
|
||||
DEBUG_ASSERT( iSample>=0 && iSample<int(ARRAYLEN(table)) );
|
||||
fVal = -table[iSample];
|
||||
}
|
||||
else
|
||||
{
|
||||
fVal = table[iSample];
|
||||
}
|
||||
}
|
||||
|
||||
return SCALE( fRemainder, 0.0f, 1.0f, fValue[0], fValue[1] );
|
||||
}
|
||||
|
||||
float RageFastCos( float x )
|
||||
{
|
||||
return RageFastSin( x + 0.5f*PI );
|
||||
}
|
||||
|
||||
float RageQuadratic::Evaluate( float fT ) const
|
||||
{
|
||||
// optimized (m_fA * fT*fT*fT) + (m_fB * fT*fT) + (m_fC * fT) + m_fD;
|
||||
|
||||
@@ -53,9 +53,6 @@ RageMatrix RageLookAt(
|
||||
void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles );
|
||||
void RageMatrixTranspose( RageMatrix* pOut, const RageMatrix* pIn );
|
||||
|
||||
float RageFastSin( float x ) CONST_FUNCTION;
|
||||
float RageFastCos( float x ) CONST_FUNCTION;
|
||||
|
||||
class RageQuadratic
|
||||
{
|
||||
public:
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ struct TweenDecelerate: public ITween
|
||||
};
|
||||
struct TweenSpring: public ITween
|
||||
{
|
||||
float Tween( float f ) const { return 1 - RageFastCos( f*PI*2.5f )/(1+f*3); }
|
||||
float Tween( float f ) const { return 1 - std::cos( f*PI*2.5f )/(1+f*3); }
|
||||
ITween *Copy() const { return new TweenSpring(*this); }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user