summaryrefslogtreecommitdiff
path: root/game/vehicles/railVehicle.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 21:07:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 21:07:37 +0000
commit7c8b8a39fd36e190578587d8d92f28f460a1fc4b (patch)
tree03c0943bcec657992aa92afb91a3613eb1c8423b /game/vehicles/railVehicle.cpp
parentNo need to pass GameState around, it has a global pointer (diff)
downloadilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.tar.bz2
ilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.tar.xz
ilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.zip
Encapsulate Ray
Diffstat (limited to 'game/vehicles/railVehicle.cpp')
-rw-r--r--game/vehicles/railVehicle.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index 8d7b06f..9ad1ea7 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -9,6 +9,7 @@
#include <location.hpp>
#include <maths.h>
#include <memory>
+#include <ray.hpp>
void
RailVehicle::render(const Shader & shader) const
@@ -29,7 +30,7 @@ RailVehicle::move(const Train * t, float & trailBy)
}
bool
-RailVehicle::intersectRay(const glm::vec3 & pos, const glm::vec3 & dir, glm::vec2 * baryPos, float * eh) const
+RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * eh) const
{
constexpr const auto X = 1.35F;
const auto Y = this->rvClass->length / 2.F;
@@ -63,8 +64,8 @@ RailVehicle::intersectRay(const glm::vec3 & pos, const glm::vec3 & dir, glm::vec
{3, 6, 7},
}};
return std::any_of(
- triangles.begin(), triangles.end(), [&cornerVertices, &pos, &dir, &baryPos, &eh](const glm::uvec3 idx) {
- return glm::intersectRayTriangle(pos, dir, cornerVertices[idx[0]], cornerVertices[idx[1]],
- cornerVertices[idx[2]], *baryPos, *eh);
+ triangles.begin(), triangles.end(), [&cornerVertices, &ray, &baryPos, &eh](const glm::uvec3 idx) {
+ return glm::intersectRayTriangle(ray.start, ray.direction, cornerVertices[idx[0]],
+ cornerVertices[idx[1]], cornerVertices[idx[2]], *baryPos, *eh);
});
}