Skip to content

Commit

Permalink
Automatic merge of T1.5.1-687-gd279e384a and 20 pull requests
Browse files Browse the repository at this point in the history
- 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 67014b7: 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 #878 at f9aa2ad: Implement Polach Adhesion
- Pull request #882 at d8a1c4d: Blueprint/train car operations UI window
- Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling
- Pull request #885 at c81447b: feat: Add notifications to Menu
- Pull request #886 at 228f0f0: Scene viewer extension to TrackViewer
- Pull request #887 at 4665bda: docs: Document projects, assemblies, namespaces
- Pull request #888 at d7daf62: docs: Document player application model
- Pull request #889 at 43341cf: No speed update
- 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 64a29c8: feat: Improved system information collection
  • Loading branch information
openrails-bot committed Nov 24, 2023
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 53 deletions.
26 changes: 2 additions & 24 deletions Source/Contrib/TrackViewer/SceneViewer.cs
Expand Up @@ -147,36 +147,14 @@ public void Update(GameTime gameTime)
{
SelectedObjectChanged();
}
if (UserInput.IsMouseMiddleButtonPressed && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
{
Camera.StoreRotationOrigin(Viewer.TerrainPoint);
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = false;
}
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
{
Camera.RotateByMouse();
}
else
{
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = true;
}
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(true, false, false))
{
Camera.PanByMouse();
}
else
{
Camera.ZoomByMouseWheel(1);
}

if (UserInput.IsPressed(UserCommand.EditorUnselectAll))
{
SelectedObject = null;
SelectedObjectChanged();
}

SetCameraLocationStatus(TrackViewer.RenderProcess?.Viewer?.Camera?.CameraWorldLocation ?? new WorldLocation());
//FillCursorPositionStatus(TrackViewer.RenderProcess?.Viewer?.TerrainPoint ?? new Vector3());
SetCameraLocationStatus(Camera?.CameraWorldLocation ?? new WorldLocation());
//FillCursorPositionStatus(Viewer?.TerrainPoint ?? new Vector3());
}

public void EndDraw()
Expand Down
5 changes: 2 additions & 3 deletions Source/Contrib/TrackViewer/TrackViewer.cs
Expand Up @@ -324,13 +324,14 @@ private void DrawLoadingMessage(string message)
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
SceneViewer?.Update(gameTime);

if (!this.IsTrackViewerWindowActive)
{
lostFocus = true;
if (this.IsRenderWindowActive)
{
base.Update(gameTime);
SceneViewer?.Update(gameTime);
}
return;
}
Expand Down Expand Up @@ -549,8 +550,6 @@ protected override void Update(GameTime gameTime)
SetTitle();

RenderProcess.IsMouseVisible = true;

SceneViewer?.Update(gameTime);
}

/// <summary>
Expand Down
54 changes: 36 additions & 18 deletions Source/RunActivity/Viewer3D/Cameras.cs
Expand Up @@ -806,6 +806,7 @@ public class ViewerCamera : FreeRoamCamera
{
Vector3 RotationOrigin;
Vector3 RotationDirection;
WorldLocation RotationLocation;
float RotationRadius;
float RotationReferenceAngleX;
float RotationReferenceAngleY;
Expand All @@ -817,25 +818,38 @@ public ViewerCamera(Viewer viewer)

public override void HandleUserInput(ElapsedTime elapsedTime)
{
// The UserInput code goes to the consuming class according to the architecture,
// this class is intentionally lacks calling the base(elapsedTime).
if (UserInput.IsMouseMiddleButtonPressed && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
{
StoreRotationOrigin(Viewer.TerrainPoint);
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = false;
}
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false))
{
RotateByMouse();
}
else
{
Viewer.EditorShapes.CrosshairPositionUpdateEnabled = true;
}
if (UserInput.IsMouseMiddleButtonDown && UserInput.ModifiersMaskShiftCtrlAlt(true, false, false))
{
PanByMouse();
}
else
{
ZoomByMouseWheel(GetSpeed(elapsedTime));
}
}

public override void ZoomByMouseWheel(float speed)
{
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here

ZoomIn(speed * UserInput.MouseWheelChange * ZoomFactor);
}

