* Draws the pillars under high bridges. * * @param psid Image and palette of a bridge pillar. * @param ti #TileInfo of current bridge-middle-tile. * @param axis Orientation of bridge. * @param drawfarpillar Whether to draw the pillar at the back * @param x Sprite X position of front pillar. * @param y Sprite Y position of front pillar. * @param z_bridge Absolute height of bridge bottom. *
| 1096 | * @param z_bridge Absolute height of bridge bottom. |
| 1097 | */ |
| 1098 | static void DrawBridgePillars(const PalSpriteID &psid, const TileInfo *ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge) |
| 1099 | { |
| 1100 | static const int bounding_box_size[2] = {16, 2}; ///< bounding box size of pillars along bridge direction |
| 1101 | static const int back_pillar_offset[2] = { 0, 9}; ///< sprite position offset of back facing pillar |
| 1102 | |
| 1103 | static const int INF = 1000; ///< big number compared to sprite size |
| 1104 | static const SubSprite half_pillar_sub_sprite[2][2] = { |
| 1105 | { { -14, -INF, INF, INF }, { -INF, -INF, -15, INF } }, // X axis, north and south |
| 1106 | { { -INF, -INF, 15, INF }, { 16, -INF, INF, INF } }, // Y axis, north and south |
| 1107 | }; |
| 1108 | |
| 1109 | if (psid.sprite == 0) return; |
| 1110 | |
| 1111 | /* Determine ground height under pillars */ |
| 1112 | DiagDirection south_dir = AxisToDiagDir(axis); |
| 1113 | int z_front_north = ti->z; |
| 1114 | int z_back_north = ti->z; |
| 1115 | int z_front_south = ti->z; |
| 1116 | int z_back_south = ti->z; |
| 1117 | GetSlopePixelZOnEdge(ti->tileh, south_dir, z_front_south, z_back_south); |
| 1118 | GetSlopePixelZOnEdge(ti->tileh, ReverseDiagDir(south_dir), z_front_north, z_back_north); |
| 1119 | |
| 1120 | /* Shared height of pillars */ |
| 1121 | int z_front = std::max(z_front_north, z_front_south); |
| 1122 | int z_back = std::max(z_back_north, z_back_south); |
| 1123 | |
| 1124 | /* x and y size of bounding-box of pillars */ |
| 1125 | int w = bounding_box_size[axis]; |
| 1126 | int h = bounding_box_size[OtherAxis(axis)]; |
| 1127 | /* sprite position of back facing pillar */ |
| 1128 | int x_back = x - back_pillar_offset[axis]; |
| 1129 | int y_back = y - back_pillar_offset[OtherAxis(axis)]; |
| 1130 | |
| 1131 | /* Draw front pillars */ |
| 1132 | int bottom_z = DrawPillarColumn(z_front, z_bridge, psid, x, y, w, h); |
| 1133 | if (z_front_north < z_front) DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]); |
| 1134 | if (z_front_south < z_front) DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]); |
| 1135 | |
| 1136 | /* Draw back pillars, skip top two parts, which are hidden by the bridge */ |
| 1137 | int z_bridge_back = z_bridge - 2 * (int)TILE_HEIGHT; |
| 1138 | if (drawfarpillar && (z_back_north <= z_bridge_back || z_back_south <= z_bridge_back)) { |
| 1139 | bottom_z = DrawPillarColumn(z_back, z_bridge_back, psid, x_back, y_back, w, h); |
| 1140 | if (z_back_north < z_back) DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]); |
| 1141 | if (z_back_south < z_back) DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]); |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | /** |
| 1146 | * Retrieve the sprites required for catenary on a road/tram bridge. |
no test coverage detected