QcAtlasLayout Class
Geometry of the texture atlas (decision E-300). More...
| Header: | #include <clientcore/textures/QcAtlasLayout.h> |
Public Functions
| QcAtlasLayout() | |
| qint64 | bytes(int tileSize) const |
| int | columns() const |
| QSize | extent(int tileSize) const |
| void | place(QImage &atlas, qsizetype index, const QImage &tile) const |
| int | rows() const |
| QPoint | tileOrigin(qsizetype index, int tileSize) const |
| QRectF | uv(qsizetype index) const |
Static Public Members
| int | cellSize(int tileSize) |
| qsizetype | firstLevelWithin(const QList<QImage> &levels, int maxSize) |
| QSize | gridOf(QSize lastLevel) |
| int | gutter(int tileSize) |
| QImage | halve(const QImage &level) |
| int | levelCount(int tileSize) |
| const int | minimumMipTile |
Detailed Description
Tiles sit in a grid of cells; a cell is the tile plus a gutter of tile / 8 pixels on every side that repeats the tile's edge pixels, so filtering and mip levels never mix neighbouring tiles. Measured in eighths of a tile (a cell is 10, the gutter 1, the tile 8), every UV rectangle is the same at every tile size: changing the resolution re-uploads the atlas but keeps all meshes.
Member Function Documentation
[constexpr noexcept default] QcAtlasLayout::QcAtlasLayout()
Default-constructs an instance of QcAtlasLayout.
qint64 QcAtlasLayout::bytes(int tileSize) const
Returns the bytes of all mip levels at tileSize (RGBA, 4 bytes per pixel).
[static] int QcAtlasLayout::cellSize(int tileSize)
Returns the edge of a cell in pixels at tileSize: the tile plus a gutter on both sides.
int QcAtlasLayout::columns() const
Returns the number of tile columns.
QSize QcAtlasLayout::extent(int tileSize) const
Returns the size in pixels of mip level 0 at tileSize.
[static] qsizetype QcAtlasLayout::firstLevelWithin(const QList<QImage> &levels, int maxSize)
Returns the index of the first of levels whose width and height are at most maxSize; -1 if none is.
[static] QSize QcAtlasLayout::gridOf(QSize lastLevel)
Returns the columns and rows of the atlas whose last level (levelCount(), tiles of 8 pixels) is lastLevel pixels large; at least 1 x 1.
[static] int QcAtlasLayout::gutter(int tileSize)
Returns the gutter width in pixels at tileSize (tileSize / 8).
[static] QImage QcAtlasLayout::halve(const QImage &level)
Returns the mip level after level: every 2 x 2 block averaged, colours weighted by their alpha so transparent pixels do not darken the edges of cut-out textures.
[static] int QcAtlasLayout::levelCount(int tileSize)
Returns the number of mip levels at tileSize down to tiles of 8 pixels (16: 2, 32: 3, 64: 4, …, 256: 6), each with a gutter of at least one pixel.
void QcAtlasLayout::place(QImage &atlas, qsizetype index, const QImage &tile) const
Draws tile (tileSize x tileSize RGBA8888) into the cell of tile index in atlas and fills the gutter around it with the tile's edge pixels.
int QcAtlasLayout::rows() const
Returns the number of tile rows.
QPoint QcAtlasLayout::tileOrigin(qsizetype index, int tileSize) const
Returns the top left pixel of tile index (inside its gutter) at tileSize.
QRectF QcAtlasLayout::uv(qsizetype index) const
Returns the UV rectangle (0..1) of tile index, independent of the tile size.
Member Variable Documentation
const int QcAtlasLayout::minimumMipTile
Tile size of the last mip level (levelCount()).