mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:23:36 +02:00
Add preference to control behavior.
This commit is contained in:
parent
5d806cba7f
commit
8198a1b4d1
4 changed files with 42 additions and 30 deletions
|
@ -733,6 +733,7 @@ void MyAvatar::saveData() {
|
|||
settings.setValue("displayName", _displayName);
|
||||
settings.setValue("collisionSoundURL", _collisionSoundURL);
|
||||
settings.setValue("useSnapTurn", _useSnapTurn);
|
||||
settings.setValue("clearOverlayWhenDriving", _clearOverlayWhenDriving);
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
@ -855,6 +856,7 @@ void MyAvatar::loadData() {
|
|||
setDisplayName(settings.value("displayName").toString());
|
||||
setCollisionSoundURL(settings.value("collisionSoundURL", DEFAULT_AVATAR_COLLISION_SOUND_URL).toString());
|
||||
setSnapTurn(settings.value("useSnapTurn", _useSnapTurn).toBool());
|
||||
setSnapTurn(settings.value("clearOverlayWhenDriving", _clearOverlayWhenDriving).toBool());
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
|
|
|
@ -160,6 +160,8 @@ public:
|
|||
|
||||
Q_INVOKABLE bool getSnapTurn() const { return _useSnapTurn; }
|
||||
Q_INVOKABLE void setSnapTurn(bool on) { _useSnapTurn = on; }
|
||||
Q_INVOKABLE bool getClearOverlayWhenDriving() const { return _clearOverlayWhenDriving; }
|
||||
Q_INVOKABLE void setClearOverlayWhenDriving(bool on) { _clearOverlayWhenDriving = on; }
|
||||
|
||||
// get/set avatar data
|
||||
void saveData();
|
||||
|
@ -396,6 +398,7 @@ private:
|
|||
QString _fullAvatarModelName;
|
||||
QUrl _animGraphUrl {""};
|
||||
bool _useSnapTurn { true };
|
||||
bool _clearOverlayWhenDriving { true };
|
||||
|
||||
// cache of the current HMD sensor position and orientation
|
||||
// in sensor space.
|
||||
|
|
|
@ -68,37 +68,39 @@ void OverlayConductor::update(float dt) {
|
|||
|
||||
void OverlayConductor::updateMode() {
|
||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
float speed = glm::length(myAvatar->getVelocity());
|
||||
const float MIN_DRIVING = 0.2f;
|
||||
const float MAX_NOT_DRIVING = 0.01f;
|
||||
const quint64 REQUIRED_USECS_IN_NEW_MODE_BEFORE_INVISIBLE = 200 * 1000;
|
||||
const quint64 REQUIRED_USECS_IN_NEW_MODE_BEFORE_VISIBLE = 1000 * 1000;
|
||||
bool nowDriving = _driving; // Assume current _driving mode unless...
|
||||
if (speed > MIN_DRIVING) { // ... we're definitely moving...
|
||||
nowDriving = true;
|
||||
} else if (speed < MAX_NOT_DRIVING) { // ... or definitely not.
|
||||
nowDriving = false;
|
||||
if (myAvatar->getClearOverlayWhenDriving()) {
|
||||
float speed = glm::length(myAvatar->getVelocity());
|
||||
const float MIN_DRIVING = 0.2f;
|
||||
const float MAX_NOT_DRIVING = 0.01f;
|
||||
const quint64 REQUIRED_USECS_IN_NEW_MODE_BEFORE_INVISIBLE = 200 * 1000;
|
||||
const quint64 REQUIRED_USECS_IN_NEW_MODE_BEFORE_VISIBLE = 1000 * 1000;
|
||||
bool nowDriving = _driving; // Assume current _driving mode unless...
|
||||
if (speed > MIN_DRIVING) { // ... we're definitely moving...
|
||||
nowDriving = true;
|
||||
} else if (speed < MAX_NOT_DRIVING) { // ... or definitely not.
|
||||
nowDriving = false;
|
||||
}
|
||||
// Check that we're in this new mode for long enough to really trigger a transition.
|
||||
if (nowDriving == _driving) { // If there's no change in state, clear any attepted timer.
|
||||
_timeInPotentialMode = 0;
|
||||
} else if (_timeInPotentialMode == 0) { // We've just changed with no timer, so start timing now.
|
||||
_timeInPotentialMode = usecTimestampNow();
|
||||
} else if ((usecTimestampNow() - _timeInPotentialMode) > (nowDriving ? REQUIRED_USECS_IN_NEW_MODE_BEFORE_INVISIBLE : REQUIRED_USECS_IN_NEW_MODE_BEFORE_VISIBLE)) {
|
||||
_timeInPotentialMode = 0; // a real transition
|
||||
if (nowDriving) {
|
||||
_wantsOverlays = Menu::getInstance()->isOptionChecked(MenuOption::Overlays);
|
||||
} else { // reset when coming out of driving
|
||||
_mode = FLAT; // Seems appropriate to let things reset, below, after the following.
|
||||
// All reset of, e.g., room-scale location as though by apostrophe key, without all the other adjustments.
|
||||
qApp->getActiveDisplayPlugin()->resetSensors();
|
||||
myAvatar->reset(true, false);
|
||||
}
|
||||
if (_wantsOverlays) {
|
||||
setEnabled(!nowDriving, false);
|
||||
}
|
||||
_driving = nowDriving;
|
||||
} // Else haven't accumulated enough time in new mode, but keep timing.
|
||||
}
|
||||
// Check that we're in this new mode for long enough to really trigger a transition.
|
||||
if (nowDriving == _driving) { // If there's no change in state, clear any attepted timer.
|
||||
_timeInPotentialMode = 0;
|
||||
} else if (_timeInPotentialMode == 0) { // We've just changed with no timer, so start timing now.
|
||||
_timeInPotentialMode = usecTimestampNow();
|
||||
} else if ((usecTimestampNow() - _timeInPotentialMode) > (nowDriving ? REQUIRED_USECS_IN_NEW_MODE_BEFORE_INVISIBLE : REQUIRED_USECS_IN_NEW_MODE_BEFORE_VISIBLE)) {
|
||||
_timeInPotentialMode = 0; // a real transition
|
||||
if (nowDriving) {
|
||||
_wantsOverlays = Menu::getInstance()->isOptionChecked(MenuOption::Overlays);
|
||||
} else { // reset when coming out of driving
|
||||
_mode = FLAT; // Seems appropriate to let things reset, below, after the following.
|
||||
// All reset of, e.g., room-scale location as though by apostrophe key, without all the other adjustments.
|
||||
qApp->getActiveDisplayPlugin()->resetSensors();
|
||||
myAvatar->reset(true, false);
|
||||
}
|
||||
if (_wantsOverlays) {
|
||||
setEnabled(!nowDriving, false);
|
||||
}
|
||||
_driving = nowDriving;
|
||||
} // Else haven't accumulated enough time in new mode, but keep timing.
|
||||
|
||||
Mode newMode;
|
||||
if (qApp->isHMDMode()) {
|
||||
|
|
|
@ -61,6 +61,11 @@ void setupPreferences() {
|
|||
auto setter = [=](bool value) { myAvatar->setSnapTurn(value); };
|
||||
preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Snap turn when in HMD", getter, setter));
|
||||
}
|
||||
{
|
||||
auto getter = [=]()->bool {return myAvatar->getClearOverlayWhenDriving(); };
|
||||
auto setter = [=](bool value) { myAvatar->setClearOverlayWhenDriving(value); };
|
||||
preferences->addPreference(new CheckPreference(AVATAR_BASICS, "Clear overlays when driving", getter, setter));
|
||||
}
|
||||
{
|
||||
auto getter = []()->QString { return Snapshot::snapshotsLocation.get(); };
|
||||
auto setter = [](const QString& value) { Snapshot::snapshotsLocation.set(value); };
|
||||
|
|
Loading…
Reference in a new issue