From 8cde2578173daa6428824a95a1b6d416b04b3b29 Mon Sep 17 00:00:00 2001 From: Moses Turner Date: Sat, 27 Nov 2021 20:01:09 -0600 Subject: [PATCH] aux/math: add vec3 overloads for scalar multiplication --- src/xrt/auxiliary/math/m_vec3.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/xrt/auxiliary/math/m_vec3.h b/src/xrt/auxiliary/math/m_vec3.h index 622077991..401cff8af 100644 --- a/src/xrt/auxiliary/math/m_vec3.h +++ b/src/xrt/auxiliary/math/m_vec3.h @@ -1,4 +1,4 @@ -// Copyright 2019-2020, Collabora, Ltd. +// Copyright 2019-2021, Collabora, Ltd. // Copyright 2020, Nova King. // SPDX-License-Identifier: BSL-1.0 /*! @@ -6,6 +6,7 @@ * @brief C vec3 math library. * @author Jakob Bornecrantz * @author Nova King + * @author Moses Turner > * * @see xrt_vec3 * @ingroup aux_math @@ -150,7 +151,13 @@ operator-(const struct xrt_vec3 &a, const struct xrt_vec3 &b) return m_vec3_sub(a, b); } -static inline struct xrt_vec3 // Until clang-format-11 is on the CI. +static inline struct xrt_vec3 +operator*(const struct xrt_vec3 &a, const float &b) +{ + return m_vec3_mul_scalar(a, b); +} + +static inline struct xrt_vec3 operator*(const struct xrt_vec3 &a, const struct xrt_vec3 &b) { return m_vec3_mul(a, b); @@ -180,6 +187,12 @@ operator*=(struct xrt_vec3 &a, const struct xrt_vec3 &b) a = a * b; } +static inline void +operator*=(struct xrt_vec3 &a, const float &b) +{ + a = a * b; +} + static inline void operator/=(struct xrt_vec3 &a, const struct xrt_vec3 &b) {