From 7f08d3d96340d38e6a2de4ca78cc62eca6f0a751 Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Tue, 13 Jun 2023 12:57:33 -0400 Subject: [PATCH] Revert floor sorting optimizations (#639) They cause some weird collision bugs, and are thus not worth keeping until properly investigated. --- src/engine/surface_load.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 8f2e31a6..d3753755 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -120,6 +120,7 @@ static void clear_static_surfaces(void) { */ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surface *surface) { struct SurfaceNode *list; + s32 priority; s32 sortDir = 1; // highest to lowest, then insertion order (water and floors) s32 listIndex; @@ -135,6 +136,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac sortDir = 0; // insertion order } + s32 surfacePriority = surface->upperY * sortDir; struct SurfaceNode *newNode = alloc_surface_node(dynamic); newNode->surface = surface; @@ -156,18 +158,14 @@ 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. - if (listIndex == SPATIAL_PARTITION_WATER) { - s32 surfacePriority = surface->upperY * sortDir; - s32 priority; - while (list->next != NULL) { - priority = list->next->surface->upperY * sortDir; + while (list->next != NULL) { + priority = list->next->surface->upperY * sortDir; - if (surfacePriority > priority) { - break; - } - - list = list->next; + if (surfacePriority > priority) { + break; } + + list = list->next; } newNode->next = list->next;