From 6005388908b3630bf4d70b33a2d3e9de00e7f770 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 10 Dec 2018 09:27:39 +0100
Subject: [PATCH] reconsider gear selection during engage

---
 .../SimulationComponent/Impl/AMTShiftStrategyV2.cs       | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
index 29b0992537..ca9f35bce0 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategyV2.cs
@@ -548,6 +548,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity)
 		{
+			//_nextGear = gear;
+			while (_nextGear > 1 && SpeedTooLowForEngine(_nextGear, outAngularVelocity)) {
+				_nextGear--;
+			}
+			while (_nextGear < ModelData.Gears.Count &&
+					SpeedTooHighForEngine(_nextGear, outAngularVelocity)) {
+				_nextGear++;
+			}
+
 			return _nextGear;
 		}
 
-- 
GitLab