[Scummvm-git-logs] scummvm master -> 757e8343b77492d366173bd2bcb17f2b009b5975

OMGPizzaGuy noreply at scummvm.org
Wed Oct 4 20:38:59 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:
4c1f8dfc59 ULTIMA8: Check x & y flat rules before z flat rules.
757e8343b7 UTLIMA8: Found test case to support the partial in front rule.


Commit: 4c1f8dfc5928fc05d4444ba5a54e2af0bd84da8e
    https://github.com/scummvm/scummvm/commit/4c1f8dfc5928fc05d4444ba5a54e2af0bd84da8e
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-04T15:36:12-05:00

Commit Message:
ULTIMA8: Check x & y flat rules before z flat rules.

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 1c9af9d8b8f..d390070973c 100644
--- a/engines/ultima/ultima8/world/sort_item.cpp
+++ b/engines/ultima/ultima8/world/sort_item.cpp
@@ -107,6 +107,40 @@ bool SortItem::below(const SortItem &si2) const {
 			return false;
 	}
 
+	// 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
+		if (si1._y / 32 <= si2._yFar / 32)
+			return true;
+		if (si1._yFar / 32 >= si2._y / 32)
+			return false;
+
+		int32 yCenter1 = (si1._yFar / 32 + si1._y / 32) / 2;
+		int32 yCenter2 = (si2._yFar / 32 + si2._y / 32) / 2;
+		if (yCenter1 != yCenter2)
+			return yCenter1 < yCenter2;
+	}
+
+	// X-flat vs non-flat handling
+	if (xFlat1 != xFlat2) {
+		// Check with a precision loss based on footpad calculations
+		if (si1._x / 32 <= si2._xLeft / 32)
+			return true;
+		if (si1._xLeft / 32 >= si2._x / 32)
+			return false;
+
+		int32 xCenter1 = (si1._xLeft / 32 + si1._x / 32) / 2;
+		int32 xCenter2 = (si2._xLeft / 32 + si2._x / 32) / 2;
+		if (xCenter1 != xCenter2)
+			return xCenter1 < xCenter2;
+	}
+
 	// Specialist z flat handling
 	if (si1._flat || si2._flat) {
 		// Lower z-bottom drawn before
@@ -146,40 +180,6 @@ 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
-		if (si1._y / 32 <= si2._yFar / 32)
-			return true;
-		if (si1._yFar / 32 >= si2._y / 32)
-			return false;
-
-		int32 yCenter1 = (si1._yFar / 32 + si1._y / 32) / 2;
-		int32 yCenter2 = (si2._yFar / 32 + si2._y / 32) / 2;
-		if (yCenter1 != yCenter2)
-			return yCenter1 < yCenter2;
-	}
-
-	// X-flat vs non-flat handling
-	if (xFlat1 != xFlat2) {
-		// Check with a precision loss based on footpad calculations
-		if (si1._x / 32 <= si2._xLeft / 32)
-			return true;
-		if (si1._xLeft / 32 >= si2._x / 32)
-			return false;
-
-		int32 xCenter1 = (si1._xLeft / 32 + si1._x / 32) / 2;
-		int32 xCenter2 = (si2._xLeft / 32 + si2._x / 32) / 2;
-		if (xCenter1 != xCenter2)
-			return xCenter1 < xCenter2;
-	}
-
 	// 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 217d8490700..48f972a4855 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -402,7 +402,7 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 
 		Ultima::Ultima8::Box b2(17408, 17888, 96, 0, 96, 40);
 		si2.setBoxBounds(b2, 0, 0);
-		si1._fixed = true;
+		si2._fixed = true;
 
 		TS_ASSERT(si1.overlap(si2));
 		TS_ASSERT(si2.overlap(si1));
@@ -425,7 +425,7 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 
 		Ultima::Ultima8::Box b2(2111, 1055, 48, 96, 0, 40);
 		si2.setBoxBounds(b2, 0, 0);
-		si1._fixed = true;
+		si2._fixed = true;
 
 		TS_ASSERT(si1.overlap(si2));
 		TS_ASSERT(si2.overlap(si1));
@@ -449,7 +449,7 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 
 		Ultima::Ultima8::Box b2(2175, 1055, 48, 96, 0, 40);
 		si2.setBoxBounds(b2, 0, 0);
-		si1._fixed = true;
+		si2._fixed = true;
 
 		// These share a one pixel edge, but we need to ignore that currently to prevent paint dependency cycles
 		TS_ASSERT(!si1.overlap(si2));
@@ -512,6 +512,33 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		TS_ASSERT(!si2.below(si1));
 	}
 
