mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Fix crack overlay for animated textures
This commit is contained in:
parent
2336d21efd
commit
96c34d369e
2 changed files with 146 additions and 113 deletions
|
@ -1133,12 +1133,17 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
|
|||
if(p.tile.material_flags & MATERIAL_FLAG_CRACK)
|
||||
{
|
||||
ITextureSource *tsrc = data->m_gamedef->tsrc();
|
||||
std::string crack_basename = tsrc->getTextureName(p.tile.texture_id);
|
||||
// Find the texture name plus ^[crack:N:
|
||||
std::ostringstream os(std::ios::binary);
|
||||
os<<tsrc->getTextureName(p.tile.texture_id)<<"^[crack";
|
||||
if(p.tile.material_flags & MATERIAL_FLAG_CRACK_OVERLAY)
|
||||
crack_basename += "^[cracko";
|
||||
else
|
||||
crack_basename += "^[crack";
|
||||
m_crack_materials.insert(std::make_pair(i, crack_basename));
|
||||
os<<"o"; // use ^[cracko
|
||||
os<<":"<<(u32)p.tile.animation_frame_count<<":";
|
||||
m_crack_materials.insert(std::make_pair(i, os.str()));
|
||||
// Replace tile texture with the cracked one
|
||||
p.tile.texture = tsrc->getTexture(
|
||||
os.str()+"0",
|
||||
&p.tile.texture_id);
|
||||
}
|
||||
// - Texture animation
|
||||
if(p.tile.material_flags & MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES)
|
||||
|
@ -1313,8 +1318,22 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||
ITextureSource *tsrc = m_gamedef->getTextureSource();
|
||||
std::ostringstream os;
|
||||
os<<basename<<crack;
|
||||
buf->getMaterial().setTexture(0,
|
||||
tsrc->getTexture(os.str()));
|
||||
u32 new_texture_id = 0;
|
||||
video::ITexture *new_texture =
|
||||
tsrc->getTexture(os.str(), &new_texture_id);
|
||||
buf->getMaterial().setTexture(0, new_texture);
|
||||
|
||||
// If the current material is also animated,
|
||||
// update animation info
|
||||
std::map<u32, TileSpec>::iterator anim_iter =
|
||||
m_animation_tiles.find(i->first);
|
||||
if(anim_iter != m_animation_tiles.end()){
|
||||
TileSpec &tile = anim_iter->second;
|
||||
tile.texture = new_texture;
|
||||
tile.texture_id = new_texture_id;
|
||||
// force animation update
|
||||
m_animation_frames[i->first] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
m_last_crack = crack;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue