m/vec2: Add C++ operators

This commit is contained in:
Jakob Bornecrantz 2020-08-28 16:58:29 +01:00
parent 2d8a39b731
commit d396117a39

View file

@ -81,11 +81,62 @@ m_vec2_len(struct xrt_vec2 l)
return sqrtf(m_vec2_len_sqrd(l));
}
#ifdef __cplusplus
}
static inline struct xrt_vec2
operator+(const struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
return m_vec2_add(a, b);
}
static inline struct xrt_vec2
operator-(const struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
return m_vec2_sub(a, b);
}
static inline struct xrt_vec2 operator*(const struct xrt_vec2 &a,
const struct xrt_vec2 &b)
{
return m_vec2_mul(a, b);
}
static inline struct xrt_vec2
operator/(const struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
return m_vec2_div(a, b);
}
static inline void
operator+=(struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
a = a + b;
}
static inline void
operator-=(struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
a = a - b;
}
static inline void
operator*=(struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
a = a * b;
}
static inline void
operator/=(struct xrt_vec2 &a, const struct xrt_vec2 &b)
{
a = a / b;
}
/*!
* @}
*/
#ifdef __cplusplus
}
#endif