Sort surfaces by upperY instrad of the first vertex

This commit is contained in:
Arceveti
2021-09-23 12:59:06 -07:00
parent 426d8ebae3
commit 8ad773a7eb

View File

@@ -132,13 +132,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
sortDir = 0; // insertion order sortDir = 0; // insertion order
} }
//! (Surface Cucking) Surfaces are sorted by the height of their first surfacePriority = surface->upperY * sortDir;
// vertex. Since vertices aren't ordered by height, this causes many
// lower triangles to be sorted higher. This worsens surface cucking since
// many functions only use the first triangle in surface order that fits,
// missing higher surfaces.
// upperY would be a better sort method.
surfacePriority = surface->vertex1[1] * sortDir;
newNode->surface = surface; newNode->surface = surface;
@@ -150,7 +144,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
// Loop until we find the appropriate place for the surface in the list. // Loop until we find the appropriate place for the surface in the list.
while (list->next != NULL) { while (list->next != NULL) {
priority = list->next->surface->vertex1[1] * sortDir; priority = list->next->surface->upperY * sortDir;
if (surfacePriority > priority) { if (surfacePriority > priority) {
break; break;