Skip to content

Commit 0e8771e

Browse files
committed
Automatic merge of T1.5.1-722-g01614a154 and 17 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 3b5a2fe: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 90255fb: Blueprint/train car operations UI window - Pull request #885 at c81447b: feat: Add notifications to Menu - Pull request #886 at 697a4b6: Scene viewer extension to TrackViewer - Pull request #888 at d7daf62: docs: Document player application model - Pull request #890 at 39a9fa4: Allow depart early - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #893 at bf8876b: Signal errors - Pull request #894 at 794fddf: Correct Decrease Colour - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 0a9d939: feat: Improved system information collection - Pull request #898 at e271395: Extra line with all the arguments for debugging purposes in logfile
19 parents 122ea76 + 01614a1 + c59c788 + d00beb9 + 3b5a2fe + f8dbeab + 43bf33e + f92de76 + 90255fb + c81447b + 697a4b6 + d7daf62 + 39a9fa4 + 1f5ba4c + bf8876b + 794fddf + 5866028 + 0a9d939 + e271395 commit 0e8771e

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

Source/Contrib/TrackViewer/SceneViewer.cs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class SceneViewer
5353
OrbitingCamera Camera;
5454

5555
EditorState EditorState;
56+
EditorMoveState EditorMoveState;
5657
StaticShape SelectedObject;
5758
WorldFile SelectedWorldFile;
5859
Orts.Formats.Msts.WorldObject SelectedWorldObject;
@@ -109,11 +110,6 @@ public void Show()
109110
SceneWindow.Activate();
110111
}
111112

