mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-16 17:01:39 +00:00
- Minor input tidy-up.
This commit is contained in:
parent
8052bc7e46
commit
991ef5c27f
10 changed files with 23 additions and 49 deletions
|
@ -103,11 +103,6 @@ public:
|
|||
return interpolatedvalue(PrevAngles.Yaw, spr.Angles.Yaw, interpfrac);
|
||||
}
|
||||
|
||||
DRotator interpolatedangles(double const interpfrac)
|
||||
{
|
||||
return interpolatedvalue(PrevAngles, spr.Angles, interpfrac);
|
||||
}
|
||||
|
||||
void backupz()
|
||||
{
|
||||
opos.Z = spr.pos.Z;
|
||||
|
|
|
@ -242,7 +242,7 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const
|
|||
if (aimmode && canslopetilt) // If the floor is sloped
|
||||
{
|
||||
// Get a point, 512 (64 for Blood) units ahead of player's position
|
||||
auto rotpt = pos + ang.ToVector() * (isBlood() ? 4 : 32);
|
||||
auto rotpt = pos + ang.ToVector() * (!isBlood() ? 32 : 4);
|
||||
auto tempsect = cursectnum;
|
||||
updatesector(rotpt, &tempsect);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ struct PlayerAngles
|
|||
// General methods.
|
||||
void initialize(DCoreActor* const actor, const DAngle viewyaw = nullAngle)
|
||||
{
|
||||
if ((pActor = actor)) RenderAngles = PrevLerpAngles = pActor->spr.Angles;
|
||||
if (pActor = actor) RenderAngles = PrevLerpAngles = pActor->spr.Angles;
|
||||
PrevViewAngles.Yaw = ViewAngles.Yaw = viewyaw;
|
||||
}
|
||||
DAngle getPitchWithView()
|
||||
|
@ -37,21 +37,17 @@ struct PlayerAngles
|
|||
}
|
||||
|
||||
// Render angle functions.
|
||||
DRotator lerpViewAngles(const double interpfrac)
|
||||
{
|
||||
return interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
|
||||
}
|
||||
DRotator getRenderAngles(const double interpfrac)
|
||||
{
|
||||
// Get angles and return with clamped off pitch.
|
||||
auto angles = RenderAngles + lerpViewAngles(interpfrac);
|
||||
auto angles = RenderAngles + interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
|
||||
angles.Pitch = ClampViewPitch(angles.Pitch);
|
||||
return angles;
|
||||
}
|
||||
void updateRenderAngles(const double interpfrac)
|
||||
{
|
||||
// Apply the current interpolated angle state to the render angles.
|
||||
const auto lerpAngles = pActor->interpolatedangles(interpfrac);
|
||||
const auto lerpAngles = interpolatedvalue(pActor->PrevAngles, pActor->spr.Angles, interpfrac);
|
||||
RenderAngles += lerpAngles - PrevLerpAngles;
|
||||
PrevLerpAngles = lerpAngles;
|
||||
}
|
||||
|
@ -66,14 +62,9 @@ struct PlayerAngles
|
|||
// Draw code helpers.
|
||||
auto getCrosshairOffsets(const double interpfrac)
|
||||
{
|
||||
// Set up angles.
|
||||
const auto viewAngles = lerpViewAngles(interpfrac);
|
||||
const auto rotTangent = viewAngles.Roll.Tan();
|
||||
const auto yawTangent = clamp(viewAngles.Yaw, -DAngle90, DAngle90).Tan();
|
||||
const auto fovTangent = tan(r_fov * pi::pi() / 360.);
|
||||
|
||||
// Return as pair with roll as the 2nd object since all callers inevitably need it.
|
||||
return std::make_pair(DVector2(160, 120 * -rotTangent) * -yawTangent / fovTangent, viewAngles.Roll);
|
||||
// Set up angles and return as pair with roll as the 2nd object since all callers inevitably need it.
|
||||
const auto viewAngles = interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac);
|
||||
return std::make_pair(DVector2(160, 120 * -viewAngles.Roll.Tan()) * -viewAngles.Yaw.Tan() / tan(r_fov * pi::pi() / 360.), viewAngles.Roll);
|
||||
}
|
||||
auto getWeaponOffsets(const double interpfrac)
|
||||
{
|
||||
|
|
|
@ -54,14 +54,11 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
|
|||
ApplyGlobalInput(gInput, hidInput);
|
||||
processMovement(&input, &gInput, hidInput, scaleAdjust);
|
||||
|
||||
if (!SyncInput() && gamestate == GS_LEVEL)
|
||||
// Perform unsynchronised angle/horizon if not dead.
|
||||
if (!SyncInput() && gamestate == GS_LEVEL && pPlayer->actor->xspr.health != 0)
|
||||
{
|
||||
// Perform unsynchronised angle/horizon if not dead.
|
||||
if (pPlayer->actor->xspr.health != 0)
|
||||
{
|
||||
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
|
||||
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
}
|
||||
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
|
||||
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
}
|
||||
|
||||
if (packet)
|
||||
|
|
|
@ -489,7 +489,7 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DRotator& cAngles, sector
|
|||
{
|
||||
cPos.Z += bobHeight;
|
||||
}
|
||||
cPos.Z -= interpolatedvalue(0., 10., cAngles.Pitch / DAngle90);
|
||||
cPos.Z -= 10. * (cAngles.Pitch / DAngle90);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -231,7 +231,7 @@ void displayweapon_d(int snum, double interpfrac)
|
|||
|
||||
auto offpair = p->Angles.getWeaponOffsets(interpfrac);
|
||||
auto offsets = offpair.first;
|
||||
auto pitchoffset = interpolatedvalue(0., 16., p->Angles.getRenderAngles(interpfrac).Pitch / DAngle90);
|
||||
auto pitchoffset = 16. * (p->Angles.getRenderAngles(interpfrac).Pitch / DAngle90);
|
||||
auto yawinput = getavel(snum) * (1. / 16.);
|
||||
auto angle = offpair.second;
|
||||
auto weapon_xoffset = 160 - 90 - (BobVal(512 + weapon_sway * 0.5) * (16384. / 1536.)) - 58 - p->weapon_ang;
|
||||
|
|
|
@ -829,14 +829,10 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
|
|||
|
||||
FinalizeInput(p, input);
|
||||
|
||||
if (!SyncInput())
|
||||
if (!SyncInput() && p->GetActor()->spr.extra > 0)
|
||||
{
|
||||
if (p->GetActor()->spr.extra > 0)
|
||||
{
|
||||
// Do these in the same order as the old code.
|
||||
p->Angles.RenderAngles.Yaw += p->adjustavel(input.avel);
|
||||
p->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
}
|
||||
p->Angles.RenderAngles.Yaw += p->adjustavel(input.avel);
|
||||
p->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
}
|
||||
|
||||
if (packet)
|
||||
|
|
|
@ -376,8 +376,6 @@ void GameInterface::Ticker()
|
|||
PlayerList[nLocalPlayer].Angles.resetRenderAngles();
|
||||
UpdatePlayerSpriteAngle(&PlayerList[nLocalPlayer]);
|
||||
|
||||
inita = inita.Normalized360();
|
||||
|
||||
// disable synchronised input if set by game.
|
||||
resetForcedSyncInput();
|
||||
|
||||
|
|
|
@ -82,17 +82,14 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
|
|||
sPlayerInput[nLocalPlayer].vel.Zero();
|
||||
}
|
||||
|
||||
if (!SyncInput() && gamestate == GS_LEVEL)
|
||||
if (!SyncInput() && gamestate == GS_LEVEL && !nFreeze)
|
||||
{
|
||||
if (!nFreeze)
|
||||
{
|
||||
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
|
||||
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
|
||||
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
|
||||
|
||||
if (input.horz)
|
||||
{
|
||||
pPlayer->bPlayerPan = pPlayer->bLockPan = true;
|
||||
}
|
||||
if (input.horz)
|
||||
{
|
||||
pPlayer->bPlayerPan = pPlayer->bLockPan = true;
|
||||
}
|
||||
|
||||
UpdatePlayerSpriteAngle(pPlayer);
|
||||
|
|
|
@ -666,7 +666,7 @@ static void pickupMessage(int no)
|
|||
|
||||
void UpdatePlayerSpriteAngle(Player* pPlayer)
|
||||
{
|
||||
if (pPlayer->pActor) inita = pPlayer->pActor->spr.Angles.Yaw;
|
||||
if (pPlayer->pActor) inita = pPlayer->pActor->spr.Angles.Yaw.Normalized360();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue