aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2022-05-20 22:33:52 +0200
committerGitHub <noreply@github.com>2022-05-20 22:33:52 +0200
commit604fb2b738c1f369c608b7f3b778034bf3dc2725 (patch)
treebbdcf4ef77af6f7058b115e3e4c24ab34e164988 /src/client
parent273bfee9a193d0dd2e9f9b400add980c0b5202a7 (diff)
downloadminetest-604fb2b738c1f369c608b7f3b778034bf3dc2725.tar.gz
minetest-604fb2b738c1f369c608b7f3b778034bf3dc2725.tar.bz2
minetest-604fb2b738c1f369c608b7f3b778034bf3dc2725.zip
Fix lighting of the wield mesh (#12341)
* Assign node light to player before final color blend. Fixes day/night lightbank ratio for wield meshes * Update wield mesh light when changing mesh
Diffstat (limited to 'src/client')
-rw-r--r--src/client/camera.cpp10
-rw-r--r--src/client/camera.h3
-rw-r--r--src/client/clientenvironment.cpp1
3 files changed, 11 insertions, 3 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp
index d1f19adb3..7cc9cb6e8 100644
--- a/src/client/camera.cpp
+++ b/src/client/camera.cpp
@@ -47,7 +47,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Camera::Camera(MapDrawControl &draw_control, Client *client, RenderingEngine *rendering_engine):
m_draw_control(draw_control),
- m_client(client)
+ m_client(client),
+ m_player_light_color(0xFFFFFFFF)
{
auto smgr = rendering_engine->get_scene_manager();
// note: making the camera node a child of the player node
@@ -153,8 +154,10 @@ void Camera::step(f32 dtime)
bool was_under_zero = m_wield_change_timer < 0;
m_wield_change_timer = MYMIN(m_wield_change_timer + dtime, 0.125);
- if (m_wield_change_timer >= 0 && was_under_zero)
+ if (m_wield_change_timer >= 0 && was_under_zero) {
m_wieldnode->setItem(m_wield_item_next, m_client);
+ m_wieldnode->setNodeLightColor(m_player_light_color);
+ }
if (m_view_bobbing_state != 0)
{
@@ -555,7 +558,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 tool_reload_ratio)
m_wieldnode->setPosition(wield_position);
m_wieldnode->setRotation(wield_rotation);
- m_wieldnode->setNodeLightColor(player->light_color);
+ m_player_light_color = player->light_color;
+ m_wieldnode->setNodeLightColor(m_player_light_color);
// Set render distance
updateViewingRange();
diff --git a/src/client/camera.h b/src/client/camera.h
index 403d6024c..cbf248d97 100644
--- a/src/client/camera.h
+++ b/src/client/camera.h
@@ -264,4 +264,7 @@ private:
std::list<Nametag *> m_nametags;
bool m_show_nametag_backgrounds;
+
+ // Last known light color of the player
+ video::SColor m_player_light_color;
};
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 448af36c6..183a95007 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -305,6 +305,7 @@ void ClientEnvironment::step(float dtime)
node_at_lplayer = m_map->getNode(p);
u16 light = getInteriorLight(node_at_lplayer, 0, m_client->ndef());
+ lplayer->light_color = encode_light(light, 0); // this transfers light.alpha
final_color_blend(&lplayer->light_color, light, day_night_ratio);
}