From 8a19c8e073e6f34dc1579ed7ab2ac64f567a1793 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Fri, 11 Nov 2022 15:19:41 -0600
Subject: [PATCH] SL-18615 Fix for beacons not rendering and beacon highlights
 flickering.

---
 indra/newview/llglsandbox.cpp        |  4 ++--
 indra/newview/llviewerdisplay.cpp    |  9 +++++++++
 indra/newview/llviewerobjectlist.cpp |  3 +++
 indra/newview/pipeline.cpp           | 14 +++-----------
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 38ec24cae87..78dba81d9a3 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -815,7 +815,7 @@ void LLViewerObjectList::renderObjectBeacons()
 			const LLVector3 &thisline = debug_beacon.mPositionAgent;
 		
 			gGL.begin(LLRender::LINES);
-			gGL.color4fv(color.mV);
+			gGL.color4fv(linearColor4(color).mV);
 			draw_cross_lines(thisline, 2.0f, 2.0f, 50.f);
 			draw_line_cube(0.10f, thisline);
 			
@@ -844,7 +844,7 @@ void LLViewerObjectList::renderObjectBeacons()
 
 			const LLVector3 &thisline = debug_beacon.mPositionAgent;
 			gGL.begin(LLRender::LINES);
-			gGL.color4fv(debug_beacon.mColor.mV);
+			gGL.color4fv(linearColor4(debug_beacon.mColor).mV);
 			draw_cross_lines(thisline, 0.5f, 0.5f, 0.5f);
 			draw_line_cube(0.10f, thisline);
 
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index c2f9779a532..7709054d24f 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1562,6 +1562,15 @@ void render_ui_3d()
 	}
 
 	gViewerWindow->renderSelections(FALSE, FALSE, TRUE); // Non HUD call in render_hud_elements
+
+    if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+    {
+        // Render debugging beacons.
+        gObjectList.renderObjectBeacons();
+        gObjectList.resetObjectBeacons();
+        gSky.addSunMoonBeacons();
+    }
+
 	stop_glerror();
 }
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 768b4f425b4..955979e6054 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1812,12 +1812,15 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 &center)
 {
 }
 
+extern BOOL gCubeSnapshot;
+
 void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent,
 										const std::string &string,
 										const LLColor4 &color,
 										const LLColor4 &text_color,
 										S32 line_width)
 {
+    llassert(!gCubeSnapshot);
 	LLDebugBeacon beacon;
 	beacon.mPositionAgent = pos_agent;
 	beacon.mString = string;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index aacf6fa73e5..aa4cd38b995 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3918,7 +3918,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 	LL_PUSH_CALLSTACKS();
 	// only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus
-	if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender)
+	if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender && !gCubeSnapshot)
 	{
 		if (sRenderScriptedTouchBeacons)
 		{
@@ -3971,12 +3971,12 @@ void LLPipeline::postSort(LLCamera& camera)
 	}
 	LL_PUSH_CALLSTACKS();
 	// If managing your telehub, draw beacons at telehub and currently selected spawnpoint.
-	if (LLFloaterTelehub::renderBeacons() && !sShadowRender)
+	if (LLFloaterTelehub::renderBeacons() && !sShadowRender && !gCubeSnapshot)
 	{
 		LLFloaterTelehub::addBeacons();
 	}
 
-	if (!sShadowRender)
+	if (!sShadowRender && !gCubeSnapshot)
 	{
 		mSelectedFaces.clear();
 
@@ -7645,14 +7645,6 @@ void LLPipeline::renderFinalize()
         gGL.popMatrix();
 
         LLVertexBuffer::unbind();
-
-        if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
-        {
-            // Render debugging beacons.
-            gObjectList.renderObjectBeacons();
-            gObjectList.resetObjectBeacons();
-            gSky.addSunMoonBeacons();
-        }
     }
 
     if (sRenderGlow)
-- 
GitLab