OpenTTD Source 20250206-master-g6089ed8059
landscape_partial_pixel_z.cpp File Reference

Tests for consistency/validity of the results of GetPartialPixelZ. More...

#include "../stdafx.h"
#include "../3rdparty/catch2/catch.hpp"
#include "../landscape.h"
#include "../slope_func.h"

Go to the source code of this file.

Functions

bool CheckPartialPixelZSlopeAddition (Slope slope_expected, Slope slope_a, Slope slope_b)
 Check whether the addition of two slope's GetPartialPixelZ values results in the GetPartialPixelZ values of the expected slope.
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - A one corner slope, plus the opposite three corner slope results in a flat but elevated slope")
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope")
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope")
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners")
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope")
 
 TEST_CASE ("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope")
 
bool CheckPartialPixelZ (Slope slope, std::array< int, TILE_SIZE *TILE_SIZE > expected)
 Check whether the partial pixel Z values are the expected values.
 
 TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_N")
 
 TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_E")
 
 TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_S")
 
 TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_W")
 
 TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_NE")
 
 TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_SE")
 
 TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_SW")
 
 TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_NW")
 
 TEST_CASE ("PartialPixelTest - Two opposite corner up slopes - SLOPE_NS")
 
 TEST_CASE ("PartialPixelTest - Two opposite corner up slopes - SLOPE_EW")
 
 TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_ENW")
 
 TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_SEN")
 
 TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_WSE")
 
 TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_NWS")
 
 TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_N")
 
 TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_E")
 
 TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_S")
 
 TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_W")
 
 TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_N")
 
 TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_E")
 
 TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_S")
 
 TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_W")
 
 TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N")
 
 TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E")
 
 TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S")
 
 TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W")
 

Detailed Description

Tests for consistency/validity of the results of GetPartialPixelZ.

Definition in file landscape_partial_pixel_z.cpp.

Function Documentation

◆ CheckPartialPixelZ()

bool CheckPartialPixelZ ( Slope  slope,
std::array< int, TILE_SIZE *TILE_SIZE expected 
)

Check whether the partial pixel Z values are the expected values.

The arrays are as if the map is rotated 45 degrees counterclockwise.

Parameters
slopeThe slope that is to be checked.
expectedThe expect partial pixels Z values.
Returns
True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates.

Definition at line 88 of file landscape_partial_pixel_z.cpp.

References GB(), and GetPartialPixelZ().

◆ CheckPartialPixelZSlopeAddition()

bool CheckPartialPixelZSlopeAddition ( Slope  slope_expected,
Slope  slope_a,
Slope  slope_b 
)

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.

Parameters
slope_expectedThe slope that is expected.
slope_aThe first slope of the addition.
slope_bThe second slope of the addition.
Returns
True iff at all GetPartialPixelZ results are the same for each sub-tile position.

Definition at line 26 of file landscape_partial_pixel_z.cpp.

References GetPartialPixelZ(), and TILE_SIZE.

◆ TEST_CASE() [1/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope"  )

Definition at line 73 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [2/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - A one corner  slope,
plus the opposite three corner slope results in a flat but elevated slope"   
)

Definition at line 39 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [3/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope"  )

Definition at line 65 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [4/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope"  )

Definition at line 47 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [5/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope"  )

Definition at line 53 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [6/32]

TEST_CASE ( "PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners"  )

Definition at line 59 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [7/32]

TEST_CASE ( "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E"  )

Definition at line 580 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [8/32]

TEST_CASE ( "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N"  )

Definition at line 559 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [9/32]

TEST_CASE ( "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S"  )

Definition at line 601 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [10/32]

TEST_CASE ( "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W"  )

Definition at line 622 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [11/32]

TEST_CASE ( "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_E"  )

Definition at line 412 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [12/32]

TEST_CASE ( "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_N"  )

Definition at line 391 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [13/32]

TEST_CASE ( "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_S"  )

Definition at line 433 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [14/32]

TEST_CASE ( "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_W"  )

Definition at line 454 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [15/32]

TEST_CASE ( "PartialPixelTest - One corner up slopes - SLOPE_E"  )

Definition at line 118 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [16/32]

TEST_CASE ( "PartialPixelTest - One corner up slopes - SLOPE_N"  )

Definition at line 97 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [17/32]

TEST_CASE ( "PartialPixelTest - One corner up slopes - SLOPE_S"  )

Definition at line 139 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [18/32]

TEST_CASE ( "PartialPixelTest - One corner up slopes - SLOPE_W"  )

Definition at line 160 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [19/32]

TEST_CASE ( "PartialPixelTest - Steep slopes - SLOPE_STEEP_E"  )

Definition at line 496 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [20/32]

TEST_CASE ( "PartialPixelTest - Steep slopes - SLOPE_STEEP_N"  )

Definition at line 475 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [21/32]

TEST_CASE ( "PartialPixelTest - Steep slopes - SLOPE_STEEP_S"  )

Definition at line 517 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [22/32]

TEST_CASE ( "PartialPixelTest - Steep slopes - SLOPE_STEEP_W"  )

Definition at line 538 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [23/32]

TEST_CASE ( "PartialPixelTest - Three corner up slopes - SLOPE_ENW"  )

Definition at line 307 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [24/32]

TEST_CASE ( "PartialPixelTest - Three corner up slopes - SLOPE_NWS"  )

Definition at line 370 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [25/32]

TEST_CASE ( "PartialPixelTest - Three corner up slopes - SLOPE_SEN"  )

Definition at line 328 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [26/32]

TEST_CASE ( "PartialPixelTest - Three corner up slopes - SLOPE_WSE"  )

Definition at line 349 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [27/32]

TEST_CASE ( "PartialPixelTest - Two corner  up,
diagonal slopes - SLOPE_NE"   
)

Definition at line 181 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [28/32]

TEST_CASE ( "PartialPixelTest - Two corner  up,
diagonal slopes - SLOPE_NW"   
)

Definition at line 244 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [29/32]

TEST_CASE ( "PartialPixelTest - Two corner  up,
diagonal slopes - SLOPE_SE"   
)

Definition at line 202 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [30/32]

TEST_CASE ( "PartialPixelTest - Two corner  up,
diagonal slopes - SLOPE_SW"   
)

Definition at line 223 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [31/32]

TEST_CASE ( "PartialPixelTest - Two opposite corner up slopes - SLOPE_EW"  )

Definition at line 286 of file landscape_partial_pixel_z.cpp.

◆ TEST_CASE() [32/32]

TEST_CASE ( "PartialPixelTest - Two opposite corner up slopes - SLOPE_NS"  )

Definition at line 265 of file landscape_partial_pixel_z.cpp.