Don't copy material, return ref const instead

Also update AnimData directly (maybe this causes SegFaulting? idk)
master
BlockMen 2017-04-25 23:59:59 +02:00 committed by darkrose
parent 478551894d
commit bc6446fc4a
3 changed files with 9 additions and 15 deletions

View File

@ -478,21 +478,18 @@ void MapBlockMesh::animate(float time)
for (std::map<u32, AnimationData>::iterator it = m_animation_data.begin();
it != m_animation_data.end(); ++it) {
AnimationData temp_data = it->second;
const TileSpec &tile = temp_data.tile;
const TileSpec &tile = it->second.tile;
// Figure out current frame
int frame = (int)(time * 1000 / tile.animation_frame_length_ms) % tile.animation_frame_count;
// If frame doesn't change, skip
if (frame == temp_data.frame)
if (frame == it->second.frame)
continue;
temp_data.frame = frame;
m_animation_data[it->first].frame = frame;
m_animation_data[it->first] = temp_data;
// Make sure we don't cause an overflow. Can get removed if future is no problems occuring
// Make sure we don't cause an overflow. Can get removed in future if no problems occuring
if (it->first >= m_mesh->getMeshBufferCount()) {
errorstream << ": animate() Tying to index non existent Buffer." << std::endl;
return;

View File

@ -163,19 +163,16 @@ void SelectionMesh::animate(float time)
for (std::map<u32, AnimationData>::iterator it = m_animation_data.begin();
it != m_animation_data.end(); ++it) {
AnimationData temp_data = it->second;
const TileSpec &tile = temp_data.tile;
const TileSpec &tile = it->second.tile;
// Figure out current frame
int frame = (int)(time * 1000 / tile.animation_frame_length_ms) % tile.animation_frame_count;
// If frame doesn't change, skip
if (frame == temp_data.frame)// || temp_data.frame < 0)
if (frame == it->second.frame)// || temp_data.frame < 0)
continue;
temp_data.frame = frame;
m_animation_data[it->first] = temp_data;
m_animation_data[it->first].frame = frame;
// Make sure we don't cause an overflow. Can get removed if future is no problems occuring
if (it->first >= m_mesh->getMeshBufferCount()) {

View File

@ -335,7 +335,7 @@ struct TileSpec
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
}
video::SMaterial getMaterial()
const video::SMaterial &getMaterial()
{
applyMaterialOptions(m_material);
m_material.setTexture(0, texture.atlas);