diff --git a/src/p_map.cpp b/src/p_map.cpp index 8a5321cf3..0fe73229c 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2837,8 +2837,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t } // set openrange, opentop, openbottom - P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); if (open.range < slidemo->height) goto isblocking; // doesn't fit @@ -3192,8 +3191,7 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } - P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac)); // set openrange, opentop, openbottom + P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom if (open.range < slidemo->height) goto bounceblocking; // doesn't fit @@ -3811,8 +3809,7 @@ struct aim_t // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening(open, NULL, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac), FIXED_MIN, 0, FFCF_NODROPOFF); + P_LineOpening(open, NULL, li, it.InterceptPoint(in), FIXED_MIN, 0, FFCF_NODROPOFF); // The following code assumes that portals on the front of the line have already been processed. @@ -4985,8 +4982,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end } else { - P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); } if (open.range <= 0 || (in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING))) @@ -5094,8 +5090,7 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->special) continue; if (ld->isLinePortal()) return false; if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; - P_LineOpening(open, NULL, ld, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); if (open.range <= 0 || open.bottom > usething->Z() + usething->MaxStepHeight || open.top < usething->Top()) return true; @@ -5179,8 +5174,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { // Check line if (in->d.line->special != UsePuzzleItem) { - P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), - it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); if (open.range <= 0) { return false; // can't use through a wall diff --git a/src/p_maputl.h b/src/p_maputl.h index d8044303e..7f045c24f 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -26,7 +26,6 @@ struct intercept_t } d; }; - //========================================================================== // // P_PointOnLineSide @@ -107,6 +106,10 @@ struct FLineOpening }; void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0, int flags=0); +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixedvec2 xy, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) +{ + P_LineOpening(open, thing, linedef, xy.x, xy.y, refx, refy, flags); +} class FBoundingBox; struct polyblock_t; @@ -359,6 +362,16 @@ public: int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL); virtual ~FPathTraverse(); const divline_t &Trace() const { return trace; } + + inline fixedvec2 InterceptPoint(const intercept_t *in) + { + return + { + trace.x + FixedMul(trace.dx, in->frac), + trace.y + FixedMul(trace.dy, in->frac) + }; + } + }; //============================================================================ diff --git a/src/portal.cpp b/src/portal.cpp index 892c10ab7..01afb0bc4 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -709,14 +709,13 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy) // Teleport portals are intentionally ignored since skipping this stuff is their entire reason for existence. if (port->mFlags & PORTF_INTERACTIVE) { - fixed_t hitdx = FixedMul(it.Trace().dx, in->frac); - fixed_t hitdy = FixedMul(it.Trace().dy, in->frac); + fixedvec2 hit = it.InterceptPoint(in); if (port->mType == PORTT_LINKED) { // optimized handling for linked portals where we only need to add an offset. - actx = it.Trace().x + hitdx + port->mXDisplacement; - acty = it.Trace().y + hitdy + port->mYDisplacement; + hit.x += port->mXDisplacement; + hit.y += port->mYDisplacement; dest.x += port->mXDisplacement; dest.y += port->mYDisplacement; } @@ -724,15 +723,12 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy) { // interactive ones are more complex because the vector may be rotated. // Note: There is no z-translation here, there's just too much code in the engine that wouldn't be able to handle interactive portals with a height difference. - actx = it.Trace().x + hitdx; - acty = it.Trace().y + hitdy; - - P_TranslatePortalXY(line, out, actx, acty); + P_TranslatePortalXY(line, out, hit.x, hit.y); P_TranslatePortalXY(line, out, dest.x, dest.y); } // update the fields, end this trace and restart from the new position - dx = dest.x - actx; - dy = dest.y - acty; + dx = dest.x - hit.x; + dy = dest.y - hit.y; repeat = true; }