Fix overlays for 2D-drawn items

fixes #11248
This commit is contained in:
sfan5 2021-05-08 19:33:52 +02:00
parent 7c2826cbc0
commit 2443f1e235

@ -997,6 +997,8 @@ void drawItemStack(
const ItemDefinition &def = item.getDefinition(client->idef()); const ItemDefinition &def = item.getDefinition(client->idef());
bool draw_overlay = false;
// Render as mesh if animated or no inventory image // Render as mesh if animated or no inventory image
if ((enable_animations && rotation_kind < IT_ROT_NONE) || def.inventory_image.empty()) { if ((enable_animations && rotation_kind < IT_ROT_NONE) || def.inventory_image.empty()) {
ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client); ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client);
@ -1089,6 +1091,8 @@ void drawItemStack(
driver->setTransform(video::ETS_VIEW, oldViewMat); driver->setTransform(video::ETS_VIEW, oldViewMat);
driver->setTransform(video::ETS_PROJECTION, oldProjMat); driver->setTransform(video::ETS_PROJECTION, oldProjMat);
driver->setViewPort(oldViewPort); driver->setViewPort(oldViewPort);
draw_overlay = def.type == ITEM_NODE && def.inventory_image.empty();
} else { // Otherwise just draw as 2D } else { // Otherwise just draw as 2D
video::ITexture *texture = client->idef()->getInventoryTexture(def.name, client); video::ITexture *texture = client->idef()->getInventoryTexture(def.name, client);
if (!texture) if (!texture)
@ -1100,11 +1104,12 @@ void drawItemStack(
draw2DImageFilterScaled(driver, texture, rect, draw2DImageFilterScaled(driver, texture, rect,
core::rect<s32>({0, 0}, core::dimension2di(texture->getOriginalSize())), core::rect<s32>({0, 0}, core::dimension2di(texture->getOriginalSize())),
clip, colors, true); clip, colors, true);
draw_overlay = true;
} }
// draw the inventory_overlay // draw the inventory_overlay
if (def.type == ITEM_NODE && def.inventory_image.empty() && if (!def.inventory_overlay.empty() && draw_overlay) {
!def.inventory_overlay.empty()) {
ITextureSource *tsrc = client->getTextureSource(); ITextureSource *tsrc = client->getTextureSource();
video::ITexture *overlay_texture = tsrc->getTexture(def.inventory_overlay); video::ITexture *overlay_texture = tsrc->getTexture(def.inventory_overlay);
core::dimension2d<u32> dimens = overlay_texture->getOriginalSize(); core::dimension2d<u32> dimens = overlay_texture->getOriginalSize();