From b7f157f4ff50d806a5df93334626a360055e79cd Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 25 Apr 2016 14:10:20 -0700 Subject: [PATCH] Reset avatar on exit of away-mode. Exposed MyAvatar.reset(bool) to script. away.js now calls this on exit of away-mode. --- examples/away.js | 1 + interface/src/avatar/MyAvatar.cpp | 9 +++++++-- interface/src/avatar/MyAvatar.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/away.js b/examples/away.js index 9c5aed98fa..dee4f841b0 100644 --- a/examples/away.js +++ b/examples/away.js @@ -196,6 +196,7 @@ function goActive() { } MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting. stopAwayAnimation(); + MyAvatar.reset(true); hideOverlay(); // restore overlays state to what it was when we went "away" diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9a61c00712..a357cd879d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -235,7 +235,12 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) { return AvatarData::toByteArray(cullSmallChanges, sendAll); } -void MyAvatar::reset(bool andReload) { +void MyAvatar::reset(bool andRecenter) { + + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter)); + return; + } // Reset dynamic state. _wasPushing = _isPushing = _isBraking = false; @@ -245,7 +250,7 @@ void MyAvatar::reset(bool andReload) { _targetVelocity = glm::vec3(0.0f); setThrust(glm::vec3(0.0f)); - if (andReload) { + if (andRecenter) { // derive the desired body orientation from the *old* hmd orientation, before the sensor reset. auto newBodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation.. diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 69bb7ea4c2..e320c0e3de 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -93,7 +93,7 @@ public: AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; } AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; } - void reset(bool andReload = false); + Q_INVOKABLE void reset(bool andRecenter = false); void update(float deltaTime); void preRender(RenderArgs* renderArgs);