aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex <24834740+GreenXenith@users.noreply.github.com>2018-12-10 18:57:04 -0800
committerParamat <paramat@users.noreply.github.com>2018-12-11 02:57:04 +0000
commita833bee9edaeb6df69d1e510759a7b33915a41e0 (patch)
treee316ad0094a27816d89af10fce16ccf125cc90a1 /src
parent98fa8a154d8136ad19d723fd89164c9d833da52b (diff)
downloadminetest-a833bee9edaeb6df69d1e510759a7b33915a41e0.tar.gz
minetest-a833bee9edaeb6df69d1e510759a7b33915a41e0.tar.bz2
minetest-a833bee9edaeb6df69d1e510759a7b33915a41e0.zip
Add object visual type 'item' (#7870)
Diffstat (limited to 'src')
-rw-r--r--src/client/content_cao.cpp5
-rw-r--r--src/client/wieldmesh.cpp6
-rw-r--r--src/client/wieldmesh.h3
3 files changed, 8 insertions, 6 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index db59ae5c5..e2517f7ca 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -662,7 +662,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
}
else
errorstream<<"GenericCAO::addToScene(): Could not load mesh "<<m_prop.mesh<<std::endl;
- } else if (m_prop.visual == "wielditem") {
+ } else if (m_prop.visual == "wielditem" || m_prop.visual == "item") {
ItemStack item;
infostream << "GenericCAO::addToScene(): wielditem" << std::endl;
if (m_prop.wield_item.empty()) {
@@ -680,7 +680,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
}
m_wield_meshnode = new WieldMeshSceneNode(
RenderingEngine::get_scene_manager(), -1);
- m_wield_meshnode->setItem(item, m_client);
+ m_wield_meshnode->setItem(item, m_client,
+ (m_prop.visual == "wielditem"));
m_wield_meshnode->setScale(
v3f(m_prop.visual_size.X / 2, m_prop.visual_size.Y / 2,
diff --git a/src/client/wieldmesh.cpp b/src/client/wieldmesh.cpp
index 7791a5a92..4c25fafb1 100644
--- a/src/client/wieldmesh.cpp
+++ b/src/client/wieldmesh.cpp
@@ -333,7 +333,7 @@ scene::SMesh *createSpecialNodeMesh(Client *client, content_t id, std::vector<It
return mesh;
}
-void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
+void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool check_wield_image)
{
ITextureSource *tsrc = client->getTextureSource();
IItemDefManager *idef = client->getItemDefManager();
@@ -354,8 +354,8 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
m_colors.clear();
m_base_color = idef->getItemstackColor(item, client);
- // If wield_image is defined, it overrides everything else
- if (!def.wield_image.empty()) {
+ // If wield_image needs to be checked and is defined, it overrides everything else
+ if (!def.wield_image.empty() && check_wield_image) {
setExtruded(def.wield_image, def.wield_overlay, def.wield_scale, tsrc,
1);
m_colors.emplace_back();
diff --git a/src/client/wieldmesh.h b/src/client/wieldmesh.h
index 0908d3ac2..7c80a811b 100644
--- a/src/client/wieldmesh.h
+++ b/src/client/wieldmesh.h
@@ -80,7 +80,8 @@ public:
void setCube(const ContentFeatures &f, v3f wield_scale);
void setExtruded(const std::string &imagename, const std::string &overlay_image,
v3f wield_scale, ITextureSource *tsrc, u8 num_frames);
- void setItem(const ItemStack &item, Client *client);
+ void setItem(const ItemStack &item, Client *client,
+ bool check_wield_image = true);
// Sets the vertex color of the wield mesh.
// Must only be used if the constructor was called with lighting = false