mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-21 03:21:08 +00:00
update comment. use sqrtf.
This commit is contained in:
parent
52c67ac35d
commit
6c2152f384
1 changed files with 6 additions and 5 deletions
|
@ -417,7 +417,7 @@ assumes axis values are in [-1, 1]. Raises the axis values to the given exponent
|
||||||
*/
|
*/
|
||||||
static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent)
|
static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent)
|
||||||
{
|
{
|
||||||
joyaxis_t result = {0};
|
joyaxis_t result;
|
||||||
float magnitude, eased_magnitude;
|
float magnitude, eased_magnitude;
|
||||||
|
|
||||||
magnitude = sqrtf( (axis.x * axis.x) + (axis.y * axis.y) );
|
magnitude = sqrtf( (axis.x * axis.x) + (axis.y * axis.y) );
|
||||||
|
@ -440,13 +440,14 @@ static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent)
|
||||||
IN_ApplyMoveEasing
|
IN_ApplyMoveEasing
|
||||||
|
|
||||||
clamps coordinates to a square with coordinates +/- sqrt(2)/2, then scales them to +/- 1.
|
clamps coordinates to a square with coordinates +/- sqrt(2)/2, then scales them to +/- 1.
|
||||||
This is so when the stick is on a diagonal, it will have coordinates (1,1).
|
This wastes a bit of stick range, but gives the diagonals coordinates of (+/-1,+/-1),
|
||||||
|
so holding the stick on a diagonal gives the same speed boost as holding the forward and strafe keyboard keys.
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
static joyaxis_t IN_ApplyMoveEasing(joyaxis_t axis)
|
static joyaxis_t IN_ApplyMoveEasing(joyaxis_t axis)
|
||||||
{
|
{
|
||||||
joyaxis_t result = {0};
|
joyaxis_t result;
|
||||||
const float v = sqrt(2)/2;
|
const float v = sqrtf(2.0f) / 2.0f;
|
||||||
|
|
||||||
result.x = q_max(-v, q_min(v, axis.x));
|
result.x = q_max(-v, q_min(v, axis.x));
|
||||||
result.y = q_max(-v, q_min(v, axis.y));
|
result.y = q_max(-v, q_min(v, axis.y));
|
||||||
|
@ -468,7 +469,7 @@ and adapted from http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zon
|
||||||
*/
|
*/
|
||||||
static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone)
|
static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone)
|
||||||
{
|
{
|
||||||
joyaxis_t result = {0};
|
joyaxis_t result;
|
||||||
float magnitude = sqrtf( (axis.x * axis.x) + (axis.y * axis.y) );
|
float magnitude = sqrtf( (axis.x * axis.x) + (axis.y * axis.y) );
|
||||||
|
|
||||||
if ( magnitude < deadzone ) {
|
if ( magnitude < deadzone ) {
|
||||||
|
|
Loading…
Reference in a new issue