Solved some sitting and sound issues while looking at

This commit is contained in:
luiscuenca 2019-09-18 17:00:10 -07:00
parent 1054e8fcde
commit 7bc8e6b237
No known key found for this signature in database
GPG key ID: 2387ECD129A6961D
5 changed files with 51 additions and 55 deletions

View file

@ -3,8 +3,8 @@
"channels": [ "channels": [
{ "from": "Keyboard.A", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" }, { "from": "Keyboard.A", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
{ "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" }, { "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
{ "from": "Keyboard.E", "when": ["!Application.CameraLookAt", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" }, { "from": "Keyboard.E", "when": ["!Application.CameraSelfie", "!Application.CameraLookAt", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
{ "from": "Keyboard.Q", "when": ["!Application.CameraLookAt", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" }, { "from": "Keyboard.Q", "when": ["!Application.CameraSelfie"," !Application.CameraLookAt", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
{ "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" }, { "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" },
{ "comment" : "Mouse turn need to be small continuous increments", { "comment" : "Mouse turn need to be small continuous increments",
@ -131,8 +131,8 @@
}, },
{ "from": { "makeAxis" : [ { "from": { "makeAxis" : [
["Keyboard.A"], ["Keyboard.E"],
["Keyboard.D"] ["Keyboard.Q"]
] ]
}, },
"when": ["Application.CameraSelfie", "!Keyboard.Control"], "when": ["Application.CameraSelfie", "!Keyboard.Control"],
@ -185,7 +185,7 @@
}, },
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] }, { "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
"when": ["!Application.CameraSelfie", "Keyboard.RightMouseButton"], "when": ["!Application.CameraSelfie", "!Application.CameraLookAt", "Keyboard.RightMouseButton"],
"to": "Actions.DeltaPitch", "to": "Actions.DeltaPitch",
"filters": "filters":
[ [
@ -193,19 +193,32 @@
] ]
}, },
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
"when": ["Application.CameraLookAt", "Keyboard.RightMouseButton"],
"to": "Actions.DeltaPitch",
"filters":
[
{ "type": "scale", "scale": 0.3 }
]
},
{ "from": { "makeAxis" : ["Keyboard.MouseMoveDown", "Keyboard.MouseMoveUp"] }, { "from": { "makeAxis" : ["Keyboard.MouseMoveDown", "Keyboard.MouseMoveUp"] },
"when": ["Application.CameraSelfie", "Keyboard.RightMouseButton"], "when": ["Application.CameraSelfie", "Keyboard.RightMouseButton"],
"to": "Actions.DeltaPitch", "to": "Actions.DeltaPitch",
"filters": "filters":
[ [
{ "type": "scale", "scale": 0.6 } { "type": "scale", "scale": 0.3 }
] ]
}, },
{ "from": "Keyboard.W", "when": "!Keyboard.Control", "to": "Actions.LONGITUDINAL_FORWARD" }, { "from": "Keyboard.W", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LONGITUDINAL_FORWARD" },
{ "from": "Keyboard.S", "when": "!Keyboard.Control", "to": "Actions.LONGITUDINAL_BACKWARD" }, { "from": "Keyboard.S", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LONGITUDINAL_BACKWARD" },
{ "from": "Keyboard.S", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LONGITUDINAL_FORWARD" },
{ "from": "Keyboard.W", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LONGITUDINAL_BACKWARD" },
{ "from": "Keyboard.A", "when": "Application.CameraLookAt", "to": "Actions.LATERAL_LEFT" }, { "from": "Keyboard.A", "when": "Application.CameraLookAt", "to": "Actions.LATERAL_LEFT" },
{ "from": "Keyboard.D", "when": "Application.CameraLookAt", "to": "Actions.LATERAL_RIGHT" }, { "from": "Keyboard.D", "when": "Application.CameraLookAt", "to": "Actions.LATERAL_RIGHT" },
{ "from": "Keyboard.A", "when": "Application.CameraSelfie", "to": "Actions.LATERAL_RIGHT" },
{ "from": "Keyboard.D", "when": "Application.CameraSelfie", "to": "Actions.LATERAL_LEFT" },
{ "from": "Keyboard.Shift", "when": ["!Keyboard.Left", "!Keyboard.Right"], "to": "Actions.SPRINT" }, { "from": "Keyboard.Shift", "when": ["!Keyboard.Left", "!Keyboard.Right"], "to": "Actions.SPRINT" },
{ "from": "Keyboard.C", "when": "!Keyboard.Control", "to": "Actions.VERTICAL_DOWN" }, { "from": "Keyboard.C", "when": "!Keyboard.Control", "to": "Actions.VERTICAL_DOWN" },
{ "from": "Keyboard.Left", "when": "Keyboard.Shift", "to": "Actions.LATERAL_LEFT" }, { "from": "Keyboard.Left", "when": "Keyboard.Shift", "to": "Actions.LATERAL_LEFT" },

View file

@ -4418,11 +4418,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
menu->triggerOption(MenuOption::LookAtScreen); menu->triggerOption(MenuOption::LookAtScreen);
break; break;
} }
case Qt::Key_4: { case Qt::Key_4:
Menu* menu = Menu::getInstance();
menu->triggerOption(MenuOption::FullscreenMirror);
break;
}
case Qt::Key_5: case Qt::Key_5:
case Qt::Key_6: case Qt::Key_6:
case Qt::Key_7: case Qt::Key_7:
@ -6008,9 +6004,6 @@ void Application::cameraModeChanged() {
case CAMERA_MODE_SELFIE: case CAMERA_MODE_SELFIE:
Menu::getInstance()->setIsOptionChecked(MenuOption::SelfieScreen, true); Menu::getInstance()->setIsOptionChecked(MenuOption::SelfieScreen, true);
break; break;
case CAMERA_MODE_MIRROR:
Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, true);
break;
default: default:
// we don't have menu items for the others, so just leave it alone. // we don't have menu items for the others, so just leave it alone.
return; return;
@ -6025,25 +6018,18 @@ void Application::changeViewAsNeeded(float boomLength) {
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON && boomLengthGreaterThanMinimum) { if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON && boomLengthGreaterThanMinimum) {
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, false); Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, false);
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true); Menu::getInstance()->setIsOptionChecked(MenuOption::LookAtScreen, true);
cameraMenuChanged(); cameraMenuChanged();
} else if (_myCamera.getMode() == CAMERA_MODE_LOOK_AT && !boomLengthGreaterThanMinimum) { } else if (_myCamera.getMode() == CAMERA_MODE_LOOK_AT && !boomLengthGreaterThanMinimum) {
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true); Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true);
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, false); Menu::getInstance()->setIsOptionChecked(MenuOption::LookAtScreen, false);
cameraMenuChanged(); cameraMenuChanged();
} }
} }
void Application::cameraMenuChanged() { void Application::cameraMenuChanged() {
auto menu = Menu::getInstance(); auto menu = Menu::getInstance();
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { if (menu->isOptionChecked(MenuOption::FirstPerson)) {
if (!isHMDMode() && _myCamera.getMode() != CAMERA_MODE_MIRROR) {
_mirrorYawOffset = 0.0f;
_myCamera.setMode(CAMERA_MODE_MIRROR);
getMyAvatar()->reset(false, false, false); // to reset any active MyAvatar::FollowHelpers
getMyAvatar()->setBoomLength(MyAvatar::ZOOM_DEFAULT);
}
} else if (menu->isOptionChecked(MenuOption::FirstPerson)) {
if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) {
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON); _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN);
@ -9145,9 +9131,7 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) {
cameraMenuChanged(); cameraMenuChanged();
} }
// Remove the mirror and selfie camera options from menu if in HMD mode // Remove the selfie camera options from menu if in HMD mode
auto mirrorAction = menu->getActionForOption(MenuOption::FullscreenMirror);
mirrorAction->setVisible(!isHmd);
auto selfieAction = menu->getActionForOption(MenuOption::SelfieScreen); auto selfieAction = menu->getActionForOption(MenuOption::SelfieScreen);
selfieAction->setVisible(!isHmd); selfieAction->setVisible(!isHmd);
} }

