mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Allow players to disable automatic falling to flight threshold.
This commit is contained in:
parent
78256fb5bb
commit
bce80130bd
5 changed files with 27 additions and 1 deletions
|
@ -168,6 +168,7 @@ MyAvatar::MyAvatar(QThread* thread) :
|
|||
_displayNameSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "displayName", ""),
|
||||
_collisionSoundURLSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "collisionSoundURL", QUrl(_collisionSoundURL)),
|
||||
_useSnapTurnSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "useSnapTurn", _useSnapTurn),
|
||||
_useFallHeightThresholdSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "useFallHeightThreshold", _useFallHeightThreshold),
|
||||
_userHeightSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "userHeight", DEFAULT_AVATAR_HEIGHT),
|
||||
_flyingHMDSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "flyingHMD", _flyingPrefHMD),
|
||||
_movementReferenceSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "movementReference", _movementReference),
|
||||
|
@ -956,6 +957,7 @@ void MyAvatar::simulate(float deltaTime, bool inView) {
|
|||
bool collisionlessAllowed = zoneInteractionProperties.second;
|
||||
_characterController.setZoneFlyingAllowed(zoneAllowsFlying || !isPhysicsEnabled);
|
||||
_characterController.setComfortFlyingAllowed(_enableFlying);
|
||||
_characterController.setUseFallHeightThreshold(_useFallHeightThreshold);
|
||||
_characterController.setCollisionlessAllowed(collisionlessAllowed);
|
||||
}
|
||||
|
||||
|
@ -1296,6 +1298,7 @@ void MyAvatar::saveData() {
|
|||
_displayNameSetting.set(_displayName);
|
||||
_collisionSoundURLSetting.set(_collisionSoundURL);
|
||||
_useSnapTurnSetting.set(_useSnapTurn);
|
||||
_useFallHeightThresholdSetting.set(_useFallHeightThreshold);
|
||||
_userHeightSetting.set(getUserHeight());
|
||||
_flyingHMDSetting.set(getFlyingHMDPref());
|
||||
_movementReferenceSetting.set(getMovementReference());
|
||||
|
@ -1898,6 +1901,7 @@ void MyAvatar::loadData() {
|
|||
setDisplayName(_displayNameSetting.get());
|
||||
setCollisionSoundURL(_collisionSoundURLSetting.get(QUrl(DEFAULT_AVATAR_COLLISION_SOUND_URL)).toString());
|
||||
setSnapTurn(_useSnapTurnSetting.get());
|
||||
setUseFallHeightThreshold(_useFallHeightThresholdSetting.get());
|
||||
setDominantHand(_dominantHandSetting.get(DOMINANT_RIGHT_HAND).toLower());
|
||||
setStrafeEnabled(_strafeEnabledSetting.get(DEFAULT_STRAFE_ENABLED));
|
||||
setHmdAvatarAlignmentType(_hmdAvatarAlignmentTypeSetting.get(DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE).toLower());
|
||||
|
|
|
@ -759,6 +759,18 @@ public:
|
|||
* @param {number} index
|
||||
*/
|
||||
Q_INVOKABLE void setControlScheme(int index) { _controlSchemeIndex = (index >= 0 && index <= 2) ? index : 0; }
|
||||
|
||||
/**jsdoc
|
||||
* @function MyAvatar.useFallHeightThreshold
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Q_INVOKABLE bool useFallHeightThreshold() const { return _useFallHeightThreshold; }
|
||||
/**jsdoc
|
||||
* @function MyAvatar.setUseFallHeightThreshold
|
||||
* @param {boolean} on
|
||||
*/
|
||||
Q_INVOKABLE void setUseFallHeightThreshold(bool on) { _useFallHeightThreshold = on; }
|
||||
|
||||
/**jsdoc
|
||||
* Sets the avatar's dominant hand.
|
||||
* @function MyAvatar.setDominantHand
|
||||
|
@ -2442,6 +2454,7 @@ private:
|
|||
ThreadSafeValueCache<QUrl> _prefOverrideAnimGraphUrl;
|
||||
QUrl _fstAnimGraphOverrideUrl;
|
||||
bool _useSnapTurn { true };
|
||||
bool _useFallHeightThreshold{ true };
|
||||
ThreadSafeValueCache<QString> _dominantHand { DOMINANT_RIGHT_HAND };
|
||||
ThreadSafeValueCache<QString> _hmdAvatarAlignmentType { DEFAULT_HMD_AVATAR_ALIGNMENT_TYPE };
|
||||
ThreadSafeValueCache<bool> _strafeEnabled{ DEFAULT_STRAFE_ENABLED };
|
||||
|
@ -2637,6 +2650,7 @@ private:
|
|||
Setting::Handle<QString> _displayNameSetting;
|
||||
Setting::Handle<QUrl> _collisionSoundURLSetting;
|
||||
Setting::Handle<bool> _useSnapTurnSetting;
|
||||
Setting::Handle<bool> _useFallHeightThresholdSetting;
|
||||
Setting::Handle<float> _userHeightSetting;
|
||||
Setting::Handle<bool> _flyingHMDSetting;
|
||||
Setting::Handle<int> _movementReferenceSetting;
|
||||
|
|
|
@ -304,6 +304,12 @@ void setupPreferences() {
|
|||
preference->setItems(items);
|
||||
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 setter = [myAvatar](int index) { myAvatar->setControlScheme(index); };
|
||||
|
|
|
@ -791,7 +791,7 @@ void CharacterController::updateState() {
|
|||
SET_STATE(State::Hover, "double jump button");
|
||||
} else if (_comfortFlyingAllowed && (jumpButtonHeld || vertTargetSpeedIsNonZero) && (now - _jumpButtonDownStartTime) > JUMP_TO_HOVER_PERIOD) {
|
||||
SET_STATE(State::Hover, "jump button held");
|
||||
} else if ((!rayHasHit && !_hasSupport) || _floorDistance > _scaleFactor * DEFAULT_AVATAR_FALL_HEIGHT) {
|
||||
} else if (_useFallHeightThreshold && ((!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
|
||||
SET_STATE(State::Hover, "above fall threshold");
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ public:
|
|||
|
||||
void setZoneFlyingAllowed(bool value) { _zoneFlyingAllowed = value; }
|
||||
void setComfortFlyingAllowed(bool value) { _comfortFlyingAllowed = value; }
|
||||
void setUseFallHeightThreshold(bool value) { _useFallHeightThreshold = value; }
|
||||
void setCollisionlessAllowed(bool value);
|
||||
|
||||
void setPendingFlagsUpdateCollisionMask(){ _pendingFlags |= PENDING_FLAG_UPDATE_COLLISION_MASK; }
|
||||
|
@ -215,6 +216,7 @@ protected:
|
|||
|
||||
bool _zoneFlyingAllowed { true };
|
||||
bool _comfortFlyingAllowed { true };
|
||||
bool _useFallHeightThreshold{ true };
|
||||
bool _collisionlessAllowed { true };
|
||||
bool _collisionless { false };
|
||||
|
||||
|
|
Loading…
Reference in a new issue