Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
91a76f2a13 | ||
|
2011179696 | ||
|
3626803e24 | ||
|
8322130890 | ||
|
7d3c0d8b5a |
@ -41,11 +41,11 @@ static ConVar net_showevents( "net_showevents", "0", FCVAR_CHEAT, "Dump game eve
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CGameEventManager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2, s_GameEventManager );
|
||||
|
||||
CGameEvent::CGameEvent( CGameEventDescriptor *descriptor )
|
||||
CGameEvent::CGameEvent( CGameEventDescriptor *descriptor, const char *name )
|
||||
{
|
||||
Assert( descriptor );
|
||||
m_pDescriptor = descriptor;
|
||||
m_pDataKeys = new KeyValues( descriptor->name );
|
||||
m_pDataKeys = new KeyValues( name );
|
||||
}
|
||||
|
||||
CGameEvent::~CGameEvent()
|
||||
@ -63,6 +63,11 @@ int CGameEvent::GetInt( const char *keyName, int defaultValue)
|
||||
return m_pDataKeys->GetInt( keyName, defaultValue );
|
||||
}
|
||||
|
||||
uint64 CGameEvent::GetUint64( const char *keyName, uint64 defaultValue)
|
||||
{
|
||||
return m_pDataKeys->GetUint64( keyName, defaultValue );
|
||||
}
|
||||
|
||||
float CGameEvent::GetFloat( const char *keyName, float defaultValue )
|
||||
{
|
||||
return m_pDataKeys->GetFloat( keyName, defaultValue );
|
||||
@ -83,6 +88,11 @@ void CGameEvent::SetInt( const char *keyName, int value )
|
||||
m_pDataKeys->SetInt( keyName, value );
|
||||
}
|
||||
|
||||
void CGameEvent::SetUint64( const char *keyName, uint64 value )
|
||||
{
|
||||
m_pDataKeys->SetUint64( keyName, value );
|
||||
}
|
||||
|
||||
void CGameEvent::SetFloat( const char *keyName, float value )
|
||||
{
|
||||
m_pDataKeys->SetFloat( keyName, value );
|
||||
@ -158,8 +168,8 @@ void CGameEventManager::Reset()
|
||||
m_Listeners.PurgeAndDeleteElements();
|
||||
m_EventFiles.RemoveAll();
|
||||
m_EventFileNames.RemoveAll();
|
||||
m_EventMap.Purge();
|
||||
m_bClientListenersChanged = true;
|
||||
|
||||
Assert( m_GameEvents.Count() == 0 );
|
||||
}
|
||||
|
||||
@ -189,10 +199,12 @@ void CGameEventManager::WriteEventList(SVC_GameEventList *msg)
|
||||
|
||||
Assert( descriptor.eventid >= 0 && descriptor.eventid < MAX_EVENT_NUMBER );
|
||||
|
||||
const char *pName = m_EventMap.GetElementName( descriptor.elementIndex );
|
||||
|
||||
msg->m_DataOut.WriteUBitLong( descriptor.eventid, MAX_EVENT_BITS );
|
||||
msg->m_DataOut.WriteString( descriptor.name );
|
||||
|
||||
KeyValues *key = descriptor.keys->GetFirstSubKey();
|
||||
msg->m_DataOut.WriteString( pName );
|
||||
|
||||
KeyValues *key = descriptor.keys->GetFirstSubKey();
|
||||
|
||||
while ( key )
|
||||
{
|
||||
@ -208,7 +220,6 @@ void CGameEventManager::WriteEventList(SVC_GameEventList *msg)
|
||||
}
|
||||
|
||||
msg->m_DataOut.WriteUBitLong( TYPE_LOCAL, 3 ); // end marker
|
||||
|
||||
msg->m_nNumEvents++;
|
||||
}
|
||||
}
|
||||
@ -296,7 +307,8 @@ void CGameEventManager::WriteListenEventList(CLC_ListenEvents *msg)
|
||||
|
||||
if ( descriptor.eventid == -1 )
|
||||
{
|
||||
DevMsg("Warning! Client listens to event '%s' unknown by server.\n", descriptor.name );
|
||||
const char *pName = m_EventMap.GetElementName(descriptor.elementIndex);
|
||||
DevMsg("Warning! Client listens to event '%s' unknown by server.\n", pName );
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -304,17 +316,17 @@ void CGameEventManager::WriteListenEventList(CLC_ListenEvents *msg)
|
||||
}
|
||||
}
|
||||
|
||||
IGameEvent *CGameEventManager::CreateEvent( CGameEventDescriptor *descriptor )
|
||||
IGameEvent *CGameEventManager::CreateEvent( CGameEventDescriptor *descriptor, const char *name )
|
||||
{
|
||||
return new CGameEvent ( descriptor );
|
||||
return new CGameEvent ( descriptor, name );
|
||||
}
|
||||
|
||||
IGameEvent *CGameEventManager::CreateEvent( const char *name, bool bForce )
|
||||
IGameEvent *CGameEventManager::CreateEvent( const char *name, bool bForce, int *pCookie )
|
||||
{
|
||||
if ( !name || !name[0] )
|
||||
return NULL;
|
||||
|
||||
CGameEventDescriptor *descriptor = GetEventDescriptor( name );
|
||||
CGameEventDescriptor *descriptor = GetEventDescriptor( name, pCookie );
|
||||
|
||||
// check if this event name is known
|
||||
if ( !descriptor )
|
||||
@ -330,7 +342,7 @@ IGameEvent *CGameEventManager::CreateEvent( const char *name, bool bForce )
|
||||
}
|
||||
|
||||
// create & return the new event
|
||||
return new CGameEvent ( descriptor );
|
||||
return new CGameEvent ( descriptor, name );
|
||||
}
|
||||
|
||||
bool CGameEventManager::FireEvent( IGameEvent *event, bool bServerOnly )
|
||||
@ -351,7 +363,8 @@ IGameEvent *CGameEventManager::DuplicateEvent( IGameEvent *event )
|
||||
return NULL;
|
||||
|
||||
// create new instance
|
||||
CGameEvent *newEvent = new CGameEvent ( gameEvent->m_pDescriptor );
|
||||
const char *pName = m_EventMap.GetElementName(gameEvent->m_pDescriptor->elementIndex );
|
||||
CGameEvent *newEvent = new CGameEvent ( gameEvent->m_pDescriptor, pName );
|
||||
|
||||
// free keys
|
||||
newEvent->m_pDataKeys->deleteThis();
|
||||
@ -414,12 +427,16 @@ bool CGameEventManager::FireEventIntern( IGameEvent *event, bool bServerOnly, bo
|
||||
{
|
||||
if ( bClientOnly )
|
||||
{
|
||||
ConMsg( "Game event \"%s\", Tick %i:\n", descriptor->name, cl.GetClientTickCount() );
|
||||
#ifndef DEDICATED
|
||||
const char *pName = m_EventMap.GetElementName(descriptor->elementIndex);
|
||||
ConMsg( "Game event \"%s\", Tick %i:\n", pName, cl.GetClientTickCount() );
|
||||
ConPrintEvent( event );
|
||||
#endif
|
||||
}
|
||||
else if ( net_showevents.GetInt() > 1 )
|
||||
{
|
||||
ConMsg( "Server event \"%s\", Tick %i:\n", descriptor->name, sv.GetTick() );
|
||||
const char *pName = m_EventMap.GetElementName(descriptor->elementIndex);
|
||||
ConMsg( "Server event \"%s\", Tick %i:\n", pName, sv.GetTick() );
|
||||
ConPrintEvent( event );
|
||||
}
|
||||
}
|
||||
@ -491,7 +508,8 @@ bool CGameEventManager::SerializeEvent( IGameEvent *event, bf_write* buf )
|
||||
|
||||
if ( net_showevents.GetInt() > 2 )
|
||||
{
|
||||
DevMsg("Serializing event '%s' (%i):\n", descriptor->name, descriptor->eventid );
|
||||
const char *pName = m_EventMap.GetElementName(descriptor->elementIndex);
|
||||
DevMsg("Serializing event '%s' (%i):\n", pName, descriptor->eventid );
|
||||
}
|
||||
|
||||
while ( key )
|
||||
@ -545,11 +563,12 @@ IGameEvent *CGameEventManager::UnserializeEvent( bf_read *buf)
|
||||
}
|
||||
|
||||
// create new event
|
||||
IGameEvent *event = CreateEvent( descriptor );
|
||||
const char *pName = m_EventMap.GetElementName(descriptor->elementIndex);
|
||||
IGameEvent *event = CreateEvent( descriptor, pName );
|
||||
|
||||
if ( !event )
|
||||
{
|
||||
DevMsg( "CGameEventManager::UnserializeEvent:: failed to create event %s.\n", descriptor->name );
|
||||
DevMsg( "CGameEventManager::UnserializeEvent:: failed to create event %i.\n", descriptor->eventid );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -766,9 +785,7 @@ bool CGameEventManager::RegisterEvent( KeyValues * event)
|
||||
int index = m_GameEvents.AddToTail();
|
||||
descriptor = &m_GameEvents.Element(index);
|
||||
|
||||
AssertMsg2( V_strlen( event->GetName() ) <= MAX_EVENT_NAME_LENGTH, "Event named '%s' exceeds maximum name length %d", event->GetName(), MAX_EVENT_NAME_LENGTH );
|
||||
|
||||
Q_strncpy( descriptor->name, event->GetName(), MAX_EVENT_NAME_LENGTH );
|
||||
descriptor->elementIndex = m_EventMap.Insert( event->GetName(), index );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -859,20 +876,34 @@ void CGameEventManager::FreeEvent( IGameEvent *event )
|
||||
delete event;
|
||||
}
|
||||
|
||||
CGameEventDescriptor *CGameEventManager::GetEventDescriptor(const char * name)
|
||||
CGameEventDescriptor *CGameEventManager::GetEventDescriptor(const char * name, int *pCookie)
|
||||
{
|
||||
const uint32 cookieBit = 0x80000000;
|
||||
const uint32 cookieMask = ~cookieBit;
|
||||
|
||||
if ( !name || !name[0] )
|
||||
return NULL;
|
||||
|
||||
for (int i=0; i < m_GameEvents.Count(); i++ )
|
||||
if ( pCookie && *pCookie )
|
||||
{
|
||||
CGameEventDescriptor *descriptor = &m_GameEvents[i];
|
||||
int gameEventIndex = uint32(*pCookie) & cookieMask;
|
||||
CGameEventDescriptor *pDescriptor = &m_GameEvents[gameEventIndex];
|
||||
if ( !V_stricmp( m_EventMap.GetElementName(pDescriptor->elementIndex), name ) )
|
||||
{
|
||||
return pDescriptor;
|
||||
}
|
||||
}
|
||||
int eventMapIndex = m_EventMap.Find( name );
|
||||
if ( eventMapIndex == m_EventMap.InvalidIndex() )
|
||||
return NULL;
|
||||
|
||||
if ( Q_strcmp( descriptor->name, name ) == 0 )
|
||||
return descriptor;
|
||||
int gameEventIndex = m_EventMap[eventMapIndex];
|
||||
if ( pCookie )
|
||||
{
|
||||
*pCookie = cookieBit | gameEventIndex;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return &m_GameEvents[gameEventIndex];
|
||||
}
|
||||
|
||||
bool CGameEventManager::AddListenerAll( void *listener, int nListenerType )
|
||||
|
@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "utldict.h"
|
||||
#include <igameevents.h>
|
||||
#include <utlvector.h>
|
||||
#include <KeyValues.h>
|
||||
@ -34,16 +35,16 @@ class CGameEventDescriptor
|
||||
public:
|
||||
CGameEventDescriptor()
|
||||
{
|
||||
name[0] = 0;
|
||||
eventid = -1;
|
||||
keys = NULL;
|
||||
local = false;
|
||||
reliable = true;
|
||||
elementIndex = -1;
|
||||
}
|
||||
|
||||
public:
|
||||
char name[MAX_EVENT_NAME_LENGTH]; // name of this event
|
||||
int eventid; // network index number, -1 = not networked
|
||||
int eventid; // network index number, -1 = not networked
|
||||
int elementIndex;
|
||||
KeyValues *keys; // KeyValue describing data types, if NULL only name
|
||||
bool local; // local event, never tell clients about that
|
||||
bool reliable; // send this event as reliable message
|
||||
@ -54,7 +55,7 @@ class CGameEvent : public IGameEvent
|
||||
{
|
||||
public:
|
||||
|
||||
CGameEvent( CGameEventDescriptor *descriptor );
|
||||
CGameEvent( CGameEventDescriptor *descriptor, const char *name );
|
||||
virtual ~CGameEvent();
|
||||
|
||||
const char *GetName() const;
|
||||
@ -64,11 +65,13 @@ public:
|
||||
|
||||
bool GetBool( const char *keyName = NULL, bool defaultValue = false );
|
||||
int GetInt( const char *keyName = NULL, int defaultValue = 0 );
|
||||
uint64 GetUint64( const char *keyName = NULL, uint64 defaultValue = 0 );
|
||||
float GetFloat( const char *keyName = NULL, float defaultValue = 0.0f );
|
||||
const char *GetString( const char *keyName = NULL, const char *defaultValue = "" );
|
||||
|
||||
void SetBool( const char *keyName, bool value );
|
||||
void SetInt( const char *keyName, int value );
|
||||
void SetUint64( const char *keyName, uint64 value );
|
||||
void SetFloat( const char *keyName, float value );
|
||||
void SetString( const char *keyName, const char *value );
|
||||
|
||||
@ -111,8 +114,9 @@ public: // IGameEventManager functions
|
||||
bool AddListener( IGameEventListener2 *listener, const char *name, bool bServerSide );
|
||||
bool FindListener( IGameEventListener2 *listener, const char *name );
|
||||
void RemoveListener( IGameEventListener2 *listener);
|
||||
|
||||
IGameEvent *CreateEvent( const char *name, bool bForce = false );
|
||||
|
||||
IGameEvent *CreateEvent( const char *name, bool bForce = false, int *pCookie = NULL );
|
||||
|
||||
IGameEvent *DuplicateEvent( IGameEvent *event);
|
||||
bool FireEvent( IGameEvent *event, bool bDontBroadcast = false );
|
||||
bool FireEventClientSide( IGameEvent *event );
|
||||
@ -127,7 +131,7 @@ public:
|
||||
void ReloadEventDefinitions(); // called by server on new map
|
||||
bool AddListener( void *listener, CGameEventDescriptor *descriptor, int nListenerType );
|
||||
|
||||
CGameEventDescriptor *GetEventDescriptor( const char *name );
|
||||
CGameEventDescriptor *GetEventDescriptor( const char *name, int *pCookie = NULL );
|
||||
CGameEventDescriptor *GetEventDescriptor( IGameEvent *event );
|
||||
CGameEventDescriptor *GetEventDescriptor( int eventid );
|
||||
|
||||
@ -145,13 +149,14 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
IGameEvent *CreateEvent( CGameEventDescriptor *descriptor );
|
||||
IGameEvent *CreateEvent( CGameEventDescriptor *descriptor, const char *name );
|
||||
bool RegisterEvent( KeyValues * keys );
|
||||
void UnregisterEvent(int index);
|
||||
bool FireEventIntern( IGameEvent *event, bool bServerSide, bool bClientOnly );
|
||||
CGameEventCallback* FindEventListener( void* listener );
|
||||
|
||||
CUtlVector<CGameEventDescriptor> m_GameEvents; // list of all known events
|
||||
CUtlDict<int, int> m_EventMap;
|
||||
CUtlVector<CGameEventCallback*> m_Listeners; // list of all registered listeners
|
||||
CUtlSymbolTable m_EventFiles; // list of all loaded event files
|
||||
CUtlVector<CUtlSymbol> m_EventFileNames;
|
||||
|
@ -66,10 +66,13 @@ CBaseClient::CBaseClient()
|
||||
m_bReportFakeClient = true;
|
||||
m_iTracing = 0;
|
||||
m_bPlayerNameLocked = false;
|
||||
|
||||
m_nDebugID = EVENT_DEBUG_ID_INIT;
|
||||
}
|
||||
|
||||
CBaseClient::~CBaseClient()
|
||||
{
|
||||
m_nDebugID = EVENT_DEBUG_ID_SHUTDOWN;
|
||||
}
|
||||
|
||||
|
||||
@ -670,6 +673,11 @@ void CBaseClient::FireGameEvent( IGameEvent *event )
|
||||
}
|
||||
}
|
||||
|
||||
int CBaseClient::GetEventDebugID( void )
|
||||
{
|
||||
return m_nDebugID;
|
||||
}
|
||||
|
||||
bool CBaseClient::SendServerInfo( void )
|
||||
{
|
||||
COM_TimestampedLog( " CBaseClient::SendServerInfo" );
|
||||
|
@ -144,6 +144,8 @@ public: // IClientMessageHandlers
|
||||
|
||||
public: // IGameEventListener
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
int m_nDebugID;
|
||||
virtual int GetEventDebugID( void );
|
||||
|
||||
public:
|
||||
|
||||
|
@ -539,6 +539,8 @@ public:
|
||||
virtual bool REMOVED_SteamRefreshLogin( const char *password, bool isSecure ) { return false; }
|
||||
virtual bool REMOVED_SteamProcessCall( bool & finished ) { return false; }
|
||||
|
||||
virtual ISPSharedMemory *GetSinglePlayerSharedMemorySpace( const char *handle, int ent_num = MAX_EDICTS );
|
||||
|
||||
virtual void SetGamestatsData( CGamestatsData *pGamestatsData );
|
||||
virtual CGamestatsData *GetGamestatsData();
|
||||
|
||||
@ -1568,6 +1570,13 @@ void CEngineClient::OnStorageDeviceDetached( void )
|
||||
g_pXboxSystem->CloseContainers();
|
||||
}
|
||||
|
||||
|
||||
ISPSharedMemory *CEngineClient::GetSinglePlayerSharedMemorySpace( const char *szName, int ent_num )
|
||||
{
|
||||
// TODO(nillerusr): it this necessary? Implement later if so
|
||||
return NULL; //g_pSinglePlayerSharedMemoryManager->GetSharedMemory( szName, ent_num );
|
||||
}
|
||||
|
||||
void CEngineClient::ResetDemoInterpolation( void )
|
||||
{
|
||||
if( demorecorder->IsRecording() )
|
||||
|
@ -50,47 +50,28 @@ csurface_t *CCollisionBSPData::GetSurfaceAtIndex( unsigned short surfaceIndex )
|
||||
return &map_surfaces[surfaceIndex];
|
||||
}
|
||||
|
||||
#if TEST_TRACE_POOL
|
||||
CTSPool<TraceInfo_t> g_TraceInfoPool;
|
||||
#else
|
||||
class CTraceInfoPool : public CTSList<TraceInfo_t *>
|
||||
{
|
||||
public:
|
||||
CTraceInfoPool() = default;
|
||||
};
|
||||
|
||||
CTraceInfoPool g_TraceInfoPool;
|
||||
#endif
|
||||
static TraceInfo_t g_TraceInfo;
|
||||
|
||||
TraceInfo_t *BeginTrace()
|
||||
{
|
||||
#if TEST_TRACE_POOL
|
||||
TraceInfo_t *pTraceInfo = g_TraceInfoPool.GetObject();
|
||||
#else
|
||||
TraceInfo_t *pTraceInfo;
|
||||
if ( !g_TraceInfoPool.PopItem( &pTraceInfo ) )
|
||||
if ( g_TraceInfo.m_BrushCounters[0].Count() != GetCollisionBSPData()->numbrushes + 1 )
|
||||
{
|
||||
pTraceInfo = new TraceInfo_t;
|
||||
}
|
||||
#endif
|
||||
if ( pTraceInfo->m_BrushCounters[0].Count() != GetCollisionBSPData()->numbrushes + 1 )
|
||||
{
|
||||
memset( pTraceInfo->m_Count, 0, sizeof( pTraceInfo->m_Count ) );
|
||||
pTraceInfo->m_nCheckDepth = -1;
|
||||
memset( g_TraceInfo.m_Count, 0, sizeof( g_TraceInfo.m_Count ) );
|
||||
g_TraceInfo.m_nCheckDepth = -1;
|
||||
|
||||
for ( int i = 0; i < MAX_CHECK_COUNT_DEPTH; i++ )
|
||||
{
|
||||
pTraceInfo->m_BrushCounters[i].SetCount( GetCollisionBSPData()->numbrushes + 1 );
|
||||
pTraceInfo->m_DispCounters[i].SetCount( g_DispCollTreeCount );
|
||||
g_TraceInfo.m_BrushCounters[i].SetCount( GetCollisionBSPData()->numbrushes + 1 );
|
||||
g_TraceInfo.m_DispCounters[i].SetCount( g_DispCollTreeCount );
|
||||
|
||||
memset( pTraceInfo->m_BrushCounters[i].Base(), 0, pTraceInfo->m_BrushCounters[i].Count() * sizeof(TraceCounter_t) );
|
||||
memset( pTraceInfo->m_DispCounters[i].Base(), 0, pTraceInfo->m_DispCounters[i].Count() * sizeof(TraceCounter_t) );
|
||||
memset( g_TraceInfo.m_BrushCounters[i].Base(), 0, g_TraceInfo.m_BrushCounters[i].Count() * sizeof(TraceCounter_t) );
|
||||
memset( g_TraceInfo.m_DispCounters[i].Base(), 0, g_TraceInfo.m_DispCounters[i].Count() * sizeof(TraceCounter_t) );
|
||||
}
|
||||
}
|
||||
|
||||
PushTraceVisits( pTraceInfo );
|
||||
PushTraceVisits( &g_TraceInfo );
|
||||
|
||||
return pTraceInfo;
|
||||
return &g_TraceInfo;
|
||||
}
|
||||
|
||||
void PushTraceVisits( TraceInfo_t *pTraceInfo )
|
||||
@ -114,16 +95,9 @@ void PopTraceVisits( TraceInfo_t *pTraceInfo )
|
||||
Assert( pTraceInfo->m_nCheckDepth >= -1 );
|
||||
}
|
||||
|
||||
void EndTrace( TraceInfo_t *&pTraceInfo )
|
||||
void EndTrace( TraceInfo_t *pTraceInfo )
|
||||
{
|
||||
PopTraceVisits( pTraceInfo );
|
||||
Assert( pTraceInfo->m_nCheckDepth == -1 );
|
||||
#if TEST_TRACE_POOL
|
||||
g_TraceInfoPool.PutObject( pTraceInfo );
|
||||
#else
|
||||
g_TraceInfoPool.PushItem( pTraceInfo );
|
||||
#endif
|
||||
pTraceInfo = NULL;
|
||||
}
|
||||
|
||||
static ConVar map_noareas( "map_noareas", "0", 0, "Disable area to area connection testing." );
|
||||
|
@ -158,7 +158,7 @@ struct cnode_t
|
||||
TraceInfo_t *BeginTrace();
|
||||
void PushTraceVisits( TraceInfo_t *pTraceInfo );
|
||||
void PopTraceVisits( TraceInfo_t *pTraceInfo );
|
||||
void EndTrace( TraceInfo_t *&pTraceInfo );
|
||||
void EndTrace( TraceInfo_t *pTraceInfo );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -475,6 +475,8 @@ CHLTVServer::CHLTVServer()
|
||||
m_nGlobalSlots = 0;
|
||||
m_nGlobalClients = 0;
|
||||
m_nGlobalProxies = 0;
|
||||
|
||||
m_nDebugID = EVENT_DEBUG_ID_INIT;
|
||||
}
|
||||
|
||||
CHLTVServer::~CHLTVServer()
|
||||
@ -488,6 +490,8 @@ CHLTVServer::~CHLTVServer()
|
||||
// make sure everything was destroyed
|
||||
Assert( m_CurrentFrame == NULL );
|
||||
Assert( CountClientFrames() == 0 );
|
||||
|
||||
m_nDebugID = EVENT_DEBUG_ID_SHUTDOWN;
|
||||
}
|
||||
|
||||
void CHLTVServer::SetMaxClients( int number )
|
||||
@ -1015,9 +1019,13 @@ void CHLTVServer::FireGameEvent(IGameEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
int CHLTVServer::GetEventDebugID( void )
|
||||
{
|
||||
return m_nDebugID;
|
||||
}
|
||||
|
||||
bool CHLTVServer::ShouldUpdateMasterServer()
|
||||
{
|
||||
|
||||
// If the main game server is active, then we let it update Steam with the server info.
|
||||
return !sv.IsActive();
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ public: // CBaseServer interface:
|
||||
|
||||
public:
|
||||
void FireGameEvent(IGameEvent *event);
|
||||
int m_nDebugID;
|
||||
int GetEventDebugID( void );
|
||||
|
||||
public: // IHLTVServer interface:
|
||||
IServer *GetBaseServer( void );
|
||||
|
@ -262,11 +262,13 @@ CON_COMMAND( logaddress_list, "List all addresses currently being used by logadd
|
||||
CLog::CLog()
|
||||
{
|
||||
Reset();
|
||||
m_nDebugID = EVENT_DEBUG_ID_INIT;
|
||||
|
||||
}
|
||||
|
||||
CLog::~CLog()
|
||||
{
|
||||
|
||||
m_nDebugID = EVENT_DEBUG_ID_SHUTDOWN;
|
||||
}
|
||||
|
||||
void CLog::Reset( void ) // reset all logging streams
|
||||
@ -644,6 +646,11 @@ void CLog::FireGameEvent( IGameEvent *event )
|
||||
}
|
||||
}
|
||||
|
||||
int CLog::GetEventDebugID( void )
|
||||
{
|
||||
return m_nDebugID;
|
||||
}
|
||||
|
||||
struct TempFilename_t
|
||||
{
|
||||
bool IsGzip;
|
||||
|
@ -24,7 +24,8 @@ public:
|
||||
public: // IGameEventListener Interface
|
||||
|
||||
void FireGameEvent( IGameEvent *event );
|
||||
|
||||
int m_nDebugID;
|
||||
int GetEventDebugID( void );
|
||||
public:
|
||||
|
||||
bool IsActive( void ); // true if logging is "on"
|
||||
|
@ -1595,6 +1595,12 @@ public:
|
||||
return sv.GetPlayerInfo( (ent_num-1), pinfo );
|
||||
}
|
||||
|
||||
virtual ISPSharedMemory *GetSinglePlayerSharedMemorySpace( const char *szName, int ent_num = MAX_EDICTS )
|
||||
{
|
||||
// TODO(nillerusr): it this necessary? Implement later if so
|
||||
return NULL; //return g_pSinglePlayerSharedMemoryManager->GetSharedMemory( szName, ent_num );
|
||||
}
|
||||
|
||||
bool IsClientFullyAuthenticated( edict_t *pEdict )
|
||||
{
|
||||
int entnum = NUM_FOR_EDICT( pEdict );
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Acts exactly like "AnimatedTexture", but ONLY if the texture
|
||||
// it's working on matches the desired texture to work on.
|
||||
@ -8,14 +8,15 @@
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "materialsystem/IMaterialProxy.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/ITexture.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
#include "utlstring.h"
|
||||
#include <KeyValues.h>
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -50,4 +51,4 @@ void CAnimateSpecificTexture::OnBind( void *pC_BaseEntity )
|
||||
//else do nothing
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CAnimateSpecificTexture, IMaterialProxy, "AnimateSpecificTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CAnimateSpecificTexture, AnimateSpecificTexture );
|
@ -1,65 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_ENVPROJECTEDTEXTURE_H
|
||||
#define C_ENVPROJECTEDTEXTURE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_baseentity.h"
|
||||
#include "basetypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_EnvProjectedTexture : public C_BaseEntity
|
||||
{
|
||||
DECLARE_CLASS( C_EnvProjectedTexture, C_BaseEntity );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_EnvProjectedTexture();
|
||||
~C_EnvProjectedTexture();
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
void ShutDownLightHandle( void );
|
||||
|
||||
virtual void Simulate();
|
||||
|
||||
void UpdateLight( bool bForceUpdate );
|
||||
|
||||
bool ShadowsEnabled();
|
||||
|
||||
float GetFOV();
|
||||
|
||||
private:
|
||||
|
||||
ClientShadowHandle_t m_LightHandle;
|
||||
|
||||
EHANDLE m_hTargetEntity;
|
||||
|
||||
bool m_bState;
|
||||
float m_flLightFOV;
|
||||
bool m_bEnableShadows;
|
||||
bool m_bLightOnlyTarget;
|
||||
bool m_bLightWorld;
|
||||
bool m_bCameraSpace;
|
||||
color32 m_cLightColor;
|
||||
float m_flAmbient;
|
||||
char m_SpotlightTextureName[ MAX_PATH ];
|
||||
int m_nSpotlightTextureFrame;
|
||||
int m_nShadowQuality;
|
||||
bool m_bCurrentShadow;
|
||||
|
||||
public:
|
||||
C_EnvProjectedTexture *m_pNext;
|
||||
};
|
||||
|
||||
C_EnvProjectedTexture* GetEnvProjectedTextureList();
|
||||
|
||||
#endif // C_ENVPROJECTEDTEXTURE_H
|
@ -1,19 +1,19 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Material Modify control entity.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "proxyentity.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "ProxyEntity.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "materialsystem/ITexture.h"
|
||||
#include "iviewrender.h"
|
||||
#include "texture_group_names.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -29,9 +29,6 @@ enum MaterialModifyMode_t
|
||||
MATERIAL_MODIFY_MODE_FLOAT_LERP = 3,
|
||||
};
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
ConVar debug_materialmodifycontrol_client( "debug_materialmodifycontrol_client", "0" );
|
||||
|
||||
struct materialanimcommands_t
|
||||
@ -328,11 +325,6 @@ void CMaterialModifyProxy::OnBind( void *pEntity )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CMaterialModifyProxy::GetMaterial()
|
||||
@ -753,11 +745,6 @@ void CMaterialModifyAnimatedProxy::OnBind( void *pEntity )
|
||||
}
|
||||
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( intFrame );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -794,5 +781,5 @@ void CMaterialModifyAnimatedProxy::AnimationWrapped( void* pArg )
|
||||
}
|
||||
|
||||
|
||||
EXPOSE_INTERFACE( CMaterialModifyProxy, IMaterialProxy, "MaterialModify" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_INTERFACE( CMaterialModifyAnimatedProxy, IMaterialProxy, "MaterialModifyAnimated" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CMaterialModifyProxy, MaterialModify );
|
||||
EXPOSE_MATERIAL_PROXY( CMaterialModifyAnimatedProxy, MaterialModifyAnimated );
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Water LOD control entity.
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Utility code.
|
||||
//
|
||||
|
@ -1,19 +1,16 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "functionproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
#include "FunctionProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the player health (from 0 to 1)
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -52,12 +49,8 @@ void CProxyIsNPC::OnBind( void *pC_BaseEntity )
|
||||
{
|
||||
SetFloatResult( 0.0f );
|
||||
}
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CProxyIsNPC, IMaterialProxy, "IsNPC" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CProxyIsNPC, IsNPC );
|
||||
|
||||
|
||||
|
@ -1,13 +1,18 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/IMaterialProxy.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
// $monitorTextureVar
|
||||
class CMonitorMaterialProxy : public IMaterialProxy
|
||||
@ -57,4 +62,4 @@ void CMonitorMaterialProxy::OnBind( void *pC_BaseEntity )
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CMonitorMaterialProxy, IMaterialProxy, "Monitor" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CMonitorMaterialProxy, Monitor );
|
||||
|
101
game/client/NPSClient.h
Normal file
101
game/client/NPSClient.h
Normal file
@ -0,0 +1,101 @@
|
||||
// *******************************************************************************
|
||||
// *
|
||||
// * Module Name:
|
||||
// * NPSClient.h
|
||||
// *
|
||||
// * Abstract:
|
||||
// * Header for NaturalPoint Simple Game Client API.
|
||||
// *
|
||||
// * Environment:
|
||||
// * Microsoft Windows -- User mode
|
||||
// *
|
||||
// *******************************************************************************
|
||||
|
||||
#ifndef _NPSCLIENT_H_DEFINED_
|
||||
#define _NPSCLIENT_H_DEFINED_
|
||||
|
||||
#pragma pack( push, npsclient_h ) // Save current pack value
|
||||
#pragma pack(1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
//////////////////
|
||||
/// Typedefs /////////////////////////////////////////////////////////////////////
|
||||
/////////////////
|
||||
|
||||
#ifndef _NPCLIENT_H_DEFINED_
|
||||
|
||||
// NPESULT values are returned from the Game Client API functions.
|
||||
//
|
||||
typedef enum tagNPResult
|
||||
{
|
||||
NP_OK = 0,
|
||||
NP_ERR_DEVICE_NOT_PRESENT,
|
||||
NP_ERR_UNSUPPORTED_OS,
|
||||
NP_ERR_INVALID_ARG,
|
||||
NP_ERR_DLL_NOT_FOUND,
|
||||
NP_ERR_NO_DATA,
|
||||
NP_ERR_INTERNAL_DATA,
|
||||
NP_ERR_ALREADY_REGISTERED, // a window handle or game ID is already registered
|
||||
NP_ERR_UNKNOWN_ID, // unknown game ID registered
|
||||
NP_ERR_READ_ONLY, // parameter is read only
|
||||
|
||||
} NPRESULT;
|
||||
|
||||
typedef struct tagTrackIRData
|
||||
{
|
||||
unsigned short wNPStatus;
|
||||
unsigned short wPFrameSignature;
|
||||
unsigned long dwNPIOData;
|
||||
|
||||
float fNPRoll;
|
||||
float fNPPitch;
|
||||
float fNPYaw;
|
||||
float fNPX;
|
||||
float fNPY;
|
||||
float fNPZ;
|
||||
float fNPRawX;
|
||||
float fNPRawY;
|
||||
float fNPRawZ;
|
||||
float fNPDeltaX;
|
||||
float fNPDeltaY;
|
||||
float fNPDeltaZ;
|
||||
float fNPSmoothX;
|
||||
float fNPSmoothY;
|
||||
float fNPSmoothZ;
|
||||
|
||||
} TRACKIRDATA, *LPTRACKIRDATA;
|
||||
|
||||
#endif
|
||||
|
||||
typedef NPRESULT (__stdcall *PF_NPS_INIT)( HWND );
|
||||
typedef NPRESULT (__stdcall *PF_NPS_SHUTDOWN)( void );
|
||||
typedef NPRESULT (__stdcall *PF_NPS_GETDATA)( LPTRACKIRDATA );
|
||||
|
||||
//// Function Prototypes ///////////////////////////////////////////////
|
||||
//
|
||||
// Functions exported from game client API DLL ( note __stdcall calling convention
|
||||
// is used for ease of interface to clients of differing implementations including
|
||||
// C, C++, Pascal (Delphi) and VB. )
|
||||
//
|
||||
NPRESULT __stdcall NPS_Init( HWND hWnd );
|
||||
NPRESULT __stdcall NPS_Shutdown( void );
|
||||
NPRESULT __stdcall NPS_GetData( LPTRACKIRDATA pTID );
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma pack( pop, npsclient_h ) // Ensure previous pack value is restored
|
||||
|
||||
#endif // #ifdef NPCLIENT_H_DEFINED_
|
||||
|
||||
//
|
||||
// *** End of file: NPSClient.h ***
|
||||
//
|
||||
|
||||
|
@ -1,245 +0,0 @@
|
||||
// C_NextBot.cpp
|
||||
// Client-side implementation of Next generation bot system
|
||||
// Author: Michael Booth, April 2005
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "C_NextBot.h"
|
||||
#include "debugoverlay_shared.h"
|
||||
#include <bitbuf.h>
|
||||
#include "viewrender.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#undef NextBot
|
||||
|
||||
ConVar NextBotShadowDist( "nb_shadow_dist", "400" );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_NextBotCombatCharacter, DT_NextBot, NextBotCombatCharacter )
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_NextBotCombatCharacter::C_NextBotCombatCharacter()
|
||||
{
|
||||
// Left4Dead have surfaces too steep for IK to work properly
|
||||
m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK;
|
||||
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
m_forcedShadowType = SHADOWS_NONE;
|
||||
m_bForceShadowType = false;
|
||||
|
||||
TheClientNextBots().Register( this );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_NextBotCombatCharacter::~C_NextBotCombatCharacter()
|
||||
{
|
||||
TheClientNextBots().UnRegister( this );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::Spawn( void )
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::UpdateClientSideAnimation()
|
||||
{
|
||||
if (IsDormant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::UpdateClientSideAnimation();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotCombatCharacter::UpdateShadowLOD( void )
|
||||
{
|
||||
ShadowType_t oldShadowType = m_shadowType;
|
||||
|
||||
if ( m_bForceShadowType )
|
||||
{
|
||||
m_shadowType = m_forcedShadowType;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NEED_SPLITSCREEN_INTEGRATION
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh )
|
||||
{
|
||||
C_BasePlayer *pl = C_BasePlayer::GetLocalPlayer(hh);
|
||||
if ( pl )
|
||||
{
|
||||
Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer(hh)->GetAbsOrigin();
|
||||
#else
|
||||
{
|
||||
if ( C_BasePlayer::GetLocalPlayer() )
|
||||
{
|
||||
Vector delta = GetAbsOrigin() - C_BasePlayer::GetLocalPlayer()->GetAbsOrigin();
|
||||
#endif
|
||||
if ( delta.IsLengthLessThan( NextBotShadowDist.GetFloat() ) )
|
||||
{
|
||||
m_shadowType = SHADOWS_RENDER_TO_TEXTURE_DYNAMIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shadowType = SHADOWS_SIMPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( oldShadowType != m_shadowType )
|
||||
{
|
||||
DestroyShadow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
ShadowType_t C_NextBotCombatCharacter::ShadowCastType( void )
|
||||
{
|
||||
if ( !IsVisible() )
|
||||
return SHADOWS_NONE;
|
||||
|
||||
if ( m_shadowTimer.IsElapsed() )
|
||||
{
|
||||
m_shadowTimer.Start( 0.15f );
|
||||
UpdateShadowLOD();
|
||||
}
|
||||
|
||||
return m_shadowType;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool C_NextBotCombatCharacter::GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const
|
||||
{
|
||||
if ( pForcedShadowType )
|
||||
{
|
||||
*pForcedShadowType = m_forcedShadowType;
|
||||
}
|
||||
return m_bForceShadowType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Singleton accessor.
|
||||
* By returning a reference, we guarantee construction of the
|
||||
* instance before its first use.
|
||||
*/
|
||||
C_NextBotManager &TheClientNextBots( void )
|
||||
{
|
||||
static C_NextBotManager manager;
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
C_NextBotManager::C_NextBotManager( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
C_NextBotManager::~C_NextBotManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotManager::Register( C_NextBotCombatCharacter *bot )
|
||||
{
|
||||
m_botList.AddToTail( bot );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_NextBotManager::UnRegister( C_NextBotCombatCharacter *bot )
|
||||
{
|
||||
m_botList.FindAndRemove( bot );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_NextBotManager::SetupInFrustumData( void )
|
||||
{
|
||||
#ifdef ENABLE_AFTER_INTEGRATION
|
||||
// Done already this frame.
|
||||
if ( IsInFrustumDataValid() )
|
||||
return true;
|
||||
|
||||
// Can we use the view data yet?
|
||||
if ( !FrustumCache()->IsValid() )
|
||||
return false;
|
||||
|
||||
// Get the number of active bots.
|
||||
int nBotCount = m_botList.Count();
|
||||
|
||||
// Reset.
|
||||
for ( int iBot = 0; iBot < nBotCount; ++iBot )
|
||||
{
|
||||
// Get the current bot.
|
||||
C_NextBotCombatCharacter *pBot = m_botList[iBot];
|
||||
if ( !pBot )
|
||||
continue;
|
||||
|
||||
pBot->InitFrustumData();
|
||||
}
|
||||
|
||||
FOR_EACH_VALID_SPLITSCREEN_PLAYER( iSlot )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( iSlot );
|
||||
// Get the active local player.
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !pPlayer )
|
||||
continue;
|
||||
|
||||
for ( int iBot = 0; iBot < nBotCount; ++iBot )
|
||||
{
|
||||
// Get the current bot.
|
||||
C_NextBotCombatCharacter *pBot = m_botList[iBot];
|
||||
if ( !pBot )
|
||||
continue;
|
||||
|
||||
// Are we in the view frustum?
|
||||
Vector vecMin, vecMax;
|
||||
pBot->CollisionProp()->WorldSpaceAABB( &vecMin, &vecMax );
|
||||
bool bInFrustum = !FrustumCache()->m_Frustums[iSlot].CullBox( vecMin, vecMax );
|
||||
|
||||
if ( bInFrustum )
|
||||
{
|
||||
Vector vecSegment;
|
||||
VectorSubtract( pBot->GetAbsOrigin(), pPlayer->GetAbsOrigin(), vecSegment );
|
||||
float flDistance = vecSegment.LengthSqr();
|
||||
if ( flDistance < pBot->GetInFrustumDistanceSqr() )
|
||||
{
|
||||
pBot->SetInFrustumDistanceSqr( flDistance );
|
||||
}
|
||||
|
||||
pBot->SetInFrustum( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark as setup this frame.
|
||||
m_nInFrustumFrame = gpGlobals->framecount;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
@ -1,134 +0,0 @@
|
||||
// C_NextBot.h
|
||||
// Next generation bot system
|
||||
// Author: Michael Booth, April 2005
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef _C_NEXT_BOT_H_
|
||||
#define _C_NEXT_BOT_H_
|
||||
|
||||
#include "c_ai_basenpc.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The interface holding IBody information
|
||||
*/
|
||||
class IBodyClient
|
||||
{
|
||||
public:
|
||||
enum ActivityType
|
||||
{
|
||||
MOTION_CONTROLLED_XY = 0x0001, // XY position and orientation of the bot is driven by the animation.
|
||||
MOTION_CONTROLLED_Z = 0x0002, // Z position of the bot is driven by the animation.
|
||||
ACTIVITY_UNINTERRUPTIBLE= 0x0004, // activity can't be changed until animation finishes
|
||||
ACTIVITY_TRANSITORY = 0x0008, // a short animation that takes over from the underlying animation momentarily, resuming it upon completion
|
||||
ENTINDEX_PLAYBACK_RATE = 0x0010, // played back at different rates based on entindex
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The client-side implementation of the NextBot
|
||||
*/
|
||||
class C_NextBotCombatCharacter : public C_BaseCombatCharacter
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_NextBotCombatCharacter, C_BaseCombatCharacter );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_NextBotCombatCharacter();
|
||||
virtual ~C_NextBotCombatCharacter();
|
||||
|
||||
public:
|
||||
virtual void Spawn( void );
|
||||
virtual void UpdateClientSideAnimation( void );
|
||||
virtual ShadowType_t ShadowCastType( void );
|
||||
virtual bool IsNextBot() { return true; }
|
||||
void ForceShadowCastType( bool bForce, ShadowType_t forcedShadowType = SHADOWS_NONE ) { m_bForceShadowType = bForce; m_forcedShadowType = forcedShadowType; }
|
||||
bool GetForcedShadowCastType( ShadowType_t* pForcedShadowType ) const;
|
||||
|
||||
// Local In View Data.
|
||||
void InitFrustumData( void ) { m_bInFrustum = false; m_flFrustumDistanceSqr = FLT_MAX; m_nInFrustumFrame = gpGlobals->framecount; }
|
||||
bool IsInFrustumValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); }
|
||||
void SetInFrustum( bool bInFrustum ) { m_bInFrustum = bInFrustum; }
|
||||
bool IsInFrustum( void ) { return m_bInFrustum; }
|
||||
void SetInFrustumDistanceSqr( float flDistance ) { m_flFrustumDistanceSqr = flDistance; }
|
||||
float GetInFrustumDistanceSqr( void ) { return m_flFrustumDistanceSqr; }
|
||||
|
||||
private:
|
||||
ShadowType_t m_shadowType; // Are we LOD'd to simple shadows?
|
||||
CountdownTimer m_shadowTimer; // Timer to throttle checks for shadow LOD
|
||||
ShadowType_t m_forcedShadowType;
|
||||
bool m_bForceShadowType;
|
||||
void UpdateShadowLOD( void );
|
||||
|
||||
// Local In View Data.
|
||||
int m_nInFrustumFrame;
|
||||
bool m_bInFrustum;
|
||||
float m_flFrustumDistanceSqr;
|
||||
|
||||
private:
|
||||
C_NextBotCombatCharacter( const C_NextBotCombatCharacter & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* The C_NextBotManager manager
|
||||
*/
|
||||
class C_NextBotManager
|
||||
{
|
||||
public:
|
||||
C_NextBotManager( void );
|
||||
~C_NextBotManager();
|
||||
|
||||
/**
|
||||
* Execute functor for each NextBot in the system.
|
||||
* If a functor returns false, stop iteration early
|
||||
* and return false.
|
||||
*/
|
||||
template < typename Functor >
|
||||
bool ForEachCombatCharacter( Functor &func )
|
||||
{
|
||||
for( int i=0; i < m_botList.Count(); ++i )
|
||||
{
|
||||
C_NextBotCombatCharacter *character = m_botList[i];
|
||||
if ( character->IsPlayer() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( character->IsDormant() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !func( character ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetActiveCount() { return m_botList.Count(); }
|
||||
|
||||
bool SetupInFrustumData( void );
|
||||
bool IsInFrustumDataValid( void ) { return ( m_nInFrustumFrame == gpGlobals->framecount ); }
|
||||
|
||||
private:
|
||||
friend class C_NextBotCombatCharacter;
|
||||
|
||||
void Register( C_NextBotCombatCharacter *bot );
|
||||
void UnRegister( C_NextBotCombatCharacter *bot );
|
||||
|
||||
CUtlVector< C_NextBotCombatCharacter * > m_botList; ///< list of all active NextBots
|
||||
|
||||
int m_nInFrustumFrame;
|
||||
};
|
||||
|
||||
// singleton accessor
|
||||
extern C_NextBotManager &TheClientNextBots( void );
|
||||
|
||||
|
||||
#endif // _C_NEXT_BOT_H_
|
@ -1,19 +1,16 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "functionproxy.h"
|
||||
#include "toolframework_client.h"
|
||||
#include "FunctionProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the player health (from 0 to 1)
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -47,13 +44,8 @@ void CProxyHealth::OnBind( void *pC_BaseEntity )
|
||||
|
||||
Assert( m_pResult );
|
||||
SetFloatResult( pEntity->HealthFraction() * m_Factor.GetFloat() );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CProxyHealth, IMaterialProxy, "Health" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CProxyHealth, Health );
|
||||
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "KeyValues.h"
|
||||
#include "keyvalues.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "view_scene.h"
|
||||
#include "viewrender.h"
|
||||
#include "tier0/icommandline.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/IMesh.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialSystemHardwareConfig.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
|
||||
#include "ScreenSpaceEffects.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
@ -6,11 +6,11 @@
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "TeamBitmapImage.h"
|
||||
#include "teambitmapimage.h"
|
||||
#include <KeyValues.h>
|
||||
#include "vgui_bitmapimage.h"
|
||||
#include "panelmetaclassmgr.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "vgui_BitmapImage.h"
|
||||
#include "PanelMetaClassMgr.h"
|
||||
#include "vguimatsurface/IMatSystemSurface.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
@ -42,14 +42,14 @@ CTeamBitmapImage::~CTeamBitmapImage()
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTeamBitmapImage::Init( vgui::Panel *pParent, KeyValues* pInitData, C_BaseEntity* pEntity )
|
||||
{
|
||||
static const char *pRelativeTeamNames[BITMAP_COUNT] =
|
||||
static char *pRelativeTeamNames[BITMAP_COUNT] =
|
||||
{
|
||||
"NoTeam",
|
||||
"MyTeam",
|
||||
"EnemyTeam",
|
||||
};
|
||||
|
||||
static const char *pAbsoluteTeamNames[BITMAP_COUNT] =
|
||||
static char *pAbsoluteTeamNames[BITMAP_COUNT] =
|
||||
{
|
||||
"Team0",
|
||||
"Team1",
|
||||
@ -59,7 +59,7 @@ bool CTeamBitmapImage::Init( vgui::Panel *pParent, KeyValues* pInitData, C_BaseE
|
||||
m_pEntity = pEntity;
|
||||
m_bRelativeTeams = (pInitData->GetInt( "relativeteam" ) != 0);
|
||||
|
||||
const char **ppTeamNames = m_bRelativeTeams ? pRelativeTeamNames : pAbsoluteTeamNames;
|
||||
char **ppTeamNames = m_bRelativeTeams ? pRelativeTeamNames : pAbsoluteTeamNames;
|
||||
|
||||
int i;
|
||||
for ( i = 0 ; i < BITMAP_COUNT; ++i )
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which is rendered image on top of an entity
|
||||
//
|
||||
@ -9,7 +9,7 @@
|
||||
#include "ViewConeImage.h"
|
||||
#include <KeyValues.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "vguimatsurface/IMatSystemSurface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: This is a panel which draws a viewcone
|
||||
//
|
||||
@ -10,7 +10,7 @@
|
||||
#define VIEWCONEIMAGE_H
|
||||
|
||||
#include "shareddefs.h"
|
||||
#include "vgui_bitmapimage.h"
|
||||
#include "VGUI_BitmapImage.h"
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
|
@ -1,22 +1,19 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/IMaterialProxy.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "iviewrender.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
// no inputs, assumes that the results go into $CHEAPWATERSTARTDISTANCE and $CHEAPWATERENDDISTANCE
|
||||
class CWaterLODMaterialProxy : public IMaterialProxy
|
||||
{
|
||||
@ -68,11 +65,6 @@ void CWaterLODMaterialProxy::OnBind( void *pC_BaseEntity )
|
||||
view->GetWaterLODParams( start, end );
|
||||
m_pCheapWaterStartDistanceVar->SetFloatValue( start );
|
||||
m_pCheapWaterEndDistanceVar->SetFloatValue( end );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CWaterLODMaterialProxy::GetMaterial()
|
||||
@ -80,4 +72,4 @@ IMaterial *CWaterLODMaterialProxy::GetMaterial()
|
||||
return m_pCheapWaterStartDistanceVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CWaterLODMaterialProxy, IMaterialProxy, "WaterLOD" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CWaterLODMaterialProxy, WaterLOD );
|
||||
|
@ -1,22 +1,19 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/IMaterialProxy.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "c_world.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
class CWorldDimsProxy : public IMaterialProxy
|
||||
{
|
||||
public:
|
||||
@ -61,11 +58,6 @@ void CWorldDimsProxy::OnBind( void *pC_BaseEntity )
|
||||
m_pMaxsVar->SetVecValue( (const float*)&pWorld->m_WorldMaxs, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CWorldDimsProxy::GetMaterial()
|
||||
@ -73,6 +65,6 @@ IMaterial *CWorldDimsProxy::GetMaterial()
|
||||
return m_pMinsVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CWorldDimsProxy, IMaterialProxy, "WorldDims" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CWorldDimsProxy, WorldDims );
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -13,7 +13,7 @@
|
||||
#include "ienginevgui.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/IVGUI.h>
|
||||
#include <vgui_controls/EditablePanel.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/ImagePanel.h>
|
||||
@ -33,14 +33,14 @@ using namespace vgui;
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DECLARE_HUDELEMENT_DEPTH( CAchievementNotificationPanel, 100 );
|
||||
// DECLARE_HUDELEMENT_DEPTH( CAchievementNotificationPanel, 100 );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CAchievementNotificationPanel::CAchievementNotificationPanel( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "AchievementNotificationPanel" )
|
||||
{
|
||||
Panel *pParent = g_pClientMode->GetViewport();
|
||||
Panel *pParent = GetClientMode()->GetViewport();
|
||||
SetParent( pParent );
|
||||
|
||||
m_flHideTime = 0;
|
||||
@ -85,7 +85,7 @@ void CAchievementNotificationPanel::PerformLayout( void )
|
||||
SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pLabelHeading->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pLabelTitle->SetBgColor( Color( 0, 0, 0, 0 ) );
|
||||
m_pPanelBackground->SetBgColor( Color( 128, 128, 128, 128 ) );
|
||||
m_pPanelBackground->SetBgColor( Color( 62,70,55, 200 ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -94,14 +94,13 @@ void CAchievementNotificationPanel::PerformLayout( void )
|
||||
void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char *name = event->GetName();
|
||||
if ( Q_strcmp( name, "achievement_event" ) == 0 )
|
||||
if ( 0 == Q_strcmp( name, "achievement_event" ) )
|
||||
{
|
||||
const char *pchName = event->GetString( "achievement_name" );
|
||||
int iCur = event->GetInt( "cur_val" );
|
||||
int iMax = event->GetInt( "max_val" );
|
||||
wchar_t szLocalizedName[256]=L"";
|
||||
|
||||
#ifndef DISABLE_STEAM
|
||||
if ( IsPC() )
|
||||
{
|
||||
// shouldn't ever get achievement progress if steam not running and user logged in, but check just in case
|
||||
@ -109,14 +108,13 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
Msg( "Steam not running, achievement progress notification not displayed\n" );
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// use Steam to show achievement progress UI
|
||||
steamapicontext->SteamUserStats()->IndicateAchievementProgress( pchName, iCur, iMax );
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// on X360 we need to show our own achievement progress UI
|
||||
|
||||
@ -127,17 +125,10 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
Q_wcsncpy( szLocalizedName, pchLocalizedName, sizeof( szLocalizedName ) );
|
||||
|
||||
// this is achievement progress, compose the message of form: "<name> (<#>/<max>)"
|
||||
wchar_t szText[512]=L"";
|
||||
wchar_t szFmt[128]=L"";
|
||||
wchar_t szText[512]=L"";
|
||||
wchar_t szNumFound[16]=L"";
|
||||
wchar_t szNumTotal[16]=L"";
|
||||
|
||||
if( iCur >= iMax )
|
||||
{
|
||||
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Awarded" ), szLocalizedName );
|
||||
return;
|
||||
}
|
||||
|
||||
_snwprintf( szNumFound, ARRAYSIZE( szNumFound ), L"%i", iCur );
|
||||
_snwprintf( szNumTotal, ARRAYSIZE( szNumTotal ), L"%i", iMax );
|
||||
|
||||
@ -147,8 +138,7 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
Q_wcsncpy( szFmt, pchFmt, sizeof( szFmt ) );
|
||||
|
||||
g_pVGuiLocalize->ConstructString( szText, sizeof( szText ), szFmt, 3, szLocalizedName, szNumFound, szNumTotal );
|
||||
|
||||
AddNotification( pchName, g_pVGuiLocalize->Find( "#GameUI_Achievement_Progress" ), szText );
|
||||
AddNotification( pchName, g_pVGuiLocalize->FindSafe( "#GameUI_Achievement_Progress" ), szText );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,13 +245,13 @@ void CAchievementNotificationPanel::SetXAndWide( Panel *pPanel, int x, int wide
|
||||
pPanel->SetWide( wide );
|
||||
}
|
||||
|
||||
CON_COMMAND( achievement_notification_test, "Test the hud notification UI" )
|
||||
CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
static int iCount=0;
|
||||
|
||||
CAchievementNotificationPanel *pPanel = GET_HUDELEMENT( CAchievementNotificationPanel );
|
||||
if ( pPanel )
|
||||
{
|
||||
{
|
||||
pPanel->AddNotification( "HL2_KILL_ODESSAGUNSHIP", L"Achievement Progress", ( 0 == ( iCount % 2 ) ? L"Test Notification Message A (1/10)" :
|
||||
L"Test Message B" ) );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
@ -1,62 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "proxyentity.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// $sineVar : name of variable that controls the alpha level (float)
|
||||
class CAlphaMaterialProxy : public CEntityMaterialProxy
|
||||
{
|
||||
public:
|
||||
CAlphaMaterialProxy();
|
||||
virtual ~CAlphaMaterialProxy();
|
||||
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||
virtual void OnBind( C_BaseEntity *pEntity );
|
||||
virtual IMaterial *GetMaterial();
|
||||
|
||||
private:
|
||||
IMaterialVar *m_AlphaVar;
|
||||
};
|
||||
|
||||
CAlphaMaterialProxy::CAlphaMaterialProxy()
|
||||
{
|
||||
m_AlphaVar = NULL;
|
||||
}
|
||||
|
||||
CAlphaMaterialProxy::~CAlphaMaterialProxy()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CAlphaMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||
{
|
||||
bool foundVar;
|
||||
m_AlphaVar = pMaterial->FindVar( "$alpha", &foundVar, false );
|
||||
return foundVar;
|
||||
}
|
||||
|
||||
void CAlphaMaterialProxy::OnBind( C_BaseEntity *pEnt )
|
||||
{
|
||||
if (m_AlphaVar)
|
||||
{
|
||||
m_AlphaVar->SetFloatValue( pEnt->m_clrRender->a );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CAlphaMaterialProxy::GetMaterial()
|
||||
{
|
||||
if ( !m_AlphaVar )
|
||||
return NULL;
|
||||
|
||||
return m_AlphaVar->GetOwningMaterial();
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE( CAlphaMaterialProxy, IMaterialProxy, "Alpha" IMATERIAL_PROXY_INTERFACE_VERSION );
|
@ -1,12 +1,13 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -21,7 +22,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedEntityTextureProxy, IMaterialProxy, "AnimatedEntityTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CAnimatedEntityTextureProxy, AnimatedEntityTexture );
|
||||
|
||||
float CAnimatedEntityTextureProxy::GetAnimationStartTime( void* pArg )
|
||||
{
|
||||
|
@ -1,12 +1,13 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -25,7 +26,7 @@ protected:
|
||||
float m_flFrameOffset;
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedOffsetTextureProxy, IMaterialProxy, "AnimatedOffsetTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CAnimatedOffsetTextureProxy, AnimatedOffsetTexture );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
|
@ -1,12 +1,13 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
|
||||
#include "imaterialproxydict.h"
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -18,7 +19,7 @@ public:
|
||||
virtual float GetAnimationStartTime( void* pBaseEntity );
|
||||
};
|
||||
|
||||
EXPOSE_INTERFACE( CAnimatedTextureProxy, IMaterialProxy, "AnimatedTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||
EXPOSE_MATERIAL_PROXY( CAnimatedTextureProxy, AnimatedTexture );
|
||||
|
||||
#pragma warning (disable : 4100)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ANIMATIONLAYER_H
|
||||
#define ANIMATIONLAYER_H
|
||||
@ -12,8 +12,11 @@
|
||||
|
||||
|
||||
#include "rangecheckedvar.h"
|
||||
#include "lerp_functions.h"
|
||||
#include "networkvar.h"
|
||||
#include "tier1/lerp_functions.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
class C_BaseAnimatingOverlay;
|
||||
#endif
|
||||
|
||||
class C_AnimationLayer
|
||||
{
|
||||
@ -25,60 +28,135 @@ public:
|
||||
C_AnimationLayer();
|
||||
void Reset();
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void SetOwner( C_BaseAnimatingOverlay *pOverlay );
|
||||
C_BaseAnimatingOverlay *GetOwner() const;
|
||||
#endif
|
||||
|
||||
void SetOrder( int order );
|
||||
bool IsActive( void );
|
||||
float GetFadeout( float flCurTime );
|
||||
|
||||
void SetSequence( int nSequence );
|
||||
void SetCycle( float flCycle );
|
||||
void SetPrevCycle( float flCycle );
|
||||
void SetPlaybackRate( float flPlaybackRate );
|
||||
void SetWeight( float flWeight );
|
||||
|
||||
int GetOrder() const;
|
||||
int GetSequence( ) const;
|
||||
float GetCycle( ) const;
|
||||
float GetPrevCycle( ) const;
|
||||
float GetPlaybackRate( ) const;
|
||||
float GetWeight( ) const;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
// If the weights, cycle or sequence #s changed due to interpolation then
|
||||
// we'll need to recompute the bbox
|
||||
int GetInvalidatePhysicsBits() const;
|
||||
void SetInvalidatePhysicsBits( int iBit ) { m_nInvalidatePhysicsBits = iBit; }
|
||||
#endif
|
||||
|
||||
public:
|
||||
float m_flLayerAnimtime;
|
||||
float m_flLayerFadeOuttime;
|
||||
|
||||
bool IsActive( void );
|
||||
|
||||
CRangeCheckedVar<int, -1, 65535, 0> m_nSequence;
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flPrevCycle;
|
||||
CRangeCheckedVar<float, -5, 5, 0> m_flWeight;
|
||||
private:
|
||||
int m_nOrder;
|
||||
CRangeCheckedVar<int, -1, 65535, 0> m_nSequence;
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flPrevCycle;
|
||||
CRangeCheckedVar<float, -5, 5, 0> m_flWeight;
|
||||
|
||||
// used for automatic crossfades between sequence changes
|
||||
CRangeCheckedVar<float, -50, 50, 1> m_flPlaybackRate;
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flCycle;
|
||||
|
||||
float GetFadeout( float flCurTime );
|
||||
#ifdef CLIENT_DLL
|
||||
C_BaseAnimatingOverlay *m_pOwner;
|
||||
int m_nInvalidatePhysicsBits;
|
||||
#endif
|
||||
|
||||
void BlendWeight();
|
||||
|
||||
float m_flLayerAnimtime;
|
||||
float m_flLayerFadeOuttime;
|
||||
|
||||
float m_flBlendIn;
|
||||
float m_flBlendOut;
|
||||
|
||||
bool m_bClientBlend;
|
||||
friend class C_BaseAnimatingOverlay;
|
||||
friend C_AnimationLayer LoopingLerp( float flPercent, C_AnimationLayer& from, C_AnimationLayer& to );
|
||||
friend C_AnimationLayer Lerp( float flPercent, const C_AnimationLayer& from, const C_AnimationLayer& to );
|
||||
friend C_AnimationLayer LoopingLerp_Hermite( const C_AnimationLayer& current, float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to );
|
||||
friend C_AnimationLayer Lerp_Hermite( const C_AnimationLayer& current, float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to );
|
||||
friend void Lerp_Clamp( C_AnimationLayer &val );
|
||||
friend int CheckForSequenceBoxChanges( const C_AnimationLayer& newLayer, const C_AnimationLayer& oldLayer );
|
||||
};
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
#define CAnimationLayer C_AnimationLayer
|
||||
#endif
|
||||
|
||||
|
||||
inline C_AnimationLayer::C_AnimationLayer()
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
m_pOwner = NULL;
|
||||
m_nInvalidatePhysicsBits = 0;
|
||||
#endif
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline void C_AnimationLayer::Reset()
|
||||
#ifdef GAME_DLL
|
||||
|
||||
inline void C_AnimationLayer::SetSequence( int nSequence )
|
||||
{
|
||||
m_nSequence = 0;
|
||||
m_flPrevCycle = 0;
|
||||
m_flWeight = 0;
|
||||
m_flPlaybackRate = 0;
|
||||
m_flCycle = 0;
|
||||
m_flLayerAnimtime = 0;
|
||||
m_flLayerFadeOuttime = 0;
|
||||
m_flBlendIn = 0;
|
||||
m_flBlendOut = 0;
|
||||
m_bClientBlend = false;
|
||||
m_nSequence = nSequence;
|
||||
}
|
||||
|
||||
|
||||
inline void C_AnimationLayer::SetOrder( int order )
|
||||
inline void C_AnimationLayer::SetCycle( float flCycle )
|
||||
{
|
||||
m_nOrder = order;
|
||||
m_flCycle = flCycle;
|
||||
}
|
||||
|
||||
inline void C_AnimationLayer::SetWeight( float flWeight )
|
||||
{
|
||||
m_flWeight = flWeight;
|
||||
}
|
||||
|
||||
#endif // GAME_DLL
|
||||
|
||||
FORCEINLINE void C_AnimationLayer::SetPrevCycle( float flPrevCycle )
|
||||
{
|
||||
m_flPrevCycle = flPrevCycle;
|
||||
}
|
||||
|
||||
FORCEINLINE void C_AnimationLayer::SetPlaybackRate( float flPlaybackRate )
|
||||
{
|
||||
m_flPlaybackRate = flPlaybackRate;
|
||||
}
|
||||
|
||||
FORCEINLINE int C_AnimationLayer::GetSequence( ) const
|
||||
{
|
||||
return m_nSequence;
|
||||
}
|
||||
|
||||
FORCEINLINE float C_AnimationLayer::GetCycle( ) const
|
||||
{
|
||||
return m_flCycle;
|
||||
}
|
||||
|
||||
FORCEINLINE float C_AnimationLayer::GetPrevCycle( ) const
|
||||
{
|
||||
return m_flPrevCycle;
|
||||
}
|
||||
|
||||
FORCEINLINE float C_AnimationLayer::GetPlaybackRate( ) const
|
||||
{
|
||||
return m_flPlaybackRate;
|
||||
}
|
||||
|
||||
FORCEINLINE float C_AnimationLayer::GetWeight( ) const
|
||||
{
|
||||
return m_flWeight;
|
||||
}
|
||||
|
||||
FORCEINLINE int C_AnimationLayer::GetOrder() const
|
||||
{
|
||||
return m_nOrder;
|
||||
}
|
||||
|
||||
inline float C_AnimationLayer::GetFadeout( float flCurTime )
|
||||
@ -107,9 +185,19 @@ inline float C_AnimationLayer::GetFadeout( float flCurTime )
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
FORCEINLINE int C_AnimationLayer::GetInvalidatePhysicsBits() const
|
||||
{
|
||||
return m_nInvalidatePhysicsBits;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline C_AnimationLayer LoopingLerp( float flPercent, C_AnimationLayer& from, C_AnimationLayer& to )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
Assert( from.GetOwner() == to.GetOwner() );
|
||||
#endif
|
||||
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
@ -120,11 +208,18 @@ inline C_AnimationLayer LoopingLerp( float flPercent, C_AnimationLayer& from, C_
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
#ifdef CLIENT_DLL
|
||||
output.SetOwner( to.GetOwner() );
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
inline C_AnimationLayer Lerp( float flPercent, const C_AnimationLayer& from, const C_AnimationLayer& to )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
Assert( from.GetOwner() == to.GetOwner() );
|
||||
#endif
|
||||
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
@ -135,37 +230,85 @@ inline C_AnimationLayer Lerp( float flPercent, const C_AnimationLayer& from, con
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
#ifdef CLIENT_DLL
|
||||
output.SetOwner( to.GetOwner() );
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
inline C_AnimationLayer LoopingLerp_Hermite( float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to )
|
||||
inline int CheckForSequenceBoxChanges( const C_AnimationLayer& newLayer, const C_AnimationLayer& oldLayer )
|
||||
{
|
||||
int nChangeFlags = 0;
|
||||
|
||||
bool bOldIsZero = ( oldLayer.GetWeight() == 0.0f );
|
||||
bool bNewIsZero = ( newLayer.GetWeight() == 0.0f );
|
||||
|
||||
if ( ( newLayer.GetSequence() != oldLayer.GetSequence() ) ||
|
||||
( bNewIsZero != bOldIsZero ) )
|
||||
{
|
||||
nChangeFlags |= SEQUENCE_CHANGED | BOUNDS_CHANGED;
|
||||
}
|
||||
|
||||
if ( newLayer.GetCycle() != oldLayer.GetCycle() )
|
||||
{
|
||||
nChangeFlags |= ANIMATION_CHANGED;
|
||||
}
|
||||
|
||||
if ( newLayer.GetOrder() != oldLayer.GetOrder() )
|
||||
{
|
||||
nChangeFlags |= BOUNDS_CHANGED;
|
||||
}
|
||||
|
||||
return nChangeFlags;
|
||||
}
|
||||
|
||||
inline C_AnimationLayer LoopingLerp_Hermite( const C_AnimationLayer& current, float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
Assert( prev.GetOwner() == from.GetOwner() );
|
||||
Assert( from.GetOwner() == to.GetOwner() );
|
||||
#endif
|
||||
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = LoopingLerp_Hermite( flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle );
|
||||
output.m_flCycle = LoopingLerp_Hermite( (float)current.m_flCycle, flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
output.SetOwner( to.GetOwner() );
|
||||
output.m_nInvalidatePhysicsBits = CheckForSequenceBoxChanges( output, current );
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
// YWB: Specialization for interpolating euler angles via quaternions...
|
||||
inline C_AnimationLayer Lerp_Hermite( float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to )
|
||||
inline C_AnimationLayer Lerp_Hermite( const C_AnimationLayer& current, float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
Assert( prev.GetOwner() == from.GetOwner() );
|
||||
Assert( from.GetOwner() == to.GetOwner() );
|
||||
#endif
|
||||
|
||||
C_AnimationLayer output;
|
||||
|
||||
output.m_nSequence = to.m_nSequence;
|
||||
output.m_flCycle = Lerp_Hermite( flPercent, prev.m_flCycle, from.m_flCycle, to.m_flCycle );
|
||||
output.m_flCycle = Lerp_Hermite( (float)current.m_flCycle, flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle );
|
||||
output.m_flPrevCycle = to.m_flPrevCycle;
|
||||
output.m_flWeight = Lerp( flPercent, from.m_flWeight, to.m_flWeight );
|
||||
output.m_nOrder = to.m_nOrder;
|
||||
|
||||
output.m_flLayerAnimtime = to.m_flLayerAnimtime;
|
||||
output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime;
|
||||
#ifdef CLIENT_DLL
|
||||
output.SetOwner( to.GetOwner() );
|
||||
output.m_nInvalidatePhysicsBits = CheckForSequenceBoxChanges( output, current );
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -180,34 +323,4 @@ inline void Lerp_Clamp( C_AnimationLayer &val )
|
||||
Lerp_Clamp( val.m_flLayerFadeOuttime );
|
||||
}
|
||||
|
||||
inline void C_AnimationLayer::BlendWeight()
|
||||
{
|
||||
if ( !m_bClientBlend )
|
||||
return;
|
||||
|
||||
m_flWeight = 1;
|
||||
|
||||
// blend in?
|
||||
if ( m_flBlendIn != 0.0f )
|
||||
{
|
||||
if (m_flCycle < m_flBlendIn)
|
||||
{
|
||||
m_flWeight = m_flCycle / m_flBlendIn;
|
||||
}
|
||||
}
|
||||
|
||||
// blend out?
|
||||
if ( m_flBlendOut != 0.0f )
|
||||
{
|
||||
if (m_flCycle > 1.0 - m_flBlendOut)
|
||||
{
|
||||
m_flWeight = (1.0 - m_flCycle) / m_flBlendOut;
|
||||
}
|
||||
}
|
||||
|
||||
m_flWeight = 3.0 * m_flWeight * m_flWeight - 2.0 * m_flWeight * m_flWeight * m_flWeight;
|
||||
if (m_nSequence == 0)
|
||||
m_flWeight = 0;
|
||||
}
|
||||
|
||||
#endif // ANIMATIONLAYER_H
|
||||
|
@ -1,23 +1,19 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "baseanimatedtextureproxy.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialvar.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "BaseAnimatedTextureProxy.h"
|
||||
#include "materialsystem/IMaterial.h"
|
||||
#include "materialsystem/IMaterialVar.h"
|
||||
#include "materialsystem/ITexture.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// forward declarations
|
||||
void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor, destructor:
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -125,11 +121,6 @@ void CBaseAnimatedTextureProxy::OnBind( void *pEntity )
|
||||
}
|
||||
|
||||
m_AnimatedTextureFrameNumVar->SetIntValue( intFrame );
|
||||
|
||||
if ( ToolsEnabled() )
|
||||
{
|
||||
ToolFramework_RecordMaterialParams( GetMaterial() );
|
||||
}
|
||||
}
|
||||
|
||||
IMaterial *CBaseAnimatedTextureProxy::GetMaterial()
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -8,7 +8,7 @@
|
||||
#ifndef BASEANIMATEDTEXTUREPROXY
|
||||
#define BASEANIMATEDTEXTUREPROXY
|
||||
|
||||
#include "materialsystem/imaterialproxy.h"
|
||||
#include "materialsystem/IMaterialProxy.h"
|
||||
|
||||
class IMaterial;
|
||||
class IMaterialVar;
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Implementation for CBaseClientRenderTargets class.
|
||||
// Provides Init functions for common render textures used by the engine.
|
||||
@ -9,10 +9,20 @@
|
||||
#include "cbase.h"
|
||||
#include "baseclientrendertargets.h" // header
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h" // Hardware config checks
|
||||
#include "materialsystem/itexture.h" // Hardware config checks
|
||||
#include "tier0/icommandline.h"
|
||||
#ifdef GAMEUI_UISYSTEM2_ENABLED
|
||||
#include "gameui.h"
|
||||
#endif
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
ConVar cl_disable_water_render_targets( "cl_disable_water_render_targets", "0" );
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
iSize = CommandLine()->ParmValue( "-reflectionTextureSize", iSize );
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_WaterReflection",
|
||||
iSize, iSize, RT_SIZE_PICMIP,
|
||||
@ -24,6 +34,7 @@ ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture( IMaterialSyste
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
iSize = CommandLine()->ParmValue( "-reflectionTextureSize", iSize );
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_WaterRefraction",
|
||||
iSize, iSize, RT_SIZE_PICMIP,
|
||||
@ -36,6 +47,7 @@ ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture( IMaterialSyste
|
||||
|
||||
ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize )
|
||||
{
|
||||
iSize = CommandLine()->ParmValue( "-monitorTextureSize", iSize );
|
||||
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_Camera",
|
||||
iSize, iSize, RT_SIZE_DEFAULT,
|
||||
@ -45,6 +57,7 @@ ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMater
|
||||
CREATERENDERTARGETFLAGS_HDR );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called by the engine in material system init and shutdown.
|
||||
// Clients should override this in their inherited version, but the base
|
||||
@ -52,14 +65,41 @@ ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMater
|
||||
// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called)
|
||||
// pHardwareConfig - the user hardware config, useful for conditional render target setup
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize, int iCameraTextureSize )
|
||||
void CBaseClientRenderTargets::SetupClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize, int iCameraTextureSize )
|
||||
{
|
||||
IMaterialSystem *pSave = materials;
|
||||
|
||||
// Make sure our config is loaded before we try to init rendertargets
|
||||
ConfigureCurrentSystemLevel();
|
||||
|
||||
// Water effects
|
||||
m_WaterReflectionTexture.Init( CreateWaterReflectionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
m_WaterRefractionTexture.Init( CreateWaterRefractionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
materials = pMaterialSystem; // in case not initted yet for mat system util
|
||||
g_pMaterialSystem = pMaterialSystem;
|
||||
g_pMaterialSystemHardwareConfig = pHardwareConfig;
|
||||
if ( iWaterTextureSize && !cl_disable_water_render_targets.GetBool() )
|
||||
{
|
||||
m_WaterReflectionTexture.Init( CreateWaterReflectionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
m_WaterRefractionTexture.Init( CreateWaterRefractionTexture( pMaterialSystem, iWaterTextureSize ) );
|
||||
}
|
||||
|
||||
// Monitors
|
||||
m_CameraTexture.Init( CreateCameraTexture( pMaterialSystem, iCameraTextureSize ) );
|
||||
if ( iCameraTextureSize )
|
||||
m_CameraTexture.Init( CreateCameraTexture( pMaterialSystem, iCameraTextureSize ) );
|
||||
|
||||
ITexture *pGlintTexture = pMaterialSystem->CreateNamedRenderTargetTextureEx2(
|
||||
"_rt_eyeglint", 32, 32, RT_SIZE_NO_CHANGE, IMAGE_FORMAT_BGRA8888, MATERIAL_RT_DEPTH_NONE );
|
||||
pGlintTexture->IncrementReferenceCount();
|
||||
g_pClientShadowMgr->InitRenderTargets();
|
||||
#ifdef GAMEUI_UISYSTEM2_ENABLED
|
||||
g_pGameUIGameSystem->InitRenderTargets();
|
||||
#endif
|
||||
|
||||
materials = pSave;
|
||||
}
|
||||
|
||||
void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig )
|
||||
{
|
||||
SetupClientRenderTargets( pMaterialSystem, pHardwareConfig );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -75,4 +115,11 @@ void CBaseClientRenderTargets::ShutdownClientRenderTargets()
|
||||
|
||||
// Monitors
|
||||
m_CameraTexture.Shutdown();
|
||||
}
|
||||
|
||||
g_pClientShadowMgr->ShutdownRenderTargets();
|
||||
|
||||
}
|
||||
|
||||
static CBaseClientRenderTargets g_BaseClientRenderTargets;
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CBaseClientRenderTargets, IClientRenderTargets,
|
||||
CLIENTRENDERTARGETS_INTERFACE_VERSION, g_BaseClientRenderTargets );
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Has init functions for all the standard render targets used by most games.
|
||||
// Mods who wish to make their own render targets can inherit from this class
|
||||
@ -14,7 +14,7 @@
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
#ifndef CLIENTRENDERTARTETS_H_
|
||||
#define CLIENTRENDERTARTETS_H_
|
||||
#ifdef _WIN32
|
||||
@ -35,12 +35,13 @@ class CBaseClientRenderTargets : public IClientRenderTargets
|
||||
DECLARE_CLASS_GAMEROOT( CBaseClientRenderTargets, IClientRenderTargets );
|
||||
public:
|
||||
// Interface called by engine during material system startup.
|
||||
virtual void InitClientRenderTargets ( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize = 1024, int iCameraTextureSize = 256 );
|
||||
virtual void InitClientRenderTargets ( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig );
|
||||
// Shutdown all custom render targets here.
|
||||
virtual void ShutdownClientRenderTargets ( void );
|
||||
|
||||
protected:
|
||||
|
||||
void SetupClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize = 1024, int iCameraTextureSize = 256 );
|
||||
|
||||
// Standard render textures used by most mods-- Classes inheriting from
|
||||
// this can choose to init these or not depending on their needs.
|
||||
|
||||
@ -51,9 +52,6 @@ protected:
|
||||
// Used for monitors
|
||||
CTextureReference m_CameraTexture;
|
||||
|
||||
// Used for the HUD in stereo and head tracking mode
|
||||
CTextureReference m_UITexture;
|
||||
|
||||
// Init functions for the common render targets
|
||||
ITexture* CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
|
||||
ITexture* CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
|
||||
|
@ -1,94 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base presence implementation for PC
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "basepresence.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// Default global singleton. Mods should override this.
|
||||
static CBasePresence s_basePresence;
|
||||
IPresence *presence = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Steam version of Rich Presence is a WIP, so PC implementation is stubbed for now.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBasePresence::Init( void )
|
||||
{
|
||||
if ( !presence )
|
||||
{
|
||||
// Mod didn't override, default to base implementation
|
||||
presence = &s_basePresence;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void CBasePresence::Shutdown( void )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::Update( float frametime )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
void CBasePresence::SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties )
|
||||
{
|
||||
// TODO: Implement for PC
|
||||
}
|
||||
unsigned int CBasePresence::GetPresenceID( const char *pIDName )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const char *CBasePresence::GetPropertyIdString( const uint id )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
void CBasePresence::GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes )
|
||||
{
|
||||
}
|
||||
void CBasePresence::StartStatsReporting( HANDLE handle, bool bArbitrated )
|
||||
{
|
||||
}
|
||||
void CBasePresence::SetStat( uint iPropertyId, int iPropertyValue, int dataType )
|
||||
{
|
||||
}
|
||||
void CBasePresence::UploadStats()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
void CBasePresence::DebugUserSetContext( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetContext( 0, atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_context <context id> <context value>\n" );
|
||||
}
|
||||
}
|
||||
void CBasePresence::DebugUserSetProperty( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetProperty( 0, strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), args.Arg( 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_property <property id> <property value>\n" );
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base implementation of the IPresence interface
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BASEPRESENCE_H
|
||||
#define BASEPRESENCE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "ipresence.h"
|
||||
#include "igamesystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Common implementation for setting user contexts and properties.
|
||||
// Each client should inherit from this to implement mod-specific presence info.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBasePresence : public IPresence, public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
// CBaseGameSystemPerFrame overrides
|
||||
virtual bool Init( void );
|
||||
virtual void Shutdown( void );
|
||||
virtual void Update( float frametime );
|
||||
virtual char const *Name( void ) { return "presence"; }
|
||||
|
||||
// IPresence Interface
|
||||
virtual void UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync = false );
|
||||
virtual void UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync = false );
|
||||
virtual void SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties );
|
||||
virtual uint GetPresenceID( const char *pIdName );
|
||||
virtual void GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes );
|
||||
virtual const char *GetPropertyIdString( const uint id );
|
||||
|
||||
// Stats reporting
|
||||
virtual void StartStatsReporting( HANDLE handle, bool bArbitrated );
|
||||
virtual void SetStat( uint iPropertyId, int iPropertyValue, int dataType );
|
||||
virtual void UploadStats();
|
||||
|
||||
protected:
|
||||
bool m_bArbitrated;
|
||||
bool m_bReportingStats;
|
||||
HANDLE m_hSession;
|
||||
CUtlVector< XUSER_PROPERTY > m_PlayerStats;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
CON_COMMAND_MEMBER_F( CBasePresence, "user_context", DebugUserSetContext, "Set a Rich Presence Context: user_context <context id> <context value>", 0 )
|
||||
CON_COMMAND_MEMBER_F( CBasePresence, "user_property", DebugUserSetProperty, "Set a Rich Presence Property: user_property <property id>", 0 )
|
||||
};
|
||||
|
||||
#endif // BASEPRESENCE_H
|
@ -1,167 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Base rich presence implementation for Xbox360
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "basepresence.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "ixboxsystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
// Default global instance. Mods should override this.
|
||||
static CBasePresence s_basePresence;
|
||||
IPresence *presence = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Init
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBasePresence::Init( void )
|
||||
{
|
||||
if ( !presence )
|
||||
{
|
||||
// Mod didn't override, default to base implementation
|
||||
presence = &s_basePresence;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::Shutdown( void )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Per-frame update
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::Update( float frametime )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Contexts are strings that describe the current state of the game.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UserSetContext( unsigned int nUserIndex, unsigned int nContextId, unsigned int nContextValue, bool bAsync )
|
||||
{
|
||||
if ( !xboxsystem->UserSetContext( nUserIndex, nContextId, nContextValue, bAsync ) )
|
||||
{
|
||||
Warning( "CBasePresence: UserSetContext failed.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Properties are (usually) numeric values that can be insterted into context strings.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UserSetProperty( unsigned int nUserIndex, unsigned int nPropertyId, unsigned int nBytes, const void *pvValue, bool bAsync )
|
||||
{
|
||||
if ( !xboxsystem->UserSetProperty( nUserIndex, nPropertyId, nBytes, pvValue, bAsync ) )
|
||||
{
|
||||
Warning( "CBasePresence: UserSetProperty failed.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get game session properties from matchmaking.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::SetupGameProperties( CUtlVector< XUSER_CONTEXT > &contexts, CUtlVector< XUSER_PROPERTY > &properties )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Convert a string to a presence ID.
|
||||
//-----------------------------------------------------------------------------
|
||||
uint CBasePresence::GetPresenceID( const char *pIdName )
|
||||
{
|
||||
Assert( 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Convert a presence ID to a string.
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBasePresence::GetPropertyIdString( const uint id )
|
||||
{
|
||||
Assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Get display string for a game property.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::GetPropertyDisplayString( uint id, uint value, char *pOutput, int nBytes )
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up for reporting stats to Live.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::StartStatsReporting( HANDLE handle, bool bArbitrated )
|
||||
{
|
||||
m_bArbitrated = bArbitrated;
|
||||
m_hSession = handle;
|
||||
m_bReportingStats = true;
|
||||
m_PlayerStats.RemoveAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set a specific stat property.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::SetStat( uint iPropertyId, int iPropertyValue, int dataType )
|
||||
{
|
||||
if ( m_bReportingStats )
|
||||
{
|
||||
XUSER_PROPERTY prop;
|
||||
prop.dwPropertyId = iPropertyId;
|
||||
prop.value.nData = iPropertyValue;
|
||||
prop.value.type = dataType;
|
||||
m_PlayerStats.AddToTail( prop );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Upload the stats to Live.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBasePresence::UploadStats()
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Debug support
|
||||
//---------------------------------------------------------
|
||||
void CBasePresence::DebugUserSetContext( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
UserSetContext( XBX_GetPrimaryUserId(), atoi( args.Arg( 1 ) ), atoi( args.Arg( 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_context <context id> <context value>\n" );
|
||||
}
|
||||
}
|
||||
void CBasePresence::DebugUserSetProperty( const CCommand &args )
|
||||
{
|
||||
if ( args.ArgC() == 3 )
|
||||
{
|
||||
int value = atoi( args.Arg( 2 ) );
|
||||
UserSetProperty( XBX_GetPrimaryUserId(), strtoul( args.Arg( 1 ), NULL, 0 ), sizeof(int), &value );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "user_property <property id> <property value>\n" );
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -9,7 +9,7 @@
|
||||
#include "cbase.h"
|
||||
#include "beamdraw.h"
|
||||
#include "enginesprite.h"
|
||||
#include "iviewrender_beams.h"
|
||||
#include "IViewRender_Beams.h"
|
||||
#include "view.h"
|
||||
#include "iviewrender.h"
|
||||
#include "engine/ivmodelinfo.h"
|
||||
@ -47,7 +47,7 @@ CEngineSprite *Draw_SetSpriteTexture( const model_t *pSpriteModel, int frame, in
|
||||
if ( ShouldDrawInWireFrameMode() || r_DrawBeams.GetInt() == 2 )
|
||||
{
|
||||
if ( !g_pBeamWireframeMaterial )
|
||||
g_pBeamWireframeMaterial = materials->FindMaterial( "shadertest/wireframevertexcolor", TEXTURE_GROUP_OTHER );
|
||||
g_pBeamWireframeMaterial = materials->FindMaterial( "debug/debugwireframevertexcolor", TEXTURE_GROUP_OTHER );
|
||||
pRenderContext->Bind( g_pBeamWireframeMaterial, NULL );
|
||||
return psprite;
|
||||
}
|
||||
@ -320,7 +320,7 @@ void DrawSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
float fadeFraction = fadeLength/ delta.Length();
|
||||
|
||||
// BUGBUG: This code generates NANs when fadeFraction is zero! REVIST!
|
||||
fadeFraction = clamp(fadeFraction,1.e-6f,1.f);
|
||||
fadeFraction = clamp(fadeFraction,1e-6,1);
|
||||
|
||||
// Choose two vectors that are perpendicular to the beam
|
||||
Vector perp1;
|
||||
@ -335,7 +335,6 @@ void DrawSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
{
|
||||
Assert( noiseIndex < (noise_divisions<<16) );
|
||||
BeamSeg_t curSeg;
|
||||
curSeg.m_flAlpha = 1;
|
||||
|
||||
fraction = i * div;
|
||||
|
||||
@ -371,7 +370,9 @@ void DrawSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
|
||||
brightness = 1;
|
||||
}
|
||||
|
||||
VectorScale( *((Vector*)color), brightness, curSeg.m_vColor );
|
||||
Vector vecTemp;
|
||||
VectorScale( *((Vector*)color), brightness, vecTemp );
|
||||
curSeg.SetColor( vecTemp, 1.0f );
|
||||
|
||||
// UNDONE: Make this a spline instead of just a line?
|
||||
VectorMA( source, fraction, delta, curSeg.m_vPos );
|
||||
@ -450,9 +451,9 @@ void CalcSegOrigin( Vector *vecOut, int iPoint, int noise_divisions, float *prgN
|
||||
{
|
||||
float s, c;
|
||||
SinCos( fraction*M_PI*length + freq, &s, &c );
|
||||
VectorMA( *vecOut, factor * s, MainViewUp(), *vecOut );
|
||||
VectorMA( *vecOut, factor * s, CurrentViewUp(), *vecOut );
|
||||
// Rotate the noise along the perpendicular axis a bit to keep the bolt from looking diagonal
|
||||
VectorMA( *vecOut, factor * c, MainViewRight(), *vecOut );
|
||||
VectorMA( *vecOut, factor * c, CurrentViewRight(), *vecOut );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -522,7 +523,7 @@ void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritem
|
||||
float fadeFraction = fadeLength/ delta.Length();
|
||||
|
||||
// BUGBUG: This code generates NANs when fadeFraction is zero! REVIST!
|
||||
fadeFraction = clamp(fadeFraction,1.e-6f,1.f);
|
||||
fadeFraction = clamp(fadeFraction,1e-6,1);
|
||||
|
||||
Vector perp;
|
||||
ComputeBeamPerpendicular( delta, &perp );
|
||||
@ -542,7 +543,6 @@ void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritem
|
||||
for ( i = 0; i < segments; i++ )
|
||||
{
|
||||
BeamSeg_t curSeg;
|
||||
curSeg.m_flAlpha = 1;
|
||||
|
||||
fraction = i * div;
|
||||
|
||||
@ -578,7 +578,9 @@ void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritem
|
||||
brightness = 1;
|
||||
}
|
||||
|
||||
VectorScale( *((Vector*)color), brightness, curSeg.m_vColor );
|
||||
Vector vecTemp;
|
||||
VectorScale( *((Vector*)color), brightness, vecTemp );
|
||||
curSeg.SetColor( vecTemp, 1.0f );
|
||||
|
||||
CalcSegOrigin( &curSeg.m_vPos, i, noise_divisions, prgNoise, source, delta, perp, segments, freq, scale, fraction, flags );
|
||||
|
||||
@ -589,7 +591,7 @@ void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritem
|
||||
curSeg.m_flWidth = ((fraction*(endWidth-startWidth))+startWidth) * 2;
|
||||
|
||||
// Reduce the width by the current number of branches we've had
|
||||
for ( int j = 0; j < iBranches; j++ )
|
||||
for ( int j = 0; i < iBranches; j++ )
|
||||
{
|
||||
curSeg.m_flWidth *= 0.5;
|
||||
}
|
||||
@ -614,12 +616,12 @@ void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritem
|
||||
|
||||
// Get an endpoint for the new branch
|
||||
vecStart = curSeg.m_vPos;
|
||||
vecEnd = source + delta + (MainViewUp() * 32) + (MainViewRight() * 32);
|
||||
vecEnd = source + delta + (CurrentViewUp() * 32) + (CurrentViewRight() * 32);
|
||||
vecEnd -= vecStart;
|
||||
|
||||
// Reduce the end width by the current number of branches we've had
|
||||
flEndWidth = endWidth;
|
||||
for ( int j = 0; j < iBranches; j++ )
|
||||
for ( int j = 0; i < iBranches; j++ )
|
||||
{
|
||||
flEndWidth *= 0.5;
|
||||
}
|
||||
@ -798,10 +800,9 @@ void DrawSplineSegs( int noise_divisions, float *prgNoise,
|
||||
brightness = 0;
|
||||
|
||||
BeamSeg_t seg;
|
||||
seg.m_flAlpha = 1;
|
||||
|
||||
VectorScale( color, brightness, scaledColor );
|
||||
seg.m_vColor.Init( scaledColor[0], scaledColor[1], scaledColor[2] );
|
||||
seg.SetColor( scaledColor[0], scaledColor[1], scaledColor[2], 1.0f );
|
||||
|
||||
|
||||
// -------------------------------------------------
|
||||
@ -1495,7 +1496,6 @@ void DrawBeamQuadratic( const Vector &start, const Vector &control, const Vector
|
||||
beamDraw.Start( pRenderContext, subdivisions+1, NULL );
|
||||
|
||||
BeamSeg_t seg;
|
||||
seg.m_flAlpha = 1.0;
|
||||
seg.m_flWidth = width;
|
||||
|
||||
float t = 0;
|
||||
@ -1513,11 +1513,12 @@ void DrawBeamQuadratic( const Vector &start, const Vector &control, const Vector
|
||||
if ( i == 0 || i == subdivisions )
|
||||
{
|
||||
// HACK: fade out the ends a bit
|
||||
seg.m_vColor = vec3_origin;
|
||||
seg.m_color.r = seg.m_color.g = seg.m_color.b = 0;
|
||||
seg.m_color.a = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
seg.m_vColor = color;
|
||||
seg.SetColor( color, 1.0f );
|
||||
}
|
||||
beamDraw.NextSeg( &seg );
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -41,10 +41,7 @@ public:
|
||||
virtual const matrix3x4_t &RenderableToWorldTransform();
|
||||
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
|
||||
virtual bool ShouldDraw( void );
|
||||
virtual bool IsTransparent( void );
|
||||
virtual int DrawModel( int flags );
|
||||
virtual void ComputeFxBlend( );
|
||||
virtual int GetFxBlend( );
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
|
||||
// Resets the beam state
|
||||
void Reset();
|
||||
@ -121,10 +118,7 @@ public:
|
||||
|
||||
float m_flHDRColorScale;
|
||||
|
||||
#ifdef PORTAL
|
||||
bool m_bDrawInMainRender;
|
||||
bool m_bDrawInPortalRender;
|
||||
#endif //#ifdef PORTAL
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -22,7 +22,6 @@ CBoneMergeCache::CBoneMergeCache()
|
||||
m_pOwner = NULL;
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
@ -32,52 +31,40 @@ void CBoneMergeCache::Init( C_BaseAnimating *pOwner )
|
||||
m_pOwner = pOwner;
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
|
||||
void CBoneMergeCache::UpdateCache()
|
||||
{
|
||||
CStudioHdr *pOwnerHdr = m_pOwner ? m_pOwner->GetModelPtr() : NULL;
|
||||
if ( !pOwnerHdr )
|
||||
{
|
||||
if ( m_pOwnerHdr )
|
||||
{
|
||||
// Owner's model got swapped out
|
||||
m_MergedBones.Purge();
|
||||
m_BoneMergeBits.Purge();
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
if ( !m_pOwner )
|
||||
return;
|
||||
|
||||
CStudioHdr *pOwnerHdr = m_pOwner->GetModelPtr();
|
||||
if ( !pOwnerHdr )
|
||||
return;
|
||||
}
|
||||
|
||||
C_BaseAnimating *pTestFollow = m_pOwner->FindFollowedEntity();
|
||||
CStudioHdr *pTestHdr = (pTestFollow ? pTestFollow->GetModelPtr() : NULL);
|
||||
const studiohdr_t *pTestStudioHDR = (pTestHdr ? pTestHdr->GetRenderHdr() : NULL);
|
||||
if ( pTestFollow != m_pFollow || pTestHdr != m_pFollowHdr || pTestStudioHDR != m_pFollowRenderHdr || pOwnerHdr != m_pOwnerHdr )
|
||||
// if the follow parent has changed, or any of the underlying models has changed, reset the MergedBones list
|
||||
if ( pTestFollow != m_pFollow || pTestHdr != m_pFollowHdr || pOwnerHdr != m_pOwnerHdr )
|
||||
{
|
||||
m_MergedBones.Purge();
|
||||
m_BoneMergeBits.Purge();
|
||||
|
||||
// Update the cache.
|
||||
if ( pTestFollow && pTestHdr && pOwnerHdr )
|
||||
{
|
||||
m_pFollow = pTestFollow;
|
||||
m_pFollowHdr = pTestHdr;
|
||||
m_pFollowRenderHdr = pTestStudioHDR;
|
||||
m_pOwnerHdr = pOwnerHdr;
|
||||
|
||||
m_BoneMergeBits.SetSize( pOwnerHdr->numbones() / 8 + 1 );
|
||||
memset( m_BoneMergeBits.Base(), 0, m_BoneMergeBits.Count() );
|
||||
m_BoneMergeBits.Resize( pOwnerHdr->numbones() );
|
||||
m_BoneMergeBits.ClearAll();
|
||||
|
||||
mstudiobone_t *pOwnerBones = m_pOwnerHdr->pBone( 0 );
|
||||
|
||||
m_nFollowBoneSetupMask = BONE_USED_BY_BONE_MERGE;
|
||||
const bool bDeveloperDebugPrints = developer.GetBool();
|
||||
for ( int i = 0; i < m_pOwnerHdr->numbones(); i++ )
|
||||
{
|
||||
int parentBoneIndex = Studio_BoneIndexByName( m_pFollowHdr, pOwnerBones[i].pszName() );
|
||||
@ -89,14 +76,32 @@ void CBoneMergeCache::UpdateCache()
|
||||
mergedBone.m_iMyBone = i;
|
||||
mergedBone.m_iParentBone = parentBoneIndex;
|
||||
m_MergedBones.AddToTail( mergedBone );
|
||||
m_BoneMergeBits.Set( i );
|
||||
|
||||
m_BoneMergeBits[i>>3] |= ( 1 << ( i & 7 ) );
|
||||
|
||||
// Warn for performance-negative ad hoc bone merges. They're bad. Don't do them.
|
||||
if ( ( m_pFollowHdr->boneFlags( parentBoneIndex ) & BONE_USED_BY_BONE_MERGE ) == 0 )
|
||||
{
|
||||
m_nFollowBoneSetupMask = BONE_USED_BY_ANYTHING;
|
||||
// Warning("Performance warning: Merge with '%s'. Mark bone '%s' in model '%s' as being used by bone merge in the .qc!\n",
|
||||
// pOwnerHdr->pszName(), m_pFollowHdr->pBone( parentBoneIndex )->pszName(), m_pFollowHdr->pszName() );
|
||||
// go ahead and mark the bone and its parents
|
||||
int n = parentBoneIndex;
|
||||
while (n != -1)
|
||||
{
|
||||
m_pFollowHdr->setBoneFlags( n, BONE_USED_BY_BONE_MERGE );
|
||||
n = m_pFollowHdr->boneParent( n );
|
||||
}
|
||||
// dump out a warning
|
||||
if ( bDeveloperDebugPrints )
|
||||
{
|
||||
char sz[ 256 ];
|
||||
Q_snprintf( sz, sizeof( sz ), "Performance warning: Add $bonemerge \"%s\" to QC that builds \"%s\"\n",
|
||||
m_pFollowHdr->pBone( parentBoneIndex )->pszName(), m_pFollowHdr->pszName() );
|
||||
|
||||
static CUtlSymbolTableMT s_FollowerWarnings;
|
||||
if ( UTL_INVAL_SYMBOL == s_FollowerWarnings.Find( sz ) )
|
||||
{
|
||||
s_FollowerWarnings.AddString( sz );
|
||||
Warning( "%s", sz );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,19 +115,13 @@ void CBoneMergeCache::UpdateCache()
|
||||
{
|
||||
m_pFollow = NULL;
|
||||
m_pFollowHdr = NULL;
|
||||
m_pFollowRenderHdr = NULL;
|
||||
m_pOwnerHdr = NULL;
|
||||
m_nFollowBoneSetupMask = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
ConVar r_captain_canteen_is_angry ( "r_captain_canteen_is_angry", "1" );
|
||||
#endif
|
||||
|
||||
void CBoneMergeCache::MergeMatchingBones( int boneMask )
|
||||
void CBoneMergeCache::MergeMatchingBones( int boneMask, CBoneBitList &boneComputed )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
@ -131,108 +130,27 @@ void CBoneMergeCache::MergeMatchingBones( int boneMask )
|
||||
return;
|
||||
|
||||
// Have the entity we're following setup its bones.
|
||||
bool bWorked = m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
// We suspect there's some cases where SetupBones couldn't do its thing, and then this causes Captain Canteen.
|
||||
Assert ( bWorked );
|
||||
if ( !bWorked )
|
||||
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
// Usually this means your parent is invisible or gone or whatever.
|
||||
// This routine has no way to tell its caller not to draw itself unfortunately.
|
||||
// But we can shrink all the bones down to zero size.
|
||||
// But it might still spawn particle systems? :-(
|
||||
matrix3x4_t NewBone;
|
||||
MatrixScaleByZero ( NewBone );
|
||||
MatrixSetTranslation ( Vector ( 0.0f, 0.0f, 0.0f ), NewBone );
|
||||
#ifdef STAGING_ONLY
|
||||
if ( r_captain_canteen_is_angry.GetBool() )
|
||||
{
|
||||
// We actually want to see when Captain Canteen happened, and make it really obvious that (a) he was here and (b) this code would have fixed him.
|
||||
float HowAngry = 20.0f; // Leon's getting larger!
|
||||
MatrixSetColumn ( Vector ( HowAngry, 0.0f, 0.0f ), 0, NewBone );
|
||||
MatrixSetColumn ( Vector ( 0.0f, HowAngry, 0.0f ), 1, NewBone );
|
||||
MatrixSetColumn ( Vector ( 0.0f, 0.0f, HowAngry ), 2, NewBone );
|
||||
}
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
#ifdef SWARM_DLL
|
||||
matrix3x4_t matPitchUp;
|
||||
AngleMatrix( QAngle( 15, 0, 0 ), matPitchUp );
|
||||
ConcatTransforms( m_pFollow->GetBone( iParentBone ), matPitchUp, m_pOwner->GetBoneForWrite( iOwnerBone ) );
|
||||
#else
|
||||
MatrixCopy(m_pFollow->GetBone(iParentBone), m_pOwner->GetBoneForWrite(iOwnerBone));
|
||||
#endif
|
||||
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
m_pOwner->GetBoneForWrite( iOwnerBone ) = NewBone;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
MatrixCopy( m_pFollow->GetBone( iParentBone ), m_pOwner->GetBoneForWrite( iOwnerBone ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// copy bones instead of matrices
|
||||
void CBoneMergeCache::CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return;
|
||||
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
if ( m_pOwnerHdr->boneParent( iOwnerBone ) == -1 || m_pFollowHdr->boneParent( iParentBone ) == -1 )
|
||||
continue;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
childPos[ iOwnerBone ] = parentPos[ iParentBone ];
|
||||
childQ[ iOwnerBone ] = parentQ[ iParentBone ];
|
||||
}
|
||||
}
|
||||
|
||||
void CBoneMergeCache::CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return;
|
||||
|
||||
// Now copy the bone matrices.
|
||||
for ( int i=0; i < m_MergedBones.Count(); i++ )
|
||||
{
|
||||
int iOwnerBone = m_MergedBones[i].m_iMyBone;
|
||||
int iParentBone = m_MergedBones[i].m_iParentBone;
|
||||
|
||||
if ( m_pOwnerHdr->boneParent( iOwnerBone ) == -1 || m_pFollowHdr->boneParent( iParentBone ) == -1 )
|
||||
continue;
|
||||
|
||||
// Only update bones reference by the bone mask.
|
||||
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
|
||||
continue;
|
||||
|
||||
parentPos[ iParentBone ] = childPos[ iOwnerBone ];
|
||||
parentQ[ iParentBone ] = childQ[ iOwnerBone ];
|
||||
boneComputed.Set( i );
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,6 +173,7 @@ bool CBoneMergeCache::GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles )
|
||||
// all over the place, then this won't get the right results.
|
||||
|
||||
// Get mFollowBone.
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 );
|
||||
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
const matrix3x4_t &mFollowBone = m_pFollow->GetBone( m_MergedBones[0].m_iParentBone );
|
||||
|
||||
@ -271,18 +190,3 @@ bool CBoneMergeCache::GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoneMergeCache::GetRootBone( matrix3x4_t &rootBone )
|
||||
{
|
||||
UpdateCache();
|
||||
|
||||
// If this is set, then all the other cache data is set.
|
||||
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
|
||||
return false;
|
||||
|
||||
// Get mFollowBone.
|
||||
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
|
||||
rootBone = m_pFollow->GetBone( m_MergedBones[0].m_iParentBone );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
class C_BaseAnimating;
|
||||
class CStudioHdr;
|
||||
|
||||
class CBoneBitList;
|
||||
|
||||
#include "mathlib/vector.h"
|
||||
|
||||
@ -31,11 +31,7 @@ public:
|
||||
|
||||
// This copies the transform from all bones in the followed entity that have
|
||||
// names that match our bones.
|
||||
void MergeMatchingBones( int boneMask );
|
||||
|
||||
// copy bones instead of matrices
|
||||
void CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask );
|
||||
void CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask );
|
||||
virtual void MergeMatchingBones( int boneMask, CBoneBitList &boneComputed );
|
||||
|
||||
// Returns true if the specified bone is one that gets merged in MergeMatchingBones.
|
||||
int IsBoneMerged( int iBone ) const;
|
||||
@ -43,9 +39,8 @@ public:
|
||||
// Gets the origin for the first merge bone on the parent.
|
||||
bool GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles );
|
||||
|
||||
bool GetRootBone( matrix3x4_t &rootBone );
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
// This is the entity that we're keeping the cache updated for.
|
||||
C_BaseAnimating *m_pOwner;
|
||||
@ -54,7 +49,6 @@ private:
|
||||
// These are either all valid pointers or all NULL.
|
||||
C_BaseAnimating *m_pFollow;
|
||||
CStudioHdr *m_pFollowHdr;
|
||||
const studiohdr_t *m_pFollowRenderHdr;
|
||||
CStudioHdr *m_pOwnerHdr;
|
||||
|
||||
// This is the mask we need to use to set up bones on the followed entity to do the bone merge
|
||||
@ -69,14 +63,14 @@ private:
|
||||
};
|
||||
|
||||
CUtlVector<CMergedBone> m_MergedBones;
|
||||
CUtlVector<unsigned char> m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
|
||||
CVarBitVec m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
|
||||
};
|
||||
|
||||
|
||||
inline int CBoneMergeCache::IsBoneMerged( int iBone ) const
|
||||
{
|
||||
if ( m_pOwnerHdr )
|
||||
return m_BoneMergeBits[iBone >> 3] & ( 1 << ( iBone & 7 ) );
|
||||
return m_BoneMergeBits.Get( iBone );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========== Copyright © 2006, Valve Corporation, All rights reserved. ========
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
@ -1,12 +1,12 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_ai_basenpc.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "c_AI_BaseNPC.h"
|
||||
#include "engine/IVDebugOverlay.h"
|
||||
|
||||
#if defined( HL2_DLL ) || defined( HL2_EPISODIC )
|
||||
#include "c_basehlplayer.h"
|
||||
@ -37,8 +37,7 @@ extern ConVar cl_npc_speedmod_intime;
|
||||
|
||||
bool NPC_IsImportantNPC( C_BaseAnimating *pAnimating )
|
||||
{
|
||||
C_AI_BaseNPC *pBaseNPC = dynamic_cast < C_AI_BaseNPC* > ( pAnimating );
|
||||
|
||||
C_AI_BaseNPC *pBaseNPC = pAnimating->MyNPCPointer();
|
||||
if ( pBaseNPC == NULL )
|
||||
return false;
|
||||
|
||||
@ -153,7 +152,7 @@ void C_AI_BaseNPC::OnDataChanged( DataUpdateType_t type )
|
||||
}
|
||||
}
|
||||
|
||||
void C_AI_BaseNPC::GetRagdollInitBoneArrays( matrix3x4_t *pDeltaBones0, matrix3x4_t *pDeltaBones1, matrix3x4_t *pCurrentBones, float boneDt )
|
||||
void C_AI_BaseNPC::GetRagdollInitBoneArrays( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt )
|
||||
{
|
||||
ForceSetupBonesAtTime( pDeltaBones0, gpGlobals->curtime - boneDt );
|
||||
GetRagdollCurSequenceWithDeathPose( this, pDeltaBones1, gpGlobals->curtime, m_iDeathPose, m_iDeathFrame );
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -29,7 +29,7 @@ public:
|
||||
bool ShouldAvoidObstacle( void ){ return m_bPerformAvoidance; }
|
||||
virtual bool AddRagdollToFadeQueue( void ) { return m_bFadeCorpse; }
|
||||
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4_t *pDeltaBones0, matrix3x4_t *pDeltaBones1, matrix3x4_t *pCurrentBones, float boneDt );
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt );
|
||||
|
||||
int GetDeathPose( void ) { return m_iDeathPose; }
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
#ifndef C_BASEANIMATING_H
|
||||
#define C_BASEANIMATING_H
|
||||
|
||||
@ -14,18 +14,19 @@
|
||||
|
||||
#include "c_baseentity.h"
|
||||
#include "studio.h"
|
||||
#include "utlvector.h"
|
||||
#include "UtlVector.h"
|
||||
#include "ragdoll.h"
|
||||
#include "mouthinfo.h"
|
||||
// Shared activities
|
||||
#include "ai_activity.h"
|
||||
#include "animationlayer.h"
|
||||
#include "sequence_Transitioner.h"
|
||||
#include "sequence_transitioner.h"
|
||||
#include "bone_accessor.h"
|
||||
#include "bone_merge_cache.h"
|
||||
#include "ragdoll_shared.h"
|
||||
#include "tier0/threadtools.h"
|
||||
#include "datacache/idatacache.h"
|
||||
#include "toolframework/itoolframework.h"
|
||||
|
||||
#define LIPSYNC_POSEPARAM_NAME "mouth"
|
||||
#define NUM_HITBOX_FIRES 10
|
||||
@ -38,6 +39,7 @@ class C_BaseClientShader
|
||||
*/
|
||||
|
||||
class IRagdoll;
|
||||
class C_ClientRagdoll;
|
||||
class CIKContext;
|
||||
class CIKState;
|
||||
class ConVar;
|
||||
@ -51,7 +53,7 @@ FORWARD_DECLARE_HANDLE( memhandle_t );
|
||||
typedef unsigned short MDLHandle_t;
|
||||
|
||||
extern ConVar vcollide_wireframe;
|
||||
|
||||
extern IDataCache *datacache;
|
||||
|
||||
struct ClientModelRenderInfo_t : public ModelRenderInfo_t
|
||||
{
|
||||
@ -88,13 +90,15 @@ typedef unsigned int ClientSideAnimationListHandle_t;
|
||||
#define INVALID_CLIENTSIDEANIMATION_LIST_HANDLE (ClientSideAnimationListHandle_t)~0
|
||||
|
||||
|
||||
class C_BaseAnimating : public C_BaseEntity, private IModelLoadCallback
|
||||
class C_BaseAnimating : public C_BaseEntity, public IClientModelRenderable
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BaseAnimating, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_INTERPOLATION();
|
||||
DECLARE_FRIEND_DATADESC_ACCESS();
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
|
||||
enum
|
||||
{
|
||||
@ -102,21 +106,28 @@ public:
|
||||
NUM_BONECTRLS = 4
|
||||
};
|
||||
|
||||
// Inherited from IClientUnknown
|
||||
public:
|
||||
virtual IClientModelRenderable* GetClientModelRenderable();
|
||||
|
||||
// Inherited from IClientModelRenderable
|
||||
public:
|
||||
virtual bool GetRenderData( void *pData, ModelDataCategory_t nCategory );
|
||||
|
||||
public:
|
||||
C_BaseAnimating();
|
||||
~C_BaseAnimating();
|
||||
|
||||
virtual C_BaseAnimating* GetBaseAnimating() { return this; }
|
||||
|
||||
bool UsesPowerOfTwoFrameBufferTexture( void );
|
||||
int GetRenderFlags( void );
|
||||
|
||||
virtual bool Interpolate( float currentTime );
|
||||
virtual void Simulate();
|
||||
virtual bool Simulate();
|
||||
virtual void Release();
|
||||
|
||||
float GetAnimTimeInterval( void ) const;
|
||||
|
||||
virtual unsigned char GetClientSideFade( void );
|
||||
|
||||
// Get bone controller values.
|
||||
virtual void GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS]);
|
||||
virtual float SetBoneController ( int iController, float flValue );
|
||||
@ -138,17 +149,18 @@ public:
|
||||
// base model functionality
|
||||
float ClampCycle( float cycle, bool isLooping );
|
||||
virtual void GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] );
|
||||
virtual void CalcBoneMerge( CStudioHdr *hdr, int boneMask, CBoneBitList &boneComputed );
|
||||
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
|
||||
void BuildJiggleTransformations( int boneIndex, const mstudiojigglebone_t *jiggleParams, const matrix3x4_t &goalMX );
|
||||
virtual void ApplyBoneMatrixTransform( matrix3x4_t& transform );
|
||||
virtual int VPhysicsGetObjectList( IPhysicsObject **pList, int listMax );
|
||||
|
||||
// model specific
|
||||
virtual bool SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime );
|
||||
virtual bool SetupBones( matrix3x4a_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime );
|
||||
virtual void UpdateIKLocks( float currentTime );
|
||||
virtual void CalculateIKLocks( float currentTime );
|
||||
virtual bool ShouldDraw();
|
||||
virtual int DrawModel( int flags );
|
||||
virtual int InternalDrawModel( int flags );
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
virtual int InternalDrawModel( int flags, const RenderableInstance_t &instance );
|
||||
virtual bool OnInternalDrawModel( ClientModelRenderInfo_t *pInfo );
|
||||
virtual bool OnPostInternalDrawModel( ClientModelRenderInfo_t *pInfo );
|
||||
void DoInternalDrawModel( ClientModelRenderInfo_t *pInfo, DrawModelState_t *pState, matrix3x4_t *pBoneToWorldArray = NULL );
|
||||
@ -161,34 +173,32 @@ public:
|
||||
virtual void DoAnimationEvents( CStudioHdr *pStudio );
|
||||
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
virtual void FireObsoleteEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
virtual const char* ModifyEventParticles( const char* token ) { return token; }
|
||||
|
||||
// Parses and distributes muzzle flash events
|
||||
virtual bool DispatchMuzzleEffect( const char *options, bool isFirstPerson );
|
||||
virtual void EjectParticleBrass( const char *pEffectName, const int iAttachment );
|
||||
|
||||
// virtual void AllocateMaterials( void );
|
||||
// virtual void FreeMaterials( void );
|
||||
|
||||
virtual void ValidateModelIndex( void );
|
||||
virtual CStudioHdr *OnNewModel( void );
|
||||
CStudioHdr *GetModelPtr() const;
|
||||
void InvalidateMdlCache();
|
||||
|
||||
virtual void SetPredictable( bool state );
|
||||
void UseClientSideAnimation();
|
||||
bool IsUsingClientSideAnimation() { return m_bClientSideAnimation; }
|
||||
|
||||
// C_BaseClientShader **p_ClientShaders;
|
||||
|
||||
virtual void StandardBlendingRules( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
|
||||
virtual void StandardBlendingRules( CStudioHdr *pStudioHdr, Vector pos[], QuaternionAligned q[], float currentTime, int boneMask );
|
||||
void UnragdollBlend( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime );
|
||||
|
||||
void MaintainSequenceTransitions( IBoneSetup &boneSetup, float flCycle, Vector pos[], Quaternion q[] );
|
||||
virtual void AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Quaternion q[], float currentTime );
|
||||
|
||||
virtual void ChildLayerBlend( Vector pos[], Quaternion q[], float currentTime, int boneMask );
|
||||
|
||||
// Attachments
|
||||
int LookupAttachment( const char *pAttachmentName );
|
||||
virtual int LookupAttachment( const char *pAttachmentName );
|
||||
int LookupRandomAttachment( const char *pAttachmentNameSubstring );
|
||||
|
||||
int LookupPoseParameter( CStudioHdr *pStudioHdr, const char *szName );
|
||||
@ -198,49 +208,25 @@ public:
|
||||
inline float SetPoseParameter( const char *szName, float flValue ) { return SetPoseParameter( GetModelPtr(), szName, flValue ); }
|
||||
float SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue );
|
||||
inline float SetPoseParameter( int iParameter, float flValue ) { return SetPoseParameter( GetModelPtr(), iParameter, flValue ); }
|
||||
float GetPoseParameter( int iParameter );
|
||||
|
||||
float GetPoseParameter( int iPoseParameter );
|
||||
|
||||
float GetPoseParameterRaw( int iPoseParameter ); // returns raw 0..1 value
|
||||
bool GetPoseParameterRange( int iPoseParameter, float &minValue, float &maxValue );
|
||||
|
||||
int LookupBone( const char *szName );
|
||||
void GetBonePosition( int iBone, Vector &origin, QAngle &angles );
|
||||
void GetBoneTransform( int iBone, matrix3x4_t &pBoneToWorld );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [menglish] Finds the bone associated with the given hitbox
|
||||
//=============================================================================
|
||||
|
||||
int GetHitboxBone( int hitboxIndex );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
// Bone attachments
|
||||
virtual void AttachEntityToBone( C_BaseAnimating* attachTarget, int boneIndexAttached=-1, Vector bonePosition=Vector(0,0,0), QAngle boneAngles=QAngle(0,0,0) );
|
||||
void AddBoneAttachment( C_BaseAnimating* newBoneAttachment );
|
||||
void RemoveBoneAttachment( C_BaseAnimating* boneAttachment );
|
||||
void RemoveBoneAttachments();
|
||||
void DestroyBoneAttachments();
|
||||
void MoveBoneAttachments( C_BaseAnimating* attachTarget );
|
||||
int GetNumBoneAttachments();
|
||||
C_BaseAnimating* GetBoneAttachment( int i );
|
||||
virtual void NotifyBoneAttached( C_BaseAnimating* attachTarget );
|
||||
virtual void UpdateBoneAttachments( void );
|
||||
|
||||
|
||||
void CopySequenceTransitions( C_BaseAnimating *pCopyFrom );
|
||||
//bool solveIK(float a, float b, const Vector &Foot, const Vector &Knee1, Vector &Knee2);
|
||||
//void DebugIK( mstudioikchain_t *pikchain );
|
||||
|
||||
virtual void PreDataUpdate( DataUpdateType_t updateType );
|
||||
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||
virtual int RestoreData( const char *context, int slot, int type );
|
||||
|
||||
|
||||
virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void AddEntity( void );
|
||||
|
||||
// This can be used to force client side animation to be on. Only use if you know what you're doing!
|
||||
// Normally, the server entity should set this.
|
||||
@ -268,14 +254,13 @@ public:
|
||||
virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
|
||||
virtual bool GetAttachment( int number, matrix3x4_t &matrix );
|
||||
virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
|
||||
virtual void InvalidateAttachments();
|
||||
|
||||
// Returns the attachment in local space
|
||||
bool GetAttachmentLocal( int iAttachment, matrix3x4_t &attachmentToLocal );
|
||||
bool GetAttachmentLocal( int iAttachment, Vector &origin, QAngle &angles );
|
||||
bool GetAttachmentLocal( int iAttachment, Vector &origin );
|
||||
|
||||
bool GetRootBone( matrix3x4_t &rootBone );
|
||||
|
||||
// Should this object cast render-to-texture shadows?
|
||||
virtual ShadowType_t ShadowCastType();
|
||||
|
||||
@ -285,12 +270,15 @@ public:
|
||||
virtual bool TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
|
||||
virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
|
||||
|
||||
// returns true if we are of type C_ClientRagdoll
|
||||
virtual bool IsClientRagdoll() const { return false; }
|
||||
|
||||
// returns true if we're currently being ragdolled
|
||||
bool IsRagdoll() const;
|
||||
bool IsAboutToRagdoll() const;
|
||||
virtual C_BaseAnimating *BecomeRagdollOnClient();
|
||||
virtual C_ClientRagdoll *CreateClientRagdoll( bool bRestoring = false );
|
||||
C_BaseAnimating *CreateRagdollCopy();
|
||||
bool InitAsClientRagdoll( const matrix3x4_t *pDeltaBones0, const matrix3x4_t *pDeltaBones1, const matrix3x4_t *pCurrentBonePosition, float boneDt, bool bFixedConstraints=false );
|
||||
bool InitAsClientRagdoll( const matrix3x4_t *pDeltaBones0, const matrix3x4_t *pDeltaBones1, const matrix3x4_t *pCurrentBonePosition, float boneDt );
|
||||
void IgniteRagdoll( C_BaseAnimating *pSource );
|
||||
void TransferDissolveFrom( C_BaseAnimating *pSource );
|
||||
virtual void SaveRagdollInfo( int numbones, const matrix3x4_t &cameraTransform, CBoneAccessor &pBoneToWorld );
|
||||
@ -298,42 +286,44 @@ public:
|
||||
virtual void Clear( void );
|
||||
void ClearRagdoll();
|
||||
void CreateUnragdollInfo( C_BaseAnimating *pRagdoll );
|
||||
void ForceSetupBonesAtTime( matrix3x4_t *pBonesOut, float flTime );
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4_t *pDeltaBones0, matrix3x4_t *pDeltaBones1, matrix3x4_t *pCurrentBones, float boneDt );
|
||||
void ForceSetupBonesAtTime( matrix3x4a_t *pBonesOut, float flTime );
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt );
|
||||
|
||||
// For shadows rendering the correct body + sequence...
|
||||
virtual int GetBody() { return m_nBody; }
|
||||
virtual int GetSkin() { return m_nSkin; }
|
||||
|
||||
bool IsOnFire() { return ( (GetFlags() & FL_ONFIRE) != 0 ); }
|
||||
bool IsOnFire() { return ( (GetFlags() & FL_ONFIRE) != 0 ); }
|
||||
float GetFrozenAmount() { return m_flFrozen; }
|
||||
|
||||
inline float GetPlaybackRate();
|
||||
inline float GetPlaybackRate() const;
|
||||
inline void SetPlaybackRate( float rate );
|
||||
|
||||
void SetModelScale( float scale, float change_duration = 0.0f );
|
||||
float GetModelScale() const { return m_flModelScale; }
|
||||
void SetModelScale( float scale );
|
||||
inline float GetModelScale() const { return m_flModelScale; }
|
||||
inline bool IsModelScaleFractional() const; /// very fast way to ask if the model scale is < 1.0f (faster than if (GetModelScale() < 1.0f) )
|
||||
inline bool IsModelScaled() const;
|
||||
void UpdateModelScale( void );
|
||||
virtual void RefreshCollisionBounds( void );
|
||||
|
||||
int GetSequence();
|
||||
virtual void SetSequence(int nSequence);
|
||||
void SetSequence(int nSequence);
|
||||
inline void ResetSequence(int nSequence);
|
||||
void OnNewSequence( );
|
||||
float GetSequenceGroundSpeed( CStudioHdr *pStudioHdr, int iSequence );
|
||||
inline float GetSequenceGroundSpeed( int iSequence ) { return GetSequenceGroundSpeed(GetModelPtr(), iSequence); }
|
||||
bool IsSequenceLooping( CStudioHdr *pStudioHdr, int iSequence );
|
||||
inline bool IsSequenceLooping( int iSequence ) { return IsSequenceLooping(GetModelPtr(),iSequence); }
|
||||
float GetSequenceMoveDist( CStudioHdr *pStudioHdr, int iSequence );
|
||||
void GetSequenceLinearMotion( int iSequence, Vector *pVec );
|
||||
float GetSequenceLinearMotionAndDuration( int iSequence, Vector *pVec );
|
||||
bool GetSequenceMovement( int nSequence, float fromCycle, float toCycle, Vector &deltaPosition, QAngle &deltaAngles );
|
||||
void GetBlendedLinearVelocity( Vector *pVec );
|
||||
void SetMovementPoseParams( const Vector &vecLocalVelocity, int iMoveX, int iMoveY, int iXSign = 1, int iYSign = 1 );
|
||||
int LookupSequence ( const char *label );
|
||||
int LookupActivity( const char *label );
|
||||
char const *GetSequenceName( int iSequence );
|
||||
char const *GetSequenceActivityName( int iSequence );
|
||||
Activity GetSequenceActivity( int iSequence );
|
||||
KeyValues *GetSequenceKeyValues( int iSequence );
|
||||
virtual void StudioFrameAdvance(); // advance animation frame to some time in the future
|
||||
void ExtractBbox( int nSequence, Vector &mins, Vector &maxs );
|
||||
|
||||
// Clientside animation
|
||||
virtual float FrameAdvance( float flInterval = 0.0f );
|
||||
@ -341,8 +331,8 @@ public:
|
||||
virtual void UpdateClientSideAnimation();
|
||||
void ClientSideAnimationChanged();
|
||||
virtual unsigned int ComputeClientSideAnimationFlags();
|
||||
|
||||
virtual void ResetClientsideFrame( void ) { SetCycle( 0 ); }
|
||||
float GetGroundSpeed( void ) { return m_flGroundSpeed; }
|
||||
virtual void ReachedEndOfSequence() { return; }
|
||||
|
||||
void SetCycle( float flCycle );
|
||||
float GetCycle() const;
|
||||
@ -350,18 +340,21 @@ public:
|
||||
void SetBodygroup( int iGroup, int iValue );
|
||||
int GetBodygroup( int iGroup );
|
||||
|
||||
void SetSkin( int iSkin );
|
||||
void SetBody( int iBody );
|
||||
|
||||
const char *GetBodygroupName( int iGroup );
|
||||
int FindBodygroupByName( const char *name );
|
||||
int GetBodygroupCount( int iGroup );
|
||||
int GetNumBodyGroups( void );
|
||||
|
||||
class CBoneCache *GetBoneCache( CStudioHdr *pStudioHdr );
|
||||
void SetHitboxSet( int setnum );
|
||||
void SetHitboxSetByName( const char *setname );
|
||||
int GetHitboxSet( void );
|
||||
char const *GetHitboxSetName( void );
|
||||
int GetHitboxSetCount( void );
|
||||
void DrawClientHitboxes( float duration = 0.0f, bool monocolor = false );
|
||||
void DrawSkeleton( CStudioHdr const* pHdr, int iBoneMask ) const;
|
||||
|
||||
C_BaseAnimating* FindFollowedEntity();
|
||||
|
||||
@ -385,8 +378,9 @@ public:
|
||||
void GetCachedBoneMatrix( int boneIndex, matrix3x4_t &out );
|
||||
|
||||
// Wrappers for CBoneAccessor.
|
||||
const matrix3x4_t& GetBone( int iBone ) const;
|
||||
matrix3x4_t& GetBoneForWrite( int iBone );
|
||||
const matrix3x4a_t& GetBone( int iBone ) const;
|
||||
matrix3x4a_t& GetBoneForWrite( int iBone );
|
||||
matrix3x4a_t* GetBoneArrayForWrite();
|
||||
|
||||
// Used for debugging. Will produce asserts if someone tries to setup bones or
|
||||
// attachments before it's allowed.
|
||||
@ -400,8 +394,11 @@ public:
|
||||
static void PushAllowBoneAccess( bool bAllowForNormalModels, bool bAllowForViewModels, char const *tagPush );
|
||||
static void PopBoneAccess( char const *tagPop );
|
||||
static void ThreadedBoneSetup();
|
||||
static bool InThreadedBoneSetup();
|
||||
static void InitBoneSetupThreadPool();
|
||||
static void ShutdownBoneSetupThreadPool();
|
||||
void MarkForThreadedBoneSetup();
|
||||
static void SetupBonesOnBaseAnimating( C_BaseAnimating *&pBaseAnimating );
|
||||
|
||||
// Invalidate bone caches so all SetupBones() calls force bone transforms to be regenerated.
|
||||
static void InvalidateBoneCaches();
|
||||
@ -424,11 +421,12 @@ public:
|
||||
void InitModelEffects( void );
|
||||
|
||||
// Sometimes the server wants to update the client's cycle to get the two to run in sync (for proper hit detection)
|
||||
virtual void SetServerIntendedCycle( float intended ) { (void)intended; }
|
||||
virtual void SetServerIntendedCycle( float intended ) { intended; }
|
||||
virtual float GetServerIntendedCycle( void ) { return -1.0f; }
|
||||
|
||||
// For prediction
|
||||
int SelectWeightedSequence ( int activity );
|
||||
int SelectWeightedSequenceFromModifiers( Activity activity, CUtlSymbol *pActivityModifiers, int iModifierCount );
|
||||
void ResetSequenceInfo( void );
|
||||
float SequenceDuration( void );
|
||||
float SequenceDuration( CStudioHdr *pStudioHdr, int iSequence );
|
||||
@ -443,15 +441,23 @@ public:
|
||||
void SetReceivedSequence( void );
|
||||
virtual bool ShouldResetSequenceOnNewModel( void );
|
||||
|
||||
// View models say yes to this.
|
||||
virtual bool IsViewModel() const;
|
||||
|
||||
// viewmodel or viewmodelattachmentmodel or lowerbody
|
||||
virtual bool IsViewModelOrAttachment() const;
|
||||
|
||||
void EnableJiggleBones( void );
|
||||
void DisableJiggleBones( void );
|
||||
|
||||
void ScriptSetPoseParameter( const char *szName, float fValue );
|
||||
|
||||
protected:
|
||||
// View models scale their attachment positions to account for FOV. To get the unmodified
|
||||
// attachment position (like if you're rendering something else during the view model's DrawModel call),
|
||||
// use TransformViewModelAttachmentToWorld.
|
||||
virtual void FormatViewModelAttachment( int nAttachment, matrix3x4_t &attachmentToWorld ) {}
|
||||
|
||||
// View models say yes to this.
|
||||
bool IsBoneAccessAllowed() const;
|
||||
CMouthInfo& MouthInfo();
|
||||
|
||||
@ -463,6 +469,12 @@ protected:
|
||||
|
||||
virtual bool CalcAttachments();
|
||||
|
||||
virtual bool ComputeStencilState( ShaderStencilState_t *pStencilState );
|
||||
|
||||
virtual bool WantsInterpolatedVars() { return true; }
|
||||
|
||||
virtual void ResetSequenceLooping() { m_bSequenceFinished = false; }
|
||||
|
||||
private:
|
||||
// This method should return true if the bones have changed + SetupBones needs to be called
|
||||
virtual float LastBoneChangedTime() { return FLT_MAX; }
|
||||
@ -473,32 +485,58 @@ private:
|
||||
void TermRopes();
|
||||
|
||||
void DelayedInitModelEffects( void );
|
||||
void ParseModelEffects( KeyValues *modelKeyValues );
|
||||
|
||||
void UpdateRelevantInterpolatedVars();
|
||||
void AddBaseAnimatingInterpolatedVars();
|
||||
void RemoveBaseAnimatingInterpolatedVars();
|
||||
|
||||
|
||||
void LockStudioHdr();
|
||||
void UnlockStudioHdr();
|
||||
|
||||
public:
|
||||
CRagdoll *m_pRagdoll;
|
||||
|
||||
// Texture group to use
|
||||
int m_nSkin;
|
||||
|
||||
// Object bodygroup
|
||||
int m_nBody;
|
||||
CBaseAnimating *m_pClientsideRagdoll;
|
||||
|
||||
// Hitbox set to use (default 0)
|
||||
int m_nHitboxSet;
|
||||
|
||||
CSequenceTransitioner m_SequenceTransitioner;
|
||||
|
||||
private:
|
||||
|
||||
// BEGIN PREDICTION DATA COMPACTION (these fields are together to allow for faster copying in prediction system)
|
||||
// FTYPEDESC_INSENDTABLE STUFF
|
||||
int m_nPrevSequence;
|
||||
protected:
|
||||
|
||||
//float m_flCycle;
|
||||
// This needs to be ranged checked because some interpolation edge cases
|
||||
// can assign it to values far out of range. Interpolation vars will only
|
||||
// clamp range checked vars.
|
||||
CRangeCheckedVar<float, -2, 2, 0> m_flCycle;
|
||||
float m_flPlaybackRate;// Animation playback framerate
|
||||
|
||||
// FTYPEDESC_INSENDTABLE STUFF (end)
|
||||
int m_nSkin;// Texture group to use
|
||||
int m_nBody;// Object bodygroup
|
||||
int m_nNewSequenceParity;
|
||||
int m_nResetEventsParity;
|
||||
int m_nPrevNewSequenceParity;
|
||||
int m_nPrevResetEventsParity;
|
||||
|
||||
float m_flEncodedController[MAXSTUDIOBONECTRLS];
|
||||
private:
|
||||
// This is compared against m_nOldMuzzleFlashParity to determine if the entity should muzzle flash.
|
||||
unsigned char m_nMuzzleFlashParity;
|
||||
// END PREDICTION DATA COMPACTION
|
||||
|
||||
protected:
|
||||
CIKContext *m_pIk;
|
||||
|
||||
int m_iEyeAttachment;
|
||||
|
||||
// Animation playback framerate
|
||||
float m_flPlaybackRate;
|
||||
|
||||
// Decomposed ragdoll info
|
||||
bool m_bStoreRagdollInfo;
|
||||
@ -510,6 +548,7 @@ protected:
|
||||
// bone transformation matrix
|
||||
unsigned long m_iMostRecentModelBoneCounter;
|
||||
unsigned long m_iMostRecentBoneSetupRequest;
|
||||
C_BaseAnimating * m_pNextForThreadedBoneSetup;
|
||||
int m_iPrevBoneMask;
|
||||
int m_iAccumulatedBoneMask;
|
||||
|
||||
@ -521,38 +560,26 @@ protected:
|
||||
// Client-side animation
|
||||
bool m_bClientSideFrameReset;
|
||||
|
||||
// Bone attachments. Used for attaching one BaseAnimating to another's bones.
|
||||
// Client side only.
|
||||
CUtlVector<CHandle<C_BaseAnimating> > m_BoneAttachments;
|
||||
int m_boneIndexAttached;
|
||||
Vector m_bonePosition;
|
||||
QAngle m_boneAngles;
|
||||
CHandle<C_BaseAnimating> m_pAttachedTo;
|
||||
|
||||
protected:
|
||||
|
||||
float m_fadeMinDist;
|
||||
float m_fadeMaxDist;
|
||||
float m_flFadeScale;
|
||||
float m_flFrozen;
|
||||
|
||||
// Can we use the fast rendering path?
|
||||
bool m_bCanUseFastPath;
|
||||
|
||||
private:
|
||||
|
||||
float m_flGroundSpeed; // computed linear movement rate for current sequence
|
||||
float m_flLastEventCheck; // cycle index of when events were last checked
|
||||
bool m_bSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry
|
||||
bool m_bSequenceLoops; // true if the sequence loops
|
||||
|
||||
bool m_bIsUsingRelativeLighting;
|
||||
|
||||
// Mouth lipsync/envelope following values
|
||||
CMouthInfo m_mouth;
|
||||
|
||||
CNetworkVar( float, m_flModelScale );
|
||||
|
||||
// Animation blending factors
|
||||
float m_flPoseParameter[MAXSTUDIOPOSEPARAM];
|
||||
CInterpolatedVarArray< float, MAXSTUDIOPOSEPARAM > m_iv_flPoseParameter;
|
||||
float m_flOldPoseParameters[MAXSTUDIOPOSEPARAM];
|
||||
|
||||
int m_nPrevSequence;
|
||||
|
||||
int m_nRestoreSequence;
|
||||
|
||||
// Ropes that got spawned when the model was created.
|
||||
@ -562,7 +589,11 @@ private:
|
||||
float m_flPrevEventCycle;
|
||||
int m_nEventSequence;
|
||||
|
||||
float m_flEncodedController[MAXSTUDIOBONECTRLS];
|
||||
// Animation blending factors
|
||||
float m_flPoseParameter[MAXSTUDIOPOSEPARAM];
|
||||
CInterpolatedVarArray< float, MAXSTUDIOPOSEPARAM > m_iv_flPoseParameter;
|
||||
float m_flOldPoseParameters[MAXSTUDIOPOSEPARAM];
|
||||
|
||||
CInterpolatedVarArray< float, MAXSTUDIOBONECTRLS > m_iv_flEncodedController;
|
||||
float m_flOldEncodedController[MAXSTUDIOBONECTRLS];
|
||||
|
||||
@ -570,37 +601,40 @@ private:
|
||||
bool m_bClientSideAnimation;
|
||||
bool m_bLastClientSideFrameReset;
|
||||
|
||||
int m_nNewSequenceParity;
|
||||
int m_nResetEventsParity;
|
||||
|
||||
int m_nPrevNewSequenceParity;
|
||||
int m_nPrevResetEventsParity;
|
||||
|
||||
bool m_builtRagdoll;
|
||||
Vector m_vecPreRagdollMins;
|
||||
Vector m_vecPreRagdollMaxs;
|
||||
bool m_builtRagdoll;
|
||||
bool m_bReceivedSequence;
|
||||
bool m_bIsStaticProp;
|
||||
|
||||
// Current animation sequence
|
||||
int m_nSequence;
|
||||
bool m_bReceivedSequence;
|
||||
|
||||
// Current cycle location from server
|
||||
protected:
|
||||
float m_flCycle;
|
||||
CInterpolatedVar< float > m_iv_flCycle;
|
||||
CInterpolatedVar< CRangeCheckedVar<float, -2, 2, 0> > m_iv_flCycle;
|
||||
//CInterpolatedVar< float > m_iv_flCycle;
|
||||
float m_flOldCycle;
|
||||
bool m_bNoModelParticles;
|
||||
float m_prevClientCycle;
|
||||
float m_prevClientAnimTime;
|
||||
|
||||
// True if bone setup should latch bones for demo polish subsystem
|
||||
bool m_bBonePolishSetup;
|
||||
|
||||
private:
|
||||
float m_flOldModelScale;
|
||||
int m_nOldSequence;
|
||||
CBoneMergeCache *m_pBoneMergeCache; // This caches the strcmp lookups that it has to do
|
||||
// when merg
|
||||
|
||||
private:
|
||||
int m_nPrevBody;
|
||||
int m_nPrevSkin;
|
||||
|
||||
float m_flOldModelScale;
|
||||
int m_nOldSequence;
|
||||
|
||||
CUtlVector< matrix3x4_t > m_CachedBoneData; // never access this directly. Use m_BoneAccessor.
|
||||
memhandle_t m_hitboxBoneCacheHandle;
|
||||
CUtlVector< matrix3x4a_t, CUtlMemoryAligned<matrix3x4a_t,16> > m_CachedBoneData; // never access this directly. Use m_BoneAccessor.
|
||||
float m_flLastBoneSetupTime;
|
||||
CJiggleBones *m_pJiggleBones;
|
||||
bool m_isJiggleBonesEnabled;
|
||||
|
||||
// Calculated attachment points
|
||||
CUtlVector<CAttachmentData> m_Attachments;
|
||||
@ -608,31 +642,21 @@ private:
|
||||
void SetupBones_AttachmentHelper( CStudioHdr *pStudioHdr );
|
||||
|
||||
EHANDLE m_hLightingOrigin;
|
||||
EHANDLE m_hLightingOriginRelative;
|
||||
|
||||
// These are compared against each other to determine if the entity should muzzle flash.
|
||||
CNetworkVar( unsigned char, m_nMuzzleFlashParity );
|
||||
unsigned char m_nOldMuzzleFlashParity;
|
||||
unsigned char m_nOldMuzzleFlashParity;
|
||||
|
||||
bool m_bInitModelEffects;
|
||||
|
||||
// Dynamic models
|
||||
bool m_bDynamicModelAllowed;
|
||||
bool m_bDynamicModelPending;
|
||||
bool m_bResetSequenceInfoOnLoad;
|
||||
CRefCountedModelIndex m_AutoRefModelIndex;
|
||||
public:
|
||||
void EnableDynamicModels() { m_bDynamicModelAllowed = true; }
|
||||
bool IsDynamicModelLoading() const { return m_bDynamicModelPending; }
|
||||
private:
|
||||
virtual void OnModelLoadComplete( const model_t* pModel );
|
||||
static bool m_bBoneListInUse;
|
||||
static CBoneList m_recordingBoneList;
|
||||
|
||||
private:
|
||||
void LockStudioHdr();
|
||||
void UnlockStudioHdr();
|
||||
mutable CStudioHdr *m_pStudioHdr;
|
||||
mutable MDLHandle_t m_hStudioHdr;
|
||||
CThreadFastMutex m_StudioHdrInitLock;
|
||||
|
||||
CUtlReference<CNewParticleEffect> m_ejectBrassEffect;
|
||||
int m_iEjectBrassAttachment;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -646,18 +670,21 @@ enum
|
||||
|
||||
class C_ClientRagdoll : public C_BaseAnimating, public IPVSNotify
|
||||
{
|
||||
|
||||
public:
|
||||
C_ClientRagdoll( bool bRestoring = true );
|
||||
C_ClientRagdoll( bool bRestoring = true , bool fullInit = true);
|
||||
public:
|
||||
DECLARE_CLASS( C_ClientRagdoll, C_BaseAnimating );
|
||||
DECLARE_DATADESC();
|
||||
|
||||
// inherited from IClientUnknown
|
||||
virtual IClientModelRenderable* GetClientModelRenderable();
|
||||
|
||||
// inherited from IPVSNotify
|
||||
virtual void OnPVSStatusChanged( bool bInPVS );
|
||||
|
||||
virtual void Release( void );
|
||||
virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
|
||||
virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
|
||||
virtual void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
|
||||
void ClientThink( void );
|
||||
void ReleaseRagdoll( void ) { m_bReleaseRagdoll = true; }
|
||||
bool ShouldSavePhysics( void ) { return true; }
|
||||
@ -672,10 +699,18 @@ public:
|
||||
void FadeOut( void );
|
||||
virtual float LastBoneChangedTime();
|
||||
|
||||
inline bool IsFadingOut() { return m_bFadingOut; }
|
||||
|
||||
bool m_bFadeOut;
|
||||
bool m_bImportant;
|
||||
float m_flEffectTime;
|
||||
|
||||
// returns true if we are of type C_ClientRagdoll
|
||||
virtual bool IsClientRagdoll() const { return true; }
|
||||
|
||||
protected:
|
||||
bool m_bReleaseRagdoll;
|
||||
|
||||
private:
|
||||
int m_iCurrentFriction;
|
||||
int m_iMinFriction;
|
||||
@ -684,7 +719,6 @@ private:
|
||||
float m_flFrictionTime;
|
||||
|
||||
int m_iFrictionAnimState;
|
||||
bool m_bReleaseRagdoll;
|
||||
|
||||
bool m_bFadingOut;
|
||||
|
||||
@ -702,9 +736,9 @@ inline void C_BaseAnimating::ResetSequence(int nSequence)
|
||||
ResetSequenceInfo();
|
||||
}
|
||||
|
||||
inline float C_BaseAnimating::GetPlaybackRate()
|
||||
inline float C_BaseAnimating::GetPlaybackRate() const
|
||||
{
|
||||
return m_flPlaybackRate;
|
||||
return m_flPlaybackRate * clamp( 1.0f - m_flFrozen, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
inline void C_BaseAnimating::SetPlaybackRate( float rate )
|
||||
@ -712,16 +746,20 @@ inline void C_BaseAnimating::SetPlaybackRate( float rate )
|
||||
m_flPlaybackRate = rate;
|
||||
}
|
||||
|
||||
inline const matrix3x4_t& C_BaseAnimating::GetBone( int iBone ) const
|
||||
inline const matrix3x4a_t& C_BaseAnimating::GetBone( int iBone ) const
|
||||
{
|
||||
return m_BoneAccessor.GetBone( iBone );
|
||||
}
|
||||
|
||||
inline matrix3x4_t& C_BaseAnimating::GetBoneForWrite( int iBone )
|
||||
inline matrix3x4a_t& C_BaseAnimating::GetBoneForWrite( int iBone )
|
||||
{
|
||||
return m_BoneAccessor.GetBoneForWrite( iBone );
|
||||
}
|
||||
|
||||
inline matrix3x4a_t* C_BaseAnimating::GetBoneArrayForWrite()
|
||||
{
|
||||
return m_BoneAccessor.GetBoneArrayForWrite();
|
||||
}
|
||||
|
||||
inline bool C_BaseAnimating::ShouldMuzzleFlash() const
|
||||
{
|
||||
@ -739,28 +777,27 @@ inline float C_BaseAnimating::GetCycle() const
|
||||
|
||||
inline CStudioHdr *C_BaseAnimating::GetModelPtr() const
|
||||
{
|
||||
if ( IsDynamicModelLoading() )
|
||||
return NULL;
|
||||
|
||||
#ifdef _DEBUG
|
||||
// GetModelPtr() is often called before OnNewModel() so go ahead and set it up first chance.
|
||||
// static IDataCacheSection *pModelCache = datacache->FindSection( "ModelData" );
|
||||
// AssertOnce( pModelCache->IsFrameLocking() );
|
||||
#ifndef _X360
|
||||
// 360's don't need to lock the modeldata cache since it never flushes
|
||||
static IDataCacheSection *pModelCache = g_pDataCache->FindSection( "ModelData" );
|
||||
AssertOnce( pModelCache->IsFrameLocking() );
|
||||
#endif
|
||||
if ( !m_pStudioHdr )
|
||||
#endif
|
||||
// GetModelPtr() is often called before OnNewModel() so go ahead and set it up first chance.
|
||||
if ( !m_pStudioHdr && GetModel() )
|
||||
{
|
||||
const_cast<C_BaseAnimating *>(this)->LockStudioHdr();
|
||||
}
|
||||
Assert( m_pStudioHdr ? m_pStudioHdr->GetRenderHdr() == mdlcache->GetStudioHdr(m_hStudioHdr) : m_hStudioHdr == MDLHANDLE_INVALID );
|
||||
return m_pStudioHdr;
|
||||
return ( m_pStudioHdr && m_pStudioHdr->IsValid() ) ? m_pStudioHdr : NULL;
|
||||
}
|
||||
|
||||
|
||||
inline void C_BaseAnimating::InvalidateMdlCache()
|
||||
{
|
||||
if ( m_pStudioHdr )
|
||||
UnlockStudioHdr();
|
||||
if ( m_pStudioHdr != NULL )
|
||||
{
|
||||
UnlockStudioHdr();
|
||||
delete m_pStudioHdr;
|
||||
m_pStudioHdr = NULL;
|
||||
}
|
||||
@ -773,11 +810,6 @@ inline bool C_BaseAnimating::IsModelScaleFractional() const /// very fast way
|
||||
return *((const int *) &m_flModelScale) < 0x3f800000;
|
||||
}
|
||||
|
||||
inline bool C_BaseAnimating::IsModelScaled() const
|
||||
{
|
||||
return ( m_flModelScale > 1.0f+FLT_EPSILON || m_flModelScale < 1.0f-FLT_EPSILON );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sequence access
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -813,6 +845,6 @@ void SetColumn( Vector &src, int column, matrix3x4_t& dest );
|
||||
EXTERN_RECV_TABLE(DT_BaseAnimating);
|
||||
|
||||
|
||||
extern void DevMsgRT( PRINTF_FORMAT_STRING char const* pMsg, ... );
|
||||
extern void DevMsgRT( char const* pMsg, ... );
|
||||
|
||||
#endif // C_BASEANIMATING_H
|
||||
|
@ -1,17 +1,19 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_baseanimatingoverlay.h"
|
||||
#include "animation.h"
|
||||
#include "bone_setup.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "engine/IVDebugOverlay.h"
|
||||
#include "datacache/imdlcache.h"
|
||||
#include "eventlist.h"
|
||||
#include "toolframework_client.h"
|
||||
|
||||
#include "dt_utlvector_recv.h"
|
||||
|
||||
@ -20,14 +22,96 @@
|
||||
|
||||
extern ConVar r_sequence_debug;
|
||||
|
||||
template class CInterpolatedVar<CAnimationLayer>;
|
||||
|
||||
|
||||
mstudioevent_for_client_server_t *GetEventIndexForSequence( mstudioseqdesc_t &seqdesc );
|
||||
|
||||
|
||||
void C_AnimationLayer::SetOwner( C_BaseAnimatingOverlay *pOverlay )
|
||||
{
|
||||
m_pOwner = pOverlay;
|
||||
}
|
||||
|
||||
C_BaseAnimatingOverlay *C_AnimationLayer::GetOwner() const
|
||||
{
|
||||
return m_pOwner;
|
||||
}
|
||||
|
||||
void C_AnimationLayer::Reset()
|
||||
{
|
||||
if ( m_pOwner )
|
||||
{
|
||||
int nFlags = 0;
|
||||
if ( m_nSequence != 0 || m_flWeight != 0.0f )
|
||||
{
|
||||
nFlags |= BOUNDS_CHANGED;
|
||||
}
|
||||
if ( m_flCycle != 0.0f )
|
||||
{
|
||||
nFlags |= ANIMATION_CHANGED;
|
||||
}
|
||||
if ( nFlags )
|
||||
{
|
||||
m_pOwner->InvalidatePhysicsRecursive( nFlags );
|
||||
}
|
||||
}
|
||||
|
||||
m_nSequence = 0;
|
||||
m_flPrevCycle = 0;
|
||||
m_flWeight = 0;
|
||||
m_flPlaybackRate = 0;
|
||||
m_flCycle = 0;
|
||||
m_flLayerAnimtime = 0;
|
||||
m_flLayerFadeOuttime = 0;
|
||||
}
|
||||
|
||||
void C_AnimationLayer::SetSequence( int nSequence )
|
||||
{
|
||||
if ( m_pOwner && m_nSequence != nSequence )
|
||||
{
|
||||
m_pOwner->InvalidatePhysicsRecursive( BOUNDS_CHANGED );
|
||||
}
|
||||
m_nSequence = nSequence;
|
||||
}
|
||||
|
||||
void C_AnimationLayer::SetCycle( float flCycle )
|
||||
{
|
||||
if ( m_pOwner && m_flCycle != flCycle )
|
||||
{
|
||||
m_pOwner->InvalidatePhysicsRecursive( ANIMATION_CHANGED );
|
||||
}
|
||||
m_flCycle = flCycle;
|
||||
}
|
||||
|
||||
void C_AnimationLayer::SetOrder( int order )
|
||||
{
|
||||
if ( m_pOwner && ( m_nOrder != order ) )
|
||||
{
|
||||
if ( m_nOrder == C_BaseAnimatingOverlay::MAX_OVERLAYS || order == C_BaseAnimatingOverlay::MAX_OVERLAYS )
|
||||
{
|
||||
m_pOwner->InvalidatePhysicsRecursive( BOUNDS_CHANGED );
|
||||
}
|
||||
}
|
||||
m_nOrder = order;
|
||||
}
|
||||
|
||||
|
||||
void C_AnimationLayer::SetWeight( float flWeight )
|
||||
{
|
||||
if ( m_pOwner && m_flWeight != flWeight )
|
||||
{
|
||||
if ( m_flWeight == 0.0f || flWeight == 0.0f )
|
||||
{
|
||||
m_pOwner->InvalidatePhysicsRecursive( BOUNDS_CHANGED );
|
||||
}
|
||||
}
|
||||
m_flWeight = flWeight;
|
||||
}
|
||||
|
||||
C_BaseAnimatingOverlay::C_BaseAnimatingOverlay()
|
||||
{
|
||||
// FIXME: where does this initialization go now?
|
||||
//for ( int i=0; i < MAX_OVERLAYS; i++ )
|
||||
//{
|
||||
// memset( &m_Layer[i], 0, sizeof(m_Layer[0]) );
|
||||
// m_Layer[i].m_nOrder = MAX_OVERLAYS;
|
||||
//}
|
||||
// NOTE: We zero the memory in the max capacity m_Layer vector in dt_ultvector_common.h
|
||||
|
||||
// FIXME: where does this initialization go now?
|
||||
// AddVar( m_Layer, &m_iv_AnimOverlay, LATCH_ANIMATION_VAR );
|
||||
@ -36,13 +120,36 @@ C_BaseAnimatingOverlay::C_BaseAnimatingOverlay()
|
||||
#undef CBaseAnimatingOverlay
|
||||
|
||||
|
||||
void RecvProxy_SequenceChanged( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
CAnimationLayer *pLayer = (CAnimationLayer *)pStruct;
|
||||
pLayer->SetSequence( pData->m_Value.m_Int );
|
||||
}
|
||||
|
||||
void RecvProxy_WeightChanged( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
CAnimationLayer *pLayer = (CAnimationLayer *)pStruct;
|
||||
pLayer->SetWeight( pData->m_Value.m_Float );
|
||||
}
|
||||
|
||||
void RecvProxy_CycleChanged( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
CAnimationLayer *pLayer = (CAnimationLayer *)pStruct;
|
||||
pLayer->SetCycle( pData->m_Value.m_Float );
|
||||
}
|
||||
|
||||
void RecvProxy_OrderChanged( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||
{
|
||||
CAnimationLayer *pLayer = (CAnimationLayer *)pStruct;
|
||||
pLayer->SetOrder( pData->m_Value.m_Int );
|
||||
}
|
||||
|
||||
BEGIN_RECV_TABLE_NOBASE(CAnimationLayer, DT_Animationlayer)
|
||||
RecvPropInt( RECVINFO_NAME(m_nSequence, m_nSequence)),
|
||||
RecvPropFloat( RECVINFO_NAME(m_flCycle, m_flCycle)),
|
||||
RecvPropInt( RECVINFO_NAME(m_nSequence, m_nSequence), 0, RecvProxy_SequenceChanged ),
|
||||
RecvPropFloat( RECVINFO_NAME(m_flCycle, m_flCycle), 0, RecvProxy_CycleChanged ),
|
||||
RecvPropFloat( RECVINFO_NAME(m_flPrevCycle, m_flPrevCycle)),
|
||||
RecvPropFloat( RECVINFO_NAME(m_flWeight, m_flWeight)),
|
||||
RecvPropInt( RECVINFO_NAME(m_nOrder, m_nOrder))
|
||||
RecvPropFloat( RECVINFO_NAME(m_flWeight, m_flWeight), 0, RecvProxy_WeightChanged ),
|
||||
RecvPropInt( RECVINFO_NAME(m_nOrder, m_nOrder), 0, RecvProxy_OrderChanged )
|
||||
END_RECV_TABLE()
|
||||
|
||||
const char *s_m_iv_AnimOverlayNames[C_BaseAnimatingOverlay::MAX_OVERLAYS] =
|
||||
@ -67,47 +174,60 @@ const char *s_m_iv_AnimOverlayNames[C_BaseAnimatingOverlay::MAX_OVERLAYS] =
|
||||
void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len )
|
||||
{
|
||||
C_BaseAnimatingOverlay *pEnt = (C_BaseAnimatingOverlay*)pStruct;
|
||||
CUtlVector < C_AnimationLayer > *pVec = &pEnt->m_AnimOverlay;
|
||||
CUtlVector< CInterpolatedVar< C_AnimationLayer > > *pVecIV = &pEnt->m_iv_AnimOverlay;
|
||||
CUtlVector < CAnimationLayer > *pVec = &pEnt->m_AnimOverlay;
|
||||
CUtlVector< CInterpolatedVar< CAnimationLayer > > *pVecIV = &pEnt->m_iv_AnimOverlay;
|
||||
|
||||
Assert( (char*)pVec - (char*)pEnt == offsetToUtlVector );
|
||||
Assert( pVec->Count() == pVecIV->Count() );
|
||||
Assert( pVec->Count() <= C_BaseAnimatingOverlay::MAX_OVERLAYS );
|
||||
|
||||
int diff = len - pVec->Count();
|
||||
|
||||
|
||||
|
||||
if ( diff == 0 )
|
||||
return;
|
||||
|
||||
// remove all entries
|
||||
for ( int i=0; i < pVec->Count(); i++ )
|
||||
if ( diff != 0 )
|
||||
{
|
||||
pEnt->RemoveVar( &pVec->Element( i ) );
|
||||
// remove all entries
|
||||
for ( int i=0; i < pVec->Count(); i++ )
|
||||
{
|
||||
pEnt->RemoveVar( &pVec->Element( i ) );
|
||||
}
|
||||
|
||||
pEnt->InvalidatePhysicsRecursive( BOUNDS_CHANGED );
|
||||
|
||||
// adjust vector sizes
|
||||
if ( diff > 0 )
|
||||
{
|
||||
for ( int i = 0; i < diff; ++i )
|
||||
{
|
||||
int j = pVec->AddToTail( );
|
||||
(*pVec)[j].SetOwner( pEnt );
|
||||
}
|
||||
pVecIV->AddMultipleToTail( diff );
|
||||
}
|
||||
else
|
||||
{
|
||||
pVec->RemoveMultiple( len, -diff );
|
||||
pVecIV->RemoveMultiple( len, -diff );
|
||||
}
|
||||
|
||||
// Rebind all the variables in the ent's list.
|
||||
for ( int i=0; i < len; i++ )
|
||||
{
|
||||
IInterpolatedVar *pWatcher = &pVecIV->Element( i );
|
||||
pWatcher->SetDebugName( s_m_iv_AnimOverlayNames[i] );
|
||||
pEnt->AddVar( &pVec->Element( i ), pWatcher, LATCH_ANIMATION_VAR, true );
|
||||
}
|
||||
}
|
||||
|
||||
// adjust vector sizes
|
||||
if ( diff > 0 )
|
||||
{
|
||||
pVec->AddMultipleToTail( diff );
|
||||
pVecIV->AddMultipleToTail( diff );
|
||||
}
|
||||
else
|
||||
{
|
||||
pVec->RemoveMultiple( len, -diff );
|
||||
pVecIV->RemoveMultiple( len, -diff );
|
||||
}
|
||||
|
||||
// Rebind all the variables in the ent's list.
|
||||
for ( int i=0; i < len; i++ )
|
||||
{
|
||||
IInterpolatedVar *pWatcher = &pVecIV->Element( i );
|
||||
pWatcher->SetDebugName( s_m_iv_AnimOverlayNames[i] );
|
||||
pEnt->AddVar( &pVec->Element( i ), pWatcher, LATCH_ANIMATION_VAR, true );
|
||||
}
|
||||
// FIXME: need to set historical values of nOrder in pVecIV to MAX_OVERLAY
|
||||
|
||||
|
||||
// Ensure capacity
|
||||
pVec->EnsureCapacity( len );
|
||||
|
||||
int nNumAllocated = pVec->NumAllocated();
|
||||
|
||||
// This is important to do because EnsureCapacity doesn't actually call the constructors
|
||||
// on the elements, but we need them to be initialized, otherwise it'll have out-of-range
|
||||
// values which will piss off the datatable encoder.
|
||||
UtlVector_InitializeAllocatedElements( pVec->Base() + pVec->Count(), nNumAllocated - pVec->Count() );
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +266,7 @@ BEGIN_PREDICTION_DATA( C_BaseAnimatingOverlay )
|
||||
|
||||
END_PREDICTION_DATA()
|
||||
|
||||
C_AnimationLayer* C_BaseAnimatingOverlay::GetAnimOverlay( int i )
|
||||
CAnimationLayer* C_BaseAnimatingOverlay::GetAnimOverlay( int i )
|
||||
{
|
||||
Assert( i >= 0 && i < MAX_OVERLAYS );
|
||||
return &m_AnimOverlay[i];
|
||||
@ -157,12 +277,28 @@ void C_BaseAnimatingOverlay::SetNumAnimOverlays( int num )
|
||||
{
|
||||
if ( m_AnimOverlay.Count() < num )
|
||||
{
|
||||
m_AnimOverlay.AddMultipleToTail( num - m_AnimOverlay.Count() );
|
||||
int nCountToAdd = num - m_AnimOverlay.Count();
|
||||
for ( int i = 0; i < nCountToAdd; ++i )
|
||||
{
|
||||
int j = m_AnimOverlay.AddToTail( );
|
||||
m_AnimOverlay[j].SetOwner( this );
|
||||
}
|
||||
}
|
||||
else if ( m_AnimOverlay.Count() > num )
|
||||
{
|
||||
m_AnimOverlay.RemoveMultiple( num, m_AnimOverlay.Count() - num );
|
||||
InvalidatePhysicsRecursive( BOUNDS_CHANGED );
|
||||
}
|
||||
|
||||
// Ensure capacity
|
||||
m_AnimOverlay.EnsureCapacity( C_BaseAnimatingOverlay::MAX_OVERLAYS );
|
||||
|
||||
int nNumAllocated = m_AnimOverlay.NumAllocated();
|
||||
|
||||
// This is important to do because EnsureCapacity doesn't actually call the constructors
|
||||
// on the elements, but we need them to be initialized, otherwise it'll have out-of-range
|
||||
// values which will piss off the datatable encoder.
|
||||
UtlVector_InitializeAllocatedElements( m_AnimOverlay.Base() + m_AnimOverlay.Count(), nNumAllocated - m_AnimOverlay.Count() );
|
||||
}
|
||||
|
||||
|
||||
@ -171,44 +307,46 @@ int C_BaseAnimatingOverlay::GetNumAnimOverlays() const
|
||||
return m_AnimOverlay.Count();
|
||||
}
|
||||
|
||||
|
||||
void C_BaseAnimatingOverlay::GetRenderBounds( Vector& theMins, Vector& theMaxs )
|
||||
{
|
||||
BaseClass::GetRenderBounds( theMins, theMaxs );
|
||||
|
||||
if ( !IsRagdoll() )
|
||||
if ( IsRagdoll() )
|
||||
return;
|
||||
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
if ( !pStudioHdr || !pStudioHdr->SequencesAvailable() )
|
||||
return;
|
||||
|
||||
int nSequences = pStudioHdr->GetNumSeq();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_AnimOverlay.Count(); i++)
|
||||
{
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
if ( !pStudioHdr || !pStudioHdr->SequencesAvailable() )
|
||||
return;
|
||||
|
||||
int nSequences = pStudioHdr->GetNumSeq();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_AnimOverlay.Count(); i++)
|
||||
if ( m_AnimOverlay[i].m_flWeight > 0.0 && m_AnimOverlay[i].m_nOrder != MAX_OVERLAYS )
|
||||
{
|
||||
if (m_AnimOverlay[i].m_flWeight > 0.0)
|
||||
{
|
||||
if ( m_AnimOverlay[i].m_nSequence >= nSequences )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( m_AnimOverlay[i].m_nSequence >= nSequences )
|
||||
continue;
|
||||
|
||||
mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( m_AnimOverlay[i].m_nSequence );
|
||||
VectorMin( seqdesc.bbmin, theMins, theMins );
|
||||
VectorMax( seqdesc.bbmax, theMaxs, theMaxs );
|
||||
}
|
||||
mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( m_AnimOverlay[i].m_nSequence );
|
||||
VectorMin( seqdesc.bbmin, theMins, theMins );
|
||||
VectorMax( seqdesc.bbmax, theMaxs, theMaxs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool C_BaseAnimatingOverlay::Interpolate( float flCurrentTime )
|
||||
{
|
||||
bool bOk = BaseClass::Interpolate( flCurrentTime );
|
||||
|
||||
CheckForLayerPhysicsInvalidate();
|
||||
|
||||
return bOk;
|
||||
}
|
||||
|
||||
void C_BaseAnimatingOverlay::CheckForLayerChanges( CStudioHdr *hdr, float currentTime )
|
||||
{
|
||||
CDisableRangeChecks disableRangeChecks;
|
||||
|
||||
bool bLayersChanged = false;
|
||||
|
||||
// FIXME: damn, there has to be a better way than this.
|
||||
int i;
|
||||
@ -221,78 +359,69 @@ void C_BaseAnimatingOverlay::CheckForLayerChanges( CStudioHdr *hdr, float curren
|
||||
|
||||
// fake up previous cycle values.
|
||||
float t0;
|
||||
C_AnimationLayer *pHead = m_iv_AnimOverlay[i].GetHistoryValue( iHead, t0 );
|
||||
CAnimationLayer *pHead = m_iv_AnimOverlay[i].GetHistoryValue( iHead, t0 );
|
||||
// reset previous
|
||||
float t1;
|
||||
C_AnimationLayer *pPrev1 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev1, t1 );
|
||||
CAnimationLayer *pPrev1 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev1, t1 );
|
||||
// reset previous previous
|
||||
float t2;
|
||||
C_AnimationLayer *pPrev2 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev2, t2 );
|
||||
CAnimationLayer *pPrev2 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev2, t2 );
|
||||
|
||||
if ( pHead && pPrev1 && pHead->m_nSequence != pPrev1->m_nSequence )
|
||||
if ( !pHead || !pPrev1 || pHead->m_nSequence == pPrev1->m_nSequence )
|
||||
continue;
|
||||
|
||||
#if 1 // _DEBUG
|
||||
if (r_sequence_debug.GetInt() == entindex())
|
||||
{
|
||||
bLayersChanged = true;
|
||||
#if 1 // _DEBUG
|
||||
if (/* Q_stristr( hdr->pszName(), r_sequence_debug.GetString()) != NULL || */ r_sequence_debug.GetInt() == entindex())
|
||||
{
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t0, hdr->pSeqdesc( pHead->m_nSequence ).pszLabel(), (float)pHead->m_flCycle, (float)pHead->m_flWeight, i );
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t1, hdr->pSeqdesc( pPrev1->m_nSequence ).pszLabel(), (float)pPrev1->m_flCycle, (float)pPrev1->m_flWeight, i );
|
||||
if (pPrev2)
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t2, hdr->pSeqdesc( pPrev2->m_nSequence ).pszLabel(), (float)pPrev2->m_flCycle, (float)pPrev2->m_flWeight, i );
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pPrev1)
|
||||
{
|
||||
pPrev1->m_nSequence = pHead->m_nSequence;
|
||||
pPrev1->m_flCycle = pHead->m_flPrevCycle;
|
||||
pPrev1->m_flWeight = pHead->m_flWeight;
|
||||
}
|
||||
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t0, hdr->pSeqdesc( pHead->m_nSequence ).pszLabel(), (float)pHead->m_flCycle, (float)pHead->m_flWeight, i );
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t1, hdr->pSeqdesc( pPrev1->m_nSequence ).pszLabel(), (float)pPrev1->m_flCycle, (float)pPrev1->m_flWeight, i );
|
||||
if (pPrev2)
|
||||
{
|
||||
float num = 0;
|
||||
if ( fabs( t0 - t1 ) > 0.001f )
|
||||
num = (t2 - t1) / (t0 - t1);
|
||||
|
||||
pPrev2->m_nSequence = pHead->m_nSequence;
|
||||
float flTemp;
|
||||
if (IsSequenceLooping( hdr, pHead->m_nSequence ))
|
||||
{
|
||||
flTemp = LoopingLerp( num, (float)pHead->m_flPrevCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
else
|
||||
{
|
||||
flTemp = Lerp( num, (float)pHead->m_flPrevCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
pPrev2->m_flCycle = flTemp;
|
||||
pPrev2->m_flWeight = pHead->m_flWeight;
|
||||
}
|
||||
|
||||
/*
|
||||
if (stricmp( r_seq_overlay_debug.GetString(), hdr->name ) == 0)
|
||||
{
|
||||
DevMsgRT( "(%30s %6.2f : %6.2f : %6.2f)\n", hdr->pSeqdesc( pHead->nSequence ).pszLabel(), (float)pPrev2->m_flCycle, (float)pPrev1->m_flCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
*/
|
||||
|
||||
m_iv_AnimOverlay[i].SetLooping( IsSequenceLooping( hdr, pHead->m_nSequence ) );
|
||||
m_iv_AnimOverlay[i].Interpolate( currentTime );
|
||||
|
||||
// reset event indexes
|
||||
m_flOverlayPrevEventCycle[i] = pHead->m_flPrevCycle - 0.01;
|
||||
DevMsgRT( "(%7.4f : %30s : %5.3f : %4.2f : %1d)\n", t2, hdr->pSeqdesc( pPrev2->m_nSequence ).pszLabel(), (float)pPrev2->m_flCycle, (float)pPrev2->m_flWeight, i );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bLayersChanged)
|
||||
{
|
||||
// render bounds may have changed
|
||||
UpdateVisibility();
|
||||
pPrev1->m_nSequence = pHead->m_nSequence;
|
||||
pPrev1->m_flCycle = pHead->m_flPrevCycle;
|
||||
pPrev1->m_flWeight = pHead->m_flWeight;
|
||||
|
||||
if (pPrev2)
|
||||
{
|
||||
float num = 0;
|
||||
if ( fabs( t0 - t1 ) > 0.001f )
|
||||
num = (t2 - t1) / (t0 - t1);
|
||||
|
||||
pPrev2->m_nSequence = pHead->m_nSequence;
|
||||
float flTemp;
|
||||
if (IsSequenceLooping( hdr, pHead->m_nSequence ))
|
||||
{
|
||||
flTemp = LoopingLerp( num, (float)pHead->m_flPrevCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
else
|
||||
{
|
||||
flTemp = Lerp( num, (float)pHead->m_flPrevCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
pPrev2->m_flCycle = flTemp;
|
||||
pPrev2->m_flWeight = pHead->m_flWeight;
|
||||
}
|
||||
|
||||
/*
|
||||
if (stricmp( r_seq_overlay_debug.GetString(), hdr->name ) == 0)
|
||||
{
|
||||
DevMsgRT( "(%30s %6.2f : %6.2f : %6.2f)\n", hdr->pSeqdesc( pHead->nSequence ).pszLabel(), (float)pPrev2->m_flCycle, (float)pPrev1->m_flCycle, (float)pHead->m_flCycle );
|
||||
}
|
||||
*/
|
||||
|
||||
m_iv_AnimOverlay[i].SetLooping( IsSequenceLooping( hdr, pHead->m_nSequence ) );
|
||||
m_iv_AnimOverlay[i].Interpolate( currentTime );
|
||||
|
||||
// reset event indexes
|
||||
m_flOverlayPrevEventCycle[i] = pHead->m_flPrevCycle - 0.01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#define DEBUG_TF2_OVERLAYS
|
||||
void C_BaseAnimatingOverlay::AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Quaternion q[], float currentTime )
|
||||
{
|
||||
BaseClass::AccumulateLayers( boneSetup, pos, q, currentTime );
|
||||
@ -304,6 +433,7 @@ void C_BaseAnimatingOverlay::AccumulateLayers( IBoneSetup &boneSetup, Vector pos
|
||||
{
|
||||
layer[i] = MAX_OVERLAYS;
|
||||
}
|
||||
|
||||
for (i = 0; i < m_AnimOverlay.Count(); i++)
|
||||
{
|
||||
if (m_AnimOverlay[i].m_nOrder < MAX_OVERLAYS)
|
||||
@ -313,9 +443,9 @@ void C_BaseAnimatingOverlay::AccumulateLayers( IBoneSetup &boneSetup, Vector pos
|
||||
layer[m_AnimOverlay[i].m_nOrder] = i;
|
||||
*/
|
||||
// hacky code until initialization of new layers is finished
|
||||
if (layer[m_AnimOverlay[i].m_nOrder] != MAX_OVERLAYS)
|
||||
if ( layer[m_AnimOverlay[i].m_nOrder] != MAX_OVERLAYS )
|
||||
{
|
||||
m_AnimOverlay[i].m_nOrder = MAX_OVERLAYS;
|
||||
m_AnimOverlay[i].SetOrder( MAX_OVERLAYS );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -333,106 +463,101 @@ void C_BaseAnimatingOverlay::AccumulateLayers( IBoneSetup &boneSetup, Vector pos
|
||||
for (j = 0; j < MAX_OVERLAYS; j++)
|
||||
{
|
||||
i = layer[ j ];
|
||||
if (i < m_AnimOverlay.Count())
|
||||
if ( i >= m_AnimOverlay.Count() )
|
||||
{
|
||||
if ( m_AnimOverlay[i].m_nSequence >= nSequences )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#if defined( DEBUG_TF2_OVERLAYS )
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", " ", 0.f, 0.f, i );
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
DevMsgRT( 1 , "%.3f %.3f %.3f\n", currentTime, fWeight, dadt );
|
||||
debugoverlay->AddTextOverlay( GetAbsOrigin() + Vector( 0, 0, 64 ), -j - 1, 0,
|
||||
"%2d(%s) : %6.2f : %6.2f",
|
||||
m_AnimOverlay[i].m_nSequence,
|
||||
hdr->pSeqdesc( m_AnimOverlay[i].m_nSequence )->pszLabel(),
|
||||
m_AnimOverlay[i].m_flCycle,
|
||||
m_AnimOverlay[i].m_flWeight
|
||||
);
|
||||
*/
|
||||
if ( m_AnimOverlay[i].m_nSequence >= nSequences )
|
||||
continue;
|
||||
|
||||
m_AnimOverlay[i].BlendWeight();
|
||||
/*
|
||||
DevMsgRT( 1 , "%.3f %.3f %.3f\n", currentTime, fWeight, dadt );
|
||||
debugoverlay->AddTextOverlay( GetAbsOrigin() + Vector( 0, 0, 64 ), -j - 1, 0,
|
||||
"%2d(%s) : %6.2f : %6.2f",
|
||||
m_AnimOverlay[i].m_nSequence,
|
||||
boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence )->pszLabel(),
|
||||
m_AnimOverlay[i].m_flCycle,
|
||||
m_AnimOverlay[i].m_flWeight
|
||||
);
|
||||
*/
|
||||
|
||||
float fWeight = m_AnimOverlay[i].m_flWeight;
|
||||
float fWeight = m_AnimOverlay[i].m_flWeight;
|
||||
if ( fWeight <= 0.0f )
|
||||
{
|
||||
#if defined( DEBUG_TF2_OVERLAYS )
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", " ", 0.f, 0.f, i );
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fWeight > 0)
|
||||
{
|
||||
// check to see if the sequence changed
|
||||
// FIXME: move this to somewhere more reasonable
|
||||
// do a nice spline interpolation of the values
|
||||
// if ( m_AnimOverlay[i].m_nSequence != m_iv_AnimOverlay.GetPrev( i )->nSequence )
|
||||
float fCycle = m_AnimOverlay[ i ].m_flCycle;
|
||||
// check to see if the sequence changed
|
||||
// FIXME: move this to somewhere more reasonable
|
||||
// do a nice spline interpolation of the values
|
||||
// if ( m_AnimOverlay[i].m_nSequence != m_iv_AnimOverlay.GetPrev( i )->nSequence )
|
||||
float fCycle = m_AnimOverlay[ i ].m_flCycle;
|
||||
fCycle = ClampCycle( fCycle, IsSequenceLooping( m_AnimOverlay[i].m_nSequence ) );
|
||||
|
||||
fCycle = ClampCycle( fCycle, IsSequenceLooping( m_AnimOverlay[i].m_nSequence ) );
|
||||
if (fWeight > 1.0f)
|
||||
{
|
||||
fWeight = 1.0f;
|
||||
}
|
||||
|
||||
if (fWeight > 1)
|
||||
fWeight = 1;
|
||||
boneSetup.AccumulatePose( pos, q, m_AnimOverlay[i].m_nSequence, fCycle, fWeight, currentTime, m_pIk );
|
||||
|
||||
boneSetup.AccumulatePose( pos, q, m_AnimOverlay[i].m_nSequence, fCycle, fWeight, currentTime, m_pIk );
|
||||
|
||||
#if 1 // _DEBUG
|
||||
if (/* Q_stristr( hdr->pszName(), r_sequence_debug.GetString()) != NULL || */ r_sequence_debug.GetInt() == entindex())
|
||||
{
|
||||
if (1)
|
||||
{
|
||||
DevMsgRT( "%8.4f : %30s : %5.3f : %4.2f : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
}
|
||||
else
|
||||
{
|
||||
int iHead, iPrev1, iPrev2;
|
||||
m_iv_AnimOverlay[i].GetInterpolationInfo( currentTime, &iHead, &iPrev1, &iPrev2 );
|
||||
|
||||
// fake up previous cycle values.
|
||||
float t0;
|
||||
C_AnimationLayer *pHead = m_iv_AnimOverlay[i].GetHistoryValue( iHead, t0 );
|
||||
// reset previous
|
||||
float t1;
|
||||
C_AnimationLayer *pPrev1 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev1, t1 );
|
||||
// reset previous previous
|
||||
float t2;
|
||||
C_AnimationLayer *pPrev2 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev2, t2 );
|
||||
|
||||
if ( pHead && pPrev1 && pPrev2 )
|
||||
{
|
||||
DevMsgRT( "%6.2f : %30s %6.2f (%6.2f:%6.2f:%6.2f) : %6.2f (%6.2f:%6.2f:%6.2f) : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(),
|
||||
fCycle, (float)pPrev2->m_flCycle, (float)pPrev1->m_flCycle, (float)pHead->m_flCycle,
|
||||
fWeight, (float)pPrev2->m_flWeight, (float)pPrev1->m_flWeight, (float)pHead->m_flWeight,
|
||||
i );
|
||||
}
|
||||
else
|
||||
{
|
||||
DevMsgRT( "%6.2f : %30s %6.2f : %6.2f : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#if defined( DEBUG_TF2_OVERLAYS )
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
#endif
|
||||
|
||||
//#define DEBUG_TF2_OVERLAYS
|
||||
#if defined( DEBUG_TF2_OVERLAYS )
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
#if 1 // _DEBUG
|
||||
if (r_sequence_debug.GetInt() == entindex())
|
||||
{
|
||||
if (1)
|
||||
{
|
||||
DevMsgRT( "%8.4f : %30s : %5.3f : %4.2f : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
}
|
||||
else
|
||||
{
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", " ", 0.f, 0.f, i );
|
||||
#endif
|
||||
int iHead, iPrev1, iPrev2;
|
||||
m_iv_AnimOverlay[i].GetInterpolationInfo( currentTime, &iHead, &iPrev1, &iPrev2 );
|
||||
|
||||
// fake up previous cycle values.
|
||||
float t0;
|
||||
CAnimationLayer *pHead = m_iv_AnimOverlay[i].GetHistoryValue( iHead, t0 );
|
||||
// reset previous
|
||||
float t1;
|
||||
CAnimationLayer *pPrev1 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev1, t1 );
|
||||
// reset previous previous
|
||||
float t2;
|
||||
CAnimationLayer *pPrev2 = m_iv_AnimOverlay[i].GetHistoryValue( iPrev2, t2 );
|
||||
|
||||
if ( pHead && pPrev1 && pPrev2 )
|
||||
{
|
||||
DevMsgRT( "%6.2f : %30s %6.2f (%6.2f:%6.2f:%6.2f) : %6.2f (%6.2f:%6.2f:%6.2f) : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(),
|
||||
fCycle, (float)pPrev2->m_flCycle, (float)pPrev1->m_flCycle, (float)pHead->m_flCycle,
|
||||
fWeight, (float)pPrev2->m_flWeight, (float)pPrev1->m_flWeight, (float)pHead->m_flWeight,
|
||||
i );
|
||||
}
|
||||
else
|
||||
{
|
||||
DevMsgRT( "%6.2f : %30s %6.2f : %6.2f : %1d\n", currentTime, boneSetup.GetStudioHdr()->pSeqdesc( m_AnimOverlay[i].m_nSequence ).pszLabel(), fCycle, fWeight, i );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#if defined( DEBUG_TF2_OVERLAYS )
|
||||
else
|
||||
{
|
||||
engine->Con_NPrintf( 10 + j, "%30s %6.2f : %6.2f : %1d", " ", 0.f, 0.f, i );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
if ( !pStudioHdr || !pStudioHdr->SequencesAvailable() )
|
||||
return;
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
|
||||
int nSequences = pStudioHdr->GetNumSeq();
|
||||
|
||||
@ -450,6 +575,12 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't bother with 0-weight layers
|
||||
if ( m_AnimOverlay[j].m_flWeight == 0.0f || m_AnimOverlay[j].m_nOrder == MAX_OVERLAYS )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( m_AnimOverlay[j].m_nSequence );
|
||||
if ( seqdesc.numevents == 0 )
|
||||
continue;
|
||||
@ -479,7 +610,7 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
}
|
||||
}
|
||||
|
||||
mstudioevent_t *pevent = seqdesc.pEvent( 0 );
|
||||
mstudioevent_t *pevent = GetEventIndexForSequence( seqdesc );
|
||||
|
||||
// This makes sure events that occur at the end of a sequence occur are
|
||||
// sent before events that occur at the beginning of a sequence.
|
||||
@ -490,10 +621,10 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
// ignore all non-client-side events
|
||||
if ( pevent[i].type & AE_TYPE_NEWEVENTSYSTEM )
|
||||
{
|
||||
if ( !( pevent[i].type & AE_TYPE_CLIENT ) )
|
||||
if ( !(pevent[i].type & AE_TYPE_CLIENT) )
|
||||
continue;
|
||||
}
|
||||
else if ( pevent[i].event < 5000 ) //Adrian - Support the old event system
|
||||
else if ( pevent[i].Event_OldSystem() < EVENT_CLIENT ) //Adrian - Support the old event system
|
||||
continue;
|
||||
|
||||
if ( pevent[i].cycle <= m_flOverlayPrevEventCycle[j] )
|
||||
@ -503,15 +634,15 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
{
|
||||
Msg( "%i FE %i Looped cycle %f, prev %f ev %f (time %.3f)\n",
|
||||
gpGlobals->tickcount,
|
||||
pevent[i].event,
|
||||
pevent[i].Event(),
|
||||
pevent[i].cycle,
|
||||
m_flOverlayPrevEventCycle[j],
|
||||
(float)m_flOverlayPrevEventCycle[j],
|
||||
(float)m_AnimOverlay[j].m_flCycle,
|
||||
gpGlobals->curtime );
|
||||
}
|
||||
|
||||
|
||||
FireEvent( GetAbsOrigin(), GetAbsAngles(), pevent[ i ].event, pevent[ i ].pszOptions() );
|
||||
FireEvent( GetAbsOrigin(), GetAbsAngles(), pevent[ i ].Event(), pevent[ i ].pszOptions() );
|
||||
}
|
||||
|
||||
// Necessary to get the next loop working
|
||||
@ -522,27 +653,29 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
{
|
||||
if ( pevent[i].type & AE_TYPE_NEWEVENTSYSTEM )
|
||||
{
|
||||
if ( !( pevent[i].type & AE_TYPE_CLIENT ) )
|
||||
if ( !(pevent[i].type & AE_TYPE_CLIENT) )
|
||||
continue;
|
||||
}
|
||||
else if ( pevent[i].event < 5000 ) //Adrian - Support the old event system
|
||||
else if ( pevent[i].Event_OldSystem() < EVENT_CLIENT ) //Adrian - Support the old event system
|
||||
continue;
|
||||
|
||||
if ( (pevent[i].cycle > m_flOverlayPrevEventCycle[j] && pevent[i].cycle <= m_AnimOverlay[j].m_flCycle) )
|
||||
bool bStartedSequence = ( m_flOverlayPrevEventCycle[j] > m_AnimOverlay[j].m_flCycle || m_flOverlayPrevEventCycle[j] == 0 );
|
||||
|
||||
if ( ( ( pevent[i].cycle > m_flOverlayPrevEventCycle[j] || bStartedSequence && pevent[i].cycle == 0 ) && pevent[i].cycle <= m_AnimOverlay[j].m_flCycle) )
|
||||
{
|
||||
if ( watch )
|
||||
{
|
||||
Msg( "%i (seq: %d) FE %i Normal cycle %f, prev %f ev %f (time %.3f)\n",
|
||||
gpGlobals->tickcount,
|
||||
m_AnimOverlay[j].m_nSequence.GetRaw(),
|
||||
pevent[i].event,
|
||||
pevent[i].cycle,
|
||||
m_flOverlayPrevEventCycle[j],
|
||||
(int)m_AnimOverlay[j].m_nSequence,
|
||||
(int)pevent[i].Event(),
|
||||
(float)pevent[i].cycle,
|
||||
(float)m_flOverlayPrevEventCycle[j],
|
||||
(float)m_AnimOverlay[j].m_flCycle,
|
||||
gpGlobals->curtime );
|
||||
}
|
||||
|
||||
FireEvent( GetAbsOrigin(), GetAbsAngles(), pevent[ i ].event, pevent[ i ].pszOptions() );
|
||||
FireEvent( GetAbsOrigin(), GetAbsAngles(), pevent[ i ].Event(), pevent[ i ].pszOptions() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,6 +683,7 @@ void C_BaseAnimatingOverlay::DoAnimationEvents( CStudioHdr *pStudioHdr )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -566,3 +700,54 @@ CStudioHdr *C_BaseAnimatingOverlay::OnNewModel()
|
||||
|
||||
return hdr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseAnimatingOverlay::CheckInterpChanges( void )
|
||||
{
|
||||
CDisableRangeChecks disableRangeChecks;
|
||||
|
||||
for (int i = 0; i < m_AnimOverlay.Count(); i++)
|
||||
{
|
||||
int iHead, iPrev1, iPrev2;
|
||||
m_iv_AnimOverlay[i].GetInterpolationInfo( gpGlobals->curtime, &iHead, &iPrev1, &iPrev2 );
|
||||
|
||||
float t0;
|
||||
CAnimationLayer *pHead = m_iv_AnimOverlay[i].GetHistoryValue( iHead, t0 );
|
||||
|
||||
float t1;
|
||||
CAnimationLayer *pPrev = m_iv_AnimOverlay[i].GetHistoryValue( iPrev1, t1 );
|
||||
|
||||
if ( !pHead || !pPrev )
|
||||
continue;
|
||||
|
||||
m_AnimOverlay[ i ].m_nInvalidatePhysicsBits = CheckForSequenceBoxChanges( *pHead, *pPrev );
|
||||
}
|
||||
|
||||
CheckForLayerPhysicsInvalidate();
|
||||
}
|
||||
|
||||
void C_BaseAnimatingOverlay::CheckForLayerPhysicsInvalidate( void )
|
||||
{
|
||||
// When the layers interpolate they may change the animation or bbox so we
|
||||
// have them accumulate the changes and call InvalidatePhysicsRecursive if any
|
||||
// changes are needed.
|
||||
int nInvalidatePhysicsChangeBits = 0;
|
||||
|
||||
int nLayerCount = m_AnimOverlay.Count();
|
||||
for ( int i = 0; i < nLayerCount; ++i )
|
||||
{
|
||||
int nChangeBits = m_AnimOverlay[ i ].m_nInvalidatePhysicsBits;
|
||||
if ( nChangeBits )
|
||||
{
|
||||
nInvalidatePhysicsChangeBits |= nChangeBits;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( nInvalidatePhysicsChangeBits )
|
||||
{
|
||||
InvalidatePhysicsRecursive( nInvalidatePhysicsChangeBits );
|
||||
}
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_BASEANIMATINGOVERLAY_H
|
||||
#define C_BASEANIMATINGOVERLAY_H
|
||||
#pragma once
|
||||
|
||||
#include "c_baseanimating.h"
|
||||
#include "toolframework/itoolframework.h"
|
||||
|
||||
// For shared code.
|
||||
#define CBaseAnimatingOverlay C_BaseAnimatingOverlay
|
||||
@ -18,45 +19,54 @@
|
||||
|
||||
class C_BaseAnimatingOverlay : public C_BaseAnimating
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BaseAnimatingOverlay, C_BaseAnimating );
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
DECLARE_INTERPOLATION();
|
||||
|
||||
|
||||
C_BaseAnimatingOverlay();
|
||||
|
||||
// Inherited from C_BaseAnimating
|
||||
public:
|
||||
virtual void AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Quaternion q[], float currentTime );
|
||||
virtual void DoAnimationEvents( CStudioHdr *pStudioHdr );
|
||||
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
|
||||
virtual CStudioHdr *OnNewModel();
|
||||
|
||||
C_AnimationLayer* GetAnimOverlay( int i );
|
||||
void SetNumAnimOverlays( int num ); // This makes sure there is space for this # of layers.
|
||||
int GetNumAnimOverlays() const;
|
||||
|
||||
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
|
||||
|
||||
void CheckForLayerChanges( CStudioHdr *hdr, float currentTime );
|
||||
|
||||
// model specific
|
||||
virtual void AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Quaternion q[], float currentTime );
|
||||
virtual void DoAnimationEvents( CStudioHdr *pStudioHdr );
|
||||
virtual bool Interpolate( float flCurrentTime );
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_OVERLAYS = 15,
|
||||
};
|
||||
|
||||
CUtlVector < C_AnimationLayer > m_AnimOverlay;
|
||||
C_BaseAnimatingOverlay();
|
||||
CAnimationLayer* GetAnimOverlay( int i );
|
||||
void SetNumAnimOverlays( int num ); // This makes sure there is space for this # of layers.
|
||||
int GetNumAnimOverlays() const;
|
||||
void SetOverlayPrevEventCycle( int nSlot, float flValue );
|
||||
|
||||
CUtlVector < CInterpolatedVar< C_AnimationLayer > > m_iv_AnimOverlay;
|
||||
void CheckInterpChanges( void );
|
||||
void CheckForLayerPhysicsInvalidate( void );
|
||||
|
||||
private:
|
||||
void CheckForLayerChanges( CStudioHdr *hdr, float currentTime );
|
||||
|
||||
CUtlVector < CAnimationLayer > m_AnimOverlay;
|
||||
CUtlVector < CInterpolatedVar< CAnimationLayer > > m_iv_AnimOverlay;
|
||||
|
||||
float m_flOverlayPrevEventCycle[ MAX_OVERLAYS ];
|
||||
|
||||
private:
|
||||
C_BaseAnimatingOverlay( const C_BaseAnimatingOverlay & ); // not defined, not accessible
|
||||
|
||||
friend void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len );
|
||||
};
|
||||
|
||||
|
||||
inline void C_BaseAnimatingOverlay::SetOverlayPrevEventCycle( int nSlot, float flValue )
|
||||
{
|
||||
m_flOverlayPrevEventCycle[nSlot] = flValue;
|
||||
}
|
||||
|
||||
EXTERN_RECV_TABLE(DT_BaseAnimatingOverlay);
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client's C_BaseCombatCharacter entity
|
||||
//
|
||||
@ -12,7 +12,6 @@
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_basecombatcharacter.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@ -26,15 +25,7 @@
|
||||
C_BaseCombatCharacter::C_BaseCombatCharacter()
|
||||
{
|
||||
for ( int i=0; i < m_iAmmo.Count(); i++ )
|
||||
{
|
||||
m_iAmmo.Set( i, 0 );
|
||||
}
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
m_pGlowEffect = NULL;
|
||||
m_bGlowEnabled = false;
|
||||
m_bOldGlowEnabled = false;
|
||||
#endif // GLOWS_ENABLE
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -42,9 +33,6 @@ C_BaseCombatCharacter::C_BaseCombatCharacter()
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatCharacter::~C_BaseCombatCharacter()
|
||||
{
|
||||
#ifdef GLOWS_ENABLE
|
||||
DestroyGlowEffect();
|
||||
#endif // GLOWS_ENABLE
|
||||
}
|
||||
|
||||
/*
|
||||
@ -57,33 +45,6 @@ int C_BaseCombatCharacter::GetAmmoCount( char *szName ) const
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::OnPreDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnPreDataChanged( updateType );
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
m_bOldGlowEnabled = m_bGlowEnabled;
|
||||
#endif // GLOWS_ENABLE
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
if ( m_bOldGlowEnabled != m_bGlowEnabled )
|
||||
{
|
||||
UpdateGlowEffect();
|
||||
}
|
||||
#endif // GLOWS_ENABLE
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Overload our muzzle flash and send it to any actively held weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -101,71 +62,26 @@ void C_BaseCombatCharacter::DoMuzzleFlash()
|
||||
BaseClass::DoMuzzleFlash();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::GetGlowEffectColor( float *r, float *g, float *b )
|
||||
{
|
||||
*r = 0.76f;
|
||||
*g = 0.76f;
|
||||
*b = 0.76f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::UpdateGlowEffect( void )
|
||||
{
|
||||
// destroy the existing effect
|
||||
if ( m_pGlowEffect )
|
||||
{
|
||||
DestroyGlowEffect();
|
||||
}
|
||||
|
||||
// create a new effect
|
||||
if ( m_bGlowEnabled )
|
||||
{
|
||||
float r, g, b;
|
||||
GetGlowEffectColor( &r, &g, &b );
|
||||
|
||||
m_pGlowEffect = new CGlowObject( this, Vector( r, g, b ), 1.0, true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::DestroyGlowEffect( void )
|
||||
{
|
||||
if ( m_pGlowEffect )
|
||||
{
|
||||
delete m_pGlowEffect;
|
||||
m_pGlowEffect = NULL;
|
||||
}
|
||||
}
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
IMPLEMENT_CLIENTCLASS(C_BaseCombatCharacter, DT_BaseCombatCharacter, CBaseCombatCharacter);
|
||||
|
||||
// Only send active weapon index to local player
|
||||
BEGIN_RECV_TABLE_NOBASE( C_BaseCombatCharacter, DT_BCCLocalPlayerExclusive )
|
||||
RecvPropTime( RECVINFO( m_flNextAttack ) ),
|
||||
|
||||
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hMyWeapons), RecvPropEHandle( RECVINFO( m_hMyWeapons[0] ) ) ),
|
||||
|
||||
|
||||
END_RECV_TABLE();
|
||||
|
||||
|
||||
BEGIN_RECV_TABLE(C_BaseCombatCharacter, DT_BaseCombatCharacter)
|
||||
RecvPropDataTable( "bcc_localdata", 0, 0, &REFERENCE_RECV_TABLE(DT_BCCLocalPlayerExclusive) ),
|
||||
RecvPropEHandle( RECVINFO( m_hActiveWeapon ) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hMyWeapons), RecvPropEHandle( RECVINFO( m_hMyWeapons[0] ) ) ),
|
||||
#ifdef GLOWS_ENABLE
|
||||
RecvPropBool( RECVINFO( m_bGlowEnabled ) ),
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
#ifdef INVASION_CLIENT_DLL
|
||||
RecvPropInt( RECVINFO( m_iPowerups ) ),
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Defines the client-side representation of CBaseCombatCharacter.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_BASECOMBATCHARACTER_H
|
||||
#define C_BASECOMBATCHARACTER_H
|
||||
@ -14,15 +14,12 @@
|
||||
|
||||
#include "shareddefs.h"
|
||||
#include "c_baseflex.h"
|
||||
#ifdef GLOWS_ENABLE
|
||||
#include "glow_outline_effect.h"
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
#define BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE 0.9f
|
||||
|
||||
class C_BaseCombatWeapon;
|
||||
class C_WeaponCombatShield;
|
||||
|
||||
#define BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE 0.9f
|
||||
|
||||
class C_BaseCombatCharacter : public C_BaseFlex
|
||||
{
|
||||
DECLARE_CLASS( C_BaseCombatCharacter, C_BaseFlex );
|
||||
@ -33,9 +30,6 @@ public:
|
||||
C_BaseCombatCharacter( void );
|
||||
virtual ~C_BaseCombatCharacter( void );
|
||||
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
virtual bool IsBaseCombatCharacter( void ) { return true; };
|
||||
virtual C_BaseCombatCharacter *MyCombatCharacterPointer( void ) { return this; }
|
||||
|
||||
@ -60,7 +54,6 @@ public:
|
||||
virtual bool IsLineOfSightClear( CBaseEntity *entity, LineOfSightCheckType checkType = IGNORE_NOTHING ) const;// strictly LOS check with no other considerations
|
||||
virtual bool IsLineOfSightClear( const Vector &pos, LineOfSightCheckType checkType = IGNORE_NOTHING, CBaseEntity *entityToIgnore = NULL ) const;
|
||||
|
||||
|
||||
// -----------------------
|
||||
// Ammo
|
||||
// -----------------------
|
||||
@ -70,7 +63,8 @@ public:
|
||||
int GetAmmoCount( int iAmmoIndex ) const;
|
||||
int GetAmmoCount( char *szName ) const;
|
||||
|
||||
C_BaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon, int iSubType = 0 ) const; // True if already owns a weapon of this class
|
||||
virtual C_BaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon, int iSubType = 0 ) const; // True if already owns a weapon of this class
|
||||
virtual int Weapon_GetSlot( const char *pszWeapon, int iSubType = 0 ) const; // Returns -1 if they don't have one
|
||||
virtual bool Weapon_Switch( C_BaseCombatWeapon *pWeapon, int viewmodelindex = 0 );
|
||||
virtual bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
|
||||
|
||||
@ -78,8 +72,8 @@ public:
|
||||
bool SwitchToNextBestWeapon(C_BaseCombatWeapon *pCurrent);
|
||||
|
||||
virtual C_BaseCombatWeapon *GetActiveWeapon( void ) const;
|
||||
int WeaponCount() const;
|
||||
C_BaseCombatWeapon *GetWeapon( int i ) const;
|
||||
int WeaponCount() const;
|
||||
virtual C_BaseCombatWeapon *GetWeapon( int i ) const;
|
||||
|
||||
// This is a sort of hack back-door only used by physgun!
|
||||
void SetAmmoCount( int iCount, int iAmmoIndex );
|
||||
@ -92,85 +86,47 @@ public:
|
||||
// Blood color (see BLOOD_COLOR_* macros in baseentity.h)
|
||||
void SetBloodColor( int nBloodColor );
|
||||
|
||||
virtual void DoMuzzleFlash();
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; }
|
||||
virtual void GetGlowEffectColor( float *r, float *g, float *b );
|
||||
#endif // GLOWS_ENABLE
|
||||
virtual void DoMuzzleFlash();
|
||||
|
||||
public:
|
||||
|
||||
// BEGIN PREDICTION DATA COMPACTION (these fields are together to allow for faster copying in prediction system)
|
||||
float m_flNextAttack;
|
||||
|
||||
protected:
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
virtual void UpdateGlowEffect( void );
|
||||
virtual void DestroyGlowEffect( void );
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
int m_bloodColor; // color of blood particless
|
||||
private:
|
||||
bool ComputeLOS( const Vector &vecEyePosition, const Vector &vecTarget ) const;
|
||||
|
||||
private:
|
||||
bool ComputeLOS( const Vector &vecEyePosition, const Vector &vecTarget ) const;
|
||||
|
||||
CNetworkArray( int, m_iAmmo, MAX_AMMO_TYPES );
|
||||
|
||||
CHandle<C_BaseCombatWeapon> m_hMyWeapons[MAX_WEAPONS];
|
||||
CHandle< C_BaseCombatWeapon > m_hActiveWeapon;
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
bool m_bGlowEnabled;
|
||||
bool m_bOldGlowEnabled;
|
||||
CGlowObject *m_pGlowEffect;
|
||||
#endif // GLOWS_ENABLE
|
||||
// END PREDICTION DATA COMPACTION
|
||||
|
||||
protected:
|
||||
|
||||
int m_bloodColor; // color of blood particless
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
C_BaseCombatCharacter( const C_BaseCombatCharacter & ); // not defined, not accessible
|
||||
|
||||
|
||||
//-----------------------
|
||||
#ifdef INVASION_CLIENT_DLL
|
||||
public:
|
||||
virtual void Release( void );
|
||||
virtual void SetDormant( bool bDormant );
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void ClientThink( void );
|
||||
|
||||
// TF2 Powerups
|
||||
virtual bool CanBePoweredUp( void ) { return true; }
|
||||
bool HasPowerup( int iPowerup ) { return ( m_iPowerups & (1 << iPowerup) ) != 0; };
|
||||
virtual void PowerupStart( int iPowerup, bool bInitial );
|
||||
virtual void PowerupEnd( int iPowerup );
|
||||
void RemoveAllPowerups( void );
|
||||
|
||||
// Powerup effects
|
||||
void AddEMPEffect( float flSize );
|
||||
void AddBuffEffect( float flSize );
|
||||
|
||||
C_WeaponCombatShield *GetShield( void );
|
||||
|
||||
public:
|
||||
int m_iPowerups;
|
||||
int m_iPrevPowerups;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
inline C_BaseCombatCharacter *ToBaseCombatCharacter( C_BaseEntity *pEntity )
|
||||
{
|
||||
if ( !pEntity || !pEntity->IsBaseCombatCharacter() )
|
||||
return NULL;
|
||||
|
||||
#if _DEBUG
|
||||
return dynamic_cast<C_BaseCombatCharacter *>( pEntity );
|
||||
#else
|
||||
return static_cast<C_BaseCombatCharacter *>( pEntity );
|
||||
#endif
|
||||
return pEntity ? pEntity->MyCombatCharacterPointer() : NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -179,16 +135,6 @@ inline int C_BaseCombatCharacter::WeaponCount() const
|
||||
return MAX_WEAPONS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : i -
|
||||
//-----------------------------------------------------------------------------
|
||||
inline C_BaseCombatWeapon *C_BaseCombatCharacter::GetWeapon( int i ) const
|
||||
{
|
||||
Assert( (i >= 0) && (i < MAX_WEAPONS) );
|
||||
return m_hMyWeapons[i].Get();
|
||||
}
|
||||
|
||||
EXTERN_RECV_TABLE(DT_BaseCombatCharacter);
|
||||
|
||||
#endif // C_BASECOMBATCHARACTER_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side implementation of CBaseCombatWeapon.
|
||||
//
|
||||
@ -20,26 +20,13 @@
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Gets the local client's active weapon, if any.
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatWeapon *GetActiveWeapon( void )
|
||||
{
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
if ( !player )
|
||||
return NULL;
|
||||
|
||||
return player->GetActiveWeapon();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::SetDormant( bool bDormant )
|
||||
{
|
||||
// If I'm going from active to dormant and I'm carried by another player, holster me.
|
||||
if ( !IsDormant() && bDormant && GetOwner() && !IsCarriedByLocalPlayer() )
|
||||
if ( !IsDormant() && bDormant && !IsCarriedByLocalPlayer() )
|
||||
{
|
||||
Holster( NULL );
|
||||
}
|
||||
@ -75,16 +62,13 @@ void C_BaseCombatWeapon::NotifyShouldTransmit( ShouldTransmitState_t state )
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: To wrap PORTAL mod specific functionality into one place
|
||||
//-----------------------------------------------------------------------------
|
||||
static inline bool ShouldDrawLocalPlayerViewModel( void )
|
||||
|
||||
static inline bool ShouldDrawLocalPlayer( C_BasePlayer *pl )
|
||||
{
|
||||
#if defined( PORTAL )
|
||||
return false;
|
||||
#else
|
||||
return !C_BasePlayer::ShouldDrawLocalPlayer();
|
||||
#endif
|
||||
|
||||
Assert( pl );
|
||||
return pl->ShouldDrawLocalPlayer();
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -96,7 +80,7 @@ void C_BaseCombatWeapon::OnRestore()
|
||||
|
||||
// if the player is holding this weapon,
|
||||
// mark it as just restored so it won't show as a new pickup
|
||||
if (GetOwner() == C_BasePlayer::GetLocalPlayer())
|
||||
if ( C_BasePlayer::IsLocalPlayer( GetOwner() ) )
|
||||
{
|
||||
m_bJustRestored = true;
|
||||
}
|
||||
@ -104,17 +88,6 @@ void C_BaseCombatWeapon::OnRestore()
|
||||
|
||||
int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
||||
{
|
||||
if ( GameRules() )
|
||||
{
|
||||
const char *pBaseName = modelinfo->GetModelName( modelinfo->GetModel( m_iWorldModelIndex ) );
|
||||
const char *pTranslatedName = GameRules()->TranslateEffectForVisionFilter( "weapons", pBaseName );
|
||||
|
||||
if ( pTranslatedName != pBaseName )
|
||||
{
|
||||
return modelinfo->GetModelIndex( pTranslatedName );
|
||||
}
|
||||
}
|
||||
|
||||
return m_iWorldModelIndex;
|
||||
}
|
||||
|
||||
@ -124,22 +97,23 @@ int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged(updateType);
|
||||
|
||||
CHandle< C_BaseCombatWeapon > handle = this;
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
// If it's being carried by the *local* player, on the first update,
|
||||
// find the registered weapon for this ID
|
||||
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
C_BaseCombatCharacter *pOwner = GetOwner();
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( pOwner );
|
||||
|
||||
// check if weapon is carried by local player
|
||||
bool bIsLocalPlayer = pPlayer && pPlayer == pOwner;
|
||||
if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() ) // TODO: figure out the purpose of the ShouldDrawLocalPlayer() test.
|
||||
bool bIsLocalPlayer = C_BasePlayer::IsLocalPlayer( pPlayer );
|
||||
if ( bIsLocalPlayer )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) );
|
||||
|
||||
// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
|
||||
if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
|
||||
if ( ( m_iState != WEAPON_NOT_CARRIED ) &&
|
||||
( m_iOldState == WEAPON_NOT_CARRIED ) )
|
||||
{
|
||||
// Tell the HUD this weapon's been picked up
|
||||
if ( ShouldDrawPickup() )
|
||||
@ -154,15 +128,7 @@ void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
|
||||
}
|
||||
}
|
||||
}
|
||||
else // weapon carried by other player or not at all
|
||||
{
|
||||
int overrideModelIndex = CalcOverrideModelIndex();
|
||||
if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() )
|
||||
{
|
||||
SetModelIndex( overrideModelIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateVisibility();
|
||||
|
||||
m_iOldState = m_iState;
|
||||
@ -200,10 +166,10 @@ ShadowType_t C_BaseCombatWeapon::ShadowCastType()
|
||||
if (!IsBeingCarried())
|
||||
return SHADOWS_RENDER_TO_TEXTURE;
|
||||
|
||||
if (IsCarriedByLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer())
|
||||
if (IsCarriedByLocalPlayer())
|
||||
return SHADOWS_NONE;
|
||||
|
||||
return SHADOWS_RENDER_TO_TEXTURE;
|
||||
return (m_iState != WEAPON_IS_CARRIED_BY_PLAYER) ? SHADOWS_RENDER_TO_TEXTURE : SHADOWS_NONE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -212,24 +178,24 @@ ShadowType_t C_BaseCombatWeapon::ShadowCastType()
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::Redraw()
|
||||
{
|
||||
if ( g_pClientMode->ShouldDrawCrosshair() )
|
||||
if ( GetClientMode()->ShouldDrawCrosshair() )
|
||||
{
|
||||
DrawCrosshair();
|
||||
}
|
||||
|
||||
// ammo drawing has been moved into hud_ammo.cpp
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw the weapon's crosshair
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::DrawCrosshair()
|
||||
{
|
||||
#ifndef INFESTED_DLL
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
Color clr = gHUD.m_clrNormal;
|
||||
Color clr = GetHud().m_clrNormal;
|
||||
/*
|
||||
|
||||
// TEST: if the thing under your crosshair is on a different team, light the crosshair with a different color.
|
||||
@ -263,7 +229,7 @@ void C_BaseCombatWeapon::DrawCrosshair()
|
||||
return;
|
||||
|
||||
// Find out if this weapon's auto-aimed onto a target
|
||||
bool bOnTarget = ( m_iState == WEAPON_IS_ONTARGET );
|
||||
bool bOnTarget = ( m_iState == WEAPON_IS_ACTIVE ) && player->m_fOnTarget;
|
||||
|
||||
if ( player->GetFOV() >= 90 )
|
||||
{
|
||||
@ -296,8 +262,8 @@ void C_BaseCombatWeapon::DrawCrosshair()
|
||||
else
|
||||
crosshair->ResetCrosshair();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: This weapon is the active weapon, and the viewmodel for it was just drawn.
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -313,20 +279,9 @@ bool C_BaseCombatWeapon::IsCarriedByLocalPlayer( void )
|
||||
if ( !GetOwner() )
|
||||
return false;
|
||||
|
||||
return ( GetOwner() == C_BasePlayer::GetLocalPlayer() );
|
||||
return ( C_BasePlayer::IsLocalPlayer( GetOwner() ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this client is carrying this weapon and is
|
||||
// using the view models
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BaseCombatWeapon::ShouldDrawUsingViewModel( void )
|
||||
{
|
||||
return IsCarriedByLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this weapon is the local client's currently wielded weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -360,10 +315,17 @@ bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles )
|
||||
vAngles.Init();
|
||||
}
|
||||
|
||||
QAngle vDummy;
|
||||
if ( IsActiveByLocalPlayer() && ShouldDrawLocalPlayerViewModel() )
|
||||
C_BasePlayer *player = ToBasePlayer( pEnt );
|
||||
bool bUseViewModel = false;
|
||||
if ( C_BasePlayer::IsLocalPlayer( pEnt ) )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pEnt );
|
||||
bUseViewModel = !player->ShouldDrawLocalPlayer();
|
||||
}
|
||||
|
||||
QAngle vDummy;
|
||||
if ( IsActiveByLocalPlayer() && bUseViewModel )
|
||||
{
|
||||
C_BasePlayer *player = ToBasePlayer( pEnt );
|
||||
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
|
||||
if ( vm )
|
||||
{
|
||||
@ -411,7 +373,6 @@ bool C_BaseCombatWeapon::ShouldDraw( void )
|
||||
return true;
|
||||
|
||||
bool bIsActive = ( m_iState == WEAPON_IS_ACTIVE );
|
||||
|
||||
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
// carried by local player?
|
||||
@ -421,15 +382,8 @@ bool C_BaseCombatWeapon::ShouldDraw( void )
|
||||
if ( !bIsActive )
|
||||
return false;
|
||||
|
||||
if ( !pOwner->ShouldDraw() )
|
||||
{
|
||||
// Our owner is invisible.
|
||||
// This also tests whether the player is zoomed in, in which case you don't want to draw the weapon.
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3rd person mode?
|
||||
if ( !ShouldDrawLocalPlayerViewModel() )
|
||||
// 3rd person mode
|
||||
if ( pLocalPlayer->ShouldDrawLocalPlayer() )
|
||||
return true;
|
||||
|
||||
// don't draw active weapon if not in some kind of 3rd person mode, the viewmodel will do that
|
||||
@ -462,11 +416,40 @@ bool C_BaseCombatWeapon::ShouldDrawPickup( void )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Hooks into the fast path render system
|
||||
//----------------------------------------------------------------------------
|
||||
IClientModelRenderable* C_BaseCombatWeapon::GetClientModelRenderable()
|
||||
{
|
||||
if ( !m_bReadyToDraw )
|
||||
return 0;
|
||||
|
||||
// check if local player chases owner of this weapon in first person
|
||||
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( localplayer && localplayer->IsObserver() && GetOwner() )
|
||||
{
|
||||
// don't draw weapon if chasing this guy as spectator
|
||||
// we don't check that in ShouldDraw() since this may change
|
||||
// without notification
|
||||
if ( localplayer->GetObserverMode() == OBS_MODE_IN_EYE &&
|
||||
localplayer->GetObserverTarget() == GetOwner() )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !BaseClass::GetClientModelRenderable() )
|
||||
return NULL;
|
||||
|
||||
EnsureCorrectRenderingModel();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
|
||||
// by this player, otherwise draw the worldmodel.
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseCombatWeapon::DrawModel( int flags )
|
||||
int C_BaseCombatWeapon::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
VPROF_BUDGET( "C_BaseCombatWeapon::DrawModel", VPROF_BUDGETGROUP_MODEL_RENDERING );
|
||||
if ( !m_bReadyToDraw )
|
||||
@ -489,32 +472,40 @@ int C_BaseCombatWeapon::DrawModel( int flags )
|
||||
return false;
|
||||
}
|
||||
|
||||
return BaseClass::DrawModel( flags );
|
||||
// See comment below
|
||||
EnsureCorrectRenderingModel();
|
||||
|
||||
return BaseClass::DrawModel( flags, instance );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Allows the client-side entity to override what the network tells it to use for
|
||||
// a model. This is used for third person mode, specifically in HL2 where the
|
||||
// the weapon timings are on the view model and not the world model. That means the
|
||||
// server needs to use the view model, but the client wants to use the world model.
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseCombatWeapon::CalcOverrideModelIndex()
|
||||
{
|
||||
// If the local player is visible (thirdperson mode, tf2 taunts, etc., then make sure that we are using the
|
||||
// w_ (world) model not the v_ (view) model or else the model can flicker, etc.
|
||||
// Otherwise, if we're not the local player, always use the world model
|
||||
void C_BaseCombatWeapon::EnsureCorrectRenderingModel()
|
||||
{
|
||||
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( localplayer &&
|
||||
localplayer == GetOwner() &&
|
||||
ShouldDrawLocalPlayerViewModel() )
|
||||
!localplayer->ShouldDrawLocalPlayer() )
|
||||
{
|
||||
return BaseClass::CalcOverrideModelIndex();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// BRJ 10/14/02
|
||||
// FIXME: Remove when Yahn's client-side prediction is done
|
||||
// It's a hacky workaround for the model indices fighting
|
||||
// (GetRenderBounds uses the model index, which is for the view model)
|
||||
SetModelIndex( GetWorldModelIndex() );
|
||||
|
||||
// Validate our current sequence just in case ( in theory the view and weapon models should have the same sequences for sequences that overlap at least )
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
if ( pStudioHdr &&
|
||||
GetSequence() >= pStudioHdr->GetNumSeq() )
|
||||
{
|
||||
return GetWorldModelIndex();
|
||||
SetSequence( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// tool recording
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client's CBaseCombatWeapon entity
|
||||
//
|
||||
@ -19,8 +19,4 @@
|
||||
class CViewSetup;
|
||||
class C_BaseViewModel;
|
||||
|
||||
// Accessors for local weapons
|
||||
C_BaseCombatWeapon *GetActiveWeapon( void );
|
||||
|
||||
|
||||
#endif // C_BASECOMBATWEAPON
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -11,15 +11,16 @@
|
||||
#endif
|
||||
|
||||
#include "c_baseentity.h"
|
||||
#include "c_basetoggle.h"
|
||||
|
||||
#if defined( CLIENT_DLL )
|
||||
#define CBaseDoor C_BaseDoor
|
||||
#endif
|
||||
|
||||
class C_BaseDoor : public C_BaseEntity
|
||||
class C_BaseDoor : public C_BaseToggle
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BaseDoor, C_BaseEntity );
|
||||
DECLARE_CLASS( C_BaseDoor, C_BaseToggle );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_BaseDoor( void );
|
||||
@ -29,4 +30,4 @@ public:
|
||||
float m_flWaveHeight;
|
||||
};
|
||||
|
||||
#endif // C_BASEDOOR_H
|
||||
#endif // C_BASEDOOR_H
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -16,7 +16,7 @@
|
||||
#include "c_baseanimatingoverlay.h"
|
||||
#include "sceneentity_shared.h"
|
||||
|
||||
#include "utlvector.h"
|
||||
#include "UtlVector.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Item in list of loaded scene files
|
||||
@ -37,93 +37,10 @@ public:
|
||||
struct Emphasized_Phoneme;
|
||||
class CSentence;
|
||||
|
||||
enum
|
||||
{
|
||||
PHONEME_CLASS_WEAK = 0,
|
||||
PHONEME_CLASS_NORMAL,
|
||||
PHONEME_CLASS_STRONG,
|
||||
|
||||
NUM_PHONEME_CLASSES
|
||||
};
|
||||
|
||||
// Mapping for each loaded scene file used by this actor
|
||||
struct FS_LocalToGlobal_t
|
||||
{
|
||||
explicit FS_LocalToGlobal_t() :
|
||||
m_Key( 0 ),
|
||||
m_nCount( 0 ),
|
||||
m_Mapping( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
explicit FS_LocalToGlobal_t( const flexsettinghdr_t *key ) :
|
||||
m_Key( key ),
|
||||
m_nCount( 0 ),
|
||||
m_Mapping( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void SetCount( int count )
|
||||
{
|
||||
Assert( !m_Mapping );
|
||||
Assert( count > 0 );
|
||||
m_nCount = count;
|
||||
m_Mapping = new int[ m_nCount ];
|
||||
Q_memset( m_Mapping, 0, m_nCount * sizeof( int ) );
|
||||
}
|
||||
|
||||
FS_LocalToGlobal_t( const FS_LocalToGlobal_t& src )
|
||||
{
|
||||
m_Key = src.m_Key;
|
||||
delete m_Mapping;
|
||||
m_Mapping = new int[ src.m_nCount ];
|
||||
Q_memcpy( m_Mapping, src.m_Mapping, src.m_nCount * sizeof( int ) );
|
||||
|
||||
m_nCount = src.m_nCount;
|
||||
}
|
||||
|
||||
~FS_LocalToGlobal_t()
|
||||
{
|
||||
delete m_Mapping;
|
||||
m_nCount = 0;
|
||||
m_Mapping = 0;
|
||||
}
|
||||
|
||||
const flexsettinghdr_t *m_Key;
|
||||
int m_nCount;
|
||||
int *m_Mapping = NULL;
|
||||
};
|
||||
|
||||
bool FlexSettingLessFunc( const FS_LocalToGlobal_t& lhs, const FS_LocalToGlobal_t& rhs );
|
||||
|
||||
class IHasLocalToGlobalFlexSettings
|
||||
{
|
||||
public:
|
||||
virtual void EnsureTranslations( const flexsettinghdr_t *pSettinghdr ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Emphasized_Phoneme
|
||||
{
|
||||
// Global fields, setup at start
|
||||
char classname[ 64 ];
|
||||
bool required;
|
||||
// Global fields setup first time tracks played
|
||||
bool basechecked;
|
||||
const flexsettinghdr_t *base;
|
||||
const flexsetting_t *exp;
|
||||
|
||||
// Local fields, processed for each sentence
|
||||
bool valid;
|
||||
float amount;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_BaseFlex : public C_BaseAnimatingOverlay, public IHasLocalToGlobalFlexSettings
|
||||
class C_BaseFlex : public C_BaseAnimatingOverlay
|
||||
{
|
||||
DECLARE_CLASS( C_BaseFlex, C_BaseAnimatingOverlay );
|
||||
public:
|
||||
@ -136,35 +53,29 @@ public:
|
||||
|
||||
virtual void Spawn();
|
||||
|
||||
virtual IClientModelRenderable* GetClientModelRenderable();
|
||||
|
||||
virtual void InitPhonemeMappings();
|
||||
|
||||
void SetupMappings( char const *pchFileRoot );
|
||||
|
||||
virtual CStudioHdr *OnNewModel( void );
|
||||
|
||||
virtual void StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
|
||||
virtual void StandardBlendingRules( CStudioHdr *hdr, Vector pos[], QuaternionAligned q[], float currentTime, int boneMask );
|
||||
|
||||
virtual void OnThreadedDrawSetup();
|
||||
|
||||
// model specific
|
||||
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
|
||||
static void LinkToGlobalFlexControllers( CStudioHdr *hdr );
|
||||
virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
|
||||
virtual bool SetupGlobalWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
|
||||
static void RunFlexDelay( int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights, float &flFlexDelayTime );
|
||||
virtual void SetupLocalWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
|
||||
virtual bool UsesFlexDelayedWeights();
|
||||
|
||||
static void RunFlexRules( CStudioHdr *pStudioHdr, float *dest );
|
||||
|
||||
virtual Vector SetViewTarget( CStudioHdr *pStudioHdr );
|
||||
|
||||
virtual bool GetSoundSpatialization( SpatializationInfo_t& info );
|
||||
|
||||
virtual void GetToolRecordingState( KeyValues *msg );
|
||||
|
||||
// Called at the lowest level to actually apply a flex animation
|
||||
void AddFlexAnimation( CSceneEventInfo *info );
|
||||
void AddFlexAnimation( CSceneEventInfo *info );
|
||||
|
||||
void SetFlexWeight( LocalFlexController_t index, float value );
|
||||
float GetFlexWeight( LocalFlexController_t index );
|
||||
@ -181,7 +92,7 @@ public:
|
||||
|
||||
int m_blinktoggle;
|
||||
|
||||
static int AddGlobalFlexController( const char *szName );
|
||||
static int AddGlobalFlexController( char *szName );
|
||||
static char const *GetGlobalFlexControllerName( int idx );
|
||||
|
||||
// bah, this should be unified with all prev/current stuff.
|
||||
@ -195,16 +106,6 @@ public:
|
||||
// Start the specifics of an scene event
|
||||
virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, C_BaseEntity *pTarget );
|
||||
|
||||
// Manipulation of events for the object
|
||||
// Should be called by think function to process all scene events
|
||||
// The default implementation resets m_flexWeight array and calls
|
||||
// AddSceneEvents
|
||||
virtual void ProcessSceneEvents( bool bFlexEvents );
|
||||
|
||||
// Assumes m_flexWeight array has been set up, this adds the actual currently playing
|
||||
// expressions to the flex weights and adds other scene events as needed
|
||||
virtual bool ProcessSceneEvent( bool bFlexEvents, CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
virtual bool ProcessSequenceSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
// Remove all playing events
|
||||
@ -214,7 +115,7 @@ public:
|
||||
virtual bool ClearSceneEvent( CSceneEventInfo *info, bool fastKill, bool canceled );
|
||||
|
||||
// Add the event to the queue for this actor
|
||||
void AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, C_BaseEntity *pTarget = NULL, bool bClientSide = false );
|
||||
void AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, C_BaseEntity *pTarget = NULL, bool bClientSide = false, C_SceneEntity *pSceneEntity = NULL );
|
||||
|
||||
// Remove the event from the queue for this actor
|
||||
void RemoveSceneEvent( CChoreoScene *scene, CChoreoEvent *event, bool fastKill );
|
||||
@ -226,20 +127,33 @@ public:
|
||||
virtual bool CheckSceneEventCompletion( CSceneEventInfo *info, float currenttime, CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
int FlexControllerLocalToGlobal( const flexsettinghdr_t *pSettinghdr, int key );
|
||||
|
||||
// IHasLocalToGlobalFlexSettings
|
||||
virtual void EnsureTranslations( const flexsettinghdr_t *pSettinghdr );
|
||||
void EnsureTranslations( const flexsettinghdr_t *pSettinghdr );
|
||||
|
||||
// For handling scene files
|
||||
void *FindSceneFile( const char *filename );
|
||||
const void *FindSceneFile( const char *filename );
|
||||
|
||||
static void InvalidateFlexCaches();
|
||||
bool IsFlexCacheValid() const;
|
||||
|
||||
private:
|
||||
Vector SetViewTarget( CStudioHdr *pStudioHdr, const float *pGlobalFlexWeight );
|
||||
void RunFlexRules( CStudioHdr *pStudioHdr, const float *pGlobalFlexWeight, float *dest );
|
||||
|
||||
// Manipulation of events for the object
|
||||
// Should be called by think function to process all scene events
|
||||
// The default implementation resets m_flexWeight array and calls
|
||||
// AddSceneEvents
|
||||
void ProcessSceneEvents( bool bFlexEvents, float *pGlobalFlexWeight );
|
||||
|
||||
// Assumes m_flexWeight array has been set up, this adds the actual currently playing
|
||||
// expressions to the flex weights and adds other scene events as needed
|
||||
bool ProcessSceneEvent( float *pGlobalFlexWeight, bool bFlexEvents, CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
bool RequestStartSequenceSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget );
|
||||
|
||||
bool ProcessFlexAnimationSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
bool ProcessFlexSettingSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
void AddFlexSetting( const char *expr, float scale,
|
||||
bool ProcessFlexSettingSceneEvent( float *pGlobalFlexWeight, CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event );
|
||||
void AddFlexSetting( float *pGlobalFlexWeight, const char *expr, float scale,
|
||||
const flexsettinghdr_t *pSettinghdr, bool newexpression );
|
||||
|
||||
// Array of active SceneEvents, in order oldest to newest
|
||||
@ -249,28 +163,107 @@ private:
|
||||
bool HasSceneEvents() const;
|
||||
|
||||
private:
|
||||
// Mapping for each loaded scene file used by this actor
|
||||
struct FS_LocalToGlobal_t
|
||||
{
|
||||
explicit FS_LocalToGlobal_t() :
|
||||
m_Key( 0 ),
|
||||
m_nCount( 0 ),
|
||||
m_Mapping( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
explicit FS_LocalToGlobal_t( const flexsettinghdr_t *key ) :
|
||||
m_Key( key ),
|
||||
m_nCount( 0 ),
|
||||
m_Mapping( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void SetCount( int count )
|
||||
{
|
||||
Assert( !m_Mapping );
|
||||
Assert( count > 0 );
|
||||
m_nCount = count;
|
||||
m_Mapping = new int[ m_nCount ];
|
||||
Q_memset( m_Mapping, 0, m_nCount * sizeof( int ) );
|
||||
}
|
||||
|
||||
FS_LocalToGlobal_t( const FS_LocalToGlobal_t& src )
|
||||
{
|
||||
m_Key = src.m_Key;
|
||||
delete m_Mapping;
|
||||
m_Mapping = new int[ src.m_nCount ];
|
||||
Q_memcpy( m_Mapping, src.m_Mapping, src.m_nCount * sizeof( int ) );
|
||||
|
||||
m_nCount = src.m_nCount;
|
||||
}
|
||||
|
||||
~FS_LocalToGlobal_t()
|
||||
{
|
||||
delete m_Mapping;
|
||||
m_nCount = 0;
|
||||
m_Mapping = 0;
|
||||
}
|
||||
|
||||
const flexsettinghdr_t *m_Key;
|
||||
int m_nCount;
|
||||
int *m_Mapping;
|
||||
};
|
||||
|
||||
static bool FlexSettingLessFunc( const FS_LocalToGlobal_t& lhs, const FS_LocalToGlobal_t& rhs );
|
||||
|
||||
CUtlRBTree< FS_LocalToGlobal_t, unsigned short > m_LocalToGlobal;
|
||||
|
||||
float m_blinktime;
|
||||
int m_prevblinktoggle;
|
||||
|
||||
int m_iBlink;
|
||||
LocalFlexController_t m_iEyeUpdown;
|
||||
LocalFlexController_t m_iEyeRightleft;
|
||||
bool m_bSearchedForEyeFlexes;
|
||||
int m_iBlink;
|
||||
LocalFlexController_t m_iEyeUpdown;
|
||||
LocalFlexController_t m_iEyeRightleft;
|
||||
int m_iMouthAttachment;
|
||||
|
||||
float m_flFlexDelayTime;
|
||||
float *m_flFlexDelayedWeight;
|
||||
int m_cFlexDelayedWeight;
|
||||
|
||||
int m_iMostRecentFlexCounter;
|
||||
Vector m_CachedViewTarget;
|
||||
CUtlVector< float > m_CachedFlexWeights;
|
||||
CUtlVector< float > m_CachedDelayedFlexWeights;
|
||||
|
||||
// shared flex controllers
|
||||
static int g_numflexcontrollers;
|
||||
static char *g_flexcontroller[MAXSTUDIOFLEXCTRL*4]; // room for global set of flexcontrollers
|
||||
static float g_flexweight[MAXSTUDIOFLEXDESC];
|
||||
static float s_pGlobalFlexWeight[MAXSTUDIOFLEXCTRL*4];
|
||||
|
||||
protected:
|
||||
|
||||
enum
|
||||
{
|
||||
PHONEME_CLASS_WEAK = 0,
|
||||
PHONEME_CLASS_NORMAL,
|
||||
PHONEME_CLASS_STRONG,
|
||||
|
||||
NUM_PHONEME_CLASSES
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Emphasized_Phoneme
|
||||
{
|
||||
// Global fields, setup at start
|
||||
char classname[ 64 ];
|
||||
bool required;
|
||||
// Global fields setup first time tracks played
|
||||
bool basechecked;
|
||||
const flexsettinghdr_t *base;
|
||||
const flexsetting_t *exp;
|
||||
|
||||
// Local fields, processed for each sentence
|
||||
bool valid;
|
||||
float amount;
|
||||
};
|
||||
|
||||
Emphasized_Phoneme m_PhonemeClasses[ NUM_PHONEME_CLASSES ];
|
||||
|
||||
private:
|
||||
@ -279,9 +272,9 @@ private:
|
||||
|
||||
const flexsetting_t *FindNamedSetting( const flexsettinghdr_t *pSettinghdr, const char *expr );
|
||||
|
||||
void ProcessVisemes( Emphasized_Phoneme *classes );
|
||||
void AddVisemesForSentence( Emphasized_Phoneme *classes, float emphasis_intensity, CSentence *sentence, float t, float dt, bool juststarted );
|
||||
void AddViseme( Emphasized_Phoneme *classes, float emphasis_intensity, int phoneme, float scale, bool newexpression );
|
||||
void ProcessVisemes( Emphasized_Phoneme *classes, float *pGlobalFlexWeight );
|
||||
void AddVisemesForSentence( float *pGlobalFlexWeight, Emphasized_Phoneme *classes, float emphasis_intensity, CSentence *sentence, float t, float dt, bool juststarted );
|
||||
void AddViseme( float *pGlobalFlexWeight, Emphasized_Phoneme *classes, float emphasis_intensity, int phoneme, float scale, bool newexpression );
|
||||
bool SetupEmphasisBlend( Emphasized_Phoneme *classes, int phoneme );
|
||||
void ComputeBlendedSetting( Emphasized_Phoneme *classes, float emphasis_intensity );
|
||||
|
||||
@ -296,30 +289,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFlexSceneFileManager : CAutoGameSystem
|
||||
{
|
||||
public:
|
||||
|
||||
CFlexSceneFileManager() : CAutoGameSystem( "CFlexSceneFileManager" )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
void EnsureTranslations( IHasLocalToGlobalFlexSettings *instance, const flexsettinghdr_t *pSettinghdr );
|
||||
void *FindSceneFile( IHasLocalToGlobalFlexSettings *instance, const char *filename, bool allowBlockingIO );
|
||||
|
||||
private:
|
||||
void DeleteSceneFiles();
|
||||
|
||||
CUtlVector< CFlexSceneFile * > m_FileList;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Do we have active expressions?
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -333,7 +302,6 @@ EXTERN_RECV_TABLE(DT_BaseFlex);
|
||||
|
||||
float *GetVisemeWeights( int phoneme );
|
||||
|
||||
|
||||
#endif // C_STUDIOFLEX_H
|
||||
|
||||
|
||||
|
3820
game/client/c_baselesson.cpp
Normal file
3820
game/client/c_baselesson.cpp
Normal file
File diff suppressed because it is too large
Load Diff
446
game/client/c_baselesson.h
Normal file
446
game/client/c_baselesson.h
Normal file
@ -0,0 +1,446 @@
|
||||
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client handler for instruction players how to play
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef _C_BASELESSON_H_
|
||||
#define _C_BASELESSON_H_
|
||||
|
||||
|
||||
#include "GameEventListener.h"
|
||||
#include "hud_locator_target.h"
|
||||
|
||||
|
||||
#define DECLARE_LESSON( _lessonClassName, _baseLessonClassName ) \
|
||||
typedef _baseLessonClassName BaseClass;\
|
||||
typedef _lessonClassName ThisClass;\
|
||||
_lessonClassName( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity, int nSplitScreenSlot )\
|
||||
: _baseLessonClassName( pchName, bIsDefaultHolder, bIsOpenOpportunity, nSplitScreenSlot )\
|
||||
{\
|
||||
Init();\
|
||||
}
|
||||
|
||||
|
||||
enum LessonInstanceType
|
||||
{
|
||||
LESSON_INSTANCE_MULTIPLE,
|
||||
LESSON_INSTANCE_SINGLE_OPEN,
|
||||
LESSON_INSTANCE_FIXED_REPLACE,
|
||||
LESSON_INSTANCE_SINGLE_ACTIVE,
|
||||
|
||||
LESSON_INSTANCE_TYPE_TOTAL
|
||||
};
|
||||
|
||||
|
||||
// This is used to solve a problem where bots can take the place of a player, where on or the other don't have valid entities on the client at the same time
|
||||
#define MAX_DELAYED_PLAYER_SWAPS 8
|
||||
|
||||
struct delayed_player_swap_t
|
||||
{
|
||||
CHandle<C_BaseEntity> *phHandleToChange;
|
||||
int iNewUserID;
|
||||
|
||||
delayed_player_swap_t( void )
|
||||
{
|
||||
phHandleToChange = NULL;
|
||||
iNewUserID = -1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
abstract_class CBaseLesson : public CGameEventListener
|
||||
{
|
||||
public:
|
||||
CBaseLesson( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity, int nSplitScreenSlot );
|
||||
virtual ~CBaseLesson( void );
|
||||
|
||||
void AddPrerequisite( const char *pchLessonName );
|
||||
|
||||
const CGameInstructorSymbol& GetNameSymbol( void ) const { return m_stringName; }
|
||||
const char * GetName( void ) const { return m_stringName.String(); }
|
||||
int GetPriority( void ) const { return m_iPriority; }
|
||||
const char * GetCloseReason( void ) const { return m_stringCloseReason.String(); }
|
||||
void SetCloseReason( const char *pchReason ) { m_stringCloseReason = pchReason; }
|
||||
|
||||
CBaseLesson* GetRoot( void ) const { return m_pRoot; }
|
||||
void SetRoot( CBaseLesson *pRoot );
|
||||
const CUtlVector < CBaseLesson * >* GetChildren( void ) const { return &m_OpenOpportunities; }
|
||||
|
||||
float GetInitTime( void ) { return m_fInitTime; }
|
||||
void SetStartTime( void ) { m_fStartTime = gpGlobals->curtime; }
|
||||
void ResetStartTime( void ) { m_fStartTime = 0.0f; m_bHasPlayedSound = false; }
|
||||
|
||||
bool ShouldShowSpew( void );
|
||||
bool NoPriority( void ) const;
|
||||
bool IsDefaultHolder( void ) const { return m_bIsDefaultHolder; }
|
||||
bool IsOpenOpportunity( void ) const { return m_bIsOpenOpportunity; }
|
||||
bool IsLocked( void ) const;
|
||||
bool CanOpenWhenDead( void ) const { return m_bCanOpenWhenDead; }
|
||||
bool IsInstructing( void ) const { return ( m_fStartTime > 0.0f ); }
|
||||
bool IsLearned( void ) const;
|
||||
bool PrerequisitesHaveBeenMet( void ) const;
|
||||
bool IsTimedOut( void );
|
||||
|
||||
int InstanceType( void ) const { return m_iInstanceType; }
|
||||
const CGameInstructorSymbol& GetReplaceKeySymbol( void ) const { return m_stringReplaceKey; }
|
||||
const char* GetReplaceKey( void ) const { return m_stringReplaceKey.String(); }
|
||||
int GetFixedInstancesMax( void ) const { return m_iFixedInstancesMax; }
|
||||
bool ShouldReplaceOnlyWhenStopped( void ) const { return m_bReplaceOnlyWhenStopped; }
|
||||
void SetInstanceActive( bool bInstanceActive ) { m_bInstanceActive = bInstanceActive; }
|
||||
bool IsInstanceActive( void ) const { return m_bInstanceActive; }
|
||||
|
||||
void ResetDisplaysAndSuccesses( void );
|
||||
bool IncDisplayCount( void );
|
||||
bool IncSuccessCount( void );
|
||||
void SetDisplayCount( int iDisplayCount ) { m_iDisplayCount = iDisplayCount; }
|
||||
void SetSuccessCount( int iSuccessCount ) { m_iSuccessCount = iSuccessCount; }
|
||||
int GetDisplayCount( void ) const { return m_iDisplayCount; }
|
||||
int GetSuccessCount( void ) const { return m_iSuccessCount; }
|
||||
int GetDisplayLimit( void ) const { return m_iDisplayLimit; }
|
||||
int GetSuccessLimit( void ) const { return m_iSuccessLimit; }
|
||||
|
||||
void Init( void ); // NOT virtual, each constructor calls their own
|
||||
virtual void InitPrerequisites( void ) {};
|
||||
virtual void Start( void ) = 0;
|
||||
virtual void Stop( void ) = 0;
|
||||
virtual void OnOpen( void ) {};
|
||||
virtual void Update( void ) {};
|
||||
virtual void UpdateInactive( void ) {};
|
||||
|
||||
virtual bool ShouldDisplay( void ) const { return true; }
|
||||
virtual bool IsVisible( void ) const { return true; }
|
||||
virtual bool WasDisplayed( void ) const { return m_bWasDisplayed ? true : false; }
|
||||
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID ) {}
|
||||
virtual void TakePlaceOf( CBaseLesson *pLesson );
|
||||
|
||||
int GetSplitScreenSlot() const { return m_nSplitScreenSlot; }
|
||||
|
||||
const char *GetGroup() { return m_szLessonGroup.String(); }
|
||||
void SetEnabled( bool bEnabled ) { m_bDisabled = !bEnabled; }
|
||||
|
||||
protected:
|
||||
void MarkSucceeded( void );
|
||||
void CloseOpportunity( const char *pchReason );
|
||||
bool DoDelayedPlayerSwaps( void ) const;
|
||||
|
||||
private:
|
||||
|
||||
CBaseLesson *m_pRoot;
|
||||
CUtlVector < CBaseLesson * > m_OpenOpportunities;
|
||||
CUtlVector < const CBaseLesson * > m_Prerequisites;
|
||||
|
||||
CGameInstructorSymbol m_stringCloseReason;
|
||||
CGameInstructorSymbol m_stringName;
|
||||
|
||||
bool m_bInstanceActive : 1;
|
||||
bool m_bSuccessCounted : 1;
|
||||
bool m_bIsDefaultHolder : 1;
|
||||
bool m_bIsOpenOpportunity : 1;
|
||||
|
||||
protected:
|
||||
LessonInstanceType m_iInstanceType;
|
||||
|
||||
int m_iPriority;
|
||||
CGameInstructorSymbol m_stringReplaceKey;
|
||||
int m_iFixedInstancesMax;
|
||||
bool m_bReplaceOnlyWhenStopped;
|
||||
int m_iTeam;
|
||||
bool m_bOnlyKeyboard;
|
||||
bool m_bOnlyGamepad;
|
||||
|
||||
int m_iDisplayLimit;
|
||||
int m_iDisplayCount;
|
||||
bool m_bWasDisplayed;
|
||||
int m_iSuccessLimit;
|
||||
int m_iSuccessCount;
|
||||
int m_nSplitScreenSlot;
|
||||
|
||||
float m_fLockDuration;
|
||||
float m_fTimeout;
|
||||
float m_fInitTime;
|
||||
float m_fStartTime;
|
||||
float m_fLockTime;
|
||||
float m_fUpdateInterval;
|
||||
bool m_bHasPlayedSound;
|
||||
|
||||
CGameInstructorSymbol m_szStartSound;
|
||||
CGameInstructorSymbol m_szLessonGroup;
|
||||
|
||||
bool m_bCanOpenWhenDead;
|
||||
bool m_bBumpWithTimeoutWhenLearned;
|
||||
bool m_bCanTimeoutWhileInactive;
|
||||
bool m_bDisabled;
|
||||
|
||||
// Right now we can only queue up 4 swaps...
|
||||
// this number can be increased if more entity handle scripted variables are added
|
||||
mutable delayed_player_swap_t m_pDelayedPlayerSwap[ MAX_DELAYED_PLAYER_SWAPS ];
|
||||
mutable int m_iNumDelayedPlayerSwaps;
|
||||
|
||||
public:
|
||||
|
||||
// Colors for console spew in verbose mode
|
||||
static Color m_rgbaVerboseHeader;
|
||||
static Color m_rgbaVerbosePlain;
|
||||
static Color m_rgbaVerboseName;
|
||||
static Color m_rgbaVerboseOpen;
|
||||
static Color m_rgbaVerboseClose;
|
||||
static Color m_rgbaVerboseSuccess;
|
||||
static Color m_rgbaVerboseUpdate;
|
||||
};
|
||||
|
||||
|
||||
class CTextLesson : public CBaseLesson
|
||||
{
|
||||
public:
|
||||
DECLARE_LESSON( CTextLesson, CBaseLesson );
|
||||
|
||||
void Init( void ); // NOT virtual, each constructor calls their own
|
||||
virtual void Start( void );
|
||||
virtual void Stop( void );
|
||||
|
||||
protected:
|
||||
|
||||
CGameInstructorSymbol m_szDisplayText;
|
||||
CGameInstructorSymbol m_szDisplayParamText;
|
||||
CGameInstructorSymbol m_szBinding;
|
||||
CGameInstructorSymbol m_szGamepadBinding;
|
||||
};
|
||||
|
||||
|
||||
class CIconLesson : public CTextLesson
|
||||
{
|
||||
public:
|
||||
DECLARE_LESSON( CIconLesson, CTextLesson );
|
||||
|
||||
void Init( void ); // NOT virtual, each constructor calls their own
|
||||
virtual void Start( void );
|
||||
virtual void Stop( void );
|
||||
virtual void Update( void );
|
||||
virtual void UpdateInactive( void );
|
||||
|
||||
virtual bool ShouldDisplay( void ) const;
|
||||
virtual bool IsVisible( void ) const;
|
||||
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
|
||||
virtual void TakePlaceOf( CBaseLesson *pLesson );
|
||||
|
||||
void SetLocatorBinding( CLocatorTarget * pLocatorTarget );
|
||||
|
||||
const char *GetCaptionColorString() { return m_szCaptionColor.String(); }
|
||||
|
||||
bool IsPresentComplete( void );
|
||||
void PresentStart( void );
|
||||
void PresentEnd( void );
|
||||
|
||||
private:
|
||||
virtual void UpdateLocatorTarget( CLocatorTarget *pLocatorTarget, C_BaseEntity *pIconTarget );
|
||||
|
||||
protected:
|
||||
CHandle<C_BaseEntity> m_hIconTarget;
|
||||
CGameInstructorSymbol m_szVguiTargetName;
|
||||
CGameInstructorSymbol m_szVguiTargetLookup;
|
||||
int m_nVguiTargetEdge;
|
||||
float m_flUpOffset;
|
||||
float m_flRelativeUpOffset;
|
||||
float m_fFixedPositionX;
|
||||
float m_fFixedPositionY;
|
||||
|
||||
int m_hLocatorTarget;
|
||||
int m_iFlags;
|
||||
|
||||
float m_fRange;
|
||||
float m_fCurrentDistance;
|
||||
float m_fOnScreenStartTime;
|
||||
float m_fUpdateDistanceTime;
|
||||
|
||||
CGameInstructorSymbol m_szOnscreenIcon;
|
||||
CGameInstructorSymbol m_szOffscreenIcon;
|
||||
CGameInstructorSymbol m_szCaptionColor;
|
||||
|
||||
bool m_bFixedPosition;
|
||||
bool m_bNoIconTarget;
|
||||
bool m_bAllowNodrawTarget;
|
||||
bool m_bVisible;
|
||||
bool m_bShowWhenOccluded;
|
||||
bool m_bNoOffscreen;
|
||||
bool m_bForceCaption;
|
||||
};
|
||||
|
||||
enum LessonAction
|
||||
{
|
||||
LESSON_ACTION_NONE,
|
||||
|
||||
LESSON_ACTION_SCOPE_IN,
|
||||
LESSON_ACTION_SCOPE_OUT,
|
||||
LESSON_ACTION_CLOSE,
|
||||
LESSON_ACTION_SUCCESS,
|
||||
LESSON_ACTION_LOCK,
|
||||
LESSON_ACTION_PRESENT_COMPLETE,
|
||||
LESSON_ACTION_PRESENT_START,
|
||||
LESSON_ACTION_PRESENT_END,
|
||||
|
||||
LESSON_ACTION_REFERENCE_OPEN,
|
||||
|
||||
LESSON_ACTION_SET,
|
||||
LESSON_ACTION_ADD,
|
||||
LESSON_ACTION_SUBTRACT,
|
||||
LESSON_ACTION_MULTIPLY,
|
||||
LESSON_ACTION_IS,
|
||||
LESSON_ACTION_LESS_THAN,
|
||||
LESSON_ACTION_HAS_PREFIX,
|
||||
LESSON_ACTION_HAS_BIT,
|
||||
LESSON_ACTION_BIT_COUNT_IS,
|
||||
LESSON_ACTION_BIT_COUNT_LESS_THAN,
|
||||
|
||||
LESSON_ACTION_GET_DISTANCE,
|
||||
LESSON_ACTION_GET_ANGULAR_DISTANCE,
|
||||
LESSON_ACTION_GET_PLAYER_DISPLAY_NAME,
|
||||
LESSON_ACTION_CLASSNAME_IS,
|
||||
LESSON_ACTION_MODELNAME_IS,
|
||||
LESSON_ACTION_TEAM_IS,
|
||||
LESSON_ACTION_HEALTH_LESS_THAN,
|
||||
LESSON_ACTION_HEALTH_PERCENTAGE_LESS_THAN,
|
||||
LESSON_ACTION_GET_ACTIVE_WEAPON,
|
||||
LESSON_ACTION_WEAPON_IS,
|
||||
LESSON_ACTION_WEAPON_HAS,
|
||||
LESSON_ACTION_GET_ACTIVE_WEAPON_SLOT,
|
||||
LESSON_ACTION_GET_WEAPON_SLOT,
|
||||
LESSON_ACTION_GET_WEAPON_IN_SLOT,
|
||||
LESSON_ACTION_CLIP_PERCENTAGE_LESS_THAN,
|
||||
LESSON_ACTION_WEAPON_AMMO_LOW,
|
||||
LESSON_ACTION_WEAPON_AMMO_FULL,
|
||||
LESSON_ACTION_WEAPON_AMMO_EMPTY,
|
||||
LESSON_ACTION_WEAPON_CAN_USE,
|
||||
LESSON_ACTION_USE_TARGET_IS,
|
||||
LESSON_ACTION_GET_USE_TARGET,
|
||||
LESSON_ACTION_GET_POTENTIAL_USE_TARGET,
|
||||
|
||||
// Enum continued in Mod_LessonAction
|
||||
LESSON_ACTION_MOD_START,
|
||||
};
|
||||
|
||||
struct LessonElement_t
|
||||
{
|
||||
int iVariable;
|
||||
int iParamVarIndex;
|
||||
int iAction;
|
||||
_fieldtypes paramType;
|
||||
CGameInstructorSymbol szParam;
|
||||
bool bNot : 1;
|
||||
bool bOptionalParam : 1;
|
||||
|
||||
LessonElement_t( int p_iVariable, int p_iAction, bool p_bNot, bool p_bOptionalParam, const char *pchParam, int p_iParamVarIndex, _fieldtypes p_paramType )
|
||||
{
|
||||
iVariable = p_iVariable;
|
||||
iAction = p_iAction;
|
||||
bNot = p_bNot;
|
||||
bOptionalParam = p_bOptionalParam;
|
||||
szParam = pchParam;
|
||||
iParamVarIndex = p_iParamVarIndex;
|
||||
paramType = p_paramType;
|
||||
}
|
||||
|
||||
LessonElement_t( const LessonElement_t &p_LessonElement )
|
||||
{
|
||||
iVariable = p_LessonElement.iVariable;
|
||||
iAction = p_LessonElement.iAction;
|
||||
bNot = p_LessonElement.bNot;
|
||||
bOptionalParam = p_LessonElement.bOptionalParam;
|
||||
szParam = p_LessonElement.szParam;
|
||||
iParamVarIndex = p_LessonElement.iParamVarIndex;
|
||||
paramType = p_LessonElement.paramType;
|
||||
}
|
||||
};
|
||||
|
||||
struct LessonEvent_t
|
||||
{
|
||||
CUtlVector< LessonElement_t > elements;
|
||||
CGameInstructorSymbol szEventName;
|
||||
};
|
||||
|
||||
class CScriptedIconLesson : public CIconLesson
|
||||
{
|
||||
public:
|
||||
DECLARE_LESSON( CScriptedIconLesson, CIconLesson )
|
||||
|
||||
virtual ~CScriptedIconLesson( void );
|
||||
|
||||
static void PreReadLessonsFromFile( void );
|
||||
static void Mod_PreReadLessonsFromFile( void );
|
||||
|
||||
void Init( void ); // NOT virtual, each constructor calls their own
|
||||
virtual void InitPrerequisites( void );
|
||||
virtual void OnOpen( void );
|
||||
virtual void Update( void );
|
||||
|
||||
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
virtual void ProcessOpenGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||
virtual void ProcessCloseGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||
virtual void ProcessSuccessGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||
|
||||
CUtlVector< LessonEvent_t >& GetOpenEvents( void ) { return m_OpenEvents; }
|
||||
CUtlVector< LessonEvent_t >& GetCloseEvents( void ) { return m_CloseEvents; }
|
||||
CUtlVector< LessonEvent_t >& GetSuccessEvents( void ) { return m_SuccessEvents; }
|
||||
CUtlVector< LessonEvent_t >& GetOnOpenEvents( void ) { return m_OnOpenEvents; }
|
||||
CUtlVector< LessonEvent_t >& GetUpdateEvents( void ) { return m_UpdateEvents; }
|
||||
|
||||
bool ProcessElements( IGameEvent *event, const CUtlVector< LessonElement_t > *pElements );
|
||||
|
||||
private:
|
||||
void InitElementsFromKeys( CUtlVector< LessonElement_t > *pLessonElements, KeyValues *pKey );
|
||||
void InitElementsFromElements( CUtlVector< LessonElement_t > *pLessonElements, const CUtlVector< LessonElement_t > *pLessonElements2 );
|
||||
|
||||
void InitFromKeys( KeyValues *pKey );
|
||||
|
||||
bool ProcessElement( IGameEvent *event, const LessonElement_t *pLessonElement, bool bInFailedScope );
|
||||
|
||||
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, float &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, int &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, bool &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam );
|
||||
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, CGameInstructorSymbol *pchVar, const CGameInstructorSymbol *pchParamName, const char *pchParam );
|
||||
|
||||
// Implemented per mod so they can have custom actions
|
||||
bool Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled );
|
||||
|
||||
LessonEvent_t * AddOpenEvent( void );
|
||||
LessonEvent_t * AddCloseEvent( void );
|
||||
LessonEvent_t * AddSuccessEvent( void );
|
||||
LessonEvent_t * AddOnOpenEvent( void );
|
||||
LessonEvent_t * AddUpdateEvent( void );
|
||||
|
||||
private:
|
||||
static CUtlDict< int, int > CScriptedIconLesson::LessonActionMap;
|
||||
|
||||
EHANDLE m_hLocalPlayer;
|
||||
float m_fOutput;
|
||||
CHandle<C_BaseEntity> m_hEntity1;
|
||||
CHandle<C_BaseEntity> m_hEntity2;
|
||||
CGameInstructorSymbol m_szString1;
|
||||
CGameInstructorSymbol m_szString2;
|
||||
int m_iInteger1;
|
||||
int m_iInteger2;
|
||||
float m_fFloat1;
|
||||
float m_fFloat2;
|
||||
|
||||
CUtlVector< CGameInstructorSymbol > m_PrerequisiteNames;
|
||||
CUtlVector< LessonEvent_t > m_OpenEvents;
|
||||
CUtlVector< LessonEvent_t > m_CloseEvents;
|
||||
CUtlVector< LessonEvent_t > m_SuccessEvents;
|
||||
CUtlVector< LessonEvent_t > m_OnOpenEvents;
|
||||
CUtlVector< LessonEvent_t > m_UpdateEvents;
|
||||
|
||||
float m_fUpdateEventTime;
|
||||
CScriptedIconLesson *m_pDefaultHolder;
|
||||
|
||||
int m_iScopeDepth;
|
||||
|
||||
// Need this to get offsets to scripted variables
|
||||
friend class LessonVariableInfo;
|
||||
friend int LessonActionFromString( const char *pchName );
|
||||
};
|
||||
|
||||
|
||||
#endif // _C_BASELESSON_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Client-side CBasePlayer.
|
||||
//
|
||||
// - Manages the player's flashlight effect.
|
||||
//
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_BASEPLAYER_H
|
||||
#define C_BASEPLAYER_H
|
||||
@ -14,29 +14,21 @@
|
||||
|
||||
#include "c_playerlocaldata.h"
|
||||
#include "c_basecombatcharacter.h"
|
||||
#include "PlayerState.h"
|
||||
#include "playerstate.h"
|
||||
#include "usercmd.h"
|
||||
#include "shareddefs.h"
|
||||
#include "timedevent.h"
|
||||
#include "smartptr.h"
|
||||
#include "fx_water.h"
|
||||
#include "hintsystem.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "soundemittersystem/isoundemittersystembase.h"
|
||||
#include "c_env_fog_controller.h"
|
||||
#include "igameevents.h"
|
||||
#include "GameEventListener.h"
|
||||
|
||||
#if defined USES_ECON_ITEMS
|
||||
#include "econ_item.h"
|
||||
#include "game_item_schema.h"
|
||||
#include "econ_item_view.h"
|
||||
#endif
|
||||
#include "C_PostProcessController.h"
|
||||
#include "C_ColorCorrection.h"
|
||||
|
||||
class C_BaseCombatWeapon;
|
||||
class C_BaseViewModel;
|
||||
class C_FuncLadder;
|
||||
class CFlashlightEffect;
|
||||
class C_EconWearable;
|
||||
|
||||
extern int g_nKillCamMode;
|
||||
extern int g_nKillCamTarget1;
|
||||
@ -58,17 +50,24 @@ public:
|
||||
Vector error;
|
||||
};
|
||||
|
||||
#define CHASE_CAM_DISTANCE_MIN 16.0f
|
||||
#define CHASE_CAM_DISTANCE_MAX 96.0f
|
||||
#define CHASE_CAM_DISTANCE 96.0f
|
||||
#define WALL_OFFSET 6.0f
|
||||
|
||||
|
||||
enum PlayerRenderMode_t
|
||||
{
|
||||
PLAYER_RENDER_NONE = 0,
|
||||
PLAYER_RENDER_FIRSTPERSON,
|
||||
PLAYER_RENDER_THIRDPERSON,
|
||||
};
|
||||
|
||||
|
||||
bool IsInFreezeCam( void );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Base Player class
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener
|
||||
class C_BasePlayer : public C_BaseCombatCharacter
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BasePlayer, C_BaseCombatCharacter );
|
||||
@ -81,7 +80,7 @@ public:
|
||||
|
||||
virtual void Spawn( void );
|
||||
virtual void SharedSpawn(); // Shared between client and server.
|
||||
virtual bool GetSteamID( CSteamID *pID );
|
||||
Class_T Classify( void ) { return CLASS_PLAYER; }
|
||||
|
||||
// IClientEntity overrides.
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
@ -94,17 +93,13 @@ public:
|
||||
|
||||
virtual void OnRestore();
|
||||
|
||||
virtual void AddEntity( void );
|
||||
|
||||
virtual void MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType );
|
||||
|
||||
virtual void GetToolRecordingState( KeyValues *msg );
|
||||
|
||||
virtual float GetPlayerMaxSpeed();
|
||||
|
||||
void SetAnimationExtension( const char *pExtension );
|
||||
|
||||
C_BaseViewModel *GetViewModel( int viewmodelindex = 0, bool bObserverOK=true );
|
||||
C_BaseViewModel *GetViewModel( int viewmodelindex = 0 );
|
||||
C_BaseCombatWeapon *GetActiveWeapon( void ) const;
|
||||
const char *GetTracerType( void );
|
||||
|
||||
@ -117,17 +112,21 @@ public:
|
||||
void SmoothViewOnStairs( Vector& eyeOrigin );
|
||||
virtual float CalcRoll (const QAngle& angles, const Vector& velocity, float rollangle, float rollspeed);
|
||||
void CalcViewRoll( QAngle& eyeAngles );
|
||||
virtual void CalcViewBob( Vector& eyeOrigin );
|
||||
void CreateWaterEffects( void );
|
||||
|
||||
virtual void SetPlayerUnderwater( bool state );
|
||||
void UpdateUnderwaterState( void );
|
||||
bool IsPlayerUnderwater( void ) { return m_bPlayerUnderwater; }
|
||||
|
||||
virtual C_BaseCombatCharacter *ActivePlayerCombatCharacter( void ) { return this; }
|
||||
|
||||
virtual Vector Weapon_ShootPosition();
|
||||
virtual bool Weapon_CanUse( C_BaseCombatWeapon *pWeapon );
|
||||
virtual void Weapon_DropPrimary( void ) {}
|
||||
|
||||
virtual Vector GetAutoaimVector( float flScale );
|
||||
void SetSuitUpdate(const char *name, int fgroup, int iNoRepeat);
|
||||
void SetSuitUpdate(char *name, int fgroup, int iNoRepeat);
|
||||
|
||||
// Input handling
|
||||
virtual bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
|
||||
@ -146,7 +145,6 @@ public:
|
||||
|
||||
// observer mode
|
||||
virtual int GetObserverMode() const;
|
||||
void SetObserverMode ( int iNewMode );
|
||||
virtual CBaseEntity *GetObserverTarget() const;
|
||||
void SetObserverTarget( EHANDLE hObserverTarget );
|
||||
|
||||
@ -169,7 +167,7 @@ public:
|
||||
virtual IRagdoll* GetRepresentativeRagdoll() const;
|
||||
|
||||
// override the initial bone position for ragdolls
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4_t *pDeltaBones0, matrix3x4_t *pDeltaBones1, matrix3x4_t *pCurrentBones, float boneDt );
|
||||
virtual void GetRagdollInitBoneArrays( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt );
|
||||
|
||||
// Returns eye vectors
|
||||
void EyeVectors( Vector *pForward, Vector *pRight = NULL, Vector *pUp = NULL );
|
||||
@ -184,6 +182,17 @@ public:
|
||||
// Flashlight
|
||||
void Flashlight( void );
|
||||
void UpdateFlashlight( void );
|
||||
void TurnOffFlashlight( void ); // TERROR
|
||||
virtual const char *GetFlashlightTextureName( void ) const { return NULL; } // TERROR
|
||||
virtual float GetFlashlightFOV( void ) const { return 0.0f; } // TERROR
|
||||
virtual float GetFlashlightFarZ( void ) const { return 0.0f; } // TERROR
|
||||
virtual float GetFlashlightLinearAtten( void ) const { return 0.0f; } // TERROR
|
||||
virtual bool CastsFlashlightShadows( void ) const { return true; } // TERROR
|
||||
virtual void GetFlashlightOffset( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp, Vector *pVecOffset ) const;
|
||||
Vector m_vecFlashlightOrigin;
|
||||
Vector m_vecFlashlightForward;
|
||||
Vector m_vecFlashlightUp;
|
||||
Vector m_vecFlashlightRight;
|
||||
|
||||
// Weapon selection code
|
||||
virtual bool IsAllowedToSwitchWeapons( void ) { return !IsObserver(); }
|
||||
@ -195,7 +204,7 @@ public:
|
||||
virtual C_BaseAnimating* GetRenderedWeaponModel();
|
||||
|
||||
virtual bool IsOverridingViewmodel( void ) { return false; };
|
||||
virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags ) { return 0; };
|
||||
virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags, const RenderableInstance_t &instance ) { return 0; };
|
||||
|
||||
virtual float GetDefaultAnimSpeed( void ) { return 1.0; }
|
||||
|
||||
@ -211,27 +220,40 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool IsLocalPlayer( void ) const;
|
||||
// Makes sure s_pLocalPlayer is properly initialized
|
||||
void CheckForLocalPlayer( int nSplitScreenSlot );
|
||||
|
||||
/// Is the passed in player one of the split screen users
|
||||
static bool IsLocalPlayer( const C_BaseEntity *pl );
|
||||
/// is this player a local player ( call when you have already verified that your pointer really is a C_BasePlayer )
|
||||
inline bool IsLocalPlayer( void ) const;
|
||||
|
||||
// Global/static methods
|
||||
virtual void ThirdPersonSwitch( bool bThirdperson );
|
||||
static bool LocalPlayerInFirstPersonView();
|
||||
static bool ShouldDrawLocalPlayer();
|
||||
static C_BasePlayer *GetLocalPlayer( void );
|
||||
int GetUserID( void );
|
||||
bool ShouldDrawLocalPlayer();
|
||||
static C_BasePlayer *GetLocalPlayer( int nSlot = -1 );
|
||||
static void SetRemoteSplitScreenPlayerViewsAreLocalPlayer( bool bSet ); //if true, calls to GetLocalPlayer() will return a remote splitscreen player when applicable.
|
||||
static bool HasAnyLocalPlayer();
|
||||
static int GetSplitScreenSlotForPlayer( C_BaseEntity *pl );
|
||||
|
||||
void AddSplitScreenPlayer( C_BasePlayer *pOther );
|
||||
void RemoveSplitScreenPlayer( C_BasePlayer *pOther );
|
||||
CUtlVector< CHandle< C_BasePlayer > > &GetSplitScreenPlayers();
|
||||
|
||||
bool IsSplitScreenPartner( C_BasePlayer *pPlayer );
|
||||
|
||||
bool IsSplitScreenPlayer() const;
|
||||
int GetSplitScreenPlayerSlot();
|
||||
|
||||
virtual IClientModelRenderable* GetClientModelRenderable();
|
||||
virtual bool PreRender( int nSplitScreenPlayerSlot );
|
||||
|
||||
int GetUserID( void ) const;
|
||||
virtual bool CanSetSoundMixer( void );
|
||||
virtual int GetVisionFilterFlags( bool bWeaponsCheck = false ) { return 0x00; }
|
||||
bool HasVisionFilterFlags( int nFlags, bool bWeaponsCheck = false ) { return ( GetVisionFilterFlags( bWeaponsCheck ) & nFlags ) == nFlags; }
|
||||
virtual void CalculateVisionUsingCurrentFlags( void ) {}
|
||||
void BuildFirstPersonMeathookTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, const char *pchHeadBoneName );
|
||||
|
||||
// Specific queries about this player.
|
||||
bool InFirstPersonView();
|
||||
bool ShouldDrawThisPlayer();
|
||||
// return the entity used for soundscape radius checks
|
||||
virtual C_BaseEntity *GetSoundscapeListener();
|
||||
|
||||
// Called by the view model if its rendering is being overridden.
|
||||
virtual bool ViewModel_IsTransparent( void );
|
||||
virtual bool ViewModel_IsUsingFBTexture( void );
|
||||
|
||||
#if !defined( NO_ENTITY_PREDICTION )
|
||||
void AddToPlayerSimulationList( C_BaseEntity *other );
|
||||
@ -245,6 +267,7 @@ public:
|
||||
|
||||
// Prediction stuff
|
||||
virtual bool ShouldPredict( void );
|
||||
virtual C_BasePlayer *GetPredictionOwner( void );
|
||||
|
||||
virtual void PreThink( void );
|
||||
virtual void PostThink( void );
|
||||
@ -264,10 +287,10 @@ public:
|
||||
|
||||
virtual void UpdateClientData( void );
|
||||
|
||||
virtual float GetFOV( void );
|
||||
int GetDefaultFOV( void ) const;
|
||||
virtual float GetFOV( void ) const;
|
||||
virtual int GetDefaultFOV( void ) const;
|
||||
virtual bool IsZoomed( void ) { return false; }
|
||||
bool SetFOV( CBaseEntity *pRequester, int FOV, float zoomRate = 0.0f, int iZoomStart = 0 );
|
||||
bool SetFOV( CBaseEntity *pRequester, int FOV, float zoomRate, int iZoomStart = 0 );
|
||||
void ClearZoomOwner( void );
|
||||
|
||||
float GetFOVDistanceAdjustFactor();
|
||||
@ -278,29 +301,35 @@ public:
|
||||
void UpdateButtonState( int nUserCmdButtonMask );
|
||||
int GetImpulse( void ) const;
|
||||
|
||||
virtual void Simulate();
|
||||
virtual bool Simulate();
|
||||
|
||||
virtual bool ShouldInterpolate();
|
||||
|
||||
virtual bool ShouldDraw();
|
||||
virtual int DrawModel( int flags );
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
|
||||
// Called when not in tactical mode. Allows view to be overriden for things like driving a tank.
|
||||
virtual void OverrideView( CViewSetup *pSetup );
|
||||
|
||||
C_BaseEntity *GetViewEntity( void ) const { return m_hViewEntity; }
|
||||
|
||||
// returns the player name
|
||||
const char * GetPlayerName();
|
||||
virtual const Vector GetPlayerMins( void ) const; // uses local player
|
||||
virtual const Vector GetPlayerMaxs( void ) const; // uses local player
|
||||
|
||||
virtual void UpdateCollisionBounds( void );
|
||||
|
||||
// Is the player dead?
|
||||
bool IsPlayerDead();
|
||||
bool IsPoisoned( void ) { return m_Local.m_bPoisoned; }
|
||||
|
||||
C_BaseEntity *GetUseEntity();
|
||||
virtual C_BaseEntity* GetUseEntity( void ) const;
|
||||
virtual C_BaseEntity* GetPotentialUseEntity( void ) const;
|
||||
|
||||
// Vehicles...
|
||||
IClientVehicle *GetVehicle();
|
||||
const IClientVehicle *GetVehicle() const;
|
||||
|
||||
bool IsInAVehicle() const { return ( NULL != m_hVehicle.Get() ) ? true : false; }
|
||||
virtual void SetVehicleRole( int nRole );
|
||||
@ -322,7 +351,7 @@ public:
|
||||
int CurrentCommandNumber() const;
|
||||
const CUserCmd *GetCurrentUserCommand() const;
|
||||
|
||||
const QAngle& GetPunchAngle();
|
||||
virtual const QAngle& GetPunchAngle();
|
||||
void SetPunchAngle( const QAngle &angle );
|
||||
|
||||
float GetWaterJumpTime() const;
|
||||
@ -346,9 +375,6 @@ public:
|
||||
virtual surfacedata_t * GetFootstepSurface( const Vector &origin, const char *surfaceName );
|
||||
virtual void GetStepSoundVelocities( float *velwalk, float *velrun );
|
||||
virtual void SetStepSoundTime( stepsoundtimes_t iStepSoundTime, bool bWalking );
|
||||
virtual const char *GetOverrideStepSound( const char *pszBaseStepSoundName ) { return pszBaseStepSoundName; }
|
||||
|
||||
virtual void OnEmitFootstepSound( const CSoundParameters& params, const Vector& vecOrigin, float fVolume ) {}
|
||||
|
||||
// Called by prediction when it detects a prediction correction.
|
||||
// vDelta is the line from where the client had predicted the player to at the usercmd in question,
|
||||
@ -361,9 +387,13 @@ public:
|
||||
virtual void ExitLadder() {}
|
||||
surfacedata_t *GetLadderSurface( const Vector &origin );
|
||||
|
||||
surfacedata_t *GetSurfaceData( void ) { return m_pSurfaceData; }
|
||||
void ForceButtons( int nButtons );
|
||||
void UnforceButtons( int nButtons );
|
||||
|
||||
|
||||
void SetLadderNormal( Vector vecLadderNormal ) { m_vecLadderNormal = vecLadderNormal; }
|
||||
const Vector &GetLadderNormal( void ) const { return m_vecLadderNormal; }
|
||||
int GetLadderSurfaceProps( void ) const { return m_ladderSurfaceProps; }
|
||||
|
||||
// Hints
|
||||
virtual CHintSystem *Hints( void ) { return NULL; }
|
||||
@ -374,89 +404,142 @@ public:
|
||||
virtual IMaterial *GetHeadLabelMaterial( void );
|
||||
|
||||
// Fog
|
||||
fogparams_t *GetFogParams( void ) { return &m_CurrentFog; }
|
||||
virtual fogparams_t *GetFogParams( void ) { return &m_CurrentFog; }
|
||||
void FogControllerChanged( bool bSnap );
|
||||
void UpdateFogController( void );
|
||||
void UpdateFogBlend( void );
|
||||
|
||||
C_PostProcessController* GetActivePostProcessController() const;
|
||||
C_ColorCorrection* GetActiveColorCorrection() const;
|
||||
|
||||
void IncrementEFNoInterpParity();
|
||||
int GetEFNoInterpParity() const;
|
||||
|
||||
float GetFOVTime( void ){ return m_flFOVTime; }
|
||||
|
||||
PlayerRenderMode_t GetPlayerRenderMode( int nSlot );
|
||||
|
||||
virtual void OnAchievementAchieved( int iAchievement ) {}
|
||||
|
||||
bool ShouldAnnounceAchievement( void ){ return m_flNextAchievementAnnounceTime < gpGlobals->curtime; }
|
||||
void SetNextAchievementAnnounceTime( float flTime ){ m_flNextAchievementAnnounceTime = flTime; }
|
||||
|
||||
#if defined USES_ECON_ITEMS
|
||||
// Wearables
|
||||
void UpdateWearables();
|
||||
C_EconWearable *GetWearable( int i ) { return m_hMyWearables[i]; }
|
||||
int GetNumWearables( void ) { return m_hMyWearables.Count(); }
|
||||
#endif
|
||||
|
||||
bool HasFiredWeapon( void ) { return m_bFiredWeapon; }
|
||||
void SetFiredWeapon( bool bFlag ) { m_bFiredWeapon = bFlag; }
|
||||
|
||||
virtual bool CanUseFirstPersonCommand( void ){ return true; }
|
||||
|
||||
protected:
|
||||
fogparams_t m_CurrentFog;
|
||||
EHANDLE m_hOldFogController;
|
||||
|
||||
public:
|
||||
// RecvProxies
|
||||
static void RecvProxy_LocalVelocityX( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_LocalVelocityY( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_LocalVelocityZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
static void RecvProxy_ObserverTarget( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_ObserverMode( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
static void RecvProxy_LocalOriginXY( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_LocalOriginZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_NonLocalOriginXY( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_NonLocalOriginZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_NonLocalCellOriginXY( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
static void RecvProxy_NonLocalCellOriginZ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||
|
||||
virtual bool ShouldRegenerateOriginFromCellBits() const;
|
||||
|
||||
public:
|
||||
int m_StuckLast;
|
||||
|
||||
// Data for only the local player
|
||||
CNetworkVarEmbedded( CPlayerLocalData, m_Local );
|
||||
|
||||
#if defined USES_ECON_ITEMS
|
||||
CNetworkVarEmbedded( CAttributeList, m_AttributeList );
|
||||
#endif
|
||||
EHANDLE m_hTonemapController;
|
||||
|
||||
// Data common to all other players, too
|
||||
CPlayerState pl;
|
||||
|
||||
public:
|
||||
// BEGIN PREDICTION DATA COMPACTION (these fields are together to allow for faster copying in prediction system)
|
||||
|
||||
// FTYPEDESC_INSENDTABLE STUFF
|
||||
// Player FOV values
|
||||
int m_iFOV; // field of view
|
||||
int m_iFOVStart; // starting value of the FOV changing over time (client only)
|
||||
int m_afButtonLast;
|
||||
int m_afButtonPressed;
|
||||
int m_afButtonReleased;
|
||||
int m_nButtons;
|
||||
protected:
|
||||
int m_nImpulse;
|
||||
CNetworkVar( int, m_ladderSurfaceProps );
|
||||
int m_flPhysics;
|
||||
public:
|
||||
float m_flFOVTime; // starting time of the FOV zoom
|
||||
int m_iDefaultFOV; // default FOV if no other zooms are occurring
|
||||
private:
|
||||
float m_flWaterJumpTime; // used to be called teleport_time
|
||||
float m_flSwimSoundTime;
|
||||
protected:
|
||||
float m_flStepSoundTime;
|
||||
float m_surfaceFriction;
|
||||
private:
|
||||
CNetworkVector( m_vecLadderNormal );
|
||||
|
||||
// FTYPEDESC_INSENDTABLE STUFF (end)
|
||||
public:
|
||||
char m_szAnimExtension[32];
|
||||
private:
|
||||
int m_nOldTickBase;
|
||||
private:
|
||||
int m_iBonusProgress;
|
||||
int m_iBonusChallenge;
|
||||
|
||||
private:
|
||||
float m_flMaxspeed;
|
||||
|
||||
|
||||
public:
|
||||
EHANDLE m_hZoomOwner; // This is a pointer to the entity currently controlling the player's zoom
|
||||
// Only this entity can change the zoom state once it has ownership
|
||||
private:
|
||||
EHANDLE m_hVehicle;
|
||||
typedef CHandle<C_BaseCombatWeapon> CBaseCombatWeaponHandle;
|
||||
CBaseCombatWeaponHandle m_hLastWeapon;
|
||||
// players own view models, left & right hand
|
||||
CHandle< C_BaseViewModel > m_hViewModel[ MAX_VIEWMODELS ];
|
||||
|
||||
public:
|
||||
// For weapon prediction
|
||||
bool m_fOnTarget; //Is the crosshair on a target?
|
||||
|
||||
char m_szAnimExtension[32];
|
||||
bool m_fOnTarget; //Is the crosshair on a target?
|
||||
|
||||
int m_afButtonLast;
|
||||
int m_afButtonPressed;
|
||||
int m_afButtonReleased;
|
||||
|
||||
int m_nButtons;
|
||||
|
||||
// END PREDICTION DATA COMPACTION
|
||||
public:
|
||||
|
||||
|
||||
int m_iDefaultFOV; // default FOV if no other zooms are occurring
|
||||
// Only this entity can change the zoom state once it has ownership
|
||||
int m_afButtonForced; // These are forced onto the player's inputs
|
||||
|
||||
|
||||
CUserCmd *m_pCurrentCommand;
|
||||
|
||||
EHANDLE m_hViewEntity;
|
||||
|
||||
// Movement constraints
|
||||
EHANDLE m_hConstraintEntity;
|
||||
Vector m_vecConstraintCenter;
|
||||
float m_flConstraintRadius;
|
||||
float m_flConstraintWidth;
|
||||
float m_flConstraintSpeedFactor;
|
||||
bool m_bConstraintPastRadius;
|
||||
|
||||
protected:
|
||||
|
||||
void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
virtual void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
void CalcVehicleView(IClientVehicle *pVehicle, Vector& eyeOrigin, QAngle& eyeAngles,
|
||||
float& zNear, float& zFar, float& fov );
|
||||
virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
|
||||
void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
virtual void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
|
||||
virtual float GetDeathCamInterpolationTime();
|
||||
|
||||
void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
virtual void CalcDeathCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
|
||||
virtual void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
|
||||
virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||
|
||||
// Check to see if we're in vgui input mode...
|
||||
@ -469,8 +552,6 @@ protected:
|
||||
// used by client side player footsteps
|
||||
surfacedata_t* GetGroundSurface();
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
protected:
|
||||
// Did we just enter a vehicle this frame?
|
||||
bool JustEnteredVehicle();
|
||||
@ -485,8 +566,6 @@ protected:
|
||||
bool m_bWasFreezeFraming;
|
||||
float m_flDeathTime; // last time player died
|
||||
|
||||
float m_flStepSoundTime;
|
||||
bool m_IsFootprintOnLeft;
|
||||
|
||||
private:
|
||||
// Make sure no one calls this...
|
||||
@ -494,50 +573,33 @@ private:
|
||||
C_BasePlayer( const C_BasePlayer & ); // not defined, not accessible
|
||||
|
||||
// Vehicle stuff.
|
||||
EHANDLE m_hVehicle;
|
||||
EHANDLE m_hOldVehicle;
|
||||
EHANDLE m_hUseEntity;
|
||||
|
||||
float m_flMaxspeed;
|
||||
|
||||
int m_iBonusProgress;
|
||||
int m_iBonusChallenge;
|
||||
|
||||
CInterpolatedVar< Vector > m_iv_vecViewOffset;
|
||||
|
||||
// Not replicated
|
||||
Vector m_vecWaterJumpVel;
|
||||
float m_flWaterJumpTime; // used to be called teleport_time
|
||||
int m_nImpulse;
|
||||
|
||||
float m_flSwimSoundTime;
|
||||
Vector m_vecLadderNormal;
|
||||
|
||||
|
||||
protected:
|
||||
QAngle m_vecOldViewAngles;
|
||||
|
||||
private:
|
||||
bool m_bWasFrozen;
|
||||
int m_flPhysics;
|
||||
|
||||
int m_nTickBase;
|
||||
int m_nFinalPredictedTick;
|
||||
|
||||
EHANDLE m_pCurrentVguiScreen;
|
||||
|
||||
bool m_bFiredWeapon;
|
||||
|
||||
|
||||
// Player flashlight dynamic light pointers
|
||||
CFlashlightEffect *m_pFlashlight;
|
||||
|
||||
typedef CHandle<C_BaseCombatWeapon> CBaseCombatWeaponHandle;
|
||||
CNetworkVar( CBaseCombatWeaponHandle, m_hLastWeapon );
|
||||
bool m_bFlashlightEnabled[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
|
||||
#if !defined( NO_ENTITY_PREDICTION )
|
||||
CUtlVector< CHandle< C_BaseEntity > > m_SimulatedByThisPlayer;
|
||||
#endif
|
||||
|
||||
// players own view models, left & right hand
|
||||
CHandle< C_BaseViewModel > m_hViewModel[ MAX_VIEWMODELS ];
|
||||
|
||||
float m_flOldPlayerZ;
|
||||
float m_flOldPlayerViewOffsetZ;
|
||||
@ -561,16 +623,17 @@ private:
|
||||
bool m_bPlayerUnderwater;
|
||||
|
||||
friend class CPrediction;
|
||||
friend class CASW_Prediction;
|
||||
|
||||
// HACK FOR TF2 Prediction
|
||||
friend class CTFGameMovementRecon;
|
||||
friend class CGameMovement;
|
||||
friend class CTFGameMovement;
|
||||
friend class CHL1GameMovement;
|
||||
friend class CCSGameMovement;
|
||||
friend class CHL2GameMovement;
|
||||
friend class CDODGameMovement;
|
||||
friend class CPortalGameMovement;
|
||||
friend class CASW_MarineGameMovement;
|
||||
friend class CPaintGameMovement;
|
||||
|
||||
// Accessors for gamemovement
|
||||
float GetStepSize( void ) const { return m_Local.m_flStepSize; }
|
||||
@ -585,7 +648,7 @@ protected:
|
||||
virtual bool IsDucked( void ) const { return m_Local.m_bDucked; }
|
||||
virtual bool IsDucking( void ) const { return m_Local.m_bDucking; }
|
||||
virtual float GetFallVelocity( void ) { return m_Local.m_flFallVelocity; }
|
||||
void ForceSetupBonesAtTimeFakeInterpolation( matrix3x4_t *pBonesOut, float curtimeOffset );
|
||||
void ForceSetupBonesAtTimeFakeInterpolation( matrix3x4a_t *pBonesOut, float curtimeOffset );
|
||||
|
||||
float m_flLaggedMovementValue;
|
||||
|
||||
@ -602,20 +665,18 @@ protected:
|
||||
// Texture names and surface data, used by CGameMovement
|
||||
int m_surfaceProps;
|
||||
surfacedata_t* m_pSurfaceData;
|
||||
float m_surfaceFriction;
|
||||
char m_chTextureType;
|
||||
|
||||
bool m_bSentFreezeFrame;
|
||||
float m_flFreezeZOffset;
|
||||
byte m_ubEFNoInterpParity;
|
||||
byte m_ubOldEFNoInterpParity;
|
||||
|
||||
float m_flNextAchievementAnnounceTime;
|
||||
|
||||
int m_nForceVisionFilterFlags; // Force our vision filter to a specific setting
|
||||
|
||||
#if defined USES_ECON_ITEMS
|
||||
// Wearables
|
||||
CUtlVector<CHandle<C_EconWearable > > m_hMyWearables;
|
||||
#endif
|
||||
// If we have any attached split users, this is the list of them
|
||||
CUtlVector< CHandle< CBasePlayer > > m_hSplitScreenPlayers;
|
||||
int m_nSplitScreenSlot; //-1 == not a split player
|
||||
CHandle< CBasePlayer > m_hSplitOwner;
|
||||
bool m_bIsLocalPlayer;
|
||||
|
||||
private:
|
||||
|
||||
@ -636,6 +697,17 @@ public:
|
||||
bool ShouldGoSouth( Vector vNPCForward, Vector vNPCRight ); //Such a bad name.
|
||||
|
||||
void SetOldPlayerZ( float flOld ) { m_flOldPlayerZ = flOld; }
|
||||
|
||||
const fogplayerparams_t& GetPlayerFog() const { return m_PlayerFog; }
|
||||
|
||||
private:
|
||||
friend class CMoveHelperClient;
|
||||
|
||||
CNetworkHandle( CPostProcessController, m_hPostProcessCtrl ); // active postprocessing controller
|
||||
CNetworkHandle( CColorCorrection, m_hColorCorrectionCtrl ); // active FXVolume color correction
|
||||
|
||||
// fog params
|
||||
fogplayerparams_t m_PlayerFog;
|
||||
};
|
||||
|
||||
EXTERN_RECV_TABLE(DT_BasePlayer);
|
||||
@ -655,12 +727,20 @@ inline C_BasePlayer *ToBasePlayer( C_BaseEntity *pEntity )
|
||||
return static_cast<C_BasePlayer *>( pEntity );
|
||||
}
|
||||
|
||||
inline C_BaseEntity *C_BasePlayer::GetUseEntity()
|
||||
{
|
||||
return m_hUseEntity;
|
||||
inline const C_BasePlayer *ToBasePlayer( const C_BaseEntity *pEntity )
|
||||
{
|
||||
if ( !pEntity || !pEntity->IsPlayer() )
|
||||
return NULL;
|
||||
|
||||
#if _DEBUG
|
||||
Assert( dynamic_cast<const C_BasePlayer *>( pEntity ) != NULL );
|
||||
#endif
|
||||
|
||||
return static_cast<const C_BasePlayer *>( pEntity );
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline IClientVehicle *C_BasePlayer::GetVehicle()
|
||||
{
|
||||
C_BaseEntity *pVehicleEnt = m_hVehicle.Get();
|
||||
@ -686,6 +766,8 @@ inline C_CommandContext* C_BasePlayer::GetCommandContext()
|
||||
inline int CBasePlayer::CurrentCommandNumber() const
|
||||
{
|
||||
Assert( m_pCurrentCommand );
|
||||
if ( !m_pCurrentCommand )
|
||||
return 0;
|
||||
return m_pCurrentCommand->command_number;
|
||||
}
|
||||
|
||||
@ -695,4 +777,17 @@ inline const CUserCmd *CBasePlayer::GetCurrentUserCommand() const
|
||||
return m_pCurrentCommand;
|
||||
}
|
||||
|
||||
extern bool g_bEngineIsHLTV;
|
||||
|
||||
inline bool C_BasePlayer::IsHLTV() const
|
||||
{
|
||||
return m_bIsLocalPlayer && g_bEngineIsHLTV;
|
||||
}
|
||||
|
||||
inline bool C_BasePlayer::IsLocalPlayer( void ) const
|
||||
{
|
||||
return m_bIsLocalPlayer;
|
||||
}
|
||||
|
||||
|
||||
#endif // C_BASEPLAYER_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Core Temp Entity client implementation.
|
||||
//
|
||||
|
@ -1,9 +1,9 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_BASETEMPENTITY_H
|
||||
#define C_BASETEMPENTITY_H
|
||||
@ -46,7 +46,8 @@ public:
|
||||
virtual IClientEntity* GetIClientEntity() { return 0; }
|
||||
virtual C_BaseEntity* GetBaseEntity() { return 0; }
|
||||
virtual IClientThinkable* GetClientThinkable() { return 0; }
|
||||
|
||||
virtual IClientModelRenderable* GetClientModelRenderable() { return 0; }
|
||||
virtual IClientAlphaProperty* GetClientAlphaProperty() { return 0; }
|
||||
|
||||
// IClientNetworkable overrides.
|
||||
public:
|
||||
|
33
game/client/c_basetoggle.cpp
Normal file
33
game/client/c_basetoggle.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2007 Turtle Rock Studios, Inc.
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_basetoggle.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_BaseToggle, DT_BaseToggle, CBaseToggle )
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Returns the velocity imparted to players standing on us.
|
||||
void C_BaseToggle::GetGroundVelocityToApply( Vector &vecGroundVel )
|
||||
{
|
||||
vecGroundVel = GetLocalVelocity();
|
||||
vecGroundVel.z = 0.0f; // don't give upward velocity, or it could predict players into the air.
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_BaseButton, DT_BaseButton, CBaseButton )
|
||||
RecvPropBool( RECVINFO( m_usable ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool C_BaseButton::IsPotentiallyUsable( void )
|
||||
{
|
||||
return true;
|
||||
}
|
42
game/client/c_basetoggle.h
Normal file
42
game/client/c_basetoggle.h
Normal file
@ -0,0 +1,42 @@
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2007 Turtle Rock Studios, Inc.
|
||||
|
||||
#if !defined( C_BASETOGGLE_H )
|
||||
#define C_BASETOGGLE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "c_baseentity.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
class C_BaseToggle: public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BaseToggle, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual void GetGroundVelocityToApply( Vector &vecGroundVel );
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
class C_BaseButton: public C_BaseToggle
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BaseButton, C_BaseToggle );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_BaseButton()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool IsPotentiallyUsable( void );
|
||||
|
||||
private:
|
||||
bool m_usable;
|
||||
};
|
||||
|
||||
|
||||
#endif // C_BASETOGGLE_H
|
@ -1,10 +1,10 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side view model implementation. Responsible for drawing
|
||||
// the view model.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
#include "c_baseviewmodel.h"
|
||||
#include "model_types.h"
|
||||
@ -18,34 +18,43 @@
|
||||
#include "tools/bonelist.h"
|
||||
#include <KeyValues.h>
|
||||
#include "hltvcamera.h"
|
||||
|
||||
#include "r_efx.h"
|
||||
#include "dlight.h"
|
||||
#include "clientalphaproperty.h"
|
||||
#include "iinput.h"
|
||||
#if defined( REPLAY_ENABLED )
|
||||
#include "replay/replaycamera.h"
|
||||
#include "replay/ireplaysystem.h"
|
||||
#include "replay/ienginereplay.h"
|
||||
#include "replaycamera.h"
|
||||
#endif
|
||||
|
||||
// NVNT haptics system interface
|
||||
#include "haptics/ihaptics.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#ifdef CSTRIKE_DLL
|
||||
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." );
|
||||
#endif
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
ConVar cl_flipviewmodels( "cl_flipviewmodels", "0", FCVAR_USERINFO | FCVAR_ARCHIVE | FCVAR_NOT_CONNECTED, "Flip view models." );
|
||||
#endif
|
||||
ConVar vm_debug( "vm_debug", "0", FCVAR_CHEAT );
|
||||
ConVar vm_draw_always( "vm_draw_always", "0" );
|
||||
|
||||
void PostToolMessage( HTOOLHANDLE hEntity, KeyValues *msg );
|
||||
extern float g_flMuzzleFlashScale;
|
||||
|
||||
void FormatViewModelAttachment( Vector &vOrigin, bool bInverse )
|
||||
void FormatViewModelAttachment( C_BasePlayer *pPlayer, Vector &vOrigin, bool bInverse )
|
||||
{
|
||||
int nSlot = 0;
|
||||
if ( pPlayer )
|
||||
{
|
||||
int nPlayerSlot = C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer );
|
||||
if ( nPlayerSlot == -1 )
|
||||
{
|
||||
nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
}
|
||||
else
|
||||
{
|
||||
nSlot = nPlayerSlot;
|
||||
}
|
||||
}
|
||||
|
||||
Assert( nSlot != -1 );
|
||||
|
||||
// Presumably, SetUpView has been called so we know our FOV and render origin.
|
||||
const CViewSetup *pViewSetup = view->GetPlayerViewSetup();
|
||||
const CViewSetup *pViewSetup = view->GetPlayerViewSetup( nSlot );
|
||||
|
||||
float worldx = tan( pViewSetup->fov * M_PI/360.0 );
|
||||
float viewx = tan( pViewSetup->fovViewmodel * M_PI/360.0 );
|
||||
@ -59,7 +68,7 @@ void FormatViewModelAttachment( Vector &vOrigin, bool bInverse )
|
||||
|
||||
// Get the coordinates in the viewer's space.
|
||||
Vector tmp = vOrigin - pViewSetup->origin;
|
||||
Vector vTransformed( MainViewRight().Dot( tmp ), MainViewUp().Dot( tmp ), MainViewForward().Dot( tmp ) );
|
||||
Vector vTransformed( MainViewRight(nSlot).Dot( tmp ), MainViewUp(nSlot).Dot( tmp ), MainViewForward(nSlot).Dot( tmp ) );
|
||||
|
||||
// Now squash X and Y.
|
||||
if ( bInverse )
|
||||
@ -84,39 +93,35 @@ void FormatViewModelAttachment( Vector &vOrigin, bool bInverse )
|
||||
|
||||
|
||||
// Transform back to world space.
|
||||
Vector vOut = (MainViewRight() * vTransformed.x) + (MainViewUp() * vTransformed.y) + (MainViewForward() * vTransformed.z);
|
||||
Vector vOut = (MainViewRight(nSlot) * vTransformed.x) + (MainViewUp(nSlot) * vTransformed.y) + (MainViewForward(nSlot) * vTransformed.z);
|
||||
vOrigin = pViewSetup->origin + vOut;
|
||||
}
|
||||
|
||||
|
||||
void C_BaseViewModel::FormatViewModelAttachment( int nAttachment, matrix3x4_t &attachmentToWorld )
|
||||
{
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() );
|
||||
Vector vecOrigin;
|
||||
MatrixPosition( attachmentToWorld, vecOrigin );
|
||||
::FormatViewModelAttachment( vecOrigin, false );
|
||||
::FormatViewModelAttachment( pPlayer, vecOrigin, false );
|
||||
PositionMatrix( vecOrigin, attachmentToWorld );
|
||||
}
|
||||
|
||||
|
||||
bool C_BaseViewModel::IsViewModel() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void C_BaseViewModel::UncorrectViewModelAttachment( Vector &vOrigin )
|
||||
{
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() );
|
||||
// Unformat the attachment.
|
||||
::FormatViewModelAttachment( vOrigin, true );
|
||||
::FormatViewModelAttachment( pPlayer, vOrigin, true );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 eventNum, const char *options )
|
||||
{
|
||||
// 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 ( ( eventNum == AE_CL_PLAYSOUND ) || ( eventNum == CL_EVENT_SOUND ) )
|
||||
{
|
||||
// Only do this if we're owned by someone
|
||||
if ( GetOwner() != NULL )
|
||||
@ -127,18 +132,23 @@ void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int
|
||||
}
|
||||
}
|
||||
|
||||
C_BasePlayer *pOwner = ToBasePlayer( GetOwner() );
|
||||
if ( !pOwner )
|
||||
return;
|
||||
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pOwner );
|
||||
|
||||
// Otherwise pass the event to our associated weapon
|
||||
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
|
||||
C_BaseCombatWeapon *pWeapon = pOwner->GetActiveWeapon();
|
||||
if ( pWeapon )
|
||||
{
|
||||
// NVNT notify the haptics system of our viewmodel's event
|
||||
if ( haptics )
|
||||
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, eventNum, options );
|
||||
if ( !bResult )
|
||||
{
|
||||
BaseClass::FireEvent( origin, angles, event, options );
|
||||
if ( eventNum == AE_CLIENT_EFFECT_ATTACH && ::input->CAM_IsThirdPerson() )
|
||||
return;
|
||||
|
||||
BaseClass::FireEvent( origin, angles, eventNum, options );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +163,7 @@ bool C_BaseViewModel::Interpolate( float currentTime )
|
||||
|
||||
// Hack to extrapolate cycle counter for view model
|
||||
float elapsed_time = currentTime - m_flAnimTime;
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() );
|
||||
|
||||
// Predicted viewmodels have fixed up interval
|
||||
if ( GetPredictable() || IsClientCreated() )
|
||||
@ -162,10 +172,7 @@ bool C_BaseViewModel::Interpolate( float currentTime )
|
||||
float curtime = pPlayer ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime;
|
||||
elapsed_time = curtime - m_flAnimTime;
|
||||
// Adjust for interpolated partial frame
|
||||
if ( !engine->IsPaused() )
|
||||
{
|
||||
elapsed_time += ( gpGlobals->interpolation_amount * TICK_INTERVAL );
|
||||
}
|
||||
elapsed_time += ( gpGlobals->interpolation_amount * TICK_INTERVAL );
|
||||
}
|
||||
|
||||
// Prediction errors?
|
||||
@ -174,7 +181,7 @@ bool C_BaseViewModel::Interpolate( float currentTime )
|
||||
elapsed_time = 0;
|
||||
}
|
||||
|
||||
float dt = elapsed_time * GetSequenceCycleRate( pStudioHdr, GetSequence() ) * GetPlaybackRate();
|
||||
float dt = elapsed_time * GetSequenceCycleRate( pStudioHdr, GetSequence() );
|
||||
if ( dt >= 1.0f )
|
||||
{
|
||||
if ( !IsSequenceLooping( GetSequence() ) )
|
||||
@ -194,24 +201,6 @@ bool C_BaseViewModel::Interpolate( float currentTime )
|
||||
|
||||
inline bool C_BaseViewModel::ShouldFlipViewModel()
|
||||
{
|
||||
#ifdef CSTRIKE_DLL
|
||||
// If cl_righthand is set, then we want them all right-handed.
|
||||
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
|
||||
if ( pWeapon )
|
||||
{
|
||||
const FileWeaponInfo_t *pInfo = &pWeapon->GetWpnData();
|
||||
return pInfo->m_bAllowFlipping && pInfo->m_bBuiltRightHanded != cl_righthand.GetBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
|
||||
if ( pWeapon )
|
||||
{
|
||||
return pWeapon->m_bFlipViewModel != cl_flipviewmodels.GetBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -220,6 +209,8 @@ void C_BaseViewModel::ApplyBoneMatrixTransform( matrix3x4_t& transform )
|
||||
{
|
||||
if ( ShouldFlipViewModel() )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() );
|
||||
|
||||
matrix3x4_t viewMatrix, viewMatrixInverse;
|
||||
|
||||
// We could get MATERIAL_VIEW here, but this is called sometimes before the renderer
|
||||
@ -256,13 +247,13 @@ void C_BaseViewModel::ApplyBoneMatrixTransform( matrix3x4_t& transform )
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BaseViewModel::ShouldDraw()
|
||||
{
|
||||
if ( engine->IsHLTV() )
|
||||
if ( g_bEngineIsHLTV )
|
||||
{
|
||||
return ( HLTVCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
||||
HLTVCamera()->GetPrimaryTarget() == GetOwner() );
|
||||
}
|
||||
#if defined( REPLAY_ENABLED )
|
||||
else if ( g_pEngineClientReplay->IsPlayingReplayDemo() )
|
||||
else if ( engine->IsReplay() )
|
||||
{
|
||||
return ( ReplayCamera()->GetMode() == OBS_MODE_IN_EYE &&
|
||||
ReplayCamera()->GetPrimaryTarget() == GetOwner() );
|
||||
@ -270,6 +261,14 @@ bool C_BaseViewModel::ShouldDraw()
|
||||
#endif
|
||||
else
|
||||
{
|
||||
Assert( !IsEffectActive( EF_NODRAW ) );
|
||||
Assert( GetRenderMode() != kRenderNone );
|
||||
|
||||
if ( vm_draw_always.GetBool() )
|
||||
return true;
|
||||
if ( GetOwner() != C_BasePlayer::GetLocalPlayer() )
|
||||
return false;
|
||||
|
||||
return BaseClass::ShouldDraw();
|
||||
}
|
||||
}
|
||||
@ -278,7 +277,7 @@ bool C_BaseViewModel::ShouldDraw()
|
||||
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
|
||||
// by this player, otherwise draw the worldmodel.
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseViewModel::DrawModel( int flags )
|
||||
int C_BaseViewModel::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
if ( !m_bReadyToDraw )
|
||||
return 0;
|
||||
@ -286,7 +285,7 @@ int C_BaseViewModel::DrawModel( int flags )
|
||||
if ( flags & STUDIO_RENDER )
|
||||
{
|
||||
// Determine blending amount and tell engine
|
||||
float blend = (float)( GetFxBlend() / 255.0f );
|
||||
float blend = (float)( instance.m_nAlpha / 255.0f );
|
||||
|
||||
// Totally gone
|
||||
if ( blend <= 0.0f )
|
||||
@ -299,24 +298,32 @@ int C_BaseViewModel::DrawModel( int flags )
|
||||
GetColorModulation( color );
|
||||
render->SetColorModulation( color );
|
||||
}
|
||||
|
||||
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
|
||||
if ( ShouldFlipViewModel() )
|
||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
|
||||
|
||||
int ret = 0;
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
||||
int ret;
|
||||
|
||||
// If the local player's overriding the viewmodel rendering, let him do it
|
||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
||||
{
|
||||
ret = pPlayer->DrawOverriddenViewmodel( this, flags );
|
||||
ret = pPlayer->DrawOverriddenViewmodel( this, flags, instance );
|
||||
}
|
||||
else if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
||||
{
|
||||
ret = pWeapon->DrawOverriddenViewmodel( this, flags );
|
||||
ret = pWeapon->DrawOverriddenViewmodel( this, flags, instance );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BaseClass::DrawModel( flags );
|
||||
ret = BaseClass::DrawModel( flags, instance );
|
||||
}
|
||||
|
||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CCW );
|
||||
|
||||
// Now that we've rendered, reset the animation restart flag
|
||||
if ( flags & STUDIO_RENDER )
|
||||
{
|
||||
@ -324,111 +331,120 @@ int C_BaseViewModel::DrawModel( int flags )
|
||||
{
|
||||
m_nOldAnimationParity = m_nAnimationParity;
|
||||
}
|
||||
|
||||
// Tell the weapon itself that we've rendered, in case it wants to do something
|
||||
if ( pWeapon )
|
||||
{
|
||||
pWeapon->ViewModelDrawn( this );
|
||||
}
|
||||
|
||||
if ( vm_debug.GetBool() )
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
|
||||
int line = 16;
|
||||
CStudioHdr *hdr = GetModelPtr();
|
||||
engine->Con_NPrintf( line++, "%s: %s(%d), cycle: %.2f cyclerate: %.2f playbackrate: %.2f\n",
|
||||
(hdr)?hdr->pszName():"(null)",
|
||||
GetSequenceName( GetSequence() ),
|
||||
GetSequence(),
|
||||
GetCycle(),
|
||||
GetSequenceCycleRate( hdr, GetSequence() ),
|
||||
GetPlaybackRate()
|
||||
);
|
||||
if ( hdr )
|
||||
{
|
||||
for( int i=0; i < hdr->GetNumPoseParameters(); ++i )
|
||||
{
|
||||
const mstudioposeparamdesc_t &Pose = hdr->pPoseParameter( i );
|
||||
engine->Con_NPrintf( line++, "pose_param %s: %f",
|
||||
Pose.pszName(), GetPoseParameter( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Determine blending amount and tell engine
|
||||
float blend = (float)( instance.m_nAlpha / 255.0f );
|
||||
float color[3];
|
||||
GetColorModulation( color );
|
||||
engine->Con_NPrintf( line++, "blend=%f, color=%f,%f,%f", blend, color[0], color[1], color[2] );
|
||||
engine->Con_NPrintf( line++, "GetRenderMode()=%d", GetRenderMode() );
|
||||
engine->Con_NPrintf( line++, "m_nRenderFX=0x%8.8X", GetRenderFX() );
|
||||
|
||||
color24 c = GetRenderColor();
|
||||
unsigned char a = GetRenderAlpha();
|
||||
engine->Con_NPrintf( line++, "rendercolor=%d,%d,%d,%d", c.r, c.g, c.b, a );
|
||||
|
||||
engine->Con_NPrintf( line++, "origin=%f, %f, %f", GetRenderOrigin().x, GetRenderOrigin().y, GetRenderOrigin().z );
|
||||
engine->Con_NPrintf( line++, "angles=%f, %f, %f", GetRenderAngles()[0], GetRenderAngles()[1], GetRenderAngles()[2] );
|
||||
|
||||
if ( IsEffectActive( EF_NODRAW ) )
|
||||
{
|
||||
engine->Con_NPrintf( line++, "EF_NODRAW" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseViewModel::InternalDrawModel( int flags )
|
||||
{
|
||||
CMatRenderContextPtr pRenderContext( materials );
|
||||
if ( ShouldFlipViewModel() )
|
||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
|
||||
|
||||
int ret = BaseClass::InternalDrawModel( flags );
|
||||
|
||||
pRenderContext->CullMode( MATERIAL_CULLMODE_CCW );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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, const RenderableInstance_t &instance )
|
||||
{
|
||||
return BaseClass::DrawModel( flags );
|
||||
return BaseClass::DrawModel( flags, instance );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseViewModel::GetFxBlend( void )
|
||||
uint8 C_BaseViewModel::OverrideAlphaModulation( uint8 nAlpha )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() );
|
||||
|
||||
// See if the local player wants to override the viewmodel's rendering
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
||||
{
|
||||
pPlayer->ComputeFxBlend();
|
||||
return pPlayer->GetFxBlend();
|
||||
}
|
||||
|
||||
return pPlayer->AlphaProp()->ComputeRenderAlpha();
|
||||
|
||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
||||
{
|
||||
pWeapon->ComputeFxBlend();
|
||||
return pWeapon->GetFxBlend();
|
||||
}
|
||||
return pWeapon->AlphaProp()->ComputeRenderAlpha();
|
||||
|
||||
return nAlpha;
|
||||
|
||||
return BaseClass::GetFxBlend();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BaseViewModel::IsTransparent( void )
|
||||
RenderableTranslucencyType_t C_BaseViewModel::ComputeTranslucencyType( void )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() );
|
||||
|
||||
// See if the local player wants to override the viewmodel's rendering
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
||||
{
|
||||
return pPlayer->ViewModel_IsTransparent();
|
||||
}
|
||||
return pPlayer->ComputeTranslucencyType();
|
||||
|
||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
||||
return pWeapon->ViewModel_IsTransparent();
|
||||
return pWeapon->ComputeTranslucencyType();
|
||||
|
||||
return BaseClass::ComputeTranslucencyType();
|
||||
|
||||
return BaseClass::IsTransparent();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BaseViewModel::UsesPowerOfTwoFrameBufferTexture( void )
|
||||
{
|
||||
// See if the local player wants to override the viewmodel's rendering
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( pPlayer && pPlayer->IsOverridingViewmodel() )
|
||||
{
|
||||
return pPlayer->ViewModel_IsUsingFBTexture();
|
||||
}
|
||||
|
||||
C_BaseCombatWeapon *pWeapon = GetOwningWeapon();
|
||||
if ( pWeapon && pWeapon->IsOverridingViewmodel() )
|
||||
{
|
||||
return pWeapon->ViewModel_IsUsingFBTexture();
|
||||
}
|
||||
|
||||
return BaseClass::UsesPowerOfTwoFrameBufferTexture();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: If the animation parity of the weapon has changed, we reset cycle to avoid popping
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseViewModel::UpdateAnimationParity( void )
|
||||
{
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() );
|
||||
|
||||
// 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
|
||||
@ -450,27 +466,26 @@ void C_BaseViewModel::UpdateAnimationParity( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseViewModel::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
AlphaProp()->EnableAlphaModulationOverride( true );
|
||||
}
|
||||
|
||||
SetPredictionEligible( true );
|
||||
BaseClass::OnDataChanged(updateType);
|
||||
}
|
||||
|
||||
void C_BaseViewModel::PostDataUpdate( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::PostDataUpdate(updateType);
|
||||
OnLatchInterpolatedVariables( LATCH_ANIMATION_VAR );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add entity to visible view models list
|
||||
// Purpose: Return the player who will predict this entity
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseViewModel::AddEntity( void )
|
||||
CBasePlayer *C_BaseViewModel::GetPredictionOwner()
|
||||
{
|
||||
// Server says don't interpolate this frame, so set previous info to new info.
|
||||
if ( IsNoInterpolationFrame() )
|
||||
{
|
||||
ResetLatched();
|
||||
}
|
||||
return ToBasePlayer( GetOwner() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -481,18 +496,14 @@ void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS])
|
||||
BaseClass::GetBoneControllers( controllers );
|
||||
|
||||
// Tell the weapon itself that we've rendered, in case it wants to do something
|
||||
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() );
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
|
||||
if ( pWeapon )
|
||||
{
|
||||
pWeapon->GetViewmodelBoneControllers( this, controllers );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : RenderGroup_t
|
||||
//-----------------------------------------------------------------------------
|
||||
RenderGroup_t C_BaseViewModel::GetRenderGroup()
|
||||
{
|
||||
return RENDER_GROUP_VIEW_MODEL_OPAQUE;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side view model implementation. Responsible for drawing
|
||||
// the view model.
|
||||
@ -13,7 +13,8 @@
|
||||
#endif
|
||||
|
||||
#include "c_baseanimating.h"
|
||||
#include "utlvector.h"
|
||||
#include "UtlVector.h"
|
||||
#include "baseviewmodel_shared.h"
|
||||
|
||||
|
||||
#endif // C_BASEVIEWMODEL_H
|
||||
|
354
game/client/c_beamspotlight.cpp
Normal file
354
game/client/c_beamspotlight.cpp
Normal file
@ -0,0 +1,354 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "dlight.h"
|
||||
#include "iefx.h"
|
||||
|
||||
#include "beam_shared.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSpotlightTraceCacheEntry
|
||||
{
|
||||
public:
|
||||
CSpotlightTraceCacheEntry()
|
||||
{
|
||||
m_origin.Init();
|
||||
m_radius = -1.0f;
|
||||
}
|
||||
bool IsValidFor( const Vector &origin )
|
||||
{
|
||||
if ( m_radius > 0 && m_origin.DistToSqr(origin) < 1.0f )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
void Cache( const Vector &origin, const trace_t &tr )
|
||||
{
|
||||
m_radius = (tr.endpos - origin).Length();
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
Vector m_origin;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
static const int NUM_CACHE_ENTRIES = 64;
|
||||
|
||||
class C_BeamSpotLight : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_BeamSpotLight, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_BeamSpotLight();
|
||||
~C_BeamSpotLight();
|
||||
|
||||
bool ShouldDraw();
|
||||
void ClientThink( void );
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
void Release( void );
|
||||
|
||||
private:
|
||||
|
||||
Vector SpotlightCurrentPos(void);
|
||||
void SpotlightCreate(void);
|
||||
void SpotlightDestroy(void);
|
||||
|
||||
// Computes render info for a spotlight
|
||||
void ComputeRenderInfo();
|
||||
|
||||
private:
|
||||
|
||||
int m_nHaloIndex;
|
||||
int m_nRotationAxis;
|
||||
float m_flRotationSpeed;
|
||||
|
||||
|
||||
bool m_bSpotlightOn;
|
||||
bool m_bHasDynamicLight;
|
||||
|
||||
float m_flSpotlightMaxLength;
|
||||
float m_flSpotlightGoalWidth;
|
||||
float m_flHDRColorScale;
|
||||
|
||||
Vector m_vSpotlightTargetPos;
|
||||
Vector m_vSpotlightCurrentPos;
|
||||
Vector m_vSpotlightDir;
|
||||
|
||||
CHandle<C_Beam> m_hSpotlight;
|
||||
|
||||
float m_flSpotlightCurLength;
|
||||
|
||||
float m_flLightScale;
|
||||
|
||||
dlight_t* m_pDynamicLight;
|
||||
|
||||
float m_lastTime;
|
||||
CSpotlightTraceCacheEntry *m_pCache;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( beam_spotlight, C_BeamSpotLight );
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_BeamSpotLight, DT_BeamSpotlight, CBeamSpotlight )
|
||||
RecvPropInt( RECVINFO(m_nHaloIndex) ),
|
||||
RecvPropBool( RECVINFO(m_bSpotlightOn) ),
|
||||
RecvPropBool( RECVINFO(m_bHasDynamicLight) ),
|
||||
RecvPropFloat( RECVINFO(m_flSpotlightMaxLength) ),
|
||||
RecvPropFloat( RECVINFO(m_flSpotlightGoalWidth) ),
|
||||
RecvPropFloat( RECVINFO(m_flHDRColorScale) ),
|
||||
RecvPropInt( RECVINFO(m_nRotationAxis) ),
|
||||
RecvPropFloat( RECVINFO(m_flRotationSpeed) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BeamSpotLight::C_BeamSpotLight()
|
||||
: m_vSpotlightTargetPos( vec3_origin )
|
||||
, m_vSpotlightCurrentPos( vec3_origin )
|
||||
, m_vSpotlightDir( vec3_origin )
|
||||
, m_flSpotlightCurLength( 0.0f )
|
||||
, m_flLightScale( 100.0f )
|
||||
, m_pDynamicLight( NULL )
|
||||
, m_lastTime( 0.0f )
|
||||
, m_pCache(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
C_BeamSpotLight::~C_BeamSpotLight()
|
||||
{
|
||||
delete[] m_pCache;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BeamSpotLight::ShouldDraw()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::ClientThink( void )
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_lastTime;
|
||||
if ( !m_lastTime )
|
||||
{
|
||||
dt = 0.0f;
|
||||
}
|
||||
m_lastTime = gpGlobals->curtime;
|
||||
|
||||
// ---------------------------------------------------
|
||||
// If I don't have a spotlight attempt to create one
|
||||
// ---------------------------------------------------
|
||||
if ( !m_hSpotlight )
|
||||
{
|
||||
if ( m_bSpotlightOn )
|
||||
{
|
||||
// Make the spotlight
|
||||
SpotlightCreate();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNextClientThink( CLIENT_THINK_NEVER );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( !m_bSpotlightOn )
|
||||
{
|
||||
SpotlightDestroy();
|
||||
SetNextClientThink( CLIENT_THINK_NEVER );
|
||||
return;
|
||||
}
|
||||
|
||||
// update rotation
|
||||
if ( m_flRotationSpeed != 0.0f )
|
||||
{
|
||||
QAngle angles = GetAbsAngles();
|
||||
angles[m_nRotationAxis] += m_flRotationSpeed * dt;
|
||||
angles[m_nRotationAxis] = anglemod(angles[m_nRotationAxis]);
|
||||
if ( !m_pCache )
|
||||
{
|
||||
m_pCache = new CSpotlightTraceCacheEntry[NUM_CACHE_ENTRIES];
|
||||
}
|
||||
|
||||
SetAbsAngles( angles );
|
||||
}
|
||||
m_vSpotlightCurrentPos = SpotlightCurrentPos();
|
||||
|
||||
Assert( m_hSpotlight );
|
||||
|
||||
m_hSpotlight->SetStartPos( GetAbsOrigin() );
|
||||
m_hSpotlight->SetEndPos( m_vSpotlightCurrentPos );
|
||||
|
||||
// Avoid sudden change in where beam fades out when cross disconinuities
|
||||
Vector dir = m_vSpotlightCurrentPos - GetAbsOrigin();
|
||||
float flBeamLength = VectorNormalize( dir );
|
||||
m_flSpotlightCurLength = (0.60*m_flSpotlightCurLength) + (0.4*flBeamLength);
|
||||
|
||||
ComputeRenderInfo();
|
||||
|
||||
m_hSpotlight->RelinkBeam();
|
||||
|
||||
//NDebugOverlay::Cross3D(GetAbsOrigin(),Vector(-5,-5,-5),Vector(5,5,5),0,255,0,true,0.1);
|
||||
//NDebugOverlay::Cross3D(m_vSpotlightCurrentPos,Vector(-5,-5,-5),Vector(5,5,5),0,255,0,true,0.1);
|
||||
//NDebugOverlay::Cross3D(m_vSpotlightTargetPos,Vector(-5,-5,-5),Vector(5,5,5),255,0,0,true,0.1);
|
||||
|
||||
// Do we need to keep updating?
|
||||
if ( !GetMoveParent() && m_flRotationSpeed == 0 )
|
||||
{
|
||||
// No reason to think again, we're not going to move unless there's a data change
|
||||
SetNextClientThink( CLIENT_THINK_NEVER );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
m_flSpotlightCurLength = m_flSpotlightMaxLength;
|
||||
}
|
||||
|
||||
// On a data change always think again
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::Release()
|
||||
{
|
||||
SpotlightDestroy();
|
||||
BaseClass::Release();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::SpotlightCreate(void)
|
||||
{
|
||||
m_vSpotlightTargetPos = SpotlightCurrentPos();
|
||||
|
||||
{
|
||||
//C_Beam *beam = CBeam::BeamCreate( "sprites/spotlight.vmt", m_flSpotlightGoalWidth );
|
||||
C_Beam *beam = C_Beam::BeamCreate( "sprites/glow_test02.vmt", m_flSpotlightGoalWidth );
|
||||
// Beam only exists client side
|
||||
ClientEntityList().AddNonNetworkableEntity( beam );
|
||||
m_hSpotlight = beam;
|
||||
}
|
||||
|
||||
// Set the temporary spawnflag on the beam so it doesn't save (we'll recreate it on restore)
|
||||
m_hSpotlight->SetHDRColorScale( m_flHDRColorScale );
|
||||
const color24 c = GetRenderColor();
|
||||
m_hSpotlight->SetColor( c.r, c.g, c.b );
|
||||
m_hSpotlight->SetHaloTexture(m_nHaloIndex);
|
||||
m_hSpotlight->SetHaloScale(60);
|
||||
m_hSpotlight->SetEndWidth(m_flSpotlightGoalWidth);
|
||||
m_hSpotlight->SetBeamFlags( (FBEAM_SHADEOUT|FBEAM_NOTILE) );
|
||||
m_hSpotlight->SetBrightness( 64 );
|
||||
m_hSpotlight->SetNoise( 0 );
|
||||
|
||||
m_hSpotlight->PointsInit( GetAbsOrigin(), m_vSpotlightTargetPos );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::SpotlightDestroy(void)
|
||||
{
|
||||
if ( m_hSpotlight )
|
||||
{
|
||||
UTIL_Remove( m_hSpotlight );
|
||||
m_hSpotlight.Term();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Vector C_BeamSpotLight::SpotlightCurrentPos(void)
|
||||
{
|
||||
QAngle angles = GetAbsAngles();
|
||||
GetVectors( &m_vSpotlightDir, NULL, NULL );
|
||||
Vector position = GetAbsOrigin();
|
||||
int cacheIndex = -1;
|
||||
if ( m_pCache )
|
||||
{
|
||||
cacheIndex = int( angles[m_nRotationAxis] * float(NUM_CACHE_ENTRIES) * (1.0f / 360.0f)) & (NUM_CACHE_ENTRIES - 1);
|
||||
if ( m_pCache[cacheIndex].IsValidFor(GetAbsOrigin()) )
|
||||
{
|
||||
return position + m_vSpotlightDir * m_pCache[cacheIndex].m_radius;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get beam end point. Only collide with solid objects, not npcs
|
||||
trace_t tr;
|
||||
UTIL_TraceLine( position, position + (m_vSpotlightDir * 2 * m_flSpotlightMaxLength), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
|
||||
if ( cacheIndex >= 0 )
|
||||
{
|
||||
m_pCache[cacheIndex].Cache(position, tr);
|
||||
}
|
||||
|
||||
return tr.endpos;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Computes render info for a spotlight
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BeamSpotLight::ComputeRenderInfo()
|
||||
{
|
||||
// Fade out spotlight end if past max length.
|
||||
if ( m_flSpotlightCurLength > 2*m_flSpotlightMaxLength )
|
||||
{
|
||||
SetRenderAlpha( 0 );
|
||||
m_hSpotlight->SetFadeLength( m_flSpotlightMaxLength );
|
||||
}
|
||||
else if ( m_flSpotlightCurLength > m_flSpotlightMaxLength )
|
||||
{
|
||||
SetRenderAlpha( (1-((m_flSpotlightCurLength-m_flSpotlightMaxLength)/m_flSpotlightMaxLength)) );
|
||||
m_hSpotlight->SetFadeLength( m_flSpotlightMaxLength );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetRenderAlpha( 1.0 );
|
||||
m_hSpotlight->SetFadeLength( m_flSpotlightCurLength );
|
||||
}
|
||||
|
||||
// Adjust end width to keep beam width constant
|
||||
float flNewWidth = m_flSpotlightGoalWidth * (m_flSpotlightCurLength / m_flSpotlightMaxLength);
|
||||
flNewWidth = clamp(flNewWidth, 0, MAX_BEAM_WIDTH );
|
||||
m_hSpotlight->SetEndWidth(flNewWidth);
|
||||
|
||||
if ( m_bHasDynamicLight )
|
||||
{
|
||||
// <<TODO>> - magic number 1.8 depends on sprite size
|
||||
m_flLightScale = 1.8*flNewWidth;
|
||||
|
||||
if ( m_flLightScale > 0 )
|
||||
{
|
||||
const color24 c = GetRenderColor();
|
||||
float a = GetRenderAlpha() / 255.0f;
|
||||
ColorRGBExp32 color;
|
||||
color.r = c.r * a;
|
||||
color.g = c.g * a;
|
||||
color.b = c.b * a;
|
||||
color.exponent = 0;
|
||||
if ( color.r == 0 && color.g == 0 && color.b == 0 )
|
||||
return;
|
||||
|
||||
// Deal with the environment light
|
||||
if ( !m_pDynamicLight || (m_pDynamicLight->key != index) )
|
||||
{
|
||||
m_pDynamicLight = effects->CL_AllocDlight( index );
|
||||
assert (m_pDynamicLight);
|
||||
}
|
||||
|
||||
//m_pDynamicLight->flags = DLIGHT_NO_MODEL_ILLUMINATION;
|
||||
m_pDynamicLight->radius = m_flLightScale*3.0f;
|
||||
m_pDynamicLight->origin = GetAbsOrigin() + Vector(0,0,5);
|
||||
m_pDynamicLight->die = gpGlobals->curtime + 0.05f;
|
||||
m_pDynamicLight->color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -18,6 +18,7 @@
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_BreakableProp, DT_BreakableProp, CBreakableProp)
|
||||
RecvPropBool( RECVINFO( m_bClientPhysics ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -28,19 +29,23 @@ C_BreakableProp::C_BreakableProp( void )
|
||||
m_takedamage = DAMAGE_YES;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BreakableProp::SetFadeMinMax( float fademin, float fademax )
|
||||
{
|
||||
m_fadeMinDist = fademin;
|
||||
m_fadeMaxDist = fademax;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copy fade from another breakable prop
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BreakableProp::CopyFadeFrom( C_BreakableProp *pSource )
|
||||
{
|
||||
m_flFadeScale = pSource->m_flFadeScale;
|
||||
SetGlobalFadeScale( pSource->GetGlobalFadeScale() );
|
||||
SetDistanceFade( pSource->GetMinFadeDist(), pSource->GetMaxFadeDist() );
|
||||
}
|
||||
|
||||
void C_BreakableProp::OnDataChanged( DataUpdateType_t type )
|
||||
{
|
||||
BaseClass::OnDataChanged( type );
|
||||
if ( m_bClientPhysics )
|
||||
{
|
||||
bool bCreate = (type == DATA_UPDATE_CREATED) ? true : false;
|
||||
VPhysicsShadowDataChanged(bCreate, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -20,11 +20,18 @@ public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_BreakableProp();
|
||||
|
||||
virtual void SetFadeMinMax( float fademin, float fademax );
|
||||
|
||||
virtual bool IsProp( void ) const
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
// Copy fade from another breakable prop
|
||||
void CopyFadeFrom( C_BreakableProp *pSource );
|
||||
virtual void OnDataChanged( DataUpdateType_t type );
|
||||
|
||||
private:
|
||||
bool m_bClientPhysics;
|
||||
};
|
||||
|
||||
#endif // C_BREAKABLEPROP_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Color correction entity with simple radial falloff
|
||||
//
|
||||
@ -6,10 +6,12 @@
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_colorcorrection.h"
|
||||
#include "filesystem.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "colorcorrectionmgr.h"
|
||||
#include "materialsystem/MaterialSystemUtil.h"
|
||||
#include "materialsystem/materialsystemutil.h"
|
||||
#include "iclientmode.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@ -17,46 +19,25 @@
|
||||
|
||||
static ConVar mat_colcorrection_disableentities( "mat_colcorrection_disableentities", "0", FCVAR_NONE, "Disable map color-correction entities" );
|
||||
|
||||
static ConVar mat_colcorrection_forceentitiesclientside( "mat_colcorrection_forceentitiesclientside", "0", FCVAR_CHEAT, "Forces color correction entities to be updated on the client" );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Color correction entity with radial falloff
|
||||
//------------------------------------------------------------------------------
|
||||
class C_ColorCorrection : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_ColorCorrection, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_ColorCorrection();
|
||||
virtual ~C_ColorCorrection();
|
||||
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
void ClientThink();
|
||||
|
||||
private:
|
||||
Vector m_vecOrigin;
|
||||
|
||||
float m_minFalloff;
|
||||
float m_maxFalloff;
|
||||
float m_flCurWeight;
|
||||
char m_netLookupFilename[MAX_PATH];
|
||||
|
||||
bool m_bEnabled;
|
||||
|
||||
ClientCCHandle_t m_CCHandle;
|
||||
};
|
||||
#ifdef CColorCorrection
|
||||
#undef CColorCorrection
|
||||
#endif
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_ColorCorrection, DT_ColorCorrection, CColorCorrection)
|
||||
RecvPropVector( RECVINFO(m_vecOrigin) ),
|
||||
RecvPropFloat( RECVINFO(m_minFalloff) ),
|
||||
RecvPropFloat( RECVINFO(m_maxFalloff) ),
|
||||
RecvPropFloat( RECVINFO(m_flCurWeight) ),
|
||||
RecvPropFloat( RECVINFO(m_flMaxWeight) ),
|
||||
RecvPropFloat( RECVINFO(m_flFadeInDuration) ),
|
||||
RecvPropFloat( RECVINFO(m_flFadeOutDuration) ),
|
||||
RecvPropString( RECVINFO(m_netLookupFilename) ),
|
||||
RecvPropBool( RECVINFO(m_bEnabled) ),
|
||||
|
||||
RecvPropBool( RECVINFO(m_bMaster) ),
|
||||
RecvPropBool( RECVINFO(m_bClientSide) ),
|
||||
RecvPropBool( RECVINFO(m_bExclusive) )
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
@ -65,14 +46,38 @@ END_RECV_TABLE()
|
||||
//------------------------------------------------------------------------------
|
||||
C_ColorCorrection::C_ColorCorrection()
|
||||
{
|
||||
m_minFalloff = -1.0f;
|
||||
m_maxFalloff = -1.0f;
|
||||
m_flFadeInDuration = 0.0f;
|
||||
m_flFadeOutDuration = 0.0f;
|
||||
m_flCurWeight = 0.0f;
|
||||
m_flMaxWeight = 1.0f;
|
||||
m_netLookupFilename[0] = '\0';
|
||||
m_bEnabled = false;
|
||||
m_bMaster = false;
|
||||
m_bExclusive = false;
|
||||
m_CCHandle = INVALID_CLIENT_CCHANDLE;
|
||||
|
||||
for ( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; i++ )
|
||||
{
|
||||
m_bEnabledOnClient[i] = false;
|
||||
m_flCurWeightOnClient[i] = 0.0f;
|
||||
m_bFadingIn[i] = false;
|
||||
m_flFadeStartWeight[i] = 0.0f;
|
||||
m_flFadeStartTime[i] = 0.0f;
|
||||
m_flFadeDuration[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
C_ColorCorrection::~C_ColorCorrection()
|
||||
{
|
||||
g_pColorCorrectionMgr->RemoveColorCorrection( m_CCHandle );
|
||||
g_pColorCorrectionMgr->RemoveColorCorrectionEntity( this, m_CCHandle );
|
||||
}
|
||||
|
||||
bool C_ColorCorrection::IsClientSide() const
|
||||
{
|
||||
return m_bClientSide || mat_colcorrection_forceentitiesclientside.GetBool();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose :
|
||||
@ -87,11 +92,13 @@ void C_ColorCorrection::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
Q_strncpy( filename, m_netLookupFilename, MAX_PATH );
|
||||
// forming a unique name without extension
|
||||
char cleanName[MAX_PATH];
|
||||
V_StripExtension( m_netLookupFilename, cleanName, sizeof( cleanName ) );
|
||||
char name[MAX_PATH];
|
||||
Q_snprintf( name, MAX_PATH, "%s_%d", cleanName, entindex() );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrection( filename );
|
||||
SetNextClientThink( ( m_CCHandle != INVALID_CLIENT_CCHANDLE ) ? CLIENT_THINK_ALWAYS : CLIENT_THINK_NEVER );
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrectionEntity( this, name, m_netLookupFilename );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,27 +111,33 @@ bool C_ColorCorrection::ShouldDraw()
|
||||
return false;
|
||||
}
|
||||
|
||||
void C_ColorCorrection::ClientThink()
|
||||
void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale )
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
return;
|
||||
Assert( m_CCHandle != INVALID_CLIENT_CCHANDLE );
|
||||
|
||||
if ( mat_colcorrection_disableentities.GetInt() )
|
||||
{
|
||||
// Allow the colorcorrectionui panel (or user) to turn off color-correction entities
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f );
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !m_bEnabled && m_flCurWeight == 0.0f )
|
||||
int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
bool bEnabled = IsClientSide() ? m_bEnabledOnClient[nSlot] : m_bEnabled;
|
||||
|
||||
// fade weight on client
|
||||
if ( IsClientSide() )
|
||||
{
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f );
|
||||
return;
|
||||
m_flCurWeightOnClient[nSlot] = Lerp( GetFadeRatio( nSlot ), m_flFadeStartWeight[nSlot], m_bFadingIn[nSlot] ? m_flMaxWeight : 0.0f );
|
||||
}
|
||||
|
||||
C_BaseEntity *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if( !pPlayer )
|
||||
float flCurWeight = IsClientSide() ? m_flCurWeightOnClient[nSlot] : m_flCurWeight;
|
||||
|
||||
if( !bEnabled && flCurWeight == 0.0f )
|
||||
{
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive );
|
||||
return;
|
||||
}
|
||||
|
||||
Vector playerOrigin = pPlayer->GetAbsOrigin();
|
||||
|
||||
@ -136,21 +149,99 @@ void C_ColorCorrection::ClientThink()
|
||||
if ( weight<0.0f ) weight = 0.0f;
|
||||
if ( weight>1.0f ) weight = 1.0f;
|
||||
}
|
||||
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_flCurWeight * ( 1.0 - weight ) );
|
||||
|
||||
BaseClass::ClientThink();
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, flCurWeight * ( 1.0 - weight ) * ccScale, m_bExclusive );
|
||||
}
|
||||
|
||||
void C_ColorCorrection::EnableOnClient( bool bEnable, bool bSkipFade )
|
||||
{
|
||||
if ( !IsClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
|
||||
if( m_bEnabledOnClient[nSlot] == bEnable )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_bFadingIn[nSlot] = bEnable;
|
||||
m_bEnabledOnClient[nSlot] = bEnable;
|
||||
|
||||
// initialize countdown timer
|
||||
m_flFadeStartWeight[nSlot] = m_flCurWeightOnClient[nSlot];
|
||||
float flFadeTimeScale = 1.0f;
|
||||
if ( m_flMaxWeight != 0.0f )
|
||||
{
|
||||
flFadeTimeScale = m_flCurWeightOnClient[nSlot] / m_flMaxWeight;
|
||||
}
|
||||
|
||||
if ( m_bFadingIn[nSlot] )
|
||||
{
|
||||
flFadeTimeScale = 1.0f - flFadeTimeScale;
|
||||
}
|
||||
|
||||
if ( bSkipFade )
|
||||
{
|
||||
flFadeTimeScale = 0.0f;
|
||||
}
|
||||
|
||||
StartFade( nSlot, flFadeTimeScale * ( m_bFadingIn[nSlot] ? m_flFadeInDuration : m_flFadeOutDuration ) );
|
||||
|
||||
// update the clientside weight once here, in case the fade duration is 0
|
||||
m_flCurWeightOnClient[nSlot] = Lerp( GetFadeRatio( nSlot ), m_flFadeStartWeight[nSlot], m_bFadingIn[nSlot] ? m_flMaxWeight : 0.0f );
|
||||
}
|
||||
|
||||
Vector C_ColorCorrection::GetOrigin()
|
||||
{
|
||||
return m_vecOrigin;
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetMinFalloff()
|
||||
{
|
||||
return m_minFalloff;
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetMaxFalloff()
|
||||
{
|
||||
return m_maxFalloff;
|
||||
}
|
||||
|
||||
void C_ColorCorrection::SetWeight( float fWeight )
|
||||
{
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, fWeight, false );
|
||||
}
|
||||
|
||||
void C_ColorCorrection::StartFade( int nSplitScreenSlot, float flDuration )
|
||||
{
|
||||
m_flFadeStartTime[nSplitScreenSlot] = gpGlobals->curtime;
|
||||
m_flFadeDuration[nSplitScreenSlot] = MAX( flDuration, 0.0f );
|
||||
}
|
||||
|
||||
float C_ColorCorrection::GetFadeRatio( int nSplitScreenSlot ) const
|
||||
{
|
||||
float flRatio = 1.0f;
|
||||
|
||||
if ( m_flFadeDuration[nSplitScreenSlot] != 0.0f )
|
||||
{
|
||||
flRatio = ( gpGlobals->curtime - m_flFadeStartTime[nSplitScreenSlot] ) / m_flFadeDuration[nSplitScreenSlot];
|
||||
flRatio = clamp( flRatio, 0.0f, 1.0f );
|
||||
}
|
||||
return flRatio;
|
||||
}
|
||||
|
||||
bool C_ColorCorrection::IsFadeTimeElapsed( int nSplitScreenSlot ) const
|
||||
{
|
||||
return ( ( gpGlobals->curtime - m_flFadeStartTime[nSplitScreenSlot] ) > m_flFadeDuration[nSplitScreenSlot] ) ||
|
||||
( ( gpGlobals->curtime - m_flFadeStartTime[nSplitScreenSlot] ) < 0.0f );
|
||||
}
|
||||
|
||||
void UpdateColorCorrectionEntities( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrection **pList, int listCount )
|
||||
{
|
||||
for ( int i = 0; i < listCount; i++ )
|
||||
{
|
||||
pList[i]->Update(pPlayer, ccScale);
|
||||
}
|
||||
}
|
76
game/client/c_colorcorrection.h
Normal file
76
game/client/c_colorcorrection.h
Normal file
@ -0,0 +1,76 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Color correction entity with simple radial falloff
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_COLORCORRECTION_H
|
||||
#define C_COLORCORRECTION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "colorcorrectionmgr.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Color correction entity with radial falloff
|
||||
//------------------------------------------------------------------------------
|
||||
class C_ColorCorrection : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_ColorCorrection, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_ColorCorrection();
|
||||
virtual ~C_ColorCorrection();
|
||||
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
virtual void Update(C_BasePlayer *pPlayer, float ccScale);
|
||||
|
||||
bool IsMaster() const { return m_bMaster; }
|
||||
bool IsClientSide() const;
|
||||
bool IsExclusive() const { return m_bExclusive; }
|
||||
|
||||
void EnableOnClient( bool bEnable, bool bSkipFade = false );
|
||||
|
||||
Vector GetOrigin();
|
||||
float GetMinFalloff();
|
||||
float GetMaxFalloff();
|
||||
|
||||
void SetWeight( float fWeight );
|
||||
|
||||
protected:
|
||||
void StartFade( int nSplitScreenSlot, float flDuration );
|
||||
float GetFadeRatio( int nSplitScreenSlot ) const;
|
||||
bool IsFadeTimeElapsed( int nSplitScreenSlot ) const;
|
||||
|
||||
Vector m_vecOrigin;
|
||||
|
||||
float m_minFalloff;
|
||||
float m_maxFalloff;
|
||||
float m_flFadeInDuration;
|
||||
float m_flFadeOutDuration;
|
||||
float m_flMaxWeight;
|
||||
float m_flCurWeight; // networked from server
|
||||
char m_netLookupFilename[MAX_PATH];
|
||||
|
||||
bool m_bEnabled; // networked from server
|
||||
bool m_bMaster;
|
||||
bool m_bClientSide;
|
||||
bool m_bExclusive;
|
||||
|
||||
bool m_bEnabledOnClient[MAX_SPLITSCREEN_PLAYERS];
|
||||
float m_flCurWeightOnClient[MAX_SPLITSCREEN_PLAYERS];
|
||||
bool m_bFadingIn[MAX_SPLITSCREEN_PLAYERS];
|
||||
float m_flFadeStartWeight[MAX_SPLITSCREEN_PLAYERS];
|
||||
float m_flFadeStartTime[MAX_SPLITSCREEN_PLAYERS];
|
||||
float m_flFadeDuration[MAX_SPLITSCREEN_PLAYERS];
|
||||
|
||||
ClientCCHandle_t m_CCHandle;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Color correction entity.
|
||||
//
|
||||
@ -8,8 +8,11 @@
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "materialsystem/MaterialSystemUtil.h"
|
||||
#include "materialsystem/materialsystemutil.h"
|
||||
#include "colorcorrectionmgr.h"
|
||||
#include "c_triggers.h"
|
||||
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@ -22,11 +25,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Shadow control entity
|
||||
//------------------------------------------------------------------------------
|
||||
class C_ColorCorrectionVolume : public C_BaseEntity
|
||||
class C_ColorCorrectionVolume : public C_BaseTrigger
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_ColorCorrectionVolume, C_BaseEntity );
|
||||
|
||||
DECLARE_CLASS( C_ColorCorrectionVolume, C_BaseTrigger );
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
|
||||
@ -36,9 +38,20 @@ public:
|
||||
void OnDataChanged(DataUpdateType_t updateType);
|
||||
bool ShouldDraw();
|
||||
|
||||
void ClientThink();
|
||||
void Update( C_BasePlayer *pPlayer, float ccScale );
|
||||
|
||||
void StartTouch( C_BaseEntity *pOther );
|
||||
void EndTouch( C_BaseEntity *pOther );
|
||||
|
||||
private:
|
||||
float m_LastEnterWeight;
|
||||
float m_LastEnterTime;
|
||||
|
||||
float m_LastExitWeight;
|
||||
float m_LastExitTime;
|
||||
bool m_bEnabled;
|
||||
float m_MaxWeight;
|
||||
float m_FadeDuration;
|
||||
float m_Weight;
|
||||
char m_lookupFilename[MAX_PATH];
|
||||
|
||||
@ -46,6 +59,9 @@ private:
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_ColorCorrectionVolume, DT_ColorCorrectionVolume, CColorCorrectionVolume)
|
||||
RecvPropBool( RECVINFO(m_bEnabled) ),
|
||||
RecvPropFloat( RECVINFO(m_MaxWeight) ),
|
||||
RecvPropFloat( RECVINFO(m_FadeDuration) ),
|
||||
RecvPropFloat( RECVINFO(m_Weight) ),
|
||||
RecvPropString( RECVINFO(m_lookupFilename) ),
|
||||
END_RECV_TABLE()
|
||||
@ -65,7 +81,7 @@ C_ColorCorrectionVolume::C_ColorCorrectionVolume()
|
||||
|
||||
C_ColorCorrectionVolume::~C_ColorCorrectionVolume()
|
||||
{
|
||||
g_pColorCorrectionMgr->RemoveColorCorrection( m_CCHandle );
|
||||
g_pColorCorrectionMgr->RemoveColorCorrectionVolume( this, m_CCHandle );
|
||||
}
|
||||
|
||||
|
||||
@ -82,11 +98,16 @@ void C_ColorCorrectionVolume::OnDataChanged(DataUpdateType_t updateType)
|
||||
{
|
||||
if ( m_CCHandle == INVALID_CLIENT_CCHANDLE )
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
Q_strncpy( filename, m_lookupFilename, MAX_PATH );
|
||||
// forming a unique name without extension
|
||||
char cleanName[MAX_PATH];
|
||||
V_StripExtension( m_lookupFilename, cleanName, sizeof( cleanName ) );
|
||||
char name[MAX_PATH];
|
||||
Q_snprintf( name, MAX_PATH, "%s_%d", cleanName, entindex() );
|
||||
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrection( filename );
|
||||
SetNextClientThink( ( m_CCHandle != INVALID_CLIENT_CCHANDLE ) ? CLIENT_THINK_ALWAYS : CLIENT_THINK_NEVER );
|
||||
m_CCHandle = g_pColorCorrectionMgr->AddColorCorrectionVolume( this, name, m_lookupFilename );
|
||||
|
||||
SetSolid( SOLID_BSP );
|
||||
SetSolidFlags( FSOLID_TRIGGER | FSOLID_NOT_SOLID );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,21 +120,85 @@ bool C_ColorCorrectionVolume::ShouldDraw()
|
||||
return false;
|
||||
}
|
||||
|
||||
void C_ColorCorrectionVolume::ClientThink()
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_ColorCorrectionVolume::StartTouch( CBaseEntity *pEntity )
|
||||
{
|
||||
Vector entityPosition = GetAbsOrigin();
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_Weight );
|
||||
m_LastEnterTime = gpGlobals->curtime;
|
||||
m_LastEnterWeight = m_Weight;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void C_ColorCorrectionVolume::EndTouch( CBaseEntity *pEntity )
|
||||
{
|
||||
m_LastExitTime = gpGlobals->curtime;
|
||||
m_LastExitWeight = m_Weight;
|
||||
}
|
||||
|
||||
|
||||
void C_ColorCorrectionVolume::Update( C_BasePlayer *pPlayer, float ccScale )
|
||||
{
|
||||
if ( pPlayer )
|
||||
{
|
||||
bool isTouching = CollisionProp()->IsPointInBounds( pPlayer->EyePosition() );
|
||||
bool wasTouching = m_LastEnterTime > m_LastExitTime;
|
||||
|
||||
if ( isTouching && !wasTouching )
|
||||
{
|
||||
StartTouch( pPlayer );
|
||||
}
|
||||
else if ( !isTouching && wasTouching )
|
||||
{
|
||||
EndTouch( pPlayer );
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_bEnabled )
|
||||
{
|
||||
m_Weight = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_LastEnterTime > m_LastExitTime )
|
||||
{
|
||||
// we most recently entered the volume
|
||||
|
||||
if( m_Weight < 1.0f )
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_LastEnterTime;
|
||||
float weight = m_LastEnterWeight + dt / ((1.0f-m_LastEnterWeight)*m_FadeDuration);
|
||||
if( weight>1.0f )
|
||||
weight = 1.0f;
|
||||
|
||||
m_Weight = weight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we most recently exitted the volume
|
||||
|
||||
if( m_Weight > 0.0f )
|
||||
{
|
||||
float dt = gpGlobals->curtime - m_LastExitTime;
|
||||
float weight = (1.0f-m_LastExitWeight) + dt / (m_LastExitWeight*m_FadeDuration);
|
||||
if( weight>1.0f )
|
||||
weight = 1.0f;
|
||||
|
||||
m_Weight = 1.0f - weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Vector entityPosition = GetAbsOrigin();
|
||||
g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_Weight * ccScale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateColorCorrectionVolumes( C_BasePlayer *pPlayer, float ccScale, C_ColorCorrectionVolume **pList, int listCount )
|
||||
{
|
||||
for ( int i = 0; i < listCount; i++ )
|
||||
{
|
||||
pList[i]->Update(pPlayer, ccScale);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Dynamic light
|
||||
//
|
||||
@ -9,7 +9,7 @@
|
||||
#include "cbase.h"
|
||||
#include "dlight.h"
|
||||
#include "iefx.h"
|
||||
#include "iviewrender.h"
|
||||
#include "IViewRender.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@ -152,9 +152,10 @@ void C_DynamicLight::ClientThink(void)
|
||||
m_pDynamicLight->flags = m_Flags;
|
||||
if ( m_OuterAngle > 0 )
|
||||
m_pDynamicLight->flags |= DLIGHT_NO_WORLD_ILLUMINATION;
|
||||
m_pDynamicLight->color.r = m_clrRender->r;
|
||||
m_pDynamicLight->color.g = m_clrRender->g;
|
||||
m_pDynamicLight->color.b = m_clrRender->b;
|
||||
color24 c = GetRenderColor();
|
||||
m_pDynamicLight->color.r = c.r;
|
||||
m_pDynamicLight->color.g = c.g;
|
||||
m_pDynamicLight->color.b = c.b;
|
||||
m_pDynamicLight->color.exponent = m_Exponent; // this makes it match the world
|
||||
m_pDynamicLight->origin = GetAbsOrigin();
|
||||
m_pDynamicLight->m_InnerAngle = m_InnerAngle;
|
||||
@ -210,9 +211,10 @@ void C_DynamicLight::ClientThink(void)
|
||||
m_pSpotlightEnd->flags = DLIGHT_NO_MODEL_ILLUMINATION | (m_Flags & DLIGHT_DISPLACEMENT_MASK);
|
||||
m_pSpotlightEnd->radius = m_SpotRadius; // * falloff;
|
||||
m_pSpotlightEnd->die = gpGlobals->curtime + 1e6;
|
||||
m_pSpotlightEnd->color.r = m_clrRender->r * falloff;
|
||||
m_pSpotlightEnd->color.g = m_clrRender->g * falloff;
|
||||
m_pSpotlightEnd->color.b = m_clrRender->b * falloff;
|
||||
color24 c = GetRenderColor();
|
||||
m_pSpotlightEnd->color.r = c.r * falloff;
|
||||
m_pSpotlightEnd->color.g = c.g * falloff;
|
||||
m_pSpotlightEnd->color.b = c.b * falloff;
|
||||
m_pSpotlightEnd->color.exponent = m_Exponent;
|
||||
|
||||
// For bumped lighting
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -10,9 +10,201 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cbase.h"
|
||||
#include "precipitation_shared.h"
|
||||
|
||||
// Draw rain effects.
|
||||
void DrawPrecipitation();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Precipitation particle type
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CPrecipitationParticle
|
||||
{
|
||||
public:
|
||||
Vector m_Pos;
|
||||
Vector m_Velocity;
|
||||
float m_SpawnTime; // Note: Tweak with this to change lifetime
|
||||
float m_Mass;
|
||||
float m_Ramp;
|
||||
|
||||
float m_flMaxLifetime;
|
||||
int m_nSplitScreenPlayerSlot;
|
||||
};
|
||||
|
||||
class CClient_Precipitation;
|
||||
static CUtlVector<CClient_Precipitation*> g_Precipitations;
|
||||
|
||||
//===========
|
||||
// Snow fall
|
||||
//===========
|
||||
class CSnowFallManager;
|
||||
static CSnowFallManager *s_pSnowFallMgr[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
bool SnowFallManagerCreate( CClient_Precipitation *pSnowEntity );
|
||||
void SnowFallManagerDestroy( void );
|
||||
|
||||
class AshDebrisEffect : public CSimpleEmitter
|
||||
{
|
||||
public:
|
||||
AshDebrisEffect( const char *pDebugName ) : CSimpleEmitter( pDebugName ) {}
|
||||
|
||||
static AshDebrisEffect* Create( const char *pDebugName );
|
||||
|
||||
virtual float UpdateAlpha( const SimpleParticle *pParticle );
|
||||
virtual float UpdateRoll( SimpleParticle *pParticle, float timeDelta );
|
||||
|
||||
private:
|
||||
AshDebrisEffect( const AshDebrisEffect & );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Precipitation blocker entity
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_PrecipitationBlocker : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_PrecipitationBlocker, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_PrecipitationBlocker();
|
||||
virtual ~C_PrecipitationBlocker();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Precipitation base entity
|
||||
//-----------------------------------------------------------------------------
|
||||
class CClient_Precipitation : public C_BaseEntity
|
||||
{
|
||||
class CPrecipitationEffect;
|
||||
friend class CClient_Precipitation::CPrecipitationEffect;
|
||||
|
||||
public:
|
||||
DECLARE_CLASS( CClient_Precipitation, C_BaseEntity );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
CClient_Precipitation();
|
||||
virtual ~CClient_Precipitation();
|
||||
|
||||
// Inherited from C_BaseEntity
|
||||
virtual void Precache( );
|
||||
virtual RenderableTranslucencyType_t ComputeTranslucencyType() { return RENDERABLE_IS_TRANSLUCENT; }
|
||||
|
||||
void Render();
|
||||
|
||||
// Computes where we're gonna emit
|
||||
bool ComputeEmissionArea( Vector& origin, Vector2D& size, C_BaseCombatCharacter *pCharacter );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Creates a single particle
|
||||
CPrecipitationParticle* CreateParticle();
|
||||
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void ClientThink();
|
||||
|
||||
void Simulate( float dt );
|
||||
|
||||
// Renders the particle
|
||||
void RenderParticle( CPrecipitationParticle* pParticle, CMeshBuilder &mb );
|
||||
|
||||
void CreateWaterSplashes();
|
||||
|
||||
// Emits the actual particles
|
||||
void EmitParticles( float fTimeDelta );
|
||||
|
||||
// Gets the tracer width and speed
|
||||
float GetWidth() const;
|
||||
float GetLength() const;
|
||||
float GetSpeed() const;
|
||||
|
||||
// Gets the remaining lifetime of the particle
|
||||
float GetRemainingLifetime( CPrecipitationParticle* pParticle ) const;
|
||||
|
||||
// Computes the wind vector
|
||||
static void ComputeWindVector( );
|
||||
|
||||
// simulation methods
|
||||
bool SimulateRain( CPrecipitationParticle* pParticle, float dt );
|
||||
bool SimulateSnow( CPrecipitationParticle* pParticle, float dt );
|
||||
|
||||
void CreateParticlePrecip( void );
|
||||
void InitializeParticlePrecip( void );
|
||||
void DispatchOuterParticlePrecip( int nSlot, C_BasePlayer *pPlayer, Vector vForward );
|
||||
void DispatchInnerParticlePrecip( int nSlot, C_BasePlayer *pPlayer, Vector vForward );
|
||||
void DestroyOuterParticlePrecip( int nSlot );
|
||||
void DestroyInnerParticlePrecip( int nSlot );
|
||||
|
||||
void UpdateParticlePrecip( C_BasePlayer *pPlayer, int nSlot );
|
||||
float GetDensity() { return m_flDensity; }
|
||||
|
||||
private:
|
||||
void CreateAshParticle( void );
|
||||
void CreateRainOrSnowParticle( const Vector &vSpawnPosition, const Vector &vEndPosition, const Vector &vVelocity ); // TERROR: adding end pos for lifetime calcs
|
||||
|
||||
// Information helpful in creating and rendering particles
|
||||
IMaterial *m_MatHandle; // material used
|
||||
|
||||
float m_Color[4]; // precip color
|
||||
float m_Lifetime; // Precip lifetime
|
||||
float m_InitialRamp; // Initial ramp value
|
||||
float m_Speed; // Precip speed
|
||||
float m_Width; // Tracer width
|
||||
float m_Remainder; // particles we should render next time
|
||||
PrecipitationType_t m_nPrecipType; // Precip type
|
||||
float m_flHalfScreenWidth; // Precalculated each frame.
|
||||
|
||||
float m_flDensity;
|
||||
|
||||
#ifdef INFESTED_DLL
|
||||
int m_nSnowDustAmount;
|
||||
#endif
|
||||
|
||||
// Some state used in rendering and simulation
|
||||
// Used to modify the rain density and wind from the console
|
||||
static ConVar s_raindensity;
|
||||
static ConVar s_rainwidth;
|
||||
static ConVar s_rainlength;
|
||||
static ConVar s_rainspeed;
|
||||
|
||||
static Vector s_WindVector; // Stores the wind speed vector
|
||||
|
||||
CUtlLinkedList<CPrecipitationParticle> m_Particles;
|
||||
CUtlVector<Vector> m_Splashes;
|
||||
|
||||
struct AshSplit_t
|
||||
{
|
||||
AshSplit_t() : m_bActiveAshEmitter( false ), m_vAshSpawnOrigin( 0, 0, 0 ), m_iAshCount( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
CSmartPtr<AshDebrisEffect> m_pAshEmitter;
|
||||
TimedEvent m_tAshParticleTimer;
|
||||
TimedEvent m_tAshParticleTraceTimer;
|
||||
bool m_bActiveAshEmitter;
|
||||
Vector m_vAshSpawnOrigin;
|
||||
|
||||
int m_iAshCount;
|
||||
};
|
||||
|
||||
protected:
|
||||
AshSplit_t m_Ash[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
|
||||
float m_flParticleInnerDist; //The distance at which to start drawing the inner system
|
||||
char *m_pParticleInnerNearDef; //Name of the first inner system
|
||||
char *m_pParticleInnerFarDef; //Name of the second inner system
|
||||
char *m_pParticleOuterDef; //Name of the outer system
|
||||
HPARTICLEFFECT m_pParticlePrecipInnerNear[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
HPARTICLEFFECT m_pParticlePrecipInnerFar[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
HPARTICLEFFECT m_pParticlePrecipOuter[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
TimedEvent m_tParticlePrecipTraceTimer[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
bool m_bActiveParticlePrecipEmitter[ MAX_SPLITSCREEN_PLAYERS ];
|
||||
bool m_bParticlePrecipInitialized;
|
||||
|
||||
private:
|
||||
CClient_Precipitation( const CClient_Precipitation & ); // not defined, not accessible
|
||||
};
|
||||
|
||||
|
||||
#endif // C_EFFECTS_H
|
||||
|
@ -1,13 +1,13 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "iviewrender.h"
|
||||
#include "IViewRender.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "bone_setup.h"
|
||||
@ -19,16 +19,16 @@
|
||||
#include "IEffects.h"
|
||||
#include "c_entitydissolve.h"
|
||||
#include "movevars_shared.h"
|
||||
#include "clienteffectprecachesystem.h"
|
||||
#include "precache_register.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectBuild )
|
||||
CLIENTEFFECT_MATERIAL( "effects/tesla_glow_noz" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/spark" )
|
||||
CLIENTEFFECT_MATERIAL( "effects/combinemuzzle2" )
|
||||
CLIENTEFFECT_REGISTER_END()
|
||||
PRECACHE_REGISTER_BEGIN( GLOBAL, PrecacheEffectBuild )
|
||||
PRECACHE( MATERIAL,"effects/tesla_glow_noz" )
|
||||
PRECACHE( MATERIAL,"effects/spark" )
|
||||
PRECACHE( MATERIAL,"effects/combinemuzzle2" )
|
||||
PRECACHE_REGISTER_END()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Networking
|
||||
@ -55,9 +55,8 @@ PMaterialHandle g_Material_AR2Glow = NULL;
|
||||
C_EntityDissolve::C_EntityDissolve( void )
|
||||
{
|
||||
m_bLinkedToServerEnt = true;
|
||||
m_pController = NULL;
|
||||
m_pController = false;
|
||||
m_bCoreExplode = false;
|
||||
m_vEffectColor = Vector( 255, 255, 255 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -112,7 +111,7 @@ IMotionEvent::simresult_e C_EntityDissolve::Simulate( IPhysicsMotionController *
|
||||
angular.Init();
|
||||
|
||||
// Make it zero g
|
||||
linear.z -= -1.02 * GetCurrentGravity();
|
||||
linear.z -= -1.02 * sv_gravity.GetFloat();
|
||||
|
||||
Vector vel;
|
||||
AngularImpulse angVel;
|
||||
@ -226,10 +225,12 @@ void C_EntityDissolve::BuildTeslaEffect( mstudiobbox_t *pHitBox, const matrix3x4
|
||||
{
|
||||
if ( !EffectOccluded( tr.endpos ) )
|
||||
{
|
||||
int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
|
||||
|
||||
// Move it towards the camera
|
||||
Vector vecFlash = tr.endpos;
|
||||
Vector vecForward;
|
||||
AngleVectors( MainViewAngles(), &vecForward );
|
||||
AngleVectors( MainViewAngles(nSlot), &vecForward );
|
||||
vecFlash -= (vecForward * 8);
|
||||
|
||||
g_pEffects->EnergySplash( vecFlash, -vecForward, false );
|
||||
@ -503,26 +504,16 @@ float C_EntityDissolve::GetModelFadeOutPercentage( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityDissolve::ClientThink( void )
|
||||
{
|
||||
C_BaseEntity *pEnt = GetMoveParent();
|
||||
if ( !pEnt )
|
||||
return;
|
||||
|
||||
bool bIsRagdoll;
|
||||
#ifdef TF_CLIENT_DLL
|
||||
bIsRagdoll = true;
|
||||
#else
|
||||
C_BaseAnimating *pAnimating = GetMoveParent() ? GetMoveParent()->GetBaseAnimating() : NULL;
|
||||
if (!pAnimating)
|
||||
return;
|
||||
bIsRagdoll = pAnimating->IsRagdoll();
|
||||
#endif
|
||||
|
||||
// NOTE: IsRagdoll means *client-side* ragdoll. We shouldn't be trying to fight
|
||||
// the server ragdoll (or any server physics) on the client
|
||||
if (( !m_pController ) && ( m_nDissolveType == ENTITY_DISSOLVE_NORMAL ) && bIsRagdoll )
|
||||
if (( !m_pController ) && ( m_nDissolveType == ENTITY_DISSOLVE_NORMAL ) && pAnimating->IsRagdoll())
|
||||
{
|
||||
IPhysicsObject *ppList[VPHYSICS_MAX_OBJECT_LIST_COUNT];
|
||||
int nCount = pEnt->VPhysicsGetObjectList( ppList, ARRAYSIZE(ppList) );
|
||||
int nCount = pAnimating->VPhysicsGetObjectList( ppList, ARRAYSIZE(ppList) );
|
||||
if ( nCount > 0 )
|
||||
{
|
||||
m_pController = physenv->CreateMotionController( this );
|
||||
@ -535,14 +526,13 @@ void C_EntityDissolve::ClientThink( void )
|
||||
|
||||
color32 color;
|
||||
|
||||
color.r = ( 1.0f - GetFadeInPercentage() ) * m_vEffectColor.x;
|
||||
color.g = ( 1.0f - GetFadeInPercentage() ) * m_vEffectColor.y;
|
||||
color.b = ( 1.0f - GetFadeInPercentage() ) * m_vEffectColor.z;
|
||||
color.r = color.g = color.b = ( 1.0f - GetFadeInPercentage() ) * 255.0f;
|
||||
color.a = GetModelFadeOutPercentage() * 255.0f;
|
||||
|
||||
// Setup the entity fade
|
||||
pEnt->SetRenderMode( kRenderTransColor );
|
||||
pEnt->SetRenderColor( color.r, color.g, color.b, color.a );
|
||||
pAnimating->SetRenderMode( kRenderTransColor );
|
||||
pAnimating->SetRenderColor( color.r, color.g, color.b );
|
||||
pAnimating->SetRenderAlpha( color.a );
|
||||
|
||||
if ( GetModelFadeOutPercentage() <= 0.2f )
|
||||
{
|
||||
@ -566,18 +556,12 @@ void C_EntityDissolve::ClientThink( void )
|
||||
{
|
||||
Release();
|
||||
|
||||
C_ClientRagdoll *pRagdoll = dynamic_cast <C_ClientRagdoll *> ( pEnt );
|
||||
C_ClientRagdoll *pRagdoll = dynamic_cast <C_ClientRagdoll *> ( pAnimating );
|
||||
|
||||
if ( pRagdoll )
|
||||
{
|
||||
pRagdoll->ReleaseRagdoll();
|
||||
}
|
||||
#ifdef TF_CLIENT_DLL
|
||||
else
|
||||
{
|
||||
pEnt->Release();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,7 +571,7 @@ void C_EntityDissolve::ClientThink( void )
|
||||
// Input : flags -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_EntityDissolve::DrawModel( int flags )
|
||||
int C_EntityDissolve::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
// See if we should draw
|
||||
if ( gpGlobals->frametime == 0 || m_bReadyToDraw == false )
|
||||
@ -660,7 +644,7 @@ int C_EntityDissolve::DrawModel( int flags )
|
||||
yDir = yvec;
|
||||
float yScale = VectorNormalize( yDir ) * 0.75f;
|
||||
|
||||
int numParticles = clamp( 3.0f * fadePerc, 0.f, 3.f );
|
||||
int numParticles = clamp( 3.0f * fadePerc, 0, 3 );
|
||||
|
||||
int iTempParts = 2;
|
||||
|
||||
@ -737,9 +721,9 @@ int C_EntityDissolve::DrawModel( int flags )
|
||||
|
||||
float alpha = 255;
|
||||
|
||||
sParticle->m_uchColor[0] = m_vEffectColor.x;
|
||||
sParticle->m_uchColor[1] = m_vEffectColor.y;
|
||||
sParticle->m_uchColor[2] = m_vEffectColor.z;
|
||||
sParticle->m_uchColor[0] = alpha;
|
||||
sParticle->m_uchColor[1] = alpha;
|
||||
sParticle->m_uchColor[2] = alpha;
|
||||
sParticle->m_uchStartAlpha = alpha;
|
||||
sParticle->m_uchEndAlpha = 0;
|
||||
sParticle->m_uchEndSize = 0;
|
||||
@ -765,9 +749,9 @@ int C_EntityDissolve::DrawModel( int flags )
|
||||
|
||||
float alpha = 255;
|
||||
|
||||
sParticle->m_uchColor[0] = m_vEffectColor.x;
|
||||
sParticle->m_uchColor[1] = m_vEffectColor.y;
|
||||
sParticle->m_uchColor[2] = m_vEffectColor.z;
|
||||
sParticle->m_uchColor[0] = alpha;
|
||||
sParticle->m_uchColor[1] = alpha;
|
||||
sParticle->m_uchColor[2] = alpha;
|
||||
sParticle->m_uchStartAlpha = alpha;
|
||||
sParticle->m_uchEndAlpha = 0;
|
||||
sParticle->m_uchEndSize = 0;
|
||||
|
@ -1,9 +1,9 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_ENTITY_DISSOLVE_H
|
||||
#define C_ENTITY_DISSOLVE_H
|
||||
@ -23,14 +23,11 @@ public:
|
||||
|
||||
// Inherited from C_BaseEntity
|
||||
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
|
||||
virtual int DrawModel( int flags );
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
virtual bool ShouldDraw() { return true; }
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void UpdateOnRemove( void );
|
||||
|
||||
virtual Vector GetEffectColor( void ) { return m_vEffectColor; }
|
||||
virtual void SetEffectColor( Vector v ) { m_vEffectColor = v; }
|
||||
|
||||
// Inherited from IMotionEvent
|
||||
virtual simresult_e Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular );
|
||||
|
||||
@ -50,8 +47,6 @@ public:
|
||||
int m_nDissolveType;
|
||||
float m_flNextSparkTime;
|
||||
|
||||
Vector m_vEffectColor;
|
||||
|
||||
Vector m_vDissolverOrigin;
|
||||
int m_nMagnitude;
|
||||
|
||||
|
156
game/client/c_entityflame.cpp
Normal file
156
game/client/c_entityflame.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "c_entityflame.h"
|
||||
#include "particle_property.h"
|
||||
#include "iefx.h"
|
||||
#include "dlight.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Datadesc
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_EntityFlame, DT_EntityFlame, CEntityFlame )
|
||||
RecvPropEHandle(RECVINFO(m_hEntAttached)),
|
||||
RecvPropBool(RECVINFO(m_bCheapEffect)),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_EntityFlame::C_EntityFlame( void ) : m_hEffect( NULL )
|
||||
{
|
||||
m_hOldAttached = NULL;
|
||||
AddToEntityList( ENTITY_LIST_SIMULATE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_EntityFlame::~C_EntityFlame( void )
|
||||
{
|
||||
StopEffect();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFlame::StopEffect( void )
|
||||
{
|
||||
if ( m_hEffect )
|
||||
{
|
||||
ParticleProp()->StopEmission( m_hEffect, true );
|
||||
m_hEffect = NULL;
|
||||
}
|
||||
|
||||
if ( m_hEntAttached )
|
||||
{
|
||||
m_hEntAttached->RemoveFlag( FL_ONFIRE );
|
||||
m_hEntAttached->SetEffectEntity( NULL );
|
||||
m_hEntAttached->StopSound( "General.BurningFlesh" );
|
||||
m_hEntAttached->StopSound( "General.BurningObject" );
|
||||
m_hEntAttached = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFlame::UpdateOnRemove( void )
|
||||
{
|
||||
StopEffect();
|
||||
BaseClass::UpdateOnRemove();
|
||||
}
|
||||
|
||||
void C_EntityFlame::CreateEffect( void )
|
||||
{
|
||||
if ( m_hEffect )
|
||||
{
|
||||
m_hOldAttached = m_hEntAttached;
|
||||
ParticleProp()->StopEmission( m_hEffect, true );
|
||||
m_hEffect = NULL;
|
||||
}
|
||||
|
||||
C_BaseEntity *pEntity = m_hEntAttached;
|
||||
if ( pEntity && !pEntity->IsAbleToHaveFireEffect() )
|
||||
return;
|
||||
|
||||
m_hEffect = ParticleProp()->Create( m_bCheapEffect ? "burning_gib_01" : "burning_character", PATTACH_ABSORIGIN_FOLLOW );
|
||||
if ( m_hEffect )
|
||||
{
|
||||
m_hOldAttached = m_hEntAttached;
|
||||
|
||||
ParticleProp()->AddControlPoint( m_hEffect, 1, pEntity, PATTACH_ABSORIGIN_FOLLOW );
|
||||
m_hEffect->SetControlPoint( 0, GetAbsOrigin() );
|
||||
m_hEffect->SetControlPoint( 1, GetAbsOrigin() );
|
||||
m_hEffect->SetControlPointEntity( 0, pEntity );
|
||||
m_hEffect->SetControlPointEntity( 1, pEntity );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFlame::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
CreateEffect();
|
||||
}
|
||||
|
||||
// FIXME: This is a bit of a shady path
|
||||
if ( updateType == DATA_UPDATE_DATATABLE_CHANGED )
|
||||
{
|
||||
// If our owner changed, then recreate the effect
|
||||
if ( m_hEntAttached != m_hOldAttached )
|
||||
{
|
||||
CreateEffect();
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_EntityFlame::Simulate( void )
|
||||
{
|
||||
if ( gpGlobals->frametime <= 0.0f )
|
||||
return true;
|
||||
|
||||
#ifdef HL2_EPISODIC
|
||||
if ( IsEffectActive(EF_BRIGHTLIGHT) || IsEffectActive(EF_DIMLIGHT) )
|
||||
{
|
||||
dlight_t *dl = effects->CL_AllocDlight( index );
|
||||
dl->origin = GetAbsOrigin();
|
||||
dl->origin[2] += 16;
|
||||
dl->color.r = 254;
|
||||
dl->color.g = 174;
|
||||
dl->color.b = 10;
|
||||
dl->radius = random->RandomFloat(400,431);
|
||||
dl->die = gpGlobals->curtime + 0.001;
|
||||
}
|
||||
|
||||
#endif // HL2_EPISODIC
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFlame::ClientThink( void )
|
||||
{
|
||||
StopEffect();
|
||||
Release();
|
||||
}
|
43
game/client/c_entityflame.h
Normal file
43
game/client/c_entityflame.h
Normal file
@ -0,0 +1,43 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
#ifndef C_ENTITY_FLAME_H
|
||||
#define C_ENTITY_FLAME_H
|
||||
|
||||
#include "c_baseentity.h"
|
||||
|
||||
//
|
||||
// Entity flame, client-side implementation
|
||||
//
|
||||
|
||||
class C_EntityFlame : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_CLASS( C_EntityFlame, C_BaseEntity );
|
||||
|
||||
C_EntityFlame( void );
|
||||
virtual ~C_EntityFlame( void );
|
||||
|
||||
virtual bool Simulate( void );
|
||||
virtual void UpdateOnRemove( void );
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
virtual void ClientThink( void );
|
||||
|
||||
EHANDLE m_hEntAttached; // The entity that we are burning (attached to).
|
||||
|
||||
private:
|
||||
void CreateEffect( void );
|
||||
void StopEffect( void );
|
||||
|
||||
CUtlReference<CNewParticleEffect> m_hEffect;
|
||||
EHANDLE m_hOldAttached;
|
||||
bool m_bCheapEffect;
|
||||
};
|
||||
|
||||
|
||||
#endif // C_ENTITY_FLAME_H
|
116
game/client/c_entityfreezing.cpp
Normal file
116
game/client/c_entityfreezing.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_entityfreezing.h"
|
||||
#include "studio.h"
|
||||
#include "bone_setup.h"
|
||||
#include "c_surfacerender.h"
|
||||
#include "engine/ivdebugoverlay.h"
|
||||
#include "dt_utlvector_recv.h"
|
||||
#include "debugoverlay_shared.h"
|
||||
#include "animation.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
ConVar cl_blobulator_freezing_max_metaball_radius( "cl_blobulator_freezing_max_metaball_radius",
|
||||
#ifdef INFESTED_DLL
|
||||
"25.0", // Don't need as much precision in Alien swarm because everything is zoomed out
|
||||
#else
|
||||
"12.0",
|
||||
#endif
|
||||
FCVAR_NONE, "Setting this can create more complex surfaces on large hitboxes at the cost of performance.", true, 12.0f, true, 100.0f );
|
||||
|
||||
|
||||
//PRECACHE_REGISTER_BEGIN( GLOBAL, PrecacheEffectFreezing )
|
||||
// PRECACHE( MATERIAL,"effects/tesla_glow_noz" )
|
||||
// PRECACHE( MATERIAL,"effects/spark" )
|
||||
// PRECACHE( MATERIAL,"effects/combinemuzzle2" )
|
||||
//PRECACHE_REGISTER_END()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Networking
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_EntityFreezing, DT_EntityFreezing, CEntityFreezing )
|
||||
RecvPropVector( RECVINFO(m_vFreezingOrigin) ),
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_flFrozenPerHitbox), RecvPropFloat( RECVINFO( m_flFrozenPerHitbox[0] ) ) ),
|
||||
RecvPropFloat( RECVINFO(m_flFrozen) ),
|
||||
RecvPropBool( RECVINFO(m_bFinishFreezing) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFreezing::GetRenderBounds( Vector& theMins, Vector& theMaxs )
|
||||
{
|
||||
if ( GetMoveParent() )
|
||||
{
|
||||
GetMoveParent()->GetRenderBounds( theMins, theMaxs );
|
||||
}
|
||||
else
|
||||
{
|
||||
theMins = GetAbsOrigin();
|
||||
theMaxs = theMaxs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Yes we bloody are
|
||||
//-----------------------------------------------------------------------------
|
||||
RenderableTranslucencyType_t C_EntityFreezing::ComputeTranslucencyType( )
|
||||
{
|
||||
return RENDERABLE_IS_TRANSLUCENT;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// On data changed
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFreezing::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EntityFreezing::ClientThink( void )
|
||||
{
|
||||
__asm nop;
|
||||
//C_BaseAnimating *pAnimating = GetMoveParent() ? GetMoveParent()->GetBaseAnimating() : NULL;
|
||||
//if (!pAnimating)
|
||||
// return;
|
||||
|
||||
//color32 color = pAnimating->GetRenderColor();
|
||||
|
||||
//color.r = color.g = ( 1.0f - m_flFrozen ) * 255.0f;
|
||||
|
||||
//// Setup the entity fade
|
||||
//pAnimating->SetRenderMode( kRenderTransColor );
|
||||
//pAnimating->SetRenderColor( color.r, color.g, color.b, color.a );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : flags -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_EntityFreezing::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
47
game/client/c_entityfreezing.h
Normal file
47
game/client/c_entityfreezing.h
Normal file
@ -0,0 +1,47 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef C_ENTITY_FREEZING_H
|
||||
#define C_ENTITY_FREEZING_H
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
|
||||
struct EntityFreezingHitboxBlobData_t
|
||||
{
|
||||
CUtlVector<Vector> m_vPoints;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Entity Dissolve, client-side implementation
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_EntityFreezing : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_CLASS( C_EntityFreezing, C_BaseEntity );
|
||||
|
||||
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
|
||||
virtual RenderableTranslucencyType_t ComputeTranslucencyType( );
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance );
|
||||
virtual bool ShouldDraw() { return true; }
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
void ClientThink( void );
|
||||
|
||||
private:
|
||||
Vector m_vFreezingOrigin;
|
||||
float m_flFrozenPerHitbox[ 50 ];
|
||||
float m_flFrozen;
|
||||
bool m_bFinishFreezing;
|
||||
|
||||
CUtlVector<EntityFreezingHitboxBlobData_t> m_HitboxBlobData;
|
||||
};
|
||||
|
||||
#endif // C_ENTITY_FREEZING_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
95
game/client/c_env_ambient_light.cpp
Normal file
95
game/client/c_env_ambient_light.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Ambient light controller entity with simple radial falloff
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_spatialentity.h"
|
||||
#include "spatialentitymgr.h"
|
||||
#include "c_env_ambient_light.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
static ConVar cl_ambient_light_disableentities( "cl_ambient_light_disableentities", "0", FCVAR_NONE, "Disable map ambient light entities." );
|
||||
|
||||
|
||||
static CSpatialEntityMgr s_EnvAmbientLightMgr;
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_EnvAmbientLight, DT_EnvAmbientLight, CEnvAmbientLight )
|
||||
RecvPropVector( RECVINFO_NAME( m_Value, m_vecColor ) ),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
void C_EnvAmbientLight::ApplyAccumulation( void )
|
||||
{
|
||||
Vector rgbVal = BlendedValue();
|
||||
|
||||
static ConVarRef mat_ambient_light_r( "mat_ambient_light_r" );
|
||||
static ConVarRef mat_ambient_light_g( "mat_ambient_light_g" );
|
||||
static ConVarRef mat_ambient_light_b( "mat_ambient_light_b" );
|
||||
|
||||
if ( mat_ambient_light_r.IsValid() )
|
||||
{
|
||||
mat_ambient_light_r.SetValue( rgbVal.x );
|
||||
}
|
||||
|
||||
if ( mat_ambient_light_g.IsValid() )
|
||||
{
|
||||
mat_ambient_light_g.SetValue( rgbVal.y );
|
||||
}
|
||||
|
||||
if ( mat_ambient_light_b.IsValid() )
|
||||
{
|
||||
mat_ambient_light_b.SetValue( rgbVal.z );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void C_EnvAmbientLight::AddToPersonalSpatialEntityMgr( void )
|
||||
{
|
||||
s_EnvAmbientLightMgr.AddSpatialEntity( this );
|
||||
}
|
||||
|
||||
void C_EnvAmbientLight::RemoveFromPersonalSpatialEntityMgr( void )
|
||||
{
|
||||
s_EnvAmbientLightMgr.RemoveSpatialEntity( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void C_EnvAmbientLight::SetColor( const Vector &vecColor, float flLerpTime )
|
||||
{
|
||||
if ( flLerpTime <= 0 )
|
||||
{
|
||||
m_Value = vecColor / 255.0f;
|
||||
m_colorTimer.Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
m_vecStartColor = m_Value;
|
||||
m_vecTargetColor = vecColor / 255.0f;
|
||||
m_colorTimer.Start( flLerpTime );
|
||||
}
|
||||
|
||||
void C_EnvAmbientLight::ClientThink( void )
|
||||
{
|
||||
BaseClass::ClientThink();
|
||||
|
||||
if ( m_colorTimer.HasStarted() )
|
||||
{
|
||||
if ( m_colorTimer.IsElapsed() )
|
||||
{
|
||||
m_Value = m_vecTargetColor;
|
||||
m_colorTimer.Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = m_vecTargetColor - ( m_vecTargetColor - m_vecStartColor ) * m_colorTimer.GetRemainingRatio();
|
||||
}
|
||||
}
|
||||
}
|
30
game/client/c_env_ambient_light.h
Normal file
30
game/client/c_env_ambient_light.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef _INCLUDED_C_ENV_AMBIENT_LIGHT_H
|
||||
#define _INCLUDED_C_ENV_AMBIENT_LIGHT_H
|
||||
|
||||
#include "c_spatialentity.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Ambient light controller entity with radial falloff
|
||||
//------------------------------------------------------------------------------
|
||||
class C_EnvAmbientLight : public C_SpatialEntityTemplate<Vector>
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_EnvAmbientLight, C_SpatialEntityTemplate<Vector> );
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual void ApplyAccumulation( void );
|
||||
virtual void ClientThink( void );
|
||||
|
||||
void SetColor( const Vector &vecColor, float flLerpTime = 0 );
|
||||
Vector GetTargetColor() { return m_vecTargetColor * 255.0f; }
|
||||
|
||||
protected:
|
||||
virtual void AddToPersonalSpatialEntityMgr( void );
|
||||
virtual void RemoveFromPersonalSpatialEntityMgr( void );
|
||||
|
||||
Vector m_vecStartColor;
|
||||
Vector m_vecTargetColor;
|
||||
CountdownTimer m_colorTimer;
|
||||
};
|
||||
|
||||
#endif // _INCLUDED_C_ENV_AMBIENT_LIGHT_H
|
100
game/client/c_env_dof_controller.cpp
Normal file
100
game/client/c_env_dof_controller.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
// NOTE: This has to be the last file included!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern bool g_bDOFEnabled;
|
||||
extern float g_flDOFNearBlurDepth;
|
||||
extern float g_flDOFNearFocusDepth;
|
||||
extern float g_flDOFFarFocusDepth;
|
||||
extern float g_flDOFFarBlurDepth;
|
||||
extern float g_flDOFNearBlurRadius;
|
||||
extern float g_flDOFFarBlurRadius;
|
||||
|
||||
EHANDLE g_hDOFControllerInUse = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class C_EnvDOFController : public C_BaseEntity
|
||||
{
|
||||
DECLARE_CLASS( C_EnvDOFController, C_BaseEntity );
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
C_EnvDOFController();
|
||||
~C_EnvDOFController();
|
||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||
|
||||
private:
|
||||
bool m_bDOFEnabled;
|
||||
float m_flNearBlurDepth;
|
||||
float m_flNearFocusDepth;
|
||||
float m_flFarFocusDepth;
|
||||
float m_flFarBlurDepth;
|
||||
float m_flNearBlurRadius;
|
||||
float m_flFarBlurRadius;
|
||||
|
||||
private:
|
||||
C_EnvDOFController( const C_EnvDOFController & );
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT( C_EnvDOFController, DT_EnvDOFController, CEnvDOFController )
|
||||
RecvPropInt( RECVINFO(m_bDOFEnabled) ),
|
||||
RecvPropFloat( RECVINFO(m_flNearBlurDepth) ),
|
||||
RecvPropFloat( RECVINFO(m_flNearFocusDepth) ),
|
||||
RecvPropFloat( RECVINFO(m_flFarFocusDepth) ),
|
||||
RecvPropFloat( RECVINFO(m_flFarBlurDepth) ),
|
||||
RecvPropFloat( RECVINFO(m_flNearBlurRadius) ),
|
||||
RecvPropFloat( RECVINFO(m_flFarBlurRadius) )
|
||||
END_RECV_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_EnvDOFController::C_EnvDOFController( void )
|
||||
: m_bDOFEnabled( true ),
|
||||
m_flNearBlurDepth( 50.0f ),
|
||||
m_flNearFocusDepth( 100.0f ),
|
||||
m_flFarFocusDepth( 250.0f ),
|
||||
m_flFarBlurDepth( 1000.0f ),
|
||||
m_flNearBlurRadius( 0.0f ), // no near blur by default
|
||||
m_flFarBlurRadius( 5.0f )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
C_EnvDOFController::~C_EnvDOFController( void )
|
||||
{
|
||||
if ( g_hDOFControllerInUse == this )
|
||||
{
|
||||
g_bDOFEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_EnvDOFController::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
g_bDOFEnabled = m_bDOFEnabled && ( ( m_flNearBlurRadius > 0.0f ) || ( m_flFarBlurRadius > 0.0f ) );
|
||||
g_flDOFNearBlurDepth = m_flNearBlurDepth;
|
||||
g_flDOFNearFocusDepth = m_flNearFocusDepth;
|
||||
g_flDOFFarFocusDepth = m_flFarFocusDepth;
|
||||
g_flDOFFarBlurDepth = m_flFarBlurDepth;
|
||||
g_flDOFNearBlurRadius = m_flNearBlurRadius;
|
||||
g_flDOFFarBlurRadius = m_flFarBlurRadius;
|
||||
|
||||
g_hDOFControllerInUse = this;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2007, Valve Corporation, All rights reserved. ====
|
||||
//
|
||||
// An entity that allows level designer control over the fog parameters.
|
||||
//
|
||||
@ -20,19 +20,21 @@ BEGIN_NETWORK_TABLE_NOBASE( CFogController, DT_FogController )
|
||||
RecvPropInt( RECVINFO( m_fog.enable ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.blend ) ),
|
||||
RecvPropVector( RECVINFO( m_fog.dirPrimary ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorPrimary ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorSecondary ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorPrimary ), 0, RecvProxy_Int32ToColor32 ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorSecondary ), 0, RecvProxy_Int32ToColor32 ),
|
||||
RecvPropFloat( RECVINFO( m_fog.start ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.end ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.farz ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.maxdensity ) ),
|
||||
|
||||
RecvPropInt( RECVINFO( m_fog.colorPrimaryLerpTo ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorSecondaryLerpTo ) ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorPrimaryLerpTo ), 0, RecvProxy_Int32ToColor32 ),
|
||||
RecvPropInt( RECVINFO( m_fog.colorSecondaryLerpTo ), 0, RecvProxy_Int32ToColor32 ),
|
||||
RecvPropFloat( RECVINFO( m_fog.startLerpTo ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.endLerpTo ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.maxdensityLerpTo ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.lerptime ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.duration ) ),
|
||||
RecvPropFloat( RECVINFO( m_fog.HDRColorScale ) ),
|
||||
END_NETWORK_TABLE()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -43,4 +45,5 @@ C_FogController::C_FogController()
|
||||
// Make sure that old maps without fog fields don't get wacked out fog values.
|
||||
m_fog.enable = false;
|
||||
m_fog.maxdensity = 1.0f;
|
||||
m_fog.HDRColorScale = 1.0f;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
|
248
game/client/c_env_global_light.cpp
Normal file
248
game/client/c_env_global_light.cpp
Normal file
@ -0,0 +1,248 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Sunlight shadow control entity.
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
|
||||
#include "c_baseplayer.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
extern ConVar cl_sunlight_ortho_size;
|
||||
extern ConVar cl_sunlight_depthbias;
|
||||
|
||||
ConVar cl_globallight_freeze( "cl_globallight_freeze", "0" );
|
||||
ConVar cl_globallight_xoffset( "cl_globallight_xoffset", "-800" );
|
||||
ConVar cl_globallight_yoffset( "cl_globallight_yoffset", "1600" );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose : Sunlights shadow control entity
|
||||
//------------------------------------------------------------------------------
|
||||
class C_GlobalLight : public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( C_GlobalLight, C_BaseEntity );
|
||||
|
||||
DECLARE_CLIENTCLASS();
|
||||
|
||||
virtual ~C_GlobalLight();
|
||||
|
||||
void OnDataChanged( DataUpdateType_t updateType );
|
||||
void Spawn();
|
||||
bool ShouldDraw();
|
||||
|
||||
void ClientThink();
|
||||
|
||||
private:
|
||||
Vector m_shadowDirection;
|
||||
bool m_bEnabled;
|
||||
char m_TextureName[ MAX_PATH ];
|
||||
CTextureReference m_SpotlightTexture;
|
||||
color32 m_LightColor;
|
||||
Vector m_CurrentLinearFloatLightColor;
|
||||
float m_flCurrentLinearFloatLightAlpha;
|
||||
float m_flColorTransitionTime;
|
||||
float m_flSunDistance;
|
||||
float m_flFOV;
|
||||
float m_flNearZ;
|
||||
float m_flNorthOffset;
|
||||
bool m_bEnableShadows;
|
||||
bool m_bOldEnableShadows;
|
||||
|
||||
static ClientShadowHandle_t m_LocalFlashlightHandle;
|
||||
};
|
||||
|
||||
|
||||
ClientShadowHandle_t C_GlobalLight::m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_GlobalLight, DT_GlobalLight, CGlobalLight)
|
||||
RecvPropVector(RECVINFO(m_shadowDirection)),
|
||||
RecvPropBool(RECVINFO(m_bEnabled)),
|
||||
RecvPropString(RECVINFO(m_TextureName)),
|
||||
RecvPropInt(RECVINFO(m_LightColor), 0, RecvProxy_Int32ToColor32),
|
||||
RecvPropFloat(RECVINFO(m_flColorTransitionTime)),
|
||||
RecvPropFloat(RECVINFO(m_flSunDistance)),
|
||||
RecvPropFloat(RECVINFO(m_flFOV)),
|
||||
RecvPropFloat(RECVINFO(m_flNearZ)),
|
||||
RecvPropFloat(RECVINFO(m_flNorthOffset)),
|
||||
RecvPropBool(RECVINFO(m_bEnableShadows)),
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
||||
C_GlobalLight::~C_GlobalLight()
|
||||
{
|
||||
if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||
{
|
||||
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
void C_GlobalLight::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
if ( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
m_SpotlightTexture.Init( m_TextureName, TEXTURE_GROUP_OTHER, true );
|
||||
}
|
||||
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
}
|
||||
|
||||
void C_GlobalLight::Spawn()
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
|
||||
m_bOldEnableShadows = m_bEnableShadows;
|
||||
|
||||
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// We don't draw...
|
||||
//------------------------------------------------------------------------------
|
||||
bool C_GlobalLight::ShouldDraw()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void C_GlobalLight::ClientThink()
|
||||
{
|
||||
VPROF("C_GlobalLight::ClientThink");
|
||||
|
||||
bool bSupressWorldLights = false;
|
||||
|
||||
if ( cl_globallight_freeze.GetBool() == true )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_bEnabled )
|
||||
{
|
||||
Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b );
|
||||
float flLinearFloatLightAlpha = m_LightColor.a;
|
||||
|
||||
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha )
|
||||
{
|
||||
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
|
||||
|
||||
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
|
||||
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
|
||||
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
|
||||
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
|
||||
}
|
||||
|
||||
FlashlightState_t state;
|
||||
|
||||
Vector vDirection = m_shadowDirection;
|
||||
VectorNormalize( vDirection );
|
||||
|
||||
//Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f );
|
||||
Vector vSunDirection2D = vDirection;
|
||||
vSunDirection2D.z = 0.0f;
|
||||
|
||||
HACK_GETLOCALPLAYER_GUARD( "C_GlobalLight::ClientThink" );
|
||||
|
||||
if ( !C_BasePlayer::GetLocalPlayer() )
|
||||
return;
|
||||
|
||||
Vector vPos;
|
||||
QAngle EyeAngles;
|
||||
float flZNear, flZFar, flFov;
|
||||
|
||||
C_BasePlayer::GetLocalPlayer()->CalcView( vPos, EyeAngles, flZNear, flZFar, flFov );
|
||||
// Vector vPos = C_BasePlayer::GetLocalPlayer()->GetAbsOrigin();
|
||||
|
||||
// vPos = Vector( 0.0f, 0.0f, 500.0f );
|
||||
vPos = ( vPos + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance;
|
||||
vPos += Vector( cl_globallight_xoffset.GetFloat(), cl_globallight_yoffset.GetFloat(), 0.0f );
|
||||
|
||||
QAngle angAngles;
|
||||
VectorAngles( vDirection, angAngles );
|
||||
|
||||
Vector vForward, vRight, vUp;
|
||||
AngleVectors( angAngles, &vForward, &vRight, &vUp );
|
||||
|
||||
state.m_fHorizontalFOVDegrees = m_flFOV;
|
||||
state.m_fVerticalFOVDegrees = m_flFOV;
|
||||
|
||||
state.m_vecLightOrigin = vPos;
|
||||
BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation );
|
||||
|
||||
state.m_fQuadraticAtten = 0.0f;
|
||||
state.m_fLinearAtten = m_flSunDistance * 2.0f;
|
||||
state.m_fConstantAtten = 0.0f;
|
||||
state.m_FarZAtten = m_flSunDistance * 2.0f;
|
||||
state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||
state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||
state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||
state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient;
|
||||
state.m_NearZ = 4.0f;
|
||||
state.m_FarZ = m_flSunDistance * 2.0f;
|
||||
state.m_fBrightnessScale = 2.0f;
|
||||
state.m_bGlobalLight = true;
|
||||
|
||||
float flOrthoSize = 1000.0f;
|
||||
|
||||
if ( flOrthoSize > 0 )
|
||||
{
|
||||
state.m_bOrtho = true;
|
||||
state.m_fOrthoLeft = -flOrthoSize;
|
||||
state.m_fOrthoTop = -flOrthoSize;
|
||||
state.m_fOrthoRight = flOrthoSize;
|
||||
state.m_fOrthoBottom = flOrthoSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.m_bOrtho = false;
|
||||
}
|
||||
|
||||
state.m_bDrawShadowFrustum = true;
|
||||
state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias();;
|
||||
state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias();
|
||||
state.m_bEnableShadows = m_bEnableShadows;
|
||||
state.m_pSpotlightTexture = m_SpotlightTexture;
|
||||
state.m_pProjectedMaterial = NULL; // don't complain cause we aren't using simple projection in this class
|
||||
state.m_nSpotlightTextureFrame = 0;
|
||||
|
||||
state.m_nShadowQuality = 1; // Allow entity to affect shadow quality
|
||||
// state.m_bShadowHighRes = true;
|
||||
|
||||
if ( m_bOldEnableShadows != m_bEnableShadows )
|
||||
{
|
||||
// If they change the shadow enable/disable, we need to make a new handle
|
||||
if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||
{
|
||||
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
m_bOldEnableShadows = m_bEnableShadows;
|
||||
}
|
||||
|
||||
if( m_LocalFlashlightHandle == CLIENTSHADOW_INVALID_HANDLE )
|
||||
{
|
||||
m_LocalFlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pClientShadowMgr->UpdateFlashlightState( m_LocalFlashlightHandle, state );
|
||||
g_pClientShadowMgr->UpdateProjectedTexture( m_LocalFlashlightHandle, true );
|
||||
}
|
||||
|
||||
bSupressWorldLights = m_bEnableShadows;
|
||||
}
|
||||
else if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||
{
|
||||
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
g_pClientShadowMgr->SetShadowFromWorldLightsEnabled( !bSupressWorldLights );
|
||||
|
||||
BaseClass::ClientThink();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -41,8 +41,7 @@ public:
|
||||
// NOTE: Ths enclosed particle effect binding will do all the drawing
|
||||
// But we have to return true, unlike other particle systems, for the animation events to work
|
||||
virtual bool ShouldDraw() { return true; }
|
||||
virtual int DrawModel( int flags ) { return 0; }
|
||||
virtual int GetFxBlend( void ) { return 0; }
|
||||
virtual int DrawModel( int flags, const RenderableInstance_t &instance ) { return 0; }
|
||||
|
||||
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||
virtual void OnPreDataChanged( DataUpdateType_t updateType );
|
||||
@ -107,9 +106,10 @@ void C_EnvParticleScript::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
if(updateType == DATA_UPDATE_CREATED)
|
||||
if( updateType == DATA_UPDATE_CREATED )
|
||||
{
|
||||
ParticleMgr()->AddEffect( &m_ParticleEffect, this );
|
||||
g_pClientLeafSystem->EnableRendering( RenderHandle(), false );
|
||||
}
|
||||
|
||||
if ( m_nOldSequence != GetSequence() )
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user