TODO: figure out why we need to do this

This commit is contained in:
unknown 2024-09-04 23:54:10 +02:00
parent 1475964e61
commit 53561ff881
11 changed files with 81 additions and 31 deletions

View file

@ -690,6 +690,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_CSPlayer, DT_CSPlayer, CCSPlayer )
RecvPropInt( RECVINFO( m_iClass ) ), RecvPropInt( RECVINFO( m_iClass ) ),
RecvPropInt( RECVINFO( m_ArmorValue ) ), RecvPropInt( RECVINFO( m_ArmorValue ) ),
RecvPropQAngles( RECVINFO( m_angEyeAngles ) ), RecvPropQAngles( RECVINFO( m_angEyeAngles ) ),
RecvPropQAngles( RECVINFO( m_angRenderAngles ) ),
RecvPropFloat( RECVINFO( m_flStamina ) ), RecvPropFloat( RECVINFO( m_flStamina ) ),
RecvPropInt( RECVINFO( m_bHasDefuser ), 0, RecvProxy_HasDefuser ), RecvPropInt( RECVINFO( m_bHasDefuser ), 0, RecvProxy_HasDefuser ),
RecvPropInt( RECVINFO( m_bNightVisionOn), 0, RecvProxy_NightVision ), RecvPropInt( RECVINFO( m_bNightVisionOn), 0, RecvProxy_NightVision ),
@ -738,6 +739,8 @@ C_CSPlayer::C_CSPlayer() :
AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR );
// interpolation on m_angRenderAngles later
m_iLastAddonBits = m_iAddonBits = 0; m_iLastAddonBits = m_iAddonBits = 0;
m_iLastPrimaryAddon = m_iLastSecondaryAddon = WEAPON_NONE; m_iLastPrimaryAddon = m_iLastSecondaryAddon = WEAPON_NONE;
m_iProgressBarDuration = 0; m_iProgressBarDuration = 0;
@ -879,19 +882,6 @@ int C_CSPlayer::GetCurrentAssaultSuitPrice()
} }
} }
const QAngle& C_CSPlayer::GetRenderAngles()
{
if ( IsRagdoll() )
{
return vec3_angle;
}
else
{
return BaseClass::GetRenderAngles();
}
}
float g_flFattenAmt = 4; float g_flFattenAmt = 4;
void C_CSPlayer::GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType ) void C_CSPlayer::GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType )
{ {
@ -2180,7 +2170,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
C_AnimationLayer backupAnimLayers[C_BaseAnimatingOverlay::MAX_OVERLAYS]; C_AnimationLayer backupAnimLayers[C_BaseAnimatingOverlay::MAX_OVERLAYS];
Vector vecBackupPosition = player->GetAbsOrigin(); Vector vecBackupPosition = player->GetAbsOrigin();
QAngle angBackupAngles = player->GetAbsAngles(); QAngle angBackupAngles = player->GetRenderAngles();
auto flOldCycle = player->GetCycle(); auto flOldCycle = player->GetCycle();
auto iOldSequence = player->GetSequence(); auto iOldSequence = player->GetSequence();
@ -2205,9 +2195,9 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
event->GetFloat( "position_y" ), event->GetFloat( "position_y" ),
event->GetFloat( "position_z" ) ) ); event->GetFloat( "position_z" ) ) );
player->SetAbsAngles( QAngle( event->GetFloat( "angle_x" ), player->m_angRenderAngles = QAngle( event->GetFloat( "angle_x" ),
event->GetFloat( "angle_y" ), event->GetFloat( "angle_y" ),
event->GetFloat( "angle_z" ) ) ); event->GetFloat( "angle_z" ) );
const auto numposeparams = event->GetInt( "num_poseparams" ); const auto numposeparams = event->GetInt( "num_poseparams" );
Assert( numposeparams == player->GetModelPtr()->GetNumPoseParameters() ); Assert( numposeparams == player->GetModelPtr()->GetNumPoseParameters() );
@ -2311,7 +2301,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
pos++; pos++;
} }
auto angles = player->GetAbsAngles(); auto angles = player->GetRenderAngles();
if ( pRecord->m_angAbsRotation != angles ) if ( pRecord->m_angAbsRotation != angles )
{ {
@ -2440,7 +2430,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
player->m_nSequence = iOldSequence; player->m_nSequence = iOldSequence;
player->m_flCycle = flOldCycle; player->m_flCycle = flOldCycle;
player->SetAbsOrigin( vecBackupPosition ); player->SetAbsOrigin( vecBackupPosition );
player->SetAbsAngles( angBackupAngles ); player->m_angRenderAngles = angBackupAngles;
for ( int i = 0; i < MAXSTUDIOPOSEPARAM; i++ ) for ( int i = 0; i < MAXSTUDIOPOSEPARAM; i++ )
{ {

View file

@ -6,6 +6,7 @@
#ifndef C_CS_PLAYER_H #ifndef C_CS_PLAYER_H
#define C_CS_PLAYER_H #define C_CS_PLAYER_H
#include "mathlib/vector.h"
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
@ -420,6 +421,8 @@ private:
}; };
CUtlCircularBuffer< HitboxRecord, MAX_HISTORY_HITBOX_RECORDS > m_HitboxTrack[MAX_PLAYERS + 1]; CUtlCircularBuffer< HitboxRecord, MAX_HISTORY_HITBOX_RECORDS > m_HitboxTrack[MAX_PLAYERS + 1];
QAngle m_angRenderAngles;
}; };
C_CSPlayer* GetLocalOrInEyeCSPlayer( void ); C_CSPlayer* GetLocalOrInEyeCSPlayer( void );

