aboutsummaryrefslogtreecommitdiff
path: root/src/mapblock_mesh.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-07-26 20:12:48 +0200
committerGitHub <noreply@github.com>2017-07-26 20:12:48 +0200
commit3e50850260db13ec63ce4ca0e47e7fd7e30ce484 (patch)
treeeb07ce2418ad29152db2378dd9e75fb873cdafd4 /src/mapblock_mesh.cpp
parent9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f (diff)
downloadminetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.tar.gz
minetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.tar.bz2
minetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.zip
TileLayer: use shared_ptr for FrameSpec vector (#6171)
* TileLayer: use shared_ptr for vector framespec This reduce memory copy of TileLayer from (4 to 16) * FrameSpec where FrameSpec = (sizeof(int) + 3 * sizeof(ptr)) to int + sizeof(ptr) Callgrind difference Before: https://lut.im/RGkiJqQb8T/LeQIEXpAuRzfl7gd.png After: https://lut.im/bcqmwee1xu/cTwtptY5tRuS9lp0.png * Fix one push_back to use vector::emplace_back & optimize inclusions
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r--src/mapblock_mesh.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index e854127c0..67195cab3 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -18,17 +18,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#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"
@@ -602,7 +597,8 @@ static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li
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++) {
@@ -1126,7 +1122,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
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) {
@@ -1314,7 +1310,7 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
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) {