From dcef947ea986f4ad4633189652abccebdd7aa3f6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 6 Jan 2024 13:03:42 +0000 Subject: Helper to create a cubiod from dimensions --- game/vehicles/railVehicle.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'game/vehicles') diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index 94f72e4..c720eb6 100644 --- a/game/vehicles/railVehicle.cpp +++ b/game/vehicles/railVehicle.cpp @@ -3,12 +3,12 @@ #include "train.h" #include #include +#include #include #include #include #include #include -#include #include RailVehicle::RailVehicle(RailVehicleClassPtr rvc) : @@ -50,16 +50,10 @@ RailVehicle::intersectRay(const Ray & ray, BaryPosition & baryPos, RelativeDista const auto Y = this->rvClass->length / 2.F; constexpr const auto Z = 3900.F; const glm::mat3 moveBy = location.getRotationTransform(); - const std::array cornerVertices {{ - location.position() + GlobalPosition3D(moveBy * glm::vec3 {-X, Y, 0}), // LFB - location.position() + GlobalPosition3D(moveBy * glm::vec3 {X, Y, 0}), // RFB - location.position() + GlobalPosition3D(moveBy * glm::vec3 {-X, Y, Z}), // LFT - location.position() + GlobalPosition3D(moveBy * glm::vec3 {X, Y, Z}), // RFT - location.position() + GlobalPosition3D(moveBy * glm::vec3 {-X, -Y, 0}), // LBB - location.position() + GlobalPosition3D(moveBy * glm::vec3 {X, -Y, 0}), // RBB - location.position() + GlobalPosition3D(moveBy * glm::vec3 {-X, -Y, Z}), // LBT - location.position() + GlobalPosition3D(moveBy * glm::vec3 {X, -Y, Z}), // RBT - }}; + const auto cornerVertices + = cuboidCorners(-X, X, -Y, Y, 0.F, Z) * [&moveBy, this](const auto & corner) -> Position3D { + return location.position() + GlobalPosition3D(moveBy * corner); + }; static constexpr const std::array, 10> triangles {{ // Front {0, 1, 2}, -- cgit v1.2.3