MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckPartialPixelZSlopeAddition

Function CheckPartialPixelZSlopeAddition

src/tests/landscape_partial_pixel_z.cpp:28–39  ·  view source on GitHub ↗

* Check whether the addition of two slope's GetPartialPixelZ values results in * the GetPartialPixelZ values of the expected slope. * This iterates over all sub-pixel locations within a single tile. * @param slope_expected The slope that is expected. * @param slope_a The first slope of the addition. * @param slope_b The second slope of the addition. * @return True iff at all GetPartialPixelZ

Source from the content-addressed store, hash-verified

26 * @return True iff at all GetPartialPixelZ results are the same for each sub-tile position.
27 */
28bool CheckPartialPixelZSlopeAddition(Slope slope_expected, Slope slope_a, Slope slope_b)
29{
30 for (uint x = 0; x < TILE_SIZE; x++) {
31 for (uint y = 0; y < TILE_SIZE; y++) {
32 int z_a = GetPartialPixelZ(x, y, slope_a);
33 int z_b = GetPartialPixelZ(x, y, slope_b);
34 int z_result = GetPartialPixelZ(x, y, slope_expected);
35 if (z_result != z_a + z_b) return false;
36 }
37 }
38 return true;
39}
40
41TEST_CASE("PartialPixelSlopeAdditionTest - A one corner slope, plus the opposite three corner slope results in a flat but elevated slope")
42{

Callers 1

Calls 1

GetPartialPixelZFunction · 0.85

Tested by

no test coverage detected