like amiri in my mind
Пользователь
-
Автор темы
- #1
Возможно вронг.
Код:
auto should_simulate_duck = false;
auto start_ducking_tick = 0; /* tick we started ducking */
auto ticks_in_duck = 0.f; /* ticks of our life we spend in ducking */
auto interpolate = false;
auto duck_act = NONE;
if (curr->m_duck > 0.f || prev->m_duck > 0.f) { /* since we don't want to simulate animations if we didn't duck */
should_simulate_duck = true;
if (prev->m_duck == 0.f) { /* define real ducking time */
ticks_in_duck = (curr->m_duck / curr->m_duck_speed) ; /* 0.125f def duck per tick */
start_ducking_tick = valve::to_ticks(curr->m_sim_time) - ticks_in_duck; /* time in past */
duck_act = DUCKING;
}else if(curr->m_duck == 0.f){
ticks_in_duck = (prev->m_duck / prev->m_duck_speed);
start_ducking_tick = valve::to_ticks(prev->m_sim_time) + ticks_in_duck; /* time in future */
duck_act = UNDUCKING;
}else if(curr->m_duck > 0 && prev->m_duck > 0.f){
interpolate = true;
}
}
for (int isim_tick = 1; isim_tick <= curr->m_update_delay; isim_tick++) {
float simulated_time = prev->m_sim_time + valve::to_time(isim_tick);
float simulated_tick = valve::to_ticks(simulated_time);
/* setting global vars, etc... */
/* simulate duck animations */
p_ent->m_flDuckAmount() = curr->m_duck;
if (should_simulate_duck) {
/* modify if needed */
if(interpolate || ticks_in_duck >= curr->m_update_delay) /*check bounds also*/
/* fuckit let this be default, tbh: we don't have enough data to simulate, so just interpolate it */
p_ent->m_flDuckAmount() = m::lerp_anim(prev->m_duck, curr->m_duck, isim_tick, curr->m_update_delay);
else if(duck_act > NONE) {
if (simulated_tick >= start_ducking_tick )
p_ent->m_flDuckAmount() = m::lerp_anim(prev->m_duck, curr->m_duck, simulated_tick - start_ducking_tick, ticks_in_duck);
else
p_ent->m_flDuckAmount() = prev->m_duck;
}
}
Последнее редактирование: