-
Автор темы
- #1
C++:
void LagCompensation::PlayerMove( LagRecord* record ) {
vec3_t start, end, normal;
CGametrace trace;
CTraceFilterWorldOnly filter;
start = record->m_pred_origin;
end = start + ( record->m_pred_velocity * g_csgo.m_globals->m_interval );
g_csgo.m_engine_trace->TraceRay( Ray( start, end, record->m_mins, record->m_maxs ), CONTENTS_SOLID, &filter, &trace );
if ( trace.m_fraction != 1.f ) {
for ( int i = 0; i < 2; ++i ) {
record->m_pred_velocity -= trace.m_plane.m_normal * record->m_pred_velocity.dot( trace.m_plane.m_normal );
float adjust = record->m_pred_velocity.dot( trace.m_plane.m_normal );
if ( adjust < 0.f )
record->m_pred_velocity -= ( trace.m_plane.m_normal * adjust );
start = trace.m_endpos;
end = start + ( record->m_pred_velocity * ( g_csgo.m_globals->m_interval * ( 1.f - trace.m_fraction ) ) );
g_csgo.m_engine_trace->TraceRay( Ray( start, end, record->m_mins, record->m_maxs ), CONTENTS_SOLID, &filter, &trace );
if ( trace.m_fraction == 1.f )
break;
}
}
record->m_pred_origin = trace.m_endpos;
end = trace.m_endpos;
end.z -= 2.f;
g_csgo.m_engine_trace->TraceRay( Ray( record->m_pred_origin, end, record->m_mins, record->m_maxs ), CONTENTS_SOLID, &filter, &trace );
record->m_pred_flags &= ~FL_ONGROUND;
if ( trace.m_fraction != 1.f && trace.m_plane.m_normal.z > 0.7f )
record->m_pred_flags |= FL_ONGROUND;
}