summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-12-29 14:12:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-12-29 14:12:40 +0000
commit048f18e2a0b32044525cef41fa053984433c74b9 (patch)
treedfa4a11169654924c55a4dbfb0de3863e1f33342 /lib
parentRemove weird operator! on vec2/3 (diff)
downloadilt-048f18e2a0b32044525cef41fa053984433c74b9.tar.bz2
ilt-048f18e2a0b32044525cef41fa053984433c74b9.tar.xz
ilt-048f18e2a0b32044525cef41fa053984433c74b9.zip
Remove misleading power operator^ on vec2/3
Diffstat (limited to 'lib')
-rw-r--r--lib/maths.cpp2
-rw-r--r--lib/maths.h24
2 files changed, 8 insertions, 18 deletions
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<glm::length_t L1, glm::length_t L2, typename T, glm::qualifier Q>
inline constexpr glm::vec<L1 + L2, T, Q>
operator||(const glm::vec<L1, T, Q> v1, const glm::vec<L2, T, Q> v2)
@@ -125,15 +113,17 @@ operator||(const glm::vec<L, T, Q> v1, const T v2)
return {v1, v2};
}
-inline Position3D
-operator%(const Position3D & p, const glm::mat4 & mutation)
+template<glm::length_t L, typename T, glm::qualifier Q>
+inline constexpr glm::vec<L, T, Q>
+operator%(const glm::vec<L, T, Q> & p, const glm::mat<L + 1, L + 1, T, Q> & 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<glm::length_t L, typename T, glm::qualifier Q>
+inline constexpr glm::vec<L, T, Q>
+operator%=(glm::vec<L, T, Q> & p, const glm::mat<L + 1, L + 1, T, Q> & mutation)
{
return p = p % mutation;
}