summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/geoData.cpp2
-rw-r--r--lib/maths.h9
-rw-r--r--ui/sceneRenderer.cpp2
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<typename R = float, typename Ta, typename Tb>
inline constexpr auto
-rdiv(Ta a, Tb b)
+ratio(Ta a, Tb b)
{
return (static_cast<R>(a) / static_cast<R>(b));
}
+template<typename R = float, typename T, glm::qualifier Q>
+inline constexpr auto
+ratio(glm::vec<2, T, Q> v)
+{
+ return ratio<R>(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<glm::vec4, 4> 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);