summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:04:31 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:04:31 +0000
commit6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6 (patch)
tree46c42bcbef1f12c4f46d53b4e0c4736bea506b51 /game/vehicles
parentUnified crossProduct (diff)
downloadilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.bz2
ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.xz
ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.zip
Template Ray on position type
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/railVehicle.cpp6
-rw-r--r--game/vehicles/railVehicle.h4
-rw-r--r--game/vehicles/train.cpp4
-rw-r--r--game/vehicles/train.h4
4 files changed, 9 insertions, 9 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index c720eb6..985e9f2 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -44,7 +44,7 @@ RailVehicle::move(const Train * t, float & trailBy)
}
bool
-RailVehicle::intersectRay(const Ray & ray, BaryPosition & baryPos, RelativeDistance & distance) const
+RailVehicle::intersectRay(const Ray<GlobalPosition3D> & ray, BaryPosition & baryPos, RelativeDistance & distance) const
{
constexpr const auto X = 1350.F;
const auto Y = this->rvClass->length / 2.F;
@@ -73,7 +73,7 @@ RailVehicle::intersectRay(const Ray & ray, BaryPosition & baryPos, RelativeDista
}};
return std::any_of(
triangles.begin(), triangles.end(), [&cornerVertices, &ray, &baryPos, &distance](const auto & idx) {
- return glm::intersectRayTriangle(ray.start, ray.direction, cornerVertices[idx[0]],
- cornerVertices[idx[1]], cornerVertices[idx[2]], baryPos, distance);
+ return ray.intersectTriangle(
+ cornerVertices[idx[0]], cornerVertices[idx[1]], cornerVertices[idx[2]], baryPos, distance);
});
}
diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h
index f6e4764..bf1e782 100644
--- a/game/vehicles/railVehicle.h
+++ b/game/vehicles/railVehicle.h
@@ -7,7 +7,7 @@
#include <glm/glm.hpp>
#include <memory>
-class Ray;
+template<typename> class Ray;
class Train;
class RailVehicle : Selectable, RailVehicleClass::Instance {
@@ -16,7 +16,7 @@ public:
void move(const Train *, float & trailBy);
- [[nodiscard]] bool intersectRay(const Ray &, BaryPosition &, RelativeDistance &) const override;
+ [[nodiscard]] bool intersectRay(const Ray<GlobalPosition3D> &, BaryPosition &, RelativeDistance &) const override;
RailVehicleClassPtr rvClass;
using LV = RailVehicleClass::LocationVertex;
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index 05b2d8a..5bddd61 100644
--- a/game/vehicles/train.cpp
+++ b/game/vehicles/train.cpp
@@ -9,7 +9,7 @@
#include <optional>
#include <utility>
-class Ray;
+template<typename> class Ray;
Location
Train::getBogiePosition(float linkDist, float dist) const
@@ -20,7 +20,7 @@ Train::getBogiePosition(float linkDist, float dist) const
}
bool
-Train::intersectRay(const Ray & ray, BaryPosition & baryPos, RelativeDistance & distance) const
+Train::intersectRay(const Ray<GlobalPosition3D> & ray, BaryPosition & baryPos, RelativeDistance & distance) const
{
return applyOne(&RailVehicle::intersectRay, ray, baryPos, distance) != end();
}
diff --git a/game/vehicles/train.h b/game/vehicles/train.h
index bb668ed..4320103 100644
--- a/game/vehicles/train.h
+++ b/game/vehicles/train.h
@@ -13,7 +13,7 @@
class SceneShader;
class ShadowMapper;
-class Ray;
+template<typename> class Ray;
class Train : public Vehicle, public Collection<RailVehicle, false>, public Can<Go>, public Can<Idle> {
public:
@@ -25,7 +25,7 @@ public:
return objects.front()->location;
}
- [[nodiscard]] bool intersectRay(const Ray &, BaryPosition &, RelativeDistance &) const override;
+ [[nodiscard]] bool intersectRay(const Ray<GlobalPosition3D> &, BaryPosition &, RelativeDistance &) const override;
void tick(TickDuration elapsed) override;
void doActivity(Go *, TickDuration) override;