support cl_righthand
This commit is contained in:
parent
cb00ff4ff5
commit
22b3d26c0b
@ -19,7 +19,7 @@
|
|||||||
#include <KeyValues.h>
|
#include <KeyValues.h>
|
||||||
#include "hltvcamera.h"
|
#include "hltvcamera.h"
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
#include "tf_weaponbase.h"
|
#include "tf_weaponbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( REPLAY_ENABLED )
|
#if defined( REPLAY_ENABLED )
|
||||||
@ -35,39 +35,39 @@
|
|||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
#ifdef CSTRIKE_DLL
|
//#ifdef CSTRIKE_DLL
|
||||||
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." );
|
ConVar cl_righthand("cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models.");
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
ConVar cl_flipviewmodels( "cl_flipviewmodels", "0", FCVAR_USERINFO | FCVAR_ARCHIVE | FCVAR_NOT_CONNECTED, "Flip view models." );
|
ConVar cl_flipviewmodels("cl_flipviewmodels", "0", FCVAR_USERINFO | FCVAR_ARCHIVE | FCVAR_NOT_CONNECTED, "Flip view models.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PostToolMessage( HTOOLHANDLE hEntity, KeyValues *msg );
|
void PostToolMessage(HTOOLHANDLE hEntity, KeyValues* msg);
|
||||||
|
|
||||||
void FormatViewModelAttachment( Vector &vOrigin, bool bInverse )
|
void FormatViewModelAttachment(Vector& vOrigin, bool bInverse)
|
||||||
{
|
{
|
||||||
// Presumably, SetUpView has been called so we know our FOV and render origin.
|
// Presumably, SetUpView has been called so we know our FOV and render origin.
|
||||||
const CViewSetup *pViewSetup = view->GetPlayerViewSetup();
|
const CViewSetup* pViewSetup = view->GetPlayerViewSetup();
|
||||||
|
|
||||||
float worldx = tan( pViewSetup->fov * M_PI/360.0 );
|
float worldx = tan(pViewSetup->fov * M_PI / 360.0);
|
||||||
float viewx = tan( pViewSetup->fovViewmodel * M_PI/360.0 );
|
float viewx = tan(pViewSetup->fovViewmodel * M_PI / 360.0);
|
||||||
|
|
||||||
// aspect ratio cancels out, so only need one factor
|
// aspect ratio cancels out, so only need one factor
|
||||||
// the difference between the screen coordinates of the 2 systems is the ratio
|
// the difference between the screen coordinates of the 2 systems is the ratio
|
||||||
// of the coefficients of the projection matrices (tan (fov/2) is that coefficient)
|
// of the coefficients of the projection matrices (tan (fov/2) is that coefficient)
|
||||||
// NOTE: viewx was coming in as 0 when folks set their viewmodel_fov to 0 and show their weapon.
|
// NOTE: viewx was coming in as 0 when folks set their viewmodel_fov to 0 and show their weapon.
|
||||||
float factorX = viewx ? ( worldx / viewx ) : 0.0f;
|
float factorX = viewx ? (worldx / viewx) : 0.0f;
|
||||||
float factorY = factorX;
|
float factorY = factorX;
|
||||||
|
|
||||||
// Get the coordinates in the viewer's space.
|
// Get the coordinates in the viewer's space.
|
||||||
Vector tmp = vOrigin - pViewSetup->origin;
|
Vector tmp = vOrigin - pViewSetup->origin;
|
||||||
Vector vTransformed( MainViewRight().Dot( tmp ), MainViewUp().Dot( tmp ), MainViewForward().Dot( tmp ) );
|
Vector vTransformed(MainViewRight().Dot(tmp), MainViewUp().Dot(tmp), MainViewForward().Dot(tmp));
|
||||||
|
|
||||||
// Now squash X and Y.
|
// Now squash X and Y.
|
||||||
if ( bInverse )
|
if (bInverse)
|
||||||
{
|
{
|
||||||
if ( factorX != 0 && factorY != 0 )
|
if (factorX != 0 && factorY != 0)
|
||||||
{
|
{
|
||||||
vTransformed.x /= factorX;
|
vTransformed.x /= factorX;
|
||||||
vTransformed.y /= factorY;
|
vTransformed.y /= factorY;
|
||||||
@ -92,12 +92,12 @@ void FormatViewModelAttachment( Vector &vOrigin, bool bInverse )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void C_BaseViewModel::FormatViewModelAttachment( int nAttachment, matrix3x4_t &attachmentToWorld )
|
void C_BaseViewModel::FormatViewModelAttachment(int nAttachment, matrix3x4_t& attachmentToWorld)
|
||||||
{
|
{
|
||||||
Vector vecOrigin;
|
Vector vecOrigin;
|
||||||
MatrixPosition( attachmentToWorld, vecOrigin );
|
MatrixPosition(attachmentToWorld, vecOrigin);
|
||||||
::FormatViewModelAttachment( vecOrigin, false );
|
::FormatViewModelAttachment(vecOrigin, false);
|
||||||
PositionMatrix( vecOrigin, attachmentToWorld );
|
PositionMatrix(vecOrigin, attachmentToWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,110 +106,110 @@ bool C_BaseViewModel::IsViewModel() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_BaseViewModel::UncorrectViewModelAttachment( Vector &vOrigin )
|
void C_BaseViewModel::UncorrectViewModelAttachment(Vector& vOrigin)
|
||||||
{
|
{
|
||||||
// Unformat the attachment.
|
// Unformat the attachment.
|
||||||
::FormatViewModelAttachment( vOrigin, true );
|
::FormatViewModelAttachment(vOrigin, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose
|
// Purpose
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
|
void C_BaseViewModel::FireEvent(const Vector& origin, const QAngle& angles, int event, const char* options)
|
||||||
{
|
{
|
||||||
// We override sound requests so that we can play them locally on the owning player
|
// We override sound requests so that we can play them locally on the owning player
|
||||||
if ( ( event == AE_CL_PLAYSOUND ) || ( event == CL_EVENT_SOUND ) )
|
if ((event == AE_CL_PLAYSOUND) || (event == CL_EVENT_SOUND))
|
||||||
{
|
{
|
||||||
// Only do this if we're owned by someone
|
// Only do this if we're owned by someone
|
||||||
if ( GetOwner() != NULL )
|
if (GetOwner() != NULL)
|
||||||
{
|
{
|
||||||
CLocalPlayerFilter filter;
|
CLocalPlayerFilter filter;
|
||||||
EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
|
EmitSound(filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise pass the event to our associated weapon
|
// Otherwise pass the event to our associated weapon
|
||||||
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
|
C_BaseCombatWeapon* pWeapon = GetActiveWeapon();
|
||||||
if ( pWeapon )
|
if (pWeapon)
|
||||||
{
|
{
|
||||||
// NVNT notify the haptics system of our viewmodel's event
|
// NVNT notify the haptics system of our viewmodel's event
|
||||||
if ( haptics )
|
if (haptics)
|
||||||
haptics->ProcessHapticEvent(4,"Weapons",pWeapon->GetName(),"AnimationEvents",VarArgs("%i",event));
|
haptics->ProcessHapticEvent(4, "Weapons", pWeapon->GetName(), "AnimationEvents", VarArgs("%i", event));
|
||||||
|
|
||||||
bool bResult = pWeapon->OnFireEvent( this, origin, angles, event, options );
|
bool bResult = pWeapon->OnFireEvent(this, origin, angles, event, options);
|
||||||
if ( !bResult )
|
if (!bResult)
|
||||||
{
|
{
|
||||||
BaseClass::FireEvent( origin, angles, event, options );
|
BaseClass::FireEvent(origin, angles, event, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C_BaseViewModel::Interpolate( float currentTime )
|
bool C_BaseViewModel::Interpolate(float currentTime)
|
||||||
{
|
{
|
||||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
CStudioHdr* pStudioHdr = GetModelPtr();
|
||||||
// Make sure we reset our animation information if we've switch sequences
|
// Make sure we reset our animation information if we've switch sequences
|
||||||
UpdateAnimationParity();
|
UpdateAnimationParity();
|
||||||
|
|
||||||
bool bret = BaseClass::Interpolate( currentTime );
|
bool bret = BaseClass::Interpolate(currentTime);
|
||||||
|
|
||||||
// Hack to extrapolate cycle counter for view model
|
// Hack to extrapolate cycle counter for view model
|
||||||
float elapsed_time = currentTime - m_flAnimTime;
|
float elapsed_time = currentTime - m_flAnimTime;
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
// Predicted viewmodels have fixed up interval
|
// Predicted viewmodels have fixed up interval
|
||||||
if ( GetPredictable() || IsClientCreated() )
|
if (GetPredictable() || IsClientCreated())
|
||||||
{
|
{
|
||||||
Assert( pPlayer );
|
Assert(pPlayer);
|
||||||
float curtime = pPlayer ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime;
|
float curtime = pPlayer ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime;
|
||||||
elapsed_time = curtime - m_flAnimTime;
|
elapsed_time = curtime - m_flAnimTime;
|
||||||
// Adjust for interpolated partial frame
|
// Adjust for interpolated partial frame
|
||||||
if ( !engine->IsPaused() )
|
if (!engine->IsPaused())
|
||||||
{
|
{
|
||||||
elapsed_time += ( gpGlobals->interpolation_amount * TICK_INTERVAL );
|
elapsed_time += (gpGlobals->interpolation_amount * TICK_INTERVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prediction errors?
|
// Prediction errors?
|
||||||
if ( elapsed_time < 0 )
|
if (elapsed_time < 0)
|
||||||
{
|
{
|
||||||
elapsed_time = 0;
|
elapsed_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dt = elapsed_time * GetSequenceCycleRate( pStudioHdr, GetSequence() ) * GetPlaybackRate();
|
float dt = elapsed_time * GetSequenceCycleRate(pStudioHdr, GetSequence()) * GetPlaybackRate();
|
||||||
if ( dt >= 1.0f )
|
if (dt >= 1.0f)
|
||||||
{
|
{
|
||||||
if ( !IsSequenceLooping( GetSequence() ) )
|
if (!IsSequenceLooping(GetSequence()))
|
||||||
{
|
{
|
||||||
dt = 0.999f;
|
dt = 0.999f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dt = fmod( dt, 1.0f );
|
dt = fmod(dt, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCycle( dt );
|
SetCycle(dt);
|
||||||
return bret;
|
return bret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool C_BaseViewModel::ShouldFlipViewModel()
|
bool C_BaseViewModel::ShouldFlipViewModel()
|
||||||
{
|
{
|
||||||
#ifdef CSTRIKE_DLL
|
//#ifdef CSTRIKE_DLL
|
||||||
// If cl_righthand is set, then we want them all right-handed.
|
// If cl_righthand is set, then we want them all right-handed.
|
||||||
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
|
CBaseCombatWeapon* pWeapon = m_hWeapon.Get();
|
||||||
if ( pWeapon )
|
if (pWeapon)
|
||||||
{
|
{
|
||||||
const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
|
const FileWeaponInfo_t* pInfo = &pWeapon->GetWpnData();
|
||||||
return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
|
return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
|
CBaseCombatWeapon* pWeapon = m_hWeapon.Get();
|
||||||
if ( pWeapon )
|
if (pWeapon)
|
||||||
{
|
{
|
||||||
return pWeapon->m_bFlipViewModel != cl_flipviewmodels.GetBool();
|
return pWeapon->m_bFlipViewModel != cl_flipviewmodels.GetBool();
|
||||||
}
|
}
|
||||||
@ -219,24 +219,24 @@ bool C_BaseViewModel::ShouldFlipViewModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void C_BaseViewModel::ApplyBoneMatrixTransform( matrix3x4_t& transform )
|
void C_BaseViewModel::ApplyBoneMatrixTransform(matrix3x4_t& transform)
|
||||||
{
|
{
|
||||||
if ( ShouldFlipViewModel() )
|
if (ShouldFlipViewModel())
|
||||||
{
|
{
|
||||||
matrix3x4_t viewMatrix, viewMatrixInverse;
|
matrix3x4_t viewMatrix, viewMatrixInverse;
|
||||||
|
|
||||||
// We could get MATERIAL_VIEW here, but this is called sometimes before the renderer
|
// We could get MATERIAL_VIEW here, but this is called sometimes before the renderer
|
||||||
// has set that matrix. Luckily, this is called AFTER the CViewSetup has been initialized.
|
// has set that matrix. Luckily, this is called AFTER the CViewSetup has been initialized.
|
||||||
const CViewSetup *pSetup = view->GetPlayerViewSetup();
|
const CViewSetup* pSetup = view->GetPlayerViewSetup();
|
||||||
AngleMatrix( pSetup->angles, pSetup->origin, viewMatrixInverse );
|
AngleMatrix(pSetup->angles, pSetup->origin, viewMatrixInverse);
|
||||||
MatrixInvert( viewMatrixInverse, viewMatrix );
|
MatrixInvert(viewMatrixInverse, viewMatrix);
|
||||||
|
|
||||||
// Transform into view space.
|
// Transform into view space.
|
||||||
matrix3x4_t temp, temp2;
|
matrix3x4_t temp, temp2;
|
||||||
ConcatTransforms( viewMatrix, transform, temp );
|
ConcatTransforms(viewMatrix, transform, temp);
|
||||||
|
|
||||||
// Flip it along X.
|
// Flip it along X.
|
||||||
|
|
||||||
// (This is the slower way to do it, and it equates to negating the top row).
|
// (This is the slower way to do it, and it equates to negating the top row).
|
||||||
//matrix3x4_t mScale;
|
//matrix3x4_t mScale;
|
||||||
//SetIdentityMatrix( mScale );
|
//SetIdentityMatrix( mScale );
|
||||||
@ -250,7 +250,7 @@ void C_BaseViewModel::ApplyBoneMatrixTransform( matrix3x4_t& transform )
|
|||||||
temp[1][3] = -temp[1][3];
|
temp[1][3] = -temp[1][3];
|
||||||
|
|
||||||
// Transform back out of view space.
|
// Transform back out of view space.
|
||||||
ConcatTransforms( viewMatrixInverse, temp, transform );
|
ConcatTransforms(viewMatrixInverse, temp, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,16 +259,16 @@ void C_BaseViewModel::ApplyBoneMatrixTransform( matrix3x4_t& transform )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool C_BaseViewModel::ShouldDraw()
|
bool C_BaseViewModel::ShouldDraw()
|
||||||
{
|
{
|
||||||
if ( engine->IsHLTV() )
|
if (engine->IsHLTV())
|
||||||
{
|
{
|
||||||
return ( HLTVCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
return (HLTVCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
||||||
HLTVCamera()->GetPrimaryTarget() == GetOwner() );
|
HLTVCamera()->GetPrimaryTarget() == GetOwner());
|
||||||
}
|
}
|
||||||
#if defined( REPLAY_ENABLED )
|
#if defined( REPLAY_ENABLED )
|
||||||
else if ( g_pEngineClientReplay->IsPlayingReplayDemo() )
|
else if (g_pEngineClientReplay->IsPlayingReplayDemo())
|
||||||
{
|
{
|
||||||
return ( ReplayCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
return (ReplayCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
||||||
ReplayCamera()->GetPrimaryTarget() == GetOwner() );
|
ReplayCamera()->GetPrimaryTarget() == GetOwner());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
@ -281,66 +281,66 @@ bool C_BaseViewModel::ShouldDraw()
|
|||||||
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
|
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
|
||||||
// by this player, otherwise draw the worldmodel.
|
// by this player, otherwise draw the worldmodel.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int C_BaseViewModel::DrawModel( int flags )
|
int C_BaseViewModel::DrawModel(int flags)
|
||||||
{
|
{
|
||||||
if ( !m_bReadyToDraw )
|
if (!m_bReadyToDraw)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( flags & STUDIO_RENDER )
|
if (flags & STUDIO_RENDER)
|
||||||
{
|
{
|
||||||
// Determine blending amount and tell engine
|
// Determine blending amount and tell engine
|
||||||
float blend = (float)( GetFxBlend() / 255.0f );
|
float blend = (float)(GetFxBlend() / 255.0f);
|
||||||
|
|
||||||
// Totally gone
|
// Totally gone
|
||||||
if ( blend <= 0.0f )
|
if (blend <= 0.0f)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Tell engine
|
// Tell engine
|
||||||
render->SetBlend( blend );
|
render->SetBlend(blend);
|
||||||
|
|
||||||
float color[3];
|
float color[3];
|
||||||
GetColorModulation( color );
|
GetColorModulation(color);
|
||||||
render->SetColorModulation( color );
|
render->SetColorModulation(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
C_BaseCombatWeapon* pWeapon = GetOwningWeapon();
|
||||||
int ret;
|
int ret;
|
||||||
// If the local player's overriding the viewmodel rendering, let him do it
|
// If the local player's overriding the viewmodel rendering, let him do it
|
||||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
if (pPlayer && pPlayer->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
ret = pPlayer->DrawOverriddenViewmodel( this, flags );
|
ret = pPlayer->DrawOverriddenViewmodel(this, flags);
|
||||||
}
|
}
|
||||||
else if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
else if (pWeapon && pWeapon->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
ret = pWeapon->DrawOverriddenViewmodel( this, flags );
|
ret = pWeapon->DrawOverriddenViewmodel(this, flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = BaseClass::DrawModel( flags );
|
ret = BaseClass::DrawModel(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we've rendered, reset the animation restart flag
|
// Now that we've rendered, reset the animation restart flag
|
||||||
if ( flags & STUDIO_RENDER )
|
if (flags & STUDIO_RENDER)
|
||||||
{
|
{
|
||||||
if ( m_nOldAnimationParity != m_nAnimationParity )
|
if (m_nOldAnimationParity != m_nAnimationParity)
|
||||||
{
|
{
|
||||||
m_nOldAnimationParity = m_nAnimationParity;
|
m_nOldAnimationParity = m_nAnimationParity;
|
||||||
}
|
}
|
||||||
// Tell the weapon itself that we've rendered, in case it wants to do something
|
// Tell the weapon itself that we've rendered, in case it wants to do something
|
||||||
if ( pWeapon )
|
if (pWeapon)
|
||||||
{
|
{
|
||||||
pWeapon->ViewModelDrawn( this );
|
pWeapon->ViewModelDrawn(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
CTFWeaponBase* pTFWeapon = dynamic_cast<CTFWeaponBase*>( pWeapon );
|
CTFWeaponBase* pTFWeapon = dynamic_cast<CTFWeaponBase*>(pWeapon);
|
||||||
if ( ( flags & STUDIO_RENDER ) && pTFWeapon && pTFWeapon->m_viewmodelStatTrakAddon )
|
if ((flags & STUDIO_RENDER) && pTFWeapon && pTFWeapon->m_viewmodelStatTrakAddon)
|
||||||
{
|
{
|
||||||
pTFWeapon->m_viewmodelStatTrakAddon->RemoveEffects( EF_NODRAW );
|
pTFWeapon->m_viewmodelStatTrakAddon->RemoveEffects(EF_NODRAW);
|
||||||
pTFWeapon->m_viewmodelStatTrakAddon->DrawModel( flags );
|
pTFWeapon->m_viewmodelStatTrakAddon->DrawModel(flags);
|
||||||
pTFWeapon->m_viewmodelStatTrakAddon->AddEffects( EF_NODRAW );
|
pTFWeapon->m_viewmodelStatTrakAddon->AddEffects(EF_NODRAW);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -350,15 +350,15 @@ int C_BaseViewModel::DrawModel( int flags )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int C_BaseViewModel::InternalDrawModel( int flags )
|
int C_BaseViewModel::InternalDrawModel(int flags)
|
||||||
{
|
{
|
||||||
CMatRenderContextPtr pRenderContext( materials );
|
CMatRenderContextPtr pRenderContext(materials);
|
||||||
if ( ShouldFlipViewModel() )
|
if (ShouldFlipViewModel())
|
||||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
|
pRenderContext->CullMode(MATERIAL_CULLMODE_CW);
|
||||||
|
|
||||||
int ret = BaseClass::InternalDrawModel( flags );
|
int ret = BaseClass::InternalDrawModel(flags);
|
||||||
|
|
||||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CCW );
|
pRenderContext->CullMode(MATERIAL_CULLMODE_CCW);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -366,27 +366,27 @@ int C_BaseViewModel::InternalDrawModel( int flags )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Called by the player when the player's overriding the viewmodel drawing. Avoids infinite recursion.
|
// Purpose: Called by the player when the player's overriding the viewmodel drawing. Avoids infinite recursion.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int C_BaseViewModel::DrawOverriddenViewmodel( int flags )
|
int C_BaseViewModel::DrawOverriddenViewmodel(int flags)
|
||||||
{
|
{
|
||||||
return BaseClass::DrawModel( flags );
|
return BaseClass::DrawModel(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Output : int
|
// Output : int
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int C_BaseViewModel::GetFxBlend( void )
|
int C_BaseViewModel::GetFxBlend(void)
|
||||||
{
|
{
|
||||||
// See if the local player wants to override the viewmodel's rendering
|
// See if the local player wants to override the viewmodel's rendering
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
if (pPlayer && pPlayer->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
pPlayer->ComputeFxBlend();
|
pPlayer->ComputeFxBlend();
|
||||||
return pPlayer->GetFxBlend();
|
return pPlayer->GetFxBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
C_BaseCombatWeapon* pWeapon = GetOwningWeapon();
|
||||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
if (pWeapon && pWeapon->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
pWeapon->ComputeFxBlend();
|
pWeapon->ComputeFxBlend();
|
||||||
return pWeapon->GetFxBlend();
|
return pWeapon->GetFxBlend();
|
||||||
@ -399,17 +399,17 @@ int C_BaseViewModel::GetFxBlend( void )
|
|||||||
// Purpose:
|
// Purpose:
|
||||||
// Output : Returns true on success, false on failure.
|
// Output : Returns true on success, false on failure.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool C_BaseViewModel::IsTransparent( void )
|
bool C_BaseViewModel::IsTransparent(void)
|
||||||
{
|
{
|
||||||
// See if the local player wants to override the viewmodel's rendering
|
// See if the local player wants to override the viewmodel's rendering
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
if (pPlayer && pPlayer->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
return pPlayer->ViewModel_IsTransparent();
|
return pPlayer->ViewModel_IsTransparent();
|
||||||
}
|
}
|
||||||
|
|
||||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
C_BaseCombatWeapon* pWeapon = GetOwningWeapon();
|
||||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
if (pWeapon && pWeapon->IsOverridingViewmodel())
|
||||||
return pWeapon->ViewModel_IsTransparent();
|
return pWeapon->ViewModel_IsTransparent();
|
||||||
|
|
||||||
return BaseClass::IsTransparent();
|
return BaseClass::IsTransparent();
|
||||||
@ -418,17 +418,17 @@ bool C_BaseViewModel::IsTransparent( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool C_BaseViewModel::UsesPowerOfTwoFrameBufferTexture( void )
|
bool C_BaseViewModel::UsesPowerOfTwoFrameBufferTexture(void)
|
||||||
{
|
{
|
||||||
// See if the local player wants to override the viewmodel's rendering
|
// See if the local player wants to override the viewmodel's rendering
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
if (pPlayer && pPlayer->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
return pPlayer->ViewModel_IsUsingFBTexture();
|
return pPlayer->ViewModel_IsUsingFBTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
C_BaseCombatWeapon* pWeapon = GetOwningWeapon();
|
||||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
if (pWeapon && pWeapon->IsOverridingViewmodel())
|
||||||
{
|
{
|
||||||
return pWeapon->ViewModel_IsUsingFBTexture();
|
return pWeapon->ViewModel_IsUsingFBTexture();
|
||||||
}
|
}
|
||||||
@ -439,20 +439,20 @@ bool C_BaseViewModel::UsesPowerOfTwoFrameBufferTexture( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: If the animation parity of the weapon has changed, we reset cycle to avoid popping
|
// Purpose: If the animation parity of the weapon has changed, we reset cycle to avoid popping
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseViewModel::UpdateAnimationParity( void )
|
void C_BaseViewModel::UpdateAnimationParity(void)
|
||||||
{
|
{
|
||||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
// If we're predicting, then we don't use animation parity because we change the animations on the clientside
|
// If we're predicting, then we don't use animation parity because we change the animations on the clientside
|
||||||
// while predicting. When not predicting, only the server changes the animations, so a parity mismatch
|
// while predicting. When not predicting, only the server changes the animations, so a parity mismatch
|
||||||
// tells us if we need to reset the animation.
|
// tells us if we need to reset the animation.
|
||||||
if ( m_nOldAnimationParity != m_nAnimationParity && !GetPredictable() )
|
if (m_nOldAnimationParity != m_nAnimationParity && !GetPredictable())
|
||||||
{
|
{
|
||||||
float curtime = (pPlayer && IsIntermediateDataAllocated()) ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime;
|
float curtime = (pPlayer && IsIntermediateDataAllocated()) ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime;
|
||||||
// FIXME: this is bad
|
// FIXME: this is bad
|
||||||
// Simulate a networked m_flAnimTime and m_flCycle
|
// Simulate a networked m_flAnimTime and m_flCycle
|
||||||
// FIXME: Do we need the magic 0.1?
|
// FIXME: Do we need the magic 0.1?
|
||||||
SetCycle( 0.0f ); // GetSequenceCycleRate( GetSequence() ) * 0.1;
|
SetCycle(0.0f); // GetSequenceCycleRate( GetSequence() ) * 0.1;
|
||||||
m_flAnimTime = curtime;
|
m_flAnimTime = curtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,26 +461,26 @@ void C_BaseViewModel::UpdateAnimationParity( void )
|
|||||||
// Purpose: Update global map state based on data received
|
// Purpose: Update global map state based on data received
|
||||||
// Input : bnewentity -
|
// Input : bnewentity -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseViewModel::OnDataChanged( DataUpdateType_t updateType )
|
void C_BaseViewModel::OnDataChanged(DataUpdateType_t updateType)
|
||||||
{
|
{
|
||||||
SetPredictionEligible( true );
|
SetPredictionEligible(true);
|
||||||
BaseClass::OnDataChanged(updateType);
|
BaseClass::OnDataChanged(updateType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_BaseViewModel::PostDataUpdate( DataUpdateType_t updateType )
|
void C_BaseViewModel::PostDataUpdate(DataUpdateType_t updateType)
|
||||||
{
|
{
|
||||||
BaseClass::PostDataUpdate(updateType);
|
BaseClass::PostDataUpdate(updateType);
|
||||||
OnLatchInterpolatedVariables( LATCH_ANIMATION_VAR );
|
OnLatchInterpolatedVariables(LATCH_ANIMATION_VAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Add entity to visible view models list
|
// Purpose: Add entity to visible view models list
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseViewModel::AddEntity( void )
|
void C_BaseViewModel::AddEntity(void)
|
||||||
{
|
{
|
||||||
// Server says don't interpolate this frame, so set previous info to new info.
|
// Server says don't interpolate this frame, so set previous info to new info.
|
||||||
if ( IsNoInterpolationFrame() )
|
if (IsNoInterpolationFrame())
|
||||||
{
|
{
|
||||||
ResetLatched();
|
ResetLatched();
|
||||||
}
|
}
|
||||||
@ -491,13 +491,13 @@ void C_BaseViewModel::AddEntity( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS])
|
void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS])
|
||||||
{
|
{
|
||||||
BaseClass::GetBoneControllers( controllers );
|
BaseClass::GetBoneControllers(controllers);
|
||||||
|
|
||||||
// Tell the weapon itself that we've rendered, in case it wants to do something
|
// Tell the weapon itself that we've rendered, in case it wants to do something
|
||||||
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
|
C_BaseCombatWeapon* pWeapon = GetActiveWeapon();
|
||||||
if ( pWeapon )
|
if (pWeapon)
|
||||||
{
|
{
|
||||||
pWeapon->GetViewmodelBoneControllers( this, controllers );
|
pWeapon->GetViewmodelBoneControllers(this, controllers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user