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