diff options
author | Ben Deutsch <ben@bendeutsch.de> | 2017-05-07 18:41:47 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2017-07-05 15:39:49 +0200 |
commit | 6bedb6de408d531c1843888edc6576040c368695 (patch) | |
tree | 1415a26e8f4f97121687f9ef8b7f21590ea88f8e /src/sky.cpp | |
parent | 61a3de42fd9c7c24c06ba8522e4240d4f5e3a04f (diff) | |
download | minetest-6bedb6de408d531c1843888edc6576040c368695.tar.gz minetest-6bedb6de408d531c1843888edc6576040c368695.tar.bz2 minetest-6bedb6de408d531c1843888edc6576040c368695.zip |
Fog effect when camera is inside cloud
Fixes issue #3576
* Clouds now take camera position as 3D, not 2D
* Cloud grid filling extracted to gridFilled method
* Clouds detect whether camera is inside cloud
* Camera in cloud changes fog by overriding sky colors
with cloud color
* Sun, moon and stars can be temporarily disabled
with setBodiesVisible
* Disabling fog also disables all "inside cloud" behaviors
Diffstat (limited to 'src/sky.cpp')
-rw-r--r-- | src/sky.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sky.cpp b/src/sky.cpp index 463400194..d92697f30 100644 --- a/src/sky.cpp +++ b/src/sky.cpp @@ -233,6 +233,10 @@ void Sky::render() vertices[3] = video::S3DVertex(-1, -1.0, 1, 0, 1, 0, c, t, o); driver->drawIndexedTriangleFan(&vertices[0], 4, indices, 2); + // If sun, moon and stars are (temporarily) disabled, abort here + if (!m_bodies_visible) + return; + driver->setMaterial(m_materials[2]); // Draw sunrise/sunset horizon glow texture (textures/base/pack/sunrisebg.png) @@ -412,8 +416,8 @@ void Sky::render() } // Draw stars - driver->setMaterial(m_materials[1]); do { + driver->setMaterial(m_materials[1]); float starbrightness = MYMAX(0, MYMIN(1, (0.285 - fabs(wicked_time_of_day < 0.5 ? wicked_time_of_day : (1.0 - wicked_time_of_day))) * 10)); @@ -501,6 +505,7 @@ void Sky::update(float time_of_day, float time_brightness, m_time_of_day = time_of_day; m_time_brightness = time_brightness; m_sunlight_seen = sunlight_seen; + m_bodies_visible = true; bool is_dawn = (time_brightness >= 0.20 && time_brightness < 0.35); |