]> git.lizzy.rs Git - minetest.git/commitdiff
Some minor Fastface optimizations. (#7628)
authorlhofhansl <lhofhansl@yahoo.com>
Wed, 8 Aug 2018 13:53:06 +0000 (17:53 +0400)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Wed, 8 Aug 2018 13:53:06 +0000 (15:53 +0200)
src/client/tile.h
src/mapblock_mesh.cpp
src/mapblock_mesh.h

index b1f6d6ac9293057a1d0dfe7fd91473a522f4ed27..143c67298a723fcf6783a43488ce81a6061c822f 100644 (file)
@@ -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.
index a616a98b7d20bc73de4449cacc838ca8d2715adb..ed8a073de5792bbc92464b8f2ff820c3327f6773 100644 (file)
@@ -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);
@@ -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:
@@ -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;
@@ -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;
@@ -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);
@@ -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();
 
index 39bc2f318c27218945840fa8755035abfed0da53..6af23a656fdd3e004abf3884ba4c4f6b193b7c25 100644 (file)
@@ -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);
@@ -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);