From a0392ec5ec5703bd54bc4e091820d1c1423bbad4 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 2 Dec 2012 21:29:43 +0100 Subject: Refactor LLFloaterDebugMaterials::convertToPrintableMaterialID() as LLMaterialID::asString() so it can be used everywhere --- indra/llprimitive/llmaterialid.cpp | 15 +++++++++++++++ indra/llprimitive/llmaterialid.h | 1 + indra/newview/llfloaterdebugmaterials.cpp | 19 +------------------ indra/newview/llfloaterdebugmaterials.h | 1 - 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 7df23e5ee0..73a61f9c54 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -111,6 +111,21 @@ LLSD LLMaterialID::asLLSD() const return materialID; } +std::string LLMaterialID::asString() const +{ + std::string materialIDString; + for (unsigned int i = 0U; i < 4; ++i) + { + if (i != 0U) + { + materialIDString += "-"; + } + const U32 *value = reinterpret_cast(&mID[i * 4]); + materialIDString += llformat("%08x", *value); + } + return materialIDString; +} + void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID) { llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8))); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 1578172aec..a474703f79 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -50,6 +50,7 @@ public: void clear(); LLSD asLLSD() const; + std::string asString() const; static const LLMaterialID null; diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index 026fd1a28c..7b3ad7aa13 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -972,9 +972,8 @@ void LLFloaterDebugMaterials::parseQueryViewableObjects() rowParams.columns.add(cellParams); cellParams.font = LLFontGL::getFontMonospace(); - std::string materialIDString = convertToPrintableMaterialID(objectMaterialID); cellParams.column = "material_id"; - cellParams.value = materialIDString; + cellParams.value = objectMaterialID.asString(); rowParams.columns.add(cellParams); LLSD rowValue = LLSD::emptyMap(); @@ -1624,22 +1623,6 @@ std::string LLFloaterDebugMaterials::convertToPrintableMaterialID(const LLSD& pB return materialIDString; } -std::string LLFloaterDebugMaterials::convertToPrintableMaterialID(const LLMaterialID& pMaterialID) const -{ - std::string materialID(reinterpret_cast(pMaterialID.get()), 16); - std::string materialIDString; - for (unsigned int i = 0U; i < 4; ++i) - { - if (i != 0U) - { - materialIDString += "-"; - } - const U32 *value = reinterpret_cast(&materialID.c_str()[i * 4]); - materialIDString += llformat("%08x", *value); - } - return materialIDString; -} - template T getLineEditorValue(const LLLineEditor *pLineEditor); template<> U8 getLineEditorValue(const LLLineEditor *pLineEditor) diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h index 0643d7a252..572b17af27 100644 --- a/indra/newview/llfloaterdebugmaterials.h +++ b/indra/newview/llfloaterdebugmaterials.h @@ -135,7 +135,6 @@ private: void updateStatusMessage(); void updateControls(); std::string convertToPrintableMaterialID(const LLSD& pBinaryHash) const; - std::string convertToPrintableMaterialID(const LLMaterialID& pMaterialID) const; LLMaterial getMaterial() const; -- cgit v1.2.3