[Scummvm-git-logs] scummvm master -> f19a339c84a725329e8fce8ab29dc43310f75c58
OMGPizzaGuy
noreply at scummvm.org
Mon Oct 2 23:48:09 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f19a339c84 ULTIMA8: Fix sort item bounds to be inclusive of right and botton screenspace edges.
Commit: f19a339c84a725329e8fce8ab29dc43310f75c58
https://github.com/scummvm/scummvm/commit/f19a339c84a725329e8fce8ab29dc43310f75c58
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-02T18:47:32-05:00
Commit Message:
ULTIMA8: Fix sort item bounds to be inclusive of right and botton screenspace edges.
This fixes a flickering render issue where bounds did not properly check overlaps previously
Changed paths:
engines/ultima/ultima8/world/sort_item.cpp
engines/ultima/ultima8/world/sort_item.h
test/engines/ultima/ultima8/world/sort_item.h
diff --git a/engines/ultima/ultima8/world/sort_item.cpp b/engines/ultima/ultima8/world/sort_item.cpp
index 177cc838122..1c9af9d8b8f 100644
--- a/engines/ultima/ultima8/world/sort_item.cpp
+++ b/engines/ultima/ultima8/world/sort_item.cpp
@@ -53,8 +53,8 @@ void SortItem::setBoxBounds(const Box& box, int32 sx, int32 sy) {
// Screenspace rect - replace with shape frame calculations
_sr.left = _sxLeft;
_sr.top = _syTop;
- _sr.right = _sxRight;
- _sr.bottom = _syBot;
+ _sr.right = _sxRight + 1;
+ _sr.bottom = _syBot + 1;
// These help out with sorting. We calc them now, so it will be faster
_fbigsq = box._xd == box._yd && box._xd >= 128;
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index 5e84877e3f6..854808f6c73 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -326,8 +326,8 @@ inline bool SortItem::overlap(const SortItem &si2) const {
// 'normal' of bot right line (-2, 1) of the bounding box
const int32 dot_bot_right = -point_bot_diff[0] - point_bot_diff[1] * 2;
- const bool right_clear = _sxRight <= si2._sxLeft;
- const bool left_clear = _sxLeft >= si2._sxRight;
+ const bool right_clear = _sxRight < si2._sxLeft;
+ const bool left_clear = _sxLeft > si2._sxRight;
const bool top_left_clear = dot_top_left >= 0;
const bool top_right_clear = dot_top_right >= 0;
const bool bot_left_clear = dot_bot_left >= 0;
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index b5c2763c20b..f6e4838a16c 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -434,6 +434,30 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si2.below(si1));
}
+ /**
+ * Overlapping y-flats vs non-flat item only by one pixel edge
+ * Test case for rendering issue at MainActor::teleport 8 2143 1215 48
+ */
+ void test_y_flat_edge_overlap_sort() {
+ Ultima::Ultima8::SortItem si1;
+ Ultima::Ultima8::SortItem si2;
+
+ Ultima::Ultima8::Box b1(2239, 1055, 48, 64, 32, 40);
+ si1.setBoxBounds(b1, 0, 0);
+ si1._solid = true;
+ si1._fixed = true;
+
+ Ultima::Ultima8::Box b2(2175, 1055, 48, 96, 0, 40);
+ si2.setBoxBounds(b2, 0, 0);
+ si1._fixed = true;
+
+ TS_ASSERT(si1.overlap(si2));
+ TS_ASSERT(si2.overlap(si1));
+
+ TS_ASSERT(si1.below(si2));
+ TS_ASSERT(!si2.below(si1));
+ }
+
/**
* Completely Overlapping y-flats differing only in item number and frame
* Test case for rendering issue at MainActor::teleport 37 17628 19668 56
@@ -696,9 +720,9 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(si1.contains(si1._sxTop, si1._syTop));
TS_ASSERT(si1.contains(si1._sxLeft, (si1._syTop + si1._syBot) / 2));
- // Exclusive of right and bottom
- TS_ASSERT(!si1.contains(si1._sxBot, si1._syBot));
- TS_ASSERT(!si1.contains(si1._sxRight, (si1._syTop + si1._syBot) / 2));
+ // Inclusive of right and bottom
+ TS_ASSERT(si1.contains(si1._sxBot, si1._syBot));
+ TS_ASSERT(si1.contains(si1._sxRight, (si1._syTop + si1._syBot) / 2));
// Outside bounds
TS_ASSERT(!si1.contains(si1._sxBot, si1._syBot + 1));
@@ -760,17 +784,30 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si1.overlap(si2));
TS_ASSERT(!si2.overlap(si1));
- // Check outside left & right bounds using non-flats
+ // Check edge left & right bounds using non-flats
b1 = Ultima::Ultima8::Box(0, 0, 0, 128, 128, 32);
si1.setBoxBounds(b1, 0, 0);
b2 = Ultima::Ultima8::Box(128, -128, 0, 128, 128, 32);
si2.setBoxBounds(b2, 0, 0);
+ TS_ASSERT(si1.overlap(si2));
+ TS_ASSERT(si2.overlap(si1));
+
+ b2 = Ultima::Ultima8::Box(-128, 128, 0, 128, 128, 32);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(si1.overlap(si2));
+ TS_ASSERT(si2.overlap(si1));
+
+ // Check outside left & right bounds using non-flats
+ b2 = Ultima::Ultima8::Box(160, -128, 0, 128, 128, 32);
+ si2.setBoxBounds(b2, 0, 0);
+
TS_ASSERT(!si1.overlap(si2));
TS_ASSERT(!si2.overlap(si1));
- b2 = Ultima::Ultima8::Box(-128, 128, 0, 128, 128, 32);
+ b2 = Ultima::Ultima8::Box(-128, 160, 0, 128, 128, 32);
si2.setBoxBounds(b2, 0, 0);
TS_ASSERT(!si1.overlap(si2));
More information about the Scummvm-git-logs
mailing list