1- // COPYRIGHT 2010, 2011, 2012, 2013, 2014 by the Open Rails project.
1+ // COPYRIGHT 2009 - 2023 by the Open Rails project.
22//
33// This file is part of Open Rails.
44//
@@ -33,13 +33,7 @@ public class PrecipitationViewer
3333 {
3434 public const float MinIntensityPPSPM2 = 0 ;
3535
36- // 16 bit version.
37- public const float MaxIntensityPPSPM2_16 = 0.010f ;
38-
39- // Default 32 bit version.
40- public const float MaxIntensityPPSPM2 = 0.035f ;
41-
42- public static bool IndexesAre32bit ;
36+ public const float MaxIntensityPPSPM2 = 0.015f ;
4337
4438 readonly Viewer Viewer ;
4539 readonly Weather Weather ;
@@ -51,8 +45,6 @@ public class PrecipitationViewer
5145
5246 public PrecipitationViewer ( Viewer viewer )
5347 {
54- IndexesAre32bit = viewer . Settings . IsDirectXFeatureLevelIncluded ( ORTS . Settings . UserSettings . DirectXFeature . Level10_0 ) ;
55-
5648 Viewer = viewer ;
5749 Weather = viewer . Simulator . Weather ;
5850
@@ -114,14 +106,9 @@ public class PrecipitationPrimitive : RenderPrimitive
114106 // This is a fiddle factor because the above values feel too slow. Alternative suggestions welcome.
115107 const float ParticleVelocityFactor = 10.0f ;
116108
117- readonly float ParticleBoxLengthM ;
118- readonly float ParticleBoxWidthM ;
119- readonly float ParticleBoxHeightM ;
120-
121- // 16bit Box Parameters
122- const float ParticleBoxLengthM_16 = 500 ;
123- const float ParticleBoxWidthM_16 = 500 ;
124- const float ParticleBoxHeightM_16 = 43 ;
109+ const float ParticleBoxLengthM = 500 ;
110+ const float ParticleBoxWidthM = 500 ;
111+ const float ParticleBoxHeightM = 43 ;
125112
126113 const int IndicesPerParticle = 6 ;
127114 const int VerticiesPerParticle = 4 ;
@@ -170,51 +157,14 @@ struct ParticleVertex
170157 public PrecipitationPrimitive ( GraphicsDevice graphicsDevice )
171158 {
172159 // Snow is the slower particle, hence longer duration, hence more particles in total.
173- // Setting the precipitation box size based on GraphicsDeviceCapabilities.
174- if ( PrecipitationViewer . IndexesAre32bit )
175- {
176- ParticleBoxLengthM = ( float ) Program . Simulator . Settings . PrecipitationBoxLength ;
177- ParticleBoxWidthM = ( float ) Program . Simulator . Settings . PrecipitationBoxWidth ;
178- ParticleBoxHeightM = ( float ) Program . Simulator . Settings . PrecipitationBoxHeight ;
179- }
180- else
181- {
182- ParticleBoxLengthM = ParticleBoxLengthM_16 ;
183- ParticleBoxWidthM = ParticleBoxWidthM_16 ;
184- ParticleBoxHeightM = ParticleBoxHeightM_16 ;
185- }
186-
187- if ( PrecipitationViewer . IndexesAre32bit )
188- {
189- MaxParticles = ( int ) ( PrecipitationViewer . MaxIntensityPPSPM2 * ParticleBoxLengthM * ParticleBoxWidthM * ParticleBoxHeightM / SnowVelocityMpS / ParticleVelocityFactor ) ;
190- }
191-
192- // Processing 16bit device
193- else
194- {
195- MaxParticles = ( int ) ( PrecipitationViewer . MaxIntensityPPSPM2_16 * ParticleBoxLengthM * ParticleBoxWidthM * ParticleBoxHeightM / SnowVelocityMpS / ParticleVelocityFactor ) ;
196- }
197-
198- // Checking if graphics device is 16bit.
199- if ( ! PrecipitationViewer . IndexesAre32bit )
200- {
201- Debug . Assert ( MaxParticles * VerticiesPerParticle < ushort . MaxValue , "The maximum number of precipitation verticies must be able to fit in a ushort (16bit unsigned) index buffer." ) ;
202- }
160+ MaxParticles = ( int ) ( PrecipitationViewer . MaxIntensityPPSPM2 * ParticleBoxLengthM * ParticleBoxWidthM * ParticleBoxHeightM / SnowVelocityMpS / ParticleVelocityFactor ) ;
161+ Debug . Assert ( MaxParticles * VerticiesPerParticle < ushort . MaxValue , "The maximum number of precipitation verticies must be able to fit in a ushort (16bit unsigned) index buffer." ) ;
203162
204163 Vertices = new ParticleVertex [ MaxParticles * VerticiesPerParticle ] ;
205164 VertexDeclaration = new VertexDeclaration ( ParticleVertex . SizeInBytes , ParticleVertex . VertexElements ) ;
206165 VertexStride = Marshal . SizeOf ( typeof ( ParticleVertex ) ) ;
207166 VertexBuffer = new DynamicVertexBuffer ( graphicsDevice , VertexDeclaration , MaxParticles * VerticiesPerParticle , BufferUsage . WriteOnly ) ;
208-
209- // Processing either 32bit or 16bit InitIndexBuffer depending on GraphicsDeviceCapabilities.
210- if ( PrecipitationViewer . IndexesAre32bit )
211- {
212- IndexBuffer = InitIndexBuffer ( graphicsDevice , MaxParticles * IndicesPerParticle ) ;
213- }
214- else
215- {
216- IndexBuffer = InitIndexBuffer16 ( graphicsDevice , MaxParticles * IndicesPerParticle ) ;
217- }
167+ IndexBuffer = InitIndexBuffer ( graphicsDevice , MaxParticles * IndicesPerParticle ) ;
218168
219169 Heights = new HeightCache ( 8 ) ;
220170
@@ -227,31 +177,7 @@ void VertexBuffer_ContentLost()
227177 VertexBuffer . SetData ( 0 , Vertices , 0 , Vertices . Length , VertexStride , SetDataOptions . NoOverwrite ) ;
228178 }
229179
230- // IndexBuffer for 32bit process.
231180 static IndexBuffer InitIndexBuffer ( GraphicsDevice graphicsDevice , int numIndices )
232- {
233- var indices = new uint [ numIndices ] ;
234- var index = 0 ;
235- for ( var i = 0 ; i < numIndices ; i += IndicesPerParticle )
236- {
237- indices [ i ] = ( uint ) index ;
238- indices [ i + 1 ] = ( uint ) ( index + 1 ) ;
239- indices [ i + 2 ] = ( uint ) ( index + 2 ) ;
240-
241- indices [ i + 3 ] = ( uint ) ( index + 2 ) ;
242- indices [ i + 4 ] = ( uint ) ( index + 3 ) ;
243- indices [ i + 5 ] = ( uint ) index ;
244-
245- index += VerticiesPerParticle ;
246- }
247-
248- var indexBuffer = new IndexBuffer ( graphicsDevice , typeof ( uint ) , numIndices , BufferUsage . WriteOnly ) ;
249- indexBuffer . SetData ( indices ) ;
250- return indexBuffer ;
251- }
252-
253- // IndexBuffer for computers that still use 16bit graphics.
254- static IndexBuffer InitIndexBuffer16 ( GraphicsDevice graphicsDevice , int numIndices )
255181 {
256182 var indices = new ushort [ numIndices ] ;
257183 var index = 0 ;
@@ -347,7 +273,6 @@ public void Update(float currentTime, ElapsedTime elapsedTime, float particlesPe
347273 var tiles = viewer . Tiles ;
348274 var scenery = viewer . World . Scenery ;
349275 var worldLocation = viewer . Camera . CameraWorldLocation ;
350- //var worldLocation = Program.Viewer.PlayerLocomotive.WorldPosition.WorldLocation; // This is used to test overall precipitation position.
351276
352277 if ( TimeParticlesLastEmitted == 0 )
353278 {
0 commit comments