1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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
This commit is contained in:
Loïc Blot 2017-04-29 20:36:09 +02:00 committed by GitHub
parent c729543ec4
commit 95409da87d
4 changed files with 35 additions and 43 deletions

View file

@ -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