MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DrawField

Method DrawField

engine/Poseidon/UI/Map/UIMap.cpp:1246–1370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1244#define HEIGHT_LOG (GLandscape->GetTerrainRangeLog() - GLandscape->GetLandRangeLog())
1245
1246#define GetHeightNT(j, i) GLandscape->GetHeight((j) << HEIGHT_LOG, (i) << HEIGHT_LOG)
1247
1248void CStaticMap::DrawField(float x, float y, float xStep, float yStep, int i, int j, int iStep, int jStep)
1249{
1250 if (InRange(i, j) || InRange(i + iStep, j + jStep))
1251 {
1252 // draw only when there is a chance to draw anything
1253 Draw2DPars pars;
1254 int maxAlpha8 = 0;
1255
1256 float alpha = 0.5 + 0.1 * GetHeightNT(j, i);
1257 int alpha8TL = toIntFloor(alpha * 255);
1258 alpha = 0.5 + 0.1 * GetHeightNT(j, i + iStep);
1259 int alpha8TR = toIntFloor(alpha * 255);
1260 alpha = 0.5 + 0.1 * GetHeightNT(j + jStep, i);
1261 int alpha8BL = toIntFloor(alpha * 255);
1262 alpha = 0.5 + 0.1 * GetHeightNT(j + jStep, i + iStep);
1263 int alpha8BR = toIntFloor(alpha * 255);
1264
1265 if (maxAlpha8 <= alpha8TL)
1266 {
1267 if (alpha8TL > 255)
1268 {
1269 alpha8TL = 255;
1270 }
1271 maxAlpha8 = alpha8TL;
1272 }
1273 else if (alpha8TL < 0)
1274 {
1275 alpha8TL = 0;
1276 }
1277 if (maxAlpha8 <= alpha8TR)
1278 {
1279 if (alpha8TR > 255)
1280 {
1281 alpha8TR = 255;
1282 }
1283 maxAlpha8 = alpha8TR;
1284 }
1285 else if (alpha8TR < 0)
1286 {
1287 alpha8TR = 0;
1288 }
1289 if (maxAlpha8 <= alpha8BL)
1290 {
1291 if (alpha8BL > 255)
1292 {
1293 alpha8BL = 255;
1294 }
1295 maxAlpha8 = alpha8BL;
1296 }
1297 else if (alpha8BL < 0)
1298 {
1299 alpha8BL = 0;
1300 }
1301 if (maxAlpha8 <= alpha8BR)
1302 {
1303 if (alpha8BR > 255)

Callers

nothing calls this directly

Calls 13

Mult1p50Function · 0.85
Mult0p75Function · 0.85
GetRandomColorMethod · 0.80
ClampFlagsMethod · 0.80
PackedColorClass · 0.50
SetA8Method · 0.45
GetTextureMethod · 0.45
GetColorMethod · 0.45
SetUMethod · 0.45
SetVMethod · 0.45
UseMipmapMethod · 0.45
TextBankMethod · 0.45

Tested by

no test coverage detected