From 02f1f793338cdccf245fe85cb3e5b8e7b81e647c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 4 Oct 2022 18:49:23 +0200 Subject: [PATCH] - use .dot() for calculating slopes --- source/core/gamefuncs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 5ed9c955d..c520054e9 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -142,7 +142,8 @@ void calcSlope(const sectortype* sec, double xpos, double ypos, double* pceilz, double len = wal->Length(); if (len != 0) { - double fac = (wal->delta().X * (ypos - wal->pos.Y) - wal->delta().Y * (xpos - wal->pos.X)) / len * (1. / SLOPEVAL_FACTOR); + DVector2 wd = DVector2(xpos, ypos) - wal->pos; + double fac = wal->delta().dot(wd.Rotated90CW()) / len * (1. / SLOPEVAL_FACTOR); if (pceilz && sec->ceilingstat & CSTAT_SECTOR_SLOPE) *pceilz += (sec->ceilingheinum * fac); if (pflorz && sec->floorstat & CSTAT_SECTOR_SLOPE) *pflorz += (sec->floorheinum * fac); }