[Scummvm-git-logs] scummvm master -> 644556324a352920882528b8b72df245defac393
OMGPizzaGuy
noreply at scummvm.org
Mon Jan 23 04:24:21 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9877dd915a ULTIMA8: Simplify item sort to have have fewer paths for flat vs non-flat items.
9fd47f8aba ULTIMA8: Small cleanup for sort item preliminary list sort.
644556324a ULTIMA8: Cleanup item sort dependency insertion
Commit: 9877dd915aa1d96bdbcc5d4bb696d4b75aa81bed
https://github.com/scummvm/scummvm/commit/9877dd915aa1d96bdbcc5d4bb696d4b75aa81bed
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-22T22:23:07-06:00
Commit Message:
ULTIMA8: Simplify item sort to have have fewer paths for flat vs non-flat items.
This also has more consistency for flat x & y coordinates. This does not address any specific rendering issue and counld introduce new issues, so it is not currently recommended for previous branches.
Changed paths:
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 7eda5e1a888..541f122a8a8 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -328,33 +328,55 @@ inline bool SortItem::below(const SortItem &si2) const {
return si1._sprite < si2._sprite;
// Clearly in y?
- if (si1._y <= si2._yFar)
+ if (si1._yFar < si2._yFar && si1._y <= si2._yFar)
return true;
- if (si1._yFar >= si2._y)
+ if (si1._yFar > si2._yFar && si1._yFar >= si2._y)
return false;
// Clearly in x?
- if (si1._x <= si2._xLeft)
+ if (si1._xLeft < si2._xLeft && si1._x <= si2._xLeft)
return true;
- if (si1._xLeft >= si2._x)
+ if (si1._xLeft > si2._xLeft && si1._xLeft >= si2._x)
return false;
- // Specialist z flat handling
- if (si1._flat && si2._flat) {
- // Differing z is easy for flats
- if (si1._z != si2._z)
- return si1._z < si2._z;
+ // 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.
+ if (si1._invitem) {
+ if (si1._z >= si2._z)
+ return false;
+ }
- // Equal z
+ // Clearly in z?
+ if (si1._z < si2._z && si1._zTop <= si2._z)
+ return true;
- // Animated always gets drawn after
- if (si1._anim != si2._anim)
- return si1._anim < si2._anim;
+ if (si1._z > si2._z && si1._z >= si2._zTop)
+ return false;
- // Trans always gets drawn after
- if (si1._trans != si2._trans)
- return si1._trans < si2._trans;
+ // 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
+ // same z-position may have different heights (think of a mouse sorting vs the Avatar).
+ if (si1._z != si2._z)
+ return si1._z < si2._z;
+ // Are overlapping in all 3 dimensions if we come here
+
+ // Flat always gets drawn before
+ if (si1._flat != si2._flat)
+ return si1._flat > si2._flat;
+
+ // Animated always gets drawn after
+ if (si1._anim != si2._anim)
+ return si1._anim < si2._anim;
+
+ // Trans always gets drawn after
+ if (si1._trans != si2._trans)
+ return si1._trans < si2._trans;
+
+ // Specialist z flat handling
+ if (si1._flat && si2._flat) {
// Draw always gets drawn first
if (si1._draw != si2._draw)
return si1._draw > si2._draw;
@@ -371,42 +393,6 @@ inline bool SortItem::below(const SortItem &si2) const {
if (si1._fbigsq != si2._fbigsq)
return si1._fbigsq > si2._fbigsq;
}
- // Mixed, or non flat
- else {
- // 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.
- if (si1._invitem) {
- if (si1._z >= si2._z)
- return false;
- }
-
- // Clearly in z
- if (si1._z < si2._z && si1._zTop <= si2._z)
- return true;
-
- if (si1._z > si2._z && si1._z >= si2._zTop)
- 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
- // same z-position may have different heights (think of a mouse sorting vs the Avatar).
- if (si1._z != si2._z)
- return si1._z < si2._z;
-
- // Equal z
-
- // Flat always gets drawn before
- if (si1._flat != si2._flat)
- return si1._flat > si2._flat;
-
- // Trans always gets drawn after
- if (si1._trans != si2._trans)
- return si1._trans < si2._trans;
- }
-
- // Are overlapping in all 3 dimentions if we come here
// Land always gets drawn first
if (si1._land != si2._land)
Commit: 9fd47f8aba4726bda74896209c07492879994bef
https://github.com/scummvm/scummvm/commit/9fd47f8aba4726bda74896209c07492879994bef
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-22T22:23:07-06:00
Commit Message:
ULTIMA8: Small cleanup for sort item preliminary list sort.
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 8fbf42c7c7e..4e6e4b4b7d5 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -177,7 +177,7 @@ void ItemSorter::AddItem(int32 x, int32 y, int32 z, uint32 shapeNum, uint32 fram
SortItem *addpoint = nullptr;
for (SortItem *si2 = _items; si2 != nullptr; si2 = si2->_next) {
// Get the insert point... which is before the first item that has higher z than us
- if (!addpoint && si->ListLessThan(si2))
+ if (!addpoint && si->listLessThan(*si2))
addpoint = si2;
// Doesn't overlap
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index 541f122a8a8..738d4c9557e 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -182,7 +182,7 @@ struct SortItem {
for (Node *n = list; n != nullptr; n = n->_next) {
// Get the insert point... which is before the first item that has higher z than us
- if (other->ListLessThan(n->val)) {
+ if (other->listLessThan(*(n->val))) {
nn->_next = n;
nn->_prev = n->_prev;
n->_prev = nn;
@@ -231,8 +231,11 @@ struct SortItem {
inline bool below(const SortItem &si2) const;
// Comparison for the sorted lists
- inline bool ListLessThan(const SortItem *other) const {
- return _z < other->_z || (_z == other->_z && _flat && !other->_flat);
+ inline bool listLessThan(const SortItem &si2) const {
+ const SortItem &si1 = *this;
+ if (si1._z != si2._z)
+ return si1._z < si2._z;
+ return si1._flat > si2._flat;
}
Common::String dumpInfo() const;
Commit: 644556324a352920882528b8b72df245defac393
https://github.com/scummvm/scummvm/commit/644556324a352920882528b8b72df245defac393
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-01-22T22:23:07-06:00
Commit Message:
ULTIMA8: Cleanup item sort dependency insertion
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 4e6e4b4b7d5..bc29c8de855 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -186,22 +186,22 @@ void ItemSorter::AddItem(int32 x, int32 y, int32 z, uint32 shapeNum, uint32 fram
// Attempt to find which is infront
if (si->below(*si2)) {
- // si2 occludes si (us)
if (si2->_occl && si2->occludes(*si)) {
// No need to do any more checks, this isn't visible
si->_occluded = true;
break;
+ } else {
+ // si1 is behind si2, so add it to si2's dependency list
+ si2->_depends.insert_sorted(si);
}
-
- // si1 is behind si2, so add it to si2's dependency list
- si2->_depends.insert_sorted(si);
} else {
- // ss occludes si2. Sadly, we can't remove it from the list.
- if (si->_occl && si->occludes(*si2))
+ if (si->_occl && si->occludes(*si2)) {
+ // Occluded, but we can't remove it from the list
si2->_occluded = true;
- // si2 is behind si1, so add it to si1's dependency list
- else
- si->_depends.push_back(si2);
+ } else {
+ // si2 is behind si1, so add it to si1's dependency list
+ si->_depends.insert_sorted(si2);
+ }
}
}
diff --git a/engines/ultima/ultima8/world/sort_item.h b/engines/ultima/ultima8/world/sort_item.h
index 738d4c9557e..0fe83611992 100644
--- a/engines/ultima/ultima8/world/sort_item.h
+++ b/engines/ultima/ultima8/world/sort_item.h
@@ -212,8 +212,7 @@ struct SortItem {
}
};
- //Std::vector<SortItem *> _depends; // All this Items dependencies (i.e. all objects behind)
- //Std::list<SortItem *> _depends; // All this Items dependencies (i.e. all objects behind)
+ // All this Items dependencies (i.e. all objects behind)
DependsList _depends;
// Functions
More information about the Scummvm-git-logs
mailing list