mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 11:43:16 +02:00
Merge pull request #3552 from AndrewMeadows/inertia
Tweak low velocity avatar keyboard control.
This commit is contained in:
commit
8084c5c77d
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_SCALE = 0.125f;
|
||||
|
||||
const float MIN_KEYBOARD_CONTROL_SPEED = 1.5f;
|
||||
const float MAX_WALKING_SPEED = 3.0f * MIN_KEYBOARD_CONTROL_SPEED;
|
||||
const float MIN_KEYBOARD_CONTROL_SPEED = 0.75f;
|
||||
const float MAX_WALKING_SPEED = 4.5f;
|
||||
|
||||
// TODO: normalize avatar speed for standard avatar size, then scale all motion logic
|
||||
// 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)
|
||||
// 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 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) {
|
||||
// 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;
|
||||
} else {
|
||||
float KEYBOARD_MOTOR_LENGTH_TIMESCALE = 2.0f;
|
||||
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;
|
||||
} else if (motorLength > finalMaxMotorSpeed) {
|
||||
motorLength = finalMaxMotorSpeed;
|
||||
}
|
||||
_keyboardMotorVelocity = motorLength * direction;
|
||||
_isPushing = true;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue