diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-15 11:41:27 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-16 15:43:15 +0000 |
commit | 92cba8dfe1034aa6fe7f2178183411a14efcd983 (patch) | |
tree | 761fb81db114d0b02348b1050e1a960a5e9412b8 | |
parent | Process UI layers in reverse, so it's stack like (diff) | |
download | ilt-92cba8dfe1034aa6fe7f2178183411a14efcd983.tar.bz2 ilt-92cba8dfe1034aa6fe7f2178183411a14efcd983.tar.xz ilt-92cba8dfe1034aa6fe7f2178183411a14efcd983.zip |
We know the last param is distance now
-rw-r--r-- | game/vehicles/railVehicle.cpp | 6 | ||||
-rw-r--r-- | game/vehicles/train.cpp | 4 | ||||
-rw-r--r-- | ui/gameMainWindow.cpp | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index 9ad1ea7..ec12674 100644 --- a/game/vehicles/railVehicle.cpp +++ b/game/vehicles/railVehicle.cpp @@ -30,7 +30,7 @@ RailVehicle::move(const Train * t, float & trailBy) } bool -RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * eh) const +RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * distance) const { constexpr const auto X = 1.35F; const auto Y = this->rvClass->length / 2.F; @@ -64,8 +64,8 @@ RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * eh) cons {3, 6, 7}, }}; return std::any_of( - triangles.begin(), triangles.end(), [&cornerVertices, &ray, &baryPos, &eh](const glm::uvec3 idx) { + triangles.begin(), triangles.end(), [&cornerVertices, &ray, &baryPos, &distance](const glm::uvec3 idx) { return glm::intersectRayTriangle(ray.start, ray.direction, cornerVertices[idx[0]], - cornerVertices[idx[1]], cornerVertices[idx[2]], *baryPos, *eh); + cornerVertices[idx[1]], cornerVertices[idx[2]], *baryPos, *distance); }); } diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp index 05915c4..d1122f8 100644 --- a/game/vehicles/train.cpp +++ b/game/vehicles/train.cpp @@ -26,9 +26,9 @@ Train::getBogiePosition(float linkDist, float dist) const } bool -Train::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * eh) const +Train::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * distance) const { - return applyOne(&RailVehicle::intersectRay, ray, baryPos, eh) != end(); + return applyOne(&RailVehicle::intersectRay, ray, baryPos, distance) != end(); } void diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index b559341..f895a20 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -60,11 +60,11 @@ public: const auto mouse = glm::vec2 {e.button.x, e.button.y} / position.size; glm::vec2 baryPos {}; - float eh; + float distance; const auto ray = camera->unProject(mouse); - if (const auto selected - = gameState->world.applyOne<Selectable>(&Selectable::intersectRay, ray, &baryPos, &eh); + 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(); |