Skip to content

Commit

Permalink
Some minor Fastface optimizations. (#7628)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhofhansl authored and nerzhul committed Aug 8, 2018
1 parent 8d68b2c commit 3a95d76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/client/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,7 @@ struct TileLayer
*/
struct TileSpec
{
TileSpec() {
for (auto &layer : layers)
layer = TileLayer();
}
TileSpec() = default;

/*!
* Returns true if this tile can be merged with the other tile.
Expand Down
12 changes: 6 additions & 6 deletions src/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static u8 getFaceLight(enum LightBank bank, MapNode n, MapNode n2,
Calculate non-smooth lighting at face of node.
Both light banks.
*/
u16 getFaceLight(MapNode n, MapNode n2, v3s16 face_dir,
u16 getFaceLight(MapNode n, MapNode n2, const v3s16 &face_dir,
const NodeDefManager *ndef)
{
u16 day = getFaceLight(LIGHTBANK_DAY, n, n2, face_dir, ndef);
Expand Down Expand Up @@ -375,7 +375,7 @@ void final_color_blend(video::SColor *result,
/*
vertex_dirs: v3s16[4]
*/
static void getNodeVertexDirs(v3s16 dir, v3s16 *vertex_dirs)
static void getNodeVertexDirs(const v3s16 &dir, v3s16 *vertex_dirs)
{
/*
If looked from outside the node towards the face, the corners are:
Expand Down Expand Up @@ -424,7 +424,7 @@ static void getNodeVertexDirs(v3s16 dir, v3s16 *vertex_dirs)
}
}

static void getNodeTextureCoords(v3f base, const v3f &scale, v3s16 dir, float *u, float *v)
static void getNodeTextureCoords(v3f base, const v3f &scale, const v3s16 &dir, float *u, float *v)
{
if (dir.X > 0 || dir.Y > 0 || dir.Z < 0)
base -= scale;
Expand Down Expand Up @@ -462,7 +462,7 @@ struct FastFace
};

static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li3,
v3f tp, v3f p, v3s16 dir, v3f scale, std::vector<FastFace> &dest)
const v3f &tp, const v3f &p, const v3s16 &dir, const v3f &scale, std::vector<FastFace> &dest)
{
// Position is at the center of the cube.
v3f pos = p * BS;
Expand Down Expand Up @@ -704,7 +704,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
/*
Gets nth node tile (0 <= n <= 5).
*/
void getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data, TileSpec &tile)
void getNodeTileN(MapNode mn, const v3s16 &p, u8 tileindex, MeshMakeData *data, TileSpec &tile)
{
const NodeDefManager *ndef = data->m_client->ndef();
const ContentFeatures &f = ndef->get(mn);
Expand All @@ -724,7 +724,7 @@ void getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data, TileSpe
/*
Gets node tile given a face direction.
*/
void getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data, TileSpec &tile)
void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *data, TileSpec &tile)
{
const NodeDefManager *ndef = data->m_client->ndef();

Expand Down
6 changes: 3 additions & 3 deletions src/mapblock_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ video::SColor encode_light(u16 light, u8 emissive_light);

// Compute light at node
u16 getInteriorLight(MapNode n, s32 increment, const NodeDefManager *ndef);
u16 getFaceLight(MapNode n, MapNode n2, v3s16 face_dir,
u16 getFaceLight(MapNode n, MapNode n2, const v3s16 &face_dir,
const NodeDefManager *ndef);
u16 getSmoothLightSolid(const v3s16 &p, const v3s16 &face_dir, const v3s16 &corner, MeshMakeData *data);
u16 getSmoothLightTransparent(const v3s16 &p, const v3s16 &corner, MeshMakeData *data);
Expand Down Expand Up @@ -224,5 +224,5 @@ void final_color_blend(video::SColor *result,
// Adds MATERIAL_FLAG_CRACK if the node is cracked
// TileSpec should be passed as reference due to the underlying TileFrame and its vector
// TileFrame vector copy cost very much to client
void getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data, TileSpec &tile);
void getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data, TileSpec &tile);
void getNodeTileN(MapNode mn, const v3s16 &p, u8 tileindex, MeshMakeData *data, TileSpec &tile);
void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *data, TileSpec &tile);

0 comments on commit 3a95d76

Please sign in to comment.