1
- // COPYRIGHT 2010, 2011, 2012, 2013, 2014 by the Open Rails project.
1
+ // COPYRIGHT 2009 - 2023 by the Open Rails project.
2
2
//
3
3
// This file is part of Open Rails.
4
4
//
@@ -33,13 +33,7 @@ public class PrecipitationViewer
33
33
{
34
34
public const float MinIntensityPPSPM2 = 0 ;
35
35
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 ;
43
37
44
38
readonly Viewer Viewer ;
45
39
readonly Weather Weather ;
@@ -51,8 +45,6 @@ public class PrecipitationViewer
51
45
52
46
public PrecipitationViewer ( Viewer viewer )
53
47
{
54
- IndexesAre32bit = viewer . Settings . IsDirectXFeatureLevelIncluded ( ORTS . Settings . UserSettings . DirectXFeature . Level10_0 ) ;
55
-
56
48
Viewer = viewer ;
57
49
Weather = viewer . Simulator . Weather ;
58
50
@@ -114,14 +106,9 @@ public class PrecipitationPrimitive : RenderPrimitive
114
106
// This is a fiddle factor because the above values feel too slow. Alternative suggestions welcome.
115
107
const float ParticleVelocityFactor = 10.0f ;
116
108
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 ;
125
112
126
113
const int IndicesPerParticle = 6 ;
127
114
const int VerticiesPerParticle = 4 ;
@@ -170,51 +157,14 @@ struct ParticleVertex
170
157
public PrecipitationPrimitive ( GraphicsDevice graphicsDevice )
171
158
{
172
159
// 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." ) ;
203
162
204
163
Vertices = new ParticleVertex [ MaxParticles * VerticiesPerParticle ] ;
205
164
VertexDeclaration = new VertexDeclaration ( ParticleVertex . SizeInBytes , ParticleVertex . VertexElements ) ;
206
165
VertexStride = Marshal . SizeOf ( typeof ( ParticleVertex ) ) ;
207
166
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 ) ;
218
168
219
169
Heights = new HeightCache ( 8 ) ;
220
170
@@ -227,31 +177,7 @@ void VertexBuffer_ContentLost()
227
177
VertexBuffer . SetData ( 0 , Vertices , 0 , Vertices . Length , VertexStride , SetDataOptions . NoOverwrite ) ;
228
178
}
229
179
230
- // IndexBuffer for 32bit process.
231
180
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 )
255
181
{
256
182
var indices = new ushort [ numIndices ] ;
257
183
var index = 0 ;
@@ -347,7 +273,6 @@ public void Update(float currentTime, ElapsedTime elapsedTime, float particlesPe
347
273
var tiles = viewer . Tiles ;
348
274
var scenery = viewer . World . Scenery ;
349
275
var worldLocation = viewer . Camera . CameraWorldLocation ;
350
- //var worldLocation = Program.Viewer.PlayerLocomotive.WorldPosition.WorldLocation; // This is used to test overall precipitation position.
351
276
352
277
if ( TimeParticlesLastEmitted == 0 )
353
278
{
0 commit comments