if spring is linked to another entity which we can't find, disable the spring

This commit is contained in:
Seth Alves 2017-04-30 11:01:34 -07:00
parent c9dfebb713
commit dabec586ec

View file

@ -82,17 +82,24 @@ bool ObjectActionSpring::getTarget(float deltaTimeStep, glm::quat& rotation, glm
float& linearTimeScale, float& angularTimeScale) {
SpatiallyNestablePointer other = getOther();
withReadLock([&]{
if (other) {
rotation = _desiredRotationalTarget * other->getRotation();
position = _desiredPositionalTarget + other->getPosition();
linearTimeScale = _linearTimeScale;
angularTimeScale = _angularTimeScale;
if (_otherID != QUuid()) {
if (other) {
rotation = _desiredRotationalTarget * other->getRotation();
position = _desiredPositionalTarget + other->getPosition();
} else {
// we should have an "other" but can't find it, so disable the spring.
linearTimeScale = FLT_MAX;
angularTimeScale = FLT_MAX;
}
} else {
rotation = _desiredRotationalTarget;
position = _desiredPositionalTarget;
}
linearVelocity = glm::vec3();
angularVelocity = glm::vec3();
linearTimeScale = _linearTimeScale;
angularTimeScale = _angularTimeScale;
});
return true;
}