From 82044399e40b5eb6ff638dad458388c03e19ef35 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Thu, 15 May 2014 21:01:11 -0400 Subject: [PATCH] Brought in Realistic Mouselook option from Black Dragon Look at the top area of Input & Camera preferences Aside from tweaks to the code, all credit to Niran. --- indra/newview/app_settings/settings.xml | 22 +++++++++++++++++ indra/newview/llagent.cpp | 7 +++++- indra/newview/llagentcamera.cpp | 24 +++++++++++++++---- indra/newview/llvoavatar.cpp | 3 ++- .../xui/en-us/panel_preferences_input.xml | 1 + 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 23b185b61..074f96a83 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -995,6 +995,17 @@ Found in Advanced->Rendering->Info Displays Value 1 + UseRealisticMouselook + + Comment + Use a realistic first person view, this prevents your camera from being the center of everything and your avatar always beeing locked below you, it allows your Avatar to move around freely in mouselook while your camera will follow it around. Prepare your seatbelts for an awesome shaky View! May break with certain super unrealistic animations. + Persist + 1 + Type + Boolean + Value + 0 + LogShowHistoryLines Comment @@ -3058,6 +3069,17 @@ This should be as low as possible, but too low may break functionality Value 2 + AvatarRotateThresholdMouselook + + Comment + Angle between avatar facing and camera facing at which avatar turns to face same direction as camera, when in mouselook (degrees) + Persist + 1 + Type + F32 + Value + 120 + AvatarBakedTextureUploadTimeout Comment diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 973466967..752d811f9 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1298,7 +1298,12 @@ F32 LLAgent::clampPitchToLimits(F32 angle) F32 angle_from_skyward = acos( mFrameAgent.getAtAxis() * skyward ); - if (isAgentAvatarValid() && gAgentAvatarp->isSitting()) + if (gAgentCamera.cameraMouselook() && gSavedSettings.getBOOL("UseRealisticMouselook")) + { + look_down_limit = 160.f * DEG_TO_RAD; + look_up_limit = 20.f * DEG_TO_RAD; + } + else if (isAgentAvatarValid() && gAgentAvatarp->isSitting()) { look_down_limit = 130.f * DEG_TO_RAD; } diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 5c21a75a3..82b82c11e 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1178,7 +1178,9 @@ void LLAgentCamera::updateCamera() validateFocusObject(); - if (isAgentAvatarValid() && + bool realistic_ml(gSavedSettings.getBOOL("UseRealisticMouselook")); + if (isAgentAvatarValid() && + !realistic_ml && gAgentAvatarp->isSitting() && camera_mode == CAMERA_MODE_MOUSELOOK) { @@ -1461,13 +1463,11 @@ void LLAgentCamera::updateCamera() } gAgent.setLastPositionGlobal(global_pos); - if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook()) + if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && (realistic_ml || !gAgentAvatarp->isSitting()) && cameraMouselook()) { LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation(); - LLVector3 diff = mCameraPositionAgent - head_pos; - diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation(); LLJoint* torso_joint = gAgentAvatarp->mTorsop; LLJoint* chest_joint = gAgentAvatarp->mChestp; @@ -1489,7 +1489,21 @@ void LLAgentCamera::updateCamera() diff.mV[VZ] = 0.f; }*/ - gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff); + if (realistic_ml) + { + LLQuaternion agent_rot(gAgent.getFrameAgent().getQuaternion()); + if (isAgentAvatarValid()) + if (LLViewerObject* parent = static_cast(gAgentAvatarp->getParent())) + if (static_cast(gAgentAvatarp->getRoot())->flagCameraDecoupled()) + agent_rot *= parent->getRenderRotation(); + LLViewerCamera::getInstance()->updateCameraLocation(head_pos, mCameraUpVector, gAgentAvatarp->mHeadp->getWorldPosition() + LLVector3(1.0, 0.0, 0.0) * agent_rot); + } + else + { + LLVector3 diff = mCameraPositionAgent - head_pos; + diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation(); + gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff); + } gAgentAvatarp->mRoot->updateWorldMatrixChildren(); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 26dae3313..ee27f7893 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4130,12 +4130,13 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) static const LLCachedControl s_pelvis_rot_threshold_slow(gSavedSettings, "AvatarRotateThresholdSlow"); static const LLCachedControl s_pelvis_rot_threshold_fast(gSavedSettings, "AvatarRotateThresholdFast"); + static const LLCachedControl s_pelvis_rot_threshold_ml(gSavedSettings, "AvatarRotateThresholdMouselook", 120.f); F32 pelvis_rot_threshold = clamp_rescale(speed, 0.1f, 1.0f, s_pelvis_rot_threshold_slow, s_pelvis_rot_threshold_fast); if (self_in_mouselook) { - pelvis_rot_threshold *= MOUSELOOK_PELVIS_FOLLOW_FACTOR; + pelvis_rot_threshold = clamp_rescale(speed, 0.1f, 1.0f, s_pelvis_rot_threshold_ml, s_pelvis_rot_threshold_fast); } pelvis_rot_threshold *= DEG_TO_RAD; diff --git a/indra/newview/skins/default/xui/en-us/panel_preferences_input.xml b/indra/newview/skins/default/xui/en-us/panel_preferences_input.xml index 0baf30023..b5252a17a 100644 --- a/indra/newview/skins/default/xui/en-us/panel_preferences_input.xml +++ b/indra/newview/skins/default/xui/en-us/panel_preferences_input.xml @@ -5,6 +5,7 @@ + UI Hidden in mouselook: