mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
fixed: Polyobject-based line portals may not cache their angle as it may change at any time.
This commit is contained in:
parent
4e148f00e6
commit
da05dfa72e
2 changed files with 28 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue