#include <string>
#include <vector>
#include <SMaterial.h>
+#include <memory>
#include "util/numeric.h"
class IGameDef;
//! If true, the tile has its own color.
bool has_color = false;
- std::vector<FrameSpec> frames;
+ std::shared_ptr<std::vector<FrameSpec>> frames = nullptr;
/*!
* The color of the tile, or if the tile does not own
*/
#include "mapblock_mesh.h"
-#include "light.h"
#include "mapblock.h"
#include "map.h"
#include "profiler.h"
-#include "nodedef.h"
#include "mesh.h"
#include "minimap.h"
#include "content_mapblock.h"
-#include "noise.h"
-#include "shader.h"
-#include "settings.h"
#include "util/directiontables.h"
#include "client/renderingengine.h"
if (layer->texture_id == 0)
continue;
- dest.push_back(FastFace());
+ // equivalent to dest.push_back(FastFace()) but faster
+ dest.emplace_back();
FastFace& face = *dest.rbegin();
for (u8 i = 0; i < 4; i++) {
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;
+ p.layer.texture = (*p.layer.frames)[0].texture;
}
if (!m_enable_shaders) {
scene::IMeshBuffer *buf = m_mesh[i->first.first]->
getMeshBuffer(i->first.second);
- const FrameSpec &animation_frame = tile.frames[frame];
+ const FrameSpec &animation_frame = (*tile.frames)[frame];
buf->getMaterial().setTexture(0, animation_frame.texture);
if (m_enable_shaders) {
if (animation_frame.normal_texture) {
tile->material_flags &= ~MATERIAL_FLAG_ANIMATION;
} else {
std::ostringstream os(std::ios::binary);
- tile->frames.resize(frame_count);
+ if (!tile->frames) {
+ tile->frames = std::make_shared<std::vector<FrameSpec>>();
+ }
+ tile->frames->resize(frame_count);
for (int i = 0; i < frame_count; i++) {
if (tile->normal_texture)
frame.normal_texture = tsrc->getNormalTexture(os.str());
frame.flags_texture = tile->flags_texture;
- tile->frames[i] = frame;
+ (*tile->frames)[i] = frame;
}
}
}
// Only use first frame of animated texture
if (tile.material_flags & MATERIAL_FLAG_ANIMATION)
- texture = tile.frames[0].texture;
+ texture = (*tile.frames)[0].texture;
else
texture = tile.texture;
material.MaterialType = *mattype;
}
if (layer->animation_frame_count > 1) {
- FrameSpec animation_frame = layer->frames[0];
+ const FrameSpec &animation_frame = (*layer->frames)[0];
material.setTexture(0, animation_frame.texture);
} else {
material.setTexture(0, layer->texture);
if (use_shaders) {
if (layer->normal_texture) {
if (layer->animation_frame_count > 1) {
- FrameSpec animation_frame = layer->frames[0];
+ const FrameSpec &animation_frame = (*layer->frames)[0];
material.setTexture(1, animation_frame.normal_texture);
} else
material.setTexture(1, layer->normal_texture);