@@ -170,8 +170,9 @@ void Clouds::render()
170
170
171
171
// Read noise
172
172
173
- bool *grid = new bool [m_cloud_radius_i * 2 * m_cloud_radius_i * 2 ];
174
-
173
+ std::vector<char > grid (m_cloud_radius_i * 2 * m_cloud_radius_i * 2 ); // vector<bool> is broken
174
+ std::vector<video::S3DVertex> vertices;
175
+ vertices.reserve (16 * m_cloud_radius_i * m_cloud_radius_i);
175
176
176
177
for (s16 zi = -m_cloud_radius_i; zi < m_cloud_radius_i; zi++) {
177
178
u32 si = (zi + m_cloud_radius_i) * m_cloud_radius_i * 2 + m_cloud_radius_i;
@@ -195,12 +196,7 @@ void Clouds::render()
195
196
{
196
197
s16 zi = zi0;
197
198
s16 xi = xi0;
198
- // Draw from front to back (needed for transparency)
199
- /* if(zi <= 0)
200
- zi = -m_cloud_radius_i - zi;
201
- if(xi <= 0)
202
- xi = -m_cloud_radius_i - xi;*/
203
- // Draw from back to front
199
+ // Draw from back to front for proper transparency
204
200
if (zi >= 0 )
205
201
zi = m_cloud_radius_i - zi - 1 ;
206
202
if (xi >= 0 )
@@ -220,17 +216,10 @@ void Clouds::render()
220
216
video::S3DVertex (0 ,0 ,0 , 0 ,0 ,0 , c_top, 0 , 0 )
221
217
};
222
218
223
- /* if(zi <= 0 && xi <= 0){
224
- v[0].Color.setBlue(255);
225
- v[1].Color.setBlue(255);
226
- v[2].Color.setBlue(255);
227
- v[3].Color.setBlue(255);
228
- }*/
229
-
230
- f32 rx = cloud_size / 2 .0f ;
219
+ const f32 rx = cloud_size / 2 .0f ;
231
220
// if clouds are flat, the top layer should be at the given height
232
- f32 ry = m_enable_3d ? m_params.thickness * BS : 0 .0f ;
233
- f32 rz = cloud_size / 2 ;
221
+ const f32 ry = m_enable_3d ? m_params.thickness * BS : 0 .0f ;
222
+ const f32 rz = cloud_size / 2 ;
234
223
235
224
for (int i=0 ; i<num_faces_to_draw; i++)
236
225
{
@@ -320,15 +309,25 @@ void Clouds::render()
320
309
v3f pos (p0.X , m_params.height * BS, p0.Y );
321
310
pos -= intToFloat (m_camera_offset, BS);
322
311
323
- for (video::S3DVertex &vertex : v)
312
+ for (video::S3DVertex &vertex : v) {
324
313
vertex.Pos += pos;
325
- u16 indices[] = {0 ,1 ,2 ,2 ,3 ,0 };
326
- driver->drawVertexPrimitiveList (v, 4 , indices, 2 ,
327
- video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
314
+ vertices.push_back (vertex);
315
+ }
328
316
}
329
317
}
330
-
331
- delete[] grid;
318
+ int quad_count = vertices.size () / 4 ;
319
+ std::vector<u16> indices;
320
+ indices.reserve (quad_count * 6 );
321
+ for (int k = 0 ; k < quad_count; k++) {
322
+ indices.push_back (4 * k + 0 );
323
+ indices.push_back (4 * k + 1 );
324
+ indices.push_back (4 * k + 2 );
325
+ indices.push_back (4 * k + 2 );
326
+ indices.push_back (4 * k + 3 );
327
+ indices.push_back (4 * k + 0 );
328
+ }
329
+ driver->drawVertexPrimitiveList (vertices.data (), vertices.size (), indices.data (), 2 * quad_count,
330
+ video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
332
331
333
332
// Restore fog settings
334
333
driver->setFog (fog_color, fog_type, fog_start, fog_end, fog_density,
0 commit comments