[Scummvm-git-logs] scummvm master -> fb9cc2365bc35dc3d41fec040ade344ccebf56f5
OMGPizzaGuy
noreply at scummvm.org
Sat Sep 30 21:06:08 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ad8fee8fde ULTIMA8: Add unit test for sort item overlaps
fb9cc2365b ULTIMA8: Add debug message for unexpected paint order.
Commit: ad8fee8fde875c0efaab9ce579d584cd9f22ef67
https://github.com/scummvm/scummvm/commit/ad8fee8fde875c0efaab9ce579d584cd9f22ef67
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-09-30T15:59:28-05:00
Commit Message:
ULTIMA8: Add unit test for sort item overlaps
Changed paths:
engines/ultima/ultima8/world/sort_item.h
test/engines/ultima/ultima8/world/sort_item.h
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index 482e3eeeafa..3f69dbcb448 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 8515e6ba681..4bac9d77f2d 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -536,7 +536,6 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
si2._solid = true;
// Due to screenspace calculation changes these no longer overlap
- // !TODO: Investigate overlap as it slightly differs from contains
//TS_ASSERT(si1.overlap(si2));
//TS_ASSERT(si2.overlap(si1));
@@ -587,14 +586,18 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si2.below(si1));
}
- /* Overlapping non-flat occludes flat */
void test_basic_occludes() {
Ultima::Ultima8::SortItem si1;
Ultima::Ultima8::SortItem si2;
Ultima::Ultima8::Box b1(0, 0, 0, 128, 128, 16);
- Ultima::Ultima8::Box b2(0, 0, 0, 128, 128, 0);
si1.setBoxBounds(b1, 0, 0);
+ si2.setBoxBounds(b1, 0, 0);
+
+ TS_ASSERT(si1.occludes(si2));
+ TS_ASSERT(si2.occludes(si1));
+
+ Ultima::Ultima8::Box b2(0, 0, 0, 128, 128, 0);
si2.setBoxBounds(b2, 0, 0);
TS_ASSERT(si1.occludes(si2));
@@ -665,4 +668,66 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si1.contains(si1._sxTop + 1, si1._syTop));
TS_ASSERT(!si1.contains(si1._sxTop - 1, si1._syTop));
}
+
+ void test_basic_overlap() {
+ Ultima::Ultima8::SortItem si1;
+ Ultima::Ultima8::SortItem si2;
+
+ Ultima::Ultima8::Box b1(0, 0, 0, 128, 128, 16);
+ si1.setBoxBounds(b1, 0, 0);
+ si2.setBoxBounds(b1, 0, 0);
+
+ TS_ASSERT(si1.overlap(si2));
+ TS_ASSERT(si2.overlap(si1));
+
+ Ultima::Ultima8::Box b2(0, 0, 0, 128, 128, 0);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(si1.overlap(si2));
+ TS_ASSERT(si2.overlap(si1));
+
+ // Check outside bounds using flats
+ b1 = Ultima::Ultima8::Box(0, 0, 0, 128, 128, 0);
+ si1.setBoxBounds(b1, 0, 0);
+
+ b2 = Ultima::Ultima8::Box(128, 0, 0, 128, 128, 0);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(!si1.overlap(si2));
+ TS_ASSERT(!si2.overlap(si1));
+
+ b2 = Ultima::Ultima8::Box(-128, 0, 0, 128, 128, 0);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(!si1.overlap(si2));
+ TS_ASSERT(!si2.overlap(si1));
+
+ b2 = Ultima::Ultima8::Box(0, 128, 0, 128, 128, 0);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(!si1.overlap(si2));
+ TS_ASSERT(!si2.overlap(si1));
+
+ b2 = Ultima::Ultima8::Box(0, -128, 0, 128, 128, 0);
+ si2.setBoxBounds(b2, 0, 0);
+
+ TS_ASSERT(!si1.overlap(si2));
+ TS_ASSERT(!si2.overlap(si1));
+
+ // Check outside 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));
+ }
};
Commit: fb9cc2365bc35dc3d41fec040ade344ccebf56f5
https://github.com/scummvm/scummvm/commit/fb9cc2365bc35dc3d41fec040ade344ccebf56f5
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-09-30T16:05:21-05:00
Commit Message:
ULTIMA8: Add debug message for unexpected paint order.
This is an indication of a paint dependency cycle.
Changed paths:
engines/ultima/ultima8/world/item_sorter.cpp
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index 66c2933b193..c956c13fc3a 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -484,6 +484,9 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si, bool showFootp
debugC(kDebugObject, "SortItem: %s", si->dumpInfo().c_str());
if (_painted && si->overlap(*_painted)) {
debugC(kDebugObject, "Overlaps: %s", _painted->dumpInfo().c_str());
+ if (si->below(*_painted)) {
+ debugC(kDebugObject, "Paint order incorrect!");
+ }
}
}
More information about the Scummvm-git-logs
mailing list