Skip to content

Commit

Permalink
Cache enable_3d_clouds flag
Browse files Browse the repository at this point in the history
Small improvement on clouds rendering performance
  • Loading branch information
est31 committed May 4, 2015
1 parent 9345ba7 commit 4b0f5fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/clouds.cpp
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/clouds.h
Expand Up @@ -88,6 +88,7 @@ class Clouds : public scene::ISceneNode
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;
Expand Down

0 comments on commit 4b0f5fc

Please sign in to comment.