View file

@ -191,13 +191,6 @@ Menu::Menu() {
selfieAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); selfieAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
// View > Mirror
auto viewMirrorAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
viewMenu, MenuOption::FullscreenMirror, 0,
false, qApp, SLOT(cameraMenuChanged())));
viewMirrorAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
viewMenu->addSeparator(); viewMenu->addSeparator();
// View > Center Player In View // View > Center Player In View

View file

@ -129,7 +129,7 @@ namespace MenuOption {
const QString Login = "Login/Sign Up"; const QString Login = "Login/Sign Up";
const QString Log = "Log"; const QString Log = "Log";
const QString LogExtraTimings = "Log Extra Timing Details"; const QString LogExtraTimings = "Log Extra Timing Details";
const QString LookAtScreen = "Look At"; const QString LookAtScreen = "Third Person";
const QString LowVelocityFilter = "Low Velocity Filter"; const QString LowVelocityFilter = "Low Velocity Filter";
const QString MeshVisible = "Draw Mesh"; const QString MeshVisible = "Draw Mesh";
const QString MuteEnvironment = "Mute Environment"; const QString MuteEnvironment = "Mute Environment";
@ -201,7 +201,7 @@ namespace MenuOption {
const QString AnimStats = "Show Animation Stats"; const QString AnimStats = "Show Animation Stats";
const QString StopAllScripts = "Stop All Scripts"; const QString StopAllScripts = "Stop All Scripts";
const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
const QString ThirdPerson = "Third Person"; const QString ThirdPerson = "Third Person Legacy";
const QString ThreePointCalibration = "3 Point Calibration"; const QString ThreePointCalibration = "3 Point Calibration";
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp
const QString ToggleHipsFollowing = "Toggle Hips Following"; const QString ToggleHipsFollowing = "Toggle Hips Following";

View file

@ -3333,10 +3333,10 @@ void MyAvatar::setRotationThreshold(float angleRadians) {
void MyAvatar::updateOrientation(float deltaTime) { void MyAvatar::updateOrientation(float deltaTime) {
// Smoothly rotate body with arrow keys // Smoothly rotate body with arrow keys
float targetSpeed = getDriveKey(YAW) * _yawSpeed; float targetSpeed = getDriveKey(YAW) * _yawSpeed;
bool computeCameraLookAt = (qApp->getCamera().getMode() == CAMERA_MODE_LOOK_AT || bool computeLookAt = (qApp->getCamera().getMode() == CAMERA_MODE_LOOK_AT ||
qApp->getCamera().getMode() == CAMERA_MODE_SELFIE) && isReadyForPhysics(); qApp->getCamera().getMode() == CAMERA_MODE_SELFIE) && isReadyForPhysics();
if (computeCameraLookAt) { if (computeLookAt) {
// Rotate directly proportional to delta yaw and delta pitch from right-click mouse movement. // For "Look At" and "Selfie" camera modes we also smooth the yaw rotation from right-click mouse movement.
float speedFromDeltaYaw = deltaTime > FLT_EPSILON ? getDriveKey(DELTA_YAW) / deltaTime : 0.0f; float speedFromDeltaYaw = deltaTime > FLT_EPSILON ? getDriveKey(DELTA_YAW) / deltaTime : 0.0f;
speedFromDeltaYaw *= _yawSpeed / YAW_SPEED_DEFAULT; speedFromDeltaYaw *= _yawSpeed / YAW_SPEED_DEFAULT;
targetSpeed += speedFromDeltaYaw; targetSpeed += speedFromDeltaYaw;
@ -3364,7 +3364,8 @@ void MyAvatar::updateOrientation(float deltaTime) {
} }
} }
float totalBodyYaw = _bodyYawDelta * deltaTime; float totalBodyYaw = _bodyYawDelta * deltaTime;
if (!computeCameraLookAt) { if (!computeLookAt) {
// Rotate directly proportional to delta yaw and delta pitch from right-click mouse movement.
totalBodyYaw += getDriveKey(DELTA_YAW) * _yawSpeed / YAW_SPEED_DEFAULT; totalBodyYaw += getDriveKey(DELTA_YAW) * _yawSpeed / YAW_SPEED_DEFAULT;
} }
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll // Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
@ -3414,7 +3415,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
float timeScale = deltaTime * FPS; float timeScale = deltaTime * FPS;
bool faceForward = false; bool faceForward = false;
if (!computeCameraLookAt) { if (!computeLookAt) {
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f)))); setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
_lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT; _lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT;
_lookAtOffsetYaw = getWorldOrientation(); _lookAtOffsetYaw = getWorldOrientation();
@ -3439,7 +3440,8 @@ void MyAvatar::updateOrientation(float deltaTime) {
} }
bool isMovingFwdBwd = getDriveKey(TRANSLATE_Z) != 0.0f; bool isMovingFwdBwd = getDriveKey(TRANSLATE_Z) != 0.0f;
bool isMovingSideways = getDriveKey(TRANSLATE_X) != 0.0f; bool isMovingSideways = getDriveKey(TRANSLATE_X) != 0.0f;
faceForward = computeCameraLookAt && (isMovingFwdBwd || isMovingSideways); bool isRotatingWhileSeated = isMovingSideways && _characterController.getSeated();
faceForward = isMovingFwdBwd || (isMovingSideways && !isRotatingWhileSeated);
// Blend the avatar orientation with the camera look at if moving forward. // Blend the avatar orientation with the camera look at if moving forward.
if (faceForward || _shouldTurnToFaceCamera) { if (faceForward || _shouldTurnToFaceCamera) {
const float REORIENT_FORWARD_BLEND = 0.25f; const float REORIENT_FORWARD_BLEND = 0.25f;
@ -3453,13 +3455,14 @@ void MyAvatar::updateOrientation(float deltaTime) {
if (isMovingFwdBwd && isMovingSideways) { if (isMovingFwdBwd && isMovingSideways) {
// Reorient avatar to face camera diagonal // Reorient avatar to face camera diagonal
blend = DIAGONAL_TURN_BLEND; blend = DIAGONAL_TURN_BLEND;
if (getDriveKey(TRANSLATE_X) > 0.0f) { float turnSign = getDriveKey(TRANSLATE_Z) < 0.0f ? -1.0f : 1.0f;
faceRotation = _lookAtOffsetYaw * glm::angleAxis(-0.25f * PI, Vectors::UP); turnSign = getDriveKey(TRANSLATE_X) > 0.0f ? -turnSign : turnSign;
} else if (getDriveKey(TRANSLATE_X) < 0.0f) { faceRotation = _lookAtOffsetYaw * glm::angleAxis(turnSign * 0.25f * PI, Vectors::UP);
faceRotation = _lookAtOffsetYaw * glm::angleAxis(0.25f * PI, Vectors::UP);
}
} }
setWorldOrientation(glm::slerp(getWorldOrientation(), faceRotation, blend)); setWorldOrientation(glm::slerp(getWorldOrientation(), faceRotation, blend));
} else if (isRotatingWhileSeated) {
float rotatingWhileSeatedYaw = -getDriveKey(TRANSLATE_X) * _yawSpeed * deltaTime;
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, rotatingWhileSeatedYaw, 0.0f))));
} }
} }
@ -3482,7 +3485,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
head->setBaseYaw(YAW(euler)); head->setBaseYaw(YAW(euler));
head->setBasePitch(PITCH(euler)); head->setBasePitch(PITCH(euler));
head->setBaseRoll(ROLL(euler)); head->setBaseRoll(ROLL(euler));
} else if (computeCameraLookAt) { } else if (computeLookAt) {
// Reset head orientation before applying the blending offset // Reset head orientation before applying the blending offset
head->setBaseYaw(0.0f); head->setBaseYaw(0.0f);
head->setBasePitch(0.0f); head->setBasePitch(0.0f);
@ -3582,7 +3585,7 @@ float MyAvatar::calculateGearedSpeed(const float driveKey) {
glm::vec3 MyAvatar::scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 right) { glm::vec3 MyAvatar::scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 right) {
float stickFullOn = 0.85f; float stickFullOn = 0.85f;
auto zSpeed = getDriveKey(TRANSLATE_Z); auto zSpeed = getDriveKey(TRANSLATE_Z);
auto xSpeed = getDriveKey(TRANSLATE_X); auto xSpeed = !_characterController.getSeated() ? getDriveKey(TRANSLATE_X) : 0.0f;
glm::vec3 direction; glm::vec3 direction;
if (!useAdvancedMovementControls() && qApp->isHMDMode()) { if (!useAdvancedMovementControls() && qApp->isHMDMode()) {
// Walking disabled in settings. // Walking disabled in settings.
@ -5272,9 +5275,13 @@ glm::quat MyAvatar::getOrientationForAudio() {
glm::quat result; glm::quat result;
switch (_audioListenerMode) { switch (_audioListenerMode) {
case AudioListenerMode::FROM_HEAD: case AudioListenerMode::FROM_HEAD: {
result = getHead()->getFinalOrientationInWorldFrame(); // Compute the head orientation if we are using the look at blending
CameraMode mode = qApp->getCamera().getMode();
bool headFollowsCamera = mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE;
result = headFollowsCamera ? qApp->getCamera().getOrientation() : getHead()->getFinalOrientationInWorldFrame();
break; break;
}
case AudioListenerMode::FROM_CAMERA: case AudioListenerMode::FROM_CAMERA:
result = qApp->getCamera().getOrientation(); result = qApp->getCamera().getOrientation();
break; break;
@ -6400,7 +6407,6 @@ void MyAvatar::sendPacket(const QUuid& entityID) const {
void MyAvatar::setSitDriveKeysStatus(bool enabled) { void MyAvatar::setSitDriveKeysStatus(bool enabled) {
const std::vector<DriveKeys> DISABLED_DRIVE_KEYS_DURING_SIT = { const std::vector<DriveKeys> DISABLED_DRIVE_KEYS_DURING_SIT = {
DriveKeys::TRANSLATE_X,
DriveKeys::TRANSLATE_Y, DriveKeys::TRANSLATE_Y,
DriveKeys::TRANSLATE_Z, DriveKeys::TRANSLATE_Z,
DriveKeys::STEP_TRANSLATE_X, DriveKeys::STEP_TRANSLATE_X,