From 0aa665c3648d788755b00c9e431c872d57fddbb8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Nov 2023 16:28:39 +0000 Subject: Model positions as integers Introduces test failure in arcs due to rounding, but I don't want to create a complicated fix as link positions are still floats and hopefully that'll go away... somehow --- game/vehicles/railVehicle.cpp | 22 +++++++++++----------- game/vehicles/railVehicleClass.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'game/vehicles') diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index bee0dd0..30b615c 100644 --- a/game/vehicles/railVehicle.cpp +++ b/game/vehicles/railVehicle.cpp @@ -38,9 +38,9 @@ RailVehicle::move(const Train * t, float & trailBy) const auto overhang {(rvClass->length - rvClass->wheelBase) / 2}; const auto & b1Pos = bogies[0] = t->getBogiePosition(t->linkDist, trailBy += overhang); const auto & b2Pos = bogies[1] = t->getBogiePosition(t->linkDist, trailBy += rvClass->wheelBase); - const auto diff = glm::normalize(b2Pos.position() - b1Pos.position()); - location.setLocation((b1Pos.position() + b2Pos.position()) / 2.F, {vector_pitch(diff), vector_yaw(diff), 0}); - trailBy += 0.6F + overhang; + const auto diff = glm::normalize(RelativePosition3D(b2Pos.position() - b1Pos.position())); + location.setLocation((b1Pos.position() + b2Pos.position()) / 2, {vector_pitch(diff), vector_yaw(diff), 0}); + trailBy += 600.F + overhang; } bool @@ -51,14 +51,14 @@ RailVehicle::intersectRay(const Ray & ray, Position2D * baryPos, float * distanc constexpr const auto Z = 3900.F; const auto moveBy = location.getRotationTransform(); const std::array cornerVertices {{ - location.position() + (moveBy * glm::vec4 {-X, Y, 0, 1}).xyz(), // LFB - location.position() + (moveBy * glm::vec4 {X, Y, 0, 1}).xyz(), // RFB - location.position() + (moveBy * glm::vec4 {-X, Y, Z, 1}).xyz(), // LFT - location.position() + (moveBy * glm::vec4 {X, Y, Z, 1}).xyz(), // RFT - location.position() + (moveBy * glm::vec4 {-X, -Y, 0, 1}).xyz(), // LBB - location.position() + (moveBy * glm::vec4 {X, -Y, 0, 1}).xyz(), // RBB - location.position() + (moveBy * glm::vec4 {-X, -Y, Z, 1}).xyz(), // LBT - location.position() + (moveBy * glm::vec4 {X, -Y, Z, 1}).xyz(), // RBT + location.position() + GlobalPosition3D(moveBy * glm::vec4 {-X, Y, 0, 1}).xyz(), // LFB + location.position() + GlobalPosition3D(moveBy * glm::vec4 {X, Y, 0, 1}).xyz(), // RFB + location.position() + GlobalPosition3D(moveBy * glm::vec4 {-X, Y, Z, 1}).xyz(), // LFT + location.position() + GlobalPosition3D(moveBy * glm::vec4 {X, Y, Z, 1}).xyz(), // RFT + location.position() + GlobalPosition3D(moveBy * glm::vec4 {-X, -Y, 0, 1}).xyz(), // LBB + location.position() + GlobalPosition3D(moveBy * glm::vec4 {X, -Y, 0, 1}).xyz(), // RBB + location.position() + GlobalPosition3D(moveBy * glm::vec4 {-X, -Y, Z, 1}).xyz(), // LBT + location.position() + GlobalPosition3D(moveBy * glm::vec4 {X, -Y, Z, 1}).xyz(), // RBT }}; static constexpr const std::array, 10> triangles {{ // Front diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h index 16dce01..913feea 100644 --- a/game/vehicles/railVehicleClass.h +++ b/game/vehicles/railVehicleClass.h @@ -20,7 +20,7 @@ public: struct LocationVertex { glm::mat4 body, front, back; - Position3D bodyPos, frontPos, backPos; + GlobalPosition3D bodyPos, frontPos, backPos; }; std::array bogies; -- cgit v1.2.3