ULTIMA8: Fix paint order issue for flat objects slightly inside walls.

This might need to be altered to check against center points.
This commit is contained in:
Matthew Jimenez 2023-09-16 15:37:54 -05:00
parent 10a2e81e85
commit f6acb92dac
2 changed files with 34 additions and 0 deletions

View File

@ -473,6 +473,18 @@ inline bool SortItem::below(const SortItem &si2) const {
if (si1._roof != si2._roof)
return si1._roof > si2._roof;
// X-Flat gets drawn after
bool xFlat1 = si1._xLeft == si1._x;
bool xFlat2 = si2._xLeft == si2._x;
if (xFlat1 != xFlat2)
return xFlat1 < xFlat2;
// Y-Flat gets drawn after
bool yFlat1 = si1._yFar == si1._y;
bool yFlat2 = si2._yFar == si2._y;
if (yFlat1 != yFlat2)
return yFlat1 < yFlat2;
// Partial in X + Y front
if (si1._x + si1._y != si2._x + si2._y)
return (si1._x + si1._y < si2._x + si2._y);

View File

@ -222,6 +222,28 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si2.below(si1));
}
/**
* Overlapping x-flat vs non-flat items
* Test case for rendering issue at MainActor::teleport 40 13103 9951 48
* Tapestry should draw after wall
*/
void test_x_flat_sort() {
Ultima::Ultima8::SortItem si1;
Ultima::Ultima8::SortItem si2;
Ultima::Ultima8::Box b1(13247, 9983, 48, 32, 128, 40);
si1.setBoxBounds(b1, 0, 0);
si1._solid = true;
si1._occl = true;
si1._land = true;
Ultima::Ultima8::Box b2(13244, 9876, 48, 0, 96, 40);
si2.setBoxBounds(b2, 0, 0);
TS_ASSERT(si1.below(si2));
TS_ASSERT(!si2.below(si1));
}
/**
* Overlapping y-flat vs non-flat items
* Test case for rendering issue at MainActor::teleport 41 20063 13887 48