mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Merge pull request #15946 from AndrewMeadows/avoid-nan-scriptedMotor
BUGZ-870: MyAvatar's scripted motor needs to filter against NaN input
This commit is contained in:
commit
d719952022
1 changed files with 13 additions and 9 deletions
|
@ -2751,19 +2751,23 @@ QString MyAvatar::getScriptedMotorMode() const {
|
|||
}
|
||||
|
||||
void MyAvatar::setScriptedMotorVelocity(const glm::vec3& velocity) {
|
||||
float MAX_SCRIPTED_MOTOR_SPEED = 500.0f;
|
||||
_scriptedMotorVelocity = velocity;
|
||||
float speed = glm::length(_scriptedMotorVelocity);
|
||||
if (speed > MAX_SCRIPTED_MOTOR_SPEED) {
|
||||
_scriptedMotorVelocity *= MAX_SCRIPTED_MOTOR_SPEED / speed;
|
||||
float newSpeed = glm::length(velocity);
|
||||
if (!glm::isnan(newSpeed)) {
|
||||
_scriptedMotorVelocity = velocity;
|
||||
constexpr float MAX_SCRIPTED_MOTOR_SPEED = 500.0f;
|
||||
if (newSpeed > MAX_SCRIPTED_MOTOR_SPEED) {
|
||||
_scriptedMotorVelocity *= MAX_SCRIPTED_MOTOR_SPEED / newSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::setScriptedMotorTimescale(float timescale) {
|
||||
// we clamp the timescale on the large side (instead of just the low side) to prevent
|
||||
// obnoxiously large values from introducing NaN into avatar's velocity
|
||||
_scriptedMotorTimescale = glm::clamp(timescale, MIN_SCRIPTED_MOTOR_TIMESCALE,
|
||||
DEFAULT_SCRIPTED_MOTOR_TIMESCALE);
|
||||
if (!glm::isnan(timescale)) {
|
||||
// we clamp the timescale on the large side (instead of just the low side) to prevent
|
||||
// obnoxiously large values from introducing NaN into avatar's velocity
|
||||
_scriptedMotorTimescale = glm::clamp(timescale, MIN_SCRIPTED_MOTOR_TIMESCALE,
|
||||
DEFAULT_SCRIPTED_MOTOR_TIMESCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::setScriptedMotorFrame(QString frame) {
|
||||
|
|
Loading…
Reference in a new issue