1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add no_texture.png as fallback for unspecified textures

This commit is contained in:
Wuzzy 2021-10-20 19:50:16 +00:00 committed by GitHub
parent c82ec8b210
commit 86b44ecd82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 68 additions and 23 deletions

View file

@ -1007,11 +1007,15 @@ void drawItemStack(
bool draw_overlay = false;
bool has_mesh = false;
ItemMesh *imesh;
// Render as mesh if animated or no inventory image
if ((enable_animations && rotation_kind < IT_ROT_NONE) || def.inventory_image.empty()) {
ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client);
if (!imesh || !imesh->mesh)
return;
imesh = client->idef()->getWieldMesh(def.name, client);
has_mesh = imesh && imesh->mesh;
}
if (has_mesh) {
scene::IMesh *mesh = imesh->mesh;
driver->clearBuffers(video::ECBF_DEPTH);
s32 delta = 0;
@ -1103,10 +1107,17 @@ void drawItemStack(
draw_overlay = def.type == ITEM_NODE && def.inventory_image.empty();
} else { // Otherwise just draw as 2D
video::ITexture *texture = client->idef()->getInventoryTexture(def.name, client);
if (!texture)
return;
video::SColor color =
client->idef()->getItemstackColor(item, client);
video::SColor color;
if (texture) {
color = client->idef()->getItemstackColor(item, client);
} else {
color = video::SColor(255, 255, 255, 255);
ITextureSource *tsrc = client->getTextureSource();
texture = tsrc->getTexture("no_texture.png");
if (!texture)
return;
}
const video::SColor colors[] = { color, color, color, color };
draw2DImageFilterScaled(driver, texture, rect,