From 02d98b26a0b387c8b036d44c7971809d7b80eb3a Mon Sep 17 00:00:00 2001 From: jpark37 Date: Fri, 17 Sep 2021 23:06:52 -0700 Subject: [PATCH] libobs/graphics: Fix vec2 min/max functions --- libobs/graphics/vec2.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/libobs/graphics/vec2.h b/libobs/graphics/vec2.h index a13d2f141..f0ca985d4 100644 --- a/libobs/graphics/vec2.h +++ b/libobs/graphics/vec2.h @@ -119,36 +119,28 @@ static inline float vec2_dist(const struct vec2 *v1, const struct vec2 *v2) static inline void vec2_minf(struct vec2 *dst, const struct vec2 *v, float val) { - if (v->x < val) - dst->x = val; - if (v->y < val) - dst->y = val; + dst->x = (v->x < val) ? v->x : val; + dst->y = (v->y < val) ? v->y : val; } static inline void vec2_min(struct vec2 *dst, const struct vec2 *v, const struct vec2 *min_v) { - if (v->x < min_v->x) - dst->x = min_v->x; - if (v->y < min_v->y) - dst->y = min_v->y; + dst->x = (v->x < min_v->x) ? v->x : min_v->x; + dst->y = (v->y < min_v->y) ? v->y : min_v->y; } static inline void vec2_maxf(struct vec2 *dst, const struct vec2 *v, float val) { - if (v->x > val) - dst->x = val; - if (v->y > val) - dst->y = val; + dst->x = (v->x > val) ? v->x : val; + dst->y = (v->y > val) ? v->y : val; } static inline void vec2_max(struct vec2 *dst, const struct vec2 *v, const struct vec2 *max_v) { - if (v->x > max_v->x) - dst->x = max_v->x; - if (v->y > max_v->y) - dst->y = max_v->y; + dst->x = (v->x > max_v->x) ? v->x : max_v->x; + dst->y = (v->y > max_v->y) ? v->y : max_v->y; } EXPORT void vec2_abs(struct vec2 *dst, const struct vec2 *v);