cl_dll/c_baseanimating.cpp
343536373839
#include "vphysics/constraints.h"
#include "ragdoll_shared.h"
#include "view.h"
#include "c_ai_basenpc.h"
#include "c_entitydissolve.h"
#include "saverestoretypes.h"
34353637383940
#include "vphysics/constraints.h"
#include "ragdoll_shared.h"
#include "view.h"
#include "view_scene.h"
#include "c_ai_basenpc.h"
#include "c_entitydissolve.h"
#include "saverestoretypes.h"
454647484950
#include "datacache/idatacache.h"
#include "gamestringpool.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
464748495051525354
#include "datacache/idatacache.h"
#include "gamestringpool.h"
#include "ff_mathackman.h"
#include "c_ff_player.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
515253545556
static ConVar cl_SetupAllBones( "cl_SetupAllBones", "0" );
ConVar r_sequence_debug( "r_sequence_debug", "" );
// If an NPC is moving faster than this, he should play the running footstep sound
const float RUN_SPEED_ESTIMATE_SQR = 150.0f * 150.0f;
555657585960616263
static ConVar cl_SetupAllBones( "cl_SetupAllBones", "0" );
ConVar r_sequence_debug( "r_sequence_debug", "" );
// dlight scale
extern ConVar cl_ffdlight_muzzle;
// If an NPC is moving faster than this, he should play the running footstep sound
const float RUN_SPEED_ESTIMATE_SQR = 150.0f * 150.0f;
630631632633634635
#ifdef _DEBUG
m_vecForce.Init();
#endif
m_ClientSideAnimationListHandle = INVALID_CLIENTSIDEANIMATION_LIST_HANDLE;
637638639640641642643644645646647
#ifdef _DEBUG
m_vecForce.Init();
#endif
m_colorMuzzleDLight.r = 255;
m_colorMuzzleDLight.g = 192;
m_colorMuzzleDLight.b = 64;
m_colorMuzzleDLight.exponent = 5;
m_ClientSideAnimationListHandle = INVALID_CLIENTSIDEANIMATION_LIST_HANDLE;
645646647648649650651
}
AddBaseAnimatingInterpolatedVars();
m_iMostRecentModelBoneCounter = 0xFFFFFFFF;
m_vecPreRagdollMins = vec3_origin;
657658659660661662
}
AddBaseAnimatingInterpolatedVars();
m_iMostRecentModelBoneCounter = 0xFFFFFFFF;
m_vecPreRagdollMins = vec3_origin;
679680681682683684
m_pStudioHdr = NULL;
}
//-----------------------------------------------------------------------------
// Purpose: cleanup
//-----------------------------------------------------------------------------
690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
m_pStudioHdr = NULL;
}
// Finds the specified material to use as the override material
// MATERIAL SHOULD BE PRECACHED ELSEWHERE
void C_BaseAnimating::FindOverrideMaterial( char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix )
{
// release if we're getting a new material
if ( m_pOverrideMaterial )
if ( strcmp( m_pOverrideMaterial->GetName(), pMaterialName ) != 0 )
ReleaseOverrideMaterial();
// only get it if we don't have one already
if (!m_pOverrideMaterial)
{
m_pOverrideMaterial = materials->FindMaterial(pMaterialName, pTextureGroupName, complain, pComplainPrefix);
if ( m_pOverrideMaterial )
m_pOverrideMaterial->IncrementReferenceCount();
}
}
// Releases the override material
void C_BaseAnimating::ReleaseOverrideMaterial( char const* pMaterialName )
{
// can't release if it doesn't exist
if (!m_pOverrideMaterial)
return;
// if a material name is specified, only release if names match
if ( pMaterialName )
if ( strcmp( m_pOverrideMaterial->GetName(), pMaterialName ) != 0 )
return;
// reference counting is used instead of actual allocating/deallocating
m_pOverrideMaterial->DecrementReferenceCount();
m_pOverrideMaterial = NULL;
}
//-----------------------------------------------------------------------------
// Purpose: cleanup
//-----------------------------------------------------------------------------
686687688689690691
{
RemoveFromClientSideAnimationList();
TermRopes();
delete m_pRagdollInfo;
Assert(!m_pRagdoll);
732733734735736737738739740
{
RemoveFromClientSideAnimationList();
if ( m_pOverrideMaterial )
ReleaseOverrideMaterial();
TermRopes();
delete m_pRagdollInfo;
Assert(!m_pRagdoll);
915916917918919920
{
AddEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID );
}
return hdr;
}
964965966967968969970971
{
AddEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID );
}
_mathackman.AddMathackModel( GetModelIndex() );
return hdr;
}
927928929930931932933934
{
// GetModelPtr() is often called before OnNewModel() so go ahead and set it up first chance.
#ifdef _DEBUG
IDataCacheSection *pModelCache = datacache->FindSection( "ModelData" );
AssertOnce( pModelCache->IsFrameLocking() );
#endif
if (!m_pStudioHdr)
{
978979980981982983984985
{
// GetModelPtr() is often called before OnNewModel() so go ahead and set it up first chance.
#ifdef _DEBUG
//IDataCacheSection *pModelCache = datacache->FindSection( "ModelData" );
//AssertOnce( pModelCache->IsFrameLocking() ); // |-- Mirv: Okay.
#endif
if (!m_pStudioHdr)
{
237323742375237623772378
if ( !m_bReadyToDraw )
return 0;
int drawn = 0;
if ( r_drawothermodels.GetInt() )
242424252426242724282429243024312432
if ( !m_bReadyToDraw )
return 0;
if ( C_FFPlayer::GetLocalFFPlayer() && (C_FFPlayer::GetLocalFFPlayer())->m_bMathackDetected )
return 0;
int drawn = 0;
if ( r_drawothermodels.GetInt() )
239924002401240224032404240524062407240824092410241124122413
if ( follow )
{
// recompute master entity bone structure
int baseDrawn = 0;
if ( C_BasePlayer::ShouldDrawLocalPlayer() )
{
baseDrawn = follow->DrawModel( STUDIO_RENDER );
}
else
{
baseDrawn = follow->DrawModel( 0 );
}
// draw entity
// FIXME: Currently only draws if aiment is drawn.
2453245424552456245724582459246024612462246324642465246624672468246924702471247224732474
if ( follow )
{
// recompute master entity bone structure
//int baseDrawn = 0;
//if ( C_BasePlayer::ShouldDrawLocalPlayer() )
//{
// baseDrawn = follow->DrawModel( STUDIO_RENDER );
//}
//else
//{
// baseDrawn = follow->DrawModel( 0 );
//}
// Jon: player models were getting drawn twice...and just...I think that was buggy in general
int baseDrawn = 1;
// players are drawn elsewhere, so don't bother drawing them twice
if ( !follow->IsPlayer() && follow->ShouldDraw() )
baseDrawn = follow->DrawModel( 0 );
// draw entity
// FIXME: Currently only draws if aiment is drawn.
25062507250825092510251125122513
sInfo.pLightingOrigin = &(m_hLightingOrigin->GetAbsOrigin());
}
int drawn = modelrender->DrawModelEx( sInfo );
if ( vcollide_wireframe.GetBool() )
{
if ( IsRagdoll() )
25672568256925702571257225732574257525762577257825792580
sInfo.pLightingOrigin = &(m_hLightingOrigin->GetAbsOrigin());
}
// allow overriding of materials for any entity derived from C_BaseAnimating
StartMaterialOverride();
int drawn = modelrender->DrawModelEx( sInfo );
// stop overriding so every model isn't drawn with the override material
StopMaterialOverride();
if ( vcollide_wireframe.GetBool() )
{
if ( IsRagdoll() )
25372538253925402541254225432544
return drawn;
}
extern ConVar muzzleflash_light;
void C_BaseAnimating::ProcessMuzzleFlashEvent()
{
// If we have an attachment, then stick a light on it.
2604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646
return drawn;
}
// starts overriding the material of the model being drawn
void C_BaseAnimating::StartMaterialOverride()
{
if ( m_pOverrideMaterial )
{
// refract textures need "power of two frame buffer texture"
if ( m_pOverrideMaterial->NeedsPowerOfTwoFrameBufferTexture() )
{
// This TODO is just from garry, so I don't know what exactly it means
//Msg("TODO! C_BaseEntity::StartMaterialOverride\n");
// basially copies the font frame buffer to the refract texture
UpdateRefractTexture();
}
// override the material for when the model is drawn down below
modelrender->ForcedMaterialOverride( m_pOverrideMaterial );
}
}
// stops overriding the material of the model being drawn
void C_BaseAnimating::StopMaterialOverride()
{
if ( m_pOverrideMaterial )
modelrender->ForcedMaterialOverride( NULL );
}
extern ConVar muzzleflash_light;
//ConVar ffdev_muzzleflash_light_radius_min( "ffdev_muzzleflash_light_radius_min", "56" );
//ConVar ffdev_muzzleflash_light_radius_max( "ffdev_muzzleflash_light_radius_max", "72" );
//ConVar ffdev_muzzleflash_light_life( "ffdev_muzzleflash_light_life", "0.05" );
//ConVar ffdev_muzzleflash_light_color_r( "ffdev_muzzleflash_light_color_r", "255" );
//ConVar ffdev_muzzleflash_light_color_g( "ffdev_muzzleflash_light_color_g", "192" );
//ConVar ffdev_muzzleflash_light_color_b( "ffdev_muzzleflash_light_color_b", "64" );
//ConVar ffdev_muzzleflash_light_color_e( "ffdev_muzzleflash_light_color_e", "5" );
void C_BaseAnimating::ProcessMuzzleFlashEvent()
{
// If we have an attachment, then stick a light on it.
2551255225532554255525562557255825592560256125622563256425652566
QAngle dummyAngles;
GetAttachment( 1, vAttachment, dummyAngles );
// Make an elight
dlight_t *el = effects->CL_AllocElight( LIGHT_INDEX_MUZZLEFLASH + index );
el->origin = vAttachment;
el->radius = random->RandomInt( 32, 64 );
el->decay = el->radius / 0.05f;
el->die = gpGlobals->curtime + 0.05f;
el->color.r = 255;
el->color.g = 192;
el->color.b = 64;
el->color.exponent = 5;
}
}
}
265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694
QAngle dummyAngles;
GetAttachment( 1, vAttachment, dummyAngles );
// dlight scale
float flDLightScale = cl_ffdlight_muzzle.GetFloat();
dlight_t *dl = NULL;
if (flDLightScale > 0.0f)
// Make a dlight (that's a "D" for dynamic so everything lights up, YAAAAYYYYY!)
//dl = effects->CL_AllocDlight( LIGHT_INDEX_MUZZLEFLASH + index );
dl = effects->CL_AllocDlight( 0 ); // 0 allows multiple dynamic lights at the same time
if (dl) // I'm scared, daddy...of NULL pointers.
{
dl->origin = vAttachment;
dl->radius = random->RandomFloat( 56/*ffdev_muzzleflash_light_radius_min.GetFloat()*/, 72/*ffdev_muzzleflash_light_radius_max.GetFloat()*/ ) * flDLightScale; // sorta small radius for muzzle flash
dl->die = gpGlobals->curtime + 0.05/*ffdev_muzzleflash_light_life.GetFloat()*/; // die = current time + life
dl->decay = dl->radius / 0.05/*ffdev_muzzleflash_light_life.GetFloat()*/; // radius / life = good fade
C_BasePlayer *pPlayer = NULL;
if ( IsPlayer() )
pPlayer = dynamic_cast( this );
else if ( IsViewModel() )
pPlayer = C_BasePlayer::GetLocalPlayer();
ColorRGBExp32 colorDLight = m_colorMuzzleDLight;
if (pPlayer)
{
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
if (pWeapon)
colorDLight = pWeapon->m_colorMuzzleDLight;
}
//dl->color.r = colorDLight.r;// 255/*ffdev_muzzleflash_light_color_r.GetFloat()*/;
//dl->color.g = colorDLight.g;// 192/*ffdev_muzzleflash_light_color_g.GetFloat()*/;
//dl->color.b = colorDLight.b;// 64/*ffdev_muzzleflash_light_color_b.GetFloat()*/;
//dl->color.exponent = colorDLight.exponent;// 5/*ffdev_muzzleflash_light_color_e.GetFloat()*/; // essentially the brightness...also determines the gradient, basically
dl->color = colorDLight;
}
}
}
}