m_cloud_y = BS * (cloudheight ? cloudheight :
g_settings->getS16("cloud_height"));
+ m_cloud_radius_i = g_settings->getU16("cloud_radius");
+
m_box = core::aabbox3d<f32>(-BS*1000000,m_cloud_y-BS,-BS*1000000,
BS*1000000,m_cloud_y+BS,BS*1000000);
driver->setMaterial(m_material);
/*
- Clouds move from X+ towards X-
+ Clouds move from Z+ towards Z-
*/
- const s16 cloud_radius_i = 12;
const float cloud_size = BS * 64;
const v2f cloud_speed(0, -BS * 2);
- const float cloud_full_radius = cloud_size * cloud_radius_i;
+ const float cloud_full_radius = cloud_size * m_cloud_radius_i;
// Position of cloud noise origin in world coordinates
v2f world_cloud_origin_pos_f = m_time * cloud_speed;
// Read noise
- bool *grid = new bool[cloud_radius_i * 2 * cloud_radius_i * 2];
+ bool *grid = new bool[m_cloud_radius_i * 2 * m_cloud_radius_i * 2];
float cloud_size_noise = cloud_size / BS / 200;
- for(s16 zi = -cloud_radius_i; zi < cloud_radius_i; zi++) {
- u32 si = (zi + cloud_radius_i) * cloud_radius_i * 2 + cloud_radius_i;
+ for(s16 zi = -m_cloud_radius_i; zi < m_cloud_radius_i; zi++) {
+ u32 si = (zi + m_cloud_radius_i) * m_cloud_radius_i * 2 + m_cloud_radius_i;
- for(s16 xi = -cloud_radius_i; xi < cloud_radius_i; xi++) {
+ for (s16 xi = -m_cloud_radius_i; xi < m_cloud_radius_i; xi++) {
u32 i = si + xi;
v2s16 p_in_noise_i(
#define INAREA(x, z, radius) \
((x) >= -(radius) && (x) < (radius) && (z) >= -(radius) && (z) < (radius))
- for(s16 zi0=-cloud_radius_i; zi0<cloud_radius_i; zi0++)
- for(s16 xi0=-cloud_radius_i; xi0<cloud_radius_i; xi0++)
+ for (s16 zi0= -m_cloud_radius_i; zi0 < m_cloud_radius_i; zi0++)
+ for (s16 xi0= -m_cloud_radius_i; xi0 < m_cloud_radius_i; xi0++)
{
s16 zi = zi0;
s16 xi = xi0;
// Draw from front to back (needed for transparency)
/*if(zi <= 0)
- zi = -cloud_radius_i - zi;
+ zi = -m_cloud_radius_i - zi;
if(xi <= 0)
- xi = -cloud_radius_i - xi;*/
+ xi = -m_cloud_radius_i - xi;*/
// Draw from back to front
if(zi >= 0)
- zi = cloud_radius_i - zi - 1;
+ zi = m_cloud_radius_i - zi - 1;
if(xi >= 0)
- xi = cloud_radius_i - xi - 1;
+ xi = m_cloud_radius_i - xi - 1;
- u32 i = GETINDEX(xi, zi, cloud_radius_i);
+ u32 i = GETINDEX(xi, zi, m_cloud_radius_i);
if(grid[i] == false)
continue;
v[3].Pos.set( rx, ry,-rz);
break;
case 1: // back
- if(INAREA(xi, zi-1, cloud_radius_i)){
- u32 j = GETINDEX(xi, zi-1, cloud_radius_i);
+ if (INAREA(xi, zi - 1, m_cloud_radius_i)) {
+ u32 j = GETINDEX(xi, zi - 1, m_cloud_radius_i);
if(grid[j])
continue;
}
v[3].Pos.set(-rx,-ry,-rz);
break;
case 2: //right
- if(INAREA(xi+1, zi, cloud_radius_i)){
- u32 j = GETINDEX(xi+1, zi, cloud_radius_i);
+ if (INAREA(xi + 1, zi, m_cloud_radius_i)) {
+ u32 j = GETINDEX(xi+1, zi, m_cloud_radius_i);
if(grid[j])
continue;
}
v[3].Pos.set( rx,-ry,-rz);
break;
case 3: // front
- if(INAREA(xi, zi+1, cloud_radius_i)){
- u32 j = GETINDEX(xi, zi+1, cloud_radius_i);
+ if (INAREA(xi, zi + 1, m_cloud_radius_i)) {
+ u32 j = GETINDEX(xi, zi + 1, m_cloud_radius_i);
if(grid[j])
continue;
}
v[3].Pos.set( rx,-ry, rz);
break;
case 4: // left
- if(INAREA(xi-1, zi, cloud_radius_i)){
- u32 j = GETINDEX(xi-1, zi, cloud_radius_i);
+ if (INAREA(xi-1, zi, m_cloud_radius_i)) {
+ u32 j = GETINDEX(xi-1, zi, m_cloud_radius_i);
if(grid[j])
continue;
}