a little more cleanup

This commit is contained in:
Brad Hefta-Gaub 2015-10-27 17:09:43 -07:00
parent 7f313e7f86
commit 65eae35433
3 changed files with 10 additions and 42 deletions

View file

@ -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);
}

View file

@ -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),

View file

@ -54,10 +54,6 @@ public:
std::vector<PalmData> 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