7 changed files with 60 additions and 50 deletions
@ -0,0 +1,54 @@
|
||||
|
||||
#pragma once |
||||
|
||||
#include <cassert> |
||||
|
||||
|
||||
typedef float real32; |
||||
typedef double real64; |
||||
typedef int32_t bool32; |
||||
typedef int32_t int32; |
||||
typedef int64_t int64; |
||||
typedef uint8_t uint8; |
||||
typedef uint32_t uint32; |
||||
|
||||
struct v2f |
||||
{ |
||||
v2f(): x(0), y(0) {} |
||||
v2f(real64 a, real64 b): x(a), y(b) {} |
||||
real64 x; |
||||
real64 y; |
||||
}; |
||||
|
||||
struct v2i |
||||
{ |
||||
v2i(int a, int b): x(a), y(b) {} |
||||
v2i() : x(0), y(0) {} |
||||
int32 x; |
||||
int32 y; |
||||
}; |
||||
|
||||
struct v4i |
||||
{ |
||||
int32 x0; |
||||
int32 y0; |
||||
int32 x1; |
||||
int32 y1; |
||||
}; |
||||
|
||||
inline real32 |
||||
SafeRatio(real32 dividend, real32 divisor) |
||||
{ |
||||
if (divisor == 0) |
||||
return dividend; |
||||
else |
||||
return dividend / divisor; |
||||
} |
||||
|
||||
inline int32 |
||||
SafeTruncateToInt32(int64 val) |
||||
{ |
||||
assert(val <= INT32_MAX && val >= INT32_MIN); |
||||
return (int32) val; |
||||
} |
||||
|
||||
Loading…
Reference in new issue