Skip to content

Commit 9e7a469

Browse files
author
stgatilov
committed
#6300. Deleted Ftou function completely.
It is very niche function, used only in two places. Most likely it can be replaced with Ftoi in both cases... It is also a bit dangerous, since passing negative value would cause unexpected result. It is deleted in Doom 3 BFG too, which confirms it's uselessness. In the two usages, I replaced the call with cast to unsigned int, so there is no behavior change here. git-svn-id: http://svn.thedarkmod.com/svn/darkmod_src/trunk@10412 49c82d7f-2e2a-0410-a16f-ae8f201b507f
1 parent c837e02 commit 9e7a469

File tree

4 files changed

+2
-12
lines changed

4 files changed

+2
-12
lines changed

idlib/Token.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void idToken::NumberValue( void ) {
8787
}
8888
}
8989
}
90-
intvalue = idMath::Ftou( floatvalue );
90+
intvalue = dword( floatvalue );
9191
}
9292
else if ( subtype & TT_DECIMAL ) {
9393
while( *p ) {

idlib/math/Math.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,14 @@ TEST_CASE("Math:Rounding") {
173173

174174
float xp = i, xm = -i;
175175

176-
errors += (idMath::Ftou(xp) != xp);
177-
178176
errors += (idMath::Ftoi(xp + 0.25f) != xp);
179177
errors += (idMath::Ftoi(xm - 0.25f) != xm);
180-
errors += (idMath::Ftou(xp + 0.25f) != xp);
181178

182179
errors += (idMath::Ftoi(xp + 0.75f) != xp);
183180
errors += (idMath::Ftoi(xm - 0.75f) != xm);
184-
errors += (idMath::Ftou(xp + 0.75f) != xp);
185181

186182
errors += (idMath::Ftoi(xp + 0.5f) != xp);
187183
errors += (idMath::Ftoi(xm - 0.5f) != xm);
188-
errors += (idMath::Ftou(xp + 0.5f) != xp);
189184

190185
errors += (idMath::FtoiFast(xp + 0.5f) != (i + (i & 1))); // FE_TONEAREST: choose even
191186
errors += (idMath::FtoiFast(xm - 0.5f) != -(i + (i & 1))); // FE_TONEAREST: choose even

idlib/math/Math.h

-5
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class idMath {
175175
static float Ceil( float f ); // returns the smallest integer that is greater than or equal to the given value
176176
static float Rint( float f ); // returns the nearest integer (ties resolved arbitrarily)
177177
static int Ftoi( float f ); // float to int conversion: round to zero
178-
static unsigned int Ftou( float f ); // float to unsigned conversion: round down
179178
static int FtoiFast( float f ); // float to int conversion: round to nearest (ties are rounded to even) --- depends on FPU mode
180179

181180
//stgatilov: branchless min and max for floating point values
@@ -901,10 +900,6 @@ ID_INLINE int idMath::FtoiFast( float f ) {
901900
#endif
902901
}
903902

904-
ID_INLINE unsigned int idMath::Ftou( float f ) {
905-
return (unsigned int) f;
906-
}
907-
908903
ID_FORCE_INLINE float idMath::Fmin ( float a, float b ) {
909904
#ifdef __SSE__
910905
return _mm_cvtss_f32(_mm_min_ss(_mm_set_ss(a), _mm_set_ss(b)));

sound/snd_system.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ int idSoundSystemLocal::AsyncUpdate( int inTime ) {
677677
dword dwCurrentBlock;
678678

679679
// here we do it in samples ( overflows in 27 hours or so )
680-
dwCurrentWritePos = idMath::Ftou((float)Sys_Milliseconds() * 44.1f) % (MIXBUFFER_SAMPLES * ROOM_SLICES_IN_BUFFER);
680+
dwCurrentWritePos = dword((float)Sys_Milliseconds() * 44.1f) % (MIXBUFFER_SAMPLES * ROOM_SLICES_IN_BUFFER);
681681
dwCurrentBlock = dwCurrentWritePos / MIXBUFFER_SAMPLES;
682682

683683
if ( nextWriteBlock == 0xffffffff ) {

0 commit comments

Comments
 (0)