From 1f723c10ae6e2c56d0a5569134228006bfe363b6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 9 Oct 2013 21:50:24 -0500 Subject: [PATCH] Add CF_INTERPVIEW for players. - Added CF_INTERPVIEW flag for players. A_SetPitch/A_SetAngle and the similar ACS APROPs set this when changing an angle. This forces the renderer to interpolate the view angles instead of updating with the latest mouse positions. The effect lasts one tick. --- src/actor.h | 4 ++++ src/d_player.h | 1 + src/p_acs.cpp | 12 ++++++++---- src/p_mobj.cpp | 24 ++++++++++++++++++++++++ src/p_user.cpp | 3 +++ src/r_utility.cpp | 1 + src/thingdef/thingdef_codeptr.cpp | 5 ++--- 7 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/actor.h b/src/actor.h index 3a97ef49a..f8b583101 100644 --- a/src/actor.h +++ b/src/actor.h @@ -764,6 +764,10 @@ public: return (PalEntry)GetClass()->Meta.GetMetaInt(AMETA_BloodColor); } + // These also set CF_INTERPVIEW for players. + void SetPitch(int p); + void SetAngle(angle_t ang); + const PClass *GetBloodType(int type = 0) const { const PClass *bloodcls; diff --git a/src/d_player.h b/src/d_player.h index f6f7674d7..22f01f490 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -198,6 +198,7 @@ typedef enum CF_INSTANTWEAPSWITCH= 1 << 11, // [RH] Switch weapons instantly CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted + CF_INTERPVIEW = 1 << 14, // [RH] view was changed outside of input, so interpolate one frame CF_DRAIN = 1 << 16, // Player owns a drain powerup CF_HIGHJUMP = 1 << 18, // more Skulltag flags. Implementation not guaranteed though. ;) CF_REFLECTION = 1 << 19, diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 21e0d5c0b..d70cc2c0b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8250,7 +8250,9 @@ scriptwait: if (STACK(2) == 0) { if (activator != NULL) - activator->angle = STACK(1) << 16; + { + activator->SetAngle(STACK(1) << 16); + } } else { @@ -8259,7 +8261,7 @@ scriptwait: while ( (actor = iterator.Next ()) ) { - actor->angle = STACK(1) << 16; + actor->SetAngle(STACK(1) << 16); } } sp -= 2; @@ -8269,7 +8271,9 @@ scriptwait: if (STACK(2) == 0) { if (activator != NULL) - activator->pitch = STACK(1) << 16; + { + activator->SetPitch(STACK(1) << 16); + } } else { @@ -8278,7 +8282,7 @@ scriptwait: while ( (actor = iterator.Next ()) ) { - actor->pitch = STACK(1) << 16; + actor->SetPitch(STACK(1) << 16); } } sp -= 2; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 492dd3389..69d4203fe 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2962,6 +2962,30 @@ void AActor::SetShade (int r, int g, int b) fillcolor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b); } +void AActor::SetPitch(int p) +{ + if (p != pitch) + { + pitch = p; + if (player != NULL) + { + player->cheats |= CF_INTERPVIEW; + } + } +} + +void AActor::SetAngle(angle_t ang) +{ + if (ang != angle) + { + angle = ang; + if (player != NULL) + { + player->cheats |= CF_INTERPVIEW; + } + } +} + // // P_MobjThinker // diff --git a/src/p_user.cpp b/src/p_user.cpp index 901f6cfaa..938c7727f 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2252,6 +2252,9 @@ void P_PlayerThink (player_t *player) { player->inventorytics--; } + // Don't interpolate the view for more than one tic + player->cheats &= ~CF_INTERPVIEW; + // No-clip cheat if ((player->cheats & (CF_NOCLIP | CF_NOCLIP2)) == CF_NOCLIP2) { // No noclip2 without noclip diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 0b51578ed..606cca840 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -581,6 +581,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi viewy = iview->oviewy + FixedMul (frac, iview->nviewy - iview->oviewy); viewz = iview->oviewz + FixedMul (frac, iview->nviewz - iview->oviewz); if (player != NULL && + !(player->cheats & CF_INTERPVIEW) && player - players == consoleplayer && camera == player->mo && !demoplayback && diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 9faeb7442..d48b18a2a 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3935,7 +3935,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) { ACTION_PARAM_START(1); ACTION_PARAM_ANGLE(angle, 0); - self->angle = angle; + self->SetAngle(angle); } //=========================================================================== @@ -3973,8 +3973,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) } pitch = clamp(pitch, min, max); } - - self->pitch = pitch; + self->SetPitch(pitch); } //===========================================================================