Friendlier and more understandable naming.

This commit is contained in:
Saracen 2019-04-11 03:57:34 +01:00
parent eb8e912808
commit 3dde53f743
5 changed files with 21 additions and 21 deletions

View file

@ -168,7 +168,7 @@ MyAvatar::MyAvatar(QThread* thread) :
_displayNameSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "displayName", ""), _displayNameSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "displayName", ""),
_collisionSoundURLSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "collisionSoundURL", QUrl(_collisionSoundURL)), _collisionSoundURLSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "collisionSoundURL", QUrl(_collisionSoundURL)),
_useSnapTurnSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "useSnapTurn", _useSnapTurn), _useSnapTurnSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "useSnapTurn", _useSnapTurn),
_useFallHeightThresholdSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "useFallHeightThreshold", _useFallHeightThreshold), _hoverWhenUnsupportedSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "hoverWhenUnsupported", _hoverWhenUnsupported),
_userHeightSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "userHeight", DEFAULT_AVATAR_HEIGHT), _userHeightSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "userHeight", DEFAULT_AVATAR_HEIGHT),
_flyingHMDSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "flyingHMD", _flyingPrefHMD), _flyingHMDSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "flyingHMD", _flyingPrefHMD),
_movementReferenceSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "movementReference", _movementReference), _movementReferenceSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "movementReference", _movementReference),
@ -957,7 +957,7 @@ void MyAvatar::simulate(float deltaTime, bool inView) {
bool collisionlessAllowed = zoneInteractionProperties.second; bool collisionlessAllowed = zoneInteractionProperties.second;
_characterController.setZoneFlyingAllowed(zoneAllowsFlying || !isPhysicsEnabled); _characterController.setZoneFlyingAllowed(zoneAllowsFlying || !isPhysicsEnabled);
_characterController.setComfortFlyingAllowed(_enableFlying); _characterController.setComfortFlyingAllowed(_enableFlying);
_characterController.setUseFallHeightThreshold(_useFallHeightThreshold); _characterController.setHoverWhenUnsupported(_hoverWhenUnsupported);
_characterController.setCollisionlessAllowed(collisionlessAllowed); _characterController.setCollisionlessAllowed(collisionlessAllowed);
} }
@ -1298,7 +1298,7 @@ void MyAvatar::saveData() {
_displayNameSetting.set(_displayName); _displayNameSetting.set(_displayName);
_collisionSoundURLSetting.set(_collisionSoundURL); _collisionSoundURLSetting.set(_collisionSoundURL);
_useSnapTurnSetting.set(_useSnapTurn); _useSnapTurnSetting.set(_useSnapTurn);
_useFallHeightThresholdSetting.set(_useFallHeightThreshold); _hoverWhenUnsupportedSetting.set(_hoverWhenUnsupported);
_userHeightSetting.set(getUserHeight()); _userHeightSetting.set(getUserHeight());
_flyingHMDSetting.set(getFlyingHMDPref()); _flyingHMDSetting.set(getFlyingHMDPref());
_movementReferenceSetting.set(getMovementReference()); _movementReferenceSetting.set(getMovementReference());
@ -1901,7 +1901,7 @@ void MyAvatar::loadData() {
setDisplayName(_displayNameSetting.get()); setDisplayName(_displayNameSetting.get());
setCollisionSoundURL(_collisionSoundURLSetting.get(QUrl(DEFAULT_AVATAR_COLLISION_SOUND_URL)).toString()); setCollisionSoundURL(_collisionSoundURLSetting.get(QUrl(DEFAULT_AVATAR_COLLISION_SOUND_URL)).toString());
setSnapTurn(_useSnapTurnSetting.get()); setSnapTurn(_useSnapTurnSetting.get());
setUseFallHeightThreshold(_useFallHeightThresholdSetting.get()); setHoverWhenUnsupported(_hoverWhenUnsupportedSetting.get());
setDominantHand(_dominantHandSetting.get(DOMINANT_RIGHT_HAND).toLower()); setDominantHand(_dominantHandSetting.get(DOMINANT_RIGHT_HAND).toLower());
setStrafeEnabled(_strafeEnabledSetting.get(DEFAULT_STRAFE_ENABLED)); setStrafeEnabled(_strafeEnabledSetting.get(DEFAULT_STRAFE_ENABLED));
setHmdAvatarAlignmentType(_hmdAvatarAlignmentTypeSetting.get(DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE).toLower()); setHmdAvatarAlignmentType(_hmdAvatarAlignmentTypeSetting.get(DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE).toLower());

View file

@ -761,15 +761,15 @@ public:
Q_INVOKABLE void setControlScheme(int index) { _controlSchemeIndex = (index >= 0 && index <= 2) ? index : 0; } Q_INVOKABLE void setControlScheme(int index) { _controlSchemeIndex = (index >= 0 && index <= 2) ? index : 0; }
/**jsdoc /**jsdoc
* @function MyAvatar.useFallHeightThreshold * @function MyAvatar.hoverWhenUnsupported
* @returns {boolean} * @returns {boolean}
*/ */
Q_INVOKABLE bool useFallHeightThreshold() const { return _useFallHeightThreshold; } Q_INVOKABLE bool hoverWhenUnsupported() const { return _hoverWhenUnsupported; }
/**jsdoc /**jsdoc
* @function MyAvatar.setUseFallHeightThreshold * @function MyAvatar.setHoverWhenUnsupported
* @param {boolean} on * @param {boolean} on
*/ */
Q_INVOKABLE void setUseFallHeightThreshold(bool on) { _useFallHeightThreshold = on; } Q_INVOKABLE void setHoverWhenUnsupported(bool on) { _hoverWhenUnsupported = on; }
/**jsdoc /**jsdoc
* Sets the avatar's dominant hand. * Sets the avatar's dominant hand.
@ -2454,7 +2454,7 @@ private:
ThreadSafeValueCache<QUrl> _prefOverrideAnimGraphUrl; ThreadSafeValueCache<QUrl> _prefOverrideAnimGraphUrl;
QUrl _fstAnimGraphOverrideUrl; QUrl _fstAnimGraphOverrideUrl;
bool _useSnapTurn { true }; bool _useSnapTurn { true };
bool _useFallHeightThreshold{ true }; bool _hoverWhenUnsupported{ true };
ThreadSafeValueCache<QString> _dominantHand { DOMINANT_RIGHT_HAND }; ThreadSafeValueCache<QString> _dominantHand { DOMINANT_RIGHT_HAND };
ThreadSafeValueCache<QString> _hmdAvatarAlignmentType { DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE }; ThreadSafeValueCache<QString> _hmdAvatarAlignmentType { DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE };
ThreadSafeValueCache<bool> _strafeEnabled{ DEFAULT_STRAFE_ENABLED }; ThreadSafeValueCache<bool> _strafeEnabled{ DEFAULT_STRAFE_ENABLED };
@ -2650,7 +2650,7 @@ private:
Setting::Handle<QString> _displayNameSetting; Setting::Handle<QString> _displayNameSetting;
Setting::Handle<QUrl> _collisionSoundURLSetting; Setting::Handle<QUrl> _collisionSoundURLSetting;
Setting::Handle<bool> _useSnapTurnSetting; Setting::Handle<bool> _useSnapTurnSetting;
Setting::Handle<bool> _useFallHeightThresholdSetting; Setting::Handle<bool> _hoverWhenUnsupportedSetting;
Setting::Handle<float> _userHeightSetting; Setting::Handle<float> _userHeightSetting;
Setting::Handle<bool> _flyingHMDSetting; Setting::Handle<bool> _flyingHMDSetting;
Setting::Handle<int> _movementReferenceSetting; Setting::Handle<int> _movementReferenceSetting;

View file

@ -278,6 +278,12 @@ void setupPreferences() {
preference->setIndented(true); preference->setIndented(true);
preferences->addPreference(preference); preferences->addPreference(preference);
} }
{
auto getter = [myAvatar]() -> bool { return myAvatar->hoverWhenUnsupported(); };
auto setter = [myAvatar](bool value) { myAvatar->setHoverWhenUnsupported(value); };
auto preference = new CheckPreference(VR_MOVEMENT, "Hover When Unsupported", getter, setter);
preferences->addPreference(preference);
}
{ {
auto getter = [myAvatar]()->int { return myAvatar->getMovementReference(); }; auto getter = [myAvatar]()->int { return myAvatar->getMovementReference(); };
auto setter = [myAvatar](int value) { myAvatar->setMovementReference(value); }; auto setter = [myAvatar](int value) { myAvatar->setMovementReference(value); };
@ -304,12 +310,6 @@ void setupPreferences() {
preference->setItems(items); preference->setItems(items);
preferences->addPreference(preference); preferences->addPreference(preference);
} }
{
auto getter = [myAvatar]() -> bool { return myAvatar->useFallHeightThreshold(); };
auto setter = [myAvatar](bool value) { myAvatar->setUseFallHeightThreshold(value); };
auto preference = new CheckPreference(VR_MOVEMENT, "Use Fall Height Threshold", getter, setter);
preferences->addPreference(preference);
}
{ {
auto getter = [myAvatar]()->int { return myAvatar->getControlScheme(); }; auto getter = [myAvatar]()->int { return myAvatar->getControlScheme(); };
auto setter = [myAvatar](int index) { myAvatar->setControlScheme(index); }; auto setter = [myAvatar](int index) { myAvatar->setControlScheme(index); };

View file

@ -754,7 +754,7 @@ void CharacterController::updateState() {
switch (_state) { switch (_state) {
case State::Ground: case State::Ground:
if (!rayHasHit && !_hasSupport) { if (!rayHasHit && !_hasSupport) {
if (_useFallHeightThreshold) { if (_hoverWhenUnsupported) {
SET_STATE(State::Hover, "no ground detected"); SET_STATE(State::Hover, "no ground detected");
} else { } else {
SET_STATE(State::InAir, "falling"); SET_STATE(State::InAir, "falling");
@ -768,7 +768,7 @@ void CharacterController::updateState() {
} }
break; break;
case State::Takeoff: case State::Takeoff:
if (_useFallHeightThreshold && (!rayHasHit && !_hasSupport)) { if (_hoverWhenUnsupported && (!rayHasHit && !_hasSupport)) {
SET_STATE(State::Hover, "no ground"); SET_STATE(State::Hover, "no ground");
} else if ((now - _takeoffToInAirStartTime) > TAKE_OFF_TO_IN_AIR_PERIOD) { } else if ((now - _takeoffToInAirStartTime) > TAKE_OFF_TO_IN_AIR_PERIOD) {
SET_STATE(State::InAir, "takeoff done"); SET_STATE(State::InAir, "takeoff done");
@ -795,7 +795,7 @@ void CharacterController::updateState() {
SET_STATE(State::Hover, "double jump button"); SET_STATE(State::Hover, "double jump button");
} else if (_comfortFlyingAllowed && (jumpButtonHeld || vertTargetSpeedIsNonZero) && (now - _jumpButtonDownStartTime) > JUMP_TO_HOVER_PERIOD) { } else if (_comfortFlyingAllowed && (jumpButtonHeld || vertTargetSpeedIsNonZero) && (now - _jumpButtonDownStartTime) > JUMP_TO_HOVER_PERIOD) {
SET_STATE(State::Hover, "jump button held"); SET_STATE(State::Hover, "jump button held");
} else if (_useFallHeightThreshold && ((!rayHasHit && !_hasSupport) || _floorDistance > _scaleFactor * DEFAULT_AVATAR_FALL_HEIGHT)) { } else if (_hoverWhenUnsupported && ((!rayHasHit && !_hasSupport) || _floorDistance > _scaleFactor * DEFAULT_AVATAR_FALL_HEIGHT)) {
// Transition to hover if there's no ground beneath us or we are above the fall threshold, regardless of _comfortFlyingAllowed // Transition to hover if there's no ground beneath us or we are above the fall threshold, regardless of _comfortFlyingAllowed
SET_STATE(State::Hover, "above fall threshold"); SET_STATE(State::Hover, "above fall threshold");
} }

View file

@ -131,7 +131,7 @@ public:
void setZoneFlyingAllowed(bool value) { _zoneFlyingAllowed = value; } void setZoneFlyingAllowed(bool value) { _zoneFlyingAllowed = value; }
void setComfortFlyingAllowed(bool value) { _comfortFlyingAllowed = value; } void setComfortFlyingAllowed(bool value) { _comfortFlyingAllowed = value; }
void setUseFallHeightThreshold(bool value) { _useFallHeightThreshold = value; } void setHoverWhenUnsupported(bool value) { _hoverWhenUnsupported = value; }
void setCollisionlessAllowed(bool value); void setCollisionlessAllowed(bool value);
void setPendingFlagsUpdateCollisionMask(){ _pendingFlags |= PENDING_FLAG_UPDATE_COLLISION_MASK; } void setPendingFlagsUpdateCollisionMask(){ _pendingFlags |= PENDING_FLAG_UPDATE_COLLISION_MASK; }
@ -216,7 +216,7 @@ protected:
bool _zoneFlyingAllowed { true }; bool _zoneFlyingAllowed { true };
bool _comfortFlyingAllowed { true }; bool _comfortFlyingAllowed { true };
bool _useFallHeightThreshold{ true }; bool _hoverWhenUnsupported{ true };
bool _collisionlessAllowed { true }; bool _collisionlessAllowed { true };
bool _collisionless { false }; bool _collisionless { false };