diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-15 14:17:27 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-15 14:17:27 +0000 |
commit | f92c378423f81b4058c19f8fc3d7e631ceb8304d (patch) | |
tree | 74c1052d5df09f8bb6b46a2d777ef8bc25f95f91 | |
parent | Psycho-rebased branch terrain-for-networks on top of main (diff) | |
download | ilt-f92c378423f81b4058c19f8fc3d7e631ceb8304d.tar.bz2 ilt-f92c378423f81b4058c19f8fc3d7e631ceb8304d.tar.xz ilt-f92c378423f81b4058c19f8fc3d7e631ceb8304d.zip |
vector difference works with floating point
Makes it a generic wrapper
-rw-r--r-- | lib/maths.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/maths.h b/lib/maths.h index 3959896..b28fe01 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -79,8 +79,11 @@ operator-(const GlobalPosition<D> & global, const CalcPosition<D> & relative) return global - GlobalPosition<D>(relative); } -template<glm::length_t D, std::integral T, glm::qualifier Q> -constexpr RelativePosition<D> +template<glm::length_t D, Arithmetic T, glm::qualifier Q> +using DifferenceVector = glm::vec<D, std::conditional_t<std::is_floating_point_v<T>, T, float>, Q>; + +template<glm::length_t D, Arithmetic T, glm::qualifier Q> +constexpr DifferenceVector<D, T, Q> difference(const glm::vec<D, T, Q> & globalA, const glm::vec<D, T, Q> & globalB) { return globalA - globalB; |