From a57170724344842e26b8cd0fa4a47c24efa834c5 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 3 Aug 2017 14:23:02 +0100
Subject: SL-731 - render metadata includes triangle count, triangle and vertex
 count included with debug text for control avatar

---
 indra/newview/llcontrolavatar.cpp                  |  7 ++++--
 indra/newview/llviewermenu.cpp                     |  4 ++++
 indra/newview/llvovolume.cpp                       | 27 +++++++++++++++++++---
 indra/newview/pipeline.h                           |  9 ++++----
 indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++++++
 5 files changed, 48 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index fb61328a1b..d458e2951b 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -214,11 +214,14 @@ void LLControlAvatar::updateDebugText()
         std::string active_string;
         std::string lod_string;
         S32 total_tris = 0;
+        S32 total_verts = 0;
         for (std::vector<LLVOVolume*>::iterator it = volumes.begin();
              it != volumes.end(); ++it)
         {
             LLVOVolume *volp = *it;
-            total_tris += volp->getTriangleCount();
+            S32 verts = 0;
+            total_tris += volp->getTriangleCount(&verts);
+            total_verts += verts;
             lod_string += llformat("%d",volp->getLOD());
                         if (volp && volp->mDrawable)
             {
@@ -253,7 +256,7 @@ void LLControlAvatar::updateDebugText()
 #endif
 
         addDebugText(llformat("lod %s",lod_string.c_str()));
-        addDebugText(llformat("tris %d", total_tris));
+        addDebugText(llformat("tris %d verts %d", total_tris, total_verts));
         //addDebugText(llformat("anim time %.1f (step %f factor %f)", 
         //                      mMotionController.getAnimTime(),
         //                      mMotionController.getTimeStep(), 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index eddbe16482..f01c67e499 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1076,6 +1076,10 @@ U32 info_display_from_string(std::string info_display)
 	{
 		return LLPipeline::RENDER_DEBUG_TEXEL_DENSITY;
 	}
+	else if ("triangle count" == info_display)
+	{
+		return LLPipeline::RENDER_DEBUG_TRIANGLE_COUNT;
+	}
 	else
 	{
 		LL_WARNS() << "unrecognized feature name '" << info_display << "'" << LL_ENDL;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index c0814c5695..04e2827182 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1295,14 +1295,35 @@ BOOL LLVOVolume::calcLOD()
 	distance *= F_PI/3.f;
 
 	cur_detail = computeLODDetail(ll_round(distance, 0.01f), 
-									ll_round(radius, 0.01f));
+                                  ll_round(radius, 0.01f));
 
 
+    if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TRIANGLE_COUNT) && mDrawable->getFace(0))
+    {
+        if (isRootEdit() && getChildren().size()>0)
+        {
+            S32 total_tris = getTriangleCount();
+            LLViewerObject::const_child_list_t& child_list = getChildren();
+            for (LLViewerObject::const_child_list_t::const_iterator iter = child_list.begin();
+                 iter != child_list.end(); ++iter)
+            {
+                LLViewerObject* childp = *iter;
+                LLVOVolume *child_volp = dynamic_cast<LLVOVolume*>(childp);
+                total_tris += child_volp->getTriangleCount();
+            }
+            setDebugText(llformat("TRIS %d TOTAL %d", getTriangleCount(), total_tris));
+        }
+        else
+        {
+            setDebugText(llformat("TRIS %d", getTriangleCount()));
+        }
+	
+    }
 	if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_LOD_INFO) &&
 		mDrawable->getFace(0))
 	{
-        // This is a display for LODs. If you need the texture index, put it somewhere else!
-		setDebugText(llformat("lod %d", cur_detail));
+        // This is a debug display for LODs. Please don't put the texture index here.
+        setDebugText(llformat("%d", cur_detail));
 	}
 
 	if (cur_detail != mLOD)
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index bba36351d9..4cc4b821bf 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -513,11 +513,11 @@ public:
 		RENDER_DEBUG_TEXTURE_AREA		= 0x00000100,
 		RENDER_DEBUG_FACE_AREA			= 0x00000200,
 		RENDER_DEBUG_PARTICLES			= 0x00000400,
-		RENDER_DEBUG_GLOW				= 0x00000800,
+		RENDER_DEBUG_GLOW				= 0x00000800, // not used
 		RENDER_DEBUG_TEXTURE_ANIM		= 0x00001000,
 		RENDER_DEBUG_LIGHTS				= 0x00002000,
 		RENDER_DEBUG_BATCH_SIZE			= 0x00004000,
-		RENDER_DEBUG_ALPHA_BINS			= 0x00008000,
+		RENDER_DEBUG_ALPHA_BINS			= 0x00008000, // not used
 		RENDER_DEBUG_RAYCAST            = 0x00010000,
 		RENDER_DEBUG_AVATAR_DRAW_INFO	= 0x00020000,
 		RENDER_DEBUG_SHADOW_FRUSTA		= 0x00040000,
@@ -531,8 +531,9 @@ public:
 		RENDER_DEBUG_NORMALS	        = 0x04000000,
 		RENDER_DEBUG_LOD_INFO	        = 0x08000000,
 		RENDER_DEBUG_RENDER_COMPLEXITY  = 0x10000000,
-		RENDER_DEBUG_ATTACHMENT_BYTES	= 0x20000000,
-		RENDER_DEBUG_TEXEL_DENSITY		= 0x40000000
+		RENDER_DEBUG_ATTACHMENT_BYTES	= 0x20000000, // not used
+		RENDER_DEBUG_TEXEL_DENSITY		= 0x40000000,
+		RENDER_DEBUG_TRIANGLE_COUNT		= 0x80000000 
 	};
 
 public:
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 697d27907d..f8b4948697 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2653,6 +2653,16 @@
            function="Advanced.ToggleInfoDisplay"
            parameter="lod info" />
         </menu_item_check>
+        <menu_item_check
+         label="Triangle Count"
+         name="Triangle Count">
+          <menu_item_check.on_check
+           function="Advanced.CheckInfoDisplay"
+           parameter="triangle count" />
+          <menu_item_check.on_click
+           function="Advanced.ToggleInfoDisplay"
+           parameter="triangle count" />
+        </menu_item_check>
         <menu_item_check
          label="Build Queue"
          name="Build Queue">
-- 
cgit v1.2.3