Clean up.

This commit is contained in:
2026-07-14 13:21:04 -07:00
parent 943ed21776
commit ffc4310646
12 changed files with 1445 additions and 955 deletions
+31 -23
View File
@@ -7,63 +7,71 @@
#include <math.h>
#include <string.h> // memset
S32 RoundF32toS32(F32 Real32)
float AbsoluteValue(float Real32)
{
S32 Result = (S32)roundf(Real32);
float Result = fabs(Real32);
return Result;
}
S32 FloorF32toS32(F32 Real32)
int RoundFloatToInt(float Real32)
{
S32 Result = (S32)floorf(Real32);
int Result = (int)roundf(Real32);
return Result;
}
F32 Sin(F32 Angle)
int FloorFloatToInt(float Real32)
{
F32 Result = sinf(Angle);
int Result = (int)floorf(Real32);
return Result;
}
F32 Cos(F32 Angle)
float Sin(float Angle)
{
F32 Result = cosf(Angle);
float Result = sinf(Angle);
return Result;
}
F32 ATan2(F32 Y, F32 X)
float Cos(float Angle)
{
F32 Result = atan2f(Y, X);
float Result = cosf(Angle);
return Result;
}
typedef struct bit_scan_result {
B32 Found;
U32 Index;
} bit_scan_result;
static bit_scan_result FindLeastSignificantSetBit(U32 Value)
float ATan2(float Y, float X)
{
bit_scan_result Result;
float Result = atan2f(Y, X);
return Result;
}
struct bit_scan_result {
int Found;
unsigned int Index;
};
static struct bit_scan_result FindLeastSignificantSetBit(unsigned int Value)
{
struct bit_scan_result Result;
memset(&Result, 0, sizeof(Result));
#if COMPILER_MSVC
unsigned long Index;
Result.Found = _BitScanForward(&Index, Value);
Result.Index = (U32)Index;
Result.Index = (unsigned int)Index;
#elif COMPILER_CLANG
Result.Index = __builtin_ffsll(Value); // NOTE: It is a GCC function, but is supported by clang compiler.
// https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html
Result.Index = __builtin_ffsll(Value); /* NOTE: It is a GCC function,
but is supported by clang
compiler.
https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html*/
if(Result.Index) {
Result.Found = TRUE;
Result.Found = 1;
if(Result.Index > 0)
Result.Index--;
}
#else
for(U32 Test = 0; Test < 32; Test++) {
for(unsigned int Test = 0; Test < 32; Test++) {
if(Value & (1 << Test)) {
Result.Index = Test;
Result.Found = TRUE;
Result.Found = 1;
break;
}
}