public override void RotateByMouse()
{
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here

RotationXRadians += GetMouseDelta(UserInput.MouseMoveY);
RotationYRadians += GetMouseDelta(UserInput.MouseMoveX);
RotationXRadians = MathHelper.WrapAngle(RotationXRadians);
RotationYRadians = MathHelper.WrapAngle(RotationYRadians);
RotationXRadians = MathHelper.WrapAngle(RotationXRadians + GetMouseDelta(UserInput.MouseMoveY));
RotationYRadians = MathHelper.WrapAngle(RotationYRadians + GetMouseDelta(UserInput.MouseMoveX));

// Method 1
//var deltaAngleX = MathHelper.WrapAngle(GetMouseDelta(UserInput.MouseMoveY));
Expand All @@ -852,27 +866,33 @@ public override void RotateByMouse()
//var deltaAngleY = MathHelper.WrapAngle(RotationYRadians - RotationReferenceAngleY);
//var transform = Matrix.CreateFromYawPitchRoll(-deltaAngleY, -deltaAngleX, 0);
//var newLocation = RotationOrigin + RotationRadius * Vector3.Transform(RotationDirection, transform);

// Method 3
//var deltaAngleX = MathHelper.WrapAngle(RotationXRadians);
//var deltaAngleY = MathHelper.WrapAngle(RotationYRadians);
//var transform = Matrix.CreateFromYawPitchRoll(-deltaAngleY, -deltaAngleX, 0);
//var newLocation = RotationOrigin + RotationRadius * Vector3.Transform(Vector3.UnitZ, transform);

//newLocation.Z *= -1;
//var newWorldLocation = CameraWorldLocation;
//var newWorldLocation = RotationLocation;
//newWorldLocation.Location = newLocation;

//SetLocation(newWorldLocation);
}

public void StoreRotationOrigin(Vector3 rotationOrigin)
{
RotationOrigin = rotationOrigin;
RotationOrigin = Viewer.TerrainPoint;
RotationLocation = CameraWorldLocation;
RotationDirection = XnaLocation(CameraWorldLocation) - RotationOrigin;
RotationRadius = RotationDirection.Length();
RotationDirection = Vector3.Normalize(RotationDirection);
RotationReferenceAngleX = RotationXRadians;
RotationReferenceAngleY = RotationYRadians;
RotationReferenceAngleX = MathHelper.WrapAngle(RotationXRadians);
RotationReferenceAngleY = MathHelper.WrapAngle(RotationYRadians);
}

public void PanByMouse()
{
// The UserInput code goes to the consuming class according to the architecture, only the functionality is implemented here

var previousFarSource = new Vector3(UserInput.MouseX - UserInput.MouseMoveX, UserInput.MouseY - UserInput.MouseMoveY, 1);
var previousFarPoint = Viewer.DefaultViewport.Unproject(previousFarSource, XnaProjection, XnaView, Matrix.Identity);
var movement = Viewer.FarPoint - previousFarPoint;
Expand All @@ -891,8 +911,6 @@ public void PanByMouse()

public bool PickByMouse(out StaticShape pickedObjectOut)
{
// The UserInput code goes to the consuming class by the accepted architecture, only the functionality is implemented here

if (Viewer == null)
{
pickedObjectOut = null;
Expand Down
7 changes: 2 additions & 5 deletions Source/RunActivity/Viewer3D/EditorPrimitives.cs
Expand Up @@ -83,11 +83,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
{
CrosshairPosition = Viewer.TerrainPoint;
}
if (CrosshairPosition != Viewer.NearPoint)
{
var mouseCrosshairMatrix = Matrix.CreateTranslation(CrosshairPosition);
frame.AddPrimitive(MouseCrosshair.Material, MouseCrosshair, RenderPrimitiveGroup.World, ref mouseCrosshairMatrix);
}
var mouseCrosshairMatrix = Matrix.CreateTranslation(CrosshairPosition);
frame.AddPrimitive(MouseCrosshair.Material, MouseCrosshair, RenderPrimitiveGroup.World, ref mouseCrosshairMatrix);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Source/RunActivity/Viewer3D/Viewer.cs
Expand Up @@ -930,14 +930,14 @@ void HandleUserInput(ElapsedTime elapsedTime)
TerrainPoint = EditorMode ? GetTerrainPoint() : NearPoint;
}

if (EditorMode)
return;

if (UserInput.IsPressed(UserCommand.CameraReset))
Camera.Reset();

Camera?.HandleUserInput(elapsedTime);

if (EditorMode)
return;

PlayerLocomotiveViewer?.HandleUserInput(elapsedTime);
InfoDisplay?.HandleUserInput(elapsedTime);
WindowManager?.HandleUserInput(elapsedTime);
Expand Down

0 comments on commit 1e8a350

Please sign in to comment.