diff options
Diffstat (limited to 'game/terrain.cpp')
-rw-r--r-- | game/terrain.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/game/terrain.cpp b/game/terrain.cpp index bf16439..ddfa31b 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -1,13 +1,13 @@ #include "terrain.h" #include "gfx/models/texture.h" #include <cache.h> -#include <cmath> #include <gfx/gl/shader.h> #include <gfx/image.h> #include <gfx/models/mesh.h> #include <gfx/models/vertex.hpp> #include <glm/glm.hpp> #include <location.hpp> +#include <maths.h> #include <random> #include <stb_image.h> @@ -41,14 +41,13 @@ Terrain::Terrain() : grass {Texture::cachedTexture.get("grass.png")}, water {Tex const glm::ivec2 hsize {rsize(gen), rsize(gen)}; if (const auto lim1 = hpos - hsize; lim1.x > 0 && lim1.y > 0) { if (const auto lim2 = hpos + hsize; lim2.x < size && lim2.y < size) { - const float height = rheight(gen); + const auto height = (float)rheight(gen); const glm::ivec2 hsizesqrd {hsize.x * hsize.x, hsize.y * hsize.y}; for (auto z = lim1.y; z < lim2.y; z += 1) { for (auto x = lim1.x; x < lim2.x; x += 1) { const auto dist {hpos - glm::ivec2 {x, z}}; const glm::ivec2 distsqrd {dist.x * dist.x, dist.y * dist.y}; - const auto out { - (pow(x - hpos.x, 2) / pow(hsize.x, 2)) + (pow(z - hpos.y, 2) / pow(hsize.y, 2))}; + const auto out {rdiv(sq(x - hpos.x), sq(hsize.x)) + rdiv(sq(z - hpos.y), sq(hsize.y))}; if (out <= 1.0) { auto & vertex = vertices[x + (z * size)]; const auto m {1.F / (7.F * out - 8.F) + 1.F}; |