This commit is contained in:
mcoms 2025-04-03 15:53:05 +03:00 committed by GitHub
commit 3f5cf8d9d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 33 deletions

View file

@ -406,7 +406,7 @@ void C_SmokeStack::RenderParticles( CParticleRenderIterator *pIterator )
// makes it get translucent and fade out for a longer time.
//float alpha = cosf( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
float tLifetime = pParticle->m_Lifetime * m_InvLifetime;
float alpha = TableCos( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
float alpha = FastCos( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
if( tLifetime > 0.5f )
alpha *= alpha;

View file

@ -115,15 +115,6 @@ float (*pfInvRSquared)(const float* v) = _InvRSquared;
void (*pfFastSinCos)(float x, float* s, float* c) = SinCos;
float (*pfFastCos)(float x) = cosf;
float SinCosTable[SIN_TABLE_SIZE];
void InitSinCosTable()
{
for( int i = 0; i < SIN_TABLE_SIZE; i++ )
{
SinCosTable[i] = sin(i * 2.0 * M_PI / SIN_TABLE_SIZE);
}
}
qboolean VectorsEqual( const float *v1, const float *v2 )
{
Assert( s_bMathlibInitialized );
@ -3402,7 +3393,6 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
s_bMathlibInitialized = true;
InitSinCosTable();
BuildGammaTable( gamma, texGamma, brightness, overbright );
}

View file

@ -436,34 +436,14 @@ inline vec_t RoundInt (vec_t in)
int Q_log2(int val);
#define SIN_TABLE_SIZE 256
#define FTOIBIAS 12582912.f
extern float SinCosTable[SIN_TABLE_SIZE];
inline float TableCos( float theta )
{
union
{
int i;
float f;
} ftmp;
// ideally, the following should compile down to: theta * constant + constant, changing any of these constants from defines sometimes fubars this.
ftmp.f = theta * ( float )( SIN_TABLE_SIZE / ( 2.0f * M_PI ) ) + ( FTOIBIAS + ( SIN_TABLE_SIZE / 4 ) );
return SinCosTable[ ftmp.i & ( SIN_TABLE_SIZE - 1 ) ];
return FastCos( theta );
}
inline float TableSin( float theta )
{
union
{
int i;
float f;
} ftmp;
// ideally, the following should compile down to: theta * constant + constant
ftmp.f = theta * ( float )( SIN_TABLE_SIZE / ( 2.0f * M_PI ) ) + FTOIBIAS;
return SinCosTable[ ftmp.i & ( SIN_TABLE_SIZE - 1 ) ];
return sinf( theta );
}
template<class T>