From 621ca7d2b4f44371cfa0b0cf47b443bec9926bc2 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 18:46:24 -0700 Subject: [PATCH] more work on the mode function --- interface/src/avatar/MyAvatar.cpp | 16 +++++++++++----- interface/src/avatar/MyAvatar.h | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index f33bd41f16..06b788a002 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -3112,11 +3112,17 @@ static bool headAngularVelocityBelowThreshold(glm::vec3 angularVelocity) { << " z: " << angularVelocity.z; return isBelowThreshold; } + /* -bool MyAvatar::withinThresholdOfStandingHeightMode(float newReading) { +bool MyAvatar::isWithinThresholdHeightMode(float newMode, float newReading) { + const float MODE_HEIGHT_THRESHOLD = 0.3f; + return newMode < +} +*/ +float MyAvatar::computeStandingHeightMode(float newReading) { const float CENTIMETERS_PER_METER = 100.0f; const float MODE_CORRECTION_FACTOR = 0.02f; - const float MODE_HEIGHT_THRESHOLD = 0.3f; + //first add the number to the mode array for (int i = 0; i < (SIZE_OF_MODE_ARRAY - 1); i++) { @@ -3143,9 +3149,9 @@ bool MyAvatar::withinThresholdOfStandingHeightMode(float newReading) { return (newReading - MODE_CORRECTION_FACTOR); } } - //return (diffFromMode < MODE_HEIGHT_THRESHOLD); + return _currentMode; } -*/ + float MyAvatar::getUserHeight() const { return _userHeight.get(); } @@ -3377,7 +3383,7 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, } headAngularVelocityBelowThreshold(myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getAngularVelocity()); - + float temp = myAvatar.computeStandingHeightMode(0.01f); if (!isActive(Horizontal) && (getForceActivateHorizontal() || (!withinBaseOfSupport(myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getTranslation()) && headAngularVelocityBelowThreshold(myAvatar.getControllerPoseInAvatarFrame(controller::Action::HEAD).getAngularVelocity())))){ //&& diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index abe957f8cd..dddc229171 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -49,8 +49,6 @@ enum AudioListenerMode { CUSTOM }; -const int SIZE_OF_MODE_ARRAY = 50; - Q_DECLARE_METATYPE(AudioListenerMode); class MyAvatar : public Avatar { @@ -1027,7 +1025,8 @@ public: bool isReadyForPhysics() const; - bool withinThresholdOfStandingHeightMode(float newReading); + float computeStandingHeightMode(float newReading); + //bool isWithinThresholdHeightMode(float newReading); public slots: @@ -1634,6 +1633,7 @@ private: // load avatar scripts once when rig is ready bool _shouldLoadScripts { false }; + static const int SIZE_OF_MODE_ARRAY = 50; bool _haveReceivedHeightLimitsFromDomain = { false }; int _heightModeArray[SIZE_OF_MODE_ARRAY]; int _currentMode = 0;