TileSet class
#include <Jazz2/Tiles/TileSet.h>
Represents tile set used by tile map, consists of texture and collision mask.
Holds the source texture and the per-tile collision masks for a single tile set, providing lookups for a tile's mask and texture coordinates. A tile map references one or more of these to render and collide its layers; textures may be true-color or indexed for palette recoloring.
Public static variables
-
static std::
int32_t DefaultTileSize constexpr - Size of a tile.
Constructors, destructors, conversion operators
-
TileSet(StringView path,
std::
uint16_t tileCount, std:: unique_ptr<Texture> textureDiffuse, std:: unique_ptr<std:: uint8_t[]> mask, std:: uint32_t maskSize, std:: unique_ptr<Color[]> captionTile, const std:: uint8_t* tileDiffuseOpaque = nullptr) - Creates a new instance.
Public functions
-
auto GetTileMask(std::
int32_t tileId) const -> std:: uint8_t* - Returns mask for specified tile.
-
auto IsTileMaskEmpty(std::
int32_t tileId) const -> bool - Returns
trueif the mask of a tile is completely empty. -
auto IsTileMaskFilled(std::
int32_t tileId) const -> bool - Returns
trueif the mask of a tile is completely filled (non-empty). -
auto IsColumnContiguous(std::
int32_t tileId) const -> bool - Returns
trueif every column of the tile's mask is vertically contiguous (no gaps). -
auto GetColumnSpans(std::
int32_t tileId) const -> const std:: uint8_t* - Returns per-column solid spans for a tile.
-
auto IsTileFilled(std::
int32_t tileId) const -> bool - Returns
trueif the texture of a tile is completely opaque (non-transparent). - auto GetCaptionTile() const -> StaticArrayView<DefaultTileSize*DefaultTileSize, Color>
- Returns a caption tile.
-
auto OverrideTileDiffuse(std::
int32_t tileId, StaticArrayView<(DefaultTileSize+2)*(DefaultTileSize+2), std:: uint32_t> tileDiffuse) -> bool - Overrides the diffuse texture of the specified tile.
-
auto OverrideTileMask(std::
int32_t tileId, StaticArrayView<DefaultTileSize*DefaultTileSize, std:: uint8_t> tileMask) -> bool - Overrides the collision mask of the specified tile.
Public variables
- String FilePath
- Relative path to source file.
-
std::
unique_ptr<Texture> TextureDiffuse - Main (diffuse) texture.
-
std::
int32_t TileCount - Total number of tiles.
-
std::
int32_t TilesPerRow - Number of tiles per row.
- bool IsIndexed
- Whether TextureDiffuse stores raw palette indices instead of baked colors.
Function documentation
Jazz2:: Tiles:: TileSet:: TileSet(StringView path,
std:: uint16_t tileCount,
std:: unique_ptr<Texture> textureDiffuse,
std:: unique_ptr<std:: uint8_t[]> mask,
std:: uint32_t maskSize,
std:: unique_ptr<Color[]> captionTile,
const std:: uint8_t* tileDiffuseOpaque = nullptr)
Creates a new instance.
| Parameters | |
|---|---|
| path | Relative path to the source file |
| tileCount | Total number of tiles |
| textureDiffuse | Main (diffuse) texture |
| mask | Collision mask of all tiles |
| maskSize | Size of the collision mask in bytes |
| captionTile | Pixels of the caption tile |
| tileDiffuseOpaque | Optional table marking fully opaque tiles |
bool Jazz2:: Tiles:: TileSet:: IsColumnContiguous(std:: int32_t tileId) const
Returns true if every column of the tile's mask is vertically contiguous (no gaps).
Contiguity allows replacing the per-pixel collision scan with an exact per-column span test.
const std:: uint8_t* Jazz2:: Tiles:: TileSet:: GetColumnSpans(std:: int32_t tileId) const
Returns per-column solid spans for a tile.
2 bytes per column (first solid row, last solid row); a first row of 0xFF marks an empty column. Only meaningful when IsColumnContiguous() returns true.
Variable documentation
bool Jazz2:: Tiles:: TileSet:: IsIndexed
Whether TextureDiffuse stores raw palette indices instead of baked colors.
Indexed tiles (red channel holds the index) are recolored at draw time through the palette shaders. false for tilesets containing 32-bit true-color tiles.