Fix RageFastSin()

This commit is contained in:
Martin Natano
2023-02-20 18:08:33 +01:00
parent 7981676f53
commit 98f4916313
+4 -5
View File
@@ -616,14 +616,14 @@ float RageFastSin(float angle)
{ {
if(angle == 0) { return 0; } if(angle == 0) { return 0; }
float index= angle * sine_table_index_mult; float index= angle * sine_table_index_mult;
auto first_index= static_cast<unsigned int>(index); int first_index= static_cast<int>(index);
auto second_index= (first_index + 1) % sine_index_mod; int second_index= (first_index + 1) % sine_index_mod;
float remainder= index - first_index; float remainder= index - first_index;
first_index%= sine_index_mod; first_index%= sine_index_mod;
float first= 0.0f; float first= 0.0f;
float second= 0.0f; float second= 0.0f;
#define SET_SAMPLE(sample) \ #define SET_SAMPLE(sample) \
if(sample##_index >= sine_table_size) \ if(sample##_index >= static_cast<int>(sine_table_size)) \
{ \ { \
sample= -sine_table[sample##_index - sine_table_size]; \ sample= -sine_table[sample##_index - sine_table_size]; \
} \ } \
@@ -634,8 +634,7 @@ float RageFastSin(float angle)
SET_SAMPLE(first); SET_SAMPLE(first);
SET_SAMPLE(second); SET_SAMPLE(second);
#undef SET_SAMPLE #undef SET_SAMPLE
float result= lerp(remainder, first, second); return lerp(remainder, first, second);
return result;
} }
float RageFastCos( float x ) float RageFastCos( float x )