X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclouds.cpp;h=3409aac73ab6b08a8015950534ee470cbd6558e7;hb=e0889c6c03d48fabc15adf06af811ab2bfc2fe23;hp=9f0bc06d8fc22a187ebd5e736f9aad51dcd80c80;hpb=22e186b4aa88b585e71500c4e9a03bf69b0b6191;p=dragonfireclient.git diff --git a/src/clouds.cpp b/src/clouds.cpp index 9f0bc06d8..3409aac73 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -21,20 +21,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "noise.h" #include "constants.h" #include "debug.h" -#include "main.h" // For g_profiler and g_settings #include "profiler.h" #include "settings.h" + +// Menu clouds are created later +class Clouds; +Clouds *g_menuclouds = NULL; +irr::scene::ISceneManager *g_menucloudsmgr = NULL; + Clouds::Clouds( scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, - u32 seed + u32 seed, + s16 cloudheight ): scene::ISceneNode(parent, mgr, id), m_seed(seed), m_camera_pos(0,0), - m_time(0) + m_time(0), + m_camera_offset(0,0,0) { m_material.setFlag(video::EMF_LIGHTING, false); //m_material.setFlag(video::EMF_BACK_FACE_CULLING, false); @@ -45,7 +52,8 @@ Clouds::Clouds( //m_material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - m_cloud_y = BS * g_settings->getS16("cloud_height"); + m_cloud_y = BS * (cloudheight ? cloudheight : + g_settings->getS16("cloud_height")); m_box = core::aabbox3d(-BS*1000000,m_cloud_y-BS,-BS*1000000, BS*1000000,m_cloud_y+BS,BS*1000000); @@ -92,13 +100,13 @@ void Clouds::render() */ const s16 cloud_radius_i = 12; - const float cloud_size = BS*64; - const v2f cloud_speed(0, -BS*2); + const float cloud_size = BS * 64; + const v2f cloud_speed(0, -BS * 2); const float cloud_full_radius = cloud_size * cloud_radius_i; // Position of cloud noise origin in world coordinates - v2f world_cloud_origin_pos_f = m_time*cloud_speed; + v2f world_cloud_origin_pos_f = m_time * cloud_speed; // Position of cloud noise origin from the camera v2f cloud_origin_from_camera_f = world_cloud_origin_pos_f - m_camera_pos; // The center point of drawing in the noise @@ -157,36 +165,31 @@ void Clouds::render() // Read noise - bool *grid = new bool[cloud_radius_i*2*cloud_radius_i*2]; + bool *grid = new bool[cloud_radius_i * 2 * cloud_radius_i * 2]; - for(s16 zi=-cloud_radius_i; zi= 0.80); -#endif -#if 1 - double noise = noise2d_perlin( - (float)p_in_noise_i.X*cloud_size/BS/200, - (float)p_in_noise_i.Y*cloud_size/BS/200, - m_seed, 3, 0.5); - grid[i] = (noise >= 0.4); -#endif + 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 xi = -cloud_radius_i; xi < cloud_radius_i; xi++) { + u32 i = si + xi; + + v2s16 p_in_noise_i( + xi + center_of_drawing_in_noise_i.X, + zi + center_of_drawing_in_noise_i.Y + ); + + double noise = noise2d_perlin( + (float)p_in_noise_i.X * cloud_size_noise, + (float)p_in_noise_i.Y * cloud_size_noise, + m_seed, 3, 0.5); + grid[i] = (noise >= 0.4); + } } #define GETINDEX(x, z, radius) (((z)+(radius))*(radius)*2 + (x)+(radius)) -#define CONTAINS(x, z, radius) \ +#define INAREA(x, z, radius) \ ((x) >= -(radius) && (x) < (radius) && (z) >= -(radius) && (z) < (radius)) for(s16 zi0=-cloud_radius_i; zi0