QcFramedMapAtlas Class
The pictures of the maps in item frames (decision E-809), one texture for all of them: a grid of columns x columns tiles of QcMapData::size pixels, one per map id drawn this frame, so every framed map is drawn with the same texture and a wall of them costs one draw call. More...
| Header: | #include <clientcore/maps/QcFramedMapAtlas.h> |
Public Types
| struct | Tile |
Public Functions
| void | beginFrame(const QList<quint32> &nearestFirst, const QcClientMaps &maps) |
| QRectF | place(quint32 id, const QcClientMaps &maps) |
| void | setColours(QList<QRgb> colours) |
| std::shared_ptr<const QList<QcFramedMapAtlas::Tile>> | tiles() const |
Static Public Members
| const int | columns |
| QImage | draw(const QcClientMaps::Map &map, const QList<QRgb> &colours) |
| const int | side |
| const int | tileCount |
| QRectF | uvOf(int index) |
Detailed Description
A map's tile is drawn again only when its picture or its frame markers change, never per frame or per frame entity. Tile 0 is blank paper: a map the client has not received yet, and every map beyond the nearest tileCount - 1 of the frame, shows it. Each frame starts with the maps in view nearest first (beginFrame): they keep their tiles, a map new among them takes the tile unused longest, so tiles never pass from map to map within a frame. Lives in the GUI thread; the renderer uploads the tiles whose version it has not seen (tiles()).
Member Function Documentation
void QcFramedMapAtlas::beginFrame(const QList<quint32> &nearestFirst, const QcClientMaps &maps)
A new frame showing the maps nearestFirst (by the distance of their nearest frame to the camera; an id may come more than once): the nearest tileCount - 1 of them that maps has a picture of keep their tiles or get the tiles unused longest, the others show paper this frame.
[static] QImage QcFramedMapAtlas::draw(const QcClientMaps::Map &map, const QList<QRgb> &colours)
Returns the picture of map on its tile: the pixels in their colours (by block definition), blank ones paper, and the frame markers (QcMapMarker::frame) as small green pointers; players are not shown on framed maps.
QRectF QcFramedMapAtlas::place(quint32 id, const QcClientMaps &maps)
Returns the texture coordinates of map id (inset half a pixel, so neighbouring tiles never bleed in), drawing its tile from maps when the map changed since; the paper tile when it got no tile in beginFrame.
void QcFramedMapAtlas::setColours(QList<QRgb> colours)
Sets colours, the colour of each block definition (QcMapColors::ofAtlas): every tile is drawn again.
std::shared_ptr<const QList<QcFramedMapAtlas::Tile>> QcFramedMapAtlas::tiles() const
Returns every tile; a new list only when a tile was drawn, so handing it to the renderer each frame copies nothing.
[static] QRectF QcFramedMapAtlas::uvOf(int index)
Returns the texture coordinates of tile index, inset half a pixel.
Member Variable Documentation
const int QcFramedMapAtlas::columns
Tiles per row and per column of the texture.
const int QcFramedMapAtlas::side
The texture's side in pixels.
const int QcFramedMapAtlas::tileCount
Number of tiles; tile 0 is blank paper.