Don't call function if flow is not active and made it thread safe

This commit is contained in:
luiscuenca 2019-04-25 10:31:05 -07:00
parent da1597c5d1
commit 6b33f4e027
No known key found for this signature in database
GPG key ID: 2387ECD129A6961D

View file

@ -5811,7 +5811,13 @@ void MyAvatar::releaseGrab(const QUuid& grabID) {
} }
void MyAvatar::addAvatarHandsToFlow(const std::shared_ptr<Avatar>& otherAvatar) { void MyAvatar::addAvatarHandsToFlow(const std::shared_ptr<Avatar>& otherAvatar) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "addAvatarHandsToFlow",
Q_ARG(const std::shared_ptr<Avatar>&, otherAvatar));
return;
}
auto &flow = _skeletonModel->getRig().getFlow(); auto &flow = _skeletonModel->getRig().getFlow();
if (otherAvatar != nullptr && flow.getActive()) {
for (auto &handJointName : HAND_COLLISION_JOINTS) { for (auto &handJointName : HAND_COLLISION_JOINTS) {
int jointIndex = otherAvatar->getJointIndex(handJointName); int jointIndex = otherAvatar->getJointIndex(handJointName);
if (jointIndex != -1) { if (jointIndex != -1) {
@ -5819,6 +5825,7 @@ void MyAvatar::addAvatarHandsToFlow(const std::shared_ptr<Avatar>& otherAvatar)
flow.setOthersCollision(otherAvatar->getID(), jointIndex, position); flow.setOthersCollision(otherAvatar->getID(), jointIndex, position);
} }
} }
}
} }
/**jsdoc /**jsdoc