- removed debug output from portal transition code.

- handle the case where a portal transition crosses more than a single boundary in one move.
This commit is contained in:
Christoph Oelckers 2016-02-24 10:08:23 +01:00
parent 326907f6ab
commit b01e0fa06e
3 changed files with 41 additions and 28 deletions

View file

@ -742,7 +742,7 @@ public:
bool IsHostile (AActor *other); bool IsHostile (AActor *other);
inline bool IsNoClip2() const; inline bool IsNoClip2() const;
void CheckPortalTransition(); void CheckPortalTransition(bool islinked);
// What species am I? // What species am I?
virtual FName GetSpecies(); virtual FName GetSpecies();

View file

@ -3289,40 +3289,45 @@ void AActor::SetRoll(angle_t r, bool interpolate)
} }
void AActor::CheckPortalTransition() void AActor::CheckPortalTransition(bool islinked)
{ {
if (!Sector->PortalBlocksMovement(sector_t::ceiling)) bool moved = false;
while (!Sector->PortalBlocksMovement(sector_t::ceiling))
{ {
AActor *port = Sector->SkyBoxes[sector_t::ceiling]; AActor *port = Sector->SkyBoxes[sector_t::ceiling];
if (Z() > port->threshold) if (Z() > port->threshold)
{ {
fixedvec3 oldpos = Pos(); fixedvec3 oldpos = Pos();
UnlinkFromWorld(); if (islinked && !moved) UnlinkFromWorld();
SetXYZ(PosRelative(port->Sector)); SetXYZ(PosRelative(port->Sector));
PrevX += X() - oldpos.x; PrevX += X() - oldpos.x;
PrevY += Y() - oldpos.y; PrevY += Y() - oldpos.y;
PrevZ += Z() - oldpos.z; PrevZ += Z() - oldpos.z;
LinkToWorld(); Sector = P_PointInSector(X(), Y());
if (player) Printf("Transitioned upwards to sector %d\n", Sector->sectornum); moved = true;
return;
} }
else break;
} }
if (!Sector->PortalBlocksMovement(sector_t::floor)) if (!moved)
{
while (!Sector->PortalBlocksMovement(sector_t::floor))
{ {
AActor *port = Sector->SkyBoxes[sector_t::floor]; AActor *port = Sector->SkyBoxes[sector_t::floor];
if (Z() < port->threshold && floorz < port->threshold) if (Z() < port->threshold && floorz < port->threshold)
{ {
fixedvec3 oldpos = Pos(); fixedvec3 oldpos = Pos();
UnlinkFromWorld(); if (islinked && !moved) UnlinkFromWorld();
SetXYZ(PosRelative(port->Sector)); SetXYZ(PosRelative(port->Sector));
PrevX += X() - oldpos.x; PrevX += X() - oldpos.x;
PrevY += Y() - oldpos.y; PrevY += Y() - oldpos.y;
PrevZ += Z() - oldpos.z; PrevZ += Z() - oldpos.z;
LinkToWorld(); Sector = P_PointInSector(X(), Y());
if (player) Printf("Transitioned downwards to sector %d\n", Sector->sectornum); moved = true;
return; }
else break;
} }
} }
if (islinked && moved) LinkToWorld();
} }
// //
@ -3392,7 +3397,7 @@ void AActor::Tick ()
UnlinkFromWorld (); UnlinkFromWorld ();
flags |= MF_NOBLOCKMAP; flags |= MF_NOBLOCKMAP;
SetXYZ(Vec3Offset(velx, vely, velz)); SetXYZ(Vec3Offset(velx, vely, velz));
CheckPortalTransition(); CheckPortalTransition(false);
SetMovement(velx, vely, velz); SetMovement(velx, vely, velz);
LinkToWorld (); LinkToWorld ();
} }
@ -3860,7 +3865,7 @@ void AActor::Tick ()
Crash(); Crash();
} }
CheckPortalTransition(); CheckPortalTransition(true);
UpdateWaterLevel (oldz); UpdateWaterLevel (oldz);

View file

@ -640,7 +640,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
// Due to interpolation this is not necessarily the same as the sector the camera is in. // Due to interpolation this is not necessarily the same as the sector the camera is in.
viewsector = R_PointInSubsector(viewx, viewy)->sector; viewsector = R_PointInSubsector(viewx, viewy)->sector;
if (!viewsector->PortalBlocksMovement(sector_t::ceiling)) bool moved = false;
while (!viewsector->PortalBlocksMovement(sector_t::ceiling))
{ {
AActor *point = viewsector->SkyBoxes[sector_t::ceiling]; AActor *point = viewsector->SkyBoxes[sector_t::ceiling];
if (viewz > point->threshold) if (viewz > point->threshold)
@ -648,9 +649,13 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
viewx += point->scaleX; viewx += point->scaleX;
viewy += point->scaleY; viewy += point->scaleY;
viewsector = R_PointInSubsector(viewx, viewy)->sector; viewsector = R_PointInSubsector(viewx, viewy)->sector;
moved = true;
} }
else break;
} }
if (!viewsector->PortalBlocksMovement(sector_t::floor)) if (!moved)
{
while (!viewsector->PortalBlocksMovement(sector_t::floor))
{ {
AActor *point = viewsector->SkyBoxes[sector_t::floor]; AActor *point = viewsector->SkyBoxes[sector_t::floor];
if (viewz < point->threshold) if (viewz < point->threshold)
@ -658,6 +663,9 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
viewx += point->scaleX; viewx += point->scaleX;
viewy += point->scaleY; viewy += point->scaleY;
viewsector = R_PointInSubsector(viewx, viewy)->sector; viewsector = R_PointInSubsector(viewx, viewy)->sector;
moved = true;
}
else break;
} }
} }
} }