From 43948c213430f40220df4dfa0e6b1db3f91efca0 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 30 Mar 2005 03:59:33 +0000 Subject: [PATCH] lerp in FastSin to fix shimmer in MusicWheel --- stepmania/src/RageMath.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/stepmania/src/RageMath.cpp b/stepmania/src/RageMath.cpp index 15eaaea409..034a3c259f 100644 --- a/stepmania/src/RageMath.cpp +++ b/stepmania/src/RageMath.cpp @@ -544,25 +544,37 @@ float RageFastSin( float x ) } } - int i = (int)SCALE( x, 0.0f, PI*2, 0, ARRAYSIZE(table)*2 ); - i %= ARRAYSIZE(table) * 2; + float fIndex = SCALE( x, 0.0f, PI*2, 0, ARRAYSIZE(table)*2 ); + + // lerp using samples from the table + int iSampleIndex[2] = { (int)floorf(fIndex), iSampleIndex[0]+1 }; + float fRemainder = fIndex - iSampleIndex[0]; + for( int i=0; i=0 && i=0 && fRemainder<=1 ); - float fRet; - if( i >= int(ARRAYSIZE(table)) ) // PI <= i < 2*PI + float fValue[ARRAYSIZE(iSampleIndex)]; + for( int i=0; i=0 && i= int(ARRAYSIZE(table)) ) // PI <= iSample < 2*PI + { + // sin(x) == -sin(2*PI-x) + iSample = ARRAYSIZE(table)*2 - 1 - iSample; // mirror about ARRAYSIZE(table) + DEBUG_ASSERT( iSample>=0 && iSample