Add a check for animation when getting an extruded mesh
Fixes issue #2667
This commit is contained in:
parent
e30d57f485
commit
3660c8c074
|
@ -259,14 +259,20 @@ void WieldMeshSceneNode::setCube(const TileSpec tiles[6],
|
||||||
}
|
}
|
||||||
|
|
||||||
void WieldMeshSceneNode::setExtruded(const std::string &imagename,
|
void WieldMeshSceneNode::setExtruded(const std::string &imagename,
|
||||||
v3f wield_scale, ITextureSource *tsrc)
|
v3f wield_scale, ITextureSource *tsrc, u8 num_frames)
|
||||||
{
|
{
|
||||||
video::ITexture *texture = tsrc->getTexture(imagename);
|
video::ITexture *texture = tsrc->getTexture(imagename);
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
changeToMesh(NULL);
|
changeToMesh(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::dimension2d<u32> dim = texture->getSize();
|
core::dimension2d<u32> dim = texture->getSize();
|
||||||
|
// Detect animation texture and pull off top frame instead of using entire thing
|
||||||
|
if (num_frames > 1) {
|
||||||
|
u32 frame_height = dim.Height / num_frames;
|
||||||
|
dim = core::dimension2d<u32>(dim.Width, frame_height);
|
||||||
|
}
|
||||||
scene::IMesh *mesh = g_extrusion_mesh_cache->create(dim);
|
scene::IMesh *mesh = g_extrusion_mesh_cache->create(dim);
|
||||||
changeToMesh(mesh);
|
changeToMesh(mesh);
|
||||||
mesh->drop();
|
mesh->drop();
|
||||||
|
@ -319,7 +325,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
|
||||||
|
|
||||||
// If wield_image is defined, it overrides everything else
|
// If wield_image is defined, it overrides everything else
|
||||||
if (def.wield_image != "") {
|
if (def.wield_image != "") {
|
||||||
setExtruded(def.wield_image, def.wield_scale, tsrc);
|
setExtruded(def.wield_image, def.wield_scale, tsrc, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Handle nodes
|
// Handle nodes
|
||||||
|
@ -335,7 +341,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
|
||||||
} else if (f.drawtype == NDT_AIRLIKE) {
|
} else if (f.drawtype == NDT_AIRLIKE) {
|
||||||
changeToMesh(NULL);
|
changeToMesh(NULL);
|
||||||
} else if (f.drawtype == NDT_PLANTLIKE) {
|
} else if (f.drawtype == NDT_PLANTLIKE) {
|
||||||
setExtruded(tsrc->getTextureName(f.tiles[0].texture_id), def.wield_scale, tsrc);
|
setExtruded(tsrc->getTextureName(f.tiles[0].texture_id), def.wield_scale, tsrc, f.tiles[0].animation_frame_count);
|
||||||
} else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
|
} else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
|
||||||
setCube(f.tiles, def.wield_scale, tsrc);
|
setCube(f.tiles, def.wield_scale, tsrc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -385,7 +391,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (def.inventory_image != "") {
|
else if (def.inventory_image != "") {
|
||||||
setExtruded(def.inventory_image, def.wield_scale, tsrc);
|
setExtruded(def.inventory_image, def.wield_scale, tsrc, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
void setCube(const TileSpec tiles[6],
|
void setCube(const TileSpec tiles[6],
|
||||||
v3f wield_scale, ITextureSource *tsrc);
|
v3f wield_scale, ITextureSource *tsrc);
|
||||||
void setExtruded(const std::string &imagename,
|
void setExtruded(const std::string &imagename,
|
||||||
v3f wield_scale, ITextureSource *tsrc);
|
v3f wield_scale, ITextureSource *tsrc, u8 num_frames);
|
||||||
void setItem(const ItemStack &item, IGameDef *gamedef);
|
void setItem(const ItemStack &item, IGameDef *gamedef);
|
||||||
|
|
||||||
// Sets the vertex color of the wield mesh.
|
// Sets the vertex color of the wield mesh.
|
||||||
|
|
Loading…
Reference in New Issue