diff options
author | Kahrl <kahrl@gmx.net> | 2014-11-02 03:47:43 +0100 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2014-11-08 23:11:57 +0100 |
commit | 9b551d5cbcaf71a8c39bbf7e886290649aed4799 (patch) | |
tree | 8eb68e4c9a7a006ec6c406da4760403c6748848e /src/environment.cpp | |
parent | cc8d7b86404f2830bcf09d04468e8041db276b98 (diff) | |
download | minetest-9b551d5cbcaf71a8c39bbf7e886290649aed4799.tar.gz minetest-9b551d5cbcaf71a8c39bbf7e886290649aed4799.tar.bz2 minetest-9b551d5cbcaf71a8c39bbf7e886290649aed4799.zip |
Implement WieldMeshSceneNode which improves wield mesh rendering
- Don't create and cache an extruded mesh for every (non-node) item.
Instead use a single one per image resolution.
- For cubic nodes reuse a single wield mesh too
- Improve lighting of the wielded item
- Increase far value of wield mesh scene camera, fixes #1770
- Also includes some minor refactorings of Camera and GenericCAO.
Diffstat (limited to 'src/environment.cpp')
-rw-r--r-- | src/environment.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 01a7e38dc..6e5305b1e 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SERVER #include "clientmap.h" #include "localplayer.h" +#include "mapblock_mesh.h" #include "event.h" #endif #include "daynightratio.h" @@ -2330,21 +2331,28 @@ void ClientEnvironment::step(float dtime) player->move(dtime, this, 100*BS); } - - // Update lighting on all players on client - float light = 1.0; - try{ - // Get node at head - v3s16 p = player->getLightPosition(); - MapNode n = m_map->getNode(p); - light = n.getLightBlendF1((float)getDayNightRatio()/1000, m_gamedef->ndef()); - } - catch(InvalidPositionException &e){ - light = blend_light_f1((float)getDayNightRatio()/1000, LIGHT_SUN, 0); - } - player->light = light; } - + + // Update lighting on local player (used for wield item) + u32 day_night_ratio = getDayNightRatio(); + { + // Get node at head + + // On InvalidPositionException, use this as default + // (day: LIGHT_SUN, night: 0) + MapNode node_at_lplayer(CONTENT_AIR, 0x0f, 0); + + try { + v3s16 p = lplayer->getLightPosition(); + node_at_lplayer = m_map->getNode(p); + } catch (InvalidPositionException &e) {} + + u16 light = getInteriorLight(node_at_lplayer, 0, m_gamedef->ndef()); + u8 day = light & 0xff; + u8 night = (light >> 8) & 0xff; + finalColorBlend(lplayer->light_color, day, night, day_night_ratio); + } + /* Step active objects and update lighting of them */ @@ -2367,10 +2375,10 @@ void ClientEnvironment::step(float dtime) // Get node at head v3s16 p = obj->getLightPosition(); MapNode n = m_map->getNode(p); - light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef()); + light = n.getLightBlend(day_night_ratio, m_gamedef->ndef()); } catch(InvalidPositionException &e){ - light = blend_light(getDayNightRatio(), LIGHT_SUN, 0); + light = blend_light(day_night_ratio, LIGHT_SUN, 0); } obj->updateLight(light); } |