mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
guard against feeding bullet a NaN
This commit is contained in:
parent
2e5b25b5d8
commit
fbede0a23f
2 changed files with 43 additions and 0 deletions
|
@ -54,6 +54,22 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
|||
if (!tryLockForWrite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check for NaNs
|
||||
if (position.x != position.x ||
|
||||
position.y != position.y ||
|
||||
position.z != position.z) {
|
||||
qDebug() << "AvatarActionHold::updateActionWorker -- target position includes NaN";
|
||||
return;
|
||||
}
|
||||
if (rotation.x != rotation.x ||
|
||||
rotation.y != rotation.y ||
|
||||
rotation.z != rotation.z ||
|
||||
rotation.w != rotation.w) {
|
||||
qDebug() << "AvatarActionHold::updateActionWorker -- target rotation includes NaN";
|
||||
return;
|
||||
}
|
||||
|
||||
_positionalTarget = position;
|
||||
_rotationalTarget = rotation;
|
||||
unlock();
|
||||
|
@ -145,6 +161,7 @@ QByteArray AvatarActionHold::serialize() {
|
|||
dataStream << _relativePosition;
|
||||
dataStream << _relativeRotation;
|
||||
dataStream << _hand;
|
||||
dataStream << _linearTimeScale;
|
||||
|
||||
return ba;
|
||||
}
|
||||
|
@ -168,6 +185,9 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _relativePosition;
|
||||
dataStream >> _relativeRotation;
|
||||
dataStream >> _hand;
|
||||
dataStream >> _linearTimeScale;
|
||||
_angularTimeScale = _linearTimeScale;
|
||||
|
||||
_parametersSet = true;
|
||||
|
||||
_active = true;
|
||||
|
|
|
@ -55,6 +55,17 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
|
|||
|
||||
// handle the linear part
|
||||
if (_positionalTargetSet) {
|
||||
// check for NaN
|
||||
if (_positionalTarget.x != _positionalTarget.x ||
|
||||
_positionalTarget.y != _positionalTarget.y ||
|
||||
_positionalTarget.z != _positionalTarget.z) {
|
||||
qDebug() << "ObjectActionSpring::updateActionWorker -- target position includes NaN";
|
||||
unlock();
|
||||
lockForWrite();
|
||||
_active = false;
|
||||
unlock();
|
||||
return;
|
||||
}
|
||||
glm::vec3 offset = _positionalTarget - bulletToGLM(rigidBody->getCenterOfMassPosition());
|
||||
float offsetLength = glm::length(offset);
|
||||
float speed = offsetLength / _linearTimeScale;
|
||||
|
@ -70,6 +81,18 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) {
|
|||
|
||||
// handle rotation
|
||||
if (_rotationalTargetSet) {
|
||||
if (_rotationalTarget.x != _rotationalTarget.x ||
|
||||
_rotationalTarget.y != _rotationalTarget.y ||
|
||||
_rotationalTarget.z != _rotationalTarget.z ||
|
||||
_rotationalTarget.w != _rotationalTarget.w) {
|
||||
qDebug() << "AvatarActionHold::updateActionWorker -- target rotation includes NaN";
|
||||
unlock();
|
||||
lockForWrite();
|
||||
_active = false;
|
||||
unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
glm::quat bodyRotation = bulletToGLM(rigidBody->getOrientation());
|
||||
// if qZero and qOne are too close to each other, we can get NaN for angle.
|
||||
auto alignmentDot = glm::dot(bodyRotation, _rotationalTarget);
|
||||
|
|
Loading…
Reference in a new issue