From 8d735ece89136c2fb81699128ff7fbb23c185657 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Fri, 28 Jul 2023 23:10:54 +0200 Subject: [PATCH] Add vec_copy and matrix_3x4_origin to util.c --- src/include/util.h | 2 ++ src/util.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/include/util.h b/src/include/util.h index 1e8c1f2..c1e5b48 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -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); diff --git a/src/util.c b/src/util.c index 6aa7a47..65de83f 100644 --- a/src/util.c +++ b/src/util.c @@ -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;