mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-01 21:51:08 +00:00
Flick Stick refactor
Removed redundant calculations
This commit is contained in:
parent
f839596168
commit
13deb72b16
2 changed files with 30 additions and 28 deletions
|
@ -1416,22 +1416,23 @@ IN_Move(usercmd_t *cmd)
|
||||||
// Flick Stick: flick in progress, changing the yaw angle to the target progressively
|
// Flick Stick: flick in progress, changing the yaw angle to the target progressively
|
||||||
if (flick_progress < 1.0f)
|
if (flick_progress < 1.0f)
|
||||||
{
|
{
|
||||||
float old = flick_progress;
|
float cur_progress = (float)(cls.realtime - started_flick) / FLICK_TIME;
|
||||||
float new = (float)(cls.realtime - started_flick) / FLICK_TIME;
|
|
||||||
|
|
||||||
if (new > 1.0f) new = 1.0f;
|
if (cur_progress > 1.0f)
|
||||||
flick_progress = new;
|
{
|
||||||
|
cur_progress = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// "Ease out" warp processing: f(x)=1-(1-x)^2 , 0 <= x <= 1
|
||||||
|
// http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0
|
||||||
|
cur_progress = 1.0f - cur_progress;
|
||||||
|
cur_progress *= cur_progress;
|
||||||
|
cur_progress = 1.0f - cur_progress;
|
||||||
|
}
|
||||||
|
|
||||||
// "Ease out" warp processing for both old and new progress
|
cl.viewangles[YAW] += (cur_progress - flick_progress) * target_angle;
|
||||||
// http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0
|
flick_progress = cur_progress;
|
||||||
old = 1.0f - old;
|
|
||||||
old *= old;
|
|
||||||
old = 1.0f - old;
|
|
||||||
new = 1.0f - new;
|
|
||||||
new *= new;
|
|
||||||
new = 1.0f - new;
|
|
||||||
|
|
||||||
cl.viewangles[YAW] += (new - old) * target_angle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1401,22 +1401,23 @@ IN_Move(usercmd_t *cmd)
|
||||||
// Flick Stick: flick in progress, changing the yaw angle to the target progressively
|
// Flick Stick: flick in progress, changing the yaw angle to the target progressively
|
||||||
if (flick_progress < 1.0f)
|
if (flick_progress < 1.0f)
|
||||||
{
|
{
|
||||||
float old = flick_progress;
|
float cur_progress = (float)(cls.realtime - started_flick) / FLICK_TIME;
|
||||||
float new = (float)(cls.realtime - started_flick) / FLICK_TIME;
|
|
||||||
|
|
||||||
if (new > 1.0f) new = 1.0f;
|
if (cur_progress > 1.0f)
|
||||||
flick_progress = new;
|
{
|
||||||
|
cur_progress = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// "Ease out" warp processing: f(x)=1-(1-x)^2 , 0 <= x <= 1
|
||||||
|
// http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0
|
||||||
|
cur_progress = 1.0f - cur_progress;
|
||||||
|
cur_progress *= cur_progress;
|
||||||
|
cur_progress = 1.0f - cur_progress;
|
||||||
|
}
|
||||||
|
|
||||||
// "Ease out" warp processing for both old and new progress
|
cl.viewangles[YAW] += (cur_progress - flick_progress) * target_angle;
|
||||||
// http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0
|
flick_progress = cur_progress;
|
||||||
old = 1.0f - old;
|
|
||||||
old *= old;
|
|
||||||
old = 1.0f - old;
|
|
||||||
new = 1.0f - new;
|
|
||||||
new *= new;
|
|
||||||
new = 1.0f - new;
|
|
||||||
|
|
||||||
cl.viewangles[YAW] += (new - old) * target_angle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue