initial
This commit is contained in:
66
public/demo_polish/demo_polish.h
Normal file
66
public/demo_polish/demo_polish.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef DEMO_POLISH_H
|
||||
#define DEMO_POLISH_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "demo_polish/demo_polish_recorder.h"
|
||||
#include "demo_polish/demo_polish_controller.h"
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool IsDemoPolishEnabled();
|
||||
bool IsDemoPolishRecording();
|
||||
bool IsDemoPolishPlaying();
|
||||
|
||||
bool DemoPolish_ShouldReplaceRoot( int iEntIndex );
|
||||
|
||||
void DemoPolish_Think();
|
||||
|
||||
CDemoPolishRecorder& DemoPolish_GetRecorder();
|
||||
CDemoPolishController& DemoPolish_GetController();
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern ConVar demo_polish_auto_polish;
|
||||
extern ConVar demo_polish_bone_test_index;
|
||||
extern ConVar demo_polish_root_adjustments_enabled;
|
||||
extern ConVar demo_polish_global_adjustments_enabled;
|
||||
extern ConVar demo_polish_local_adjustments_enabled;
|
||||
extern ConVar demo_polish_bone_overrides_enabled;
|
||||
extern ConVar demo_polish_leaning_enabled;
|
||||
extern ConVar demo_polish_leaning_strafe_kneebend_enabled;
|
||||
extern ConVar demo_polish_ik_enabled;
|
||||
extern ConVar demo_polish_draw_path_enabled;
|
||||
extern ConVar demo_polish_step_in_place_enabled;
|
||||
extern ConVar demo_polish_pelvis_noise_enabled;
|
||||
extern ConVar demo_polish_terrain_adjust_enabled;
|
||||
extern ConVar demo_polish_foot_plants_enabled;
|
||||
extern ConVar demo_polish_draw_skeleton;
|
||||
extern ConVar demo_polish_draw_prev_skeleton_frames;
|
||||
extern ConVar demo_polish_draw_next_skeleton_frames;
|
||||
extern ConVar demo_polish_path_frames; // # of path frames to draw before/after current frame
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// One day this could go in a math library - this is very similar to FLerp() except it does a bounds check and the params
|
||||
// are in a different order.
|
||||
//
|
||||
inline float LerpScale( float flInLo, float flInHi, float flOutLo, float flOutHi, float flX )
|
||||
{
|
||||
float const tt = MIN( 1, MAX( 0, (flX - flInLo) / (flInHi - flInLo) ) );
|
||||
return Lerp(tt, flOutLo, flOutHi);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif // DEMO_POLISH_H
|
||||
49
public/demo_polish/demo_polish_consts.h
Normal file
49
public/demo_polish/demo_polish_consts.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_DEMO_POLISH_CONSTS_H
|
||||
#define C_DEMO_POLISH_CONSTS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define kMaxPlayersSupported 4
|
||||
#define MAX_STR 256
|
||||
#define DEMO_POLISH_DIR "demo_polish"
|
||||
#define DEMO_POLISH_DIR_FILTERED "filtered"
|
||||
#define DEMO_POLISH_DIR_RAW "raw"
|
||||
#define DEMO_POLISH_HEADER_NAME "header.bin"
|
||||
#define DEMO_POLISH_CFG_FILENAME "demo_polish_settings.cfg"
|
||||
#define SERIALIZE_POLISH_FILES_AS_TEXT false
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxBones = 128, // Same as MAXSTUDIOBONES -- including "studio.h" here would be painful
|
||||
kMaxOverlays = 16 ,
|
||||
};
|
||||
|
||||
enum ESide
|
||||
{
|
||||
kInvalidSide = -1,
|
||||
kLeft,
|
||||
kRight
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
inline ESide GetOppositeSide(ESide iSide)
|
||||
{
|
||||
Assert( !iSide == (iSide == kLeft ? kRight : kLeft) );
|
||||
return (ESide)(!(int)iSide);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
120
public/demo_polish/demo_polish_controller.h
Normal file
120
public/demo_polish/demo_polish_controller.h
Normal file
@@ -0,0 +1,120 @@
|
||||
//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef DEMO_POLISH_CONTROLLER_H
|
||||
#define DEMO_POLISH_CONTROLLER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "demo_polish/demo_polish_consts.h"
|
||||
//#include "locator.h"
|
||||
#include "../game/shared/Multiplayer/multiplayer_animstate.h"
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CBonePolishData;
|
||||
class CDemoPolishFile;
|
||||
class C_BaseAnimating;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CHeaderFile;
|
||||
class CBoneBitList;
|
||||
class CFinalDemoPolishFile;
|
||||
class FinalPolishElementData;
|
||||
class CBonePath;
|
||||
class CPathManager;
|
||||
class CDemoPolishEventQueue;
|
||||
class CLowerBodyController;
|
||||
class CDemoPolishConfig;
|
||||
class CDemoPolishPanel;
|
||||
class ISequenceAnalyzer;
|
||||
|
||||
class CDemoPolishController
|
||||
{
|
||||
public:
|
||||
static CDemoPolishController& Instance();
|
||||
|
||||
bool Init( char const* pDemoBaseName );
|
||||
void Think( float flPlaybackTime );
|
||||
bool Shutdown();
|
||||
|
||||
bool IsInitialized() const { return m_bLateInit; }
|
||||
bool IsEntityRegistered( int iEntIndex ) const;
|
||||
|
||||
void RefreshEvents();
|
||||
|
||||
int GetSequenceOverride( int iPlayerEntIndex, float flCurrentDemoTime );
|
||||
void MakeGlobalAdjustments( int iPlayerEntIndex, CStudioHdr const* pStudioHdr, int& iBoneMask, CBoneAccessor& boneAccessor );
|
||||
void MakeLocalAdjustments( int iPlayerEntIndex, CStudioHdr const* pStudioHdr, int& iBoneMask, Vector* pPositions,
|
||||
Quaternion* pRotations, CBoneBitList& boneComputed );
|
||||
|
||||
void DrawUnpolishedSkeleton( int iPlayerEntIndex, CStudioHdr const* pStudioHdr );
|
||||
void DrawUnpolishedSkeleton( int iPlayerLookupIndex, CStudioHdr const* pStudioHdr, CBonePath const* pBonePath, int iDrawFrame, float s, int r, int g, int b );
|
||||
|
||||
float GetAdjustedPlaybackTime() const;
|
||||
float GetElapsed() const;
|
||||
|
||||
QAngle& GetRenderAngles( int iPlayerEntIndex ) const;
|
||||
Vector& GetRenderOrigin( int iPlayerEntIndex ) const;
|
||||
|
||||
void UpdatePlayerAnimState( int iPlayerEntIndex, PlayerAnimEvent_t iEvent );
|
||||
|
||||
public:
|
||||
bool m_bInit;
|
||||
|
||||
private:
|
||||
friend class CDemoPolishRecorder;
|
||||
|
||||
CDemoPolishController();
|
||||
~CDemoPolishController();
|
||||
|
||||
void MakeRootAdjustments( int iPlayerLookupIndex, Vector& pos, Quaternion& rot );
|
||||
void ReloadDemoPolishConfig();
|
||||
bool InitPanel();
|
||||
void DispatchEvents( int iPlayerLookupIndex, float flCurrentDemoTime );
|
||||
bool ReadEventData( int iPlayerLookupIndex );
|
||||
bool AnalyzeDataForEvents( int iPlayerLookupIndex, int iStartFrame = 0 );
|
||||
int GetLookupIndexFromEntIndex( int iPlayerEntIndex ) const;
|
||||
int GetEntIndexFromLookupIndex( int iPlayerLookupIndex ) const;
|
||||
void AddNewLeaningStartEvent( int iPlayerLookupIndex, float flStartTime, float flLeanDir, bool bStrafe );
|
||||
void AddNewLeaningStopEvent( int iPlayerLookupIndex, float flStopTime, float flLeanDir, bool bStrafe );
|
||||
|
||||
CUtlVector< CDemoPolishFile* > m_vFiles;
|
||||
|
||||
int m_iNumPlayerFiles;
|
||||
|
||||
public:
|
||||
CBonePath** m_pBonePaths;
|
||||
CPathManager* m_pPathManager;
|
||||
CHeaderFile* m_pHeader;
|
||||
CDemoPolishEventQueue** m_pEventQueues; // TODO: One queue per player (as of now this is implemented as one queue for one player)
|
||||
CLowerBodyController** m_pLowerBodyControllers;
|
||||
CDemoPolishConfig* m_pDemoPolishConfig;
|
||||
ISequenceAnalyzer** m_pSequenceAnalyzers;
|
||||
|
||||
mutable Vector m_renderOrigins[kMaxPlayersSupported];
|
||||
mutable QAngle m_renderAngles[kMaxPlayersSupported];
|
||||
|
||||
private:
|
||||
float m_flLastTime;
|
||||
float m_flElapsed;
|
||||
Vector m_noisePt;
|
||||
|
||||
bool LateInit();
|
||||
bool m_bLateInit;
|
||||
|
||||
CDemoPolishPanel* m_pDemoPolishPanel;
|
||||
|
||||
CThreadFastMutex m_mutex;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif // DEMO_POLISH_CONTROLLER_H
|
||||
91
public/demo_polish/demo_polish_recorder.h
Normal file
91
public/demo_polish/demo_polish_recorder.h
Normal file
@@ -0,0 +1,91 @@
|
||||
//===== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef C_DEMO_POLISH_RECORDER_H
|
||||
#define C_DEMO_POLISH_RECORDER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class CUserCmd;
|
||||
class CIntDemoPolishFile;
|
||||
class CFinalDemoPolishFile;
|
||||
class FinalPolishElementData;
|
||||
class CPathManager;
|
||||
class CBonePolishData;
|
||||
class CIntDemoPolishFile;
|
||||
class CAnimDataFile;
|
||||
class CDemoPolishFile;
|
||||
class CUserInputDataFile;
|
||||
class CHeadingDataFile;
|
||||
class CHeadingData;
|
||||
class CBoneAccessor;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Records to intermediate polish files. These files are then analyzed (on shutdown)
|
||||
// and converted into a final set of polish data, which can be interpreted during demo
|
||||
// playback.
|
||||
//
|
||||
class CDemoPolishRecorder
|
||||
{
|
||||
public:
|
||||
static CDemoPolishRecorder& Instance();
|
||||
|
||||
bool Init( char const* pDemoBaseFileName );
|
||||
bool Shutdown();
|
||||
|
||||
void Think( float flTime );
|
||||
|
||||
void RecordAnimData( int iPlayerEntIndex, CStudioHdr* pStudioHdr, float fCycle, matrix3x4_t const& renderTransform,
|
||||
Vector pos[], Quaternion q[], int iBoneMask, CBoneAccessor const& boneAccessor );
|
||||
void RecordStandingHeadingChange( int iPlayerEntIndex, float flCurrentHeading, float flGoalHeading );
|
||||
void RecordJumpEvent( int iPlayerEntIndex );
|
||||
void RecordUserInput( CUserCmd const* pUserCmd );
|
||||
|
||||
public:
|
||||
bool m_bInit;
|
||||
|
||||
private:
|
||||
CDemoPolishRecorder();
|
||||
~CDemoPolishRecorder();
|
||||
|
||||
enum EFileType
|
||||
{
|
||||
kAnim,
|
||||
kEvents,
|
||||
kNumFileTypes
|
||||
};
|
||||
|
||||
bool InitLocalFileSystem();
|
||||
bool SetupFiles();
|
||||
bool WriteHeader();
|
||||
bool InitUserInputFile();
|
||||
bool SetupFile( char const* pFilenameStem, int iPlayerIndex, int iEntIndex, CUtlVector< CDemoPolishFile* >& vFiles, int iFileType );
|
||||
bool ClosePolishFiles( EFileType iFileType );
|
||||
CDemoPolishFile* GetFileForPlayerAt( int iPlayerEntIndex, EFileType iFileType );
|
||||
float GetTime() const;
|
||||
void FlushQueuedTurnEvents();
|
||||
|
||||
char m_szDemoBaseFileName[MAX_PATH];
|
||||
|
||||
CUtlVector< CDemoPolishFile* >* m_vFileLists[kNumFileTypes];
|
||||
CUtlVector< CDemoPolishFile* > m_vAnimFiles;
|
||||
CUtlVector< CDemoPolishFile* > m_vEventFiles;
|
||||
|
||||
CUtlVector< int > m_vPlayerEntIndexMap; // Maps from player lookup index to entity index
|
||||
|
||||
CUtlVector< CHeadingData* > m_standingHeadingEvents; // In-place turn events that will be filtered out before written to disk
|
||||
|
||||
CPathManager* m_pPathManager;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif // C_DEMO_POLISH_RECORDER_H
|
||||
Reference in New Issue
Block a user