More Fixes to lag compensation, it is always almost pixel perfect now
- In theory, to have even more perfect values, we could go the other way around, let the client send the values and see if it's within range of lerp time - The fact that the netvar gets compressed and touched made it worse for lag compensation
This commit is contained in:
parent
f4ded28fe0
commit
87337859f4
7 changed files with 48 additions and 10 deletions
|
@ -6336,6 +6336,13 @@ void C_BaseEntity::AddVar( void *data, IInterpolatedVar *watcher, int type, bool
|
|||
{
|
||||
// Only add it if it hasn't been added yet.
|
||||
bool bAddIt = true;
|
||||
|
||||
// TODO_ENHANCED:
|
||||
// This is needed to get the perfect lag compensation for origin.
|
||||
// It's possible to have hermite interpolation in lag compensation,
|
||||
// but it would require some extra flags being sent to the server.
|
||||
type |= INTERPOLATE_LINEAR_ONLY;
|
||||
|
||||
for ( int i=0; i < m_VarMap.m_Entries.Count(); i++ )
|
||||
{
|
||||
if ( m_VarMap.m_Entries[i].watcher == watcher )
|
||||
|
|
|
@ -2199,7 +2199,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
|||
|
||||
for ( int i = 0; i < player->GetNumAnimOverlays(); i++ )
|
||||
{
|
||||
backupAnimLayers[i] = *player->GetAnimOverlay(i);
|
||||
backupAnimLayers[i] = *player->GetAnimOverlay( i );
|
||||
}
|
||||
|
||||
player->m_nSequence = event->GetInt( "sequence" );
|
||||
|
@ -2277,6 +2277,26 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
|||
int pos = 0;
|
||||
|
||||
auto newOrigin = player->GetAbsOrigin();
|
||||
auto simtime = event->GetFloat( "simtime" );
|
||||
auto animtime = event->GetFloat( "animtime" );
|
||||
|
||||
if ( pRecord->m_flSimulationTime != simtime )
|
||||
{
|
||||
char buffer[256];
|
||||
V_sprintf_safe( buffer, "simtime: %f != %f", simtime, pRecord->m_flSimulationTime );
|
||||
|
||||
NDebugOverlay::EntityTextAtPosition( pRecord->m_vecAbsOrigin, pos, buffer, flDuration );
|
||||
pos++;
|
||||
}
|
||||
|
||||
if ( pRecord->m_flAnimTime != animtime )
|
||||
{
|
||||
char buffer[256];
|
||||
V_sprintf_safe( buffer, "animtime: %f != %f", animtime, pRecord->m_flAnimTime );
|
||||
|
||||
NDebugOverlay::EntityTextAtPosition( pRecord->m_vecAbsOrigin, pos, buffer, flDuration );
|
||||
pos++;
|
||||
}
|
||||
|
||||
if ( pRecord->m_vecAbsOrigin != newOrigin )
|
||||
{
|
||||
|
@ -2293,7 +2313,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
|||
NDebugOverlay::EntityTextAtPosition( pRecord->m_vecAbsOrigin, pos, buffer, flDuration );
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
if ( pRecord->m_angRenderAngles != player->m_angRenderAngles )
|
||||
{
|
||||
char buffer[256];
|
||||
|
@ -2483,7 +2503,6 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void C_CSPlayer::SetActivity( Activity eActivity )
|
||||
{
|
||||
m_Activity = eActivity;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "cs_player.h"
|
||||
#include "cs_gamerules.h"
|
||||
#include "dt_send.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "trains.h"
|
||||
#include "vcollide_parse.h"
|
||||
#include "in_buttons.h"
|
||||
|
|
|
@ -1700,7 +1700,7 @@ void CMultiPlayerAnimState::ComputePoseParam_AimYaw( CStudioHdr *pStudioHdr )
|
|||
}
|
||||
|
||||
// Rotate the body into position.
|
||||
m_angRender[YAW] = m_flCurrentFeetYaw;
|
||||
m_angRender[YAW] = AngleNormalize( m_flCurrentFeetYaw );
|
||||
|
||||
// Find the aim(torso) yaw base on the eye and feet yaws.
|
||||
float flAimYaw = m_flEyeYaw - m_flCurrentFeetYaw;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "cbase.h"
|
||||
#include "base_playeranimstate.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "animation.h"
|
||||
#include "studio.h"
|
||||
|
@ -862,7 +863,7 @@ void CBasePlayerAnimState::ComputePoseParam_BodyYaw()
|
|||
float flCurrentTorsoYaw = AngleNormalize( m_flEyeYaw - m_flCurrentFeetYaw );
|
||||
|
||||
// Rotate entire body into position
|
||||
m_angRender[YAW] = m_flCurrentFeetYaw;
|
||||
m_angRender[YAW] = AngleNormalize( m_flCurrentFeetYaw );
|
||||
m_angRender[PITCH] = m_angRender[ROLL] = 0;
|
||||
|
||||
SetOuterBodyYaw( flCurrentTorsoYaw );
|
||||
|
|
|
@ -344,7 +344,7 @@ void FX_FireBullets(
|
|||
record.m_angRenderAngles = lagPlayer->m_angRenderAngles;
|
||||
|
||||
record.m_nAttackerTickBase = pPlayer->m_nTickBase;
|
||||
record.m_flSimulationTime = lagPlayer->GetSimulationTime();
|
||||
record.m_flSimulationTime = lagPlayer->m_flInterpolatedSimulationTime;
|
||||
record.m_flAnimTime = lagPlayer->GetAnimTime();
|
||||
record.m_flCycle = lagPlayer->GetCycle();
|
||||
record.m_nSequence = lagPlayer->GetSequence();
|
||||
|
|
|
@ -183,8 +183,9 @@ void SendProxy_AngleToFloat( const SendProp *pProp, const void *pStruct, const v
|
|||
{
|
||||
float angle;
|
||||
|
||||
// TODO_ENHANCED: anglemod => This cause the angle to not have perfectly aligned angles and causes lag compensation issues !
|
||||
angle = *((float*)pData);
|
||||
pOut->m_Float = anglemod( angle );
|
||||
pOut->m_Float = angle;
|
||||
|
||||
Assert( IsFinite( pOut->m_Float ) );
|
||||
}
|
||||
|
@ -197,10 +198,11 @@ void SendProxy_FloatToFloat( const SendProp *pProp, const void *pStruct, const v
|
|||
|
||||
void SendProxy_QAngles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
|
||||
{
|
||||
// TODO_ENHANCED: same as SendProxy_AngleToFloat
|
||||
QAngle *v = (QAngle*)pData;
|
||||
pOut->m_Vector[0] = anglemod( v->x );
|
||||
pOut->m_Vector[1] = anglemod( v->y );
|
||||
pOut->m_Vector[2] = anglemod( v->z );
|
||||
pOut->m_Vector[0] = v->x;
|
||||
pOut->m_Vector[1] = v->y;
|
||||
pOut->m_Vector[2] = v->z;
|
||||
}
|
||||
|
||||
void SendProxy_VectorToVector( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID)
|
||||
|
@ -586,6 +588,10 @@ SendProp SendPropAngle(
|
|||
Assert(sizeofVar == 4);
|
||||
}
|
||||
|
||||
// TODO_ENHANCED: These variables will get compressed with zstd
|
||||
flags = SPROP_NOSCALE;
|
||||
nBits = 0;
|
||||
|
||||
if ( nBits == 32 )
|
||||
flags |= SPROP_NOSCALE;
|
||||
|
||||
|
@ -619,6 +625,10 @@ SendProp SendPropQAngles(
|
|||
Assert(sizeofVar == 4);
|
||||
}
|
||||
|
||||
// TODO_ENHANCED: These variables will get compressed with zstd
|
||||
flags = SPROP_NOSCALE;
|
||||
nBits = 0;
|
||||
|
||||
if ( nBits == 32 )
|
||||
flags |= SPROP_NOSCALE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue