diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-15 20:30:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 20:30:30 +0200 |
commit | 9dd0f952e09471f15f59a98c1ae650d99499cd77 (patch) | |
tree | ef600d29b8b753353657ac6740d47208dd0e5d09 /src/client/tile.h | |
parent | 64c7a689ad8a596f6b72afe200d9ced20cdd9630 (diff) | |
download | minetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.tar.gz minetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.tar.bz2 minetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.zip |
Modernize client code (#6250)
* Various code style fixes
* Use range based for loops
* Use empty instead of empty objects
* Use C++11 default keyword for trivial constructors and destructors
* Drop some useless casts
* Use emplace_back instead of push_back to improve performance of some vectors push
Diffstat (limited to 'src/client/tile.h')
-rw-r--r-- | src/client/tile.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/client/tile.h b/src/client/tile.h index cfdcf30bd..cd3c3880e 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -90,8 +90,10 @@ struct TextureFromMeshParams class ISimpleTextureSource { public: - ISimpleTextureSource(){} - virtual ~ISimpleTextureSource(){} + ISimpleTextureSource() = default; + + virtual ~ISimpleTextureSource() = default; + virtual video::ITexture* getTexture( const std::string &name, u32 *id = nullptr) = 0; }; @@ -99,8 +101,10 @@ public: class ITextureSource : public ISimpleTextureSource { public: - ITextureSource(){} - virtual ~ITextureSource(){} + ITextureSource() = default; + + virtual ~ITextureSource() = default; + virtual u32 getTextureId(const std::string &name)=0; virtual std::string getTextureName(u32 id)=0; virtual video::ITexture* getTexture(u32 id)=0; @@ -126,8 +130,10 @@ public: class IWritableTextureSource : public ITextureSource { public: - IWritableTextureSource(){} - virtual ~IWritableTextureSource(){} + IWritableTextureSource() = default; + + virtual ~IWritableTextureSource() = default; + virtual u32 getTextureId(const std::string &name)=0; virtual std::string getTextureName(u32 id)=0; virtual video::ITexture* getTexture(u32 id)=0; @@ -170,7 +176,7 @@ enum MaterialType{ // Ignored if MATERIAL_FLAG_CRACK is not set. #define MATERIAL_FLAG_CRACK_OVERLAY 0x04 #define MATERIAL_FLAG_ANIMATION 0x08 -#define MATERIAL_FLAG_HIGHLIGHTED 0x10 +//#define MATERIAL_FLAG_HIGHLIGHTED 0x10 #define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20 #define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40 @@ -180,7 +186,8 @@ enum MaterialType{ */ struct FrameSpec { - FrameSpec() {} + FrameSpec() = default; + u32 texture_id = 0; video::ITexture *texture = nullptr; video::ITexture *normal_texture = nullptr; @@ -192,7 +199,7 @@ struct FrameSpec //! Defines a layer of a tile. struct TileLayer { - TileLayer() {} + TileLayer() = default; /*! * Two layers are equal if they can be merged. @@ -232,8 +239,7 @@ struct TileLayer material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; break; } - material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) - ? true : false; + material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0; if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) { material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE; } @@ -244,8 +250,7 @@ struct TileLayer void applyMaterialOptionsWithShaders(video::SMaterial &material) const { - material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) - ? true : false; + material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0; if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) { material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE; material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE; |