mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +00:00
- some preparations for actor interpolation through wall portals.
This commit is contained in:
parent
58d3b04590
commit
e11da06e69
12 changed files with 47 additions and 50 deletions
|
@ -912,6 +912,8 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearInterpolation();
|
||||||
|
|
||||||
void Move(fixed_t dx, fixed_t dy, fixed_t dz)
|
void Move(fixed_t dx, fixed_t dy, fixed_t dz)
|
||||||
{
|
{
|
||||||
SetOrigin(X() + dx, Y() + dy, Z() + dz, true);
|
SetOrigin(X() + dx, Y() + dy, Z() + dz, true);
|
||||||
|
@ -1120,6 +1122,7 @@ public:
|
||||||
// [RH] Used to interpolate the view to get >35 FPS
|
// [RH] Used to interpolate the view to get >35 FPS
|
||||||
fixed_t PrevX, PrevY, PrevZ;
|
fixed_t PrevX, PrevY, PrevZ;
|
||||||
angle_t PrevAngle;
|
angle_t PrevAngle;
|
||||||
|
int PrevPortalGroup;
|
||||||
|
|
||||||
// ThingIDs
|
// ThingIDs
|
||||||
static void ClearTIDHashes ();
|
static void ClearTIDHashes ();
|
||||||
|
@ -1253,11 +1256,6 @@ public:
|
||||||
__pos.y = npos.y;
|
__pos.y = npos.y;
|
||||||
__pos.z = npos.z;
|
__pos.z = npos.z;
|
||||||
}
|
}
|
||||||
void SetMovement(fixed_t x, fixed_t y, fixed_t z)
|
|
||||||
{
|
|
||||||
// not yet implemented
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FActorIterator
|
class FActorIterator
|
||||||
|
|
|
@ -1257,6 +1257,7 @@ void G_FinishTravel ()
|
||||||
oldpawn->Destroy();
|
oldpawn->Destroy();
|
||||||
pawndup->Destroy ();
|
pawndup->Destroy ();
|
||||||
pawn->LinkToWorld ();
|
pawn->LinkToWorld ();
|
||||||
|
pawn->ClearInterpolation();
|
||||||
pawn->AddToHash ();
|
pawn->AddToHash ();
|
||||||
pawn->SetState(pawn->SpawnState);
|
pawn->SetState(pawn->SpawnState);
|
||||||
pawn->player->SendPitchLimits();
|
pawn->player->SendPitchLimits();
|
||||||
|
|
|
@ -27,11 +27,8 @@ void AFastProjectile::Tick ()
|
||||||
fixed_t zfrac;
|
fixed_t zfrac;
|
||||||
int changexy;
|
int changexy;
|
||||||
|
|
||||||
PrevX = X();
|
ClearInterpolation();
|
||||||
PrevY = Y();
|
|
||||||
PrevZ = Z();
|
|
||||||
fixed_t oldz = Z();
|
fixed_t oldz = Z();
|
||||||
PrevAngle = angle;
|
|
||||||
|
|
||||||
if (!(flags5 & MF5_NOTIMEFREEZE))
|
if (!(flags5 & MF5_NOTIMEFREEZE))
|
||||||
{
|
{
|
||||||
|
|
|
@ -590,10 +590,7 @@ void AActorMover::Activate (AActor *activator)
|
||||||
// Don't let the renderer interpolate between the actor's
|
// Don't let the renderer interpolate between the actor's
|
||||||
// old position and its new position.
|
// old position and its new position.
|
||||||
Interpolate ();
|
Interpolate ();
|
||||||
tracer->PrevX = tracer->X();
|
tracer->ClearInterpolation();
|
||||||
tracer->PrevY = tracer->Y();
|
|
||||||
tracer->PrevZ = tracer->Z();
|
|
||||||
tracer->PrevAngle = tracer->angle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AActorMover::Deactivate (AActor *activator)
|
void AActorMover::Deactivate (AActor *activator)
|
||||||
|
|
|
@ -458,9 +458,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
|
||||||
}
|
}
|
||||||
// Do not interpolate from the position the actor was at when it was
|
// Do not interpolate from the position the actor was at when it was
|
||||||
// picked up, in case that is different from where it is now.
|
// picked up, in case that is different from where it is now.
|
||||||
self->PrevX = self->X();
|
self->ClearInterpolation();
|
||||||
self->PrevY = self->Y();
|
|
||||||
self->PrevZ = self->Z();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,9 +525,7 @@ bool P_Move (AActor *actor)
|
||||||
// so make it switchable
|
// so make it switchable
|
||||||
if (nomonsterinterpolation)
|
if (nomonsterinterpolation)
|
||||||
{
|
{
|
||||||
actor->PrevX = actor->X();
|
actor->ClearInterpolation();
|
||||||
actor->PrevY = actor->Y();
|
|
||||||
actor->PrevZ = actor->Z();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_ok && friction > ORIG_FRICTION)
|
if (try_ok && friction > ORIG_FRICTION)
|
||||||
|
@ -2520,6 +2518,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele
|
||||||
// CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions.
|
// CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions.
|
||||||
fixed_t oldX = actor->X();
|
fixed_t oldX = actor->X();
|
||||||
fixed_t oldY = actor->Y();
|
fixed_t oldY = actor->Y();
|
||||||
|
int oldgroup = actor->PrevPortalGroup;
|
||||||
FTextureID oldFloor = actor->floorpic;
|
FTextureID oldFloor = actor->floorpic;
|
||||||
|
|
||||||
// chase towards player
|
// chase towards player
|
||||||
|
@ -2537,6 +2536,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele
|
||||||
{
|
{
|
||||||
actor->PrevX = oldX;
|
actor->PrevX = oldX;
|
||||||
actor->PrevY = oldY;
|
actor->PrevY = oldY;
|
||||||
|
actor->PrevPortalGroup = oldgroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(flags & CHF_STOPIFBLOCKED))
|
if (!(flags & CHF_STOPIFBLOCKED))
|
||||||
|
|
|
@ -508,10 +508,6 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra
|
||||||
R_ResetViewInterpolation();
|
R_ResetViewInterpolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
thing->PrevX = x;
|
|
||||||
thing->PrevY = y;
|
|
||||||
thing->PrevZ = z;
|
|
||||||
|
|
||||||
// If this teleport was caused by a move, P_TryMove() will handle the
|
// If this teleport was caused by a move, P_TryMove() will handle the
|
||||||
// sector transition messages better than we can here.
|
// sector transition messages better than we can here.
|
||||||
if (!(thing->flags6 & MF6_INTRYMOVE))
|
if (!(thing->flags6 & MF6_INTRYMOVE))
|
||||||
|
|
|
@ -416,6 +416,7 @@ bool AActor::FixMapthingPos()
|
||||||
// Get the distance we have to move the object away from the wall
|
// Get the distance we have to move the object away from the wall
|
||||||
distance = radius - distance;
|
distance = radius - distance;
|
||||||
SetXY(X() + FixedMul(distance, finecosine[finean]), Y() + FixedMul(distance, finesine[finean]));
|
SetXY(X() + FixedMul(distance, finecosine[finean]), Y() + FixedMul(distance, finesine[finean]));
|
||||||
|
ClearInterpolation();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,9 +534,9 @@ void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving)
|
||||||
{
|
{
|
||||||
UnlinkFromWorld ();
|
UnlinkFromWorld ();
|
||||||
SetXYZ(ix, iy, iz);
|
SetXYZ(ix, iy, iz);
|
||||||
if (moving) SetMovement(ix - X(), iy - Y(), iz - Z());
|
|
||||||
LinkToWorld ();
|
LinkToWorld ();
|
||||||
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
|
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
|
||||||
|
if (!moving) ClearInterpolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -473,10 +473,7 @@ void AActor::Serialize (FArchive &arc)
|
||||||
Speed = GetDefault()->Speed;
|
Speed = GetDefault()->Speed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrevX = X();
|
ClearInterpolation();
|
||||||
PrevY = Y();
|
|
||||||
PrevZ = Z();
|
|
||||||
PrevAngle = angle;
|
|
||||||
UpdateWaterLevel(Z(), false);
|
UpdateWaterLevel(Z(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3304,6 +3301,7 @@ void AActor::CheckPortalTransition(bool islinked)
|
||||||
PrevY += Y() - oldpos.y;
|
PrevY += Y() - oldpos.y;
|
||||||
PrevZ += Z() - oldpos.z;
|
PrevZ += Z() - oldpos.z;
|
||||||
Sector = P_PointInSector(X(), Y());
|
Sector = P_PointInSector(X(), Y());
|
||||||
|
PrevPortalGroup = Sector->PortalGroup;
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
@ -3322,6 +3320,7 @@ void AActor::CheckPortalTransition(bool islinked)
|
||||||
PrevY += Y() - oldpos.y;
|
PrevY += Y() - oldpos.y;
|
||||||
PrevZ += Z() - oldpos.z;
|
PrevZ += Z() - oldpos.z;
|
||||||
Sector = P_PointInSector(X(), Y());
|
Sector = P_PointInSector(X(), Y());
|
||||||
|
PrevPortalGroup = Sector->PortalGroup;
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
@ -3368,10 +3367,7 @@ void AActor::Tick ()
|
||||||
|
|
||||||
// This is necessary to properly interpolate movement outside this function
|
// This is necessary to properly interpolate movement outside this function
|
||||||
// like from an ActorMover
|
// like from an ActorMover
|
||||||
PrevX = X();
|
ClearInterpolation();
|
||||||
PrevY = Y();
|
|
||||||
PrevZ = Z();
|
|
||||||
PrevAngle = angle;
|
|
||||||
|
|
||||||
if (flags5 & MF5_NOINTERACTION)
|
if (flags5 & MF5_NOINTERACTION)
|
||||||
{
|
{
|
||||||
|
@ -3398,7 +3394,6 @@ void AActor::Tick ()
|
||||||
flags |= MF_NOBLOCKMAP;
|
flags |= MF_NOBLOCKMAP;
|
||||||
SetXYZ(Vec3Offset(velx, vely, velz));
|
SetXYZ(Vec3Offset(velx, vely, velz));
|
||||||
CheckPortalTransition(false);
|
CheckPortalTransition(false);
|
||||||
SetMovement(velx, vely, velz);
|
|
||||||
LinkToWorld ();
|
LinkToWorld ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4157,9 +4152,6 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t
|
||||||
actor->Conversation = NULL;
|
actor->Conversation = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
actor->PrevX = ix;
|
|
||||||
actor->PrevY = iy;
|
|
||||||
actor->PrevZ = iz;
|
|
||||||
actor->SetXYZ(ix, iy, iz);
|
actor->SetXYZ(ix, iy, iz);
|
||||||
actor->picnum.SetInvalid();
|
actor->picnum.SetInvalid();
|
||||||
actor->health = actor->SpawnHealth();
|
actor->health = actor->SpawnHealth();
|
||||||
|
@ -4195,6 +4187,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t
|
||||||
|
|
||||||
// set subsector and/or block links
|
// set subsector and/or block links
|
||||||
actor->LinkToWorld (SpawningMapThing);
|
actor->LinkToWorld (SpawningMapThing);
|
||||||
|
actor->ClearInterpolation();
|
||||||
|
|
||||||
actor->dropoffz = // killough 11/98: for tracking dropoffs
|
actor->dropoffz = // killough 11/98: for tracking dropoffs
|
||||||
actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy);
|
actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy);
|
||||||
|
@ -5822,6 +5815,7 @@ bool P_CheckMissileSpawn (AActor* th, fixed_t maxdist)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
th->ClearInterpolation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
|
||||||
oldy = source->Y();
|
oldy = source->Y();
|
||||||
oldz = source->Z();
|
oldz = source->Z();
|
||||||
|
|
||||||
source->SetOrigin (x, y, z, false);
|
source->SetOrigin (x, y, z, true);
|
||||||
if (P_TestMobjLocation (source))
|
if (P_TestMobjLocation (source))
|
||||||
{
|
{
|
||||||
if (fog)
|
if (fog)
|
||||||
|
@ -138,9 +138,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
|
||||||
P_SpawnTeleportFog(source, x, y, z, false, true);
|
P_SpawnTeleportFog(source, x, y, z, false, true);
|
||||||
P_SpawnTeleportFog(source, oldx, oldy, oldz, true, true);
|
P_SpawnTeleportFog(source, oldx, oldy, oldz, true, true);
|
||||||
}
|
}
|
||||||
source->PrevX = x;
|
source->ClearInterpolation();
|
||||||
source->PrevY = y;
|
|
||||||
source->PrevZ = z;
|
|
||||||
if (source == players[consoleplayer].camera)
|
if (source == players[consoleplayer].camera)
|
||||||
{
|
{
|
||||||
R_ResetViewInterpolation();
|
R_ResetViewInterpolation();
|
||||||
|
@ -149,7 +147,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source->SetOrigin (oldx, oldy, oldz, false);
|
source->SetOrigin (oldx, oldy, oldz, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,6 +693,8 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedvec3 old = caller->Pos();
|
fixedvec3 old = caller->Pos();
|
||||||
|
int oldpgroup = caller->Sector->PortalGroup;
|
||||||
|
|
||||||
zofs += FixedMul(reference->height, heightoffset);
|
zofs += FixedMul(reference->height, heightoffset);
|
||||||
|
|
||||||
|
|
||||||
|
@ -744,12 +744,12 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
|
||||||
{
|
{
|
||||||
if (flags & WARPF_TOFLOOR)
|
if (flags & WARPF_TOFLOOR)
|
||||||
{
|
{
|
||||||
caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs);
|
caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs, true);
|
||||||
caller->SetZ(caller->floorz + zofs);
|
caller->SetZ(caller->floorz + zofs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs);
|
caller->SetOrigin(xofs + FixedMul(rad, finecosine[fineangle]), yofs + FixedMul(rad, finesine[fineangle]), zofs, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,23 +782,29 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs,
|
||||||
caller->velz = 0;
|
caller->velz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is no fun with line portals
|
||||||
if (flags & WARPF_WARPINTERPOLATION)
|
if (flags & WARPF_WARPINTERPOLATION)
|
||||||
{
|
{
|
||||||
caller->PrevX += caller->X() - old.x;
|
// This just translates the movement but doesn't change the vector
|
||||||
caller->PrevY += caller->Y() - old.y;
|
fixedvec3 displacedold = old + Displacements(oldpgroup, caller->Sector->PortalGroup);
|
||||||
caller->PrevZ += caller->Z() - old.z;
|
caller->PrevX += caller->X() - displacedold.x;
|
||||||
|
caller->PrevY += caller->Y() - displacedold.y;
|
||||||
|
caller->PrevZ += caller->Z() - displacedold.z;
|
||||||
|
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
||||||
}
|
}
|
||||||
else if (flags & WARPF_COPYINTERPOLATION)
|
else if (flags & WARPF_COPYINTERPOLATION)
|
||||||
{
|
{
|
||||||
|
// Map both positions of the reference actor to the current portal group
|
||||||
|
fixedvec3 displacedold = old + Displacements(reference->PrevPortalGroup, caller->Sector->PortalGroup);
|
||||||
|
fixedvec3 displacedref = old + Displacements(reference->Sector->PortalGroup, caller->Sector->PortalGroup);
|
||||||
caller->PrevX = caller->X() + reference->PrevX - reference->X();
|
caller->PrevX = caller->X() + reference->PrevX - reference->X();
|
||||||
caller->PrevY = caller->Y() + reference->PrevY - reference->Y();
|
caller->PrevY = caller->Y() + reference->PrevY - reference->Y();
|
||||||
caller->PrevZ = caller->Z() + reference->PrevZ - reference->Z();
|
caller->PrevZ = caller->Z() + reference->PrevZ - reference->Z();
|
||||||
|
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
||||||
}
|
}
|
||||||
else if (!(flags & WARPF_INTERPOLATE))
|
else if (!(flags & WARPF_INTERPOLATE))
|
||||||
{
|
{
|
||||||
caller->PrevX = caller->X();
|
caller->ClearInterpolation();
|
||||||
caller->PrevY = caller->Y();
|
|
||||||
caller->PrevZ = caller->Z();
|
|
||||||
}
|
}
|
||||||
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
|
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
|
||||||
{
|
{
|
||||||
|
|
10
src/r_defs.h
10
src/r_defs.h
|
@ -1278,4 +1278,14 @@ inline fixedvec3 PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refse
|
||||||
return pos + Displacements(refsec->PortalGroup, line->frontsector->PortalGroup);
|
return pos + Displacements(refsec->PortalGroup, line->frontsector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void AActor::ClearInterpolation()
|
||||||
|
{
|
||||||
|
PrevX = X();
|
||||||
|
PrevY = Y();
|
||||||
|
PrevZ = Z();
|
||||||
|
PrevAngle = angle;
|
||||||
|
PrevPortalGroup = Sector->PortalGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4983,7 +4983,6 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis
|
||||||
newX -= self->X();
|
newX -= self->X();
|
||||||
newY -= self->Y();
|
newY -= self->Y();
|
||||||
self->SetXY(self->Vec2Offset(newX, newY));
|
self->SetXY(self->Vec2Offset(newX, newY));
|
||||||
self->SetMovement(newX, newY, 0);
|
|
||||||
self->LinkToWorld ();
|
self->LinkToWorld ();
|
||||||
}
|
}
|
||||||
self->WeaveIndexXY = weaveXY;
|
self->WeaveIndexXY = weaveXY;
|
||||||
|
|
Loading…
Reference in a new issue