Making arm restoration rate independent of FPS and easier to tune.

This commit is contained in:
Andrew Meadows 2014-02-13 10:04:58 -08:00
parent 9523ea7d03
commit 312bc7521f

View file

@ -36,23 +36,24 @@ void SkeletonModel::simulate(float deltaTime) {
HandData& hand = _owningAvatar->getHand(); HandData& hand = _owningAvatar->getHand();
hand.getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); hand.getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
const float HAND_RESTORATION_RATE = 0.25f; const float HAND_RESTORATION_PERIOD = 1.f; // seconds
float handRestorePercent = glm::clamp(deltaTime / HAND_RESTORATION_PERIOD, 0.f, 1.f);
const FBXGeometry& geometry = _geometry->getFBXGeometry(); const FBXGeometry& geometry = _geometry->getFBXGeometry();
if (leftPalmIndex == -1) { if (leftPalmIndex == -1) {
// no Leap data; set hands from mouse // no Leap data; set hands from mouse
if (_owningAvatar->getHandState() == HAND_STATE_NULL) { if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
restoreRightHandPosition(HAND_RESTORATION_RATE); restoreRightHandPosition(handRestorePercent);
} else { } else {
applyHandPosition(geometry.rightHandJointIndex, _owningAvatar->getHandPosition()); applyHandPosition(geometry.rightHandJointIndex, _owningAvatar->getHandPosition());
} }
restoreLeftHandPosition(HAND_RESTORATION_RATE); restoreLeftHandPosition(handRestorePercent);
} else if (leftPalmIndex == rightPalmIndex) { } else if (leftPalmIndex == rightPalmIndex) {
// right hand only // right hand only
applyPalmData(geometry.rightHandJointIndex, geometry.rightFingerJointIndices, geometry.rightFingertipJointIndices, applyPalmData(geometry.rightHandJointIndex, geometry.rightFingerJointIndices, geometry.rightFingertipJointIndices,
hand.getPalms()[leftPalmIndex]); hand.getPalms()[leftPalmIndex]);
restoreLeftHandPosition(HAND_RESTORATION_RATE); restoreLeftHandPosition(handRestorePercent);
} else { } else {
applyPalmData(geometry.leftHandJointIndex, geometry.leftFingerJointIndices, geometry.leftFingertipJointIndices, applyPalmData(geometry.leftHandJointIndex, geometry.leftFingerJointIndices, geometry.leftFingertipJointIndices,