From da05dfa72e2c7014fbffca2b44364a0a5284d9e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 19 Jun 2016 12:32:45 +0200 Subject: [PATCH] fixed: Polyobject-based line portals may not cache their angle as it may change at any time. --- src/portal.cpp | 34 +++++++++++++++++++++++++++------- src/portal.h | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/portal.cpp b/src/portal.cpp index 41f2e755e..ec3d5d90f 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -272,14 +272,31 @@ static line_t *FindDestination(line_t *src, int tag) static void SetRotation(FLinePortal *port) { - if (port != NULL && port->mDestination != NULL) + if (port != nullptr && port->mDestination != nullptr) { - line_t *dst = port->mDestination; - line_t *line = port->mOrigin; - DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.; - port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions. - port->mCosRot = cosdeg(angle.Degrees); - port->mAngleDiff = angle; + if (port->mType != PORTT_LINKED) + { + line_t *dst = port->mDestination; + line_t *line = port->mOrigin; + DAngle angle = dst->Delta().Angle() - line->Delta().Angle() + 180.; + port->mSinRot = sindeg(angle.Degrees); // Here precision matters so use the slower but more precise versions. + port->mCosRot = cosdeg(angle.Degrees); + port->mAngleDiff = angle; + if ((line->sidedef[0]->Flags & WALLF_POLYOBJ) || (dst->sidedef[0]->Flags & WALLF_POLYOBJ)) + { + port->mFlags |= PORTF_POLYOBJ; + } + else + { + port->mFlags &= PORTF_POLYOBJ; + } + } + else + { + // Linked portals have no angular difference. + port->mSinRot = port->mCosRot = 0.; + port->mAngleDiff = 0.; + } } } @@ -593,6 +610,7 @@ void P_TranslatePortalXY(line_t* src, double& x, double& y) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. // offsets from line double nposx = x - src->v1->fX(); @@ -620,6 +638,7 @@ void P_TranslatePortalVXVY(line_t* src, double &velx, double &vely) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. double orig_velx = velx; double orig_vely = vely; @@ -638,6 +657,7 @@ void P_TranslatePortalAngle(line_t* src, DAngle& angle) if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; + if (port->mFlags & PORTF_POLYOBJ) SetRotation(port); // update the angle for polyportals. angle = (angle + port->mAngleDiff).Normalized360(); } diff --git a/src/portal.h b/src/portal.h index a87ae207f..44d636e4b 100644 --- a/src/portal.h +++ b/src/portal.h @@ -145,6 +145,7 @@ enum PORTF_PASSABLE = 2, PORTF_SOUNDTRAVERSE = 4, PORTF_INTERACTIVE = 8, + PORTF_POLYOBJ = 16, PORTF_TYPETELEPORT = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE, PORTF_TYPEINTERACTIVE = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE | PORTF_INTERACTIVE,