Skip to content

Commit dfc715e

Browse files
committed
feat: Make precipitation response to camera movement
1 parent 6a55f3b commit dfc715e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Source/RunActivity/Viewer3D/Precipitation.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2009 - 2023 by the Open Rails project.
1+
// COPYRIGHT 2009 - 2023 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -261,7 +261,7 @@ public void Update(float currentTime, ElapsedTime elapsedTime, float particlesPe
261261
var tiles = viewer.Tiles;
262262
var scenery = viewer.World.Scenery;
263263
var worldLocation = viewer.Camera.CameraWorldLocation;
264-
var particleDirection2D = viewer.Simulator.Weather.WindInstantaneousDirection * viewer.Simulator.Weather.WindInstantaneousSpeedMpS;
264+
var particleDirection2D = viewer.World.WeatherControl.PrecipitationSlewMpS;
265265
var particleDirection3D = new Vector3(particleDirection2D.X, 0, particleDirection2D.Y);
266266

267267
if (TimeParticlesLastEmitted == 0)

Source/RunActivity/Viewer3D/Weather.cs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class WeatherControl
4848
public readonly List<SoundSourceBase> WeatherSounds = new List<SoundSourceBase>();
4949

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

5253
Vector2 CloudScale;
5354
Vector2 CloudPositionM;
@@ -240,6 +241,7 @@ private void UpdateWind(ElapsedTime elapsedTime)
240241

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

0 commit comments

Comments
 (0)