diff options
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r-- | src/mapblock_mesh.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 40158e1ad..28c52f4b9 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -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; |