]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/wieldmesh.cpp
Remove reference to a removed file in devtest (followup to #12157)
[dragonfireclient.git] / src / client / wieldmesh.cpp
index e76bbfa9ea7a43ef2d5f0b49b526e427661b96ab..ab6fc9281a1883f45b61e13122fa4f6b01f642a0 100644 (file)
@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/numeric.h"
 #include <map>
 #include <IMeshManipulator.h>
+#include "client/renderingengine.h"
 
 #define WIELD_SCALE_FACTOR 30.0
 #define WIELD_SCALE_FACTOR_EXTRUDED 40.0
@@ -220,11 +221,18 @@ WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id, bool l
        m_meshnode->setReadOnlyMaterials(false);
        m_meshnode->setVisible(false);
        dummymesh->drop(); // m_meshnode grabbed it
+
+       m_shadow = RenderingEngine::get_shadow_renderer();
 }
 
 WieldMeshSceneNode::~WieldMeshSceneNode()
 {
        sanity_check(g_extrusion_mesh_cache);
+
+       // Remove node from shadow casters. m_shadow might be an invalid pointer!
+       if (auto shadow = RenderingEngine::get_shadow_renderer())
+               shadow->removeNodeFromShadowList(m_meshnode);
+
        if (g_extrusion_mesh_cache->drop())
                g_extrusion_mesh_cache = nullptr;
 }
@@ -307,18 +315,21 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
        MeshMakeData mesh_make_data(client, false);
        MeshCollector collector;
        mesh_make_data.setSmoothLighting(false);
-       MapblockMeshGenerator gen(&mesh_make_data, &collector);
+       MapblockMeshGenerator gen(&mesh_make_data, &collector,
+               client->getSceneManager()->getMeshManipulator());
 
        if (n.getParam2()) {
                // keep it
        } else if (f.param_type_2 == CPT2_WALLMOUNTED ||
                        f.param_type_2 == CPT2_COLORED_WALLMOUNTED) {
-               if (f.drawtype == NDT_TORCHLIKE)
-                       n.setParam2(1);
-               else if (f.drawtype == NDT_SIGNLIKE ||
+               if (f.drawtype == NDT_TORCHLIKE ||
+                               f.drawtype == NDT_SIGNLIKE ||
                                f.drawtype == NDT_NODEBOX ||
-                               f.drawtype == NDT_MESH)
+                               f.drawtype == NDT_MESH) {
                        n.setParam2(4);
+               }
+       } else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE) {
+               n.setParam2(1);
        }
        gen.renderSingle(n.getContent(), n.getParam2());
 
@@ -447,9 +458,14 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che
                        material.setFlag(video::EMF_TRILINEAR_FILTER, m_trilinear_filter);
                }
                return;
-       } else if (!def.inventory_image.empty()) {
-               setExtruded(def.inventory_image, def.inventory_overlay, def.wield_scale,
-                       tsrc, 1);
+       } else {
+               if (!def.inventory_image.empty()) {
+                       setExtruded(def.inventory_image, def.inventory_overlay, def.wield_scale,
+                               tsrc, 1);
+               } else {
+                       setExtruded("no_texture.png", "", def.wield_scale, tsrc, 1);
+               }
+
                m_colors.emplace_back();
                // overlay is white, if present
                m_colors.emplace_back(true, video::SColor(0xFFFFFFFF));
@@ -499,8 +515,9 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
                        material.EmissiveColor = color;
                }
        }
-
-       setColor(color);
+       else {
+               setColor(color);
+       }
 }
 
 void WieldMeshSceneNode::render()
@@ -524,6 +541,15 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
        // need to normalize normals when lighting is enabled (because of setScale())
        m_meshnode->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, m_lighting);
        m_meshnode->setVisible(true);
+
+       if (m_shadow) {
+               // Add mesh to shadow caster
+               m_shadow->addNodeToShadowList(m_meshnode);
+
+               // Set shadow texture
+               for (u32 i = 0; i < m_meshnode->getMaterialCount(); i++)
+                       m_meshnode->setMaterialTexture(3, m_shadow->get_texture());
+       }
 }
 
 void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
@@ -536,7 +562,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
        content_t id = ndef->getId(def.name);
 
        FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized");
-       
+
        scene::SMesh *mesh = nullptr;
 
        // Shading is on by default