-
Автор темы
- #1
Purpose for this: After reviewing the leaked fatality source, it seems how the calculations are being done to predict player movement are a lot more consistent. It was fairly straightforward moving this to default supremacy, no additional things should be needed.
Edit - Add Dot to vector3.h in sdk.
Edit - Add Dot to vector3.h in sdk.
LagComp - PlayerMove:
void LagCompensation::PlayerMove(LagRecord* record)
{
ConVar* sv_gravity = g_csgo.m_cvar->FindVar( HASH( "sv_gravity" ) );
ConVar* sv_jump_impulse = g_csgo.m_cvar->FindVar( HASH( "sv_jump_impulse" ) );
if ( ~( record->m_pred_flags & FL_ONGROUND ) )
{
record->m_pred_velocity.z -= g_csgo.m_globals->m_interval * sv_gravity->GetFloat( );
record->m_pred_velocity.z += g_csgo.m_globals->m_interval * record->m_velocity.z;
}
const vec3_t min = record->m_mins;
const vec3_t maxs = record->m_maxs;
const vec3_t start = record->m_pred_origin;
vec3_t end = start + ( record->m_pred_velocity * g_csgo.m_globals->m_interval );
CGameTrace trace;
CTraceFilterWorldOnly filter;
// trace.
g_csgo.m_engine_trace->TraceRay(Ray(start, end, min, maxs), MASK_PLAYERSOLID, &filter, &trace);
if (trace.m_fraction != 1.f)
{
for (int i = 0; i < 2; ++i)
{
const float dot = record->m_pred_velocity.Dot( trace.m_plane.m_normal );
if (dot < 0.f)
{
record->m_pred_velocity.x -= dot * trace.m_plane.m_normal.x;
record->m_pred_velocity.y -= dot * trace.m_plane.m_normal.y;
record->m_pred_velocity.z -= dot * trace.m_plane.m_normal.z;
}
end = trace.m_endpos + ( record->m_pred_velocity * ( g_csgo.m_globals->m_interval * ( 1.f - trace.m_fraction ) ) );
g_csgo.m_engine_trace->TraceRay(Ray(start, end, min, maxs), MASK_PLAYERSOLID, &filter, &trace);
if (trace.m_fraction == 1.f)
break;
}
}
// set new final origin.
start == trace.m_endpos;
end = trace.m_endpos;
// move endpos 2 units down.
// this way we can check if we are in/on the ground.
end.z -= 2.f;
// trace.
g_csgo.m_engine_trace->TraceRay(Ray(start, end, min, maxs), MASK_PLAYERSOLID, &filter, &trace);
// strip onground flag.
record->m_pred_flags &= ~FL_ONGROUND;
// add back onground flag if we are onground.
if (trace.m_fraction != 1.f && trace.m_plane.m_normal.z > 0.7f)
record->m_pred_flags |= FL_ONGROUND;
}
vector3.h:
__forceinline float Dot(const vec3_t& vOther) const
{
const vec3_t& a = *this;
return(ax * vOther.x + ay * vOther.y + az * vOther.z);
}