MCPcopy Create free account
hub / github.com/ddnet/ddnet / FillTmpTile

Function FillTmpTile

src/game/map/render_layer.cpp:57–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55constexpr std::array<CTexCoords, 8> TEX_COORDS_TABLE = MakeTexCoordsTable<8>();
56
57static void FillTmpTile(CGraphicTile *pTmpTile, CGraphicTileTextureCoords *pTmpTex, unsigned char Flags, unsigned char Index, int x, int y, const ivec2 &Offset, int Scale)
58{
59 if(pTmpTex)
60 {
61 uint8_t TableFlag = (Flags & (TILEFLAG_XFLIP | TILEFLAG_YFLIP)) + ((Flags & TILEFLAG_ROTATE) >> 1);
62 const auto &aTexX = TEX_COORDS_TABLE[TableFlag].m_aTexX;
63 const auto &aTexY = TEX_COORDS_TABLE[TableFlag].m_aTexY;
64
65 pTmpTex->m_TexCoordTopLeft.x = aTexX[0];
66 pTmpTex->m_TexCoordTopLeft.y = aTexY[0];
67 pTmpTex->m_TexCoordBottomLeft.x = aTexX[3];
68 pTmpTex->m_TexCoordBottomLeft.y = aTexY[3];
69 pTmpTex->m_TexCoordTopRight.x = aTexX[1];
70 pTmpTex->m_TexCoordTopRight.y = aTexY[1];
71 pTmpTex->m_TexCoordBottomRight.x = aTexX[2];
72 pTmpTex->m_TexCoordBottomRight.y = aTexY[2];
73
74 pTmpTex->m_TexCoordTopLeft.z = Index;
75 pTmpTex->m_TexCoordBottomLeft.z = Index;
76 pTmpTex->m_TexCoordTopRight.z = Index;
77 pTmpTex->m_TexCoordBottomRight.z = Index;
78
79 bool HasRotation = (Flags & TILEFLAG_ROTATE) != 0;
80 pTmpTex->m_TexCoordTopLeft.w = HasRotation;
81 pTmpTex->m_TexCoordBottomLeft.w = HasRotation;
82 pTmpTex->m_TexCoordTopRight.w = HasRotation;
83 pTmpTex->m_TexCoordBottomRight.w = HasRotation;
84 }
85
86 vec2 TopLeft(x * Scale + Offset.x, y * Scale + Offset.y);
87 vec2 BottomRight(x * Scale + Scale + Offset.x, y * Scale + Scale + Offset.y);
88 pTmpTile->m_TopLeft = TopLeft;
89 pTmpTile->m_BottomLeft.x = TopLeft.x;
90 pTmpTile->m_BottomLeft.y = BottomRight.y;
91 pTmpTile->m_TopRight.x = BottomRight.x;
92 pTmpTile->m_TopRight.y = TopLeft.y;
93 pTmpTile->m_BottomRight = BottomRight;
94}
95
96static void FillTmpTileSpeedup(CGraphicTile *pTmpTile, CGraphicTileTextureCoords *pTmpTex, unsigned char Flags, int x, int y, const ivec2 &Offset, int Scale, short AngleRotate)
97{

Callers 2

FillTmpTileSpeedupFunction · 0.85
AddTileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected