Changed animation data to simulation data
This commit is contained in:
parent
82a097ee1c
commit
0f150c08df
5 changed files with 29 additions and 94 deletions
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
|
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
|
#include "baseentity_shared.h"
|
||||||
|
#include "c_baseanimating.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "bone_setup.h"
|
#include "bone_setup.h"
|
||||||
|
@ -1298,12 +1300,6 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
|
||||||
m_EntityGroundContact.RemoveAll();
|
m_EntityGroundContact.RemoveAll();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < MAX_EDICTS; i++)
|
|
||||||
{
|
|
||||||
cmd->has_simulation[i] = false;
|
|
||||||
cmd->has_animation[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send interpolated simulation time for lag compensation
|
// Send interpolated simulation time for lag compensation
|
||||||
for (int i = 0; i <= ClientEntityList().GetHighestEntityIndex(); i++)
|
for (int i = 0; i <= ClientEntityList().GetHighestEntityIndex(); i++)
|
||||||
{
|
{
|
||||||
|
@ -1314,23 +1310,8 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd->has_simulation[pEntity->index] = true;
|
cmd->simulationdata[pEntity->index].m_flInterpolatedSimulationTime = pEntity->m_flInterpolatedSimulationTime;
|
||||||
cmd->simulationtimes[pEntity->index] = pEntity->m_flInterpolatedSimulationTime;
|
cmd->simulationdata[pEntity->index].m_flSimulationTime = pEntity->m_flSimulationTime;
|
||||||
|
|
||||||
if (pEntity->index < 1 && pEntity->index > MAX_PLAYERS)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pBasePlayer = ToBasePlayer(pEntity);
|
|
||||||
|
|
||||||
if (!pBasePlayer)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd->has_animation[pBasePlayer->index] = true;
|
|
||||||
cmd->animationdata[pBasePlayer->index].m_flUninterpolatedSimulationTime = pBasePlayer->m_flSimulationTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConVarRef cl_showhitboxes("cl_showhitboxes");
|
static ConVarRef cl_showhitboxes("cl_showhitboxes");
|
||||||
|
|
|
@ -398,8 +398,8 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer *pPlayer, CUserCmd *c
|
||||||
VPROF_BUDGET( "BacktrackPlayer", "CLagCompensationManager" );
|
VPROF_BUDGET( "BacktrackPlayer", "CLagCompensationManager" );
|
||||||
int pl_index = pPlayer->entindex() - 1;
|
int pl_index = pPlayer->entindex() - 1;
|
||||||
|
|
||||||
float flTargetSimulationTime = cmd->simulationtimes[pl_index + 1];
|
float flTargetSimulationTime = cmd->simulationdata[pl_index + 1].m_flInterpolatedSimulationTime;
|
||||||
auto animationData = &cmd->animationdata[pl_index + 1];
|
float flTargetSimulatedAnimationTime = cmd->simulationdata[pl_index + 1].m_flSimulationTime;
|
||||||
|
|
||||||
// get track history of this player
|
// get track history of this player
|
||||||
CUtlFixedLinkedList< LagRecord > *trackSim = &m_PlayerTrack[ pl_index ];
|
CUtlFixedLinkedList< LagRecord > *trackSim = &m_PlayerTrack[ pl_index ];
|
||||||
|
@ -428,7 +428,7 @@ void CLagCompensationManager::BacktrackPlayer( CBasePlayer *pPlayer, CUserCmd *c
|
||||||
recordSim = &trackSim->Element(currSim);
|
recordSim = &trackSim->Element(currSim);
|
||||||
|
|
||||||
if (recordSim->m_flSimulationTime
|
if (recordSim->m_flSimulationTime
|
||||||
<= animationData->m_flUninterpolatedSimulationTime && !foundAnimationData)
|
<= flTargetSimulatedAnimationTime && !foundAnimationData)
|
||||||
{
|
{
|
||||||
recordAnim = recordSim;
|
recordAnim = recordSim;
|
||||||
foundAnimationData = true;
|
foundAnimationData = true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CRopeKeyframe, DT_RopeKeyframe )
|
||||||
SendPropInt( SENDINFO(m_iRopeMaterialModelIndex), 16, SPROP_UNSIGNED ),
|
SendPropInt( SENDINFO(m_iRopeMaterialModelIndex), 16, SPROP_UNSIGNED ),
|
||||||
SendPropInt( SENDINFO(m_Subdiv), 4, SPROP_UNSIGNED ),
|
SendPropInt( SENDINFO(m_Subdiv), 4, SPROP_UNSIGNED ),
|
||||||
|
|
||||||
SendPropFloat( SENDINFO(m_TextureScale), 10, 0, 0.1f, 10.0f ),
|
SendPropFloat( SENDINFO(m_TextureScale), 10, 0, 0.0f, 10.0f ),
|
||||||
SendPropFloat( SENDINFO(m_Width), 0, SPROP_NOSCALE ),
|
SendPropFloat( SENDINFO(m_Width), 0, SPROP_NOSCALE ),
|
||||||
SendPropFloat( SENDINFO(m_flScrollSpeed), 0, SPROP_NOSCALE ),
|
SendPropFloat( SENDINFO(m_flScrollSpeed), 0, SPROP_NOSCALE ),
|
||||||
|
|
||||||
|
|
|
@ -192,36 +192,23 @@ void WriteUsercmd( bf_write *buf, const CUserCmd *to, const CUserCmd *from )
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= entityCount; i++)
|
for (int i = 0; i <= entityCount; i++)
|
||||||
{
|
{
|
||||||
buf->WriteOneBit(to->has_simulation[i]);
|
if (to->simulationdata[i].m_flInterpolatedSimulationTime
|
||||||
|
!= from->simulationdata[i].m_flInterpolatedSimulationTime)
|
||||||
if (!to->has_simulation[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to->simulationtimes[i] != from->simulationtimes[i])
|
|
||||||
{
|
{
|
||||||
buf->WriteOneBit(1);
|
buf->WriteOneBit(1);
|
||||||
buf->WriteFloat(to->simulationtimes[i]);
|
buf->WriteFloat(
|
||||||
|
to->simulationdata[i].m_flInterpolatedSimulationTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf->WriteOneBit(0);
|
buf->WriteOneBit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->WriteOneBit(to->has_animation[i]);
|
if (to->simulationdata[i].m_flSimulationTime
|
||||||
|
!= from->simulationdata[i].m_flSimulationTime)
|
||||||
if (!to->has_animation[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to->animationdata[i].m_flUninterpolatedSimulationTime
|
|
||||||
!= from->animationdata[i].m_flUninterpolatedSimulationTime)
|
|
||||||
{
|
{
|
||||||
buf->WriteOneBit(1);
|
buf->WriteOneBit(1);
|
||||||
buf->WriteFloat(
|
buf->WriteFloat(to->simulationdata[i].m_flSimulationTime);
|
||||||
to->animationdata[i].m_flUninterpolatedSimulationTime);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -365,30 +352,15 @@ void ReadUsercmd( bf_read *buf, CUserCmd *move, CUserCmd *from )
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= entityCount; i++)
|
for (int i = 0; i <= entityCount; i++)
|
||||||
{
|
{
|
||||||
// Has simulation ?
|
if (buf->ReadOneBit())
|
||||||
move->has_simulation[i] = buf->ReadOneBit();
|
|
||||||
|
|
||||||
if (!move->has_simulation[i])
|
|
||||||
{
|
{
|
||||||
continue;
|
move->simulationdata[i].m_flInterpolatedSimulationTime = buf
|
||||||
|
->ReadFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->ReadOneBit())
|
if (buf->ReadOneBit())
|
||||||
{
|
{
|
||||||
move->simulationtimes[i] = buf->ReadFloat();
|
move->simulationdata[i].m_flSimulationTime = buf
|
||||||
}
|
|
||||||
|
|
||||||
// Has animation ?
|
|
||||||
move->has_animation[i] = buf->ReadOneBit();
|
|
||||||
|
|
||||||
if (!move->has_animation[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf->ReadOneBit())
|
|
||||||
{
|
|
||||||
move->animationdata[i].m_flUninterpolatedSimulationTime = buf
|
|
||||||
->ReadFloat();
|
->ReadFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// $NoKeywords: $
|
// $NoKeywords: $
|
||||||
//
|
//
|
||||||
//=============================================================================//
|
//=============================================================================//
|
||||||
|
#include "const.h"
|
||||||
#ifdef CLIENT_DLL
|
#ifdef CLIENT_DLL
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,12 +52,13 @@ struct LayerRecord
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClientSideAnimationData
|
struct SimulationData
|
||||||
{
|
{
|
||||||
// TODO_ENHANCED:
|
// TODO_ENHANCED:
|
||||||
// For now we send the last received update for animations.
|
// For now we send the last received update for animations.
|
||||||
// anim time is unreliable on low fps.
|
// anim time is unreliable on low fps.
|
||||||
float m_flUninterpolatedSimulationTime;
|
float m_flInterpolatedSimulationTime;
|
||||||
|
float m_flSimulationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CEntityGroundContact
|
class CEntityGroundContact
|
||||||
|
@ -97,14 +99,7 @@ public:
|
||||||
|
|
||||||
for (int i = 0; i < MAX_EDICTS; i++)
|
for (int i = 0; i < MAX_EDICTS; i++)
|
||||||
{
|
{
|
||||||
simulationtimes[i] = 0.0f;
|
simulationdata[i] = {};
|
||||||
has_simulation[i] = false;
|
|
||||||
has_animation[i] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= MAX_PLAYERS; i++)
|
|
||||||
{
|
|
||||||
animationdata[i] = {};
|
|
||||||
}
|
}
|
||||||
debug_hitboxes = DEBUG_HITBOXES_OFF;
|
debug_hitboxes = DEBUG_HITBOXES_OFF;
|
||||||
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
||||||
|
@ -135,14 +130,7 @@ public:
|
||||||
|
|
||||||
for (int i = 0; i < MAX_EDICTS; i++)
|
for (int i = 0; i < MAX_EDICTS; i++)
|
||||||
{
|
{
|
||||||
simulationtimes[i] = src.simulationtimes[i];
|
simulationdata[i] = src.simulationdata[i];
|
||||||
has_simulation[i] = src.has_simulation[i];
|
|
||||||
has_animation[i] = src.has_animation[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= MAX_PLAYERS; i++)
|
|
||||||
{
|
|
||||||
animationdata[i] = src.animationdata[i];
|
|
||||||
}
|
}
|
||||||
debug_hitboxes = src.debug_hitboxes;
|
debug_hitboxes = src.debug_hitboxes;
|
||||||
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
||||||
|
@ -175,10 +163,7 @@ public:
|
||||||
CRC32_ProcessBuffer( &crc, &random_seed, sizeof( random_seed ) );
|
CRC32_ProcessBuffer( &crc, &random_seed, sizeof( random_seed ) );
|
||||||
CRC32_ProcessBuffer( &crc, &mousedx, sizeof( mousedx ) );
|
CRC32_ProcessBuffer( &crc, &mousedx, sizeof( mousedx ) );
|
||||||
CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy));
|
CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy));
|
||||||
CRC32_ProcessBuffer(&crc, has_simulation, sizeof(has_simulation));
|
CRC32_ProcessBuffer(&crc, simulationdata, sizeof(simulationdata));
|
||||||
CRC32_ProcessBuffer(&crc, has_animation, sizeof(has_animation));
|
|
||||||
CRC32_ProcessBuffer( &crc, simulationtimes, sizeof( simulationtimes ) );
|
|
||||||
CRC32_ProcessBuffer(&crc, animationdata, sizeof(animationdata));
|
|
||||||
CRC32_ProcessBuffer(&crc, &debug_hitboxes, sizeof(debug_hitboxes));
|
CRC32_ProcessBuffer(&crc, &debug_hitboxes, sizeof(debug_hitboxes));
|
||||||
CRC32_Final( &crc );
|
CRC32_Final( &crc );
|
||||||
|
|
||||||
|
@ -230,10 +215,7 @@ public:
|
||||||
|
|
||||||
// TODO_ENHANCED: Lag compensate also other entities when needed.
|
// TODO_ENHANCED: Lag compensate also other entities when needed.
|
||||||
// Send simulation times for each players for lag compensation.
|
// Send simulation times for each players for lag compensation.
|
||||||
bool has_simulation[MAX_EDICTS];
|
SimulationData simulationdata[MAX_EDICTS];
|
||||||
bool has_animation[MAX_EDICTS];
|
|
||||||
float simulationtimes[MAX_EDICTS];
|
|
||||||
ClientSideAnimationData animationdata[MAX_PLAYERS+1];
|
|
||||||
|
|
||||||
enum debug_hitboxes_t : uint8
|
enum debug_hitboxes_t : uint8
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue