aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-05-04 22:50:04 +0200
committerest31 <MTest31@outlook.com>2015-05-04 22:50:04 +0200
commit4b0f5fcbf5a52b234f0571ad521707998be320f7 (patch)
tree416c6a545e813e3014bc337d27c847600e444c4c
parent9345ba7b6a6cd19e0af0f51be1154ae571332f04 (diff)
downloadminetest-4b0f5fcbf5a52b234f0571ad521707998be320f7.tar.gz
minetest-4b0f5fcbf5a52b234f0571ad521707998be320f7.tar.bz2
minetest-4b0f5fcbf5a52b234f0571ad521707998be320f7.zip
Cache enable_3d_clouds flag
Small improvement on clouds rendering performance
-rw-r--r--src/clouds.cpp7
-rw-r--r--src/clouds.h1
2 files changed, 5 insertions, 3 deletions
diff --git a/src/clouds.cpp b/src/clouds.cpp
index ff3f603d9..a42e588aa 100644
--- a/src/clouds.cpp
+++ b/src/clouds.cpp
@@ -57,6 +57,8 @@ Clouds::Clouds(
m_cloud_radius_i = g_settings->getU16("cloud_radius");
+ m_enable_3d = g_settings->getBool("enable_3d_clouds");
+
m_box = core::aabbox3d<f32>(-BS*1000000,m_cloud_y-BS,-BS*1000000,
BS*1000000,m_cloud_y+BS,BS*1000000);
@@ -89,10 +91,9 @@ void Clouds::render()
ScopeProfiler sp(g_profiler, "Rendering of clouds, avg", SPT_AVG);
- bool enable_3d = g_settings->getBool("enable_3d_clouds");
- int num_faces_to_draw = enable_3d ? 6 : 1;
+ int num_faces_to_draw = m_enable_3d ? 6 : 1;
- m_material.setFlag(video::EMF_BACK_FACE_CULLING, enable_3d);
+ m_material.setFlag(video::EMF_BACK_FACE_CULLING, m_enable_3d);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->setMaterial(m_material);
diff --git a/src/clouds.h b/src/clouds.h
index 70f12239e..348220fb1 100644
--- a/src/clouds.h
+++ b/src/clouds.h
@@ -88,6 +88,7 @@ private:
core::aabbox3d<f32> m_box;
float m_cloud_y;
u16 m_cloud_radius_i;
+ bool m_enable_3d;
video::SColorf m_color;
u32 m_seed;
v2f m_camera_pos;