- // Add to MapBlockMesh in order to animate these tiles
- m_animation_tiles[i] = p.tile;
- m_animation_frames[i] = 0;
- if(g_settings->getBool("desynchronize_mapblock_texture_animation")){
- // Get starting position from noise
- m_animation_frame_offsets[i] = 100000 * (2.0 + noise3d(
- data->m_blockpos.X, data->m_blockpos.Y,
- data->m_blockpos.Z, 0));
- } else {
- // Play all synchronized
- m_animation_frame_offsets[i] = 0;
+ PreMeshBuffer &p = collector.prebuffers[layer][i];
+
+ // Generate animation data
+ // - Cracks
+ if (p.layer.material_flags & MATERIAL_FLAG_CRACK) {
+ // Find the texture name plus ^[crack:N:
+ std::ostringstream os(std::ios::binary);
+ os << m_tsrc->getTextureName(p.layer.texture_id) << "^[crack";
+ if (p.layer.material_flags & MATERIAL_FLAG_CRACK_OVERLAY)
+ os << "o"; // use ^[cracko
+ u8 tiles = p.layer.scale;
+ if (tiles > 1)
+ os << ":" << (u32)tiles;
+ os << ":" << (u32)p.layer.animation_frame_count << ":";
+ m_crack_materials.insert(std::make_pair(
+ std::pair<u8, u32>(layer, i), os.str()));
+ // Replace tile texture with the cracked one
+ p.layer.texture = m_tsrc->getTextureForMesh(
+ os.str() + "0",
+ &p.layer.texture_id);
+ }
+ // - Texture animation
+ if (p.layer.material_flags & MATERIAL_FLAG_ANIMATION) {
+ // Add to MapBlockMesh in order to animate these tiles
+ m_animation_tiles[std::pair<u8, u32>(layer, i)] = p.layer;
+ m_animation_frames[std::pair<u8, u32>(layer, i)] = 0;
+ if (g_settings->getBool(
+ "desynchronize_mapblock_texture_animation")) {
+ // Get starting position from noise
+ m_animation_frame_offsets[std::pair<u8, u32>(layer, i)] =
+ 100000 * (2.0 + noise3d(
+ data->m_blockpos.X, data->m_blockpos.Y,
+ data->m_blockpos.Z, 0));
+ } else {
+ // Play all synchronized
+ m_animation_frame_offsets[std::pair<u8, u32>(layer, i)] = 0;
+ }
+ // Replace tile texture with the first animation frame
+ p.layer.texture = (*p.layer.frames)[0].texture;