From 732ab0abc7fea476ac7d956a21163a411c1b5f68 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 13 Apr 2023 12:20:52 -0400
Subject: [PATCH] Remove Look At features that do nothing to actually improve
 the user experience and actually cause harm.

---
 .../newview/app_settings/settings_alchemy.xml | 10 +--
 indra/newview/llagentcamera.cpp               |  9 +--
 indra/newview/llhudeffectlookat.cpp           | 79 +++---------------
 indra/newview/llhudeffectlookat.h             |  5 +-
 indra/newview/llviewermenu.cpp                |  5 +-
 .../xui/en/panel_preferences_privacy.xml      | 80 -------------------
 6 files changed, 22 insertions(+), 166 deletions(-)

diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml
index a907d3137a8..8982d73db8c 100644
--- a/indra/newview/app_settings/settings_alchemy.xml
+++ b/indra/newview/app_settings/settings_alchemy.xml
@@ -423,7 +423,7 @@
     <key>AlchemyLookAtShow</key>
     <map>
       <key>Comment</key>
-      <string>If true, avatar look at beacons will be displayed</string>
+      <string>[OBSOLETE]</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -434,7 +434,7 @@
     <key>AlchemyLookAtLines</key>
     <map>
       <key>Comment</key>
-      <string>Render a line from Look At beacon to the originating avatar</string>
+      <string>[OBSOLETE]</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -445,7 +445,7 @@
     <key>AlchemyLookAtNames</key>
     <map>
       <key>Comment</key>
-      <string>Render name of originating avatar under Look At beacon</string>
+      <string>[OBSOLETE]</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -456,7 +456,7 @@
     <key>AlchemyLookAtHideSelf</key>
     <map>
       <key>Comment</key>
-      <string>Hide own Look At beacon when Look At render is enabled</string>
+      <string>[OBSOLETE]</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -467,7 +467,7 @@
     <key>AlchemyLookAtPrivate</key>
     <map>
       <key>Comment</key>
