From fe56d2345db8d83691f2eca567576e24558ef26b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Oct 2022 15:53:57 +0200 Subject: [PATCH] - always use the float version of keepaway Does not work yet - movement is significantly different that the int version --- source/build/src/clip.cpp | 16 +++++++++------- source/core/gamefuncs.cpp | 4 ++-- source/core/gamefuncs.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index bee36f2f8..1f8d27b35 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -162,10 +162,6 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, fgoal = NearestPointOnLine(fgoal.X, fgoal.Y, fvec.X, fvec.Y, fvec.X + clipdelta.X, fvec.Y + clipdelta.Y, false); - goal.X = int(fgoal.X * worldtoint); - goal.Y = int(fgoal.Y * worldtoint); - - vec2_t const clipr = { clip.clipobjects[hitwall].x2() - clip.clipobjects[hitwall].x1(), clip.clipobjects[hitwall].y2() - clip.clipobjects[hitwall].y1()}; int32_t tempint; tempint = DMulScale(clipr.X, move.X, clipr.Y, move.Y, 6); @@ -189,9 +185,15 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect, } } - keepaway(clip, &goal.X, &goal.Y, hitwall); - xvect = (goal.X-vec.X)<<14; - yvect = (goal.Y-vec.Y)<<14; + keepaway(clip, fgoal, clip.clipobjects[hitwall]); + goal.X = int(fgoal.X * worldtoint); + goal.Y = int(fgoal.Y * worldtoint); + + //keepaway(clip, &goal.X, &goal.Y, hitwall); + //xvect = (goal.X-vec.X)<<14; + //yvect = (goal.Y-vec.Y)<<14; + xvect = FloatToFixed<4>(fgoal.X - fvec.X) << 14; + yvect = FloatToFixed<4>(fgoal.Y - fvec.Y) << 14; if (cnt == clipmoveboxtracenum) clipReturn = clip.clipobjects[hitwall].obj; diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 2fe6573f8..5c1f3111d 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -1672,7 +1672,7 @@ int FindBestSector(const DVector3& pos) //========================================================================== #if 0 -static inline void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo) +void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo) { // later, once we are using floats throughout we should be able to do this auto start = clipo.line.start, normal = clipo.line.delta().Rotated90CCW().Unit(); @@ -1683,7 +1683,7 @@ static inline void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo) } } #else -static inline void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo) +void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo) { // for now this has to be retained... auto start = clipo.line.start, normal = clipo.line.delta().Rotated90CCW(); diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index f857ed92f..6769db237 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -317,6 +317,7 @@ void collectClipObjects(MoveClipper& clip, int spritemask); int FindBestSector(const DVector3& pos); int FindSectorInSearchList(const DVector3& pos, BFSSectorSearch& search); void PushAway(MoveClipper &clip, DVector2& pos, sectortype* sect); +void keepaway(MoveClipper& clip, DVector2& pos, ClipObject& clipo); int FindBestSector(const DVector3& pos);