* Determine the Z height of the corners of a specific tile edge * * @note If a tile has a non-continuous halftile foundation, a corner can have different heights wrt. its edges. * * @pre z1 and z2 must be initialized (typ. with TileZ). The corner heights just get added. * * @param tileh The slope of the tile. * @param edge The edge of interest. * @param z1 Gets incremented by the height of
| 356 | * @param z2 Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera) |
| 357 | */ |
| 358 | void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int &z1, int &z2) |
| 359 | { |
| 360 | static const Slope corners[4][4] = { |
| 361 | /* corner | steep slope |
| 362 | * z1 z2 | z1 z2 */ |
| 363 | {SLOPE_E, SLOPE_N, SLOPE_STEEP_E, SLOPE_STEEP_N}, // DIAGDIR_NE, z1 = E, z2 = N |
| 364 | {SLOPE_S, SLOPE_E, SLOPE_STEEP_S, SLOPE_STEEP_E}, // DIAGDIR_SE, z1 = S, z2 = E |
| 365 | {SLOPE_S, SLOPE_W, SLOPE_STEEP_S, SLOPE_STEEP_W}, // DIAGDIR_SW, z1 = S, z2 = W |
| 366 | {SLOPE_W, SLOPE_N, SLOPE_STEEP_W, SLOPE_STEEP_N}, // DIAGDIR_NW, z1 = W, z2 = N |
| 367 | }; |
| 368 | |
| 369 | int halftile_test = (IsHalftileSlope(tileh) ? SlopeWithOneCornerRaised(GetHalftileSlopeCorner(tileh)) : 0); |
| 370 | if (halftile_test == corners[edge][0]) z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side. |
| 371 | if (halftile_test == corners[edge][1]) z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side. |
| 372 | |
| 373 | if ((tileh & corners[edge][0]) != 0) z1 += TILE_HEIGHT; // z1 is raised |
| 374 | if ((tileh & corners[edge][1]) != 0) z2 += TILE_HEIGHT; // z2 is raised |
| 375 | if (RemoveHalftileSlope(tileh) == corners[edge][2]) z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope |
| 376 | if (RemoveHalftileSlope(tileh) == corners[edge][3]) z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Get slope of a tile on top of a (possible) foundation |
no test coverage detected