mirror of
https://github.com/minetest/minetest.git
synced 2024-09-12 00:26:50 +02:00
Add object visual type 'item' (#7870)
This commit is contained in:
parent
98fa8a154d
commit
a833bee9ed
@ -5472,7 +5472,7 @@ Used by `ObjectRef` methods. Part of an Entity definition.
|
||||
pointable = true,
|
||||
-- Overrides selection box when false
|
||||
|
||||
visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
|
||||
visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
|
||||
-- "cube" is a node-sized cube.
|
||||
-- "sprite" is a flat texture always facing the player.
|
||||
-- "upright_sprite" is a vertical flat texture.
|
||||
@ -5488,6 +5488,7 @@ Used by `ObjectRef` methods. Part of an Entity definition.
|
||||
-- of its texture.
|
||||
-- Otherwise for non-node items, the object will be an extrusion of
|
||||
-- 'inventory_image'.
|
||||
-- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
|
||||
|
||||
visual_size = {x = 1, y = 1},
|
||||
-- `x` multiplies horizontal (X and Z) visual size.
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user