From 4a171124786acffc9e3dee68be77ee42a2077b3d Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 11:08:09 -0700 Subject: [PATCH 01/13] Kinect moving average filter for hands --- plugins/hifiKinect/src/KinectPlugin.cpp | 50 ++++++++++++++++++++++++- plugins/hifiKinect/src/KinectPlugin.h | 17 +++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index 6d29a261dd..2c9568cb50 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -248,6 +248,7 @@ void KinectPlugin::init() { auto preference = new CheckPreference(KINECT_PLUGIN, "Extra Debugging", debugGetter, debugSetter); preferences->addPreference(preference); } + } bool KinectPlugin::isSupported() const { @@ -493,11 +494,15 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) { //_joints[j].orientation = jointOrientation; if (joints[j].JointType == JointType_HandRight) { static const quat kinectToHandRight = glm::angleAxis(-PI / 2.0f, Vectors::UNIT_Y); - _joints[j].orientation = jointOrientation * kinectToHandRight; + // add moving average of orientation quaternion + glm::quat jointTmp = jointOrientation * kinectToHandRight; + _joints[j].orientation = QMAR(jointTmp); } else if (joints[j].JointType == JointType_HandLeft) { // To transform from Kinect to our LEFT Hand.... Postive 90 deg around Y static const quat kinectToHandLeft = glm::angleAxis(PI / 2.0f, Vectors::UNIT_Y); - _joints[j].orientation = jointOrientation * kinectToHandLeft; + // add moving average of orientation quaternion + glm::quat jointTmp = jointOrientation * kinectToHandLeft; + _joints[j].orientation = QMAL(jointTmp); } else { _joints[j].orientation = jointOrientation; } @@ -644,3 +649,44 @@ void KinectPlugin::InputDevice::clearState() { _poseStateMap[poseIndex] = controller::Pose(); } } + +glm::quat KinectPlugin::QMAL(glm::quat q) +{ + if (glm::dot(_q_barL, q) < 0) + _q_barL = (1 - _deltaL)*_q_barL + -_deltaL*q; + else + _q_barL = (1 - _deltaL)*_q_barL + _deltaL*q; + + _q_barL = glm::normalize(_q_barL); + + + if (_debug) + { + qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; + qDebug() << __FUNCTION__ << "_q_barL = " << _q_barL.x << "," << _q_barL.y << "," << _q_barL.z << "," << _q_barL.w; + } + return _q_barL; +} + + +glm::quat KinectPlugin::QMAR(glm::quat q) +{ + if (glm::dot(_q_barR, q) < 0) + _q_barR = (1 - _deltaR)*_q_barR + -_deltaR*q; + else + _q_barR = (1 - _deltaR)*_q_barR + _deltaR*q; + + _q_barR = glm::normalize(_q_barR); + + + _q_barR = -_q_barR; + + if (_debug) + { + qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; + qDebug() << __FUNCTION__ << "_q_barL = " << _q_barR.x << "," << _q_barR.y << "," << _q_barR.z << "," << _q_barR.w; + } + + return _q_barR; +} + diff --git a/plugins/hifiKinect/src/KinectPlugin.h b/plugins/hifiKinect/src/KinectPlugin.h index 90794fa6b0..16e41cce8d 100644 --- a/plugins/hifiKinect/src/KinectPlugin.h +++ b/plugins/hifiKinect/src/KinectPlugin.h @@ -16,6 +16,12 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif +// glm files + +#include +#include + + // Windows Header Files #include @@ -58,6 +64,14 @@ public: virtual void saveSettings() const override; virtual void loadSettings() override; +private: + // add variables for moving average + + glm::quat _q_barL; + glm::quat _q_barR; + float _deltaL = (float)0.5; + float _deltaR = (float)0.5; + protected: struct KinectJoint { @@ -113,6 +127,9 @@ protected: // Body reader mutable IBodyFrameReader* _bodyFrameReader { nullptr }; + // moving average for a quaternion + glm::quat QMAL(glm::quat q); + glm::quat QMAR(glm::quat q); #endif }; From 001c92416b45848e41a4832ab7dc753f3984de5c Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 11:23:33 -0700 Subject: [PATCH 02/13] clean ups - coding standard --- plugins/hifiKinect/src/KinectPlugin.cpp | 73 ++++++++++++------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index 2c9568cb50..165bca266c 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -248,7 +248,6 @@ void KinectPlugin::init() { auto preference = new CheckPreference(KINECT_PLUGIN, "Extra Debugging", debugGetter, debugSetter); preferences->addPreference(preference); } - } bool KinectPlugin::isSupported() const { @@ -494,15 +493,15 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) { //_joints[j].orientation = jointOrientation; if (joints[j].JointType == JointType_HandRight) { static const quat kinectToHandRight = glm::angleAxis(-PI / 2.0f, Vectors::UNIT_Y); - // add moving average of orientation quaternion - glm::quat jointTmp = jointOrientation * kinectToHandRight; - _joints[j].orientation = QMAR(jointTmp); + // add moving average of orientation quaternion + glm::quat jointTmp = jointOrientation * kinectToHandRight; + _joints[j].orientation = QMAR(jointTmp); } else if (joints[j].JointType == JointType_HandLeft) { // To transform from Kinect to our LEFT Hand.... Postive 90 deg around Y static const quat kinectToHandLeft = glm::angleAxis(PI / 2.0f, Vectors::UNIT_Y); - // add moving average of orientation quaternion - glm::quat jointTmp = jointOrientation * kinectToHandLeft; - _joints[j].orientation = QMAL(jointTmp); + // add moving average of orientation quaternion + glm::quat jointTmp = jointOrientation * kinectToHandLeft; + _joints[j].orientation = QMAL(jointTmp); } else { _joints[j].orientation = jointOrientation; } @@ -652,41 +651,41 @@ void KinectPlugin::InputDevice::clearState() { glm::quat KinectPlugin::QMAL(glm::quat q) { - if (glm::dot(_q_barL, q) < 0) - _q_barL = (1 - _deltaL)*_q_barL + -_deltaL*q; - else - _q_barL = (1 - _deltaL)*_q_barL + _deltaL*q; - - _q_barL = glm::normalize(_q_barL); - - - if (_debug) - { - qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; - qDebug() << __FUNCTION__ << "_q_barL = " << _q_barL.x << "," << _q_barL.y << "," << _q_barL.z << "," << _q_barL.w; - } - return _q_barL; + if (glm::dot(_q_barL, q) < 0) { + _q_barL = (1 - _deltaL) * _q_barL + -_deltaL * q; + } + else { + _q_barL = (1 - _deltaL) * _q_barL + _deltaL * q; + } + + _q_barL = glm::normalize(_q_barL); + if (_debug) + { + qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; + qDebug() << __FUNCTION__ << "_q_barL = " << _q_barL.x << "," << _q_barL.y << "," << _q_barL.z << "," << _q_barL.w; + } + return _q_barL; } glm::quat KinectPlugin::QMAR(glm::quat q) { - if (glm::dot(_q_barR, q) < 0) - _q_barR = (1 - _deltaR)*_q_barR + -_deltaR*q; - else - _q_barR = (1 - _deltaR)*_q_barR + _deltaR*q; - - _q_barR = glm::normalize(_q_barR); - - - _q_barR = -_q_barR; - - if (_debug) - { - qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; - qDebug() << __FUNCTION__ << "_q_barL = " << _q_barR.x << "," << _q_barR.y << "," << _q_barR.z << "," << _q_barR.w; - } + if (glm::dot(_q_barR, q) < 0){ + _q_barR = (1 - _deltaR)*_q_barR + -_deltaR*q; + } + else { + _q_barR = (1 - _deltaR)*_q_barR + _deltaR*q; + } - return _q_barR; + _q_barR = glm::normalize(_q_barR); + _q_barR = -_q_barR; + + if (_debug) + { + qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; + qDebug() << __FUNCTION__ << "_q_barL = " << _q_barR.x << "," << _q_barR.y << "," << _q_barR.z << "," << _q_barR.w; + } + + return _q_barR; } From e6e522464770b0c81188f3cbd31c4f65b467dc37 Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 11:27:58 -0700 Subject: [PATCH 03/13] clean ups - coding standard --- plugins/hifiKinect/src/KinectPlugin.cpp | 14 ++++++-------- plugins/hifiKinect/src/KinectPlugin.h | 16 +++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index 165bca266c..d9888ca8d6 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -653,8 +653,7 @@ glm::quat KinectPlugin::QMAL(glm::quat q) { if (glm::dot(_q_barL, q) < 0) { _q_barL = (1 - _deltaL) * _q_barL + -_deltaL * q; - } - else { + } else { _q_barL = (1 - _deltaL) * _q_barL + _deltaL * q; } @@ -670,15 +669,14 @@ glm::quat KinectPlugin::QMAL(glm::quat q) glm::quat KinectPlugin::QMAR(glm::quat q) { - if (glm::dot(_q_barR, q) < 0){ - _q_barR = (1 - _deltaR)*_q_barR + -_deltaR*q; - } - else { - _q_barR = (1 - _deltaR)*_q_barR + _deltaR*q; + if (glm::dot(_q_barR, q) < 0) { + _q_barR = (1 - _deltaR) * _q_barR + -_deltaR*q; + } else { + _q_barR = (1 - _deltaR) * _q_barR + _deltaR * q; } _q_barR = glm::normalize(_q_barR); - _q_barR = -_q_barR; + _q_barR = -_q_barR; if (_debug) { diff --git a/plugins/hifiKinect/src/KinectPlugin.h b/plugins/hifiKinect/src/KinectPlugin.h index 16e41cce8d..114d4b76aa 100644 --- a/plugins/hifiKinect/src/KinectPlugin.h +++ b/plugins/hifiKinect/src/KinectPlugin.h @@ -16,12 +16,6 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif -// glm files - -#include -#include - - // Windows Header Files #include @@ -65,12 +59,12 @@ public: virtual void loadSettings() override; private: - // add variables for moving average + // add variables for moving average - glm::quat _q_barL; - glm::quat _q_barR; - float _deltaL = (float)0.5; - float _deltaR = (float)0.5; + glm::quat _q_barL; + glm::quat _q_barR; + float _deltaL = 0.5f; + float _deltaR = 0.5f; protected: From de1fdfacca9318359cf99f64b25fcb8d26fb7bd2 Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 16:18:40 -0700 Subject: [PATCH 04/13] made requested changes in PR10147 --- libraries/shared/src/SimpleMovingAverage.h | 7 ++- plugins/hifiKinect/src/KinectPlugin.cpp | 58 ++++++---------------- plugins/hifiKinect/src/KinectPlugin.h | 10 ++-- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/libraries/shared/src/SimpleMovingAverage.h b/libraries/shared/src/SimpleMovingAverage.h index 858ee21371..2559bb36ec 100644 --- a/libraries/shared/src/SimpleMovingAverage.h +++ b/libraries/shared/src/SimpleMovingAverage.h @@ -61,7 +61,7 @@ public: const float WEIGHTING = 1.0f / (float)MAX_NUM_SAMPLES; const float ONE_MINUS_WEIGHTING = 1.0f - WEIGHTING; std::atomic numSamples{ 0 }; - std::atomic average; + T average; void clear() { numSamples = 0; @@ -71,12 +71,15 @@ public: void addSample(T sample) { if (numSamples > 0) { - average = ((float)sample * WEIGHTING) + ((float)average * ONE_MINUS_WEIGHTING); + average = (sample * WEIGHTING) + (average * ONE_MINUS_WEIGHTING); } else { average = sample; } numSamples++; } + + + }; template class ThreadSafeMovingAverage { diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index d9888ca8d6..8f10efed86 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -21,6 +21,7 @@ #include #include + Q_DECLARE_LOGGING_CATEGORY(inputplugins) Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins") @@ -494,14 +495,22 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) { if (joints[j].JointType == JointType_HandRight) { static const quat kinectToHandRight = glm::angleAxis(-PI / 2.0f, Vectors::UNIT_Y); // add moving average of orientation quaternion - glm::quat jointTmp = jointOrientation * kinectToHandRight; - _joints[j].orientation = QMAR(jointTmp); + glm::quat jointSample = jointOrientation * kinectToHandRight; + if (glm::dot(jointSample, _RightHandOrientationAverage.average) < 0) { + jointSample = -jointSample; + } + _RightHandOrientationAverage.addSample(jointSample); + _joints[j].orientation = glm::normalize(_RightHandOrientationAverage.average); } else if (joints[j].JointType == JointType_HandLeft) { // To transform from Kinect to our LEFT Hand.... Postive 90 deg around Y static const quat kinectToHandLeft = glm::angleAxis(PI / 2.0f, Vectors::UNIT_Y); // add moving average of orientation quaternion - glm::quat jointTmp = jointOrientation * kinectToHandLeft; - _joints[j].orientation = QMAL(jointTmp); + glm::quat jointSample = jointOrientation * kinectToHandLeft; + if (glm::dot(jointSample, _LeftHandOrientationAverage.average) < 0) { + jointSample = -jointSample; + } + _LeftHandOrientationAverage.addSample(jointSample); + _joints[j].orientation = glm::normalize(_LeftHandOrientationAverage.average); } else { _joints[j].orientation = jointOrientation; } @@ -647,43 +656,4 @@ void KinectPlugin::InputDevice::clearState() { int poseIndex = KinectJointIndexToPoseIndex((KinectJointIndex)i); _poseStateMap[poseIndex] = controller::Pose(); } -} - -glm::quat KinectPlugin::QMAL(glm::quat q) -{ - if (glm::dot(_q_barL, q) < 0) { - _q_barL = (1 - _deltaL) * _q_barL + -_deltaL * q; - } else { - _q_barL = (1 - _deltaL) * _q_barL + _deltaL * q; - } - - _q_barL = glm::normalize(_q_barL); - if (_debug) - { - qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; - qDebug() << __FUNCTION__ << "_q_barL = " << _q_barL.x << "," << _q_barL.y << "," << _q_barL.z << "," << _q_barL.w; - } - return _q_barL; -} - - -glm::quat KinectPlugin::QMAR(glm::quat q) -{ - if (glm::dot(_q_barR, q) < 0) { - _q_barR = (1 - _deltaR) * _q_barR + -_deltaR*q; - } else { - _q_barR = (1 - _deltaR) * _q_barR + _deltaR * q; - } - - _q_barR = glm::normalize(_q_barR); - _q_barR = -_q_barR; - - if (_debug) - { - qDebug() << __FUNCTION__ << "q = " << q.x << "," << q.y << "," << q.z << "," << q.w; - qDebug() << __FUNCTION__ << "_q_barL = " << _q_barR.x << "," << _q_barR.y << "," << _q_barR.z << "," << _q_barR.w; - } - - return _q_barR; -} - +} \ No newline at end of file diff --git a/plugins/hifiKinect/src/KinectPlugin.h b/plugins/hifiKinect/src/KinectPlugin.h index 114d4b76aa..73cc9f4103 100644 --- a/plugins/hifiKinect/src/KinectPlugin.h +++ b/plugins/hifiKinect/src/KinectPlugin.h @@ -23,6 +23,7 @@ // Kinect Header files #include +#include // Safe release for interfaces template inline void SafeRelease(Interface *& pInterfaceToRelease) { @@ -61,10 +62,8 @@ public: private: // add variables for moving average - glm::quat _q_barL; - glm::quat _q_barR; - float _deltaL = 0.5f; - float _deltaR = 0.5f; + MovingAverage _LeftHandOrientationAverage; + MovingAverage _RightHandOrientationAverage; protected: @@ -121,9 +120,6 @@ protected: // Body reader mutable IBodyFrameReader* _bodyFrameReader { nullptr }; - // moving average for a quaternion - glm::quat QMAL(glm::quat q); - glm::quat QMAR(glm::quat q); #endif }; From e737456dcd40175c3948258d14985f4770ab7de6 Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 16:56:03 -0700 Subject: [PATCH 05/13] used thread safe moving average for the quaternions --- libraries/shared/src/SimpleMovingAverage.h | 2 +- plugins/hifiKinect/src/KinectPlugin.cpp | 8 ++++---- plugins/hifiKinect/src/KinectPlugin.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/shared/src/SimpleMovingAverage.h b/libraries/shared/src/SimpleMovingAverage.h index 2559bb36ec..783c13d4b1 100644 --- a/libraries/shared/src/SimpleMovingAverage.h +++ b/libraries/shared/src/SimpleMovingAverage.h @@ -61,7 +61,7 @@ public: const float WEIGHTING = 1.0f / (float)MAX_NUM_SAMPLES; const float ONE_MINUS_WEIGHTING = 1.0f - WEIGHTING; std::atomic numSamples{ 0 }; - T average; + std::atomic average; void clear() { numSamples = 0; diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index 8f10efed86..a6bf5df9dd 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -496,21 +496,21 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) { static const quat kinectToHandRight = glm::angleAxis(-PI / 2.0f, Vectors::UNIT_Y); // add moving average of orientation quaternion glm::quat jointSample = jointOrientation * kinectToHandRight; - if (glm::dot(jointSample, _RightHandOrientationAverage.average) < 0) { + if (glm::dot(jointSample, _RightHandOrientationAverage.getAverage()) < 0) { jointSample = -jointSample; } _RightHandOrientationAverage.addSample(jointSample); - _joints[j].orientation = glm::normalize(_RightHandOrientationAverage.average); + _joints[j].orientation = glm::normalize(_RightHandOrientationAverage.getAverage()); } else if (joints[j].JointType == JointType_HandLeft) { // To transform from Kinect to our LEFT Hand.... Postive 90 deg around Y static const quat kinectToHandLeft = glm::angleAxis(PI / 2.0f, Vectors::UNIT_Y); // add moving average of orientation quaternion glm::quat jointSample = jointOrientation * kinectToHandLeft; - if (glm::dot(jointSample, _LeftHandOrientationAverage.average) < 0) { + if (glm::dot(jointSample, _LeftHandOrientationAverage.getAverage()) < 0) { jointSample = -jointSample; } _LeftHandOrientationAverage.addSample(jointSample); - _joints[j].orientation = glm::normalize(_LeftHandOrientationAverage.average); + _joints[j].orientation = glm::normalize(_LeftHandOrientationAverage.getAverage()); } else { _joints[j].orientation = jointOrientation; } diff --git a/plugins/hifiKinect/src/KinectPlugin.h b/plugins/hifiKinect/src/KinectPlugin.h index 73cc9f4103..68ba1a7b86 100644 --- a/plugins/hifiKinect/src/KinectPlugin.h +++ b/plugins/hifiKinect/src/KinectPlugin.h @@ -62,8 +62,8 @@ public: private: // add variables for moving average - MovingAverage _LeftHandOrientationAverage; - MovingAverage _RightHandOrientationAverage; + ThreadSafeMovingAverage _LeftHandOrientationAverage; + ThreadSafeMovingAverage _RightHandOrientationAverage; protected: From c628b23895336976b38c21eaeac6d81ed07257a2 Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 17:21:58 -0700 Subject: [PATCH 06/13] removed whitespace --- libraries/shared/src/SimpleMovingAverage.h | 3 --- plugins/hifiKinect/src/KinectPlugin.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/libraries/shared/src/SimpleMovingAverage.h b/libraries/shared/src/SimpleMovingAverage.h index 783c13d4b1..0404ab9646 100644 --- a/libraries/shared/src/SimpleMovingAverage.h +++ b/libraries/shared/src/SimpleMovingAverage.h @@ -77,9 +77,6 @@ public: } numSamples++; } - - - }; template class ThreadSafeMovingAverage { diff --git a/plugins/hifiKinect/src/KinectPlugin.cpp b/plugins/hifiKinect/src/KinectPlugin.cpp index a6bf5df9dd..3a36be0982 100644 --- a/plugins/hifiKinect/src/KinectPlugin.cpp +++ b/plugins/hifiKinect/src/KinectPlugin.cpp @@ -21,11 +21,9 @@ #include #include - Q_DECLARE_LOGGING_CATEGORY(inputplugins) Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins") - const char* KinectPlugin::NAME = "Kinect"; const char* KinectPlugin::KINECT_ID_STRING = "Kinect"; From ead4793392145d83177efc89700ac4be2c1e639b Mon Sep 17 00:00:00 2001 From: Al Bernstein Date: Thu, 6 Apr 2017 17:26:12 -0700 Subject: [PATCH 07/13] removed whitespace --- plugins/hifiKinect/src/KinectPlugin.h | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/hifiKinect/src/KinectPlugin.h b/plugins/hifiKinect/src/KinectPlugin.h index 68ba1a7b86..158e66ee62 100644 --- a/plugins/hifiKinect/src/KinectPlugin.h +++ b/plugins/hifiKinect/src/KinectPlugin.h @@ -61,7 +61,6 @@ public: private: // add variables for moving average - ThreadSafeMovingAverage _LeftHandOrientationAverage; ThreadSafeMovingAverage _RightHandOrientationAverage; From d25c0ace4440e992c1755bfea3910de66b87a4e6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 11 Apr 2017 15:02:27 -0700 Subject: [PATCH 08/13] AvatarMixer sends min updates for out-of-view avatars --- assignment-client/src/avatars/AvatarMixerSlave.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/avatars/AvatarMixerSlave.cpp b/assignment-client/src/avatars/AvatarMixerSlave.cpp index 05de209e81..c4497a1066 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlave.cpp @@ -325,7 +325,7 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) { _stats.overBudgetAvatars++; detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::NoData; } else if (!isInView) { - detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::NoData; + detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::MinimumData; nodeData->incrementAvatarOutOfView(); } else { detail = distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO From b8a3c856be0e697ef34f8d01731a2ed0855c4cd3 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 11 Apr 2017 15:03:11 -0700 Subject: [PATCH 09/13] update model transform even when out of view --- interface/src/avatar/SkeletonModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index d7dd93cedf..0c11fa456d 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -240,8 +240,8 @@ void SkeletonModel::updateAttitude() { // Called by Avatar::simulate after it has set the joint states (fullUpdate true if changed), // but just before head has been simulated. void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { + updateAttitude(); if (fullUpdate) { - updateAttitude(); setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients()); Model::simulate(deltaTime, fullUpdate); From 695c55bc3dfa6cd46d82b32ddfb3194447acb605 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 12 Apr 2017 03:44:24 +0200 Subject: [PATCH 10/13] fix teleport cool-in, added missing TARGETTING state and some ESLINT style fixes --- scripts/system/controllers/teleport.js | 63 ++++++++++++++------------ 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 33c0b3116e..dcbcaeb621 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -29,13 +29,13 @@ var COLORS_TELEPORT_SEAT = { red: 255, green: 0, blue: 170 -} +}; var COLORS_TELEPORT_CAN_TELEPORT = { red: 97, green: 247, blue: 255 -} +}; var COLORS_TELEPORT_CANNOT_TELEPORT = { red: 0, @@ -52,7 +52,7 @@ var COLORS_TELEPORT_CANCEL = { var TELEPORT_CANCEL_RANGE = 1; var COOL_IN_DURATION = 500; -const handInfo = { +var handInfo = { right: { controllerInput: Controller.Standard.RightHand }, @@ -80,7 +80,7 @@ function Trigger(hand) { this.down = function() { var down = _this.buttonValue === 1 ? 1.0 : 0.0; - return down + return down; }; } @@ -90,8 +90,9 @@ var ignoredEntities = []; var TELEPORTER_STATES = { IDLE: 'idle', COOL_IN: 'cool_in', + TARGETTING: 'targetting', TARGETTING_INVALID: 'targetting_invalid', -} +}; var TARGET = { NONE: 'none', // Not currently targetting anything @@ -99,7 +100,7 @@ var TARGET = { INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.) SURFACE: 'surface', // The current target is a valid surface SEAT: 'seat', // The current target is a seat -} +}; function Teleporter() { var _this = this; @@ -114,8 +115,8 @@ function Teleporter() { this.updateConnected = null; this.activeHand = null; - this.telporterMappingInternalName = 'Hifi-Teleporter-Internal-Dev-' + Math.random(); - this.teleportMappingInternal = Controller.newMapping(this.telporterMappingInternalName); + this.teleporterMappingInternalName = 'Hifi-Teleporter-Internal-Dev-' + Math.random(); + this.teleportMappingInternal = Controller.newMapping(this.teleporterMappingInternalName); // Setup overlays this.cancelOverlay = Overlays.addOverlay("model", { @@ -135,11 +136,11 @@ function Teleporter() { }); this.enableMappings = function() { - Controller.enableMapping(this.telporterMappingInternalName); + Controller.enableMapping(this.teleporterMappingInternalName); }; this.disableMappings = function() { - Controller.disableMapping(teleporter.telporterMappingInternalName); + Controller.disableMapping(teleporter.teleporterMappingInternalName); }; this.cleanup = function() { @@ -179,7 +180,7 @@ function Teleporter() { if (_this.state === TELEPORTER_STATES.COOL_IN) { _this.state = TELEPORTER_STATES.TARGETTING; } - }, COOL_IN_DURATION) + }, COOL_IN_DURATION); this.activeHand = hand; this.enableMappings(); @@ -203,13 +204,13 @@ function Teleporter() { }; this.deleteOverlayBeams = function() { - for (key in this.overlayLines) { + for (var key in this.overlayLines) { if (this.overlayLines[key] !== null) { Overlays.deleteOverlay(this.overlayLines[key]); this.overlayLines[key] = null; } } - } + }; this.update = function() { if (_this.state === TELEPORTER_STATES.IDLE) { @@ -272,7 +273,8 @@ function Teleporter() { this.hideCancelOverlay(); this.hideSeatOverlay(); - this.updateLineOverlay(_this.activeHand, pickRay.origin, intersection.intersection, COLORS_TELEPORT_CAN_TELEPORT); + this.updateLineOverlay(_this.activeHand, pickRay.origin, intersection.intersection, + COLORS_TELEPORT_CAN_TELEPORT); this.updateDestinationOverlay(this.targetOverlay, intersection); } } else if (teleportLocationType === TARGET.SEAT) { @@ -284,13 +286,15 @@ function Teleporter() { } - if (((_this.activeHand == 'left' ? leftPad : rightPad).buttonValue === 0) && inTeleportMode === true) { + if (((_this.activeHand === 'left' ? leftPad : rightPad).buttonValue === 0) && inTeleportMode === true) { + // remember the state before we exit teleport mode and set it back to IDLE + var previousState = this.state; this.exitTeleportMode(); this.hideCancelOverlay(); this.hideTargetOverlay(); this.hideSeatOverlay(); - if (teleportLocationType === TARGET.NONE || teleportLocationType === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) { + if (teleportLocationType === TARGET.NONE || teleportLocationType === TARGET.INVALID || previousState === TELEPORTER_STATES.COOL_IN) { // Do nothing } else if (teleportLocationType === TARGET.SEAT) { Entities.callEntityMethod(intersection.entityID, 'sit'); @@ -321,7 +325,7 @@ function Teleporter() { this.overlayLines[hand] = Overlays.addOverlay("line3d", lineProperties); } else { - var success = Overlays.editOverlay(this.overlayLines[hand], { + Overlays.editOverlay(this.overlayLines[hand], { start: closePoint, end: farPoint, color: color @@ -361,7 +365,7 @@ function Teleporter() { }; } -//related to repositioning the avatar after you teleport +// related to repositioning the avatar after you teleport function getAvatarFootOffset() { var data = getJointData(); var upperLeg, lowerLeg, foot, toe, toeTop; @@ -384,14 +388,14 @@ function getAvatarFootOffset() { var offset = upperLeg + lowerLeg + foot + toe + toeTop; offset = offset / 100; return offset; -}; +} function getJointData() { var allJointData = []; var jointNames = MyAvatar.jointNames; jointNames.forEach(function(joint, index) { var translation = MyAvatar.getJointTranslation(index); - var rotation = MyAvatar.getJointRotation(index) + var rotation = MyAvatar.getJointRotation(index); allJointData.push({ joint: joint, index: index, @@ -401,7 +405,7 @@ function getJointData() { }); return allJointData; -}; +} var leftPad = new ThumbPad('left'); var rightPad = new ThumbPad('right'); @@ -420,7 +424,7 @@ function isMoving() { } else { return false; } -}; +} function parseJSON(json) { try { @@ -433,7 +437,7 @@ function parseJSON(json) { // point that is being intersected with is looked at. If this normal is more // than MAX_ANGLE_FROM_UP_TO_TELEPORT degrees from <0, 1, 0> (straight up), then // you can't teleport there. -const MAX_ANGLE_FROM_UP_TO_TELEPORT = 70; +var MAX_ANGLE_FROM_UP_TO_TELEPORT = 70; function getTeleportTargetType(intersection) { if (!intersection.intersects) { return TARGET.NONE; @@ -465,7 +469,7 @@ function getTeleportTargetType(intersection) { } else { return TARGET.SURFACE; } -}; +} function registerMappings() { mappingName = 'Hifi-Teleporter-Dev-' + Math.random(); @@ -487,7 +491,7 @@ function registerMappings() { if (isMoving() === true) { return; } - teleporter.enterTeleportMode('left') + teleporter.enterTeleportMode('left'); return; }); teleportMapping.from(Controller.Standard.RightPrimaryThumb) @@ -502,10 +506,10 @@ function registerMappings() { return; } - teleporter.enterTeleportMode('right') + teleporter.enterTeleportMode('right'); return; }); -}; +} registerMappings(); @@ -521,7 +525,6 @@ Script.scriptEnding.connect(cleanup); var isDisabled = false; var handleTeleportMessages = function(channel, message, sender) { - var data; if (sender === MyAvatar.sessionUUID) { if (channel === 'Hifi-Teleport-Disabler') { if (message === 'both') { @@ -531,7 +534,7 @@ var handleTeleportMessages = function(channel, message, sender) { isDisabled = 'left'; } if (message === 'right') { - isDisabled = 'right' + isDisabled = 'right'; } if (message === 'none') { isDisabled = false; @@ -545,7 +548,7 @@ var handleTeleportMessages = function(channel, message, sender) { } } } -} +}; Messages.subscribe('Hifi-Teleport-Disabler'); Messages.subscribe('Hifi-Teleport-Ignore-Add'); From 9376ac646f71fb4454aa3f64c034cc36cf0c2dcd Mon Sep 17 00:00:00 2001 From: David Kelly Date: Wed, 12 Apr 2017 08:24:46 -0700 Subject: [PATCH 11/13] offline people sort change --- interface/resources/qml/hifi/Pal.qml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index 1e72d71b18..8dfc277f05 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -1401,6 +1401,13 @@ Rectangle { var selectedIDs = getSelectedConnectionsUserNames(); connectionsUserModelData.sort(function (a, b) { var aValue = a[sortProperty].toString().toLowerCase(), bValue = b[sortProperty].toString().toLowerCase(); + if (!aValue && !bValue) { + return 0; + } else if (!aValue) { + return after; + } else if (!bValue) { + return before + } switch (true) { case (aValue < bValue): return before; case (aValue > bValue): return after; From 058a5b14a42c14e8038e5dc3e38f00df93b347af Mon Sep 17 00:00:00 2001 From: David Kelly Date: Wed, 12 Apr 2017 10:22:40 -0700 Subject: [PATCH 12/13] damn linter didn't run - vimrc work ahead... --- interface/resources/qml/hifi/Pal.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index 8dfc277f05..833e641b09 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -1406,7 +1406,7 @@ Rectangle { } else if (!aValue) { return after; } else if (!bValue) { - return before + return before; } switch (true) { case (aValue < bValue): return before; From 39587d53084a4349b7b6c21b9e18c392239e8f36 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 12 Apr 2017 10:54:28 -0700 Subject: [PATCH 13/13] lol --- interface/src/avatar/Head.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 4c6aa10d12..282acf6bf5 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -77,7 +77,7 @@ void Head::simulate(float deltaTime, bool isMine) { float audioLoudness = 0.0f; if (_owningAvatar) { - _owningAvatar->getAudioLoudness(); + audioLoudness = _owningAvatar->getAudioLoudness(); } // Update audio trailing average for rendering facial animations