From 048f18e2a0b32044525cef41fa053984433c74b9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 29 Dec 2023 14:12:40 +0000 Subject: Remove misleading power operator^ on vec2/3 --- lib/maths.cpp | 2 +- lib/maths.h | 24 +++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/maths.cpp b/lib/maths.cpp index 0c25820..17082d4 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -9,7 +9,7 @@ glm::mat4 flat_orientation(const Direction3D & diff) { static const auto oneeighty {glm::rotate(pi, up)}; - const auto flatdiff {glm::normalize(diff.xy() ^ 0.F)}; + const auto flatdiff {glm::normalize(diff.xy() || 0.F)}; auto e {glm::orientation(flatdiff, north)}; // Handle if diff is exactly opposite to north return (std::isnan(e[0][0])) ? oneeighty : e; diff --git a/lib/maths.h b/lib/maths.h index dd83c4b..f7ff148 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -99,18 +99,6 @@ perspective_divide(glm::vec<4, T, Q> v) return v / v.w; } -constexpr inline Position3D -operator^(const Position2D & v, float z) -{ - return {v.x, v.y, z}; -} - -constexpr inline glm::vec4 -operator^(const Position3D & v, float w) -{ - return {v.x, v.y, v.z, w}; -} - template inline constexpr glm::vec operator||(const glm::vec v1, const glm::vec v2) @@ -125,15 +113,17 @@ operator||(const glm::vec v1, const T v2) return {v1, v2}; } -inline Position3D -operator%(const Position3D & p, const glm::mat4 & mutation) +template +inline constexpr glm::vec +operator%(const glm::vec & p, const glm::mat & mutation) { - const auto p2 = mutation * (p ^ 1); + const auto p2 = mutation * (p || T(1)); return p2 / p2.w; } -inline Position3D -operator%=(Position3D & p, const glm::mat4 & mutation) +template +inline constexpr glm::vec +operator%=(glm::vec & p, const glm::mat & mutation) { return p = p % mutation; } -- cgit v1.2.3