Move truncf, roundf fallbacks to the right place.

Fix BeatToNoteRow rounding backwards for negative numbers.
This commit is contained in:
Glenn Maynard
2003-10-27 03:45:15 +00:00
parent f1d94cfb83
commit 0eaa9aa178
3 changed files with 9 additions and 14 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ struct HoldNote
};
inline int BeatToNoteRow( float fBeatNum ) { return int( fBeatNum * ROWS_PER_BEAT + 0.5f); }; // round
inline int BeatToNoteRow( float fBeatNum ) { return (int) roundf( fBeatNum * ROWS_PER_BEAT); };
inline int BeatToNoteRowNotRounded( float fBeatNum ) { return (int)( fBeatNum * ROWS_PER_BEAT ); };
inline float NoteRowToBeat( float fNoteIndex ) { return fNoteIndex / (float)ROWS_PER_BEAT; };
inline float NoteRowToBeat( int iNoteIndex ) { return NoteRowToBeat( (float)iNoteIndex ); };
-13
View File
@@ -119,19 +119,6 @@ inline float randomf( const float low=-1.0f, const float high=1.0f )
return low + ( high - low ) * ( (float)rand() ) / RAND_MAX;
}
/* XXX: These are C99 functions (except for the roundf(double) overload); what's
* the C99 define we can test for? XXX autoconf */
#if defined(WIN32)
inline double trunc( double f ) { return float(int(f)); };
#else
#include <math.h>
#endif
#if defined(NEED_TRUNCF)
inline float truncf( float f ) { return float(int(f)); };
#endif
#if defined(NEED_ROUNDF)
inline float roundf( float f ) { if(f < 0) return truncf(f-0.5f); return truncf(f+0.5f); };
#endif
inline float froundf( const float f, const float fRoundInterval )
{
return int( (f + fRoundInterval/2)/fRoundInterval ) * fRoundInterval;
+8
View File
@@ -136,6 +136,14 @@ inline float cosf(float x) { return float(cos(double(x))); }
inline float acosf(float x) { return float(acos(double(x))); }
#endif
#ifdef NEED_TRUNCF
inline float truncf( float f ) { return float(int(f)); };
#endif
#ifdef NEED_ROUNDF
inline float roundf( float f ) { if(f < 0) return truncf(f-0.5f); return truncf(f+0.5f); };
#endif
#ifdef _XBOX
#include <xtl.h>
#include <xgraphics.h>