91 lines
1.3 KiB
C
91 lines
1.3 KiB
C
|
#pragma once
|
||
|
|
||
|
#define DEG_TO_RAD(deg) ((deg) * 0.01745329251f)
|
||
|
#define RAD_TO_DEG(rad) ((rad) * 57.29578f)
|
||
|
|
||
|
const float PI_DIV_2 = 1.570796f;
|
||
|
|
||
|
typedef struct {
|
||
|
float x;
|
||
|
float y;
|
||
|
} vec2;
|
||
|
|
||
|
typedef struct {
|
||
|
float x;
|
||
|
float y;
|
||
|
float z;
|
||
|
} vec3;
|
||
|
|
||
|
typedef struct {
|
||
|
float x;
|
||
|
float y;
|
||
|
float z;
|
||
|
float w;
|
||
|
} vec4;
|
||
|
|
||
|
typedef struct {
|
||
|
float e00; float e01; float e02; float e03;
|
||
|
float e10; float e11; float e12; float e13;
|
||
|
float e20; float e21; float e22; float e23;
|
||
|
float e30; float e31; float e32; float e33;
|
||
|
} mat4;
|
||
|
|
||
|
typedef struct ray {
|
||
|
vec3 origin;
|
||
|
vec3 direction;
|
||
|
} ray_t;
|
||
|
|
||
|
typedef struct box_collider {
|
||
|
handle_t transform;
|
||
|
vec3 extents;
|
||
|
} box_collider_t;
|
||
|
|
||
|
float
|
||
|
vec3_length(vec3 v);
|
||
|
|
||
|
vec3
|
||
|
vec3_normalize(vec3 v);
|
||
|
|
||
|
vec3
|
||
|
vec3_negate(vec3 v);
|
||
|
|
||
|
vec3
|
||
|
vec3_add(vec3 a, vec3 b);
|
||
|
|
||
|
vec3
|
||
|
vec3_sub(vec3 a, vec3 b);
|
||
|
|
||
|
float
|
||
|
vec3_dot(vec3 a, vec3 b);
|
||
|
|
||
|
vec3
|
||
|
vec3_cross(vec3 a, vec3 b);
|
||
|
|
||
|
vec3
|
||
|
vec3_mult(vec3 v, float f);
|
||
|
|
||
|
mat4
|
||
|
mat4_identity(void);
|
||
|
|
||
|
mat4
|
||
|
mat4_multm(mat4 m0, mat4 m1);
|
||
|
|
||
|
vec4
|
||
|
mat4_multv(mat4 m, vec4 v);
|
||
|
|
||
|
bool
|
||
|
aabb_check(box_collider_t a, box_collider_t b);
|
||
|
|
||
|
float
|
||
|
periodic_value(float min, float max, float freq, float time);
|
||
|
|
||
|
bool
|
||
|
ray_aabb_intersect(box_collider_t aabb, ray_t ray);
|
||
|
|
||
|
float
|
||
|
lerp(float a, float b, float t);
|
||
|
|
||
|
float
|
||
|
normalize(float val, float min, float max);
|
||
|
|