From 96809415002ca76ae54cd539db389751bdb560e3 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 29 Nov 2013 14:50:18 -0800 Subject: [PATCH] Add palm velocity --- interface/src/Application.cpp | 6 +++--- interface/src/Application.h | 2 +- interface/src/devices/SixenseManager.cpp | 5 ++++- interface/src/devices/SixenseManager.h | 2 +- libraries/avatars/src/HandData.h | 3 +++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 43a5e784ed..a06024132e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2221,11 +2221,11 @@ void Application::updateLeap(float deltaTime) { LeapManager::nextFrame(); } -void Application::updateSixense() { +void Application::updateSixense(float deltaTime) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateSixense()"); - _sixenseManager.update(); + _sixenseManager.update(deltaTime); } void Application::updateSerialDevices(float deltaTime) { @@ -2435,7 +2435,7 @@ void Application::update(float deltaTime) { updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels updateHandAndTouch(deltaTime); // Update state for touch sensors updateLeap(deltaTime); // Leap finger-sensing device - updateSixense(); // Razer Hydra controllers + updateSixense(deltaTime); // Razer Hydra controllers updateSerialDevices(deltaTime); // Read serial port interface devices updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... diff --git a/interface/src/Application.h b/interface/src/Application.h index e2d0820ab9..a81c10041b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -247,7 +247,7 @@ private: glm::vec3& eyePosition); void updateHandAndTouch(float deltaTime); void updateLeap(float deltaTime); - void updateSixense(); + void updateSixense(float deltaTime); void updateSerialDevices(float deltaTime); void updateThreads(float deltaTime); void updateMyAvatarSimulation(float deltaTime); diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index dfeab1f309..8322c589c9 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -25,7 +25,7 @@ SixenseManager::~SixenseManager() { #endif } -void SixenseManager::update() { +void SixenseManager::update(float deltaTime) { #ifdef HAVE_SIXENSE if (sixenseGetNumActiveControllers() == 0) { return; @@ -63,6 +63,9 @@ void SixenseManager::update() { palm.setActive(true); glm::vec3 position(data.pos[0], data.pos[1], data.pos[2]); + // Compute current velocity from position change + palm.setVelocity((position - palm.getPosition()) / deltaTime); + // Adjust for distance between acquisition 'orb' and the user's torso // (distance to the right of body center, distance below torso, distance behind torso) const glm::vec3 SPHERE_TO_TORSO(-250.f, -300.f, -300.f); diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index 90b8cf988f..43e11b682f 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -16,7 +16,7 @@ public: SixenseManager(); ~SixenseManager(); - void update(); + void update(float deltaTime); }; #endif /* defined(__interface__SixenseManager__) */ diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index c871c568bb..ad32d068bc 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -144,6 +144,8 @@ public: void setLeapID(int id) { _leapID = id; } void setRawPosition(const glm::vec3& pos) { _rawPosition = pos; } void setRawNormal(const glm::vec3& normal) { _rawNormal = normal; } + void setVelocity(const glm::vec3& velocity) { _velocity = velocity; } + const glm::vec3& getVelocity() const { return _velocity; } void incrementFramesWithoutData() { _numFramesWithoutData++; } void resetFramesWithoutData() { _numFramesWithoutData = 0; } @@ -153,6 +155,7 @@ private: std::vector _fingers; glm::vec3 _rawPosition; glm::vec3 _rawNormal; + glm::vec3 _velocity; bool _isActive; // This has current valid data int _leapID; // the Leap's serial id for this tracked object int _numFramesWithoutData; // after too many frames without data, this tracked object assumed lost.