mirror of
https://github.com/overte-org/overte.git
synced 2025-06-22 00:21:04 +02:00
Merge pull request #478 from overte-org/fix/ui_jumping
VR overlay recenter now triggers on hasDriveInput rising edge
This commit is contained in:
commit
092cb8a572
2 changed files with 6 additions and 40 deletions
|
@ -41,32 +41,6 @@ bool OverlayConductor::headNotCenteredInOverlay() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayConductor::updateAvatarIsAtRest() {
|
|
||||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
|
||||||
|
|
||||||
const quint64 REST_ENABLE_TIME_USECS = 1000 * 1000; // 1 s
|
|
||||||
const quint64 REST_DISABLE_TIME_USECS = 200 * 1000; // 200 ms
|
|
||||||
|
|
||||||
const float AT_REST_THRESHOLD = 0.01f;
|
|
||||||
bool desiredAtRest = glm::length(myAvatar->getWorldVelocity()) < AT_REST_THRESHOLD;
|
|
||||||
if (desiredAtRest != _desiredAtRest) {
|
|
||||||
// start timer
|
|
||||||
_desiredAtRestTimer = usecTimestampNow() + (desiredAtRest ? REST_ENABLE_TIME_USECS : REST_DISABLE_TIME_USECS);
|
|
||||||
}
|
|
||||||
|
|
||||||
_desiredAtRest = desiredAtRest;
|
|
||||||
|
|
||||||
if (_desiredAtRestTimer != 0 && usecTimestampNow() > _desiredAtRestTimer) {
|
|
||||||
// timer expired
|
|
||||||
// change state!
|
|
||||||
_currentAtRest = _desiredAtRest;
|
|
||||||
// disable timer
|
|
||||||
_desiredAtRestTimer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _currentAtRest;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverlayConductor::centerUI() {
|
void OverlayConductor::centerUI() {
|
||||||
// place the overlay at the current hmd position in sensor space
|
// place the overlay at the current hmd position in sensor space
|
||||||
auto camMat = cancelOutRollAndPitch(qApp->getHMDSensorPose());
|
auto camMat = cancelOutRollAndPitch(qApp->getHMDSensorPose());
|
||||||
|
@ -103,16 +77,12 @@ void OverlayConductor::update(float dt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldRecenter = false;
|
bool shouldRecenter = false;
|
||||||
if (initiateRecenter || _suppressedByHead) {
|
|
||||||
_suppressedByHead = !updateAvatarIsAtRest();
|
|
||||||
shouldRecenter = !_suppressedByHead;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool currentVisible = !desktop->property("pinned").toBool();
|
bool hasDriveInput = myAvatar->hasDriveInput();
|
||||||
bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && !_suppressedByHead;
|
if (hasDriveInput && !_lastHasDriveInput && initiateRecenter) {
|
||||||
if (targetVisible != currentVisible) {
|
shouldRecenter = true;
|
||||||
offscreenUi->setPinned(!targetVisible);
|
|
||||||
}
|
}
|
||||||
|
_lastHasDriveInput = hasDriveInput;
|
||||||
|
|
||||||
if (shouldRecenter) {
|
if (shouldRecenter) {
|
||||||
centerUI();
|
centerUI();
|
||||||
|
|
|
@ -23,17 +23,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool headNotCenteredInOverlay() const;
|
bool headNotCenteredInOverlay() const;
|
||||||
bool updateAvatarIsAtRest();
|
|
||||||
|
|
||||||
#if !defined(DISABLE_QML)
|
#if !defined(DISABLE_QML)
|
||||||
bool _suppressedByHead { false };
|
|
||||||
bool _hmdMode { false };
|
bool _hmdMode { false };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// used by updateAvatarIsAtRest
|
// This stores value of myAvatar->hasDriveInput() from previous update, so that recentering can be triggered by a rising edge of that function's output
|
||||||
uint64_t _desiredAtRestTimer { 0 };
|
bool _lastHasDriveInput { false };
|
||||||
bool _desiredAtRest { true };
|
|
||||||
bool _currentAtRest { true };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue