diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index f821c79d59..e39bfe246b 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -236,20 +236,15 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { const FBXGeometry& geometry = _geometry->getFBXGeometry(); - // find the left and rightmost active palms - int leftPalmIndex, rightPalmIndex; - Hand* hand = _owningAvatar->getHand(); - - // FIXME - it's possible that the left/right hand indices could change between this call - // and the call to hand->getCopyOfPalms(); This logic should be reworked to only operate on - // the copy of the palms data - hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); - // Don't Relax toward hand positions when in animGraph mode. if (!_rig->getEnableAnimGraph()) { - auto palms = hand->getCopyOfPalms(); + + Hand* hand = _owningAvatar->getHand(); + auto leftPalm = hand->getCopyOfPalmData(HandData::LeftHand); + auto rightPalm = hand->getCopyOfPalmData(HandData::RightHand); + const float HAND_RESTORATION_RATE = 0.25f; - if (leftPalmIndex == -1 && rightPalmIndex == -1) { + if (!leftPalm.isActive() && !rightPalm.isActive()) { // palms are not yet set, use mouse if (_owningAvatar->getHandState() == HAND_STATE_NULL) { restoreRightHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY); @@ -259,20 +254,14 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { applyHandPosition(geometry.rightHandJointIndex, handPosition); } restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY); - - } else if (leftPalmIndex == rightPalmIndex) { - // right hand only - applyPalmData(geometry.rightHandJointIndex, palms[leftPalmIndex]); - restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY); - } else { - if (leftPalmIndex != -1) { - applyPalmData(geometry.leftHandJointIndex, palms[leftPalmIndex]); + if (leftPalm.isActive()) { + applyPalmData(geometry.leftHandJointIndex, leftPalm); } else { restoreLeftHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY); } - if (rightPalmIndex != -1) { - applyPalmData(geometry.rightHandJointIndex, palms[rightPalmIndex]); + if (rightPalm.isActive()) { + applyPalmData(geometry.rightHandJointIndex, rightPalm); } else { restoreRightHandPosition(HAND_RESTORATION_RATE, PALM_PRIORITY); } diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index fc6d18932a..5d783a671e 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -48,23 +48,6 @@ PalmData HandData::getCopyOfPalmData(Hand hand) const { return PalmData(); // invalid hand } -void HandData::getLeftRightPalmIndices(int& leftPalmIndex, int& rightPalmIndex) const { - QReadLocker locker(&_palmsLock); - leftPalmIndex = -1; - rightPalmIndex = -1; - for (size_t i = 0; i < _palms.size(); i++) { - const PalmData& palm = _palms[i]; - if (palm.isActive()) { - if (palm.whichHand() == LeftHand) { - leftPalmIndex = i; - } - if (palm.whichHand() == RightHand) { - rightPalmIndex = i; - } - } - } -} - PalmData::PalmData(HandData* owningHandData, HandData::Hand hand) : _rawRotation(0.0f, 0.0f, 0.0f, 1.0f), _rawPosition(0.0f), diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index b475248d9e..d782f240ee 100644 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -54,10 +54,6 @@ public: std::vector getCopyOfPalms() const { QReadLocker locker(&_palmsLock); return _palms; } - /// Finds the indices of the left and right palms according to their locations, or -1 if either or - /// both is not found. - void getLeftRightPalmIndices(int& leftPalmIndex, int& rightPalmIndex) const; - /// Checks for penetration between the described sphere and the hand. /// \param penetratorCenter the center of the penetration test sphere /// \param penetratorRadius the radius of the penetration test sphere