aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-05-04 18:53:58 +0100
committerest31 <MTest31@outlook.com>2015-05-04 22:41:13 +0200
commit9345ba7b6a6cd19e0af0f51be1154ae571332f04 (patch)
tree5a25f7fe58e8ff659b870ecfb76d6fddd942cd6c
parent5fa4fed09731fa869cfcee5c15e53d9fbdedc28b (diff)
downloadminetest-9345ba7b6a6cd19e0af0f51be1154ae571332f04.tar.gz
minetest-9345ba7b6a6cd19e0af0f51be1154ae571332f04.tar.bz2
minetest-9345ba7b6a6cd19e0af0f51be1154ae571332f04.zip
Clouds: Make cloud area radius settable in .conf
-rw-r--r--minetest.conf.example3
-rw-r--r--src/clouds.cpp45
-rw-r--r--src/clouds.h1
-rw-r--r--src/defaultsettings.cpp1
4 files changed, 28 insertions, 22 deletions
diff --git a/minetest.conf.example b/minetest.conf.example
index 8967eff23..2475235a2 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -142,6 +142,9 @@
# Enable/disable clouds
#enable_clouds = true
#cloud_height = 120
+# Radius of cloud area stated in number of 64 node cloud squares.
+# Values > 22 will start to produce clipping of the cloud area corners.
+#cloud_radius = 12
#enable_3d_clouds = true
# Use a cloud animation for the main menu background
#menu_clouds = true
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)");