]> git.lizzy.rs Git - minetest.git/blobdiff - src/clouds.cpp
tile: don't duplicate std::string::find_last_of
[minetest.git] / src / clouds.cpp
index 19bcca942fbf606e98aeca9e5bd231572f5ac720..23243659707bb8c56ddc2a9ce72f920d57d5e4f9 100644 (file)
@@ -21,6 +21,9 @@ 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"
 
 Clouds::Clouds(
                scene::ISceneNode* parent,
@@ -76,6 +79,12 @@ void Clouds::render()
        if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID)
                return;
 
+       ScopeProfiler sp(g_profiler, "Rendering of clouds, avg", SPT_AVG);
+
+       int num_faces_to_draw = 1;
+       if(g_settings->getBool("enable_3d_clouds"))
+               num_faces_to_draw = 6;
+
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
        driver->setMaterial(m_material);
        
@@ -84,7 +93,7 @@ void Clouds::render()
        */
 
        const s16 cloud_radius_i = 12;
-       const float cloud_size = BS*50;
+       const float cloud_size = BS*48;
        const v2f cloud_speed(-BS*2, 0);
        
        // Position of cloud noise origin in world coordinates
@@ -123,7 +132,7 @@ void Clouds::render()
                                (float)p_in_noise_i.X*cloud_size/BS/200,
                                (float)p_in_noise_i.Y*cloud_size/BS/200,
                                m_seed, 3, 0.4);
-               if(noise < 0.8)
+               if(noise < 0.95)
                        continue;
 
                float b = m_brightness;
@@ -144,7 +153,7 @@ void Clouds::render()
                f32 ry = 8*BS;
                f32 rz = cloud_size;
 
-               for(int i=0;i<6;i++)
+               for(int i=0; i<num_faces_to_draw; i++)
                {
                        switch(i)
                        {