OpenTTD Source 20241224-master-gf74b0cf984
landscape_partial_pixel_z.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#include "../stdafx.h"
11
12#include "../3rdparty/catch2/catch.hpp"
13
14#include "../landscape.h"
15#include "../slope_func.h"
16
26bool CheckPartialPixelZSlopeAddition(Slope slope_expected, Slope slope_a, Slope slope_b)
27{
28 for (uint x = 0; x < TILE_SIZE; x++) {
29 for (uint y = 0; y < TILE_SIZE; y++) {
30 int z_a = GetPartialPixelZ(x, y, slope_a);
31 int z_b = GetPartialPixelZ(x, y, slope_b);
32 int z_result = GetPartialPixelZ(x, y, slope_expected);
33 if (z_result != z_a + z_b) return false;
34 }
35 }
36 return true;
37}
38
39TEST_CASE("PartialPixelSlopeAdditionTest - A one corner slope, plus the opposite three corner slope results in a flat but elevated slope")
40{
45}
46
47TEST_CASE("PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope")
48{
51}
52
53TEST_CASE("PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope")
54{
57}
58
59TEST_CASE("PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners")
60{
63}
64
65TEST_CASE("PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope")
66{
71}
72
73TEST_CASE("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope")
74{
79}
80
88bool CheckPartialPixelZ(Slope slope, std::array<int, TILE_SIZE * TILE_SIZE> expected)
89{
90 for (uint i = 0; i < expected.size(); i++) {
91 int actual = GetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope);
92 if (actual != expected[i]) return false;
93 }
94 return true;
95}
96
97TEST_CASE("PartialPixelTest - One corner up slopes - SLOPE_N")
98{
100 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0,
101 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0,
102 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0,
103 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0,
104 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0,
105 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
106 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0,
107 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
108 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
116}
117
118TEST_CASE("PartialPixelTest - One corner up slopes - SLOPE_E")
119{
121 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
122 0, 0, 1, 1, 2,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 4, 4, 5, 5, 6, 6, 7, 7, 8}));
221}
222
223TEST_CASE("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_SW")
224{
226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
227 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
228 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
230 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
231 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
232 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
233 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
234 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
235 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
236 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
237 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
238 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
239 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
240 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
241 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}));
242}
243
244TEST_CASE("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_NW")
245{
247 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0,
248 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 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}));
347}
348
349TEST_CASE("PartialPixelTest - Three corner up slopes - SLOPE_WSE")
350{
352 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
353 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
354 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8,
355 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8,
356 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8,
357 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8,
358 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8,
359 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
360 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
361 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
362 5, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
363 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
364 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
365 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
366 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
367 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}));
368}
369
370TEST_CASE("PartialPixelTest - Three corner up slopes - SLOPE_NWS")
371{
373 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0,
374 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1,
375 8, 8, 8, 7, 7, 6, 6, 5, 5,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0, 0,
470 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0,
471 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0,
472 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0}));
473}
474
475TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_N")
476{
478 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8,
479 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8,
480 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7,
481 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7,
482 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6,
483 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6,
484 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5,
485 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5,
486 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4,
487 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4,
488 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3,
489 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3,
490 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2,
491 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2,
492 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1,
493 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1}));
494}
495
496TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_E")
497{
499 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,
500 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15,
501 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15,
502 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
503 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14,
504 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
505 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13,
506 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
507 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12,
508 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
509 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
510 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
511 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
512 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
513 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9,
514 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8}));
515}
516
517TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_S")
518{
520 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
521 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
522 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9,
523 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
524 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
525 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
526 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
527 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
528 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12,
529 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
530 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13,
531 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
532 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14,
533 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
534 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15,
535 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15}));
536}
537
538TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_W")
539{
541 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0,
542 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1,
543 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1,
544 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2,
545 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2,
546 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3,
547 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3,
548 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4,
549 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4,
550 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5,
551 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5,
552 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6,
553 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6,
554 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7,
555 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7,
556 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8}));
557}
558
559TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N")
560{
562 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
563 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8,
564 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7,
565 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7,
566 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6,
567 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6,
568 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5,
569 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5,
570 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4,
571 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4,
572 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3,
573 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3,
574 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2,
575 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2,
576 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1,
577 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1}));
578}
579
580TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E")
581{
583 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
584 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
585 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
586 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
587 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
588 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
589 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
590 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16,
591 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16,
592 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16,
593 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16,
594 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16,
595 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16,
596 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16,
597 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16,
598 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16}));
599}
600
601TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S")
602{
604 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
605 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16,
606 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16,
607 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16,
608 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16,
609 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16,
610 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16,
611 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16,
612 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16,
613 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16,
614 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
615 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
616 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
617 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
618 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
619 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}));
620}
621
622TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W")
623{
625 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0,
626 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1,
627 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1,
628 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2,
629 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2,
630 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3,
631 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3,
632 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4,
633 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4,
634 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5,
635 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5,
636 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6,
637 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6,
638 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7,
639 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7,
640 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8}));
641}
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
bool CheckPartialPixelZ(Slope slope, std::array< int, TILE_SIZE *TILE_SIZE > expected)
Check whether the partial pixel Z values are the expected values.
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 val...
static constexpr Slope HalftileSlope(Slope s, Corner corner)
Adds a halftile slope to a slope.
Definition slope_func.h:274
Slope
Enumeration for the slope-type.
Definition slope_type.h:48
@ SLOPE_W
the west corner of the tile is raised
Definition slope_type.h:50
@ SLOPE_ELEVATED
bit mask containing all 'simple' slopes
Definition slope_type.h:61
@ SLOPE_NS
north and south corner are raised
Definition slope_type.h:60
@ SLOPE_E
the east corner of the tile is raised
Definition slope_type.h:52
@ SLOPE_WSE
west, south and east corner are raised
Definition slope_type.h:63
@ SLOPE_S
the south corner of the tile is raised
Definition slope_type.h:51
@ SLOPE_N
the north corner of the tile is raised
Definition slope_type.h:53
@ SLOPE_SEN
south, east and north corner are raised
Definition slope_type.h:64
@ SLOPE_ENW
east, north and west corner are raised
Definition slope_type.h:65
@ SLOPE_SW
south and west corner are raised
Definition slope_type.h:56
@ SLOPE_STEEP_W
a steep slope falling to east (from west)
Definition slope_type.h:66
@ SLOPE_NE
north and east corner are raised
Definition slope_type.h:58
@ SLOPE_STEEP_E
a steep slope falling to west (from east)
Definition slope_type.h:68
@ SLOPE_SE
south and east corner are raised
Definition slope_type.h:57
@ SLOPE_NWS
north, west and south corner are raised
Definition slope_type.h:62
@ SLOPE_NW
north and west corner are raised
Definition slope_type.h:55
@ SLOPE_STEEP_N
a steep slope falling to south (from north)
Definition slope_type.h:69
@ SLOPE_STEEP_S
a steep slope falling to north (from south)
Definition slope_type.h:67
@ SLOPE_EW
east and west corner are raised
Definition slope_type.h:59
static const uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15