Navigation Menu

Skip to content

Commit

Permalink
Add no_texture.png as fallback for unspecified textures
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 committed Oct 20, 2021
1 parent c82ec8b commit 86b44ec
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 23 deletions.
3 changes: 2 additions & 1 deletion doc/texture_packs.txt
Expand Up @@ -90,9 +90,10 @@ by texture packs. All existing fallback textures can be found in the directory
* `minimap_mask_square.png`: mask used for the square minimap
* `minimap_overlay_round.png`: overlay texture for the round minimap
* `minimap_overlay_square.png`: overlay texture for the square minimap
* `no_texture_airlike.png`: fallback inventory image for airlike nodes
* `object_marker_red.png`: texture for players on the minimap
* `player_marker.png`: texture for the own player on the square minimap
* `no_texture_airlike.png`: fallback inventory image for airlike nodes
* `no_texture.png`: fallback image for unspecified textures

* `player.png`: front texture of the 2D upright sprite player
* `player_back.png`: back texture of the 2D upright sprite player
Expand Down
11 changes: 11 additions & 0 deletions games/devtest/mods/broken/init.lua
@@ -0,0 +1,11 @@
-- Register stuff with empty definitions to test if Minetest fallback options
-- for these things work properly.

-- The itemstrings are deliberately kept descriptive to keep them easy to
-- recognize.

minetest.register_node("broken:node_with_empty_definition", {})
minetest.register_tool("broken:tool_with_empty_definition", {})
minetest.register_craftitem("broken:craftitem_with_empty_definition", {})

minetest.register_entity("broken:entity_with_empty_definition", {})
2 changes: 2 additions & 0 deletions games/devtest/mods/broken/mod.conf
@@ -0,0 +1,2 @@
name = broken
description = Register items and an entity with empty definitions to test fallback
10 changes: 5 additions & 5 deletions src/client/content_cao.cpp
Expand Up @@ -647,7 +647,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
m_matrixnode, v2f(1, 1), v3f(0,0,0), -1);
m_spritenode->grab();
m_spritenode->setMaterialTexture(0,
tsrc->getTextureForMesh("unknown_node.png"));
tsrc->getTextureForMesh("no_texture.png"));

setSceneNodeMaterial(m_spritenode);

Expand Down Expand Up @@ -1288,7 +1288,7 @@ void GenericCAO::updateTextures(std::string mod)

if (m_spritenode) {
if (m_prop.visual == "sprite") {
std::string texturestring = "unknown_node.png";
std::string texturestring = "no_texture.png";
if (!m_prop.textures.empty())
texturestring = m_prop.textures[0];
texturestring += mod;
Expand Down Expand Up @@ -1367,7 +1367,7 @@ void GenericCAO::updateTextures(std::string mod)
{
for (u32 i = 0; i < 6; ++i)
{
std::string texturestring = "unknown_node.png";
std::string texturestring = "no_texture.png";
if(m_prop.textures.size() > i)
texturestring = m_prop.textures[i];
texturestring += mod;
Expand Down Expand Up @@ -1400,7 +1400,7 @@ void GenericCAO::updateTextures(std::string mod)
} else if (m_prop.visual == "upright_sprite") {
scene::IMesh *mesh = m_meshnode->getMesh();
{
std::string tname = "unknown_object.png";
std::string tname = "no_texture.png";
if (!m_prop.textures.empty())
tname = m_prop.textures[0];
tname += mod;
Expand All @@ -1422,7 +1422,7 @@ void GenericCAO::updateTextures(std::string mod)
buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
}
{
std::string tname = "unknown_object.png";
std::string tname = "no_texture.png";
if (m_prop.textures.size() >= 2)
tname = m_prop.textures[1];
else if (!m_prop.textures.empty())
Expand Down
5 changes: 2 additions & 3 deletions src/client/game.cpp
Expand Up @@ -3331,9 +3331,8 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
} else {
MapNode n = map.getNode(nodepos);

if (nodedef_manager->get(n).tiledef[0].name == "unknown_node.png") {
m_game_ui->setInfoText(L"Unknown node: " +
utf8_to_wide(nodedef_manager->get(n).name));
if (nodedef_manager->get(n).name == "unknown") {
m_game_ui->setInfoText(L"Unknown node");
}
}

Expand Down
25 changes: 18 additions & 7 deletions src/client/hud.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions src/client/wieldmesh.cpp
Expand Up @@ -458,9 +458,14 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che
material.setFlag(video::EMF_TRILINEAR_FILTER, m_trilinear_filter);
}
return;
} else if (!def.inventory_image.empty()) {
setExtruded(def.inventory_image, def.inventory_overlay, def.wield_scale,
tsrc, 1);
} else {
if (!def.inventory_image.empty()) {
setExtruded(def.inventory_image, def.inventory_overlay, def.wield_scale,
tsrc, 1);
} else {
setExtruded("no_texture.png", "", def.wield_scale, tsrc, 1);
}

m_colors.emplace_back();
// overlay is white, if present
m_colors.emplace_back(true, video::SColor(0xFFFFFFFF));
Expand Down
17 changes: 14 additions & 3 deletions src/nodedef.cpp
Expand Up @@ -796,17 +796,24 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
TileDef tdef[6];
for (u32 j = 0; j < 6; j++) {
tdef[j] = tiledef[j];
if (tdef[j].name.empty())
tdef[j].name = "unknown_node.png";
if (tdef[j].name.empty()) {
tdef[j].name = "no_texture.png";
tdef[j].backface_culling = false;
}
}
// also the overlay tiles
TileDef tdef_overlay[6];
for (u32 j = 0; j < 6; j++)
tdef_overlay[j] = tiledef_overlay[j];
// also the special tiles
TileDef tdef_spec[6];
for (u32 j = 0; j < CF_SPECIAL_COUNT; j++)
for (u32 j = 0; j < CF_SPECIAL_COUNT; j++) {
tdef_spec[j] = tiledef_special[j];
if (tdef_spec[j].name.empty()) {
tdef_spec[j].name = "no_texture.png";
tdef_spec[j].backface_culling = false;
}
}

bool is_liquid = false;

Expand Down Expand Up @@ -1052,6 +1059,10 @@ void NodeDefManager::clear()
{
ContentFeatures f;
f.name = "unknown";
TileDef unknownTile;
unknownTile.name = "unknown_node.png";
for (int t = 0; t < 6; t++)
f.tiledef[t] = unknownTile;
// Insert directly into containers
content_t c = CONTENT_UNKNOWN;
m_content_features[c] = f;
Expand Down
2 changes: 1 addition & 1 deletion src/object_properties.cpp
Expand Up @@ -28,7 +28,7 @@ static const video::SColor NULL_BGCOLOR{0, 1, 1, 1};

ObjectProperties::ObjectProperties()
{
textures.emplace_back("unknown_object.png");
textures.emplace_back("no_texture.png");
colors.emplace_back(255,255,255,255);
}

Expand Down
5 changes: 5 additions & 0 deletions src/server/luaentity_sao.cpp
Expand Up @@ -108,7 +108,12 @@ void LuaEntitySAO::addedToEnvironment(u32 dtime_s)
m_env->getScriptIface()->
luaentity_Activate(m_id, m_init_state, dtime_s);
} else {
// It's an unknown object
// Use entitystring as infotext for debugging
m_prop.infotext = m_init_name;
// Set unknown object texture
m_prop.textures.clear();
m_prop.textures.emplace_back("unknown_object.png");
}
}

Expand Down
Binary file added textures/base/pack/no_texture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 86b44ec

Please sign in to comment.