fixed: Polyobject-based line portals may not cache their angle as it may change at any time.

This commit is contained in:
Christoph Oelckers 2016-06-19 12:32:45 +02:00
parent 4e148f00e6
commit da05dfa72e
2 changed files with 28 additions and 7 deletions

View file

@ -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();
}

View file

@ -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,