mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:18:12 +02:00
Attempt to disable Hydra hands after five seconds without movement.
This commit is contained in:
parent
38118fdab0
commit
515b40ecc3
2 changed files with 21 additions and 1 deletions
|
@ -13,7 +13,9 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "SixenseManager.h"
|
#include "SixenseManager.h"
|
||||||
|
|
||||||
SixenseManager::SixenseManager() {
|
using namespace std;
|
||||||
|
|
||||||
|
SixenseManager::SixenseManager() : _lastMovement(usecTimestampNow()) {
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
sixenseInit();
|
sixenseInit();
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,6 +100,12 @@ void SixenseManager::update(float deltaTime) {
|
||||||
palm->setRawVelocity(rawVelocity); // meters/sec
|
palm->setRawVelocity(rawVelocity); // meters/sec
|
||||||
palm->setRawPosition(position);
|
palm->setRawPosition(position);
|
||||||
|
|
||||||
|
// use the velocity to determine whether there's any movement
|
||||||
|
const float MOVEMENT_SPEED_THRESHOLD = 0.001f;
|
||||||
|
if (glm::length(rawVelocity) > MOVEMENT_SPEED_THRESHOLD) {
|
||||||
|
_lastMovement = usecTimestampNow();
|
||||||
|
}
|
||||||
|
|
||||||
// initialize the "finger" based on the direction
|
// initialize the "finger" based on the direction
|
||||||
FingerData finger(palm, &hand);
|
FingerData finger(palm, &hand);
|
||||||
finger.setActive(true);
|
finger.setActive(true);
|
||||||
|
@ -118,6 +126,14 @@ void SixenseManager::update(float deltaTime) {
|
||||||
palm->getFingers().push_back(finger);
|
palm->getFingers().push_back(finger);
|
||||||
palm->getFingers().push_back(finger);
|
palm->getFingers().push_back(finger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the controllers haven't been moved in a while, disable
|
||||||
|
const int MOVEMENT_DISABLE_DURATION = 5 * 1000 * 1000;
|
||||||
|
if (usecTimestampNow() - _lastMovement > MOVEMENT_DISABLE_DURATION) {
|
||||||
|
for (vector<PalmData>::iterator it = hand.getPalms().begin(); it != hand.getPalms().end(); it++) {
|
||||||
|
it->setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setFilter(bool filter);
|
void setFilter(bool filter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint64_t _lastMovement;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__SixenseManager__) */
|
#endif /* defined(__interface__SixenseManager__) */
|
||||||
|
|
Loading…
Reference in a new issue