summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-09 00:40:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-09 00:40:40 +0000
commit9c2c3f71065c94a18c02440111b6ff8ca977b90e (patch)
tree339c9846cdd6937a5e77b37f88e3ee3674f944e5 /game/vehicles
parentWIP typedefing all the things - headers (diff)
downloadilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.bz2
ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.tar.xz
ilt-9c2c3f71065c94a18c02440111b6ff8ca977b90e.zip
WIP typedefing all the things - sources
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/railVehicle.cpp12
-rw-r--r--game/vehicles/train.cpp2
2 files changed, 7 insertions, 7 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index 2d820b6..fc43995 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -14,8 +14,8 @@
RailVehicle::RailVehicle(RailVehicleClassPtr rvc) :
RailVehicleClass::Instance {rvc->instances.acquire()}, rvClass {std::move(rvc)}, location {&LV::body, *this},
bogies {{
- {&LV::front, *this, glm::vec3 {0, rvClass->wheelBase / 2.F, 0}},
- {&LV::back, *this, glm::vec3 {0, -rvClass->wheelBase / 2.F, 0}},
+ {&LV::front, *this, Position3D {0, rvClass->wheelBase / 2.F, 0}},
+ {&LV::back, *this, Position3D {0, -rvClass->wheelBase / 2.F, 0}},
}}
{
}
@@ -32,13 +32,13 @@ RailVehicle::move(const Train * t, float & trailBy)
}
bool
-RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * distance) const
+RailVehicle::intersectRay(const Ray & ray, Position2D * baryPos, float * distance) const
{
constexpr const auto X = 1.35F;
const auto Y = this->rvClass->length / 2.F;
constexpr const auto Z = 3.9F;
const auto moveBy = location.getTransform();
- const std::array<glm::vec3, 8> cornerVertices {{
+ const std::array<Position3D, 8> cornerVertices {{
moveBy * glm::vec4 {-X, Y, 0, 1}, // LFB
moveBy * glm::vec4 {X, Y, 0, 1}, // RFB
moveBy * glm::vec4 {-X, Y, Z, 1}, // LFT
@@ -48,7 +48,7 @@ RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * distance
moveBy * glm::vec4 {-X, -Y, Z, 1}, // LBT
moveBy * glm::vec4 {X, -Y, Z, 1}, // RBT
}};
- static constexpr const std::array<glm::uvec3, 10> triangles {{
+ static constexpr const std::array<glm::vec<3, uint8_t>, 10> triangles {{
// Front
{0, 1, 2},
{1, 2, 3},
@@ -66,7 +66,7 @@ RailVehicle::intersectRay(const Ray & ray, glm::vec2 * baryPos, float * distance
{3, 6, 7},
}};
return std::any_of(
- triangles.begin(), triangles.end(), [&cornerVertices, &ray, &baryPos, &distance](const glm::uvec3 idx) {
+ 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);
});
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index 6f3b036..4aa24dc 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, glm::vec2 * baryPos, float * distance) const
+Train::intersectRay(const Ray & ray, Position2D * baryPos, float * distance) const
{
return applyOne(&RailVehicle::intersectRay, ray, baryPos, distance) != end();
}