Fixes for SCALEDNOLERP

No longer relies on last input fraction to determine offset on frame (now uses TicFrac). No longer modifies Actor angle in real-time. Fixed offsetting breaking when other viewports are being renderer.
This commit is contained in:
Boondorl 2024-02-23 14:39:58 -05:00 committed by Christoph Oelckers
parent d848a57bac
commit e4ea5ad307
4 changed files with 30 additions and 58 deletions

View file

@ -458,8 +458,7 @@ public:
bool Resurrect();
// Scaled angle adjustment info. Not for direct manipulation.
DRotator angleTargets;
DRotator angleAppliedAmounts;
DRotator angleOffsetTargets;
};
// Bookkeeping on players - state.

View file

@ -3495,22 +3495,16 @@ void AActor::SetPitch(DAngle p, int fflags)
{
if (player != nullptr)
{
const bool mustLerp = !P_NoInterpolation(player, this);
if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp))
if (fflags & SPF_SCALEDNOLERP)
{
Angles.Pitch = p;
player->cheats |= CF_INTERPVIEW;
}
else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp)
{
player->angleTargets.Pitch = deltaangle(Angles.Pitch, p);
player->angleAppliedAmounts.Pitch = nullAngle;
player->angleOffsetTargets.Pitch = deltaangle(Angles.Pitch, p);
player->cheats |= CF_SCALEDNOLERP;
}
else
{
Angles.Pitch = p;
if (fflags & SPF_INTERPOLATE)
player->cheats |= CF_INTERPVIEW;
}
}
else
@ -3527,22 +3521,16 @@ void AActor::SetAngle(DAngle ang, int fflags)
{
if (player != nullptr)
{
const bool mustLerp = !P_NoInterpolation(player, this);
if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp))
if (fflags & SPF_SCALEDNOLERP)
{
Angles.Yaw = ang;
player->cheats |= CF_INTERPVIEW;
}
else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp)
{
player->angleTargets.Yaw = deltaangle(Angles.Yaw, ang);
player->angleAppliedAmounts.Yaw = nullAngle;
player->angleOffsetTargets.Yaw = deltaangle(Angles.Yaw, ang);
player->cheats |= CF_SCALEDNOLERP;
}
else
{
Angles.Yaw = ang;
if (fflags & SPF_INTERPOLATE)
player->cheats |= CF_INTERPVIEW;
}
}
else
@ -3559,22 +3547,16 @@ void AActor::SetRoll(DAngle r, int fflags)
{
if (player != nullptr)
{
const bool mustLerp = !P_NoInterpolation(player, this);
if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp))
if (fflags & SPF_SCALEDNOLERP)
{
Angles.Roll = r;
player->cheats |= CF_INTERPVIEW;
}
else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp)
{
player->angleTargets.Roll = deltaangle(Angles.Roll, r);
player->angleAppliedAmounts.Roll = nullAngle;
player->angleOffsetTargets.Roll = deltaangle(Angles.Roll, r);
player->cheats |= CF_SCALEDNOLERP;
}
else
{
Angles.Roll = r;
if (fflags & SPF_INTERPOLATE)
player->cheats |= CF_INTERPVIEW;
}
}
else

View file

@ -1239,6 +1239,17 @@ void P_PlayerThink (player_t *player)
I_Error ("No player %td start\n", player - players + 1);
}
for (unsigned int i = 0u; i < 3u; ++i)
{
if (fabs(player->angleOffsetTargets[i].Degrees()) >= EQUAL_EPSILON)
{
player->mo->Angles[i] += player->angleOffsetTargets[i];
player->mo->PrevAngles[i] = player->mo->Angles[i];
}
player->angleOffsetTargets[i] = nullAngle;
}
if (player->SubtitleCounter > 0)
{
player->SubtitleCounter--;

View file

@ -783,26 +783,12 @@ static double QuakePower(double factor, double intensity, double offset)
//
//==========================================================================
static void R_DoActorTickerAngleChanges(player_t* const player, AActor* const actor, const double scale)
static void R_DoActorTickerAngleChanges(player_t* const player, DRotator& angles, const double scale)
{
for (unsigned i = 0; i < 3; i++)
{
if (player->angleTargets[i].Sgn())
{
// Calculate scaled amount of target and add to the accumlation buffer.
DAngle addition = player->angleTargets[i] * scale;
player->angleAppliedAmounts[i] += addition;
// Test whether we're now reached/exceeded our target.
if (abs(player->angleAppliedAmounts[i]) >= abs(player->angleTargets[i]))
{
addition -= player->angleAppliedAmounts[i] - player->angleTargets[i];
player->angleTargets[i] = player->angleAppliedAmounts[i] = nullAngle;
}
// Apply the scaled addition to the angle.
actor->Angles[i] += addition;
}
if (fabs(player->angleOffsetTargets[i].Degrees()) >= EQUAL_EPSILON)
angles[i] += player->angleOffsetTargets[i] * scale;
}
}
@ -843,15 +829,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
I_Error ("You lost your body. Bad dehacked work is likely to blame.");
}
// [MR] Get the input fraction, even if we don't need it this frame. Must run every frame.
const auto scaleAdjust = I_GetInputFrac();
// [MR] Process player angle changes if permitted to do so.
if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera))
{
R_DoActorTickerAngleChanges(player, viewpoint.camera, scaleAdjust);
}
iview = FindPastViewer (viewpoint.camera);
int nowtic = I_GetTime ();
@ -972,6 +949,9 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
// [MR] Apply view angles as the viewpoint angles if asked to do so.
iview->New.Angles = !(viewpoint.camera->flags8 & MF8_ABSVIEWANGLES) ? viewpoint.camera->Angles : viewpoint.camera->ViewAngles;
iview->New.ViewAngles = viewpoint.camera->ViewAngles;
// [MR] Process player angle changes if permitted to do so.
if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera))
R_DoActorTickerAngleChanges(player, iview->New.Angles, viewpoint.TicFrac);
if (viewpoint.camera->player != 0)
{