We have to use renderangles again

This commit is contained in:
unknown 2024-09-08 22:42:23 +02:00
parent 4377aa7b81
commit ec524a26b5
10 changed files with 81 additions and 31 deletions

View file

@ -691,6 +691,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 ),
@ -739,6 +740,8 @@ C_CSPlayer::C_CSPlayer() :
AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR );
// interpolation on m_angRenderAngles later
m_iLastAddonBits = m_iAddonBits = 0;
m_iLastPrimaryAddon = m_iLastSecondaryAddon = WEAPON_NONE;
m_iProgressBarDuration = 0;
@ -880,19 +883,6 @@ int C_CSPlayer::GetCurrentAssaultSuitPrice()
}
}
const QAngle& C_CSPlayer::GetRenderAngles()
{
if ( IsRagdoll() )
{
return vec3_angle;
}
else
{
return BaseClass::GetRenderAngles();
}
}
float g_flFattenAmt = 4;
void C_CSPlayer::GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType )
{
@ -2182,7 +2172,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
C_AnimationLayer backupAnimLayers[C_BaseAnimatingOverlay::MAX_OVERLAYS];
Vector vecBackupPosition = player->GetLocalOrigin();
QAngle angBackupAngles = player->GetLocalAngles();
QAngle angBackupAngles = player->GetRenderAngles();
auto flOldCycle = player->GetCycle();
auto iOldSequence = player->GetSequence();
@ -2207,9 +2197,9 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
event->GetFloat( "position_y" ),
event->GetFloat( "position_z" ) ) );
player->SetLocalAngles( 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" );
AssertFatal( numposeparams == pStudioHdr->GetNumPoseParameters() );
@ -2313,7 +2303,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
pos++;
}
auto angles = player->GetLocalAngles();
auto angles = player->GetRenderAngles();
if ( pRecord->m_angLocalAngles != angles )
{
@ -2440,7 +2430,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
player->m_nSequence = iOldSequence;
player->m_flCycle = flOldCycle;
player->SetLocalOrigin( vecBackupPosition );
player->SetLocalAngles( angBackupAngles );
player->m_angRenderAngles = angBackupAngles;
for ( int i = 0; i < MAXSTUDIOPOSEPARAM; i++ )
{

View file

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

View file

@ -480,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(), GetAbsOrigin(), gpGlobals->curtime, m_iIKCounter, boneMask );
boneSetup.CalcAutoplaySequences( pos, q, gpGlobals->curtime, &auto_ik );
}
else

View file

@ -1680,7 +1680,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
// FIXME: trace based on gravity or trace based on angles?
Vector up;
AngleVectors( GetAbsAngles(), NULL, NULL, &up );
AngleVectors( GetRenderAngles(), NULL, NULL, &up );
// FIXME: check number of slots?
float minHeight = FLT_MAX;
@ -1791,7 +1791,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
else if (trace.DidHitNonWorldEntity())
{
pTarget->SetPos( trace.endpos );
pTarget->SetAngles( GetAbsAngles() );
pTarget->SetAngles( GetRenderAngles() );
// only do this on forward tracking or commited IK ground rules
if (pTarget->est.release < 0.1)
@ -1825,7 +1825,7 @@ void CBaseAnimating::CalculateIKLocks( float currentTime )
else
{
pTarget->SetPos( trace.endpos );
pTarget->SetAngles( GetAbsAngles() );
pTarget->SetAngles( GetRenderAngles() );
pTarget->SetOnWorld( true );
}
}
@ -2041,7 +2041,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 );
@ -2065,7 +2065,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask )
{
BuildMatricesWithBoneMerge(
pStudioHdr,
GetAbsAngles(),
GetRenderAngles(),
adjOrigin,
pos,
q,
@ -2084,7 +2084,7 @@ void CBaseAnimating::SetupBones( matrix3x4_t *pBoneToWorld, int boneMask )
Studio_BuildMatrices(
pStudioHdr,
GetAbsAngles(),
GetRenderAngles(),
adjOrigin,
pos,
q,
@ -3046,7 +3046,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

View file

@ -427,6 +427,11 @@ public:
const Vector& GetAbsOrigin( void ) const;
const QAngle& GetAbsAngles( void ) const;
virtual const QAngle& GetRenderAngles( void )
{
return GetAbsAngles();
}
SolidType_t GetSolid() 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_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 ) ),
@ -1589,7 +1590,7 @@ void CCSPlayer::PostThink()
m_PlayerAnimState->Update( m_angEyeAngles[YAW], m_angEyeAngles[PITCH] );
// Use the m_angRotation instead.
SetLocalAngles( m_PlayerAnimState->GetRenderAngles() );
m_angRenderAngles = m_PlayerAnimState->GetRenderAngles();
// check if we need to apply a deafness DSP effect.
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* Instance( int iEnt );
virtual const QAngle& GetRenderAngles( void );
virtual void Precache();
virtual void Spawn();
virtual void InitialSpawn( void );
@ -814,6 +816,7 @@ public:
// Copyed from EyeAngles() so we can send it to the client.
CNetworkQAngle( m_angEyeAngles );
CNetworkQAngle( m_angRenderAngles );
bool m_bVCollisionInitted;

View file

@ -18,6 +18,9 @@
#include "util.h"
#include "utllinkedlist.h"
#include "BaseAnimatingOverlay.h"
#ifdef CSTRIKE_DLL
#include "cs_player.h"
#endif
#include "tier0/vprof.h"
// memdbgon must be the last include file in a .cpp file!!!
@ -75,6 +78,9 @@ struct LagRecord
float m_masterCycle;
float m_poseParameters[MAXSTUDIOPOSEPARAM];
float m_encodedControllers[MAXSTUDIOBONECTRLS];
#ifdef CSTRIKE_DLL
QAngle m_angRenderAngles;
#endif
};
//
@ -224,6 +230,15 @@ void CLagCompensationManager::TrackEntities()
}
}
#ifdef CSTRIKE_DLL
auto csPlayer = dynamic_cast<CCSPlayer*>(pEntity);
if (csPlayer)
{
record.m_angRenderAngles = csPlayer->GetRenderAngles();
}
#endif
track->Push( record );
}
}
@ -560,6 +575,16 @@ inline void CLagCompensationManager::BacktrackEntity( CBaseEntity* pEntity, int
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();
}
@ -662,6 +687,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->SetAnimTime( restore->m_flAnimTime );
}

View file

@ -44,6 +44,22 @@
ConVar weapon_accuracy_nospread( "weapon_accuracy_nospread", "0", FCVAR_REPLICATED );
#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 );
#ifdef _DEBUG
@ -558,7 +574,7 @@ void CCSPlayer::FireBullet(
QAngle angles[MAXSTUDIOBONES];
int indexes[MAXSTUDIOBONES];
auto angle = lagPlayer->GetLocalAngles();
auto angle = lagPlayer->GetRenderAngles();
auto position = lagPlayer->GetLocalOrigin();
event->SetFloat( "position_x", position.x );

View file

@ -319,8 +319,8 @@ void FX_FireBullets(
C_CSPlayer::HitboxRecord record;
record.m_vecLocalOrigin = lagPlayer->GetLocalOrigin();
record.m_angLocalAngles = lagPlayer->GetLocalAngles();
record.m_vecLocalOrigin = lagPlayer->GetLocalOrigin();
record.m_angLocalAngles = lagPlayer->GetRenderAngles();
record.m_nAttackerTickBase = pPlayer->m_nTickBase;
record.m_flSimulationTime = lagPlayer->m_flInterpolatedSimulationTime;