-      <string>Disable broadcast of own look at to other users.</string>
+      <string>[OBSOLETE]</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 4152db363bb..16e1168ed2d 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -2971,14 +2971,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL re
 
 BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
 {
-	static LLCachedControl<bool> isPrivate(gSavedSettings, "AlchemyLookAtPrivate", false);
-	if (isPrivate)
-	{
-		target_type = LOOKAT_TARGET_NONE;
-		object = gAgentAvatarp;
-		position.clearVec();
-	}
-	else if(object && object->isAttachment())
+	if(object && object->isAttachment())
 	{
 		LLViewerObject* parent = object;
 		while(parent)
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 320fd58fe2e..6d2174e2e6b 100644
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -43,9 +43,8 @@
 #include "llglheaders.h"
 #include "llxmltree.h"
 
-#include "llavatarnamecache.h"
-#include "llhudrender.h"
-#include "llviewercontrol.h"
+
+BOOL LLHUDEffectLookAt::sDebugLookAt = FALSE;
 
 // packet layout
 const S32 SOURCE_AVATAR = 0;
@@ -242,8 +241,7 @@ static BOOL loadAttentions()
 LLHUDEffectLookAt::LLHUDEffectLookAt(const U8 type) : 
 	LLHUDEffect(type), 
 	mKillTime(0.f),
-	mLastSendTime(0.f),
-	mDebugLookAt(gSavedSettings, "AlchemyLookAtShow", false)
+	mLastSendTime(0.f)
 {
 	clearLookAtTarget();
 	// parse the default sets
@@ -563,14 +561,8 @@ void LLHUDEffectLookAt::setSourceObject(LLViewerObject* objectp)
 //-----------------------------------------------------------------------------
 void LLHUDEffectLookAt::render()
 {
-	if (mDebugLookAt && mSourceObject.notNull())
+	if (sDebugLookAt && mSourceObject.notNull())
 	{
-		static LLCachedControl<bool> isOwnHidden(gSavedSettings, "AlchemyLookAtHideSelf", true);
-		static LLCachedControl<bool> isPrivate(gSavedSettings, "AlchemyLookAtPrivate", false);
-
-		if ((isOwnHidden || isPrivate) && static_cast<LLVOAvatar*>(mSourceObject.get())->isSelf())
-			return;
-
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
 		//LLGLDisable gls_stencil(GL_STENCIL_TEST);
@@ -579,7 +571,7 @@ void LLHUDEffectLookAt::render()
 		gGL.matrixMode(LLRender::MM_MODELVIEW);
 		gGL.pushMatrix();
 		gGL.translatef(target.mV[VX], target.mV[VY], target.mV[VZ]);
-		gGL.scalef(0.1f, 0.1f, 0.1f);
+		gGL.scalef(0.3f, 0.3f, 0.3f);
 		gGL.begin(LLRender::LINES);
 		{
 			LLColor3 color = (*mAttentions)[mTargetType].mColor;
@@ -592,62 +584,8 @@ void LLHUDEffectLookAt::render()
 
 			gGL.vertex3f(0.f, 0.f, -1.f);
 			gGL.vertex3f(0.f, 0.f, 1.f);
-
-			static LLCachedControl<bool> lookAtLines(gSavedSettings, "AlchemyLookAtLines", false);
-			if(lookAtLines)
-			{
-				const std::string targname = (*mAttentions)[mTargetType].mName;
-				if(targname != "None" && targname != "Idle" && targname != "AutoListen")
-				{
-					LLVector3 dist = (mSourceObject->getWorldPosition() - mTargetPos) * 10;
-					gGL.vertex3f(0.f, 0.f, 0.f);
-					gGL.vertex3f(dist.mV[VX], dist.mV[VY], dist.mV[VZ] + 0.5f);
-				}
-			}
-		}
-		gGL.end();
+		} gGL.end();
 		gGL.popMatrix();
-
-		static LLCachedControl<U32> lookAtNames(gSavedSettings, "AlchemyLookAtNames", 0);
-		if(lookAtNames > 0)
-		{
-			std::string text;
-			LLAvatarName av_name;
-			LLAvatarNameCache::get(static_cast<LLVOAvatar*>(mSourceObject.get())->getID(), &av_name);
-			switch (lookAtNames)
-			{
-				case 1: // Display Name (user.name)
-					text = av_name.getCompleteName();
-					break;
-				case 2: // Display Name
-					text = av_name.getDisplayName();
-					break;
-				case 3: // First Last
-					text = av_name.getUserName();
-					break;
-				default: //user.name
-					text = av_name.getAccountName();
-					break;
-			}
-
-			const LLFontGL* fontp = LLFontGL::getFontSansSerif();
-			gGL.pushMatrix();
-
-			LLWString wstr(utf8str_to_wstring(text));
-
-			hud_render_text(
-				wstr,
-				target + LLVector3(0.f, 0.f, 0.15f),
-				*fontp,
-				LLFontGL::NORMAL, 
-				LLFontGL::NO_SHADOW,
-				-0.5f * fontp->getWidthF32(wstr.c_str()),
-				0.0f,
-				(*mAttentions)[mTargetType].mColor, 
-				FALSE
-			);
-			gGL.popMatrix();
-		}
 	}
 }
 
@@ -700,6 +638,11 @@ void LLHUDEffectLookAt::update()
 			}
 		}
 	}
