Surface iteration optimisation

Skips over surfaces that will literally never intentionally come into play.
This commit is contained in:
Fazana
2021-09-17 17:35:33 +01:00
parent 02a6bf0f95
commit 0b3c98557c

View File

@@ -39,6 +39,8 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
while (surfaceNode != NULL) {
surf = surfaceNode->surface;
surfaceNode = surfaceNode->next;
if (y > surf->upperY)
continue;
// Exclude a large number of walls immediately to optimize.
if (y < surf->lowerY || y > surf->upperY) {
@@ -407,6 +409,8 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
while (surfaceNode != NULL) {
surf = surfaceNode->surface;
surfaceNode = surfaceNode->next;
if (y < surf->lowerY - 30)
continue;
x1 = surf->vertex1[0];
z1 = surf->vertex1[2];
x2 = surf->vertex2[0];