[Scummvm-git-logs] scummvm master -> 478f821b7f135715ea1b4ee69773f0df676b3170
OMGPizzaGuy
noreply at scummvm.org
Mon Oct 2 02:30:42 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:
478f821b7f ULTIMA8: Improve tolerance check when comparing Z in sort item.
Commit: 478f821b7f135715ea1b4ee69773f0df676b3170
https://github.com/scummvm/scummvm/commit/478f821b7f135715ea1b4ee69773f0df676b3170
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-01T21:30:26-05:00
Commit Message:
ULTIMA8: Improve tolerance check when comparing Z in sort item.
Updated unit test with a better test case & solves a paint dependecy cycle.
Changed paths:
engines/ultima/ultima8/world/sort_item.cpp
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 aa983878406..177cc838122 100644
--- a/engines/ultima/ultima8/world/sort_item.cpp
+++ b/engines/ultima/ultima8/world/sort_item.cpp
@@ -72,11 +72,10 @@ bool SortItem::below(const SortItem &si2) const {
if (si1._z != si2._z)
return si1._z < si2._z;
} else if (si1._invitem == si2._invitem) {
- // Check with a tolerance based on footpad calculations
// Lower item cannot be inventory
- if (si1._zTop - 8 < si2._z)
+ if (si1._zTop <= si2._z)
return true;
- if (si1._z > si2._zTop - 8)
+ if (si1._z >= si2._zTop)
return false;
}
@@ -147,6 +146,12 @@ bool SortItem::below(const SortItem &si2) const {
return si1._fbigsq > si2._fbigsq;
}
+ // Check with a tolerance based on footpad calculations
+ if (si1._zTop - 8 <= si2._z && si1._z < si2._zTop - 8)
+ return true;
+ if (si1._z >= si2._zTop - 8 && si1._zTop - 8 > si2._z)
+ return false;
+
// Y-flat vs non-flat handling
if (yFlat1 != yFlat2) {
// Check with a precision loss based on footpad calculations
@@ -175,14 +180,6 @@ bool SortItem::below(const SortItem &si2) const {
return xCenter1 < xCenter2;
}
- // Check z-bottom with a tolerance
- if (si1._z != si2._z) {
- if (si1._z < si2._z - 8)
- return true;
- else if (si1._z - 8 > si2._z)
- return false;
- }
-
// Specialist handling for same location
if (si1._x == si2._x && si1._y == si2._y) {
// Trans always gets drawn after
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index d2d22b536e9..b5c2763c20b 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -315,14 +315,14 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
/**
* Overlapping x-flat vs non-flat floor where z order not clear
- * Test case for rendering issue at MainActor::teleport 40 12311 9415 48
+ * Test case for rendering issue at MainActor::teleport 37 17620 19260 104
* Tapestry should draw after floor
*/
void test_x_flat_z_tolerance_sort() {
Ultima::Ultima8::SortItem si1;
Ultima::Ultima8::SortItem si2;
- Ultima::Ultima8::Box b1(12543, 9727, 40, 256, 256, 8);
+ Ultima::Ultima8::Box b1(17663, 19199, 96, 256, 256, 8);
si1.setBoxBounds(b1, 0, 0);
si1._solid = true;
si1._occl = true;
@@ -330,7 +330,7 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
si1._land = true;
si1._fixed = true;
- Ultima::Ultima8::Box b2(12287, 9791, 46, 0, 96, 40);
+ Ultima::Ultima8::Box b2(17410, 19110, 96, 0, 96, 40);
si2.setBoxBounds(b2, 0, 0);
si2._fixed = true;
More information about the Scummvm-git-logs
mailing list