From 9ccb839ae2c34399417b2dd2ab7c29dc0aff3859 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sun, 16 Nov 2014 16:23:15 +1300 Subject: [PATCH] Fix slope inconsistency for 64bit - Fixed: Slope logic would change between 32bit and 64bit due to float math. --- src/p_map.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 066805d3f..b406dff7b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -736,11 +736,9 @@ bool PIT_CheckLine(line_t *ld, const FBoundingBox &box, FCheckPosition &tm) else { // Find the point on the line closest to the actor's center, and use // that to calculate openings - float dx = (float)ld->dx; - float dy = (float)ld->dy; - fixed_t r = (fixed_t)(((float)(tm.x - ld->v1->x) * dx + - (float)(tm.y - ld->v1->y) * dy) / - (dx*dx + dy*dy) * 16777216.f); + SQWORD r_den = (SQWORD(ld->dx)*ld->dx + SQWORD(ld->dy)*ld->dy) / (1 << 24); + SQWORD r_num = ((SQWORD(tm.x - ld->v1->x)*ld->dx) + (SQWORD(tm.y - ld->v1->y)*ld->dy)); + fixed_t r = (fixed_t)(r_num / r_den); /* Printf ("%d:%d: %d (%d %d %d %d) (%d %d %d %d)\n", level.time, ld-lines, r, ld->frontsector->floorplane.a, ld->frontsector->floorplane.b,