Merge pull request #9650 from kunalgosar/browserFix

Added isAway (paused) property to myAvatar
This commit is contained in:
Chris Collins 2017-02-14 11:16:07 -08:00 committed by GitHub
commit 442e8d68ef
4 changed files with 49 additions and 20 deletions

View file

@ -296,6 +296,10 @@ Fadable {
// fall through
default:
if (MyAvatar.isAway) {
// If stuck in a window and a key is pressed this should exit paused mode
MyAvatar.isAway = false;
}
// Consume unmodified keyboard entries while the window is focused, to prevent them
// from propagating to the application
if (event.modifiers === Qt.NoModifier) {

View file

@ -88,6 +88,7 @@ MyAvatar::MyAvatar(RigPointer rig) :
_isPushing(false),
_isBeingPushed(false),
_isBraking(false),
_isAway(false),
_boomLength(ZOOM_DEFAULT),
_yawSpeed(YAW_SPEED_DEFAULT),
_pitchSpeed(PITCH_SPEED_DEFAULT),
@ -2361,6 +2362,15 @@ bool MyAvatar::hasDriveInput() const {
return fabsf(_driveKeys[TRANSLATE_X]) > 0.0f || fabsf(_driveKeys[TRANSLATE_Y]) > 0.0f || fabsf(_driveKeys[TRANSLATE_Z]) > 0.0f;
}
void MyAvatar::setAway(bool value) {
_isAway = value;
if (_isAway) {
emit wentAway();
} else {
emit wentActive();
}
}
// The resulting matrix is used to render the hand controllers, even if the camera is decoupled from the avatar.
// Specificly, if we are rendering using a third person camera. We would like to render the hand controllers in front of the camera,
// not in front of the avatar.

View file

@ -82,6 +82,7 @@ class MyAvatar : public Avatar {
Q_PROPERTY(controller::Pose rightHandTipPose READ getRightHandTipPose)
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
Q_PROPERTY(float isAway READ getIsAway WRITE setAway)
Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
@ -328,6 +329,8 @@ signals:
void energyChanged(float newEnergy);
void positionGoneTo();
void onLoadComplete();
void wentAway();
void wentActive();
private:
@ -385,6 +388,7 @@ private:
bool _isPushing;
bool _isBeingPushed;
bool _isBraking;
bool _isAway;
float _boomLength;
float _yawSpeed; // degrees/sec
@ -521,6 +525,8 @@ private:
float getEnergy();
void setEnergy(float value);
bool didTeleport();
bool getIsAway() const { return _isAway; }
void setAway(bool value);
};
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);

View file

@ -165,9 +165,36 @@ function goAway(fromStartup) {
if (!isEnabled || isAway) {
return;
}
// If we're entering away mode from some other state than startup, then we create our move timer immediately.
// However if we're just stating up, we need to delay this process so that we don't think the initial teleport
// is actually a move.
if (fromStartup === undefined || fromStartup === false) {
avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL);
} else {
var WAIT_FOR_MOVE_ON_STARTUP = 3000; // 3 seconds
Script.setTimeout(function() {
avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL);
}, WAIT_FOR_MOVE_ON_STARTUP);
}
UserActivityLogger.toggledAway(true);
MyAvatar.isAway = true;
}
function goActive() {
if (!isAway) {
return;
}
UserActivityLogger.toggledAway(false);
MyAvatar.isAway = false;
}
MyAvatar.wentAway.connect(setAwayProperties)
MyAvatar.wentActive.connect(setActiveProperties)
function setAwayProperties() {
isAway = true;
wasMuted = AudioDevice.getMuted();
if (!wasMuted) {
@ -189,27 +216,9 @@ function goAway(fromStartup) {
wasHmdMounted = HMD.mounted; // always remember the correct state
avatarPosition = MyAvatar.position;
// If we're entering away mode from some other state than startup, then we create our move timer immediately.
// However if we're just stating up, we need to delay this process so that we don't think the initial teleport
// is actually a move.
if (fromStartup === undefined || fromStartup === false) {
avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL);
} else {
var WAIT_FOR_MOVE_ON_STARTUP = 3000; // 3 seconds
Script.setTimeout(function() {
avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL);
}, WAIT_FOR_MOVE_ON_STARTUP);
}
}
function goActive() {
if (!isAway) {
return;
}
UserActivityLogger.toggledAway(false);
function setActiveProperties() {
isAway = false;
if (!wasMuted) {
AudioDevice.toggleMute();