+	/**
+	 * Overlapping y-flat vs z-flat floor where z order not clear
+	 * Test case for rendering issue at MainActor::teleport 37 22546 18656 56
+	 * Vines should draw after floor
+	 */
+	void test_y_flat_z_tolerance_sort() {
+		Ultima::Ultima8::SortItem si1;
+		Ultima::Ultima8::SortItem si2;
+
+		Ultima::Ultima8::Box b1(22271, 18431, 56, 128, 128, 0);
+		si1.setBoxBounds(b1, 0, 0);
+		si1._solid = true;
+		si1._occl = true;
+		si1._land = true;
+		si1._fixed = true;
+
+		Ultima::Ultima8::Box b2(22367, 18399, 48, 128, 0, 40);
+		si2.setBoxBounds(b2, 0, 0);
+		si2._fixed = true;
+
+		TS_ASSERT(si1.overlap(si2));
+		TS_ASSERT(si2.overlap(si1));
+
+		TS_ASSERT(si1.below(si2));
+		TS_ASSERT(!si2.below(si1));
+	}
+
 	/**
 	 * Overlapping fixed y-flat vs non-fixed non-flat items where the flat should draw first
 	 * Test case for rendering issue at MainActor::teleport 3 12355 5467 8


Commit: 757e8343b77492d366173bd2bcb17f2b009b5975
    https://github.com/scummvm/scummvm/commit/757e8343b77492d366173bd2bcb17f2b009b5975
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-10-04T15:36:12-05:00

Commit Message:
UTLIMA8: Found test case to support the partial in front rule.
The rules that temporarily replaced this rule appear to only work well for x & y flats

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 d390070973c..e14d4da26f9 100644
--- a/engines/ultima/ultima8/world/sort_item.cpp
+++ b/engines/ultima/ultima8/world/sort_item.cpp
@@ -203,29 +203,31 @@ bool SortItem::below(const SortItem &si2) const {
 	if (si1._z != si2._z)
 		return si1._z < si2._z;
 
-	// Higher screenspace left drawn before?
-	if (si1._sxLeft != si2._sxLeft)
-		return si1._sxLeft > si2._sxLeft;
-
-	// Lower screenspace bottom drawn before?
-	if (si1._syBot != si2._syBot)
-		return si1._syBot < si2._syBot;
+	if (xFlat1 || xFlat2 || yFlat1 || yFlat2) {
+		// Higher screenspace left drawn before?
+		if (si1._sxLeft != si2._sxLeft)
+			return si1._sxLeft > si2._sxLeft;
+
+		// Lower screenspace bottom drawn before?
+		if (si1._syBot != si2._syBot)
+			return si1._syBot < si2._syBot;
+	}
 
-	//// Partial in X + Y front
-	//if (si1._x + si1._y != si2._x + si2._y)
-	//	return (si1._x + si1._y < si2._x + si2._y);
+	// Partial in X + Y front
+	if (si1._x + si1._y != si2._x + si2._y)
+		return (si1._x + si1._y < si2._x + si2._y);
 
-	//// Partial in X + Y back
-	//if (si1._xLeft + si1._yFar != si2._xLeft + si2._yFar)
-	//	return (si1._xLeft + si1._yFar < si2._xLeft + si2._yFar);
+	// Partial in X + Y back
+	if (si1._xLeft + si1._yFar != si2._xLeft + si2._yFar)
+		return (si1._xLeft + si1._yFar < si2._xLeft + si2._yFar);
 
-	//// Partial in y?
-	//if (si1._y != si2._y)
-	//	return si1._y < si2._y;
+	// Partial in y?
+	if (si1._y != si2._y)
+		return si1._y < si2._y;
 
-	//// Partial in x?
-	//if (si1._x != si2._x)
-	//	return si1._x < si2._x;
+	// Partial in x?
+	if (si1._x != si2._x)
+		return si1._x < si2._x;
 
 	// Just sort by shape number
 	if (si1._shapeNum != si2._shapeNum)
diff --git a/test/engines/ultima/ultima8/world/sort_item.h b/test/engines/ultima/ultima8/world/sort_item.h
index 48f972a4855..ba412bdffd2 100644
--- a/test/engines/ultima/ultima8/world/sort_item.h
+++ b/test/engines/ultima/ultima8/world/sort_item.h
@@ -267,6 +267,33 @@ class U8SortItemTestSuite : public CxxTest::TestSuite {
 		TS_ASSERT(!si2.below(si1));
 	}
 
+	/**
+	 * Overlapping non-flat items partially in front draw after
+	 * Test case for rendering issue at MainActor::teleport 37 22730 18016 56
+	 */
+	void test_nonflat_partial_front_sort() {
+		Ultima::Ultima8::SortItem si1;
+		Ultima::Ultima8::SortItem si2;
+
+		Ultima::Ultima8::Box b1(22591, 17599, 56, 160, 160, 8);
+		si1.setBoxBounds(b1, 0, 0);
+		si1._solid = true;
+		si1._land = true;
+		si1._fixed = true;
+
+		Ultima::Ultima8::Box b2(22719, 17695, 56, 160, 160, 8);
+		si2.setBoxBounds(b2, 0, 0);
+		si2._solid = true;
+		si2._land = true;
+		si2._fixed = true;
+
+		TS_ASSERT(si1.overlap(si2));
+		TS_ASSERT(si2.overlap(si1));
+
+		TS_ASSERT(si1.below(si2));
+		TS_ASSERT(!si2.below(si1));
+	}
+
 	/**
 	 * Overlapping lower Z position transparent non-solid draw after
 	 * Test case for rendering issue at MainActor::teleport 50 2316 7812 48




More information about the Scummvm-git-logs mailing list