Merge pull request #3869 from ctrlaltdavid/fix-leap-hands-in-face

Fix Leap hands in face
This commit is contained in:
Philip Rosedale 2014-11-26 15:49:29 -08:00
commit f0fa627892
3 changed files with 26 additions and 19 deletions

View file

@ -471,17 +471,20 @@ var leapHands = (function () {
} else { } else {
hands[h].inactiveCount += 1; if (hands[h].inactiveCount < MAX_HAND_INACTIVE_COUNT) {
if (hands[h].inactiveCount === MAX_HAND_INACTIVE_COUNT) { hands[h].inactiveCount += 1;
if (h === 0) {
MyAvatar.clearJointData("LeftHand"); if (hands[h].inactiveCount === MAX_HAND_INACTIVE_COUNT) {
MyAvatar.clearJointData("LeftForeArm"); if (h === 0) {
MyAvatar.clearJointData("LeftArm"); MyAvatar.clearJointData("LeftHand");
} else { MyAvatar.clearJointData("LeftForeArm");
MyAvatar.clearJointData("RightHand"); MyAvatar.clearJointData("LeftArm");
MyAvatar.clearJointData("RightForeArm"); } else {
MyAvatar.clearJointData("RightArm"); MyAvatar.clearJointData("RightHand");
MyAvatar.clearJointData("RightForeArm");
MyAvatar.clearJointData("RightArm");
}
} }
} }
} }

View file

@ -135,16 +135,20 @@ glm::vec3 vec3FromLeapVector(const Leap::Vector& vec) {
void Leapmotion::update() { void Leapmotion::update() {
#ifdef HAVE_LEAPMOTION #ifdef HAVE_LEAPMOTION
// Check that the controller is actually active bool wasActive = _active;
_active = _controller.isConnected(); _active = _controller.isConnected();
if (!_active) {
return; if (_active || wasActive) {
// Go through all the joints and increment their counter since last update.
// Increment all counters once after controller first becomes inactive so that each joint reports itself as inactive.
// TODO C++11 for (auto jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) {
for (JointTracker::Vector::iterator jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) {
(*jointIt).tickNewFrame();
}
} }
// go through all the joints and increment their counter since last update if (!_active) {
// TODO C++11 for (auto jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) { return;
for (JointTracker::Vector::iterator jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) {
(*jointIt).tickNewFrame();
} }
// Get the most recent frame and report some basic information // Get the most recent frame and report some basic information

View file

@ -119,14 +119,14 @@ MotionTracker::JointTracker::JointTracker() :
_absFrame(), _absFrame(),
_semantic(""), _semantic(""),
_parent(INVALID_PARENT), _parent(INVALID_PARENT),
_lastUpdate(0) _lastUpdate(1) // Joint inactive
{ {
} }
MotionTracker::JointTracker::JointTracker(const Semantic& semantic, Index parent) : MotionTracker::JointTracker::JointTracker(const Semantic& semantic, Index parent) :
_semantic(semantic), _semantic(semantic),
_parent(parent), _parent(parent),
_lastUpdate(0) _lastUpdate(1) // Joint inactive
{ {
} }