OpenTTD Source  20240919-master-gdf0233f4c2
landscape_partial_pixel_z.cpp File Reference
#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. More...
 
 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. More...
 
 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.