diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 16:57:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:57:47 +0100 |
commit | 3e16c3a78fff61c20e63ba730d15e94e3bb877b4 (patch) | |
tree | c070350db219f2c4241d22bc31949685c7b42fe9 /src/client/tile.h | |
parent | 5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (diff) | |
parent | 6ccb5835ff55d85156be91473c598eca9d6cb9a6 (diff) | |
download | dragonfireclient-3e16c3a78fff61c20e63ba730d15e94e3bb877b4.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/client/tile.h')
-rw-r--r-- | src/client/tile.h | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/src/client/tile.h b/src/client/tile.h index 695bcdeac..49c46f749 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -78,7 +78,7 @@ public: virtual ~ISimpleTextureSource() = default; - virtual video::ITexture *getTexture( + virtual video::ITexture* getTexture( const std::string &name, u32 *id = nullptr) = 0; }; @@ -89,12 +89,12 @@ public: 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; - virtual video::ITexture *getTexture( - const std::string &name, u32 *id = nullptr) = 0; - virtual video::ITexture *getTextureForMesh( + virtual u32 getTextureId(const std::string &name)=0; + virtual std::string getTextureName(u32 id)=0; + virtual video::ITexture* getTexture(u32 id)=0; + virtual video::ITexture* getTexture( + const std::string &name, u32 *id = nullptr)=0; + virtual video::ITexture* getTextureForMesh( const std::string &name, u32 *id = nullptr) = 0; /*! * Returns a palette from the given texture name. @@ -102,11 +102,11 @@ public: * destructed. * Should be called from the main thread. */ - virtual Palette *getPalette(const std::string &name) = 0; - virtual bool isKnownSourceImage(const std::string &name) = 0; - virtual video::ITexture *getNormalTexture(const std::string &name) = 0; - virtual video::SColor getTextureAverageColor(const std::string &name) = 0; - virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present) = 0; + virtual Palette* getPalette(const std::string &name) = 0; + virtual bool isKnownSourceImage(const std::string &name)=0; + virtual video::ITexture* getNormalTexture(const std::string &name)=0; + virtual video::SColor getTextureAverageColor(const std::string &name)=0; + virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0; }; class IWritableTextureSource : public ITextureSource @@ -116,30 +116,29 @@ public: 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; - virtual video::ITexture *getTexture( - const std::string &name, u32 *id = nullptr) = 0; - virtual bool isKnownSourceImage(const std::string &name) = 0; - - virtual void processQueue() = 0; - virtual void insertSourceImage(const std::string &name, video::IImage *img) = 0; - virtual void rebuildImagesAndTextures() = 0; - virtual video::ITexture *getNormalTexture(const std::string &name) = 0; - virtual video::SColor getTextureAverageColor(const std::string &name) = 0; - virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present) = 0; + virtual u32 getTextureId(const std::string &name)=0; + virtual std::string getTextureName(u32 id)=0; + virtual video::ITexture* getTexture(u32 id)=0; + virtual video::ITexture* getTexture( + const std::string &name, u32 *id = nullptr)=0; + virtual bool isKnownSourceImage(const std::string &name)=0; + + virtual void processQueue()=0; + virtual void insertSourceImage(const std::string &name, video::IImage *img)=0; + virtual void rebuildImagesAndTextures()=0; + virtual video::ITexture* getNormalTexture(const std::string &name)=0; + virtual video::SColor getTextureAverageColor(const std::string &name)=0; + virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0; }; IWritableTextureSource *createTextureSource(); #if ENABLE_GLES bool hasNPotSupport(); -video::IImage *Align2Npot2(video::IImage *image, irr::video::IVideoDriver *driver); +video::IImage * Align2Npot2(video::IImage * image, irr::video::IVideoDriver* driver); #endif -enum MaterialType -{ +enum MaterialType{ TILE_MATERIAL_BASIC, TILE_MATERIAL_ALPHA, TILE_MATERIAL_LIQUID_TRANSPARENT, @@ -193,16 +192,21 @@ struct TileLayer */ bool operator==(const TileLayer &other) const { - return texture_id == other.texture_id && - material_type == other.material_type && - material_flags == other.material_flags && color == other.color && - scale == other.scale; + return + texture_id == other.texture_id && + material_type == other.material_type && + material_flags == other.material_flags && + color == other.color && + scale == other.scale; } /*! * Two tiles are not equal if they must have different vertices. */ - bool operator!=(const TileLayer &other) const { return !(*this == other); } + bool operator!=(const TileLayer &other) const + { + return !(*this == other); + } // Sets everything else except the texture in the material void applyMaterialOptions(video::SMaterial &material) const @@ -228,8 +232,7 @@ struct TileLayer default: break; } - material.BackfaceCulling = - (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0; + 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; } @@ -240,8 +243,7 @@ struct TileLayer void applyMaterialOptionsWithShaders(video::SMaterial &material) const { - material.BackfaceCulling = - (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0; + 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; @@ -254,8 +256,8 @@ struct TileLayer bool isTileable() const { - return (material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) && - (material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL); + return (material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) + && (material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL); } // Ordered for size, please do not reorder @@ -273,10 +275,10 @@ struct TileLayer u8 material_type = TILE_MATERIAL_BASIC; u8 material_flags = - // 0 // <- DEBUG, Use the one below - MATERIAL_FLAG_BACKFACE_CULLING | - MATERIAL_FLAG_TILEABLE_HORIZONTAL | - MATERIAL_FLAG_TILEABLE_VERTICAL; + //0 // <- DEBUG, Use the one below + MATERIAL_FLAG_BACKFACE_CULLING | + MATERIAL_FLAG_TILEABLE_HORIZONTAL| + MATERIAL_FLAG_TILEABLE_VERTICAL; //! If true, the tile has its own color. bool has_color = false; @@ -302,16 +304,16 @@ struct TileSpec /*! * Returns true if this tile can be merged with the other tile. */ - bool isTileable(const TileSpec &other) const - { + bool isTileable(const TileSpec &other) const { for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) { if (layers[layer] != other.layers[layer]) return false; if (!layers[layer].isTileable()) return false; } - return rotation == 0 && rotation == other.rotation && - emissive_light == other.emissive_light; + return rotation == 0 + && rotation == other.rotation + && emissive_light == other.emissive_light; } //! If true, the tile rotation is ignored. |