diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 7e59a15b09..970607f387 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -1979,7 +1979,8 @@ void C_BaseAnimating::StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quat if ( m_pIk ) { CIKContext auto_ik; - auto_ik.Init( hdr, GetRenderAngles(), GetRenderOrigin(), currentTime, gpGlobals->framecount, boneMask ); + m_iIKCounter++; + auto_ik.Init( hdr, GetRenderAngles(), GetRenderOrigin(), currentTime, m_iIKCounter, boneMask ); boneSetup.CalcAutoplaySequences( pos, q, currentTime, &auto_ik ); } else @@ -2929,7 +2930,8 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i if (Teleported() || IsNoInterpolationFrame()) m_pIk->ClearTargets(); - m_pIk->Init( hdr, GetRenderAngles(), GetRenderOrigin(), currentTime, gpGlobals->framecount, bonesMaskNeedRecalc ); + m_iIKCounter++; + m_pIk->Init( hdr, GetRenderAngles(), GetRenderOrigin(), currentTime, m_iIKCounter, bonesMaskNeedRecalc ); } // Let pose debugger know that we are blending diff --git a/game/client/cstrike/c_cs_player.cpp b/game/client/cstrike/c_cs_player.cpp index 804952c297..04a558f892 100644 --- a/game/client/cstrike/c_cs_player.cpp +++ b/game/client/cstrike/c_cs_player.cpp @@ -688,6 +688,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_CSPlayer, DT_CSPlayer, CCSPlayer ) RecvPropInt( RECVINFO( m_iClass ) ), RecvPropInt( RECVINFO( m_ArmorValue ) ), RecvPropQAngles( RECVINFO( m_angEyeAngles ) ), + RecvPropQAngles( RECVINFO( m_angRenderAngles ) ), RecvPropFloat( RECVINFO( m_flStamina ) ), RecvPropInt( RECVINFO( m_bHasDefuser ), 0, RecvProxy_HasDefuser ), RecvPropInt( RECVINFO( m_bNightVisionOn), 0, RecvProxy_NightVision ), @@ -729,11 +730,14 @@ END_RECV_TABLE() C_CSPlayer::C_CSPlayer() : - m_iv_angEyeAngles( "C_CSPlayer::m_iv_angEyeAngles" ) + m_iv_angEyeAngles( "C_CSPlayer::m_iv_angEyeAngles" ), + m_iv_angRenderAngles( "C_CSPlayer::m_iv_angRenderAngles" ) { m_angEyeAngles.Init(); + m_angRenderAngles.Init(); - // AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); + AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); + AddVar( &m_angRenderAngles, &m_iv_angRenderAngles, LATCH_SIMULATION_VAR ); m_iLastAddonBits = m_iAddonBits = 0; m_iLastPrimaryAddon = m_iLastSecondaryAddon = WEAPON_NONE; @@ -884,7 +888,7 @@ const QAngle& C_CSPlayer::GetRenderAngles() } else { - return BaseClass::GetRenderAngles(); + return m_angRenderAngles; } } @@ -2133,7 +2137,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event ) if ( index == GetUserID() && IsLocalPlayer() ) { const auto playerIndex = event->GetInt( "player_index" ); - const auto player = UTIL_PlayerByIndex( playerIndex ); + const auto player = ( C_CSPlayer* )UTIL_PlayerByIndex( playerIndex ); if ( player && !player->IsLocalPlayer() ) { @@ -2169,7 +2173,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event ) float flBackupBoneControllers[MAXSTUDIOBONECTRLS]; C_AnimationLayer backupAnimLayers[C_BaseAnimatingOverlay::MAX_OVERLAYS]; Vector vecBackupPosition = player->GetAbsOrigin(); - QAngle angBackupAngles = player->GetAbsAngles(); + QAngle angBackupAngles = player->m_angRenderAngles; auto flOldCycle = GetCycle(); auto iOldSequence = GetSequence(); @@ -2192,9 +2196,10 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event ) player->SetAbsOrigin( Vector( event->GetFloat( "position_x" ), event->GetFloat( "position_y" ), event->GetFloat( "position_z" ) ) ); - player->SetAbsAngles( QAngle( event->GetFloat( "angle_x" ), - event->GetFloat( "angle_y" ), - event->GetFloat( "angle_z" ) ) ); + + player->m_angRenderAngles = QAngle( event->GetFloat( "angle_x" ), + event->GetFloat( "angle_y" ), + event->GetFloat( "angle_z" ) ); const auto numposeparams = event->GetInt( "num_poseparams" ); Assert( numposeparams == pStudioHdr->GetNumPoseParameters() ); @@ -2265,7 +2270,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event ) player->SetSequence( iOldSequence ); player->SetCycle( flOldCycle ); player->SetAbsOrigin( vecBackupPosition ); - player->SetAbsAngles( angBackupAngles ); + player->m_angRenderAngles = angBackupAngles; for ( int i = 0; i < numposeparams; i++ ) { diff --git a/game/client/cstrike/c_cs_player.h b/game/client/cstrike/c_cs_player.h index 786c34e408..f9b5bfea2d 100644 --- a/game/client/cstrike/c_cs_player.h +++ b/game/client/cstrike/c_cs_player.h @@ -329,6 +329,7 @@ private: int m_iClass; int m_ArmorValue; QAngle m_angEyeAngles; + QAngle m_angRenderAngles; bool m_bHasDefuser; float m_fNextThinkPushAway; @@ -342,6 +343,7 @@ private: Vector m_vecRagdollVelocity; CInterpolatedVar< QAngle > m_iv_angEyeAngles; + CInterpolatedVar< QAngle > m_iv_angRenderAngles; // ID Target int m_iIDEntIndex; diff --git a/game/server/BaseAnimatingOverlay.cpp b/game/server/BaseAnimatingOverlay.cpp index cae9fd4a1a..929f251600 100644 --- a/game/server/BaseAnimatingOverlay.cpp +++ b/game/server/BaseAnimatingOverlay.cpp @@ -434,7 +434,6 @@ void CAnimationLayer::DispatchAnimEvents( CBaseAnimating *eventHandler, CBaseAni } - void CBaseAnimatingOverlay::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], int boneMask ) { if(!pStudioHdr) @@ -481,7 +480,7 @@ void CBaseAnimatingOverlay::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Q if ( m_pIk ) { CIKContext auto_ik; - auto_ik.Init( pStudioHdr, GetAbsAngles(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask ); + auto_ik.Init( pStudioHdr, GetRenderAngles(), GetRenderOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask ); boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik ); } else diff --git a/game/server/BaseAnimatingOverlay.h b/game/server/BaseAnimatingOverlay.h index 942494d263..0a4fe25bb9 100644 --- a/game/server/BaseAnimatingOverlay.h +++ b/game/server/BaseAnimatingOverlay.h @@ -132,7 +132,7 @@ public: MAX_OVERLAYS = 15, }; -private: +protected: CUtlVector< CAnimationLayer > m_AnimOverlay; //int m_nActiveLayers; //int m_nActiveBaseLayers; diff --git a/game/server/baseanimating.cpp b/game/server/baseanimating.cpp index 0c4ab7f33f..ff609238dd 100644 --- a/game/server/baseanimating.cpp +++ b/game/server/baseanimating.cpp @@ -2029,7 +2029,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask ) // FIXME: pass this into Studio_BuildMatrices to skip transforms CBoneBitList boneComputed; 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 ); UpdateIKLocks( gpGlobals->curtime ); @@ -2053,7 +2053,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask ) { BuildMatricesWithBoneMerge( pStudioHdr, - GetAbsAngles(), + GetRenderAngles(), adjOrigin, pos, q, @@ -2072,7 +2072,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask ) Studio_BuildMatrices( pStudioHdr, - GetAbsAngles(), + GetRenderAngles(), adjOrigin, pos, q, @@ -3033,7 +3033,7 @@ void CBaseAnimating::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Quaterni if ( m_pIk ) { 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 ); } else diff --git a/game/server/baseanimating.h b/game/server/baseanimating.h index 221f9ae8fc..c54984b6f1 100644 --- a/game/server/baseanimating.h +++ b/game/server/baseanimating.h @@ -425,7 +425,7 @@ protected: public: COutputEvent m_OnIgnite; -private: +protected: CStudioHdr *m_pStudioHdr; CThreadFastMutex m_StudioHdrInitLock; CThreadFastMutex m_BoneSetupMutex; diff --git a/game/server/baseentity.h b/game/server/baseentity.h index 04d3861077..6592911a68 100644 --- a/game/server/baseentity.h +++ b/game/server/baseentity.h @@ -426,6 +426,8 @@ public: bool IsCurrentlyTouching( void ) const; const Vector& GetAbsOrigin( void ) const; const QAngle& GetAbsAngles( void ) const; + virtual const Vector& GetRenderOrigin( void ) const { return GetAbsOrigin(); } + virtual const QAngle& GetRenderAngles( void ) const { return GetAbsAngles(); } SolidType_t GetSolid() const; int GetSolidFlags( void ) const; diff --git a/game/server/cstrike/cs_player.cpp b/game/server/cstrike/cs_player.cpp index 8bff482666..573f0fb94c 100644 --- a/game/server/cstrike/cs_player.cpp +++ b/game/server/cstrike/cs_player.cpp @@ -6,6 +6,7 @@ //=============================================================================// #include "cbase.h" +#include "bone_setup.h" #include "cs_player.h" #include "cs_gamerules.h" #include "dt_send.h" @@ -300,6 +301,7 @@ IMPLEMENT_SERVERCLASS_ST( CCSPlayer, DT_CSPlayer ) SendPropInt( SENDINFO( m_iClass ), Q_log2( CS_NUM_CLASSES )+1, SPROP_UNSIGNED ), SendPropInt( SENDINFO( m_ArmorValue ), 8 ), SendPropQAngles(SENDINFO(m_angEyeAngles)), + SendPropQAngles(SENDINFO(m_angRenderAngles)), SendPropBool( SENDINFO( m_bHasDefuser ) ), SendPropBool( SENDINFO( m_bNightVisionOn ) ), //send as int so we can use a RecvProxy on the client SendPropBool( SENDINFO( m_bHasNightVision ) ), @@ -1161,7 +1163,7 @@ void CCSPlayer::Event_Killed( const CTakeDamageInfo &info ) { if ( RandomInt( 0, 100 ) < 20 ) { - CHolidayGift::Create( WorldSpaceCenter(), GetAbsAngles(), EyeAngles(), GetAbsVelocity(), this ); + CHolidayGift::Create( WorldSpaceCenter(), GetRenderAngles(), EyeAngles(), GetAbsVelocity(), this ); } } @@ -1452,7 +1454,7 @@ void CCSPlayer::UpdateRadar() WRITE_SBITLONG( pPlayer->GetAbsOrigin().x/4, COORD_INTEGER_BITS-1 ); WRITE_SBITLONG( pPlayer->GetAbsOrigin().y/4, COORD_INTEGER_BITS-1 ); WRITE_SBITLONG( pPlayer->GetAbsOrigin().z/4, COORD_INTEGER_BITS-1 ); - WRITE_SBITLONG( AngleNormalize( pPlayer->GetAbsAngles().y ), 9 ); + WRITE_SBITLONG( AngleNormalize( pPlayer->GetRenderAngles().y ), 9 ); } WRITE_BYTE( 0 ); // end marker @@ -1574,6 +1576,8 @@ void CCSPlayer::PostThink() m_PlayerAnimState->Update( m_angEyeAngles[YAW], m_angEyeAngles[PITCH] ); + m_angRenderAngles = m_PlayerAnimState->GetRenderAngles(); + // check if we need to apply a deafness DSP effect. if ((m_applyDeafnessTime != 0.0f) && (m_applyDeafnessTime <= gpGlobals->curtime)) { @@ -2768,7 +2772,7 @@ void CCSPlayer::DropShield( void ) #ifdef CS_SHIELD_ENABLED //Drop an item_defuser Vector vForward, vRight; - AngleVectors( GetAbsAngles(), &vForward, &vRight, NULL ); + AngleVectors( GetRenderAngles(), &vForward, &vRight, NULL ); RemoveShield(); @@ -6707,7 +6711,7 @@ void CCSPlayer::DropWeapons( bool fromDeath, bool friendlyFire ) { //Drop an item_defuser Vector vForward, vRight; - AngleVectors( GetAbsAngles(), &vForward, &vRight, NULL ); + AngleVectors( GetRenderAngles(), &vForward, &vRight, NULL ); CBaseAnimating *pDefuser = (CBaseAnimating *)CBaseEntity::Create( "item_defuser", WorldSpaceCenter(), GetLocalAngles(), this ); pDefuser->ApplyAbsVelocityImpulse( vForward * 200 + vRight * random->RandomFloat( -50, 50 ) ); diff --git a/game/server/cstrike/cs_player.h b/game/server/cstrike/cs_player.h index de2bc7e6e6..2d6f859889 100644 --- a/game/server/cstrike/cs_player.h +++ b/game/server/cstrike/cs_player.h @@ -287,6 +287,9 @@ public: virtual void SetupVisibility( CBaseEntity *pViewEntity, unsigned char *pvs, int pvssize ); virtual int GetNextObserverSearchStartPoint( bool bReverse ); + + virtual const QAngle& GetRenderAngles( void ) const { return m_angRenderAngles; } + // In shared code. public: @@ -813,6 +816,7 @@ public: // Copyed from EyeAngles() so we can send it to the client. CNetworkQAngle( m_angEyeAngles ); + CNetworkQAngle( m_angRenderAngles ); bool m_bVCollisionInitted; diff --git a/game/server/player_lagcompensation.cpp b/game/server/player_lagcompensation.cpp index 5a3314a125..1f1882530b 100644 --- a/game/server/player_lagcompensation.cpp +++ b/game/server/player_lagcompensation.cpp @@ -6,6 +6,9 @@ //=============================================================================// #include "cbase.h" +#ifdef CSTRIKE_DLL +#include "cs_player.h" +#endif #include "icvar.h" #include "player.h" #include "shareddefs.h" @@ -88,6 +91,9 @@ struct LagRecord { m_encodedControllers[i] = 0; } +#ifdef CSTRIKE_DLL + m_angRenderAngles.Init(); +#endif } LagRecord( const LagRecord& src ) @@ -117,6 +123,10 @@ struct LagRecord { m_encodedControllers[i] = src.m_encodedControllers[i]; } + +#ifdef CSTRIKE_DLL + m_angRenderAngles = src.m_angRenderAngles; +#endif } // Did player die this frame @@ -137,6 +147,9 @@ struct LagRecord float m_masterCycle; float m_poseParameters[MAXSTUDIOPOSEPARAM]; float m_encodedControllers[MAXSTUDIOBONECTRLS]; +#ifdef CSTRIKE_DLL + QAngle m_angRenderAngles; +#endif }; // @@ -323,6 +336,15 @@ void CLagCompensationManager::TrackPlayerData( CBasePlayer* pPlayer ) } } +#ifdef CSTRIKE_DLL + const auto csPlayer = dynamic_cast< CCSPlayer* >( pPlayer ); + + if ( csPlayer ) + { + record.m_angRenderAngles = csPlayer->m_angRenderAngles; + } +#endif + track->Push( record ); } @@ -384,10 +406,17 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer* pPlayer, CUserCmd* c Vector minsPreScaled; Vector maxsPreScaled; QAngle ang; +#ifdef CSTRIKE_DLL + QAngle renderAngles; +#endif LagRecord* nextRecordSim; LagRecord* recordSim; LagRecord* recordAnim; +#ifdef CSTRIKE_DLL + auto csPlayer = dynamic_cast< CCSPlayer* >( pPlayer ); +#endif + int pl_index = pPlayer->entindex(); float flTargetLerpSimTime = cmd->simulationdata[pl_index].lerp_time; @@ -470,6 +499,12 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer* pPlayer, CUserCmd* c org = Lerp( fracSim, recordSim->m_vecOrigin, nextRecordSim->m_vecOrigin ); minsPreScaled = Lerp( fracSim, recordSim->m_vecMinsPreScaled, nextRecordSim->m_vecMinsPreScaled ); maxsPreScaled = Lerp( fracSim, recordSim->m_vecMaxsPreScaled, nextRecordSim->m_vecMaxsPreScaled ); +#ifdef CSTRIKE_DLL + if ( csPlayer ) + { + renderAngles = Lerp( fracSim, recordSim->m_angRenderAngles, nextRecordSim->m_angRenderAngles ); + } +#endif } else { @@ -479,6 +514,9 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer* pPlayer, CUserCmd* c ang = recordSim->m_vecAngles; minsPreScaled = recordSim->m_vecMinsPreScaled; maxsPreScaled = recordSim->m_vecMaxsPreScaled; +#ifdef CSTRIKE_DLL + renderAngles = recordSim->m_angRenderAngles; +#endif } // See if this represents a change for the player @@ -493,6 +531,14 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer* pPlayer, CUserCmd* c restore->m_flSimulationTime = pPlayer->GetSimulationTime(); restore->m_flAnimTime = pPlayer->GetAnimTime(); +#ifdef CSTRIKE_DLL + if ( csPlayer ) + { + restore->m_angRenderAngles = csPlayer->m_angRenderAngles; + csPlayer->m_angRenderAngles = renderAngles; + } +#endif + if ( angdiff.LengthSqr() > 0.0f ) { flags |= LC_ANGLES_CHANGED; @@ -634,6 +680,15 @@ void CLagCompensationManager::FinishLagCompensation( CBasePlayer* player ) LagRecord* restore = &m_RestoreData[i]; LagRecord* change = &m_ChangeData[i]; +#ifdef CSTRIKE_DLL + auto csPlayer = dynamic_cast< CCSPlayer* >( pPlayer ); + + if ( csPlayer ) + { + csPlayer->m_angRenderAngles = restore->m_angRenderAngles; + } +#endif + if ( restore->m_fFlags & LC_SIZE_CHANGED ) { // see if simulation made any changes, if no, then do the restore, otherwise, diff --git a/game/shared/cstrike/cs_player_shared.cpp b/game/shared/cstrike/cs_player_shared.cpp index 06cd9218e1..88fce9954b 100644 --- a/game/shared/cstrike/cs_player_shared.cpp +++ b/game/shared/cstrike/cs_player_shared.cpp @@ -541,8 +541,8 @@ void CCSPlayer::FireBullet( QAngle angles[MAXSTUDIOBONES]; int indexes[MAXSTUDIOBONES]; - auto angle = lagPlayer->GetAbsAngles(); - auto position = lagPlayer->GetAbsOrigin(); + auto angle = lagPlayer->GetRenderAngles(); + auto position = lagPlayer->GetRenderOrigin(); event->SetFloat( "position_x", position.x ); event->SetFloat( "position_y", position.y );