Let's use local origin instead to interpolate with
This commit is contained in:
parent
fea66298de
commit
413264e208
4 changed files with 29 additions and 29 deletions
game
|
@ -776,8 +776,8 @@ void CPrediction::StartCommand( C_BasePlayer *player, CUserCmd *cmd )
|
||||||
C_BaseEntity::SetPredictionRandomSeed( cmd );
|
C_BaseEntity::SetPredictionRandomSeed( cmd );
|
||||||
C_BaseEntity::SetPredictionPlayer( player );
|
C_BaseEntity::SetPredictionPlayer( player );
|
||||||
|
|
||||||
InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
|
InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
|
||||||
InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
|
InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,29 +852,29 @@ void CPrediction::StartInterpolatingPlayer( C_BasePlayer *player )
|
||||||
|
|
||||||
// Let's interpolate the local player, this is similar to lag compensation,
|
// 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)
|
// 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_vecViewOffset = player->GetViewOffset();
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
|
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
|
||||||
|
|
||||||
auto pCmd = player->m_pCurrentCommand;
|
auto pCmd = player->m_pCurrentCommand;
|
||||||
|
|
||||||
Vector vecNewAbsOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin,
|
Vector vecNewLocalOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin,
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin,
|
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin,
|
||||||
pCmd->interpolated_amount );
|
pCmd->interpolated_amount );
|
||||||
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
|
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
|
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
|
||||||
pCmd->interpolated_amount );
|
pCmd->interpolated_amount );
|
||||||
|
|
||||||
player->SetAbsOrigin( vecNewAbsOrigin );
|
player->SetLocalOrigin( vecNewLocalOrigin );
|
||||||
player->SetViewOffset( vecNewViewOffset );
|
player->SetViewOffset( vecNewViewOffset );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPrediction::FinishInterpolatingPlayer( C_BasePlayer *player )
|
void CPrediction::FinishInterpolatingPlayer( C_BasePlayer* player )
|
||||||
{
|
{
|
||||||
#if !defined( NO_ENTITY_PREDICTION )
|
#if !defined( NO_ENTITY_PREDICTION )
|
||||||
VPROF( "CPrediction::FinishInterpolatingPlayer" );
|
VPROF( "CPrediction::FinishInterpolatingPlayer" );
|
||||||
|
|
||||||
player->SetAbsOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin );
|
player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
|
||||||
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
|
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ private:
|
||||||
|
|
||||||
struct InterpolationContext
|
struct InterpolationContext
|
||||||
{
|
{
|
||||||
Vector m_vecAbsOrigin;
|
Vector m_vecLocalOrigin;
|
||||||
Vector m_vecViewOffset;
|
Vector m_vecViewOffset;
|
||||||
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
|
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,10 +56,10 @@ void CPlayerMove::StartCommand( CBasePlayer *player, CUserCmd *cmd )
|
||||||
CBaseEntity::SetPredictionRandomSeed( cmd );
|
CBaseEntity::SetPredictionRandomSeed( cmd );
|
||||||
CBaseEntity::SetPredictionPlayer( player );
|
CBaseEntity::SetPredictionPlayer( player );
|
||||||
|
|
||||||
InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset = player->GetViewOffset();
|
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)
|
#if defined( HL2_DLL )
|
||||||
// pull out backchannel data and move this out
|
// pull out backchannel data and move this out
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -305,27 +305,27 @@ void CPlayerMove::StartInterpolatingPlayer( CBasePlayer *player )
|
||||||
|
|
||||||
// Let's interpolate the local player, this is similar to lag compensation,
|
// 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)
|
// 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_vecViewOffset = player->GetViewOffset();
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin = player->GetAbsOrigin();
|
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin = player->GetLocalOrigin();
|
||||||
|
|
||||||
auto pCmd = player->m_pCurrentCommand;
|
auto pCmd = player->m_pCurrentCommand;
|
||||||
|
|
||||||
Vector vecNewAbsOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecAbsOrigin,
|
Vector vecNewLocalOrigin = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecLocalOrigin,
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin,
|
InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin,
|
||||||
pCmd->interpolated_amount );
|
pCmd->interpolated_amount );
|
||||||
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
|
Vector vecNewViewOffset = VectorLerp( InterpolationContexts[BEFORE_MOVEMENT].m_vecViewOffset,
|
||||||
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
|
InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset,
|
||||||
pCmd->interpolated_amount );
|
pCmd->interpolated_amount );
|
||||||
|
|
||||||
player->SetAbsOrigin( vecNewAbsOrigin );
|
player->SetLocalOrigin( vecNewLocalOrigin );
|
||||||
player->SetViewOffset( vecNewViewOffset );
|
player->SetViewOffset( vecNewViewOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerMove::FinishInterpolatingPlayer( CBasePlayer *player )
|
void CPlayerMove::FinishInterpolatingPlayer( CBasePlayer* player )
|
||||||
{
|
{
|
||||||
VPROF( "CPlayerMove::FinishInterpolatingPlayer" );
|
VPROF( "CPlayerMove::FinishInterpolatingPlayer" );
|
||||||
|
|
||||||
player->SetAbsOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecAbsOrigin );
|
player->SetLocalOrigin( InterpolationContexts[AFTER_MOVEMENT].m_vecLocalOrigin );
|
||||||
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
|
player->SetViewOffset( InterpolationContexts[AFTER_MOVEMENT].m_vecViewOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ protected:
|
||||||
|
|
||||||
struct InterpolationContext
|
struct InterpolationContext
|
||||||
{
|
{
|
||||||
Vector m_vecAbsOrigin;
|
Vector m_vecLocalOrigin;
|
||||||
Vector m_vecViewOffset;
|
Vector m_vecViewOffset;
|
||||||
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
|
} InterpolationContexts[INTERPOLATION_CONTEXT_MAX];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue