From eac5512e917b0796bdd4b4a118e8c537682f8de3 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 12 Dec 2023 02:27:27 +0100 Subject: [PATCH] FIRE-32882: Fix clamped crosshairs pointing at other avatar's crotches instead of their face (and fix the whole stuff properly) --- indra/newview/llhudeffectlookat.cpp | 53 +++++++++---------- .../xui/en/panel_preferences_privacy.xml | 2 +- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index 8a30714289..4e7f845b3c 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -511,22 +511,14 @@ BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec //} - // FIRE-24175: Fix look at target clamping - bool isLookingAtSelf = false; - if(object){ - isLookingAtSelf = object->isAvatar() && ((LLVOAvatar*)(LLViewerObject*)object)->isSelf(); - } static LLCachedControl s_EnableLimiter(gSavedSettings, "FSLookAtTargetLimitDistance"); bool lookAtShouldClamp = s_EnableLimiter && - //(*mAttentions)[mTargetType].mName != "None" && - //(*mAttentions)[mTargetType].mName != "Idle" && + (*mAttentions)[mTargetType].mName != "None" && + (*mAttentions)[mTargetType].mName != "Idle" && (*mAttentions)[mTargetType].mName != "Respond" && (*mAttentions)[mTargetType].mName != "Conversation" && - //(*mAttentions)[mTargetType].mName != "FreeLook" && - //(*mAttentions)[mTargetType].mName != "AutoListen"; - (*mAttentions)[mTargetType].mName != "AutoListen" && - !isLookingAtSelf; - // FIRE-24175 + (*mAttentions)[mTargetType].mName != "FreeLook" && + (*mAttentions)[mTargetType].mName != "AutoListen"; if (!lookAtShouldClamp) //We do a similar but seperate calculation if we are doing limited distances { @@ -558,20 +550,25 @@ BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec { if (lookAtShouldClamp) { - // FIRE-24175: Fix look at target clamping - //if (mTargetObject->isAvatar() && ((LLVOAvatar*)(LLViewerObject*)mTargetObject)->isSelf()) - //{ - // //We use this branch and mimic our mouse/first person look pose. - // mTargetOffsetGlobal.setVec(gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition() + position)); - // mTargetObject = NULL; - //} - //else - //{ - //Otherwise, mimic looking at the object. + if (object->isAvatar()) + { + if (auto avatar = static_cast(object); !avatar->isSelf()) + { + // Looking at another avatar, have to aim at its head here since calcTargetPosition() doesn't do it anymore because we clear mTargetObject + mTargetOffsetGlobal.setVec(gAgent.getPosGlobalFromAgent(avatar->mHeadp->getWorldPosition())); + mTargetObject = nullptr; + } + else + { + // Continue normal when looking at ourself - lookat will be within the limit anyway + mTargetOffsetGlobal.setVec(position); + } + } + else + { mTargetOffsetGlobal.setVec(object->getPositionGlobal() + (LLVector3d)(position * object->getRotationRegion())); - mTargetObject = NULL; - //} - // FIRE-24175 + mTargetObject = nullptr; + } } else { @@ -583,7 +580,7 @@ BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec mTargetOffsetGlobal = gAgent.getPosGlobalFromAgent(position); } - if (lookAtShouldClamp) + if (lookAtShouldClamp && !mTargetObject) { static LLCachedControl s_Radius(gSavedSettings, "FSLookAtTargetMaxDistance"); @@ -850,8 +847,10 @@ bool LLHUDEffectLookAt::calcTargetPosition() // if selecting self, stare forward if (looking_at_self && mTargetOffsetGlobal.magVecSquared() < MIN_TARGET_OFFSET_SQUARED) { + // 1m in front of the avatar should be enough; changed because of distance clamp //sets the lookat point in front of the avatar - mTargetOffsetGlobal.setVec(5.0, 0.0, 0.0); + //mTargetOffsetGlobal.setVec(5.0, 0.0, 0.0); + mTargetOffsetGlobal.setVec(1.0, 0.0, 0.0); local_offset.setVec(mTargetOffsetGlobal); } diff --git a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml index 2ccea56ab7..372be5bd97 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml @@ -480,7 +480,7 @@ initial_value="160" layout="topleft" max_val="32" - min_val="4" + min_val="1" name="LimitLookAtDistance" width="150" />