From 8ad773a7ebbf1690697fea275b917e8ea15c607c Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Thu, 23 Sep 2021 12:59:06 -0700 Subject: [PATCH] Sort surfaces by upperY instrad of the first vertex --- src/engine/surface_load.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index eae8335b..1c7eb441 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -132,13 +132,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac sortDir = 0; // insertion order } - //! (Surface Cucking) Surfaces are sorted by the height of their first - // 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; + surfacePriority = surface->upperY * sortDir; 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. while (list->next != NULL) { - priority = list->next->surface->vertex1[1] * sortDir; + priority = list->next->surface->upperY * sortDir; if (surfacePriority > priority) { break;