Revert floor sorting optimizations (#639)

They cause some weird collision bugs, and are thus not worth keeping until properly investigated.
This commit is contained in:
Gregory Heskett
2023-06-13 12:57:33 -04:00
committed by GitHub
parent 5764ae0ece
commit 7f08d3d963

View File

@@ -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;