diff options
author | Danila Shutov <dcbrwn2@gmail.com> | 2020-04-19 19:47:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 18:47:13 +0200 |
commit | cdbe3c5e5784b34e548c58b08579ff55b3096fb9 (patch) | |
tree | b751e0f348e1fd1461ac05f6ec1e04d0bed1033c /src/client | |
parent | c87d52a5fa21f31c2d68795822b48c8bf993ca6b (diff) | |
download | minetest-cdbe3c5e5784b34e548c58b08579ff55b3096fb9.tar.gz minetest-cdbe3c5e5784b34e548c58b08579ff55b3096fb9.tar.bz2 minetest-cdbe3c5e5784b34e548c58b08579ff55b3096fb9.zip |
Reuse object_shader for "wielditem" and "item" entity drawtypes (#9537)
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/camera.cpp | 2 | ||||
-rw-r--r-- | src/client/content_cao.cpp | 9 | ||||
-rw-r--r-- | src/client/wieldmesh.cpp | 17 | ||||
-rw-r--r-- | src/client/wieldmesh.h | 2 |
4 files changed, 24 insertions, 6 deletions
diff --git a/src/client/camera.cpp b/src/client/camera.cpp index fb1c3ff56..69bd82a47 100644 --- a/src/client/camera.cpp +++ b/src/client/camera.cpp @@ -542,7 +542,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r m_wieldnode->setPosition(wield_position); m_wieldnode->setRotation(wield_rotation); - m_wieldnode->setColor(player->light_color); + m_wieldnode->setNodeLightColor(player->light_color); // Set render distance updateViewingRange(); diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 39ea4ab1e..e9e1cebd3 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -826,11 +826,12 @@ void GenericCAO::setNodeLight(u8 light) video::SColor color(255, light, light, light); if (m_prop.visual == "wielditem" || m_prop.visual == "item") { - // Since these types of visuals are using their own shader - // they should be handled separately if (m_wield_meshnode) - m_wield_meshnode->setColor(color); - } else if (m_enable_shaders) { + m_wield_meshnode->setNodeLightColor(color); + return; + } + + if (m_enable_shaders) { scene::ISceneNode *node = getSceneNode(); if (node == nullptr) diff --git a/src/client/wieldmesh.cpp b/src/client/wieldmesh.cpp index 2c6807fab..997eb1b5b 100644 --- a/src/client/wieldmesh.cpp +++ b/src/client/wieldmesh.cpp @@ -347,7 +347,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che scene::SMesh *mesh = nullptr; if (m_enable_shaders) { - u32 shader_id = shdrsrc->getShader("wielded_shader", TILE_MATERIAL_BASIC, NDT_NORMAL); + u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL); m_material_type = shdrsrc->getShaderInfo(shader_id).material; } @@ -471,6 +471,21 @@ void WieldMeshSceneNode::setColor(video::SColor c) } } +void WieldMeshSceneNode::setNodeLightColor(video::SColor color) +{ + if (!m_meshnode) + return; + + if (m_enable_shaders) { + for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) { + video::SMaterial &material = m_meshnode->getMaterial(i); + material.EmissiveColor = color; + } + } else { + setColor(color); + } +} + void WieldMeshSceneNode::render() { // note: if this method is changed to actually do something, diff --git a/src/client/wieldmesh.h b/src/client/wieldmesh.h index 7c80a811b..933097230 100644 --- a/src/client/wieldmesh.h +++ b/src/client/wieldmesh.h @@ -87,6 +87,8 @@ public: // Must only be used if the constructor was called with lighting = false void setColor(video::SColor color); + void setNodeLightColor(video::SColor color); + scene::IMesh *getMesh() { return m_meshnode->getMesh(); } virtual void render(); |