[Scummvm-git-logs] scummvm master -> eb5a079fd315ecd87c00e3ffeaced73ca072eee0

OMGPizzaGuy noreply at scummvm.org
Wed Jan 25 04:59:45 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:
eb5a079fd3 ULTIMA8: Fix item sorter dependency graph cycle and add test


Commit: eb5a079fd315ecd87c00e3ffeaced73ca072eee0
    https://github.com/scummvm/scummvm/commit/eb5a079fd315ecd87c00e3ffeaced73ca072eee0
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-24T22:59:25-06:00

Commit Message:
ULTIMA8: Fix item sorter dependency graph cycle and add test

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 96e9dcc9833..65f351b7636 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -329,18 +329,6 @@ inline bool SortItem::below(const SortItem &si2) const {
 	if (si1._sprite != si2._sprite)
 		return si1._sprite < si2._sprite;
 
-	// Clearly in y?
-	if (si1._y <= si2._yFar)
-		return true;
-	if (si1._yFar >= si2._y)
-		return false;
-
-	// Clearly in x?
-	if (si1._x <= si2._xLeft)
-		return true;
-	if (si1._xLeft >= si2._x)
-		return false;
-
 	// Inv items always drawn first if their z-bottom is equal or higher.
 	// This is a bit of a hack as 2 places in Crusader there are keycards
 	// on tables but their z position is the bottom z of the table.
@@ -349,13 +337,25 @@ inline bool SortItem::below(const SortItem &si2) const {
 			return false;
 	}
 
-	// Clearly in z?
+	// Clearly in z with at least one non-flat?
 	if (si1._z < si2._z && si1._zTop <= si2._z)
 		return true;
 
 	if (si1._z > si2._z && si1._z >= si2._zTop)
 		return false;
 
+	// Clearly in y?
+	if (si1._y <= si2._yFar)
+		return true;
+	if (si1._yFar >= si2._y)
+		return false;
+
+	// Clearly in x?
+	if (si1._x <= si2._xLeft)
+		return true;
+	if (si1._xLeft >= si2._x)
+		return false;
+
 	// Overlapping z-bottom check
 	// If an object's base (z-bottom) is higher another's, it should be rendered after.
 	// This check must be on the z-bottom and not the z-top because two objects with the
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index 3849a41edd7..54bec8e327b 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -214,6 +214,35 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		TS_ASSERT(!si2.below(si1));
 	}
 
+	/**
+	 * Overlapping non-flat items clearly in z - avatar above candle
+	 * Test case for rendering issue at MainActor::teleport 6 7774 19876 48
+	 */
+	void test_nonflat_z_clear_sort() {
+		Ultima::Ultima8::SortItem si1(nullptr);
+		Ultima::Ultima8::SortItem si2(nullptr);
+
+		si1._x = 129;
+		si1._y = 32;
+		si1._z = 0;
+		si1._xLeft = 65;
+		si1._yFar = 0;
+		si1._zTop = 24;
+		si1._anim = true;
+		si1._solid = true;
+
+		si2._x = 64;
+		si2._y = 69;
+		si2._z = 24;
+		si2._xLeft = 0;
+		si2._yFar = 5;
+		si2._zTop = 64;
+		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