From 070a517423af7e6304f3ddc50564b0e65dd01bd0 Mon Sep 17 00:00:00 2001 From: amantley Date: Fri, 19 Oct 2018 18:07:03 -0700 Subject: [PATCH] changed the recenterModel variables to userRecenterModel --- interface/resources/qml/hifi/AvatarApp.qml | 2 +- .../resources/qml/hifi/avatarapp/Settings.qml | 17 ++- interface/src/avatar/MyAvatar.cpp | 108 +++++++++--------- interface/src/avatar/MyAvatar.h | 20 ++-- scripts/system/avatarapp.js | 18 +-- 5 files changed, 80 insertions(+), 85 deletions(-) diff --git a/interface/resources/qml/hifi/AvatarApp.qml b/interface/resources/qml/hifi/AvatarApp.qml index 2d714c0d33..549db20ab1 100644 --- a/interface/resources/qml/hifi/AvatarApp.qml +++ b/interface/resources/qml/hifi/AvatarApp.qml @@ -252,7 +252,7 @@ Rectangle { var avatarSettings = { dominantHand : settings.dominantHandIsLeft ? 'left' : 'right', collisionsEnabled : settings.avatarCollisionsOn, - recenterModel : settings.avatarRecenterModelOn, + userRecenterModel : settings.avatarRecenterModelOn, animGraphOverrideUrl : settings.avatarAnimationOverrideJSON, collisionSoundUrl : settings.avatarCollisionSoundUrl }; diff --git a/interface/resources/qml/hifi/avatarapp/Settings.qml b/interface/resources/qml/hifi/avatarapp/Settings.qml index cd71442bca..eb994b86de 100644 --- a/interface/resources/qml/hifi/avatarapp/Settings.qml +++ b/interface/resources/qml/hifi/avatarapp/Settings.qml @@ -20,7 +20,7 @@ Rectangle { property real scaleValue: scaleSlider.value / 10 property alias dominantHandIsLeft: leftHandRadioButton.checked property alias avatarCollisionsOn: collisionsEnabledRadiobutton.checked - property alias avatarRecenterModelOn: boxy.currentIndex + property alias avatarRecenterModelOn: userModelComboBox.currentIndex property alias avatarAnimationOverrideJSON: avatarAnimationUrlInputText.text property alias avatarAnimationJSON: avatarAnimationUrlInputText.placeholderText property alias avatarCollisionSoundUrl: avatarCollisionSoundUrlInputText.text @@ -49,8 +49,7 @@ Rectangle { avatarAnimationJSON = settings.animGraphUrl; avatarAnimationOverrideJSON = settings.animGraphOverrideUrl; avatarCollisionSoundUrl = settings.collisionSoundUrl; - print("values " + avatarRecenterModelOn + " " + settings.recenterModel); - avatarRecenterModelOn = settings.recenterModel; + avatarRecenterModelOn = settings.userRecenterModel; visible = true; } @@ -294,22 +293,21 @@ Rectangle { } // TextStyle9 - + RalewaySemiBold { size: 17; Layout.row: 2 Layout.column: 0 - text: "Sitting State" + text: "User Model:" } - ButtonGroup { - id: sitStand - } // sit stand combo box HifiControlsUit.ComboBox { - id: boxy + Layout.row: 2 + Layout.column: 1 + id: userModelComboBox comboBox.textRole: "text" currentIndex: 2 model: ListModel { @@ -325,7 +323,6 @@ Rectangle { console.debug("line 2") } } - } ColumnLayout { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 14829a7b2e..0b58c2c158 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -470,57 +470,58 @@ void MyAvatar::updateSitStandState(float newHeightReading, float dt) { const float SITTING_TIMEOUT = 4.0f; // 4 seconds const float STANDING_TIMEOUT = 0.3333f; // 1/3 second const float SITTING_UPPER_BOUND = 1.52f; - - if (!getIsSitStandStateLocked() && !getIsAway() && qApp->isHMDMode()) { - if (getIsInSittingState()) { - if (newHeightReading > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) { - // if we recenter upwards then no longer in sitting state - _sitStandStateTimer += dt; - if (_sitStandStateTimer > STANDING_TIMEOUT) { - _averageUserHeightSensorSpace = newHeightReading; - _tippingPoint = newHeightReading; - setIsInSittingState(false); - } - } else if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) { - // if we are mis labelled as sitting but we are standing in the real world this will - // make sure that a real sit is still recognized so we won't be stuck in sitting unable to change state - _sitStandStateTimer += dt; - if (_sitStandStateTimer > SITTING_TIMEOUT) { - _averageUserHeightSensorSpace = newHeightReading; - _tippingPoint = newHeightReading; - // here we stay in sit state but reset the average height - setIsInSittingState(true); + if (!getIsSitStandStateLocked()) { + if (!getIsAway() && qApp->isHMDMode()) { + if (getIsInSittingState()) { + if (newHeightReading > (STANDING_HEIGHT_MULTIPLE * _tippingPoint)) { + // if we recenter upwards then no longer in sitting state + _sitStandStateTimer += dt; + if (_sitStandStateTimer > STANDING_TIMEOUT) { + _averageUserHeightSensorSpace = newHeightReading; + _tippingPoint = newHeightReading; + setIsInSittingState(false); + } + } else if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) { + // if we are mis labelled as sitting but we are standing in the real world this will + // make sure that a real sit is still recognized so we won't be stuck in sitting unable to change state + _sitStandStateTimer += dt; + if (_sitStandStateTimer > SITTING_TIMEOUT) { + _averageUserHeightSensorSpace = newHeightReading; + _tippingPoint = newHeightReading; + // here we stay in sit state but reset the average height + setIsInSittingState(true); + } + } else { + // sanity check if average height greater than 5ft they are not sitting(or get off your dangerous barstool please) + if (_averageUserHeightSensorSpace > SITTING_UPPER_BOUND) { + setIsInSittingState(false); + } else { + // tipping point is average height when sitting. + _tippingPoint = _averageUserHeightSensorSpace; + _sitStandStateTimer = 0.0f; + } } } else { - // sanity check if average height greater than 5ft they are not sitting(or get off your dangerous barstool please) - if (_averageUserHeightSensorSpace > SITTING_UPPER_BOUND) { - setIsInSittingState(false); + // in the standing state + if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) { + _sitStandStateTimer += dt; + if (_sitStandStateTimer > SITTING_TIMEOUT) { + _averageUserHeightSensorSpace = newHeightReading; + _tippingPoint = newHeightReading; + setIsInSittingState(true); + } } else { - // tipping point is average height when sitting. - _tippingPoint = _averageUserHeightSensorSpace; + // use the mode height for the tipping point when we are standing. + _tippingPoint = getCurrentStandingHeight(); _sitStandStateTimer = 0.0f; } } } else { - // in the standing state - if (newHeightReading < (SITTING_HEIGHT_MULTIPLE * _tippingPoint)) { - _sitStandStateTimer += dt; - if (_sitStandStateTimer > SITTING_TIMEOUT) { - _averageUserHeightSensorSpace = newHeightReading; - _tippingPoint = newHeightReading; - setIsInSittingState(true); - } - } else { - // use the mode height for the tipping point when we are standing. - _tippingPoint = getCurrentStandingHeight(); - _sitStandStateTimer = 0.0f; - } + //if you are away then reset the average and set state to standing. + _averageUserHeightSensorSpace = _userHeight.get(); + _tippingPoint = _userHeight.get(); + setIsInSittingState(false); } - } else { - // if you are away then reset the average and set state to standing. - _averageUserHeightSensorSpace = _userHeight.get(); - _tippingPoint = _userHeight.get(); - setIsInSittingState(false); } } @@ -533,7 +534,7 @@ void MyAvatar::update(float deltaTime) { float tau = deltaTime / HMD_FACING_TIMESCALE; setHipToHandController(computeHandAzimuth()); - //qCDebug(interfaceapp) << " the sit state is " << _isInSittingState.get() << " the lock is " << _lockSitStandState.get(); + qCDebug(interfaceapp) << " the sit state is " << _isInSittingState.get() << " the lock is " << _lockSitStandState.get(); // put the average hand azimuth into sensor space. // then mix it with head facing direction to determine rotation recenter @@ -3867,8 +3868,8 @@ bool MyAvatar::getIsInSittingState() const { return _isInSittingState.get(); } -MyAvatar::SitStandModelType MyAvatar::getRecenterModel() const { - return _recenterModel.get(); +MyAvatar::SitStandModelType MyAvatar::getUserRecenterModel() const { + return _userRecenterModel.get(); } bool MyAvatar::getIsSitStandStateLocked() const { @@ -3907,25 +3908,25 @@ void MyAvatar::setIsInSittingState(bool isSitting) { setCenterOfGravityModelEnabled(true); } setSitStandStateChange(true); - - emit sittingEnabledChanged(isSitting); } -void MyAvatar::setRecenterModel(MyAvatar::SitStandModelType modelName) { +void MyAvatar::setUserRecenterModel(MyAvatar::SitStandModelType modelName) { + + _userRecenterModel.set(modelName); - _recenterModel.set(modelName); - //int temp = 0; - qCDebug(interfaceapp) << "recenter property changed " << modelName; switch (modelName) { case SitStandModelType::ForceSit: + setHMDLeanRecenterEnabled(true); setIsInSittingState(true); setIsSitStandStateLocked(true); break; case SitStandModelType::ForceStand: + setHMDLeanRecenterEnabled(true); setIsInSittingState(false); setIsSitStandStateLocked(true); break; case SitStandModelType::Auto: + setHMDLeanRecenterEnabled(true); setIsInSittingState(false); setIsSitStandStateLocked(false); break; @@ -3936,7 +3937,7 @@ void MyAvatar::setRecenterModel(MyAvatar::SitStandModelType modelName) { break; } qCDebug(interfaceapp) << "recenter property changed " << modelName << " sit " << _isInSittingState.get() << " lock " << _lockSitStandState.get(); - emit recenterModelChanged((int)modelName); + emit userRecenterModelChanged((int)modelName); } void MyAvatar::setIsSitStandStateLocked(bool isLocked) { @@ -3949,7 +3950,6 @@ void MyAvatar::setIsSitStandStateLocked(bool isLocked) { // always start the auto transition mode in standing state. setIsInSittingState(false); } - emit sitStandStateLockEnabledChanged(isLocked); } void MyAvatar::setWalkSpeed(float value) { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index c59bdcd66d..691ab80530 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -143,7 +143,7 @@ class MyAvatar : public Avatar { * @property {number} walkBackwardSpeed * @property {number} sprintSpeed * @property {number} isInSittingState - * @property {number} recenterModel + * @property {number} userRecenterModel * * @property {Vec3} skeletonOffset - Can be used to apply a translation offset between the avatar's position and the * registration point of the 3D model. @@ -245,7 +245,7 @@ class MyAvatar : public Avatar { Q_PROPERTY(float walkBackwardSpeed READ getWalkBackwardSpeed WRITE setWalkBackwardSpeed); Q_PROPERTY(float sprintSpeed READ getSprintSpeed WRITE setSprintSpeed); Q_PROPERTY(bool isInSittingState READ getIsInSittingState WRITE setIsInSittingState); - Q_PROPERTY(MyAvatar::SitStandModelType recenterModel READ getRecenterModel WRITE setRecenterModel); + Q_PROPERTY(MyAvatar::SitStandModelType userRecenterModel READ getUserRecenterModel WRITE setUserRecenterModel); Q_PROPERTY(bool isSitStandStateLocked READ getIsSitStandStateLocked WRITE setIsSitStandStateLocked); const QString DOMINANT_LEFT_HAND = "left"; @@ -1117,8 +1117,8 @@ public: bool getIsInWalkingState() const; void setIsInSittingState(bool isSitting); bool getIsInSittingState() const; - void setRecenterModel(MyAvatar::SitStandModelType modelName); - MyAvatar::SitStandModelType getRecenterModel() const; + void setUserRecenterModel(MyAvatar::SitStandModelType modelName); + MyAvatar::SitStandModelType getUserRecenterModel() const; void setIsSitStandStateLocked(bool isLocked); bool getIsSitStandStateLocked() const; void setWalkSpeed(float value); @@ -1545,11 +1545,11 @@ signals: /**jsdoc * Triggered when the recenter model is changed - * @function MyAvatar.recenterModelChanged - * @param {int} modeltype - * @ + * @function MyAvatar.userRecenterModelChanged + * @param {int} userRecenteringModeltype + * @returns {Signal} */ - void recenterModelChanged(int modelName); + void userRecenterModelChanged(int modelName); /**jsdoc * Triggered when the sit state is enabled or disabled @@ -1850,8 +1850,6 @@ private: void updateChildCauterization(SpatiallyNestablePointer object, bool cauterize); - - // height of user in sensor space, when standing erect. ThreadSafeValueCache _userHeight { DEFAULT_AVATAR_HEIGHT }; float _averageUserHeightSensorSpace { _userHeight.get() }; @@ -1865,7 +1863,7 @@ private: float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR }; bool _isInWalkingState { false }; ThreadSafeValueCache _isInSittingState { false }; - ThreadSafeValueCache _recenterModel { MyAvatar::SitStandModelType::Auto }; + ThreadSafeValueCache _userRecenterModel { MyAvatar::SitStandModelType::Auto }; float _sitStandStateTimer { 0.0f }; float _squatTimer { 0.0f }; float _tippingPoint { _userHeight.get() }; diff --git a/scripts/system/avatarapp.js b/scripts/system/avatarapp.js index d64454c534..b30f87c944 100644 --- a/scripts/system/avatarapp.js +++ b/scripts/system/avatarapp.js @@ -64,7 +64,7 @@ function getMyAvatarSettings() { return { dominantHand: MyAvatar.getDominantHand(), collisionsEnabled : MyAvatar.getCollisionsEnabled(), - recenterModel: MyAvatar.recenterModel, + userRecenterModel: MyAvatar.userRecenterModel, collisionSoundUrl : MyAvatar.collisionSoundURL, animGraphUrl: MyAvatar.getAnimGraphUrl(), animGraphOverrideUrl : MyAvatar.getAnimGraphOverrideUrl(), @@ -137,11 +137,11 @@ function onCollisionsEnabledChanged(enabled) { } } -function onRecenterModelChanged(modelName) { - if (currentAvatarSettings.recenterModel !== modelName) { - currentAvatarSettings.recenterModel = modelName; - print("emit recenter model changed"); - sendToQml({ 'method': 'settingChanged', 'name': 'recenterModel', 'value': modelName }) +function onUserRecenterModelChanged(modelName) { + if (currentAvatarSettings.userRecenterModel !== modelName) { + currentAvatarSettings.userRecenterModel = modelName; + print("emit user recenter model changed"); + sendToQml({ 'method': 'settingChanged', 'name': 'userRecenterModel', 'value': modelName }) } } @@ -322,7 +322,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See currentAvatar.avatarScale = message.avatarScale; MyAvatar.setDominantHand(message.settings.dominantHand); MyAvatar.setCollisionsEnabled(message.settings.collisionsEnabled); - MyAvatar.recenterModel = message.settings.recenterModel; + MyAvatar.userRecenterModel = message.settings.userRecenterModel; MyAvatar.collisionSoundURL = message.settings.collisionSoundUrl; MyAvatar.setAnimGraphOverrideUrl(message.settings.animGraphOverrideUrl); settings = getMyAvatarSettings(); @@ -515,7 +515,7 @@ function off() { MyAvatar.skeletonModelURLChanged.disconnect(onSkeletonModelURLChanged); MyAvatar.dominantHandChanged.disconnect(onDominantHandChanged); MyAvatar.collisionsEnabledChanged.disconnect(onCollisionsEnabledChanged); - MyAvatar.recenterModelChanged.disconnect(onRecenterModelChanged); + MyAvatar.userRecenterModelChanged.disconnect(onUserRecenterModelChanged); MyAvatar.newCollisionSoundURL.disconnect(onNewCollisionSoundUrl); MyAvatar.animGraphUrlChanged.disconnect(onAnimGraphUrlChanged); MyAvatar.targetScaleChanged.disconnect(onTargetScaleChanged); @@ -530,7 +530,7 @@ function on() { MyAvatar.skeletonModelURLChanged.connect(onSkeletonModelURLChanged); MyAvatar.dominantHandChanged.connect(onDominantHandChanged); MyAvatar.collisionsEnabledChanged.connect(onCollisionsEnabledChanged); - MyAvatar.recenterModelChanged.connect(onRecenterModelChanged); + MyAvatar.userRecenterModelChanged.connect(onUserRecenterModelChanged); MyAvatar.newCollisionSoundURL.connect(onNewCollisionSoundUrl); MyAvatar.animGraphUrlChanged.connect(onAnimGraphUrlChanged); MyAvatar.targetScaleChanged.connect(onTargetScaleChanged);