112-
/// <summary>
113-
/// Allows the game to run logic such as updating the world,
114-
/// checking for collisions, gathering input, and playing audio.
115-
/// </summary>
116-
/// <param name="gameTime">Provides a snapshot of timing values.</param>
117113
public void Update(GameTime gameTime)
118114
{
119115
Viewer = Viewer ?? Game.RenderProcess?.Viewer;
@@ -155,19 +151,29 @@ public void Update(GameTime gameTime)
155151
{
156152
if (UserInput.IsPressed(UserCommand.EditorMove))
157153
{
154+
EditorMoveState = EditorMoveState.Move;
155+
StartObjectMove();
156+
}
157+
if (UserInput.IsPressed(UserCommand.EditorRotate))
158+
{
159+
EditorMoveState = EditorMoveState.Rotate;
158160
StartObjectMove();
159161
}
160162
if (UserInput.IsPressed(UserCommand.EditorMoveHandle))
161163
{
164+
EditorMoveState = EditorMoveState.Move;
162165
StartHandleMove();
163166
}
164167
}
165168
if (EditorState == EditorState.HandleMoving)
166169
{
167170
if (UserInput.IsPressed(UserCommand.EditorMove))
168171
{
169-
CancelHandleMove();
170-
StartObjectMove();
172+
EditorMoveState = EditorMoveState.Move;
173+
}
174+
if (UserInput.IsPressed(UserCommand.EditorRotate))
175+
{
176+
EditorMoveState = EditorMoveState.Rotate;
171177
}
172178
if (UserInput.IsPressed(UserCommand.EditorCancel))
173179
{
@@ -180,10 +186,13 @@ public void Update(GameTime gameTime)
180186
}
181187
if (EditorState == EditorState.ObjectMoving)
182188
{
183-
if (UserInput.IsPressed(UserCommand.EditorMoveHandle))
189+
if (UserInput.IsPressed(UserCommand.EditorMove))
184190
{
185-
CancelObjectMove();
186-
StartHandleMove();
191+
EditorMoveState = EditorMoveState.Move;
192+
}
193+
if (UserInput.IsPressed(UserCommand.EditorRotate))
194+
{
195+
EditorMoveState = EditorMoveState.Rotate;
187196
}
188197
if (UserInput.IsPressed(UserCommand.EditorCancel))
189198
{
@@ -315,7 +324,7 @@ Matrix GetMovingMatrix(in WorldPosition originalPosition, in WorldPosition handl
315324
var handle = handleOriginalPosition ?? originalPosition;
316325
var xnaMatrix = originalPosition.XNAMatrix;
317326

318-
if (UserInput.IsDown(UserCommand.EditorLockRotation))
327+
if (EditorMoveState == EditorMoveState.Rotate)
319328
{
320329
var distance = WorldLocation.GetDistance(handle.WorldLocation, CursorLocation);
321330
distance.Z *= -1;
@@ -337,8 +346,12 @@ Matrix GetMovingMatrix(in WorldPosition originalPosition, in WorldPosition handl
337346
handleMatrix.Translation += translation;
338347
handlePosition.XNAMatrix = handleMatrix;
339348
}
349+
350+
DeltaX = 0;
351+
DeltaY = MathHelper.ToDegrees(angle);
352+
DeltaZ = 0;
340353
}
341-
else
354+
else if (EditorMoveState == EditorMoveState.Move)
342355
{
343356
var distance = WorldLocation.GetDistance(originalPosition.WorldLocation, CursorLocation);
344357
distance.Z *= -1;
@@ -461,16 +474,9 @@ void UndoRedo(UndoDataSet undoDataSet, bool undo)
461474
}
462475
else if (undoDataSet.UndoEvent == UndoEvent.WorldObjectChanged)
463476
{
464-
if (undo)
465-
{
466-
var newPosition = new WorldPosition(undoDataSet.ChangedStaticShape.Location);
467-
undoDataSet.ChangedStaticShape.Location.CopyFrom(undoDataSet.OldPosition);
468-
undoDataSet.OldPosition.CopyFrom(newPosition);
469-
}
470-
else
471-
{
472-
473-
}
477+
var newPosition = new WorldPosition(undoDataSet.ChangedStaticShape.Location);
478+
undoDataSet.ChangedStaticShape.Location.CopyFrom(undoDataSet.OldPosition);
479+
undoDataSet.OldPosition.CopyFrom(newPosition);
474480
}
475481
}
476482

@@ -500,8 +506,8 @@ void ApplyObjectMove()
500506
TileZ = MovedObject.Location.TileZ,
501507
Uid = MovedObject.Uid,
502508
ChangedStaticShape = MovedObject,
503-
OldPosition = MovedObjectOriginalPosition,
504-
MovedWithRespectTo = HandlePosition ?? MovedObject.Location,
509+
OldPosition = new WorldPosition(MovedObjectOriginalPosition),
510+
MoveOrigin = HandlePosition,
505511
});
506512
RedoStack.Clear();
507513

@@ -593,7 +599,7 @@ public class UndoDataSet
593599
public int Uid;
594600
public StaticShape ChangedStaticShape;
595601
public WorldPosition OldPosition;
596-
public WorldPosition MovedWithRespectTo;
602+
public WorldPosition MoveOrigin;
597603
public Orts.Formats.Msts.WorldObject OldWorldObject;
598604
public Orts.Formats.Msts.WorldObject NewWorldObject;
599605

@@ -620,6 +626,12 @@ public enum EditorState
620626
HandleMoving,
621627
}
622628

629+
public enum EditorMoveState
630+
{
631+
Move,
632+
Rotate,
633+
}
634+
623635
public class SceneViewerHwndHost : HwndHost
624636
{
625637
readonly IntPtr HwndChildHandle;

Source/ORTS.Common/Coordinates.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void CopyFrom(WorldPosition copy)
186186
{
187187
TileX = copy.TileX;
188188
TileZ = copy.TileZ;
189-
Location = copy.Location;
189+
XNAMatrix = copy.XNAMatrix;
190190
}
191191
}
192192

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,6 @@ public enum UserCommand
260260
[GetString("Editor Move Handle")] EditorMoveHandle,
261261
[GetString("Editor Move Orthogonal")] EditorLockOrthogonal,
262262
[GetString("Editor Move Orthogonal")] EditorLockElevation,
263-
[GetString("Editor Move Orthogonal")] EditorLockRotation,
263+
[GetString("Editor Move Orthogonal")] EditorRotate,
264264
}
265265
}

Source/ORTS.Settings/InputSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static void InitializeCommands(UserCommandInput[] Commands)
547547
Commands[(int)UserCommand.EditorMoveHandle] = new UserCommandKeyInput(Keys.M, KeyModifiers.Alt);
548548
Commands[(int)UserCommand.EditorLockOrthogonal] = new UserCommandModifierInput(KeyModifiers.Shift);
549549
Commands[(int)UserCommand.EditorLockElevation] = new UserCommandModifierInput(KeyModifiers.Control);
550-
Commands[(int)UserCommand.EditorLockRotation] = new UserCommandKeyInput(Keys.R);
550+
Commands[(int)UserCommand.EditorRotate] = new UserCommandKeyInput(Keys.R);
551551
}
552552
#endregion
553553

0 commit comments

Comments
 (0)