View file

@ -1321,7 +1321,7 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
} }
cmd->simulationdata[i].sim_time = pEntity->m_flInterpolatedSimulationTime; cmd->simulationdata[i].sim_time = pEntity->m_flInterpolatedSimulationTime;
cmd->simulationdata[i].anim_time = pEntity->m_flInterpolatedAnimTime; cmd->simulationdata[i].anim_time = pEntity->m_flAnimTime;
} }
#ifdef CSTRIKE_DLL #ifdef CSTRIKE_DLL

View file

@ -480,7 +480,7 @@ void CBaseAnimatingOverlay::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Q
if ( m_pIk ) if ( m_pIk )
{ {
CIKContext auto_ik; CIKContext auto_ik;
auto_ik.Init( pStudioHdr, GetAbsAngles(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask ); auto_ik.Init( pStudioHdr, GetRenderAngles(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask );
boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik ); boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik );
} }
else else

View file

@ -1670,7 +1670,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
// FIXME: trace based on gravity or trace based on angles? // FIXME: trace based on gravity or trace based on angles?
Vector up; Vector up;
AngleVectors( GetAbsAngles(), NULL, NULL, &up ); AngleVectors( GetRenderAngles(), NULL, NULL, &up );
// FIXME: check number of slots? // FIXME: check number of slots?
float minHeight = FLT_MAX; float minHeight = FLT_MAX;
@ -1781,7 +1781,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
else if (trace.DidHitNonWorldEntity()) else if (trace.DidHitNonWorldEntity())
{ {
pTarget->SetPos( trace.endpos ); pTarget->SetPos( trace.endpos );
pTarget->SetAngles( GetAbsAngles() ); pTarget->SetAngles( GetRenderAngles() );
// only do this on forward tracking or commited IK ground rules // only do this on forward tracking or commited IK ground rules
if (pTarget->est.release < 0.1) if (pTarget->est.release < 0.1)
@ -1815,7 +1815,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
else else
{ {
pTarget->SetPos( trace.endpos ); pTarget->SetPos( trace.endpos );
pTarget->SetAngles( GetAbsAngles() ); pTarget->SetAngles( GetRenderAngles() );
pTarget->SetOnWorld( true ); pTarget->SetOnWorld( true );
} }
} }
@ -2031,7 +2031,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask )
// FIXME: pass this into Studio_BuildMatrices to skip transforms // FIXME: pass this into Studio_BuildMatrices to skip transforms
CBoneBitList boneComputed; CBoneBitList boneComputed;
m_iIKCounter++; m_iIKCounter++;
m_pIk->Init( pStudioHdr, GetAbsAngles(), adjOrigin, gpGlobals->curtime, m_iIKCounter, boneMask ); m_pIk->Init( pStudioHdr, GetRenderAngles(), adjOrigin, gpGlobals->curtime, m_iIKCounter, boneMask );
GetSkeleton( pStudioHdr, pos, q, boneMask ); GetSkeleton( pStudioHdr, pos, q, boneMask );
UpdateIKLocks( gpGlobals->curtime ); UpdateIKLocks( gpGlobals->curtime );
@ -2055,7 +2055,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask )
{ {
BuildMatricesWithBoneMerge( BuildMatricesWithBoneMerge(
pStudioHdr, pStudioHdr,
GetAbsAngles(), GetRenderAngles(),
adjOrigin, adjOrigin,
pos, pos,
q, q,
@ -2074,7 +2074,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask )
Studio_BuildMatrices( Studio_BuildMatrices(
pStudioHdr, pStudioHdr,
GetAbsAngles(), GetRenderAngles(),
adjOrigin, adjOrigin,
pos, pos,
q, q,
@ -3036,7 +3036,7 @@ void CBaseAnimating::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Quaterni
if ( m_pIk ) if ( m_pIk )
{ {
CIKContext auto_ik; CIKContext auto_ik;
auto_ik.Init( pStudioHdr, GetAbsAngles(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask ); auto_ik.Init( pStudioHdr, GetRenderAngles(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask );
boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik ); boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik );
} }
else else

View file

@ -427,6 +427,11 @@ public:
const Vector& GetAbsOrigin( void ) const; const Vector& GetAbsOrigin( void ) const;
const QAngle& GetAbsAngles( void ) const; const QAngle& GetAbsAngles( void ) const;
virtual const QAngle& GetRenderAngles( void )
{
return GetAbsAngles();
}
SolidType_t GetSolid() const; SolidType_t GetSolid() const;
int GetSolidFlags( void ) const; int GetSolidFlags( void ) const;

View file

@ -302,6 +302,7 @@ IMPLEMENT_SERVERCLASS_ST( CCSPlayer, DT_CSPlayer )
SendPropInt( SENDINFO( m_iClass ), Q_log2( CS_NUM_CLASSES )+1, SPROP_UNSIGNED ), SendPropInt( SENDINFO( m_iClass ), Q_log2( CS_NUM_CLASSES )+1, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_ArmorValue ), 8 ), SendPropInt( SENDINFO( m_ArmorValue ), 8 ),
SendPropQAngles(SENDINFO(m_angEyeAngles)), SendPropQAngles(SENDINFO(m_angEyeAngles)),
SendPropQAngles(SENDINFO(m_angRenderAngles)),
SendPropBool( SENDINFO( m_bHasDefuser ) ), SendPropBool( SENDINFO( m_bHasDefuser ) ),
SendPropBool( SENDINFO( m_bNightVisionOn ) ), //send as int so we can use a RecvProxy on the client SendPropBool( SENDINFO( m_bNightVisionOn ) ), //send as int so we can use a RecvProxy on the client
SendPropBool( SENDINFO( m_bHasNightVision ) ), SendPropBool( SENDINFO( m_bHasNightVision ) ),
@ -1584,7 +1585,7 @@ void CCSPlayer::PostThink()
m_PlayerAnimState->Update( m_angEyeAngles[YAW], m_angEyeAngles[PITCH] ); m_PlayerAnimState->Update( m_angEyeAngles[YAW], m_angEyeAngles[PITCH] );
// Use the m_angRotation instead. // Use the m_angRotation instead.
SetAbsAngles( m_PlayerAnimState->GetRenderAngles() ); m_angRenderAngles = m_PlayerAnimState->GetRenderAngles();
// check if we need to apply a deafness DSP effect. // check if we need to apply a deafness DSP effect.
if ((m_applyDeafnessTime != 0.0f) && (m_applyDeafnessTime <= gpGlobals->curtime)) if ((m_applyDeafnessTime != 0.0f) && (m_applyDeafnessTime <= gpGlobals->curtime))

View file

@ -245,6 +245,8 @@ public:
static CCSPlayer *CreatePlayer( const char *className, edict_t *ed ); static CCSPlayer *CreatePlayer( const char *className, edict_t *ed );
static CCSPlayer* Instance( int iEnt ); static CCSPlayer* Instance( int iEnt );
virtual const QAngle& GetRenderAngles( void );
virtual void Precache(); virtual void Precache();
virtual void Spawn(); virtual void Spawn();
virtual void InitialSpawn( void ); virtual void InitialSpawn( void );
@ -814,6 +816,7 @@ public:
// Copyed from EyeAngles() so we can send it to the client. // Copyed from EyeAngles() so we can send it to the client.
CNetworkQAngle( m_angEyeAngles ); CNetworkQAngle( m_angEyeAngles );
CNetworkQAngle( m_angRenderAngles );
bool m_bVCollisionInitted; bool m_bVCollisionInitted;

View file

@ -17,6 +17,9 @@
#include "util.h" #include "util.h"
#include "utllinkedlist.h" #include "utllinkedlist.h"
#include "BaseAnimatingOverlay.h" #include "BaseAnimatingOverlay.h"
#ifdef CSTRIKE_DLL
#include "cs_player.h"
#endif
#include "tier0/vprof.h" #include "tier0/vprof.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
@ -74,6 +77,9 @@ struct LagRecord
float m_masterCycle; float m_masterCycle;
float m_poseParameters[MAXSTUDIOPOSEPARAM]; float m_poseParameters[MAXSTUDIOPOSEPARAM];
float m_encodedControllers[MAXSTUDIOBONECTRLS]; float m_encodedControllers[MAXSTUDIOBONECTRLS];
#ifdef CSTRIKE_DLL
QAngle m_angRenderAngles;
#endif
}; };
// //
@ -220,6 +226,15 @@ void CLagCompensationManager::TrackEntities()
} }
} }
#ifdef CSTRIKE_DLL
auto csPlayer = dynamic_cast<CCSPlayer*>(pEntity);
if (csPlayer)
{
record.m_angRenderAngles = csPlayer->GetRenderAngles();
}
#endif
track->Push( record ); track->Push( record );
} }
} }
@ -555,6 +570,16 @@ inline void CLagCompensationManager::BacktrackEntity( CBaseEntity* pEntity, int
flags |= LC_ANIM_OVERS_CHANGED; flags |= LC_ANIM_OVERS_CHANGED;
} }
#ifdef CSTRIKE_DLL
auto csPlayer = dynamic_cast<CCSPlayer*>(pEntity);
if (csPlayer && foundAnim)
{
restore->m_angRenderAngles = csPlayer->GetRenderAngles();
csPlayer->m_angRenderAngles = recordAnim->m_angRenderAngles;
}
#endif
Finish(); Finish();
} }
@ -653,6 +678,13 @@ void CLagCompensationManager::FinishLagCompensation( CBasePlayer* player )
} }
} }
auto csPlayer = dynamic_cast<CCSPlayer*>(pEntity);
if (csPlayer)
{
csPlayer->m_angRenderAngles = restore->m_angRenderAngles;
}
pEntity->SetSimulationTime( restore->m_flSimulationTime ); pEntity->SetSimulationTime( restore->m_flSimulationTime );
pEntity->SetAnimTime( restore->m_flAnimTime ); pEntity->SetAnimTime( restore->m_flAnimTime );
} }

