From 58146790aa2bc68135054928881a4a9bf3d4b716 Mon Sep 17 00:00:00 2001 From: Reonu Date: Tue, 27 Apr 2021 21:18:07 +0100 Subject: [PATCH] Slope fix --- src/engine/surface_collision.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index cab0a35a..ad755b19 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -397,6 +397,7 @@ f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometr * Iterate through the list of floors and find the first floor under a given point. */ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, f32 *pheight) { + f32 slopeFix = -9999999999999999.0f; register struct Surface *surf; register s32 x1, z1, x2, z2, x3, z3; f32 nx, ny, nz; @@ -454,13 +455,16 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 // Find the height of the floor at a given location. height = -(x * nx + nz * z + oo) / ny; // Checks for floor interaction with a 78 unit buffer. + if (height < slopeFix) { + continue; + } if (y - (height + -78.0f) < 0.0f) { continue; } *pheight = height; floor = surf; - break; + slopeFix = height; } //! (Surface Cucking) Since only the first floor is returned and not the highest,