From 95409da87d009c352f27c737621972c2225796c9 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 29 Apr 2017 20:36:09 +0200 Subject: Optimize updateFastFaceRow processing by removing some TileSpec copy (#5678) * Optimize updateFastFaceRow processing by removing some TileSpec copy It permit to decrease this function from 54% runtime to 45% and reduce copy from 14% runtime to 12.5% getTileInfo also reduced from 27% to 23% * makeFastFace should use a const ref too this trigger a const pointer need in the underlying function Also fix some code style and prevent calculating 4 times the same position at a point * Reduce a comparison cost for lights in updateFastFaceRow --- src/content_mapblock.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/content_mapblock.cpp') diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 6673e2bd9..8be0a7d7b 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -76,7 +76,7 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector void MapblockMeshGenerator::useTile(int index, bool disable_backface_culling) { - tile = getNodeTileN(n, p, index, data); + getNodeTileN(n, p, index, data, tile); if (!data->m_smooth_lighting) color = encode_light(light, f->light_source); for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) { @@ -88,14 +88,14 @@ void MapblockMeshGenerator::useTile(int index, bool disable_backface_culling) void MapblockMeshGenerator::useDefaultTile(bool set_color) { - tile = getNodeTile(n, p, v3s16(0, 0, 0), data); + getNodeTile(n, p, v3s16(0, 0, 0), data, tile); if (set_color && !data->m_smooth_lighting) color = encode_light(light, f->light_source); } -TileSpec MapblockMeshGenerator::getTile(const v3s16& direction) +void MapblockMeshGenerator::getTile(const v3s16& direction, TileSpec &tile) { - return getNodeTile(n, p, direction, data); + getNodeTile(n, p, direction, data, tile); } void MapblockMeshGenerator::drawQuad(v3f *coords, const v3s16 &normal) @@ -660,7 +660,7 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode() { TileSpec tiles[6]; for (int face = 0; face < 6; face++) - tiles[face] = getTile(g_6dirs[face]); + getTile(g_6dirs[face], tiles[face]); TileSpec glass_tiles[6]; if (tiles[1].layers[0].texture && @@ -1193,7 +1193,7 @@ void MapblockMeshGenerator::drawNodeboxNode() TileSpec tiles[6]; for (int face = 0; face < 6; face++) { // Handles facedir rotation for textures - tiles[face] = getTile(tile_dirs[face]); + getTile(tile_dirs[face], tiles[face]); } // locate possible neighboring nodes to connect to -- cgit v1.2.3