From 93ca75e1464cff49e5a1609d8d36f6a3d356661b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Nov 2022 09:55:24 +0100 Subject: [PATCH] - got rid of the two intermediate functions between clipmove_tweak_pos and InterceptLineSegments. --- source/build/src/clip.cpp | 11 ++++++++--- source/core/gamefuncs.h | 29 ----------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 3d238cf7b..720be6315 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -107,9 +107,14 @@ static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2, inline void clipmove_tweak_pos(const vec3_t *pos, int32_t gx, int32_t gy, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *daxptr, int32_t *dayptr) { - int32_t daz; - - if (rintersect(pos->X, pos->Y, 0, gx, gy, 0, x1, y1, x2, y2, daxptr, dayptr, &daz) == -1) + double result = InterceptLineSegments(pos->X * inttoworld, pos->Y * inttoworld, gx * inttoworld, gy * inttoworld, + x1 * inttoworld, y1 * inttoworld, (x2 - x1) * inttoworld, (y2 - y1) * inttoworld); + if (result >= 0) + { + *daxptr = int(pos->X + result * gx); + *dayptr = int(pos->Y + result * gy); + } + else { *daxptr = pos->X; *dayptr = pos->Y; diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 5e6eb3c49..6b659a4bb 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -498,15 +498,6 @@ inline double SquareDistToWall(double px, double py, const walltype* wal, DVecto double SquareDistToSector(double px, double py, const sectortype* sect, DVector2* point = nullptr); -inline double GetRayIntersect(const DVector3& start1, const DVector3& vect1, const DVector2& start2, const DVector2& vect2, DVector3& retv) -{ - double factor2; - double factor = InterceptLineSegments(start1.X, start1.Y, vect1.X, vect1.Y, start2.X, start2.Y, vect2.X, vect2.Y, &factor2); - if (factor <= 0) return -1; - retv = start1 + factor * vect1; - return factor2; -} - inline double BobVal(int val) { return g_sinbam((unsigned)val << 21); @@ -532,24 +523,4 @@ inline DAngle ClampViewPitch(const DAngle pitch) return clamp(pitch, GetMaxPitch(), GetMinPitch()); } -//========================================================================== -// -// old deprecated integer versions -// -//========================================================================== - -[[deprecated]] -inline int rintersect(int x1, int y1, int z1, int vx, int vy, int vz, int x3, int y3, int x4, int y4, int* intx, int* inty, int* intz) -{ - DVector3 retv; - double result = GetRayIntersect(DVector3(x1 * inttoworld, y1 * inttoworld, z1 * zinttoworld), DVector3(vx * inttoworld, vy * inttoworld, vz * zinttoworld), - DVector2(x3 * inttoworld, y3 * inttoworld), DVector2((x4 - x3) * inttoworld, (y4 - y3) * inttoworld), retv); - if (result < 0) return -1; - *intx = int(retv.X * worldtoint); - *inty = int(retv.Y * worldtoint); - *intz = int(retv.Z * zworldtoint); - return FloatToFixed(result); -} - - #include "updatesector.h"