mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:13:42 +02:00
Tweak low velocity avatar keyboard control.
This commit is contained in:
parent
e867b49701
commit
6aba2359ed
1 changed files with 10 additions and 12 deletions
|
@ -49,8 +49,8 @@ const float PITCH_SPEED = 100.0f; // degrees/sec
|
||||||
const float COLLISION_RADIUS_SCALAR = 1.2f; // pertains to avatar-to-avatar collisions
|
const float COLLISION_RADIUS_SCALAR = 1.2f; // pertains to avatar-to-avatar collisions
|
||||||
const float COLLISION_RADIUS_SCALE = 0.125f;
|
const float COLLISION_RADIUS_SCALE = 0.125f;
|
||||||
|
|
||||||
const float MIN_KEYBOARD_CONTROL_SPEED = 1.5f;
|
const float MIN_KEYBOARD_CONTROL_SPEED = 0.75f;
|
||||||
const float MAX_WALKING_SPEED = 3.0f * MIN_KEYBOARD_CONTROL_SPEED;
|
const float MAX_WALKING_SPEED = 4.5f;
|
||||||
|
|
||||||
// TODO: normalize avatar speed for standard avatar size, then scale all motion logic
|
// TODO: normalize avatar speed for standard avatar size, then scale all motion logic
|
||||||
// to properly follow avatar size.
|
// to properly follow avatar size.
|
||||||
|
@ -1262,21 +1262,19 @@ glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVe
|
||||||
|
|
||||||
// Compute the target keyboard velocity (which ramps up slowly, and damps very quickly)
|
// Compute the target keyboard velocity (which ramps up slowly, and damps very quickly)
|
||||||
// the max magnitude of which depends on what we're doing:
|
// the max magnitude of which depends on what we're doing:
|
||||||
float finalMaxMotorSpeed = hasFloor ? _scale * MAX_WALKING_SPEED : _scale * MAX_KEYBOARD_MOTOR_SPEED;
|
|
||||||
float motorLength = glm::length(_keyboardMotorVelocity);
|
float motorLength = glm::length(_keyboardMotorVelocity);
|
||||||
|
float finalMaxMotorSpeed = hasFloor ? _scale * MAX_WALKING_SPEED : _scale * MAX_KEYBOARD_MOTOR_SPEED;
|
||||||
|
float speedGrowthTimescale = 2.0f;
|
||||||
|
float speedIncreaseFactor = 1.8f;
|
||||||
|
motorLength *= 1.0f + glm::clamp(deltaTime / speedGrowthTimescale , 0.0f, 1.0f) * speedIncreaseFactor;
|
||||||
if (motorLength < _scale * MIN_KEYBOARD_CONTROL_SPEED) {
|
if (motorLength < _scale * MIN_KEYBOARD_CONTROL_SPEED) {
|
||||||
// an active keyboard motor should never be slower than this
|
// an active keyboard motor should never be slower than this
|
||||||
_keyboardMotorVelocity = _scale * MIN_KEYBOARD_CONTROL_SPEED * direction;
|
motorLength = _scale * MIN_KEYBOARD_CONTROL_SPEED;
|
||||||
motorEfficiency = 1.0f;
|
motorEfficiency = 1.0f;
|
||||||
} else {
|
} else if (motorLength > finalMaxMotorSpeed) {
|
||||||
float KEYBOARD_MOTOR_LENGTH_TIMESCALE = 2.0f;
|
motorLength = finalMaxMotorSpeed;
|
||||||
float INCREASE_FACTOR = 1.8f;
|
|
||||||
motorLength *= 1.0f + glm::clamp(deltaTime / KEYBOARD_MOTOR_LENGTH_TIMESCALE, 0.0f, 1.0f) * INCREASE_FACTOR;
|
|
||||||
if (motorLength > finalMaxMotorSpeed) {
|
|
||||||
motorLength = finalMaxMotorSpeed;
|
|
||||||
}
|
|
||||||
_keyboardMotorVelocity = motorLength * direction;
|
|
||||||
}
|
}
|
||||||
|
_keyboardMotorVelocity = motorLength * direction;
|
||||||
_isPushing = true;
|
_isPushing = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue