From 668307e4e3b59ac4f4f955aa0d36183c361352b8 Mon Sep 17 00:00:00 2001
From: Robin Cornelius <none@none>
Date: Wed, 23 Feb 2011 15:50:55 -0500
Subject: [PATCH] STORM-1019 Add ability to display beacons for Media on a Prim
 objects Changes merged into viewer 2 by Jonathan Yap

---
 doc/contributions.txt                         |  2 +
 indra/newview/app_settings/settings.xml       | 11 ++++
 indra/newview/llfloaterbeacons.cpp            |  2 +
 indra/newview/llviewermenu.cpp                | 10 ++++
 indra/newview/llviewerwindow.cpp              |  5 ++
 indra/newview/pipeline.cpp                    | 60 +++++++++++++++++++
 indra/newview/pipeline.h                      |  5 ++
 .../skins/default/xui/en/floater_beacons.xml  | 14 ++++-
 8 files changed, 107 insertions(+), 2 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 5d59627a929..d6ac7b4b3a4 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -396,6 +396,7 @@ Jonathan Yap
 	VWR-17801
 	VWR-24347
 	STORM-975
+	STORM-1019
 Kage Pixel
 	VWR-11
 Ken March
@@ -624,6 +625,7 @@ Robin Cornelius
 	SNOW-747
 	STORM-422
 	STORM-960
+	STORM-1019
 	VWR-2488
 	VWR-9557
 	VWR-10579
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a0105240911..d8b23d9d885 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12069,6 +12069,17 @@
       <key>Value</key>
       <real>0.40000000596</real>
     </map>
+	<key>moapbeacon</key>
+	<map>
+		<key>Comment</key>
+		<string>Beacon / Highlight media on a prim sources</string>
+		<key>Persist</key>
+		<integer>1</integer>
+		<key>Type</key>
+		<string>Boolean</string>
+		<key>Value</key>
+		<integer>0</integer>
+	</map>
     <key>particlesbeacon</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloaterbeacons.cpp b/indra/newview/llfloaterbeacons.cpp
index e24df948c42..316294a4774 100644
--- a/indra/newview/llfloaterbeacons.cpp
+++ b/indra/newview/llfloaterbeacons.cpp
@@ -48,6 +48,7 @@ LLFloaterBeacons::LLFloaterBeacons(const LLSD& seed)
 	LLPipeline::setRenderParticleBeacons(     gSavedSettings.getBOOL("particlesbeacon"));
 	LLPipeline::setRenderHighlights(          gSavedSettings.getBOOL("renderhighlights"));
 	LLPipeline::setRenderBeacons(             gSavedSettings.getBOOL("renderbeacons"));
+	LLPipeline::setRenderMOAPBeacons(		  gSavedSettings.getBOOL("moapbeacon"));
 	mCommitCallbackRegistrar.add("Beacons.UICheck",	boost::bind(&LLFloaterBeacons::onClickUICheck, this,_1));
 }
 
@@ -96,6 +97,7 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
 	else if(name == "physical")       LLPipeline::setRenderPhysicalBeacons(check->get());
 	else if(name == "sounds")         LLPipeline::setRenderSoundBeacons(check->get());
 	else if(name == "particles")      LLPipeline::setRenderParticleBeacons(check->get());
+	else if(name == "moapbeacon")     LLPipeline::setRenderMOAPBeacons(check->get());
 	else if(name == "highlights")
 	{
 		LLPipeline::toggleRenderHighlights(NULL);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 7cc04e0338a..82bfe9ec643 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7356,6 +7356,11 @@ class LLViewToggleBeacon : public view_listener_t
 			LLPipeline::toggleRenderPhysicalBeacons(NULL);
 			gSavedSettings.setBOOL( "physicalbeacon", LLPipeline::getRenderPhysicalBeacons(NULL) );
 		}
+		else if (beacon == "moapbeacon")
+		{
+			LLPipeline::toggleRenderMOAPBeacons(NULL);
+			gSavedSettings.setBOOL( "moapbeacon", LLPipeline::getRenderMOAPBeacons(NULL) );
+		}
 		else if (beacon == "soundsbeacon")
 		{
 			LLPipeline::toggleRenderSoundBeacons(NULL);
@@ -7415,6 +7420,11 @@ class LLViewCheckBeaconEnabled : public view_listener_t
 			new_value = gSavedSettings.getBOOL( "scriptsbeacon");
 			LLPipeline::setRenderScriptedBeacons(new_value);
 		}
+		else if (beacon == "moapbeacon")
+		{
+			new_value = gSavedSettings.getBOOL( "moapbeacon");
+			LLPipeline::setRenderMOAPBeacons(new_value);
+		}
 		else if (beacon == "physicalbeacon")
 		{
 			new_value = gSavedSettings.getBOOL( "physicalbeacon");
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 0028ced6c8a..b5cdd733ff9 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -584,6 +584,11 @@ class LLDebugText
 				addText(xpos, ypos, "Viewing scripted object beacons (red)");
 				ypos += y_inc;
 			}