View file

@ -44,6 +44,22 @@
ConVar weapon_accuracy_nospread( "weapon_accuracy_nospread", "0", FCVAR_REPLICATED ); ConVar weapon_accuracy_nospread( "weapon_accuracy_nospread", "0", FCVAR_REPLICATED );
#define CS_MASK_SHOOT (MASK_SOLID|CONTENTS_DEBRIS) #define CS_MASK_SHOOT (MASK_SOLID|CONTENTS_DEBRIS)
const QAngle& CCSPlayer::GetRenderAngles()
{
#ifdef CLIENT_DLL
if ( IsRagdoll() )
{
return vec3_angle;
}
else
{
return m_angRenderAngles;
}
#else
return m_angRenderAngles;
#endif
}
void DispatchEffect( const char *pName, const CEffectData &data ); void DispatchEffect( const char *pName, const CEffectData &data );
#ifdef _DEBUG #ifdef _DEBUG
@ -541,7 +557,7 @@ void CCSPlayer::FireBullet(
QAngle angles[MAXSTUDIOBONES]; QAngle angles[MAXSTUDIOBONES];
int indexes[MAXSTUDIOBONES]; int indexes[MAXSTUDIOBONES];
auto angle = lagPlayer->GetAbsAngles(); auto angle = lagPlayer->GetRenderAngles();
auto position = lagPlayer->GetAbsOrigin(); auto position = lagPlayer->GetAbsOrigin();
event->SetFloat( "position_x", position.x ); event->SetFloat( "position_x", position.x );

View file

@ -336,7 +336,7 @@ void FX_FireBullets(
C_CSPlayer::HitboxRecord record; C_CSPlayer::HitboxRecord record;
record.m_vecAbsOrigin = lagPlayer->GetAbsOrigin(); record.m_vecAbsOrigin = lagPlayer->GetAbsOrigin();
record.m_angAbsRotation = lagPlayer->GetAbsAngles(); record.m_angAbsRotation = lagPlayer->GetRenderAngles();
record.m_nAttackerTickBase = pPlayer->m_nTickBase; record.m_nAttackerTickBase = pPlayer->m_nTickBase;
record.m_flSimulationTime = lagPlayer->m_flInterpolatedSimulationTime; record.m_flSimulationTime = lagPlayer->m_flInterpolatedSimulationTime;