day 13
This commit is contained in:
@@ -28,7 +28,7 @@ Tokens str_tokenize(Arena *arena, str s, str delim) {
|
||||
|
||||
str stuff = s;
|
||||
isize token_count = 0;
|
||||
while (str_next_token(&stuff, delim).len > 0) {
|
||||
for (; stuff.len > 0; str_next_token(&stuff, delim)) {
|
||||
token_count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,76 +98,3 @@ typedef double f64;
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x))
|
||||
|
||||
typedef union Vec2 {
|
||||
struct { f32 x, y; };
|
||||
struct { f32 u, v; };
|
||||
} Vec2;
|
||||
|
||||
typedef union Vec2i {
|
||||
struct { i32 x, y; };
|
||||
struct { i32 u, v; };
|
||||
} Vec2i ;
|
||||
|
||||
typedef struct Mat4 {
|
||||
float e[4][4];
|
||||
} Mat4;
|
||||
|
||||
|
||||
static inline Vec2
|
||||
vec2_add(Vec2 a, Vec2 b) {
|
||||
Vec2 result = {
|
||||
.x = a.x + b.x,
|
||||
.y = a.y + b.y,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Vec2
|
||||
vec2_sub(Vec2 a, Vec2 b) {
|
||||
Vec2 result = {
|
||||
.x = a.x - b.x,
|
||||
.y = a.y - b.y,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Vec2
|
||||
vec2(f32 x, f32 y) {
|
||||
Vec2 result = {{ x, y }};
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline f32
|
||||
vec2_dot(Vec2 a, Vec2 b) {
|
||||
return a.x * b.x + a.y * b.y;
|
||||
}
|
||||
|
||||
static inline f32
|
||||
vec2_norm2(Vec2 v) {
|
||||
return vec2_dot(v, v);
|
||||
}
|
||||
|
||||
static inline f32
|
||||
vec2_norm(Vec2 v) {
|
||||
return sqrtf(vec2_norm2(v));
|
||||
}
|
||||
|
||||
static inline f32
|
||||
vec2_dist(Vec2 a, Vec2 b) {
|
||||
return vec2_norm(vec2_sub(a, b));
|
||||
}
|
||||
|
||||
typedef struct Rect2i {
|
||||
int x, y, w, h;
|
||||
} Rect2i;
|
||||
|
||||
typedef struct Rect2f {
|
||||
f32 x, y, w, h;
|
||||
} Rect2f;
|
||||
|
||||
static inline Rect2f
|
||||
rect2f(f32 x, f32 y, f32 w, f32 h) {
|
||||
Rect2f result = { x, y, w, h };
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user