summaryrefslogtreecommitdiff
path: root/game/geoData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r--game/geoData.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp
index 4537026..32ec55e 100644
--- a/game/geoData.cpp
+++ b/game/geoData.cpp
@@ -95,30 +95,28 @@ GeoData::positionAt(const glm::vec2 wcoord) const
return wcoord || heightMid;
}
-GeoData::RayTracer::RayTracer(glm::vec2 p0, glm::vec2 p1, float scale) : p {glm::floor(p0)}, d {glm::abs(p1 - p0)}
+GeoData::RayTracer::RayTracer(glm::vec2 p0, glm::vec2 p1) : p {glm::floor(p0)}, d {glm::abs(p1)}
{
using Limits = std::numeric_limits<typename glm::vec2::value_type>;
static_assert(Limits::has_infinity);
- static constexpr const glm::vec2 inf {Limits::infinity(), -Limits::infinity()};
- auto byAxis = [this, p0, p1, scale](auto axis) {
+ auto byAxis = [this, p0, p1](auto axis) {
if (d[axis] == 0) {
inc[axis] = 0;
- return inf[axis];
+ return Limits::infinity();
}
- else if (p1[axis] > p0[axis]) {
- inc[axis] = scale;
- return (std::floor(p0[axis]) + 1 - p0[axis]) * d[1 - axis];
+ else if (p1[axis] > 0) {
+ inc[axis] = 1;
+ return (std::floor(p0[axis]) + 1.F - p0[axis]) * d[1 - axis];
}
else {
- inc[axis] = -scale;
+ inc[axis] = -1;
return (p0[axis] - std::floor(p0[axis])) * d[1 - axis];
}
};
error = byAxis(0);
error -= byAxis(1);
- inc.z = scale;
}
glm::vec2
@@ -129,7 +127,7 @@ GeoData::RayTracer::next()
static constexpr const glm::vec2 m {1, -1};
const int axis = (error > 0) ? 1 : 0;
p[axis] += inc[axis];
- error += d[1 - axis] * m[axis] * inc.z;
+ error += d[1 - axis] * m[axis];
return cur;
}