Skip to content

Fix physics quirkiness on slopes with convex sectors

Hanicef requested to merge Hanicef/SRB2:fix-slope-convex-sectors into next

!2214 (merged) introduced a regression on convex sectors which assumed that P_ClosestPointOnLine would be clamped within the line. the result was that slopes that had a line that close in angle to another on at the top would then incorrectly measure the distance from the wrong line, causing the game to think that the object was still not on top of the sector:

bitmap

here, the white dot is the highest point of the object, and the red line is the line that was used to match towards "closest" line. the result here is that it picks the wrong line when checking if if's inside the sector, resulting the function returning false positives on these sectors.

this patch fixes this by verifying that the point we got from P_ClosestPointOnLine is actually on the line, and clamps it if it's not. this works since if the point we're checking against is not perpendicular to the line we want the point from, it's guaranteed to always be at the edge of the line.

actually, fuck it. the old algorithm ain't working out so we're changing it.

this new algorithm appropriately called the ray casting algorithm solves it by simply checking the lines that levels with the point and counts the amount of lines on either side (left in our case). if the amount of lines on the left is odd, we're inside the line.

Edited by Hanicef

Merge request reports