Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions src/game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,9 @@ CStudioHdr *C_BaseAnimating::OnNewModel()
}
m_BoneAccessor.Init( this, m_CachedBoneData.Base() ); // Always call this in case the studiohdr_t has changed.

// Reset the accumulated bone mask.
m_iAccumulatedBoneMask = 0;

// Free any IK data
if (m_pIk)
{
Expand Down Expand Up @@ -2286,16 +2289,24 @@ bool C_BaseAnimating::PutAttachment( int number, const matrix3x4_t &attachmentTo
return false;

CAttachmentData *pAtt = &m_Attachments[number-1];
if ( gpGlobals->frametime > 0 && pAtt->m_nLastFramecount > 0 && pAtt->m_nLastFramecount == gpGlobals->framecount - 1 )
if ( gpGlobals->frametime > 0 && pAtt->m_nLastFramecount > 0 && pAtt->m_nLastFramecount < gpGlobals->framecount )
{
Vector vecPreviousOrigin, vecOrigin;
MatrixPosition( pAtt->m_AttachmentToWorld, vecPreviousOrigin );
MatrixPosition( attachmentToWorld, vecOrigin );
pAtt->m_vOriginVelocity = (vecOrigin - vecPreviousOrigin) / gpGlobals->frametime;

// compensate for the fact that the previous origin could have been multiple frames behind
pAtt->m_vOriginVelocity = (vecOrigin - vecPreviousOrigin) / (gpGlobals->frametime * (gpGlobals->framecount - pAtt->m_nLastFramecount));
// only update the frame count if the position changed, so we don't have to recompute attachments
if ( !pAtt->m_vOriginVelocity.IsZero( 0.00001f ) )
{
pAtt->m_nLastFramecount = gpGlobals->framecount;
}
}
else
{
pAtt->m_vOriginVelocity.Init();
pAtt->m_nLastFramecount = gpGlobals->framecount;
}
pAtt->m_nLastFramecount = gpGlobals->framecount;
pAtt->m_bAnglesComputed = false;
Expand All @@ -2308,6 +2319,20 @@ bool C_BaseAnimating::PutAttachment( int number, const matrix3x4_t &attachmentTo
return true;
}

bool C_BaseAnimating::GetAttachmentDeferred( int number, matrix3x4_t& matrix )
{
if ( number < 1 || number > m_Attachments.Count() )
return false;

// allow visual effects (eg. particles) to be a frame behind bone setup so that there are not messy dependencies.
CAttachmentData* pAtt = &m_Attachments[number - 1];
const bool bShouldUpdate = pAtt->m_nLastFramecount < gpGlobals->framecount - 1;
if ( bShouldUpdate && !CalcAttachments() )
return false;

matrix = pAtt->m_AttachmentToWorld;
return true;
}

bool C_BaseAnimating::SetupBones_AttachmentHelper( CStudioHdr *hdr )
{
Expand Down Expand Up @@ -3122,6 +3147,22 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
}
}

// If we're setting up LOD N, we have set up all lower LODs also
// because lower LODs always use subsets of the bones of higher LODs.
int nLOD = 0;
int nMask = BONE_USED_BY_VERTEX_LOD0;

for ( ; nLOD < MAX_NUM_LODS; ++nLOD, nMask <<= 1 )
{
if ( boneMask & nMask )
break;
}

for ( ; nLOD < MAX_NUM_LODS; ++nLOD, nMask <<= 1 )
{
boneMask |= nMask;
}

#ifdef DEBUG_BONE_SETUP_THREADING
if ( cl_warn_thread_contested_bone_setup.GetBool() )
{
Expand Down Expand Up @@ -3154,7 +3195,9 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
m_flLastBoneSetupTime = currentTime;
}
m_iPrevBoneMask = m_iAccumulatedBoneMask;
m_iAccumulatedBoneMask = 0;

// Keep record of the fact that we've used attachments. Because of deferred attachments, we can't keep track from the previous frame.
m_iAccumulatedBoneMask = m_iAccumulatedBoneMask & BONE_USED_BY_ATTACHMENT;

#ifdef STUDIO_ENABLE_PERF_COUNTERS
CStudioHdr *hdr = GetModelPtr();
Expand Down Expand Up @@ -3189,7 +3232,7 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
return false;

// Setup our transform based on render angles and origin.
matrix3x4_t parentTransform;
ALIGN16 matrix3x4_t parentTransform ALIGN16_POST;
AngleMatrix( GetRenderAngles(), GetRenderOrigin(), parentTransform );

// Load the boneMask with the total of what was asked for last frame.
Expand Down
1 change: 1 addition & 0 deletions src/game/client/c_baseanimating.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class C_BaseAnimating : public C_BaseEntity, private IModelLoadCallback
// Attachments.
bool GetAttachment( const char *szName, Vector &absOrigin );
bool GetAttachment( const char *szName, Vector &absOrigin, QAngle &absAngles );
virtual bool GetAttachmentDeferred( int number, matrix3x4_t& matrix );

// Inherited from C_BaseEntity
virtual bool GetAttachment( int number, Vector &origin );
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/c_baseflex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Vector C_BaseFlex::SetViewTarget( CStudioHdr *pStudioHdr )
if (m_iEyeAttachment > 0)
{
matrix3x4_t attToWorld;
if (!GetAttachment( m_iEyeAttachment, attToWorld ))
if (!GetAttachmentDeferred( m_iEyeAttachment, attToWorld ))
{
return Vector( 0, 0, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/c_smokestack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void C_SmokeStack::RenderParticles( CParticleRenderIterator *pIterator )
// makes it get translucent and fade out for a longer time.
//float alpha = cosf( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
float tLifetime = pParticle->m_Lifetime * m_InvLifetime;
float alpha = TableCos( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
float alpha = FastCos( -M_PI_F + tLifetime * M_PI_F * 2.f ) * 0.5f + 0.5f;
if( tLifetime > 0.5f )
alpha *= alpha;

Expand Down
2 changes: 1 addition & 1 deletion src/game/client/glow_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void CGlowOverlay::UpdateSkyGlowObstruction( float zFar, bool bCacheFullSceneSta
if ( PixelVisibility_IsAvailable() )
{
// Trace a ray at the object.
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.999f;
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.99f;

// UNDONE: Can probably do only the pixelvis query in this case if you can figure out where
// to put it - or save the position of this trace
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/in_steamcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ void CInput::ApplySteamControllerCameraMove( QAngle& viewangles, CUserCmd *cmd,
//roll the view angles so roll is 0 (the HL2 assumed state) and mouse adjustments are relative to the screen.
//Assuming roll is unchanging, we want mouse left to translate to screen left at all times (same for right, up, and down)

ConVarRef cl_pitchdown ( "cl_pitchdown" );
ConVarRef cl_pitchup ( "cl_pitchup" );
static ConVarRef cl_pitchdown ( "cl_pitchdown" );
static ConVarRef cl_pitchup ( "cl_pitchup" );

// Scale yaw and pitch inputs by sensitivity, and make sure they are within acceptable limits (important to avoid exploits, e.g. during Demoman charge we must restrict allowed yaw).
float yaw = CAM_CapYaw( sc_yaw_sensitivity.GetFloat() * vecPosition.x );
Expand Down
55 changes: 43 additions & 12 deletions src/game/client/tf/c_tf_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,20 @@ bool C_TFRagdoll::GetAttachment( int iAttachment, matrix3x4_t &attachmentToWorld
}
}

bool C_TFRagdoll::GetAttachmentDeferred( int iAttachment, matrix3x4_t& attachmentToWorld )
{
int iHeadAttachment = LookupAttachment( "head" );
if ( IsDecapitation() && (iAttachment == iHeadAttachment) )
{
MatrixCopy( m_mHeadAttachment, attachmentToWorld );
return true;
}
else
{
return BaseClass::GetAttachmentDeferred( iAttachment, attachmentToWorld );
}
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : -
Expand Down Expand Up @@ -1369,6 +1383,9 @@ bool C_TFRagdoll::IsRagdollVisible()
#define DISSOLVE_FADE_OUT_START_TIME 2.0f
#define DISSOLVE_FADE_OUT_END_TIME 2.0f

extern ConVar g_ragdoll_lvfadespeed;
extern ConVar g_ragdoll_fadespeed;

void C_TFRagdoll::ClientThink( void )
{
SetNextClientThink( CLIENT_THINK_ALWAYS );
Expand Down Expand Up @@ -1510,9 +1527,16 @@ void C_TFRagdoll::ClientThink( void )
if ( m_bFadingOut == true )
{
int iAlpha = GetRenderColor().a;
int iFadeSpeed = 600.0f;
int iFadeSpeed = ( g_RagdollLVManager.IsLowViolence() ) ? g_ragdoll_lvfadespeed.GetInt() : g_ragdoll_fadespeed.GetInt();

iAlpha = MAX( iAlpha - ( iFadeSpeed * gpGlobals->frametime ), 0 );
if (iFadeSpeed < 1)
{
iAlpha = 0;
}
else
{
iAlpha = MAX( iAlpha - ( iFadeSpeed * gpGlobals->frametime ), 0 );
}

SetRenderMode( kRenderTransAlpha );
SetRenderColorA( iAlpha );
Expand All @@ -1531,15 +1555,22 @@ void C_TFRagdoll::ClientThink( void )
if ( cl_ragdoll_forcefade.GetBool() )
{
m_bFadingOut = true;
float flDelay = cl_ragdoll_fade_time.GetFloat() * 0.33f;
m_fDeathTime = gpGlobals->curtime + flDelay;

RemoveAllDecals();
}

// Fade out after the specified delay.
StartFadeOut( cl_ragdoll_fade_time.GetFloat() * 0.33f );
return;
float flDelay = cl_ragdoll_fade_time.GetFloat() * 0.33f;
if (flDelay > 0.01f)
{
m_fDeathTime = gpGlobals->curtime + flDelay;
return;
}
m_fDeathTime = -1;
}
else
{
// Fade out after the specified delay.
StartFadeOut( cl_ragdoll_fade_time.GetFloat() * 0.33f );
return;
}
}

// Remove us if our death time has passed.
Expand Down Expand Up @@ -6845,15 +6876,15 @@ int C_TFPlayer::DrawModel( int flags )
// Don't draw the model at all if we're fully invisible
if ( GetEffectiveInvisibilityLevel() >= 1.0f )
{
if ( m_hHalloweenBombHat && ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 90 ) && !m_hHalloweenBombHat->IsEffectActive( EF_NODRAW ) )
if ( m_hHalloweenBombHat && ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 90 || g_pMaterialSystemHardwareConfig->PreferReducedFillrate() ) && !m_hHalloweenBombHat->IsEffectActive( EF_NODRAW ) )
{
m_hHalloweenBombHat->SetEffects( EF_NODRAW );
}
return 0;
}
else
{
if ( m_hHalloweenBombHat && ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 90 ) && m_hHalloweenBombHat->IsEffectActive( EF_NODRAW ) )
if ( m_hHalloweenBombHat && ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 90 || g_pMaterialSystemHardwareConfig->PreferReducedFillrate() ) && m_hHalloweenBombHat->IsEffectActive( EF_NODRAW ) )
{
m_hHalloweenBombHat->RemoveEffects( EF_NODRAW );
}
Expand Down Expand Up @@ -7504,7 +7535,7 @@ void C_TFPlayer::DropWearable( C_TFWearable *pItem, const breakablepropparams_t
}

pEntity->m_nSkin = m_nSkin;
pEntity->StartFadeOut( 15.0f );
pEntity->StartFadeOut( cl_ragdoll_fade_time.GetFloat() );

IPhysicsObject *pPhysicsObject = pEntity->VPhysicsGetObject();
if ( !pPhysicsObject )
Expand Down
1 change: 1 addition & 0 deletions src/game/client/tf/c_tf_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ class C_TFRagdoll : public C_BaseFlex
int GetDamageCustom() { return m_iDamageCustom; }

virtual bool GetAttachment( int iAttachment, matrix3x4_t &attachmentToWorld );
virtual bool GetAttachmentDeferred( int iAttachment, matrix3x4_t& attachmentToWorld );

int GetClass() { return m_iClass; }

Expand Down
4 changes: 2 additions & 2 deletions src/game/client/tf/tf_hud_notification_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CHudNotificationPanel::MsgFunc_HudNotify( bf_read &msg )
// Ignore notifications in minmode
if ( !bForceShow )
{
ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
static ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
if ( cl_hud_minmode.IsValid() && cl_hud_minmode.GetBool() )
return;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ void CHudNotificationPanel::MsgFunc_HudNotify( bf_read &msg )
void CHudNotificationPanel::MsgFunc_HudNotifyCustom( bf_read &msg )
{
// Ignore notifications in minmode
ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
static ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
if ( cl_hud_minmode.IsValid() && cl_hud_minmode.GetBool() )
return;

Expand Down
10 changes: 10 additions & 0 deletions src/game/client/tf/vgui/tf_classmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,11 @@ void CTFClassMenu::SetVisible( bool state )

if ( state )
{
if (m_pTFPlayerModelPanel)
{
m_pTFPlayerModelPanel->SetVisible( true );
}

engine->ServerCmd( "menuopen" ); // to the server
engine->ClientCmd( "_cl_classmenuopen 1" ); // for other panels
CBroadcastRecipientFilter filter;
Expand All @@ -1198,6 +1203,11 @@ void CTFClassMenu::SetVisible( bool state )
{
engine->ServerCmd( "menuclosed" );
engine->ClientCmd( "_cl_classmenuopen 0" );

if (m_pTFPlayerModelPanel)
{
m_pTFPlayerModelPanel->SetVisible( false );
}

if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() )
{
Expand Down
6 changes: 1 addition & 5 deletions src/game/client/viewrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2796,15 +2796,11 @@ void CViewRender::DetermineWaterRenderInfo( const VisibleFogVolumeInfo_t &fogVol
// Gary says: I'm reverting this change so that water LOD works on dx9 for ep2.

// Check if the water is out of the cheap water LOD range; if so, use cheap water
#ifdef _X360
if ( !bForceExpensive && ( bForceCheap || ( fogVolumeInfo.m_flDistanceToWater >= m_flCheapWaterEndDistance ) ) )
{
return;
}
#else
if ( ( (fogVolumeInfo.m_flDistanceToWater >= m_flCheapWaterEndDistance) && !bLocalReflection ) || bForceCheap )
return;
#endif

// Get the material that is for the water surface that is visible and check to see
// what render targets need to be rendered, if any.
if ( !r_WaterDrawRefraction.GetBool() )
Expand Down
8 changes: 4 additions & 4 deletions src/game/server/tf/entity_ammopack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ bool CAmmoPack::MyTouch( CBasePlayer *pPlayer )
float flPackRatio = PackRatios[GetPowerupSize()];

int iMaxPrimary = pTFPlayer->GetMaxAmmo(TF_AMMO_PRIMARY);
if ( pTFPlayer->GiveAmmo( ceil(iMaxPrimary * flPackRatio), TF_AMMO_PRIMARY, true, kAmmoSource_Pickup ) )
if ( pTFPlayer->GiveAmmo( Ceil2Int(iMaxPrimary * flPackRatio), TF_AMMO_PRIMARY, true, kAmmoSource_Pickup ) )
{
bSuccess = true;
}

int iMaxSecondary = pTFPlayer->GetMaxAmmo(TF_AMMO_SECONDARY);
if ( pTFPlayer->GiveAmmo( ceil(iMaxSecondary * flPackRatio), TF_AMMO_SECONDARY, true, kAmmoSource_Pickup ) )
if ( pTFPlayer->GiveAmmo( Ceil2Int(iMaxSecondary * flPackRatio), TF_AMMO_SECONDARY, true, kAmmoSource_Pickup ) )
{
bSuccess = true;
}

int iMaxMetal = pTFPlayer->GetMaxAmmo(TF_AMMO_METAL);
if ( pTFPlayer->GiveAmmo( ceil(iMaxMetal * flPackRatio), TF_AMMO_METAL, true, kAmmoSource_Pickup ) )
if ( pTFPlayer->GiveAmmo( Ceil2Int(iMaxMetal * flPackRatio), TF_AMMO_METAL, true, kAmmoSource_Pickup ) )
{
bSuccess = true;
}
Expand Down Expand Up @@ -112,7 +112,7 @@ bool CAmmoPack::MyTouch( CBasePlayer *pPlayer )
if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) )
{
int iMaxGrenades1 = pTFPlayer->GetMaxAmmo(TF_AMMO_GRENADES1);
if ( pTFPlayer->GiveAmmo( ceil(iMaxGrenades1 * flPackRatio), TF_AMMO_GRENADES1, true, kAmmoSource_Pickup ) )
if ( pTFPlayer->GiveAmmo( Ceil2Int(iMaxGrenades1 * flPackRatio), TF_AMMO_GRENADES1, true, kAmmoSource_Pickup ) )
{
bSuccess = true;
}
Expand Down
Loading
Loading