diff options
author | Kahrl <kahrl@gmx.net> | 2011-09-07 19:21:28 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2011-09-07 19:21:28 +0200 |
commit | c0b35fa429c68b49b2d6a5124aff6dcc31400b63 (patch) | |
tree | 32a3c9856e7f34bf1055177ba3f939624dc0c695 /src/map.cpp | |
parent | d28ea57083481bff8180249fc8b43f7ed7b18545 (diff) | |
download | minetest-c0b35fa429c68b49b2d6a5124aff6dcc31400b63.tar.gz minetest-c0b35fa429c68b49b2d6a5124aff6dcc31400b63.tar.bz2 minetest-c0b35fa429c68b49b2d6a5124aff6dcc31400b63.zip |
Removed unused camera_position and camera_direction fields from Client. Moved ClientEnvironment::drawPostFx to ClientMap::renderPostFx -- this will make the camera management classes easier to write, as ClientMap already knows the camera position but ClientEnvironment doesn't and has to be told about it. This also eliminates the need for Client::getEnv(). Made the post effect color a content feature defined in content_mapnode.h.
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp index 7de79c75d..6f22498fe 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3925,6 +3925,35 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) <<", rendered "<<vertex_count<<" vertices."<<std::endl;*/ } +void ClientMap::renderPostFx() +{ + // Sadly ISceneManager has no "post effects" render pass, in that case we + // could just register for that and handle it in renderMap(). + + m_camera_mutex.Lock(); + v3f camera_position = m_camera_position; + m_camera_mutex.Unlock(); + + MapNode n = getNodeNoEx(floatToInt(camera_position, BS)); + + // - If the player is in a solid node, make everything black. + // - If the player is in liquid, draw a semi-transparent overlay. + ContentFeatures& features = content_features(n); + video::SColor post_effect_color = features.post_effect_color; + if(features.solidness == 2 && g_settings.getBool("free_move") == false) + { + post_effect_color = video::SColor(255, 0, 0, 0); + } + if (post_effect_color.getAlpha() != 0) + { + // Draw a full-screen rectangle + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + v2u32 ss = driver->getScreenSize(); + core::rect<s32> rect(0,0, ss.X, ss.Y); + driver->draw2DRectangle(post_effect_color, rect); + } +} + bool ClientMap::setTempMod(v3s16 p, NodeMod mod, core::map<v3s16, MapBlock*> *affected_blocks) { |