[Scummvm-git-logs] scummvm master -> e813af901fd6136dd1d55d375f03613cdc5489b6
OMGPizzaGuy
noreply at scummvm.org
Wed Jan 25 03:18:57 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:
b616f53a89 ULTIMA8: Improve item sorter debugging.
e813af901f ULTIMA8: Remove x & y flat checks that introduced bugs
Commit: b616f53a8950df44fb3ac96f6fae912a8393c5ca
https://github.com/scummvm/scummvm/commit/b616f53a8950df44fb3ac96f6fae912a8393c5ca
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-24T21:18:23-06:00
Commit Message:
ULTIMA8: Improve item sorter debugging.
Changed paths:
engines/ultima/ultima8/world/item_sorter.cpp
engines/ultima/ultima8/world/item_sorter.h
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index bc29c8de855..409188b06e2 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -43,7 +43,8 @@ namespace Ultima8 {
ItemSorter::ItemSorter(int capacity) :
_shapes(nullptr), _clipWindow(0, 0, 0, 0), _items(nullptr), _itemsTail(nullptr),
- _itemsUnused(nullptr), _painted(nullptr), _sortLimit(0), _camSx(0), _camSy(0) {
+ _itemsUnused(nullptr), _painted(nullptr), _camSx(0), _camSy(0),
+ _sortLimit(0), _sortLimitChanged(false) {
int i = capacity;
while (i--) _itemsUnused = new SortItem(_itemsUnused);
}
@@ -83,9 +84,17 @@ void ItemSorter::BeginDisplayList(const Rect &clipWindow, int32 camx, int32 camy
_painted = nullptr;
// Screenspace bounding box bottom x coord (RNB x coord)
- _camSx = (camx - camy) / 4;
+ int32 camSx = (camx - camy) / 4;
// Screenspace bounding box bottom extent (RNB y coord)
- _camSy = (camx + camy) / 8 - camz;
+ int32 camSy = (camx + camy) / 8 - camz;
+
+ if (camSx != _camSx || camSy != _camSy) {
+ _camSx = camSx;
+ _camSy = camSy;
+
+ // Reset sort limit debugging on camera move
+ _sortLimit = 0;
+ }
}
void ItemSorter::AddItem(int32 x, int32 y, int32 z, uint32 shapeNum, uint32 frame_num, uint32 flags, uint32 ext_flags, uint16 itemNum) {
@@ -288,8 +297,8 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si) {
SortItem::DependsList::iterator end = si->_depends.end();
while (it != end) {
if ((*it)->_order == -2) {
- //warning("cycle in paint dependency graph %d -> %d -> ... -> %d",
- // si->_shapeNum, (*it)->_shapeNum, si->_shapeNum);
+ debugC(kDebugObject, "Cycle in paint dependency graph %d -> %d -> ... -> %d",
+ si->_shapeNum, (*it)->_shapeNum, si->_shapeNum);
break;
}
else if ((*it)->_order == -1) {
@@ -299,9 +308,6 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si) {
++it;
}
- // Set our painting _order based on previously painted item
- si->_order = _painted ? _painted->_order + 1 : 0;
-
// Now paint us!
if (surf) {
// if (wire) si->info->draw_box_back(s, dispx, dispy, 255);
@@ -339,18 +345,21 @@ bool ItemSorter::PaintSortItem(RenderSurface *surf, SortItem *si) {
}
}
- if (_sortLimit) {
- if (si->_order == _sortLimit) {
- if (!_painted || _painted->_itemNum != si->_itemNum) {
- debugC(kDebugObject, "SortItem: %s", si->dumpInfo().c_str());
- if (_painted && si->overlap(_painted)) {
- debugC(kDebugObject, "Overlaps: %s", _painted->dumpInfo().c_str());
- }
- }
+ // Set our painting _order based on previously painted item
+ si->_order = _painted ? _painted->_order + 1 : 0;
- _painted = si;
- return true;
+ if (_sortLimit && si->_order == _sortLimit) {
+ if (_sortLimitChanged) {
+ _sortLimitChanged = false;
+
+ debugC(kDebugObject, "SortItem: %s", si->dumpInfo().c_str());
+ if (_painted && si->overlap(_painted)) {
+ debugC(kDebugObject, "Overlaps: %s", _painted->dumpInfo().c_str());
+ }
}
+
+ _painted = si;
+ return true;
}
_painted = si;
@@ -475,6 +484,7 @@ uint16 ItemSorter::Trace(int32 x, int32 y, HitFace *face, bool item_highlight) {
void ItemSorter::IncSortLimit(int count) {
_sortLimit += count;
+ _sortLimitChanged = true;
if (_sortLimit < 0)
_sortLimit = 0;
}
diff --git a/engines/ultima/ultima8/world/item_sorter.h b/engines/ultima/ultima8/world/item_sorter.h
index cf4a04b4370..a3bee29330a 100644
--- a/engines/ultima/ultima8/world/item_sorter.h
+++ b/engines/ultima/ultima8/world/item_sorter.h
@@ -41,8 +41,9 @@ class ItemSorter {
SortItem *_itemsUnused;
SortItem *_painted;
- int32 _sortLimit;
int32 _camSx, _camSy;
+ int32 _sortLimit;
+ bool _sortLimitChanged;
public:
ItemSorter(int capacity);
Commit: e813af901fd6136dd1d55d375f03613cdc5489b6
https://github.com/scummvm/scummvm/commit/e813af901fd6136dd1d55d375f03613cdc5489b6
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-24T21:18:23-06:00
Commit Message:
ULTIMA8: Remove x & y flat checks that introduced bugs
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 0fe83611992..96e9dcc9833 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -330,15 +330,15 @@ inline bool SortItem::below(const SortItem &si2) const {
return si1._sprite < si2._sprite;
// Clearly in y?
- if (si1._yFar < si2._yFar && si1._y <= si2._yFar)
+ if (si1._y <= si2._yFar)
return true;
- if (si1._yFar > si2._yFar && si1._yFar >= si2._y)
+ if (si1._yFar >= si2._y)
return false;
// Clearly in x?
- if (si1._xLeft < si2._xLeft && si1._x <= si2._xLeft)
+ if (si1._x <= si2._xLeft)
return true;
- if (si1._xLeft > si2._xLeft && si1._xLeft >= si2._x)
+ if (si1._xLeft >= si2._x)
return false;
// Inv items always drawn first if their z-bottom is equal or higher.
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index fd205a24e4c..3849a41edd7 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -186,6 +186,34 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
TS_ASSERT(!si2.below(si1));
}
+ /**
+ * Overlapping y-flat vs non-flat items
+ * Test case for rendering issue at MainActor::teleport 41 20063 13887 48
+ */
+ void test_y_flat_sort() {
+ Ultima::Ultima8::SortItem si1(nullptr);
+ Ultima::Ultima8::SortItem si2(nullptr);
+
+ si1._x = 64;
+ si1._y = 0;
+ si1._z = 16;
+ si1._xLeft = 0;
+ si1._yFar = 0;
+ si1._zTop = 32;
+ si1._solid = true;
+
+ si2._x = 64;
+ si2._y = 64;
+ si2._z = 0;
+ si2._xLeft = 0;
+ si2._yFar = 0;
+ si2._zTop = 40;
+ si2._solid = true;
+
+ TS_ASSERT(si1.below(si2));
+ TS_ASSERT(!si2.below(si1));
+ }
+
/* Overlapping non-flat occludes flat */
void test_basic_occludes() {
Ultima::Ultima8::SortItem si1(nullptr);
More information about the Scummvm-git-logs
mailing list