mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-15 13:35:08 +00:00
Core/Misc: Remove dependency on undefined behaviour (#2678)
Co-authored-by: Ujp8LfXBJ6wCPR <github@lillecarl.com> Co-authored-by: Ujp8LfXBJ6wCPR <github@lillecarl.com>
This commit is contained in:
@@ -18,29 +18,26 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
#define MAX_STACK_SIZE 64
|
#define MAX_STACK_SIZE 64
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/4328396
|
||||||
|
|
||||||
static inline uint32 floatToRawIntBits(float f)
|
static inline uint32 floatToRawIntBits(float f)
|
||||||
{
|
{
|
||||||
union
|
static_assert(sizeof(float) == sizeof(uint32), "Size of uint32 and float must be equal for this to work");
|
||||||
{
|
uint32 ret;
|
||||||
uint32 ival;
|
memcpy(&ret, &f, sizeof(float));
|
||||||
float fval;
|
return ret;
|
||||||
} temp;
|
|
||||||
temp.fval=f;
|
|
||||||
return temp.ival;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float intBitsToFloat(uint32 i)
|
static inline float intBitsToFloat(uint32 i)
|
||||||
{
|
{
|
||||||
union
|
static_assert(sizeof(float) == sizeof(uint32), "Size of uint32 and float must be equal for this to work");
|
||||||
{
|
float ret;
|
||||||
uint32 ival;
|
memcpy(&ret, &i, sizeof(uint32));
|
||||||
float fval;
|
return ret;
|
||||||
} temp;
|
|
||||||
temp.ival=i;
|
|
||||||
return temp.fval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AABound
|
struct AABound
|
||||||
|
|||||||
Reference in New Issue
Block a user