From ba770a85b2b0ff9222e2867689c693ebee841e55 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 18 Nov 2022 20:39:54 +0000 Subject: Rename rdiv to ratio and add a vec2 override --- game/geoData.cpp | 2 +- lib/maths.h | 9 ++++++++- ui/sceneRenderer.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/game/geoData.cpp b/game/geoData.cpp index 25c7131..af39ce3 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -43,7 +43,7 @@ GeoData::generateRandom() for (auto x = lim1.x; x < lim2.x; x += 1) { const auto dist {hpos - glm::ivec2 {x, y}}; const glm::ivec2 distsqrd {dist.x * dist.x, dist.y * dist.y}; - const auto out {rdiv(sq(x - hpos.x), sq(hsize.x)) + rdiv(sq(y - hpos.y), sq(hsize.y))}; + const auto out {ratio(sq(x - hpos.x), sq(hsize.x)) + ratio(sq(y - hpos.y), sq(hsize.y))}; if (out <= 1.0F) { auto & node {nodes[at({x, y})]}; const auto m {1.F / (7.F * out - 8.F) + 1.F}; diff --git a/lib/maths.h b/lib/maths.h index 514a5ad..1c07baa 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -67,11 +67,18 @@ sq(T v) template inline constexpr auto -rdiv(Ta a, Tb b) +ratio(Ta a, Tb b) { return (static_cast(a) / static_cast(b)); } +template +inline constexpr auto +ratio(glm::vec<2, T, Q> v) +{ + return ratio(v.x, v.y); +} + constexpr inline glm::vec2 operator!(const glm::vec3 & v) { diff --git a/ui/sceneRenderer.cpp b/ui/sceneRenderer.cpp index 852f64c..6986fb6 100644 --- a/ui/sceneRenderer.cpp +++ b/ui/sceneRenderer.cpp @@ -12,7 +12,7 @@ static constexpr std::array displayVAOdata {{ {1.0f, -1.0f, 1.0f, 0.0f}, }}; SceneRenderer::SceneRenderer(glm::ivec2 size, GLuint o) : - camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, rdiv(size.x, size.y), 0.1F, 10000.0F}, output {o}, + camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(size), 0.1F, 10000.0F}, output {o}, lighting {lightingShader_vs, lightingShader_fs} { glBindVertexArray(displayVAO); -- cgit v1.2.3