Skip to content

Commit

Permalink
Automatic merge of T1.5.1-243-g3ffb9bc10 and 10 pull requests
Browse files Browse the repository at this point in the history
- Pull request #719 at 0f4d975: Upgraded to MonoGame 3.8.0 (+ small update for other libraries)
- Pull request #722 at fb9079e: Fix Windows Forms deprecations in ActivityEditor
- Pull request #732 at 83002d7: Improvements for air brakes
- Pull request #735 at b9a0ea3: Added new parameter for battery switch
- Pull request #751 at f947f29: Web interface to control cab controls with external hardware
- Pull request #753 at ab8fe32: Extends CabControls for user input
- Pull request #766 at c9657de: Control Car additional functionality
- Pull request #767 at 9317f8c: Refine sunrise and sunset
- Pull request #768 at bc8aea4: OpenRailway Map enhancements
- Pull request #769 at 1a99f43: Partial turntables https://blueprints.launchpad.net/or/+spec/partial-turntable
  • Loading branch information
openrails-bot committed Jan 21, 2023
12 parents 1435554 + 3ffb9bc + 0f4d975 + fb9079e + 83002d7 + b9a0ea3 + f947f29 + ab8fe32 + c9657de + 9317f8c + bc8aea4 + 1a99f43 commit c05fe7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Documentation/Manual/features-route.rst
Expand Up @@ -208,6 +208,18 @@ TrackShape block within the tsection.dat file. You only have to insert the diame
the turntable and the degree step. Of course you have to take only the lines up to the
one preceding the one with degrees = 180.

Also turntables which may rotate less than 360 degrees can be implemented, like the one in
the picture here below:

.. image:: images/features-partial-turntable.png

In this case following line has to be added at the end of the ``Turntable()`` block
in file ``turntables.dat`` for a turntable that can rotate only between 0 and 40 degrees::

MaxAngle ( 40 )

Angles increase clockwise.

Already many existing turntables have been successfully animated and many new other
have been created. More can be read
`in this forum thread <http://www.elvastower.com/forums/index.php?/topic/28591-operational-turntable/>`_ .
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Source/Orts.Simulation/Simulation/Turntables.cs
Expand Up @@ -352,6 +352,7 @@ public class Turntable : MovingTable
public List<float> Angles = new List<float>();
public float StartingY = 0; // starting yaw angle
public float ThresholdForTarget; // Threshold to check if we can now go to the target
public float MaxAngle = -1; // max angle extension for partial turntables (in radians)
// Dynamic data
public bool Clockwise; // clockwise motion on
public bool Counterclockwise; // counterclockwise motion on
Expand Down Expand Up @@ -392,6 +393,7 @@ public Turntable(STFReader stf, Simulator simulator)
TrackShapeIndex = stf.ReadIntBlock(-1);
InitializeAnglesAndTrackNodes();
}),
new STFReader.TokenProcessor("maxangle", ()=>{ MaxAngle = MathHelper.ToRadians(stf.ReadFloatBlock(STFReader.UNITS.None , null));}),
});
}

Expand Down Expand Up @@ -636,6 +638,18 @@ public override void StartContinuous(bool isClockwise)

public void GeneralStartContinuous(bool isClockwise)
{
if (MaxAngle > 0)
{
var positiveYAngle = YAngle >= 0 ? YAngle : YAngle + 2 * (float)Math.PI;
if (!isClockwise && positiveYAngle < 0.2 || isClockwise && positiveYAngle <= 2 * (float)Math.PI - MaxAngle && positiveYAngle > 0.2)
{
Clockwise = false;
Counterclockwise = false;
Continuous = false;
if (SendNotifications) Simulator.Confirmer.Warning(Simulator.Catalog.GetStringFmt("Turntable is at its bound, can't rotate"));
return;
}
}
if (TrainsOnMovingTable.Count > 1 || (TrainsOnMovingTable.Count == 1 && TrainsOnMovingTable[0].FrontOnBoard ^ TrainsOnMovingTable[0].BackOnBoard))
{
Clockwise = false;
Expand Down
11 changes: 11 additions & 0 deletions Source/RunActivity/Viewer3D/Shapes.cs
Expand Up @@ -1594,6 +1594,17 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
AnimationKey = nextKey % animation.FrameCount;
if (AnimationKey < 0)
AnimationKey += animation.FrameCount;
// used if Turntable cannot turn 360 degrees
if (Turntable.MaxAngle > 0 && AnimationKey != 0)
{
if (AnimationKey < -SharedShape.Animations[0].FrameCount * Turntable.MaxAngle / (2 * Math.PI) + animation.FrameCount)
{
if (AnimationKey > 20)
AnimationKey = -SharedShape.Animations[0].FrameCount * Turntable.MaxAngle / (float)(2 * Math.PI) + animation.FrameCount;
else
AnimationKey = 0;
}
}
Turntable.YAngle = MathHelper.WrapAngle(nextKey / animation.FrameCount * 2 * (float)Math.PI);

if ((Turntable.Clockwise || Turntable.Counterclockwise || Turntable.AutoClockwise || Turntable.AutoCounterclockwise) && !Rotating)
Expand Down

0 comments on commit c05fe7f

Please sign in to comment.