aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clouds.cpp45
-rw-r--r--src/clouds.h1
-rw-r--r--src/defaultsettings.cpp1
3 files changed, 25 insertions, 22 deletions
diff --git a/src/clouds.cpp b/src/clouds.cpp
index 3409aac73..ff3f603d9 100644
--- a/src/clouds.cpp
+++ b/src/clouds.cpp
@@ -55,6 +55,8 @@ Clouds::Clouds(
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);
@@ -96,14 +98,13 @@ void Clouds::render()
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;
@@ -165,14 +166,14 @@ void Clouds::render()
// 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(
@@ -192,23 +193,23 @@ void Clouds::render()
#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;
@@ -247,8 +248,8 @@ void Clouds::render()
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;
}
@@ -262,8 +263,8 @@ void Clouds::render()
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;
}
@@ -277,8 +278,8 @@ void Clouds::render()
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;
}
@@ -292,8 +293,8 @@ void Clouds::render()
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;
}
diff --git a/src/clouds.h b/src/clouds.h
index add8a7247..70f12239e 100644
--- a/src/clouds.h
+++ b/src/clouds.h
@@ -87,6 +87,7 @@ private:
video::SMaterial m_material;
core::aabbox3d<f32> m_box;
float m_cloud_y;
+ u16 m_cloud_radius_i;
video::SColorf m_color;
u32 m_seed;
v2f m_camera_pos;
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index e629377ee..45188f791 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -127,6 +127,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("fall_bobbing_amount", "0.0");
settings->setDefault("enable_3d_clouds", "true");
settings->setDefault("cloud_height", "120");
+ settings->setDefault("cloud_radius", "12");
settings->setDefault("menu_clouds", "true");
settings->setDefault("opaque_water", "false");
settings->setDefault("console_color", "(0,0,0)");