Add vec_copy and matrix_3x4_origin to util.c

This commit is contained in:
8dcc 2023-07-28 23:10:54 +02:00
parent 2a57c69444
commit 8d735ece89
2 changed files with 18 additions and 0 deletions

View File

@ -30,11 +30,13 @@ bool is_friend(cl_entity_t* ent);
char* get_name(int ent_idx);
game_id get_cur_game(void);
vec3_t vec3(float x, float y, float z);
void vec_copy(vec3_t* dst, const vec3_t* src);
vec3_t vec_add(vec3_t a, vec3_t b);
bool vec_is_zero(vec3_t v);
float vec_len2d(vec3_t v);
void vec_clamp(vec3_t v);
float angle_delta_rad(float a, float b);
vec3_t matrix_3x4_origin(matrix_3x4 m);
bool world_to_screen(vec3_t vec, vec2_t screen);
void engine_draw_text(int x, int y, char* s, rgb_t c);
void gl_drawbox(int x, int y, int w, int h, rgb_t c);

View File

@ -100,6 +100,12 @@ vec3_t vec3(float x, float y, float z) {
return ret;
}
void vec_copy(vec3_t* dst, const vec3_t* src) {
dst->x = src->x;
dst->y = src->y;
dst->z = src->z;
}
vec3_t vec_add(vec3_t a, vec3_t b) {
return vec3(a.x + b.x, a.y + b.y, a.z + b.z);
}
@ -129,6 +135,16 @@ float angle_delta_rad(float a, float b) {
return delta;
}
vec3_t matrix_3x4_origin(matrix_3x4 m) {
vec3_t ret;
ret.x = m[0][3];
ret.y = m[1][3];
ret.z = m[2][3];
return ret;
}
bool world_to_screen(vec3_t vec, vec2_t screen) {
if (vec_is_zero(vec))
return false;