Let's use local origin instead to interpolate with

This commit is contained in:
Kamay Xutax 2024-09-06 00:25:17 +02:00
parent fea66298de
commit 413264e208
4 changed files with 29 additions and 29 deletions

View file

@ -777,7 +777,7 @@ void CPrediction::StartCommand( C_BasePlayer *player, CUserCmd *cmd )
C_BaseEntity::SetPredictionPlayer( player );
InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
#endif
}
@ -853,18 +853,18 @@ void CPrediction::StartInterpolatingPlayer( C_BasePlayer *player )
// Let's interpolate the local player, this is similar to lag compensation,
// except it isn't since local player is always predicted. (except if user didn't want to for some reasons)
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
auto pCmd = player->m_pCurrentCommand;
Vector vecNewAbsOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin,
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin,
Vector vecNewLocalOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin,
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin,
pCmd->interpolated_amount );
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
pCmd->interpolated_amount );
player->SetAbsOrigin( vecNewAbsOrigin );
player->SetLocalOrigin( vecNewLocalOrigin );
player->SetViewOffset( vecNewViewOffset );
#endif
}
@ -874,7 +874,7 @@ void CPrediction::FinishInterpolatingPlayer( C_BasePlayer *player )
#if !defined( NO_ENTITY_PREDICTION )
VPROF( "CPrediction::FinishInterpolatingPlayer" );
player->SetAbsOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin );
player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
#endif
}

View file

@ -193,7 +193,7 @@ private:
struct InterpolationContext
{
Vector m_vecAbsOrigin;
Vector m_vecLocalOrigin;
Vector m_vecViewOffset;
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
};

View file

@ -57,7 +57,7 @@ void CPlayerMove::StartCommand( CBasePlayer *player, CUserCmd *cmd )
CBaseEntity::SetPredictionPlayer( player );
InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
#if defined( HL2_DLL )
// pull out backchannel data and move this out
@ -306,18 +306,18 @@ void CPlayerMove::StartInterpolatingPlayer( CBasePlayer *player )
// Let's interpolate the local player, this is similar to lag compensation,
// except it isn't since local player is always predicted. (except if user didn't want to for some reasons)
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
auto pCmd = player->m_pCurrentCommand;
Vector vecNewAbsOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin,
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin,
Vector vecNewLocalOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin,
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin,
pCmd->interpolated_amount );
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
pCmd->interpolated_amount );
player->SetAbsOrigin( vecNewAbsOrigin );
player->SetLocalOrigin( vecNewLocalOrigin );
player->SetViewOffset( vecNewViewOffset );
}
@ -325,7 +325,7 @@ void CPlayerMove::FinishInterpolatingPlayer( CBasePlayer *player )
{
VPROF( "CPlayerMove::FinishInterpolatingPlayer" );
player->SetAbsOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin );
player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
}

View file

@ -65,7 +65,7 @@ protected:
struct InterpolationContext
{
Vector m_vecAbsOrigin;
Vector m_vecLocalOrigin;
Vector m_vecViewOffset;
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
};