aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-10-17 00:08:27 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-10-17 00:08:27 +0300
commit9ff806742655340a8e5abb8d5f91d32b89b9cd5f (patch)
treec90e8df9fa832840eb6d643586af00ee9e0ddcad /src
parent162619a426c9af15ac4868c9c7ce882f9932db38 (diff)
downloadminetest-9ff806742655340a8e5abb8d5f91d32b89b9cd5f.tar.gz
minetest-9ff806742655340a8e5abb8d5f91d32b89b9cd5f.tar.bz2
minetest-9ff806742655340a8e5abb8d5f91d32b89b9cd5f.zip
Fix items showing up as sticks when placed in world
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp72
1 files changed, 29 insertions, 43 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index d3a1813f1..b17c28109 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -208,6 +208,35 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr)
// This is needed for changing the texture in the future
m_node->setReadOnlyMaterials(true);
updateNodePos();
+
+ /*
+ Update image of node
+ */
+
+ // Create an inventory item to see what is its image
+ std::istringstream is(m_inventorystring, std::ios_base::binary);
+ video::ITexture *texture = NULL;
+ try{
+ InventoryItem *item = NULL;
+ item = InventoryItem::deSerialize(is);
+ infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
+ <<m_inventorystring<<"\" -> item="<<item
+ <<std::endl;
+ if(item)
+ {
+ texture = item->getImage();
+ delete item;
+ }
+ }
+ catch(SerializationError &e)
+ {
+ infostream<<"WARNING: "<<__FUNCTION_NAME
+ <<": error deSerializing inventorystring \""
+ <<m_inventorystring<<"\""<<std::endl;
+ }
+
+ // Set meshbuffer texture
+ buf->getMaterial().setTexture(0, texture);
}
void ItemCAO::removeFromScene()
@@ -289,49 +318,6 @@ void ItemCAO::initialize(const std::string &data)
}
updateNodePos();
-
- /*
- Update image of node
- */
-
- if(m_node == NULL)
- return;
-
- scene::IMesh *mesh = m_node->getMesh();
-
- if(mesh == NULL)
- return;
-
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
-
- if(buf == NULL)
- return;
-
- // Create an inventory item to see what is its image
- std::istringstream is(m_inventorystring, std::ios_base::binary);
- video::ITexture *texture = NULL;
- try{
- InventoryItem *item = NULL;
- item = InventoryItem::deSerialize(is);
- infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
- <<m_inventorystring<<"\" -> item="<<item
- <<std::endl;
- if(item)
- {
- texture = item->getImage();
- delete item;
- }
- }
- catch(SerializationError &e)
- {
- infostream<<"WARNING: "<<__FUNCTION_NAME
- <<": error deSerializing inventorystring \""
- <<m_inventorystring<<"\""<<std::endl;
- }
-
- // Set meshbuffer texture
- buf->getMaterial().setTexture(0, texture);
-
}
/*