[Scummvm-git-logs] scummvm master -> 4af829d7a4c83c29d53f3f5bea1f41820733f4b8

OMGPizzaGuy noreply at scummvm.org
Tue Sep 26 02:54:07 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:
4af829d7a4 ULTIMA8: Fix wrong occlusions caused by different heights in the adjoined squares


Commit: 4af829d7a4c83c29d53f3f5bea1f41820733f4b8
    https://github.com/scummvm/scummvm/commit/4af829d7a4c83c29d53f3f5bea1f41820733f4b8
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-09-25T21:52:58-05:00

Commit Message:
ULTIMA8: Fix wrong occlusions caused by different heights in the adjoined squares

Changed paths:
    engines/ultima/ultima8/world/item_sorter.cpp
    engines/ultima/ultima8/world/sort_item.h


diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index 9857f1306ab..0cb6de2ee2b 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -298,18 +298,15 @@ void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool
 			si1->_xAdjoin && si1->_yAdjoin &&
 			si1->_xAdjoin->_yAdjoin && si1->_yAdjoin->_xAdjoin &&
 			si1->_xAdjoin->_yAdjoin == si1->_yAdjoin->_xAdjoin) {
-			SortItem *si2 = si1->_xAdjoin->_yAdjoin;
-			SortItem *siX = si1->_xAdjoin;
-			SortItem *siY = si1->_yAdjoin;
+			SortItem *si2 = si1;
+			SortItem *siX = si1;
+			SortItem *siY = si1;
 
 			int32 group = si1->_itemNum;
 			si1->_groupNum = group;
-			si2->_groupNum = group;
-			siX->_groupNum = group;
-			siY->_groupNum = group;
 
 			// Expand NxN adjoined square
-			for (int n = 3; n < 6; n++) {
+			for (int n = 2; n < 6; n++) {
 				// Expand out 1 from X and Y edge points
 				SortItem *p1 = siX->_xAdjoin;
 				SortItem *p2 = siY->_yAdjoin;
@@ -338,23 +335,29 @@ void ItemSorter::PaintDisplayList(RenderSurface *surf, bool item_highlight, bool
 				siY = siY->_yAdjoin;
 			}
 
-			SortItem oc;
-			oc._occl = true;
-			oc._fbigsq = true;
-			oc._flat = si1->_flat;
-			oc._solid = si1->_solid;
-			oc._roof = si1->_roof;
-			oc._fixed = si1->_fixed;
-			oc._land = si1->_land;
-
-			Box box = si1->getBoxBounds();
-			box.extend(si2->getBoxBounds());
-			oc.setBoxBounds(box, _camSx, _camSy);
-
-			for (si2 = _items; si2 != nullptr; si2 = si2->_next) {
-				if (si2->_groupNum != group && !si2->_occluded &&
-					si2->overlap(oc) && si2->below(oc) && oc.occludes(*si2)) {
-					si2->_occluded = true;
+			if (si1 != si2) {
+				SortItem oc;
+				oc._occl = true;
+				oc._fbigsq = true;
+				oc._flat = si1->_flat;
+				oc._solid = si1->_solid;
+				oc._roof = si1->_roof;
+				oc._fixed = si1->_fixed;
+				oc._land = si1->_land;
+
+				Box box = si1->getBoxBounds();
+				box.extend(si2->getBoxBounds());
+
+				// Keep the box flat to avoid wrong occlusions caused by different heights
+				box._zd = 0;
+
+				oc.setBoxBounds(box, _camSx, _camSy);
+
+				for (si2 = _items; si2 != nullptr; si2 = si2->_next) {
+					if (si2->_groupNum != group && !si2->_occluded &&
+						si2->overlap(oc) && si2->below(oc) && oc.occludes(*si2)) {
+						si2->_occluded = true;
+					}
 				}
 			}
 		}
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index 37d622d1eb3..83ca0c206c0 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -27,7 +27,6 @@
 #include "ultima/ultima8/misc/rect.h"
 #include "ultima/ultima8/misc/box.h"
 
-// Multiple wrong occlusions at MainActor::teleport 39 14680 7344 48
 //#define SORTITEM_OCCLUSION_EXPERIMENTAL 1
 
 namespace Ultima {




More information about the Scummvm-git-logs mailing list