summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/geoData.cpp18
-rw-r--r--game/geoData.h4
2 files changed, 10 insertions, 12 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;
}
diff --git a/game/geoData.h b/game/geoData.h
index 7bd6ae5..a296205 100644
--- a/game/geoData.h
+++ b/game/geoData.h
@@ -34,7 +34,7 @@ public:
class RayTracer {
public:
- RayTracer(glm::vec2 p0, glm::vec2 p1, float scale);
+ RayTracer(glm::vec2 p0, glm::vec2 p1);
glm::vec2 next();
@@ -42,7 +42,7 @@ public:
glm::vec2 p;
const glm::vec2 d;
float error;
- glm::vec3 inc;
+ glm::vec2 inc;
};
protected: