1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 07:38:48 -05:00

Clouds: Make cloud area radius settable in .conf

This commit is contained in:
paramat 2015-05-04 18:53:58 +01:00 committed by est31
parent 5fa4fed097
commit 9345ba7b6a
4 changed files with 28 additions and 22 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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)");