+			if (LLPipeline::getRenderMOAPBeacons(NULL))
+			{
+				addText(xpos, ypos, "Viewing MOAP beacons (white)");
+				ypos += y_inc;
+			}
 			else
 				if (LLPipeline::getRenderScriptedTouchBeacons(NULL))
 				{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 13e537fae59..911961777b3 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -253,6 +253,7 @@ S32		LLPipeline::sCompiles = 0;
 BOOL	LLPipeline::sPickAvatar = TRUE;
 BOOL	LLPipeline::sDynamicLOD = TRUE;
 BOOL	LLPipeline::sShowHUDAttachments = TRUE;
+BOOL	LLPipeline::sRenderMOAPBeacons = FALSE;
 BOOL	LLPipeline::sRenderPhysicalBeacons = TRUE;
 BOOL	LLPipeline::sRenderScriptedBeacons = FALSE;
 BOOL	LLPipeline::sRenderScriptedTouchBeacons = TRUE;
@@ -2510,6 +2511,42 @@ void renderPhysicalBeacons(LLDrawable* drawablep)
 	}
 }
 
+void renderMOAPBeacons(LLDrawable* drawablep)
+{
+	LLViewerObject *vobj = drawablep->getVObj();
+
+	if(!vobj || vobj->isAvatar())
+		return;
+
+	BOOL beacon=FALSE;
+	U8 tecount=vobj->getNumTEs();
+	for(int x=0;x<tecount;x++)
+	{
+		if(vobj->getTE(x)->hasMedia())
+		{
+			beacon=TRUE;
+			break;
+		}
+	}
+	if(beacon==TRUE)
+	{
+		if (gPipeline.sRenderBeacons)
+		{
+			gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 1.f, 1.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth"));
+		}
+
+		if (gPipeline.sRenderHighlight)
+		{
+			S32 face_id;
+			S32 count = drawablep->getNumFaces();
+			for (face_id = 0; face_id < count; face_id++)
+			{
+				gPipeline.mHighlightFaces.push_back(drawablep->getFace(face_id) );
+			}
+		}
+	}
+}
+
 void renderParticleBeacons(LLDrawable* drawablep)
 {
 	// Look for attachments, objects, etc.
@@ -2715,6 +2752,11 @@ void LLPipeline::postSort(LLCamera& camera)
 			forAllVisibleDrawables(renderPhysicalBeacons);
 		}
 
+		if(sRenderMOAPBeacons)
+		{
+			forAllVisibleDrawables(renderMOAPBeacons);
+		}
+
 		if (sRenderParticleBeacons)
 		{
 			forAllVisibleDrawables(renderParticleBeacons);
@@ -4937,6 +4979,24 @@ BOOL LLPipeline::getRenderScriptedTouchBeacons(void*)
 	return sRenderScriptedTouchBeacons;
 }
 
+// static
+void LLPipeline::setRenderMOAPBeacons(BOOL val)
+{
+	sRenderMOAPBeacons = val;
+}
+
+// static
+void LLPipeline::toggleRenderMOAPBeacons(void*)
+{
+	sRenderMOAPBeacons = !sRenderMOAPBeacons;
+}
+
+// static
+BOOL LLPipeline::getRenderMOAPBeacons(void*)
+{
+	return sRenderMOAPBeacons;
+}
+
 // static
 void LLPipeline::setRenderPhysicalBeacons(BOOL val)
 {
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index e99b0d71e3f..92ae40ebb07 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -312,6 +312,10 @@ class LLPipeline
 	static void toggleRenderSoundBeacons(void* data);
 	static BOOL getRenderSoundBeacons(void* data);
 
+	static void setRenderMOAPBeacons(BOOL val);
+	static void toggleRenderMOAPBeacons(void * data);
+	static BOOL getRenderMOAPBeacons(void * data);
+
 	static void setRenderPhysicalBeacons(BOOL val);
 	static void toggleRenderPhysicalBeacons(void* data);
 	static BOOL getRenderPhysicalBeacons(void* data);
@@ -698,6 +702,7 @@ class LLPipeline
 	S32						mLightingDetail;
 		
 	static BOOL				sRenderPhysicalBeacons;
+	static BOOL				sRenderMOAPBeacons;
 	static BOOL				sRenderScriptedTouchBeacons;
 	static BOOL				sRenderScriptedBeacons;
 	static BOOL				sRenderParticleBeacons;
diff --git a/indra/newview/skins/default/xui/en/floater_beacons.xml b/indra/newview/skins/default/xui/en/floater_beacons.xml
index 4fc2b698d80..3d29356b225 100644
--- a/indra/newview/skins/default/xui/en/floater_beacons.xml
+++ b/indra/newview/skins/default/xui/en/floater_beacons.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
  legacy_header_height="18"
- height="225"
+ height="245"
  layout="topleft"
  name="beacons"
  help_topic="beacons"
@@ -12,7 +12,7 @@
  width="240">
     <panel
      follows="left|top|right|bottom"
-     height="200"
+     height="240"
      layout="topleft"
      left="10"
      name="beacons_panel"
@@ -133,6 +133,16 @@
           <check_box.commit_callback
            function="Beacons.UICheck" />
         </check_box>
+         <check_box
+         control_name="moapbeacon"
+         height="16"
+         left="0"
+         label="Media sources"
+         layout="topleft"
+         name="moapbeacon" >
+          <check_box.commit_callback
+           function="Beacons.UICheck" />
+        </check_box>
 
     </panel>
 </floater>
-- 
GitLab