mathlib: make Gain and Bias inline

This commit is contained in:
nillerusr
2023-04-26 22:33:20 +03:00
parent 7ceba77616
commit e3edbc2d96
2 changed files with 21 additions and 31 deletions

View File

@@ -1392,33 +1392,6 @@ void VectorYawRotate( const Vector &in, float flYaw, Vector &out)
out.z = in.z;
}
float Bias( float x, float biasAmt )
{
// WARNING: not thread safe
static float lastAmt = -1;
static float lastExponent = 0;
if( lastAmt != biasAmt )
{
lastExponent = log( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5))
}
float fRet = pow( x, lastExponent );
Assert ( !IS_NAN( fRet ) );
return fRet;
}
float Gain( float x, float biasAmt )
{
// WARNING: not thread safe
if( x < 0.5 )
return 0.5f * Bias( 2*x, 1-biasAmt );
else
return 1 - 0.5f * Bias( 2 - 2*x, 1-biasAmt );
}
float SmoothCurve( float x )
{
// Actual smooth curve. Visualization: