Fix hands being put in face if Leap on HMD is set but Leap not connected

The joints were reporting themselves as "active" even though the Leap
wasn't connected, both at startup if not connected and after unplugging.
This commit is contained in:
David Rowe 2014-11-26 12:03:10 -08:00
parent 7737994399
commit 5f58c76842
2 changed files with 13 additions and 9 deletions

View file

@ -135,16 +135,20 @@ glm::vec3 vec3FromLeapVector(const Leap::Vector& vec) {
void Leapmotion::update() {
#ifdef HAVE_LEAPMOTION
// Check that the controller is actually active
bool wasActive = _active;
_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
// 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();
if (!_active) {
return;
}
// Get the most recent frame and report some basic information

View file

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