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

Method AnalyseTileFlags

src/game/editor/mapitems/image.cpp:25–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void CEditorImage::AnalyseTileFlags()
26{
27 std::fill(std::begin(m_aTileFlags), std::end(m_aTileFlags), 0);
28
29 size_t TileWidth = m_Width / 16;
30 size_t TileHeight = m_Height / 16;
31 if(TileWidth == TileHeight && m_Format == CImageInfo::FORMAT_RGBA)
32 {
33 int TileId = 0;
34 for(size_t ty = 0; ty < 16; ty++)
35 for(size_t tx = 0; tx < 16; tx++, TileId++)
36 {
37 bool Opaque = true;
38 for(size_t x = 0; x < TileWidth; x++)
39 for(size_t y = 0; y < TileHeight; y++)
40 {
41 size_t p = (ty * TileWidth + y) * m_Width + tx * TileWidth + x;
42 if(m_pData[p * 4 + 3] < 250)
43 {
44 Opaque = false;
45 break;
46 }
47 }
48
49 if(Opaque)
50 m_aTileFlags[TileId] |= TILEFLAG_OPAQUE;
51 }
52 }
53}
54
55void CEditorImage::Free()
56{

Callers 1

SaveMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected