mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- Set up interpolated camera angle changes to occur at framerate when all conditions in P_NoInterpolation()
are met.
This commit is contained in:
parent
20bf9e89f5
commit
cf1ac82da3
3 changed files with 93 additions and 9 deletions
|
@ -449,6 +449,10 @@ public:
|
|||
void SetFOV(float fov);
|
||||
bool HasWeaponsInSlot(int slot) const;
|
||||
bool Resurrect();
|
||||
|
||||
// Scaled angle adjustment info. Not for direct manipulation.
|
||||
DRotator angleTargets;
|
||||
DRotator angleAppliedAmounts;
|
||||
};
|
||||
|
||||
// Bookkeeping on players - state.
|
||||
|
|
|
@ -3427,12 +3427,27 @@ void AActor::SetPitch(DAngle p, int fflags)
|
|||
|
||||
if (p != Angles.Pitch)
|
||||
{
|
||||
Angles.Pitch = p;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
if (player != nullptr)
|
||||
{
|
||||
if (fflags & SPF_INTERPOLATE)
|
||||
{
|
||||
if (P_NoInterpolation(player, this))
|
||||
{
|
||||
player->angleTargets.Pitch = deltaangle(Angles.Pitch, p);
|
||||
player->angleAppliedAmounts.Pitch = nullAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Pitch = p;
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Pitch = p;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -3440,12 +3455,27 @@ void AActor::SetAngle(DAngle ang, int fflags)
|
|||
{
|
||||
if (ang != Angles.Yaw)
|
||||
{
|
||||
Angles.Yaw = ang;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
if (player != nullptr)
|
||||
{
|
||||
if (fflags & SPF_INTERPOLATE)
|
||||
{
|
||||
if (P_NoInterpolation(player, this))
|
||||
{
|
||||
player->angleTargets.Yaw = deltaangle(Angles.Yaw, ang);
|
||||
player->angleAppliedAmounts.Yaw = nullAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Yaw = ang;
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Yaw = ang;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -3453,13 +3483,28 @@ void AActor::SetRoll(DAngle r, int fflags)
|
|||
{
|
||||
if (r != Angles.Roll)
|
||||
{
|
||||
Angles.Roll = r;
|
||||
if (player != nullptr && (fflags & SPF_INTERPOLATE))
|
||||
if (player != nullptr)
|
||||
{
|
||||
if (fflags & SPF_INTERPOLATE)
|
||||
{
|
||||
if (P_NoInterpolation(player, this))
|
||||
{
|
||||
player->angleTargets.Roll = deltaangle(Angles.Roll, r);
|
||||
player->angleAppliedAmounts.Roll = nullAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Roll = r;
|
||||
player->cheats |= CF_INTERPVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Angles.Roll = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AActor::SetViewPitch(DAngle p, int fflags)
|
||||
{
|
||||
|
|
|
@ -762,6 +762,35 @@ static double QuakePower(double factor, double intensity, double offset)
|
|||
return factor * (offset + randumb);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_DoActorTickerAngleChanges
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static void R_DoActorTickerAngleChanges(player_t* const player, AActor* const actor, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_SetupFrame
|
||||
|
@ -799,6 +828,12 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
I_Error ("You lost your body. Bad dehacked work is likely to blame.");
|
||||
}
|
||||
|
||||
// [MR] Process player angle changes if permitted to do so.
|
||||
if (player && P_NoInterpolation(player, viewpoint.camera))
|
||||
{
|
||||
R_DoActorTickerAngleChanges(player, viewpoint.camera, I_GetInputFrac(false));
|
||||
}
|
||||
|
||||
iview = FindPastViewer (viewpoint.camera);
|
||||
|
||||
int nowtic = I_GetTime ();
|
||||
|
|
Loading…
Reference in a new issue