From f3536344c274073fcdbeb5501261e122830a869c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 15 Jan 2026 00:52:57 +0000 Subject: Add constexpr lround for glm::vec --- lib/maths.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/maths.h') diff --git a/lib/maths.h b/lib/maths.h index 43d6dcd..4a835d3 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -76,6 +76,18 @@ constexpr auto degreesToRads = pi / 180.F; constexpr auto earthMeanRadius = 6371.01F; // In km constexpr auto astronomicalUnit = 149597890.F; // In km +// GLM round is not constexpr :( And we can use lround to convert at the same time +template +[[nodiscard]] constexpr glm::vec +lround(const glm::vec & value) +{ + glm::vec out {}; + for (glm::length_t axis = 0; axis < D; ++axis) { + out[axis] = std::lround(value[axis]); + } + return out; +} + template constexpr GlobalPosition operator+(const GlobalPosition & global, const RelativePosition & relative) -- cgit v1.2.3