From c88a83c7a6f7addf89f8528dabc5b4f5fc9e04c5 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 13 Jun 2009 22:34:07 +0100 Subject: [PATCH] Tidy up point transformation code --- src/Points.cpp | 33 +++++---------------------------- src/Train.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/Points.cpp b/src/Points.cpp index 790b5e6..172e12e 100644 --- a/src/Points.cpp +++ b/src/Points.cpp @@ -215,42 +215,22 @@ void Points::transform(const track::TravelToken& aToken, double aDelta) const const float angle = radToDeg(atanf(deriv.y / deriv.x)); - if (myAxis == -axis::X && aToken.direction == axis::X) { + if (myAxis == -axis::X) { xTrans = 1.0f - curveValue.x; yTrans = amReflected ? curveValue.y : -curveValue.y; rotate = amReflected ? angle : -angle; } - else if (myAxis == -axis::X && aToken.direction == -axis::X) { - xTrans = 1.0f - curveValue.x; - yTrans = amReflected ? curveValue.y : -curveValue.y; - rotate = amReflected ? angle : -angle; - } - else if (myAxis == axis::X && aToken.direction == -axis::X) { + else if (myAxis == axis::X) { xTrans = curveValue.x; yTrans = amReflected ? -curveValue.y : curveValue.y; rotate = amReflected ? angle : -angle; } - else if (myAxis == axis::X && aToken.direction == axis::X) { - xTrans = curveValue.x; - yTrans = amReflected ? -curveValue.y : curveValue.y; - rotate = amReflected ? angle : -angle; - } - else if (myAxis == -axis::Y && aToken.direction == axis::Y) { - xTrans = amReflected ? -curveValue.y : curveValue.y; - yTrans = 1.0f - curveValue.x; - rotate = amReflected ? angle : -angle; - } - else if (myAxis == -axis::Y && aToken.direction == -axis::Y) { + else if (myAxis == -axis::Y) { xTrans = amReflected ? -curveValue.y : curveValue.y; yTrans = 1.0f - curveValue.x; rotate = amReflected ? angle : -angle; } - else if (myAxis == axis::Y && aToken.direction == -axis::Y) { - xTrans = amReflected ? curveValue.y : -curveValue.y; - yTrans = curveValue.x; - rotate = amReflected ? angle : -angle; - } - else if (myAxis == axis::Y && aToken.direction == axis::Y) { + else if (myAxis == axis::Y) { xTrans = amReflected ? curveValue.y : -curveValue.y; yTrans = curveValue.x; rotate = amReflected ? angle : -angle; @@ -295,10 +275,7 @@ bool Points::isValidDirection(const track::Direction& aDirection) const track::Connection Points::nextPosition(const track::TravelToken& aToken) const { bool branching = aToken.activeChoice != track::CHOOSE_STRAIGHT_ON; - - debug() << "axis=" << myAxis << " dir=" << aToken.direction - << " r=" << amReflected; - + if (myAxis == axis::X) { if (aToken.direction == -axis::X) { // Two possible entry points diff --git a/src/Train.cpp b/src/Train.cpp index 98a5d0b..99c251a 100644 --- a/src/Train.cpp +++ b/src/Train.cpp @@ -45,7 +45,8 @@ private: // The different parts of the train are on different track segments struct Part { explicit Part(IRollingStockPtr aVehicle) - : vehicle(aVehicle), segmentDelta(0.0) {} + : vehicle(aVehicle), segmentDelta(0.0) + {} IRollingStockPtr vehicle; @@ -57,7 +58,7 @@ private: track::TravelToken travelToken; // Direction train part is travelling along the track - Vector direction; + Vector direction; }; list myParts; @@ -92,7 +93,7 @@ Train::Train(IMapPtr aMap) // Bit of a hack to put the engine in the right place move(0.275); - for (int i = 1; i <= 0; i++) + for (int i = 1; i <= 5; i++) addPart(makeWaggon()); mySmokeTrail = makeSmokeTrail(); -- 2.39.2