diff options
-rw-r--r-- | game/selectable.h | 2 | ||||
-rw-r--r-- | game/vehicles/railVehicle.cpp | 4 | ||||
-rw-r--r-- | game/vehicles/railVehicle.h | 3 | ||||
-rw-r--r-- | game/vehicles/train.cpp | 2 | ||||
-rw-r--r-- | game/vehicles/train.h | 4 | ||||
-rw-r--r-- | ui/gameMainSelector.cpp | 7 |
6 files changed, 9 insertions, 13 deletions
diff --git a/game/selectable.h b/game/selectable.h index 9732dca..c794461 100644 --- a/game/selectable.h +++ b/game/selectable.h @@ -12,5 +12,5 @@ public: virtual ~Selectable() = default; DEFAULT_MOVE_COPY(Selectable); - [[nodiscard]] virtual bool intersectRay(const Ray &, Position2D *, float *) const = 0; + [[nodiscard]] virtual bool intersectRay(const Ray &, BaryPosition &, RelativeDistance &) const = 0; }; diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index 7e4b1ee..6653333 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, float * distance) const +RailVehicle::intersectRay(const Ray & ray, BaryPosition & baryPos, RelativeDistance & distance) const { constexpr const auto X = 1350.F; const auto Y = this->rvClass->length / 2.F; @@ -80,6 +80,6 @@ RailVehicle::intersectRay(const Ray & ray, BaryPosition * baryPos, float * dista 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); + cornerVertices[idx[1]], cornerVertices[idx[2]], baryPos, distance); }); } diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h index 8cbc49d..f6e4764 100644 --- a/game/vehicles/railVehicle.h +++ b/game/vehicles/railVehicle.h @@ -6,7 +6,6 @@ #include <game/selectable.h> #include <glm/glm.hpp> #include <memory> -#include <utility> class Ray; class Train; @@ -17,7 +16,7 @@ public: void move(const Train *, float & trailBy); - [[nodiscard]] bool intersectRay(const Ray &, BaryPosition *, float *) const override; + [[nodiscard]] bool intersectRay(const Ray &, BaryPosition &, RelativeDistance &) const override; RailVehicleClassPtr rvClass; using LV = RailVehicleClass::LocationVertex; diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp index 13905a3..05b2d8a 100644 --- a/game/vehicles/train.cpp +++ b/game/vehicles/train.cpp @@ -20,7 +20,7 @@ Train::getBogiePosition(float linkDist, float dist) const } bool -Train::intersectRay(const Ray & ray, BaryPosition * baryPos, float * distance) const +Train::intersectRay(const Ray & 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 c77cd23..bb668ed 100644 --- a/game/vehicles/train.h +++ b/game/vehicles/train.h @@ -10,8 +10,6 @@ #include <collection.h> #include <glm/glm.hpp> #include <location.h> -#include <memory> -#include <vector> class SceneShader; class ShadowMapper; @@ -27,7 +25,7 @@ public: return objects.front()->location; } - [[nodiscard]] bool intersectRay(const Ray &, BaryPosition *, float *) const override; + [[nodiscard]] bool intersectRay(const Ray &, BaryPosition &, RelativeDistance &) const override; void tick(TickDuration elapsed) override; void doActivity(Go *, TickDuration) override; diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp index a451ee1..703cfab 100644 --- a/ui/gameMainSelector.cpp +++ b/ui/gameMainSelector.cpp @@ -73,11 +73,10 @@ GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos) void GameMainSelector::defaultClick(const Ray & ray) { - Position2D baryPos {}; - float distance {}; + BaryPosition baryPos {}; + RelativeDistance distance {}; - if (const auto selected - = gameState->world.applyOne<Selectable>(&Selectable::intersectRay, ray, &baryPos, &distance); + if (const auto selected = gameState->world.applyOne<Selectable>(&Selectable::intersectRay, ray, baryPos, distance); selected != gameState->world.end()) { const auto & ref = *selected.base()->get(); clicked = typeid(ref).name(); |