Skip to content

Commit

Permalink
feat: Make precipitation response to camera movement
Browse files Browse the repository at this point in the history
  • Loading branch information
twpol committed Apr 11, 2024
1 parent 6a55f3b commit dfc715e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/RunActivity/Viewer3D/Precipitation.cs
@@ -1,4 +1,4 @@
// COPYRIGHT 2009 - 2023 by the Open Rails project.
// COPYRIGHT 2009 - 2023 by the Open Rails project.
//
// This file is part of Open Rails.
//
Expand Down Expand Up @@ -261,7 +261,7 @@ public void Update(float currentTime, ElapsedTime elapsedTime, float particlesPe
var tiles = viewer.Tiles;
var scenery = viewer.World.Scenery;
var worldLocation = viewer.Camera.CameraWorldLocation;
var particleDirection2D = viewer.Simulator.Weather.WindInstantaneousDirection * viewer.Simulator.Weather.WindInstantaneousSpeedMpS;
var particleDirection2D = viewer.World.WeatherControl.PrecipitationSlewMpS;
var particleDirection3D = new Vector3(particleDirection2D.X, 0, particleDirection2D.Y);

if (TimeParticlesLastEmitted == 0)
Expand Down
2 changes: 2 additions & 0 deletions Source/RunActivity/Viewer3D/Weather.cs
Expand Up @@ -48,6 +48,7 @@ public class WeatherControl
public readonly List<SoundSourceBase> WeatherSounds = new List<SoundSourceBase>();

public Vector4 CloudScalePosition { get => new Vector4(CloudScale.X, CloudScale.Y, CloudPositionM.X / SkyPrimitive.RadiusM, CloudPositionM.Y / SkyPrimitive.RadiusM); }
public Vector2 PrecipitationSlewMpS { get; set; }

Vector2 CloudScale;
Vector2 CloudPositionM;
Expand Down Expand Up @@ -240,6 +241,7 @@ private void UpdateWind(ElapsedTime elapsedTime)

WorldLocation.GetDistance(CameraWorldLocation, Viewer.Camera.CameraWorldLocation).Deconstruct(out var x, out var _, out var y);
CloudPositionM += elapsedTime.ClockSeconds * Weather.WindAverageDirection * Weather.WindAverageSpeedMpS - new Vector2(x, -y);
PrecipitationSlewMpS = Weather.WindInstantaneousDirection * Weather.WindInstantaneousSpeedMpS - new Vector2(x, -y) / elapsedTime.ClockSeconds;
CameraWorldLocation = Viewer.Camera.CameraWorldLocation;
}

Expand Down

0 comments on commit dfc715e

Please sign in to comment.