+
+	if (sDebugLookAt)
+	{
+		((LLVOAvatar*)(LLViewerObject*)mSourceObject)->addDebugText((*mAttentions)[mTargetType].mName);
+	}
 }
 
 /**
diff --git a/indra/newview/llhudeffectlookat.h b/indra/newview/llhudeffectlookat.h
index c1bc0b02a26..22e487126af 100644
--- a/indra/newview/llhudeffectlookat.h
+++ b/indra/newview/llhudeffectlookat.h
@@ -28,7 +28,6 @@
 #define LL_LLHUDEFFECTLOOKAT_H
 
 #include "llhudeffect.h"
-#include "llcontrol.h"
 
 class LLViewerObject;
 class LLVOAvatar;
@@ -79,6 +78,9 @@ class LLHUDEffectLookAt final : public LLHUDEffect
 	void setTargetObjectAndOffset(LLViewerObject *objp, LLVector3d offset);
 	void setTargetPosGlobal(const LLVector3d &target_pos_global);
 
+public:
+	static BOOL sDebugLookAt;
+
 private:
 	ELookAtType					mTargetType;
 	LLVector3d					mTargetOffsetGlobal;
@@ -88,7 +90,6 @@ class LLHUDEffectLookAt final : public LLHUDEffect
 	LLVector3					mTargetPos;
 	F32							mLastSendTime;
 	LLAttentionSet*				mAttentions;
-	LLCachedControl<bool> mDebugLookAt;
 };
 
 #endif // LL_LLHUDEFFECTLOOKAT_H
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index b927dd8e4b5..93a09f9b8b5 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1909,8 +1909,7 @@ class LLAdvancedToggleShowLookAt : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		bool value = !gSavedSettings.getBOOL("AlchemyLookAtShow");
-		gSavedSettings.setBOOL("AlchemyLookAtShow", value);
+		LLHUDEffectLookAt::sDebugLookAt = !(LLHUDEffectLookAt::sDebugLookAt);
 		return true;
 	}
 };
@@ -1919,7 +1918,7 @@ class LLAdvancedCheckShowLookAt : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		bool new_value = gSavedSettings.getBOOL("AlchemyLookAtShow");
+		bool new_value = LLHUDEffectLookAt::sDebugLookAt;
 		return new_value;
 	}
 };
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 73be714d92a..a078f08cd08 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
@@ -152,66 +152,7 @@
          width="250"
          control_name="AlchemyLookAtShow"
          tool_tip="Enable crosshairs marking where people are looking."/>
-        <text
-         type="string"
-         length="1"
-         follows="left|top"
-         height="15"
-         layout="topleft"
-         left="290"
-         name="lookatnames"
-		     tool_tip="Select whether to show avatar names on the LookAt crosshairs"
-         left_delta="250"
-         width="70">
-            Name Style:
-        </text>
-        <combo_box
-         control_name="AlchemyLookAtNames"
-         follows="left|top"
-         height="23"
-         layout="topleft"
 
-         left_pad="0"
-         max_chars="135"
-         name="lookatshownames_combobox"
-         width="150">
-            <combo_box.item
-             enabled="true"
-             label="None"
-             name="None"
-             value="0" />
-            <combo_box.item
-             enabled="true"
-             label="Complete name"
-             name="Complete_Name"
-             value="1" />
-            <combo_box.item
-             enabled="true"
-             label="Display name"
-             name="Display_Name"
-             value="2" />
-            <combo_box.item
-             enabled="true"
-             label="Legacy name"
-             name="Legacy_Name"
-             value="3" />
-            <combo_box.item
-             enabled="true"
-             label="Username"
-             name="User_Name"
-             value="4" />
-        </combo_box>
-
-        <check_box
-         control_name="AlchemyLookAtLines"
-         height="16"
-         label="Show a line from the Look At beacon to its owner"
-         layout="topleft"
-         left="30"
-         name="lineslookat"
-         tool_tip="See a line connecting the camera focus point to the avatar. Useful to find where they are."
-         top_pad="4"
-         width="350" />
 
         <text
          type="string"
@@ -225,28 +166,8 @@
          text_color="LtGray_50">
             My LookAt:
         </text>
-	    	<check_box
-         control_name="AlchemyLookAtHideSelf"
-         height="16"
-         initial_value="true"
-         label="Don't show me my LookAt target"
-         layout="topleft"
-         left="30"
-         name="LookAtHideOwn"
-         tool_tip="Don't show me my own camera crosshairs"
-         width="350" />
-        <check_box
-         control_name="AlchemyLookAtPrivate"
-         height="16"
-         label="Don't send my actual camera target to others"
-         layout="topleft"
-         left="30"
-         name="privatelookat"
-         tool_tip="Disable your camera focus point from showing to others"
-         width="350" />
         <check_box
          control_name="AlchemyLookAtClampEnabled"
-         disabled_control="AlchemyLookAtPrivate"
          height="16"
          label="Limit camera target distance"
          layout="topleft"
@@ -262,7 +183,6 @@
             max_val="128"
             follows="top|left"
             control_name="AlchemyLookAtClampDistance"
-            disabled_control="AlchemyLookAtPrivate"
             initial_value="1.0"
             increment="0.5"
             label="Max Distance"
-- 
GitLab