summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterdebugmaterials.cpp
diff options
context:
space:
mode:
authorWilliam Todd Stinson <stinson@lindenlab.com>2012-10-09 12:30:38 -0700
committerWilliam Todd Stinson <stinson@lindenlab.com>2012-10-09 12:30:38 -0700
commit38a565f71a54aaa66300a0ab593e366731aac769 (patch)
tree8e96f9abeecf1b6ef02141cb9021ef2348c1f5aa /indra/newview/llfloaterdebugmaterials.cpp
parent002a54f7798761e3cc885253c46f4180c02e49c9 (diff)
Initial pass at getting a list of viewer objects with non-null material IDs.
Diffstat (limited to 'indra/newview/llfloaterdebugmaterials.cpp')
-rw-r--r--indra/newview/llfloaterdebugmaterials.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp
index 471e8e3dbf..85a0fc7a2f 100644
--- a/indra/newview/llfloaterdebugmaterials.cpp
+++ b/indra/newview/llfloaterdebugmaterials.cpp
@@ -44,6 +44,7 @@
#include "llfontgl.h"
#include "llhttpclient.h"
#include "lllineeditor.h"
+#include "llmaterialid.h"
#include "llscrolllistcell.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
@@ -56,7 +57,9 @@
#include "lltextvalidate.h"
#include "lluicolortable.h"
#include "lluictrl.h"
+#include "lluuid.h"
#include "llviewerobject.h"
+#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "v4color.h"
@@ -217,6 +220,10 @@ BOOL LLFloaterDebugMaterials::postBuild()
mPutScrollList = findChild<LLScrollListCtrl>("put_scroll_list");
llassert(mPutScrollList != NULL);
+ mQueryVisibleObjectsButton = findChild<LLButton>("query_visible_object_button");
+ llassert(mQueryVisibleObjectsButton != NULL);
+ mQueryVisibleObjectsButton->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onQueryVisibleObjectsClicked, this));
+
mGoodPostButton = findChild<LLButton>("good_post_button");
llassert(mGoodPostButton != NULL);
mGoodPostButton->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onGoodPostClicked, this));
@@ -316,6 +323,7 @@ LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams)
mPutSetButton(NULL),
mPutClearButton(NULL),
mPutScrollList(NULL),
+ mQueryVisibleObjectsButton(NULL),
mGoodPostButton(NULL),
mBadPostButton(NULL),
mPostScrollList(NULL),
@@ -365,6 +373,42 @@ void LLFloaterDebugMaterials::onPutClearClicked()
requestPutMaterials(false);
}
+void LLFloaterDebugMaterials::onQueryVisibleObjectsClicked()
+{
+ S32 numViewerObjects = gObjectList.getNumObjects();
+ for (S32 viewerObjectIndex = 0; viewerObjectIndex < numViewerObjects; ++viewerObjectIndex)
+ {
+ const LLViewerObject *viewerObject = gObjectList.getObject(viewerObjectIndex);
+ if ((viewerObject != NULL) && !viewerObject->isDead())
+ {
+ U8 objectNumTEs = viewerObject->getNumTEs();
+
+ if (objectNumTEs > 0U)
+ {
+ const LLUUID& objectId = viewerObject->getID();
+ U32 objectLocalId = viewerObject->getLocalID();
+ S32 objectNumFaces = viewerObject->getNumFaces();
+ const LLViewerRegion* objectRegion = viewerObject->getRegion();
+ for (U8 curTEIndex = 0U; curTEIndex < objectNumTEs; ++curTEIndex)
+ {
+ const LLTextureEntry* objectTE = viewerObject->getTE(curTEIndex);
+ llassert(objectTE != NULL);
+ const LLMaterialID& objectMaterialID = objectTE->getMaterialID();
+ if (!objectMaterialID.isNull())
+ {
+ llinfos << "STINSON DEBUG: #" << (viewerObjectIndex + 1) << ": " << objectId.asString()
+ << " (" << ((objectRegion != NULL) ? objectRegion->getRegionID().asString() : "<null>")
+ << ") [" << objectLocalId << "] {" << static_cast<unsigned int>(curTEIndex)
+ << "} : numFaces(" << objectNumFaces << ") material("
+ << convertToPrintableMaterialID(objectMaterialID) << ")" << llendl;
+ }
+ }
+ }
+
+ }
+ }
+}
+
void LLFloaterDebugMaterials::onGoodPostClicked()
{
requestPostMaterials(true);
@@ -1357,6 +1401,22 @@ std::string LLFloaterDebugMaterials::convertToPrintableMaterialID(const LLSD& pB
return materialIDString;
}
+std::string LLFloaterDebugMaterials::convertToPrintableMaterialID(const LLMaterialID& pMaterialID) const
+{
+ std::string materialID(reinterpret_cast<const char *>(pMaterialID.get()), 16);
+ std::string materialIDString;
+ for (unsigned int i = 0U; i < 4; ++i)
+ {
+ if (i != 0U)
+ {
+ materialIDString += "-";
+ }
+ const U32 *value = reinterpret_cast<const U32*>(&materialID.c_str()[i * 4]);
+ materialIDString += llformat("%08x", *value);
+ }
+ return materialIDString;
+}
+
S32 LLFloaterDebugMaterials::getNormalMapOffsetX() const
{
return getLineEditorValue(mNormalMapOffsetX);