From 1e26dbdcd27a1f29fe249cc7e074e5ede284bac8 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 01:46:26 +0100 Subject: Started LLMaterialMgr to handle viewer<->region materials communication * refactored LLFloaterDebugMaterials::requestPutMaterials() to use LLMaterialMgr instead * replaced "Object editing" results list with information about the active selection instead --- indra/newview/llmaterialmgr.cpp | 270 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 indra/newview/llmaterialmgr.cpp (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp new file mode 100644 index 0000000000..5ba7ad5a05 --- /dev/null +++ b/indra/newview/llmaterialmgr.cpp @@ -0,0 +1,270 @@ +/** + * @file llmaterialmgr.cpp + * @brief Material manager + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llsdserialize.h" + +#include "llmaterialmgr.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" + +/** + * Materials cap parameters + */ + +#define MATERIALS_CAPABILITY_NAME "RenderMaterials" + +#define MATERIALS_CAP_ZIP_FIELD "Zipped" + +#define MATERIALS_CAP_FULL_PER_FACE_FIELD "FullMaterialsPerFace" +#define MATERIALS_CAP_FACE_FIELD "Face" +#define MATERIALS_CAP_MATERIAL_FIELD "Material" +#define MATERIALS_CAP_OBJECT_ID_FIELD "ID" +#define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" + +/** + * LLMaterialsResponder helper class + */ + +class LLMaterialsResponder : public LLHTTPClient::Responder +{ +public: + typedef boost::function CallbackFunction; + + LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback); + virtual ~LLMaterialsResponder(); + + virtual void result(const LLSD& pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +private: + std::string mMethod; + std::string mCapabilityURL; + CallbackFunction mCallback; +}; + +LLMaterialsResponder::LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback) + : LLHTTPClient::Responder() + , mMethod(pMethod) + , mCapabilityURL(pCapabilityURL) + , mCallback(pCallback) +{ +} + +LLMaterialsResponder::~LLMaterialsResponder() +{ +} + +void LLMaterialsResponder::result(const LLSD& pContent) +{ + mCallback(true, pContent); +} + +void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) +{ + LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; + LL_WARNS("debugMaterials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME + << "' with url '" << mCapabilityURL << "' because " << pReason << LL_ENDL; + LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; + + LLSD emptyResult; + mCallback(false, emptyResult); +} + +/** + * LLMaterialMgr class + */ + +LLMaterialMgr::LLMaterialMgr() +{ +} + +LLMaterialMgr::~LLMaterialMgr() +{ +} + +void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) +{ + put_queue_t::iterator itQueue = mPutQueue.find(object_id); + if (mPutQueue.end() == itQueue) + { + mPutQueue.insert(std::pair(object_id, facematerial_map_t())); + itQueue = mPutQueue.find(object_id); + } + + facematerial_map_t::iterator itFace = itQueue->second.find(te); + if (itQueue->second.end() == itFace) + { + itQueue->second.insert(std::pair(te, material)); + } + else + { + itFace->second = material; + } +} + +void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUID& object_id) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + LLViewerObject* objectp = gObjectList.findObject(object_id); + if (!objectp) + { + LL_WARNS("debugMaterials") << "Received PUT response for unknown object" << LL_ENDL; + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + + LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + else + { + llassert(response_data.isArray()); + + for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter) + { + const LLSD& face_data = *faceIter; + llassert(face_data.isMap()); + + llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(face_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isInteger()); + U32 local_id = face_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asInteger(); + if (objectp->getLocalID() != local_id) + { + LL_ERRS("debugMaterials") << "Received PUT response for wrong object" << LL_ENDL; + continue; + } + + llassert(face_data.has(MATERIALS_CAP_FACE_FIELD)); + llassert(face_data.get(MATERIALS_CAP_FACE_FIELD).isInteger()); + S32 te = face_data.get(MATERIALS_CAP_FACE_FIELD).asInteger(); + + llassert(face_data.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); + llassert(face_data.get(MATERIALS_CAP_MATERIAL_ID_FIELD).isBinary()); + LLMaterialID material_id(face_data.get(MATERIALS_CAP_MATERIAL_ID_FIELD).asBinary()); + + LL_INFOS("debugMaterials") << "Setting material '" << material_id.asString() << "' on object '" << local_id + << "' face " << te << LL_ENDL; + + objectp->setTEMaterialID(te, material_id); + } + } +} + +void LLMaterialMgr::processPutQueue() +{ + put_queue_t::iterator itQueue = mPutQueue.begin(); + while (itQueue != mPutQueue.end()) + { + put_queue_t::iterator curQueue = itQueue++; + + const LLUUID& object_id = curQueue->first; + const LLViewerObject* objectp = gObjectList.findObject(object_id); + if ( (!objectp) || (!objectp->getRegion()) ) + { + LL_WARNS("debugMaterials") << "Object or object region is NULL" << LL_ENDL; + + mPutQueue.erase(curQueue); + continue; + } + + const LLViewerRegion* regionp = objectp->getRegion(); + if (!regionp->capabilitiesReceived()) + { + continue; + } + + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + + mPutQueue.erase(curQueue); + continue; + } + + LLSD facesData = LLSD::emptyArray(); + for (facematerial_map_t::const_iterator itFace = curQueue->second.begin(); itFace != curQueue->second.end(); ++itFace) + { + LLSD faceData = LLSD::emptyMap(); + faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); + faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(objectp->getLocalID()); + if (!itFace->second.isNull()) + { + faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); + } + facesData.append(faceData); + + LL_INFOS("debugMaterials") << "Requesting material change on object '" << faceData[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger() + << "' face " << faceData[MATERIALS_CAP_FACE_FIELD].asInteger() << LL_ENDL; + } + + LLSD materialsData = LLSD::emptyMap(); + materialsData[MATERIALS_CAP_FULL_PER_FACE_FIELD] = facesData; + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + + mPutQueue.erase(curQueue); + continue; + } + else + { + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); + + LLSD putData = LLSD::emptyMap(); + putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + + // *HACK: the viewer can't lookup the local object id the cap returns so we'll pass the object's uuid along + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2, object_id)); + LLHTTPClient::put(capURL, putData, materialsResponder); + } + } +} -- cgit v1.3 From 25bffc3d43ec7696c0a9fab43514affbfe006fb9 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 15:20:11 +0100 Subject: Added LLMaterialMgr::get() to retrieve individual materials (with optional callback) --- indra/llprimitive/llmaterial.h | 4 + indra/llprimitive/llmaterialid.cpp | 5 + indra/llprimitive/llmaterialid.h | 1 + indra/newview/llfloaterdebugmaterials.cpp | 415 +++++++++--------------------- indra/newview/llfloaterdebugmaterials.h | 7 +- indra/newview/llmaterialmgr.cpp | 157 +++++++++++ indra/newview/llmaterialmgr.h | 18 ++ 7 files changed, 310 insertions(+), 297 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 42e3dd04b9..da364e548c 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -27,6 +27,8 @@ #ifndef LL_LLMATERIAL_H #define LL_LLMATERIAL_H +#include + #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" @@ -94,4 +96,6 @@ protected: U8 mAlphaMaskCutoff; }; +typedef boost::shared_ptr LLMaterialPtr; + #endif // LL_LLMATERIAL_H diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 73a61f9c54..bbbbf0ced3 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -77,6 +77,11 @@ LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID) return (*this); } +bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const +{ + return (compareToOtherMaterialID(pOtherMaterialID) < 0); +} + bool LLMaterialID::isNull() const { return (compareToOtherMaterialID(LLMaterialID::null) == 0); diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index a474703f79..ffefc9f11c 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -42,6 +42,7 @@ public: bool operator == (const LLMaterialID& pOtherMaterialID) const; bool operator != (const LLMaterialID& pOtherMaterialID) const; LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID); + bool operator < (const LLMaterialID& pOtherMaterialID) const; bool isNull() const; diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index f69dd6214c..1ee6bab36b 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -43,6 +43,7 @@ #include "llcolorswatch.h" #include "llenvmanager.h" #include "llfloater.h" +#include "llfloaterreg.h" #include "llfontgl.h" #include "llhttpclient.h" #include "lllineeditor.h" @@ -380,17 +381,12 @@ LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams) mSelectionUpdateConnection(), mUnparsedGetData(), mNextUnparsedGetDataIndex(-1), - mNextUnparsedQueryDataIndex(-1), - mMultiMaterialsResponder() + mNextUnparsedQueryDataIndex(-1) { } LLFloaterDebugMaterials::~LLFloaterDebugMaterials() { - if (!mMultiMaterialsResponder) - { - mMultiMaterialsResponder.reset(); - } } void LLFloaterDebugMaterials::onGetClicked() @@ -439,7 +435,25 @@ void LLFloaterDebugMaterials::onQueryVisibleObjectsClicked() void LLFloaterDebugMaterials::onPostClicked() { - requestPostMaterials(); + clearPostResults(); + + std::vector selectedItems = mViewableObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + for (std::vector::const_iterator selectedItemIter = selectedItems.begin(); + selectedItemIter != selectedItems.end(); ++selectedItemIter) + { + const LLScrollListItem* selectedItem = *selectedItemIter; + const LLSD& selectedItemValue = selectedItem->getValue(); + + llassert(selectedItemValue.has(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD)); + llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); + const LLMaterialID material_id(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).asBinary()); + + LLMaterialMgr::instance().get(material_id, boost::bind(&LLFloaterDebugMaterials::onGetMaterial, _1, _2)); + } + LLMaterialMgr::instance().processGetQueue(); + } } void LLFloaterDebugMaterials::onRegionCross() @@ -579,20 +593,6 @@ void LLFloaterDebugMaterials::onGetResponse(bool pRequestStatus, const LLSD& pCo } } -void LLFloaterDebugMaterials::onPostResponse(bool pRequestStatus, const LLSD& pContent) -{ - if (pRequestStatus) - { - setState(kRequestCompleted); - parsePostResponse(pContent); - } - else - { - setState(kError); - } - mMultiMaterialsResponder.reset(); -} - void LLFloaterDebugMaterials::checkRegionMaterialStatus() { LLViewerRegion *region = gAgent.getRegion(); @@ -747,128 +747,6 @@ void LLFloaterDebugMaterials::requestPutMaterials(const LLUUID& regionId, bool p } } -void LLFloaterDebugMaterials::requestPostMaterials() -{ - llassert(!mMultiMaterialsResponder); - - std::vector selectedItems = mViewableObjectsScrollList->getAllSelected(); - std::map uniqueRegions; - - if (!selectedItems.empty()) - { - for (std::vector::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem* selectedItem = *selectedItemIter; - const LLSD& selectedItemValue = selectedItem->getValue(); - llassert(selectedItemValue.isMap()); - - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); - const LLUUID& regionId = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); - if (uniqueRegions.find(regionId) == uniqueRegions.end()) - { - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_OBJECT_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_OBJECT_ID_FIELD).isUUID()); - const LLUUID& objectId = selectedItemValue.get(VIEWABLE_OBJECTS_OBJECT_ID_FIELD).asUUID(); - LLViewerObject* viewerObject = gObjectList.findObject(objectId); - if (viewerObject != NULL) - { - LLViewerRegion* region = viewerObject->getRegion(); - if (region != NULL) - { - if (!region->capabilitiesReceived()) - { - LL_WARNS("debugMaterials") << "region '" << region->getName() << "' (id:" - << region->getRegionID().asString() << ") has not received capabilities" - << LL_ENDL; - } - else - { - std::string capURL = region->getCapability(MATERIALS_CAPABILITY_NAME); - - if (capURL.empty()) - { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on the current region '" << region->getName() << "'" << LL_ENDL; - } - else - { - uniqueRegions.insert(std::make_pair(regionId, capURL)); - } - } - } - } - } - } - - unsigned int numRegions = static_cast(uniqueRegions.size()); - - if (numRegions > 0U) - { - setState(kRequestStarted); - mMultiMaterialsResponder = MultiMaterialsResponderPtr(new MultiMaterialsResponder(boost::bind(&LLFloaterDebugMaterials::onPostResponse, this, _1, _2), numRegions)); - - for (std::map::const_iterator regionIdIter = uniqueRegions.begin(); - regionIdIter != uniqueRegions.end(); ++regionIdIter) - { - const LLUUID& regionId = regionIdIter->first; - std::string capURL = regionIdIter->second; - - LLSD materialIdsData = LLSD::emptyArray(); - - for (std::vector::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem* selectedItem = *selectedItemIter; - const LLSD& selectedItemValue = selectedItem->getValue(); - - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); - const LLUUID& selectedItemRegionId = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); - if (selectedItemRegionId == regionId) - { - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); - const LLSD& materidIdLLSD = selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD); - - materialIdsData.append(materidIdLLSD); - } - } - - if (materialIdsData.size() <= 0) - { - LL_ERRS("debugMaterials") << "no material IDs to POST to region id " << regionId.asString() - << LL_ENDL; - } - else - { - std::string materialsString = zip_llsd(materialIdsData); - S32 materialsSize = materialsString.size(); - - if (materialsSize <= 0) - { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - } - else - { - LLSD::Binary materialsBinary; - materialsBinary.resize(materialsSize); - memcpy(materialsBinary.data(), materialsString.data(), materialsSize); - - LLSD postData = LLSD::emptyMap(); - postData[MATERIALS_CAP_ZIP_FIELD] = materialsBinary; - - LLHTTPClient::ResponderPtr materialsResponder = new MaterialsResponder("POST", - capURL, boost::bind(&MultiMaterialsResponder::onMaterialsResponse, mMultiMaterialsResponder.get(), _1, _2)); - LLHTTPClient::post(capURL, postData, materialsResponder); - } - } - } - } - } -} - void LLFloaterDebugMaterials::parseQueryViewableObjects() { llassert(mNextUnparsedQueryDataIndex >= 0); @@ -1100,158 +978,111 @@ void LLFloaterDebugMaterials::parseGetResponse() } } -void LLFloaterDebugMaterials::parsePostResponse(const LLSD& pMultiContent) +void LLFloaterDebugMaterials::onGetMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp) { - clearPostResults(); - - llassert(pMultiContent.isArray()); - for (LLSD::array_const_iterator contentIter = pMultiContent.beginArray(); - contentIter != pMultiContent.endArray(); ++contentIter) + LLFloaterDebugMaterials* instancep = LLFloaterReg::findTypedInstance("floater_debug_materials"); + if ( (!instancep) || (!materialp.get()) ) { - const LLSD& content = *contentIter; - - llassert(content.isMap()); - llassert(content.has(MULTI_MATERIALS_STATUS_FIELD)); - llassert(content.get(MULTI_MATERIALS_STATUS_FIELD).isBoolean()); - if (content.get(MULTI_MATERIALS_STATUS_FIELD).asBoolean()) - { - llassert(content.has(MULTI_MATERIALS_DATA_FIELD)); - llassert(content.get(MULTI_MATERIALS_DATA_FIELD).isMap()); - const LLSD& postData = content.get(MULTI_MATERIALS_DATA_FIELD); - - llassert(postData.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(postData.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary postDataBinary = postData.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 postDataSize = static_cast(postDataBinary.size()); - std::string postDataString(reinterpret_cast(postDataBinary.data()), postDataSize); - - std::istringstream postDataStream(postDataString); - - LLSD unzippedPostData; - if (!unzip_llsd(unzippedPostData, postDataStream, postDataSize)) - { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; - } - - LLScrollListCell::Params cellParams; - LLScrollListItem::Params normalMapRowParams; - LLScrollListItem::Params specularMapRowParams; - LLScrollListItem::Params otherDataRowParams; - - llassert(unzippedPostData.isArray()); - for (LLSD::array_const_iterator materialIter = unzippedPostData.beginArray(); - materialIter != unzippedPostData.endArray(); ++materialIter) - { - const LLSD &material_entry = *materialIter; - llassert(material_entry.isMap()); - llassert(material_entry.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - const LLSD &materialID = material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD); - std::string materialIDString = convertToPrintableMaterialID(materialID); - - llassert(material_entry.has(MATERIALS_CAP_MATERIAL_FIELD)); - const LLSD &materialData = material_entry.get(MATERIALS_CAP_MATERIAL_FIELD); - llassert(materialData.isMap()); - - LLMaterial material(materialData); - - F32 x, y; - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "id"; - cellParams.value = materialIDString; - normalMapRowParams.columns.add(cellParams); - specularMapRowParams.columns.add(cellParams); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_map"; - cellParams.value = material.getNormalID().asString(); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - material.getNormalOffset(x, y); - cellParams.column = "normal_map_list_offset_x"; - cellParams.value = llformat("%f", x); - normalMapRowParams.columns.add(cellParams); - cellParams.column = "normal_map_list_offset_y"; - cellParams.value = llformat("%f", y); - normalMapRowParams.columns.add(cellParams); - - material.getNormalRepeat(x, y); - cellParams.column = "normal_map_list_repeat_x"; - cellParams.value = llformat("%f", x); - normalMapRowParams.columns.add(cellParams); - cellParams.column = "normal_map_list_repeat_y"; - cellParams.value = llformat("%f", y); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_rotation"; - cellParams.value = llformat("%f", material.getNormalRotation()); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "specular_map_list_map"; - cellParams.value = material.getSpecularID().asString(); - specularMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - material.getSpecularOffset(x, y); - cellParams.column = "specular_map_list_offset_x"; - cellParams.value = llformat("%f", x); - specularMapRowParams.columns.add(cellParams); - cellParams.column = "specular_map_list_offset_y"; - cellParams.value = llformat("%f", y); - specularMapRowParams.columns.add(cellParams); - - material.getSpecularRepeat(x, y); - cellParams.column = "specular_map_list_repeat_x"; - cellParams.value = llformat("%f", x); - specularMapRowParams.columns.add(cellParams); - cellParams.column = "specular_map_list_repeat_y"; - cellParams.value = llformat("%f", y); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_rotation"; - cellParams.value = llformat("%d", material.getSpecularRotation()); - specularMapRowParams.columns.add(cellParams); - - const LLColor4U& specularColor = material.getSpecularLightColor(); - cellParams.column = "specular_color"; - cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], - specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "specular_exponent"; - cellParams.value = llformat("%d", material.getSpecularLightExponent()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "env_intensity"; - cellParams.value = llformat("%d", material.getEnvironmentIntensity()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "alpha_mask_cutoff"; - cellParams.value = llformat("%d", material.getAlphaMaskCutoff()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "diffuse_alpha_mode"; - cellParams.value = llformat("%d", material.getDiffuseAlphaMode()); - otherDataRowParams.columns.add(cellParams); - - normalMapRowParams.value = materialIDString; - specularMapRowParams.value = materialIDString; - otherDataRowParams.value = materialIDString; - - mPostNormalMapScrollList->addRow(normalMapRowParams); - mPostSpecularMapScrollList->addRow(specularMapRowParams); - mPostOtherDataScrollList->addRow(otherDataRowParams); - } - } + return; } + + LLScrollListCell::Params cellParams; + LLScrollListItem::Params normalMapRowParams; + LLScrollListItem::Params specularMapRowParams; + LLScrollListItem::Params otherDataRowParams; + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "id"; + cellParams.value = material_id.asString(); + normalMapRowParams.columns.add(cellParams); + specularMapRowParams.columns.add(cellParams); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_map"; + cellParams.value = materialp->getNormalID().asString(); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + F32 x, y; + materialp->getNormalOffset(x, y); + cellParams.column = "normal_map_list_offset_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_offset_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + materialp->getNormalRepeat(x, y); + cellParams.column = "normal_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_rotation"; + cellParams.value = llformat("%f", materialp->getNormalRotation()); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "specular_map_list_map"; + cellParams.value = materialp->getSpecularID().asString(); + specularMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + materialp->getSpecularOffset(x, y); + cellParams.column = "specular_map_list_offset_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_offset_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + materialp->getSpecularRepeat(x, y); + cellParams.column = "specular_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_rotation"; + cellParams.value = llformat("%d", materialp->getSpecularRotation()); + specularMapRowParams.columns.add(cellParams); + + const LLColor4U& specularColor =materialp->getSpecularLightColor(); + cellParams.column = "specular_color"; + cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], + specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "specular_exponent"; + cellParams.value = llformat("%d", materialp->getSpecularLightExponent()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "env_intensity"; + cellParams.value = llformat("%d", materialp->getEnvironmentIntensity()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "alpha_mask_cutoff"; + cellParams.value = llformat("%d", materialp->getAlphaMaskCutoff()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "diffuse_alpha_mode"; + cellParams.value = llformat("%d", materialp->getDiffuseAlphaMode()); + otherDataRowParams.columns.add(cellParams); + + normalMapRowParams.value = cellParams.value; + specularMapRowParams.value = cellParams.value; + otherDataRowParams.value = cellParams.value; + + instancep->mPostNormalMapScrollList->addRow(normalMapRowParams); + instancep->mPostSpecularMapScrollList->addRow(specularMapRowParams); + instancep->mPostOtherDataScrollList->addRow(otherDataRowParams); } void LLFloaterDebugMaterials::setState(EState pState) diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h index 920bc4ae6d..a40e1d1b5c 100644 --- a/indra/newview/llfloaterdebugmaterials.h +++ b/indra/newview/llfloaterdebugmaterials.h @@ -33,6 +33,7 @@ #include #include "llfloater.h" +#include "llmaterial.h" #include "lluuid.h" #include "v4color.h" @@ -40,7 +41,6 @@ class LLButton; class LLColorSwatchCtrl; class LLColor4U; class LLLineEditor; -class LLMaterial; class LLMaterialID; class LLScrollListCtrl; class LLSD; @@ -96,7 +96,6 @@ private: void onDeferredRequestGetMaterials(LLUUID regionId); void onDeferredRequestPutMaterials(LLUUID regionId, bool pIsDoSet); void onGetResponse(bool pRequestStatus, const LLSD& pContent); - void onPostResponse(bool pRequestStatus, const LLSD& pContent); void checkRegionMaterialStatus(); void checkRegionMaterialStatus(const LLUUID& regionId); @@ -107,11 +106,10 @@ private: void requestPutMaterials(bool pIsDoSet); void requestPutMaterials(const LLUUID& regionId, bool pIsDoSet); - void requestPostMaterials(); + static void onGetMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp); void parseGetResponse(); void parseQueryViewableObjects(); - void parsePostResponse(const LLSD& pMultiContent); void setState(EState pState); inline EState getState() const; @@ -185,7 +183,6 @@ private: S32 mNextUnparsedGetDataIndex; S32 mNextUnparsedQueryDataIndex; - MultiMaterialsResponderPtr mMultiMaterialsResponder; }; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 5ba7ad5a05..9ee96dccb9 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -28,6 +28,7 @@ #include "llsdserialize.h" +#include "llagent.h" #include "llmaterialmgr.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -47,6 +48,8 @@ #define MATERIALS_CAP_OBJECT_ID_FIELD "ID" #define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" +#define MATERIALS_POST_TIMEOUT (60.f * 5) + /** * LLMaterialsResponder helper class */ @@ -108,6 +111,57 @@ LLMaterialMgr::~LLMaterialMgr() { } +bool LLMaterialMgr::isGetPending(const LLMaterialID& material_id) +{ + get_pending_map_t::const_iterator itPending = mGetPending.find(material_id); + return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT); +} + +const LLMaterialPtr LLMaterialMgr::get(const LLMaterialID& material_id) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + return itMaterial->second; + } + + if (!isGetPending(material_id)) + { + mGetQueue.insert(material_id); + } + return LLMaterialPtr(); +} + +boost::signals2::connection LLMaterialMgr::get(const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + get_callback_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second); + return boost::signals2::connection(); + } + + if (!isGetPending(material_id)) + { + mGetQueue.insert(material_id); + } + + get_callback_t* signalp = NULL; + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback == mGetCallbacks.end()) + { + signalp = new get_callback_t(); + mGetCallbacks.insert(std::pair(material_id, signalp)); + } + else + { + signalp = itCallback->second; + } + return signalp->connect(cb);; +} + void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) { put_queue_t::iterator itQueue = mPutQueue.find(object_id); @@ -128,6 +182,59 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& } } +void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + + LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + else + { + llassert(response_data.isArray()); + + for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + { + const LLSD& material_data = *itMaterial; + llassert(material_data.isMap()); + + llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); + LLMaterialID material_id(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asBinary()); + + llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data.get(MATERIALS_CAP_MATERIAL_FIELD).isMap()); + LLMaterialPtr material(new LLMaterial(material_data.get(MATERIALS_CAP_MATERIAL_FIELD))); + + mMaterials[material_id] = material; + + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback != mGetCallbacks.end()) + { + (*itCallback->second)(material_id, material); + + delete itCallback->second; + mGetCallbacks.erase(itCallback); + } + } + } +} + void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUID& object_id) { if (!success) @@ -191,6 +298,56 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI } } +void LLMaterialMgr::processGetQueue() +{ + LLViewerRegion* regionp = gAgent.getRegion(); + if (!regionp) + { + LL_WARNS("debugMaterials") << "Agent region is NULL" << LL_ENDL; + return; + } + else if (!regionp->capabilitiesReceived()) + { + return; + } + + const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + return; + } + + LLSD materialsData = LLSD::emptyArray(); + + for (get_queue_t::const_iterator itQueue = mGetQueue.begin(); itQueue != mGetQueue.end(); ++itQueue) + { + const LLMaterialID& material_id = *itQueue; + materialsData.append(material_id.asLLSD()); + } + mGetQueue.clear(); + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + return; + } + + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); + + LLSD postData = LLSD::emptyMap(); + postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2)); + LLHTTPClient::post(capURL, postData, materialsResponder); +} + void LLMaterialMgr::processPutQueue() { put_queue_t::iterator itQueue = mPutQueue.begin(); diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index c4e1c01389..d801d40c36 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -28,6 +28,7 @@ #define LL_LLMATERIALMGR_H #include "llmaterial.h" +#include "llmaterialid.h" #include "llsingleton.h" class LLMaterialMgr : public LLSingleton @@ -38,16 +39,33 @@ protected: virtual ~LLMaterialMgr(); public: + typedef boost::signals2::signal get_callback_t; + const LLMaterialPtr get(const LLMaterialID& material_id); + boost::signals2::connection get(const LLMaterialID& material_id, get_callback_t::slot_type cb); void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); + void processGetQueue(); void processPutQueue(); protected: + bool isGetPending(const LLMaterialID& material_id); + + void onGetResponse(bool success, const LLSD& content); void onPutResponse(bool success, const LLSD& content, const LLUUID& object_id); protected: + typedef std::set get_queue_t; + get_queue_t mGetQueue; + typedef std::map get_pending_map_t; + get_pending_map_t mGetPending; + typedef std::map get_callback_map_t; + get_callback_map_t mGetCallbacks; + typedef std::map facematerial_map_t; typedef std::map put_queue_t; put_queue_t mPutQueue; + + typedef std::map material_map_t; + material_map_t mMaterials; }; #endif // LL_LLMATERIALMGR_H -- cgit v1.3 From 1e194eb412bb10c1733ed76e270e45578ac15e0b Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 3 Dec 2012 15:46:49 +0100 Subject: Handle delayed requesting and sending of materials through an idle callback --- indra/newview/llfloaterdebugmaterials.cpp | 3 --- indra/newview/llmaterialmgr.cpp | 22 ++++++++++++++++++++++ indra/newview/llmaterialmgr.h | 5 +++-- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index 1ee6bab36b..5ad5ecbdfd 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -452,7 +452,6 @@ void LLFloaterDebugMaterials::onPostClicked() LLMaterialMgr::instance().get(material_id, boost::bind(&LLFloaterDebugMaterials::onGetMaterial, _1, _2)); } - LLMaterialMgr::instance().processGetQueue(); } } @@ -731,8 +730,6 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet) } } } - - LLMaterialMgr::instance().processPutQueue(); } } } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 9ee96dccb9..a8731a8c4c 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -29,6 +29,7 @@ #include "llsdserialize.h" #include "llagent.h" +#include "llcallbacklist.h" #include "llmaterialmgr.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -105,10 +106,12 @@ void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) LLMaterialMgr::LLMaterialMgr() { + gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); } LLMaterialMgr::~LLMaterialMgr() { + gIdleCallbacks.deleteFunction(&LLMaterialMgr::onIdle, NULL); } bool LLMaterialMgr::isGetPending(const LLMaterialID& material_id) @@ -298,6 +301,25 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI } } +static LLFastTimer::DeclareTimer FTM_MATERIALS_IDLE("Materials"); + +void LLMaterialMgr::onIdle(void*) +{ + LLFastTimer t(FTM_MATERIALS_IDLE); + + LLMaterialMgr* instancep = LLMaterialMgr::getInstance(); + + if (!instancep->mGetQueue.empty()) + { + instancep->processGetQueue(); + } + + if (!instancep->mPutQueue.empty()) + { + instancep->processPutQueue(); + } +} + void LLMaterialMgr::processGetQueue() { LLViewerRegion* regionp = gAgent.getRegion(); diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index d801d40c36..49d1029522 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -43,13 +43,14 @@ public: const LLMaterialPtr get(const LLMaterialID& material_id); boost::signals2::connection get(const LLMaterialID& material_id, get_callback_t::slot_type cb); void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); - void processGetQueue(); - void processPutQueue(); protected: bool isGetPending(const LLMaterialID& material_id); + static void onIdle(void*); + void processGetQueue(); void onGetResponse(bool success, const LLSD& content); + void processPutQueue(); void onPutResponse(bool success, const LLSD& content, const LLUUID& object_id); protected: -- cgit v1.3 From 4c68faec400e4c6d75a53528d8064a3448707158 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 5 Dec 2012 19:34:27 +0100 Subject: Added LLMaterialMgr::getAll() to retrieve all materials for the specified region --- indra/newview/llfloaterdebugmaterials.cpp | 342 +++++++++++------------------- indra/newview/llfloaterdebugmaterials.h | 11 +- indra/newview/llmaterialmgr.cpp | 145 ++++++++++++- indra/newview/llmaterialmgr.h | 17 +- indra/newview/llworld.cpp | 13 ++ indra/newview/llworld.h | 1 + 6 files changed, 293 insertions(+), 236 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index 5ad5ecbdfd..ca375b6985 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -47,9 +47,7 @@ #include "llfontgl.h" #include "llhttpclient.h" #include "lllineeditor.h" -#include "llmaterial.h" #include "llmaterialid.h" -#include "llmaterialmgr.h" #include "llresmgr.h" #include "llscrolllistcell.h" #include "llscrolllistctrl.h" @@ -322,10 +320,6 @@ void LLFloaterDebugMaterials::onClose(bool pIsAppQuitting) void LLFloaterDebugMaterials::draw() { - if (mUnparsedGetData.isDefined()) - { - parseGetResponse(); - } if (mNextUnparsedQueryDataIndex >= 0) { parseQueryViewableObjects(); @@ -379,8 +373,6 @@ LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams) mRegionCrossConnection(), mTeleportFailedConnection(), mSelectionUpdateConnection(), - mUnparsedGetData(), - mNextUnparsedGetDataIndex(-1), mNextUnparsedQueryDataIndex(-1) { } @@ -450,7 +442,7 @@ void LLFloaterDebugMaterials::onPostClicked() llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); const LLMaterialID material_id(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).asBinary()); - LLMaterialMgr::instance().get(material_id, boost::bind(&LLFloaterDebugMaterials::onGetMaterial, _1, _2)); + LLMaterialMgr::instance().get(material_id, boost::bind(&LLFloaterDebugMaterials::onPostMaterial, _1, _2)); } } } @@ -578,20 +570,6 @@ void LLFloaterDebugMaterials::onDeferredRequestPutMaterials(LLUUID regionId, boo requestPutMaterials(regionId, pIsDoSet); } -void LLFloaterDebugMaterials::onGetResponse(bool pRequestStatus, const LLSD& pContent) -{ - clearGetResults(); - if (pRequestStatus) - { - setState(kRequestCompleted); - setUnparsedGetData(pContent); - } - else - { - setState(kError); - } -} - void LLFloaterDebugMaterials::checkRegionMaterialStatus() { LLViewerRegion *region = gAgent.getRegion(); @@ -659,9 +637,8 @@ void LLFloaterDebugMaterials::requestGetMaterials() } else { - setState(kRequestStarted); - LLHTTPClient::ResponderPtr materialsResponder = new MaterialsResponder("GET", capURL, boost::bind(&LLFloaterDebugMaterials::onGetResponse, this, _1, _2)); - LLHTTPClient::get(capURL, materialsResponder); + setState(kReady); + LLMaterialMgr::instance().getAll(region->getRegionID(), boost::bind(&LLFloaterDebugMaterials::onGetMaterials, _1, _2)); } } } @@ -828,154 +805,129 @@ void LLFloaterDebugMaterials::parseQueryViewableObjects() } } -void LLFloaterDebugMaterials::parseGetResponse() +void LLFloaterDebugMaterials::onGetMaterials(const LLUUID& region_id, const LLMaterialMgr::material_map_t& materials) { - llassert(mUnparsedGetData.isDefined()); - llassert(mNextUnparsedGetDataIndex >= 0); - - if (mUnparsedGetData.isDefined()) + LLFloaterDebugMaterials* instancep = LLFloaterReg::findTypedInstance("floater_debug_materials"); + if (!instancep) { - LLScrollListCell::Params cellParams; - LLScrollListItem::Params normalMapRowParams; - LLScrollListItem::Params specularMapRowParams; - LLScrollListItem::Params otherDataRowParams; - - llassert(mUnparsedGetData.isArray()); - LLSD::array_const_iterator materialIter = mUnparsedGetData.beginArray(); - S32 materialIndex; + return; + } - for (materialIndex = 0; - (materialIndex < mNextUnparsedGetDataIndex) && (materialIter != mUnparsedGetData.endArray()); - ++materialIndex, ++materialIter) - { - } + LLViewerRegion* regionp = gAgent.getRegion(); + if ( (!regionp) || (regionp->getRegionID() != region_id) ) + { + return; + } - for (S32 currentParseCount = 0; - (currentParseCount < 10) && (materialIter != mUnparsedGetData.endArray()); - ++currentParseCount, ++materialIndex, ++materialIter) - { - const LLSD &material_entry = *materialIter; - llassert(material_entry.isMap()); - llassert(material_entry.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - const LLSD &materialID = material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD); - std::string materialIDString = convertToPrintableMaterialID(materialID); - - llassert(material_entry.has(MATERIALS_CAP_MATERIAL_FIELD)); - const LLSD &materialData = material_entry.get(MATERIALS_CAP_MATERIAL_FIELD); - llassert(materialData.isMap()); - - LLMaterial material(materialData); - - F32 x, y; - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "id"; - cellParams.value = materialIDString; - normalMapRowParams.columns.add(cellParams); - specularMapRowParams.columns.add(cellParams); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_map"; - cellParams.value = material.getNormalID().asString(); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - material.getNormalOffset(x, y); - cellParams.column = "normal_map_list_offset_x"; - cellParams.value = llformat("%f", x); - normalMapRowParams.columns.add(cellParams); - cellParams.column = "normal_map_list_offset_y"; - cellParams.value = llformat("%f", y); - normalMapRowParams.columns.add(cellParams); - - material.getNormalRepeat(x, y); - cellParams.column = "normal_map_list_repeat_x"; - cellParams.value = llformat("%f", x); - normalMapRowParams.columns.add(cellParams); - cellParams.column = "normal_map_list_repeat_y"; - cellParams.value = llformat("%f", y); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_rotation"; - cellParams.value = llformat("%f", material.getNormalRotation()); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "specular_map_list_map"; - cellParams.value = material.getSpecularID().asString(); - specularMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - material.getSpecularOffset(x, y); - cellParams.column = "specular_map_list_offset_x"; - cellParams.value = llformat("%f", x); - specularMapRowParams.columns.add(cellParams); - cellParams.column = "specular_map_list_offset_y"; - cellParams.value = llformat("%f", y); - specularMapRowParams.columns.add(cellParams); - - material.getSpecularRepeat(x, y); - cellParams.column = "specular_map_list_repeat_x"; - cellParams.value = llformat("%f", x); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_repeat_y"; - cellParams.value = llformat("%f", y); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_rotation"; - cellParams.value = llformat("%f", material.getSpecularRotation()); - specularMapRowParams.columns.add(cellParams); - - const LLColor4U& specularColor = material.getSpecularLightColor(); - cellParams.column = "specular_color"; - cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], - specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "specular_exponent"; - cellParams.value = llformat("%d", material.getSpecularLightExponent()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "env_intensity"; - cellParams.value = llformat("%d", material.getEnvironmentIntensity()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "alpha_mask_cutoff"; - cellParams.value = llformat("%d", material.getAlphaMaskCutoff()); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "diffuse_alpha_mode"; - cellParams.value = llformat("%d", material.getDiffuseAlphaMode()); - otherDataRowParams.columns.add(cellParams); - - normalMapRowParams.value = materialIDString; - specularMapRowParams.value = materialIDString; - otherDataRowParams.value = materialIDString; - - mGetNormalMapScrollList->addRow(normalMapRowParams); - mGetSpecularMapScrollList->addRow(specularMapRowParams); - mGetOtherDataScrollList->addRow(otherDataRowParams); - } + LLScrollListCell::Params cellParams; + LLScrollListItem::Params normalMapRowParams; + LLScrollListItem::Params specularMapRowParams; + LLScrollListItem::Params otherDataRowParams; - if (materialIter != mUnparsedGetData.endArray()) - { - mNextUnparsedGetDataIndex = materialIndex; - updateGetParsingStatus(); - } - else - { - clearUnparsedGetData(); - } + instancep->clearGetResults(); + for (LLMaterialMgr::material_map_t::const_iterator itMaterial = materials.begin(); itMaterial != materials.end(); ++itMaterial) + { + const LLMaterialID& material_id = itMaterial->first; + const LLMaterialPtr material = itMaterial->second; + + F32 x, y; + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "id"; + cellParams.value = material_id.asString(); + normalMapRowParams.columns.add(cellParams); + specularMapRowParams.columns.add(cellParams); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_map"; + cellParams.value = material->getNormalID().asString(); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + material->getNormalOffset(x, y); + cellParams.column = "normal_map_list_offset_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_offset_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + material->getNormalRepeat(x, y); + cellParams.column = "normal_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_rotation"; + cellParams.value = llformat("%f", material->getNormalRotation()); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "specular_map_list_map"; + cellParams.value = material->getSpecularID().asString(); + specularMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + material->getSpecularOffset(x, y); + cellParams.column = "specular_map_list_offset_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_offset_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + material->getSpecularRepeat(x, y); + cellParams.column = "specular_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_rotation"; + cellParams.value = llformat("%f", material->getSpecularRotation()); + specularMapRowParams.columns.add(cellParams); + + const LLColor4U& specularColor = material->getSpecularLightColor(); + cellParams.column = "specular_color"; + cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], + specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "specular_exponent"; + cellParams.value = llformat("%d", material->getSpecularLightExponent()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "env_intensity"; + cellParams.value = llformat("%d", material->getEnvironmentIntensity()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "alpha_mask_cutoff"; + cellParams.value = llformat("%d", material->getAlphaMaskCutoff()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "diffuse_alpha_mode"; + cellParams.value = llformat("%d", material->getDiffuseAlphaMode()); + otherDataRowParams.columns.add(cellParams); + + normalMapRowParams.value = cellParams.value; + specularMapRowParams.value = cellParams.value; + otherDataRowParams.value = cellParams.value; + + instancep->mGetNormalMapScrollList->addRow(normalMapRowParams); + instancep->mGetSpecularMapScrollList->addRow(specularMapRowParams); + instancep->mGetOtherDataScrollList->addRow(otherDataRowParams); } } -void LLFloaterDebugMaterials::onGetMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp) +void LLFloaterDebugMaterials::onPostMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp) { LLFloaterDebugMaterials* instancep = LLFloaterReg::findTypedInstance("floater_debug_materials"); if ( (!instancep) || (!materialp.get()) ) @@ -1167,7 +1119,6 @@ void LLFloaterDebugMaterials::clearGetResults() mGetNormalMapScrollList->deleteAllItems(); mGetSpecularMapScrollList->deleteAllItems(); mGetOtherDataScrollList->deleteAllItems(); - clearUnparsedGetData(); } void LLFloaterDebugMaterials::clearPostResults() @@ -1183,63 +1134,6 @@ void LLFloaterDebugMaterials::clearViewableObjectsResults() clearUnparsedQueryData(); } -void LLFloaterDebugMaterials::setUnparsedGetData(const LLSD& pGetData) -{ - llassert(pGetData.isMap()); - llassert(pGetData.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(pGetData.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary getDataBinary = pGetData.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 getDataSize = static_cast(getDataBinary.size()); - std::string getDataString(reinterpret_cast(getDataBinary.data()), getDataSize); - - std::istringstream getDataStream(getDataString); - - llassert(!mUnparsedGetData.isDefined()); - if (!unzip_llsd(mUnparsedGetData, getDataStream, getDataSize)) - { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; - } - mNextUnparsedGetDataIndex = 0; - - updateGetParsingStatus(); -} - -void LLFloaterDebugMaterials::clearUnparsedGetData() -{ - mUnparsedGetData.clear(); - mNextUnparsedGetDataIndex = -1; - - updateGetParsingStatus(); -} - -void LLFloaterDebugMaterials::updateGetParsingStatus() -{ - std::string parsingStatus; - - if (mUnparsedGetData.isDefined()) - { - LLLocale locale(LLStringUtil::getLocale()); - std::string numProcessedString; - LLResMgr::getInstance()->getIntegerString(numProcessedString, mNextUnparsedGetDataIndex); - - std::string numTotalString; - LLResMgr::getInstance()->getIntegerString(numTotalString, mUnparsedGetData.size()); - - LLStringUtil::format_map_t stringArgs; - stringArgs["[NUM_PROCESSED]"] = numProcessedString; - stringArgs["[NUM_TOTAL]"] = numTotalString; - - parsingStatus = getString("loading_status_in_progress", stringArgs); - } - else - { - parsingStatus = getString("loading_status_done"); - } - - mParsingStatusText->setText(static_cast(parsingStatus)); -} - void LLFloaterDebugMaterials::setUnparsedQueryData() { mNextUnparsedQueryDataIndex = 0; diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h index a40e1d1b5c..f7ee3a0d2b 100644 --- a/indra/newview/llfloaterdebugmaterials.h +++ b/indra/newview/llfloaterdebugmaterials.h @@ -34,6 +34,7 @@ #include "llfloater.h" #include "llmaterial.h" +#include "llmaterialmgr.h" #include "lluuid.h" #include "v4color.h" @@ -106,7 +107,8 @@ private: void requestPutMaterials(bool pIsDoSet); void requestPutMaterials(const LLUUID& regionId, bool pIsDoSet); - static void onGetMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp); + static void onGetMaterials(const LLUUID& region_id, const LLMaterialMgr::material_map_t& materials); + static void onPostMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp); void parseGetResponse(); void parseQueryViewableObjects(); @@ -120,10 +122,6 @@ private: void clearPostResults(); void clearViewableObjectsResults(); - void setUnparsedGetData(const LLSD& pGetData); - void clearUnparsedGetData(); - void updateGetParsingStatus(); - void setUnparsedQueryData(); void clearUnparsedQueryData(); void updateQueryParsingStatus(); @@ -179,9 +177,6 @@ private: boost::signals2::connection mTeleportFailedConnection; boost::signals2::connection mSelectionUpdateConnection; - LLSD mUnparsedGetData; - S32 mNextUnparsedGetDataIndex; - S32 mNextUnparsedQueryDataIndex; }; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index a8731a8c4c..d463f9480e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llsdserialize.h" +#include "llsdutil.h" #include "llagent.h" #include "llcallbacklist.h" @@ -34,6 +35,7 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" +#include "llworld.h" /** * Materials cap parameters @@ -49,6 +51,7 @@ #define MATERIALS_CAP_OBJECT_ID_FIELD "ID" #define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" +#define MATERIALS_GET_TIMEOUT (60.f * 20) #define MATERIALS_POST_TIMEOUT (60.f * 5) /** @@ -165,6 +168,41 @@ boost::signals2::connection LLMaterialMgr::get(const LLMaterialID& material_id, return signalp->connect(cb);; } +bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) +{ + getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); + return (mGetAllPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_GET_TIMEOUT); +} + +void LLMaterialMgr::getAll(const LLUUID& region_id) +{ + if (!isGetAllPending(region_id)) + { + mGetAllQueue.insert(region_id); + } +} + +boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMaterialMgr::getall_callback_t::slot_type cb) +{ + if (!isGetAllPending(region_id)) + { + mGetAllQueue.insert(region_id); + } + + getall_callback_t* signalp = NULL; + getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); + if (mGetAllCallbacks.end() == itCallback) + { + signalp = new getall_callback_t(); + mGetAllCallbacks.insert(std::pair(region_id, signalp)); + } + else + { + signalp = itCallback->second; + } + return signalp->connect(cb);; +} + void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) { put_queue_t::iterator itQueue = mPutQueue.find(object_id); @@ -185,6 +223,19 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& } } +const LLMaterialPtr LLMaterialMgr::setMaterial(const LLMaterialID& material_id, const LLSD& material_data) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (mMaterials.end() == itMaterial) + { + LLMaterialPtr material(new LLMaterial(material_data)); + mMaterials[material_id] = material; + return material; + } + return itMaterial->second; +} + + void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) { if (!success) @@ -222,9 +273,7 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); llassert(material_data.get(MATERIALS_CAP_MATERIAL_FIELD).isMap()); - LLMaterialPtr material(new LLMaterial(material_data.get(MATERIALS_CAP_MATERIAL_FIELD))); - - mMaterials[material_id] = material; + LLMaterialPtr material = setMaterial(material_id, material_data.get(MATERIALS_CAP_MATERIAL_FIELD)); get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); if (itCallback != mGetCallbacks.end()) @@ -238,6 +287,57 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) } } +void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + + LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + + llassert(response_data.isArray()); + material_map_t materials; + for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + { + const LLSD& material_data = *itMaterial; + llassert(material_data.isMap()); + + llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); + LLMaterialID material_id(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asBinary()); + + llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data.get(MATERIALS_CAP_MATERIAL_FIELD).isMap()); + LLMaterialPtr material = setMaterial(material_id, material_data.get(MATERIALS_CAP_MATERIAL_FIELD)); + + materials[material_id] = material; + } + + getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); + if (itCallback != mGetAllCallbacks.end()) + { + (*itCallback->second)(region_id, materials); + + delete itCallback->second; + mGetAllCallbacks.erase(itCallback); + } +} + void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUID& object_id) { if (!success) @@ -314,6 +414,11 @@ void LLMaterialMgr::onIdle(void*) instancep->processGetQueue(); } + if (!instancep->mGetAllQueue.empty()) + { + instancep->processGetAllQueue(); + } + if (!instancep->mPutQueue.empty()) { instancep->processPutQueue(); @@ -370,6 +475,40 @@ void LLMaterialMgr::processGetQueue() LLHTTPClient::post(capURL, postData, materialsResponder); } +void LLMaterialMgr::processGetAllQueue() +{ + getall_queue_t::iterator itRegion = mGetAllQueue.begin(); + while (mGetAllQueue.end() != itRegion) + { + getall_queue_t::iterator curRegion = itRegion++; + + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(*curRegion); + if (regionp == NULL) + { + LL_WARNS("debugMaterials") << "Unknown region with id " << (*curRegion).asString() << LL_ENDL; + mGetAllQueue.erase(curRegion); + continue; + } + else if (!regionp->capabilitiesReceived()) + { + continue; + } + + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; + mGetAllQueue.erase(curRegion); + continue; + } + + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *curRegion)); + LLHTTPClient::get(capURL, materialsResponder); + mGetAllQueue.erase(curRegion); + } +} + void LLMaterialMgr::processPutQueue() { put_queue_t::iterator itQueue = mPutQueue.begin(); diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 49d1029522..9e5efd7041 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -39,17 +39,26 @@ protected: virtual ~LLMaterialMgr(); public: + typedef std::map material_map_t; + typedef boost::signals2::signal get_callback_t; const LLMaterialPtr get(const LLMaterialID& material_id); boost::signals2::connection get(const LLMaterialID& material_id, get_callback_t::slot_type cb); + typedef boost::signals2::signal getall_callback_t; + void getAll(const LLUUID& region_id); + boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); protected: bool isGetPending(const LLMaterialID& material_id); + bool isGetAllPending(const LLUUID& region_id); + const LLMaterialPtr setMaterial(const LLMaterialID& material_id, const LLSD& material_data); static void onIdle(void*); void processGetQueue(); void onGetResponse(bool success, const LLSD& content); + void processGetAllQueue(); + void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); void processPutQueue(); void onPutResponse(bool success, const LLSD& content, const LLUUID& object_id); @@ -61,11 +70,17 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + typedef std::set getall_queue_t; + getall_queue_t mGetAllQueue; + typedef std::map getall_pending_map_t; + getall_pending_map_t mGetAllPending; + typedef std::map getall_callback_map_t; + getall_callback_map_t mGetAllCallbacks; + typedef std::map facematerial_map_t; typedef std::map put_queue_t; put_queue_t mPutQueue; - typedef std::map material_map_t; material_map_t mMaterials; }; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 78ee3e4fd9..ed6c8bd32b 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -403,6 +403,19 @@ LLViewerRegion* LLWorld::getRegionFromHandle(const U64 &handle) return NULL; } +LLViewerRegion* LLWorld::getRegionFromID(const LLUUID& region_id) +{ + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) + { + LLViewerRegion* regionp = *iter; + if (regionp->getRegionID() == region_id) + { + return regionp; + } + } + return NULL; +} void LLWorld::updateAgentOffset(const LLVector3d &offset_global) { diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index f350009d10..72f2ac46da 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -76,6 +76,7 @@ public: LLViewerRegion* getRegionFromPosGlobal(const LLVector3d &pos); LLViewerRegion* getRegionFromPosAgent(const LLVector3 &pos); LLViewerRegion* getRegionFromHandle(const U64 &handle); + LLViewerRegion* getRegionFromID(const LLUUID& region_id); BOOL positionRegionValidGlobal(const LLVector3d& pos); // true if position is in valid region LLVector3d clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos); -- cgit v1.3 From 3cd04749128f3daa185bca477552a566bc287a8e Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 12 Dec 2012 20:39:47 +0100 Subject: Refactor material retrieval to always invoke the region's GET material cap first --- indra/newview/llfloaterdebugmaterials.cpp | 7 +- indra/newview/llmaterialmgr.cpp | 290 +++++++++++++++++------------- indra/newview/llmaterialmgr.h | 25 +-- 3 files changed, 185 insertions(+), 137 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index e62b08d2b4..c9f15a9c35 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -386,12 +386,17 @@ void LLFloaterDebugMaterials::onPostClicked() { const LLScrollListItem* selectedItem = *selectedItemIter; const LLSD& selectedItemValue = selectedItem->getValue(); + llassert(selectedItemValue.isMap()); + + llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); + llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); + const LLUUID& region_id = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); llassert(selectedItemValue.has(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD)); llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); const LLMaterialID material_id(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).asBinary()); - LLMaterialMgr::instance().get(material_id, boost::bind(&LLFloaterDebugMaterials::onPostMaterial, _1, _2)); + LLMaterialMgr::instance().get(region_id, material_id, boost::bind(&LLFloaterDebugMaterials::onPostMaterial, _1, _2)); } } } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index d463f9480e..77c0102fa7 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -51,7 +51,9 @@ #define MATERIALS_CAP_OBJECT_ID_FIELD "ID" #define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" +#define MATERIALS_GET_MAX_ENTRIES 50 #define MATERIALS_GET_TIMEOUT (60.f * 20) +#define MATERIALS_POST_MAX_ENTRIES 50 #define MATERIALS_POST_TIMEOUT (60.f * 5) /** @@ -117,28 +119,34 @@ LLMaterialMgr::~LLMaterialMgr() gIdleCallbacks.deleteFunction(&LLMaterialMgr::onIdle, NULL); } -bool LLMaterialMgr::isGetPending(const LLMaterialID& material_id) +bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) { - get_pending_map_t::const_iterator itPending = mGetPending.find(material_id); + get_pending_map_t::const_iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT); } -const LLMaterialPtr LLMaterialMgr::get(const LLMaterialID& material_id) +const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id) { material_map_t::const_iterator itMaterial = mMaterials.find(material_id); - if (itMaterial != mMaterials.end()) + if (mMaterials.end() != itMaterial) { return itMaterial->second; } - if (!isGetPending(material_id)) + if (!isGetPending(region_id, material_id)) { - mGetQueue.insert(material_id); + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + std::pair ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + itQueue->second.insert(material_id); } return LLMaterialPtr(); } -boost::signals2::connection LLMaterialMgr::get(const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) +boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) { material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (itMaterial != mMaterials.end()) @@ -149,23 +157,24 @@ boost::signals2::connection LLMaterialMgr::get(const LLMaterialID& material_id, return boost::signals2::connection(); } - if (!isGetPending(material_id)) + if (!isGetPending(region_id, material_id)) { - mGetQueue.insert(material_id); + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + std::pair ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + itQueue->second.insert(material_id); } - get_callback_t* signalp = NULL; get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); if (itCallback == mGetCallbacks.end()) { - signalp = new get_callback_t(); - mGetCallbacks.insert(std::pair(material_id, signalp)); + std::pair ret = mGetCallbacks.insert(std::pair(material_id, new get_callback_t())); + itCallback = ret.first; } - else - { - signalp = itCallback->second; - } - return signalp->connect(cb);; + return itCallback->second->connect(cb);; } bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) @@ -189,18 +198,13 @@ boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMat mGetAllQueue.insert(region_id); } - getall_callback_t* signalp = NULL; getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); if (mGetAllCallbacks.end() == itCallback) { - signalp = new getall_callback_t(); - mGetAllCallbacks.insert(std::pair(region_id, signalp)); - } - else - { - signalp = itCallback->second; + std::pair ret = mGetAllCallbacks.insert(std::pair(region_id, new getall_callback_t())); + itCallback = ret.first; } - return signalp->connect(cb);; + return itCallback->second->connect(cb);; } void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) @@ -223,20 +227,30 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& } } -const LLMaterialPtr LLMaterialMgr::setMaterial(const LLMaterialID& material_id, const LLSD& material_data) +const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data) { material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (mMaterials.end() == itMaterial) { - LLMaterialPtr material(new LLMaterial(material_data)); - mMaterials[material_id] = material; - return material; + std::pair ret = mMaterials.insert(std::pair(material_id, new LLMaterial(material_data))); + itMaterial = ret.first; } + + mGetPending.erase(pending_material_t(region_id, material_id)); + + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback != mGetCallbacks.end()) + { + (*itCallback->second)(material_id, itMaterial->second); + + delete itCallback->second; + mGetCallbacks.erase(itCallback); + } + return itMaterial->second; } - -void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) +void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUID& region_id) { if (!success) { @@ -246,9 +260,9 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) llassert(content.isMap()); llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); - LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); std::istringstream content_stream(content_string); @@ -258,32 +272,21 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content) LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; return; } - else - { - llassert(response_data.isArray()); - - for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) - { - const LLSD& material_data = *itMaterial; - llassert(material_data.isMap()); - llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - LLMaterialID material_id(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asBinary()); - - llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); - llassert(material_data.get(MATERIALS_CAP_MATERIAL_FIELD).isMap()); - LLMaterialPtr material = setMaterial(material_id, material_data.get(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(response_data.isArray()); + for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + { + const LLSD& material_data = *itMaterial; + llassert(material_data.isMap()); - get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); - if (itCallback != mGetCallbacks.end()) - { - (*itCallback->second)(material_id, material); + llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].isBinary()); + LLMaterialID material_id(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].asBinary()); - delete itCallback->second; - mGetCallbacks.erase(itCallback); - } - } + llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data[MATERIALS_CAP_MATERIAL_FIELD].isMap()); + + setMaterial(region_id, material_id, material_data[MATERIALS_CAP_MATERIAL_FIELD]); } } @@ -297,9 +300,9 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL llassert(content.isMap()); llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); - LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); std::istringstream content_stream(content_string); @@ -310,20 +313,26 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL return; } - llassert(response_data.isArray()); + get_queue_t::iterator itQueue = mGetQueue.find(region_id); material_map_t materials; + + llassert(response_data.isArray()); for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) { const LLSD& material_data = *itMaterial; llassert(material_data.isMap()); llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - LLMaterialID material_id(material_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asBinary()); + llassert(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].isBinary()); + LLMaterialID material_id(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].asBinary()); + if (mGetQueue.end() != itQueue) + { + itQueue->second.erase(material_id); + } llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); - llassert(material_data.get(MATERIALS_CAP_MATERIAL_FIELD).isMap()); - LLMaterialPtr material = setMaterial(material_id, material_data.get(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data[MATERIALS_CAP_MATERIAL_FIELD].isMap()); + LLMaterialPtr material = setMaterial(region_id, material_id, material_data[MATERIALS_CAP_MATERIAL_FIELD]); materials[material_id] = material; } @@ -336,6 +345,13 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL delete itCallback->second; mGetAllCallbacks.erase(itCallback); } + + if ( (mGetQueue.end() != itQueue) && (itQueue->second.empty()) ) + { + mGetQueue.erase(itQueue); + } + mGetAllRequested.insert(region_id); + mGetAllPending.erase(region_id); // Invalidates region_id } void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUID& object_id) @@ -355,9 +371,9 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI llassert(content.isMap()); llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(content.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); - LLSD::Binary content_binary = content.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); std::string content_string(reinterpret_cast(content_binary.data()), content_binary.size()); std::istringstream content_stream(content_string); @@ -377,8 +393,8 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI llassert(face_data.isMap()); llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(face_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).isInteger()); - U32 local_id = face_data.get(MATERIALS_CAP_OBJECT_ID_FIELD).asInteger(); + llassert(face_data[MATERIALS_CAP_OBJECT_ID_FIELD].isInteger()); + U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); if (objectp->getLocalID() != local_id) { LL_ERRS("debugMaterials") << "Received PUT response for wrong object" << LL_ENDL; @@ -386,12 +402,12 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI } llassert(face_data.has(MATERIALS_CAP_FACE_FIELD)); - llassert(face_data.get(MATERIALS_CAP_FACE_FIELD).isInteger()); - S32 te = face_data.get(MATERIALS_CAP_FACE_FIELD).asInteger(); + llassert(face_data[MATERIALS_CAP_FACE_FIELD].isInteger()); + S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); llassert(face_data.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); - llassert(face_data.get(MATERIALS_CAP_MATERIAL_ID_FIELD).isBinary()); - LLMaterialID material_id(face_data.get(MATERIALS_CAP_MATERIAL_ID_FIELD).asBinary()); + llassert(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].isBinary()); + LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); LL_INFOS("debugMaterials") << "Setting material '" << material_id.asString() << "' on object '" << local_id << "' face " << te << LL_ENDL; @@ -427,66 +443,89 @@ void LLMaterialMgr::onIdle(void*) void LLMaterialMgr::processGetQueue() { - LLViewerRegion* regionp = gAgent.getRegion(); - if (!regionp) + get_queue_t::iterator loopRegionQueue = mGetQueue.begin(); + while (mGetQueue.end() != loopRegionQueue) { - LL_WARNS("debugMaterials") << "Agent region is NULL" << LL_ENDL; - return; - } - else if (!regionp->capabilitiesReceived()) - { - return; - } + get_queue_t::iterator itRegionQueue = loopRegionQueue++; - const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); - if (capURL.empty()) - { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; - return; - } + const LLUUID& region_id = itRegionQueue->first; + if (isGetAllPending(region_id)) + { + continue; + } - LLSD materialsData = LLSD::emptyArray(); + const LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + if (!regionp) + { + LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + else if (!regionp->capabilitiesReceived()) + { + continue; + } + else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) + { + getAll(region_id); + continue; + } - for (get_queue_t::const_iterator itQueue = mGetQueue.begin(); itQueue != mGetQueue.end(); ++itQueue) - { - const LLMaterialID& material_id = *itQueue; - materialsData.append(material_id.asLLSD()); - } - mGetQueue.clear(); + const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } - std::string materialString = zip_llsd(materialsData); + LLSD materialsData = LLSD::emptyArray(); - S32 materialSize = materialString.size(); - if (materialSize <= 0) - { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - return; - } + material_queue_t& materials = itRegionQueue->second; + material_queue_t::iterator loopMaterial = materials.begin(); + while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) + { + material_queue_t::iterator itMaterial = loopMaterial++; + materialsData.append((*itMaterial).asLLSD()); + materials.erase(itMaterial); + mGetPending.insert(std::pair(pending_material_t(region_id, *itMaterial), LLFrameTimer::getTotalSeconds())); + } + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + return; + } - LLSD::Binary materialBinary; - materialBinary.resize(materialSize); - memcpy(materialBinary.data(), materialString.data(), materialSize); + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); - LLSD postData = LLSD::emptyMap(); - postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + LLSD postData = LLSD::emptyMap(); + postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2)); - LLHTTPClient::post(capURL, postData, materialsResponder); + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); + LLHTTPClient::post(capURL, postData, materialsResponder); + } } void LLMaterialMgr::processGetAllQueue() { - getall_queue_t::iterator itRegion = mGetAllQueue.begin(); - while (mGetAllQueue.end() != itRegion) + getall_queue_t::iterator loopRegion = mGetAllQueue.begin(); + while (mGetAllQueue.end() != loopRegion) { - getall_queue_t::iterator curRegion = itRegion++; + getall_queue_t::iterator itRegion = loopRegion++; - LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(*curRegion); + const LLUUID& region_id = *itRegion; + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); if (regionp == NULL) { - LL_WARNS("debugMaterials") << "Unknown region with id " << (*curRegion).asString() << LL_ENDL; - mGetAllQueue.erase(curRegion); + LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetAllQueue.erase(itRegion); continue; } else if (!regionp->capabilitiesReceived()) @@ -499,30 +538,31 @@ void LLMaterialMgr::processGetAllQueue() { LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; - mGetAllQueue.erase(curRegion); + mGetAllQueue.erase(itRegion); continue; } - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *curRegion)); + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); LLHTTPClient::get(capURL, materialsResponder); - mGetAllQueue.erase(curRegion); + mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); + mGetAllQueue.erase(itRegion); // Invalidates region_id } } void LLMaterialMgr::processPutQueue() { - put_queue_t::iterator itQueue = mPutQueue.begin(); - while (itQueue != mPutQueue.end()) + put_queue_t::iterator loopQueue = mPutQueue.begin(); + while (mPutQueue.end() != loopQueue) { - put_queue_t::iterator curQueue = itQueue++; + put_queue_t::iterator itQueue = loopQueue++; - const LLUUID& object_id = curQueue->first; + const LLUUID& object_id = itQueue->first; const LLViewerObject* objectp = gObjectList.findObject(object_id); if ( (!objectp) || (!objectp->getRegion()) ) { LL_WARNS("debugMaterials") << "Object or object region is NULL" << LL_ENDL; - mPutQueue.erase(curQueue); + mPutQueue.erase(itQueue); continue; } @@ -538,12 +578,12 @@ void LLMaterialMgr::processPutQueue() LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; - mPutQueue.erase(curQueue); + mPutQueue.erase(itQueue); continue; } LLSD facesData = LLSD::emptyArray(); - for (facematerial_map_t::const_iterator itFace = curQueue->second.begin(); itFace != curQueue->second.end(); ++itFace) + for (facematerial_map_t::const_iterator itFace = itQueue->second.begin(); itFace != itQueue->second.end(); ++itFace) { LLSD faceData = LLSD::emptyMap(); faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); @@ -568,7 +608,7 @@ void LLMaterialMgr::processPutQueue() { LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - mPutQueue.erase(curQueue); + mPutQueue.erase(itQueue); continue; } else diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 9e5efd7041..b8722ce90e 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -42,38 +42,41 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - const LLMaterialPtr get(const LLMaterialID& material_id); - boost::signals2::connection get(const LLMaterialID& material_id, get_callback_t::slot_type cb); + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); + boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); protected: - bool isGetPending(const LLMaterialID& material_id); + bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id); bool isGetAllPending(const LLUUID& region_id); - const LLMaterialPtr setMaterial(const LLMaterialID& material_id, const LLSD& material_data); + const LLMaterialPtr setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data); static void onIdle(void*); void processGetQueue(); - void onGetResponse(bool success, const LLSD& content); + void onGetResponse(bool success, const LLSD& content, const LLUUID& region_id); void processGetAllQueue(); void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); void processPutQueue(); void onPutResponse(bool success, const LLSD& content, const LLUUID& object_id); protected: - typedef std::set get_queue_t; - get_queue_t mGetQueue; - typedef std::map get_pending_map_t; - get_pending_map_t mGetPending; + typedef std::set material_queue_t; + typedef std::map get_queue_t; + get_queue_t mGetQueue; + typedef std::pair pending_material_t; + typedef std::map get_pending_map_t; + get_pending_map_t mGetPending; typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; typedef std::set getall_queue_t; - getall_queue_t mGetAllQueue; + getall_queue_t mGetAllQueue; + getall_queue_t mGetAllRequested; typedef std::map getall_pending_map_t; - getall_pending_map_t mGetAllPending; + getall_pending_map_t mGetAllPending; typedef std::map getall_callback_map_t; getall_callback_map_t mGetAllCallbacks; -- cgit v1.3 From ef301c59832025240a20f9959008a33dc52233f9 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 12 Dec 2012 21:36:36 +0100 Subject: Don't call setTEMaterialID() while processing a PUT response; the region will send its own ObjectUpdate message --- indra/newview/llmaterialmgr.cpp | 31 ++++++------------------------- indra/newview/llmaterialmgr.h | 2 +- 2 files changed, 7 insertions(+), 26 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 77c0102fa7..f623ca11ec 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -354,7 +354,7 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL mGetAllPending.erase(region_id); // Invalidates region_id } -void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUID& object_id) +void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) { if (!success) { @@ -362,13 +362,6 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI return; } - LLViewerObject* objectp = gObjectList.findObject(object_id); - if (!objectp) - { - LL_WARNS("debugMaterials") << "Received PUT response for unknown object" << LL_ENDL; - return; - } - llassert(content.isMap()); llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); @@ -394,25 +387,17 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content, const LLUUI llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); llassert(face_data[MATERIALS_CAP_OBJECT_ID_FIELD].isInteger()); - U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); - if (objectp->getLocalID() != local_id) - { - LL_ERRS("debugMaterials") << "Received PUT response for wrong object" << LL_ENDL; - continue; - } +// U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); llassert(face_data.has(MATERIALS_CAP_FACE_FIELD)); llassert(face_data[MATERIALS_CAP_FACE_FIELD].isInteger()); - S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); +// S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); llassert(face_data.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); llassert(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].isBinary()); - LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); +// LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); - LL_INFOS("debugMaterials") << "Setting material '" << material_id.asString() << "' on object '" << local_id - << "' face " << te << LL_ENDL; - - objectp->setTEMaterialID(te, material_id); + // *TODO: do we really still need to process this? } } } @@ -593,9 +578,6 @@ void LLMaterialMgr::processPutQueue() faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); } facesData.append(faceData); - - LL_INFOS("debugMaterials") << "Requesting material change on object '" << faceData[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger() - << "' face " << faceData[MATERIALS_CAP_FACE_FIELD].asInteger() << LL_ENDL; } LLSD materialsData = LLSD::emptyMap(); @@ -620,8 +602,7 @@ void LLMaterialMgr::processPutQueue() LLSD putData = LLSD::emptyMap(); putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - // *HACK: the viewer can't lookup the local object id the cap returns so we'll pass the object's uuid along - LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2, object_id)); + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); } } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index b8722ce90e..1066f3ef37 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -60,7 +60,7 @@ protected: void processGetAllQueue(); void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); void processPutQueue(); - void onPutResponse(bool success, const LLSD& content, const LLUUID& object_id); + void onPutResponse(bool success, const LLSD& content); protected: typedef std::set material_queue_t; -- cgit v1.3 From a18ea9d92923e331c0a3e179e126659e694b1c07 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 12 Dec 2012 21:47:24 +0100 Subject: Clean up pending requests when regions are removed from LLWorld --- indra/newview/llmaterialmgr.cpp | 25 +++++++++++++++++++++++++ indra/newview/llmaterialmgr.h | 3 +++ indra/newview/llworld.cpp | 9 ++++++++- indra/newview/llworld.h | 5 +++++ 4 files changed, 41 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f623ca11ec..1daeedb8b0 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -112,6 +112,7 @@ void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) LLMaterialMgr::LLMaterialMgr() { gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); + LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); } LLMaterialMgr::~LLMaterialMgr() @@ -607,3 +608,27 @@ void LLMaterialMgr::processPutQueue() } } } + +void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) +{ + const LLUUID& region_id = regionp->getRegionID(); + + // Get + mGetQueue.erase(region_id); + for (get_pending_map_t::const_iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) + { + if (region_id == itPending->first.first) + mGetPending.erase(itPending++); + else + ++itPending; + } + + // Get all + mGetAllQueue.erase(region_id); + mGetAllRequested.erase(region_id); + mGetAllPending.erase(region_id); + mGetAllCallbacks.erase(region_id); + + // Put +// mPutQueue.erase(region_id); +} diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 1066f3ef37..5a0064ae27 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -31,6 +31,8 @@ #include "llmaterialid.h" #include "llsingleton.h" +class LLViewerRegion; + class LLMaterialMgr : public LLSingleton { friend LLSingleton; @@ -61,6 +63,7 @@ protected: void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); void processPutQueue(); void onPutResponse(bool success, const LLSD& content); + void onRegionRemoved(LLViewerRegion* regionp); protected: typedef std::set material_queue_t; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index ed6c8bd32b..604f7f2b56 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -275,7 +275,9 @@ void LLWorld::removeRegion(const LLHost &host) mActiveRegionList.remove(regionp); mCulledRegionList.remove(regionp); mVisibleRegionList.remove(regionp); - + + mRegionRemovedSignal(regionp); + delete regionp; updateWaterObjects(); @@ -1259,6 +1261,11 @@ bool LLWorld::isRegionListed(const LLViewerRegion* region) const return it != mRegionList.end(); } +boost::signals2::connection LLWorld::setRegionRemovedCallback(const region_remove_signal_t::slot_type& cb) +{ + return mRegionRemovedSignal.connect(cb); +} + LLHTTPRegistration gHTTPRegistrationEstablishAgentCommunication( "/message/EstablishAgentCommunication"); diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index 72f2ac46da..d0b001ba44 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -150,6 +150,9 @@ public: typedef std::list region_list_t; const region_list_t& getRegionList() const { return mActiveRegionList; } + typedef boost::signals2::signal region_remove_signal_t; + boost::signals2::connection setRegionRemovedCallback(const region_remove_signal_t::slot_type& cb); + // Returns lists of avatar IDs and their world-space positions within a given distance of a point. // All arguments are optional. Given containers will be emptied and then filled. // Not supplying origin or radius input returns data on all avatars in the known regions. @@ -169,6 +172,8 @@ private: region_list_t mVisibleRegionList; region_list_t mCulledRegionList; + region_remove_signal_t mRegionRemovedSignal; + // Number of points on edge static const U32 mWidth; -- cgit v1.3 From d4910e15a68368d3cebbda1485da4fb68b45ed62 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 3 Jan 2013 14:14:43 -0500 Subject: changes needed to compile with Linden-standard toolchain --- indra/newview/llmaterialmgr.cpp | 9 +++++++-- indra/newview/llmaterialmgr.h | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 1daeedb8b0..3dd60f5dc3 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -233,7 +233,8 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (mMaterials.end() == itMaterial) { - std::pair ret = mMaterials.insert(std::pair(material_id, new LLMaterial(material_data))); + LLMaterialPtr newMaterial(new LLMaterial(material_data)); + std::pair ret = mMaterials.insert(std::pair(material_id, newMaterial)); itMaterial = ret.first; } @@ -615,12 +616,16 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) // Get mGetQueue.erase(region_id); - for (get_pending_map_t::const_iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) + for (get_pending_map_t::iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) { if (region_id == itPending->first.first) + { mGetPending.erase(itPending++); + } else + { ++itPending; + } } // Get all diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 5a0064ae27..0b7217445a 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -35,7 +35,7 @@ class LLViewerRegion; class LLMaterialMgr : public LLSingleton { - friend LLSingleton; + friend class LLSingleton; protected: LLMaterialMgr(); virtual ~LLMaterialMgr(); @@ -69,8 +69,8 @@ protected: typedef std::set material_queue_t; typedef std::map get_queue_t; get_queue_t mGetQueue; - typedef std::pair pending_material_t; - typedef std::map get_pending_map_t; + typedef std::pair pending_material_t; + typedef std::map get_pending_map_t; get_pending_map_t mGetPending; typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; -- cgit v1.3 From 8b78b9960a32fb7a8a8663478d3fd30de65095fd Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 4 Jan 2013 14:12:05 -0500 Subject: add conditional to suppress unused variable warning in Release builds --- indra/newview/llmaterialmgr.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 3dd60f5dc3..3138bfd4e1 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -384,20 +384,22 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter) { - const LLSD& face_data = *faceIter; +# ifndef LL_RELEASE_FOR_DOWNLOAD + const LLSD& face_data = *faceIter; // conditional to avoid unused variable warning +# endif llassert(face_data.isMap()); llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); llassert(face_data[MATERIALS_CAP_OBJECT_ID_FIELD].isInteger()); -// U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); + // U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); llassert(face_data.has(MATERIALS_CAP_FACE_FIELD)); llassert(face_data[MATERIALS_CAP_FACE_FIELD].isInteger()); -// S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); + // S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); llassert(face_data.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); llassert(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].isBinary()); -// LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); + // LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); // *TODO: do we really still need to process this? } -- cgit v1.3 From 510a68134110b06779f34d2dd896a337911d5fef Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 31 Jan 2013 16:00:57 -0500 Subject: make logging tag for Materials uniform --- indra/newview/llmaterialmgr.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 3138bfd4e1..3895411bb9 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -96,10 +96,10 @@ void LLMaterialsResponder::result(const LLSD& pContent) void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) { - LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; - LL_WARNS("debugMaterials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME + LL_WARNS("Materials") << "--------------------------------------------------------------------------" << LL_ENDL; + LL_WARNS("Materials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME << "' with url '" << mCapabilityURL << "' because " << pReason << LL_ENDL; - LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; + LL_WARNS("Materials") << "--------------------------------------------------------------------------" << LL_ENDL; LLSD emptyResult; mCallback(false, emptyResult); @@ -271,7 +271,7 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUI LLSD response_data; if (!unzip_llsd(response_data, content_stream, content_binary.size())) { - LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + LL_ERRS("Materials") << "Cannot unzip LLSD binary content" << LL_ENDL; return; } @@ -311,7 +311,7 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL LLSD response_data; if (!unzip_llsd(response_data, content_stream, content_binary.size())) { - LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + LL_ERRS("Materials") << "Cannot unzip LLSD binary content" << LL_ENDL; return; } @@ -375,7 +375,7 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) LLSD response_data; if (!unzip_llsd(response_data, content_stream, content_binary.size())) { - LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + LL_ERRS("Materials") << "Cannot unzip LLSD binary content" << LL_ENDL; return; } else @@ -446,7 +446,7 @@ void LLMaterialMgr::processGetQueue() const LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); if (!regionp) { - LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; mGetQueue.erase(itRegionQueue); continue; } @@ -463,7 +463,7 @@ void LLMaterialMgr::processGetQueue() const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); if (capURL.empty()) { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; mGetQueue.erase(itRegionQueue); continue; @@ -486,7 +486,7 @@ void LLMaterialMgr::processGetQueue() S32 materialSize = materialString.size(); if (materialSize <= 0) { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + LL_ERRS("Materials") << "cannot zip LLSD binary content" << LL_ENDL; return; } @@ -513,7 +513,7 @@ void LLMaterialMgr::processGetAllQueue() LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); if (regionp == NULL) { - LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; mGetAllQueue.erase(itRegion); continue; } @@ -525,7 +525,7 @@ void LLMaterialMgr::processGetAllQueue() std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); if (capURL.empty()) { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; mGetAllQueue.erase(itRegion); continue; @@ -549,7 +549,7 @@ void LLMaterialMgr::processPutQueue() const LLViewerObject* objectp = gObjectList.findObject(object_id); if ( (!objectp) || (!objectp->getRegion()) ) { - LL_WARNS("debugMaterials") << "Object or object region is NULL" << LL_ENDL; + LL_WARNS("Materials") << "Object or object region is NULL" << LL_ENDL; mPutQueue.erase(itQueue); continue; @@ -564,7 +564,7 @@ void LLMaterialMgr::processPutQueue() std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); if (capURL.empty()) { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; mPutQueue.erase(itQueue); @@ -592,7 +592,7 @@ void LLMaterialMgr::processPutQueue() S32 materialSize = materialString.size(); if (materialSize <= 0) { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + LL_ERRS("Materials") << "cannot zip LLSD binary content" << LL_ENDL; mPutQueue.erase(itQueue); continue; -- cgit v1.3 From 90bf22ef24fbb8ff3497dd271abc7f7555a4f758 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 1 Feb 2013 10:20:44 -0500 Subject: add debug logging, ostream support for material ids, and some minor cleanup --- indra/llprimitive/llmaterialid.cpp | 7 ++++++ indra/llprimitive/llmaterialid.h | 2 ++ indra/newview/llmaterialmgr.cpp | 47 ++++++++++++++++++++++++++------------ 3 files changed, 42 insertions(+), 14 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 590f5cd91f..820f62c43c 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -150,6 +150,13 @@ std::string LLMaterialID::asString() const return materialIDString; } +std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id) +{ + s << material_id.asString(); + return s; +} + + 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 9db4065302..0a95204085 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -60,6 +60,8 @@ public: LLSD asLLSD() const; std::string asString() const; + friend std::ostream& operator<<(std::ostream& s, const LLMaterialID &material_id); + static const LLMaterialID null; private: diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 3895411bb9..aa98748dbe 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -2,9 +2,9 @@ * @file llmaterialmgr.cpp * @brief Material manager * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2013, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -128,23 +128,31 @@ bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& ma const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id) { + LL_DEBUGS("Materials") << "region " << region_id << " material id " << material_id << LL_ENDL; + LLMaterialPtr material; material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (mMaterials.end() != itMaterial) { - return itMaterial->second; + material = itMaterial->second; + LL_DEBUGS("Materials") << " found material " << LL_ENDL; } - - if (!isGetPending(region_id, material_id)) + else { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) + if (!isGetPending(region_id, material_id)) { - std::pair ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; + LL_DEBUGS("Materials") << " material pending " << material_id << LL_ENDL; + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + std::pair ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + itQueue->second.insert(material_id); } - itQueue->second.insert(material_id); + LL_DEBUGS("Materials") << " returning empty material " << LL_ENDL; + material = LLMaterialPtr(); } - return LLMaterialPtr(); + return material; } boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) @@ -188,8 +196,13 @@ void LLMaterialMgr::getAll(const LLUUID& region_id) { if (!isGetAllPending(region_id)) { + LL_DEBUGS("Materials") << "queuing for region " << region_id << LL_ENDL; mGetAllQueue.insert(region_id); } + else + { + LL_DEBUGS("Materials") << "already pending for region " << region_id << LL_ENDL; + } } boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMaterialMgr::getall_callback_t::slot_type cb) @@ -210,6 +223,7 @@ boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMat void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) { + LL_DEBUGS("Materials") << "object " << object_id << LL_ENDL; put_queue_t::iterator itQueue = mPutQueue.find(object_id); if (mPutQueue.end() == itQueue) { @@ -230,9 +244,11 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data) { + LL_DEBUGS("Materials") << "region " << region_id << " material id " << material_id << LL_ENDL; material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (mMaterials.end() == itMaterial) { + LL_DEBUGS("Materials") << "new material" << LL_ENDL; LLMaterialPtr newMaterial(new LLMaterial(material_data)); std::pair ret = mMaterials.insert(std::pair(material_id, newMaterial)); itMaterial = ret.first; @@ -257,6 +273,7 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUI if (!success) { // *TODO: is there any kind of error handling we can do here? + LL_WARNS("Materials")<< "failed"< Date: Mon, 4 Feb 2013 00:57:45 +0100 Subject: Material PUT queue entries aren't removed after a request is sent --- indra/newview/llmaterialmgr.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 3138bfd4e1..c93f17859c 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -590,14 +590,7 @@ void LLMaterialMgr::processPutQueue() std::string materialString = zip_llsd(materialsData); S32 materialSize = materialString.size(); - if (materialSize <= 0) - { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - - mPutQueue.erase(itQueue); - continue; - } - else + if (materialSize > 0) { LLSD::Binary materialBinary; materialBinary.resize(materialSize); @@ -609,6 +602,11 @@ void LLMaterialMgr::processPutQueue() LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); } + else + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + } + mPutQueue.erase(itQueue); } } @@ -636,6 +634,5 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) mGetAllPending.erase(region_id); mGetAllCallbacks.erase(region_id); - // Put -// mPutQueue.erase(region_id); + // Put doesn't need clearing: objects that can't be found will clean up in processPutQueue() } -- cgit v1.3 From 5bbc33383ed63d4d0c8a4241c8274b32fa5b22cc Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Sun, 3 Feb 2013 23:01:22 -0600 Subject: Don't spam the sim with repeated queries for an empty list of materials. --- indra/newview/llmaterialmgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index c93f17859c..6068c2606c 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -473,6 +473,11 @@ void LLMaterialMgr::processGetQueue() material_queue_t& materials = itRegionQueue->second; material_queue_t::iterator loopMaterial = materials.begin(); + if (materials.end() == loopMaterial) + { + //LL_INFOS("Material") << "Get queue for region empty, trying next region." << LL_ENDL; + continue; + } while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) { material_queue_t::iterator itMaterial = loopMaterial++; -- cgit v1.3 From 7cc7ae873c5aeca9b5939176fb70677365e25395 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 4 Feb 2013 09:35:12 -0500 Subject: improve and clarify logging --- indra/newview/llmaterialmgr.cpp | 6 +++++- indra/newview/llviewerobject.cpp | 13 ++++++++++++- indra/newview/llvovolume.cpp | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index aa98748dbe..d74cc0c6ed 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -293,6 +293,7 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUI } llassert(response_data.isArray()); + LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) { const LLSD& material_data = *itMaterial; @@ -337,6 +338,7 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL material_map_t materials; llassert(response_data.isArray()); + LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) { const LLSD& material_data = *itMaterial; @@ -400,7 +402,7 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) else { llassert(response_data.isArray()); - + LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter) { # ifndef LL_RELEASE_FOR_DOWNLOAD @@ -550,6 +552,7 @@ void LLMaterialMgr::processGetAllQueue() continue; } + LL_DEBUGS("Materials") << "getAll for region " << region_id << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); LLHTTPClient::get(capURL, materialsResponder); mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); @@ -625,6 +628,7 @@ void LLMaterialMgr::processPutQueue() LLSD putData = LLSD::emptyMap(); putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + LL_DEBUGS("Materials") << "put for " << facesData.size() << " faces; object " << object_id << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index b8de345a9a..4c6d655058 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4351,10 +4351,17 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID const LLTextureEntry *tep = getTE(te); if (!tep) { - llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; + LL_WARNS("Material") << "No texture entry for te " << (S32)te + << ", object " << mID + << ", material " << pMaterialID + << LL_ENDL; } else if (pMaterialID != tep->getMaterialID()) { + LL_DEBUGS("Material") << "Changing texture entry for te " << (S32)te + << ", object " << mID + << ", material " << pMaterialID + << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); setChanged(TEXTURE); if (mDrawable.notNull() && retval) @@ -4376,6 +4383,10 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri else if (pMaterialParams != tep->getMaterialParams()) { retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); + LL_DEBUGS("Material") << "Changing material params for te " << (S32)te + << ", object " << mID + << " (" << retval << ")" + << LL_ENDL; setTENormalMap(te, tep->getMaterialParams()->getNormalID()); setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); setChanged(TEXTURE); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6c073a8e20..94799f8bbd 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2005,7 +2005,7 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { if (!pMaterialID.isNull()) { - LL_INFOS("Materials") << "Oh god it's a material! " << pMaterialID.asString() << LL_ENDL; + LL_INFOS("Materials") << " " << pMaterialID.asString() << LL_ENDL; S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); if (res) { -- cgit v1.3 From 64a4a13397ea7b895ebbeb707bdba72e2d97ff6b Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 15 Feb 2013 15:40:43 -0500 Subject: fix crasher in setNumTEs --- indra/newview/lldrawpoolmaterials.cpp | 2 +- indra/newview/llmaterialmgr.cpp | 27 ++++++++++++++++++--------- indra/newview/llpanelface.cpp | 7 +++++-- indra/newview/llviewerobject.cpp | 4 ++-- indra/newview/llvovolume.cpp | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index e775346563..c5f4740afc 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -68,7 +68,7 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) switch (params.mDiffuseAlphaMode) { case 0: - LL_INFOS("Asdf") << "Renderererererrerererrrr!!!~!!!~!~" << LL_ENDL; + LL_DEBUGS("Asdf") << "Renderererererrerererrrr!!!~!!!~!~" << LL_ENDL; mShader = &gDeferredMaterialShinyNormal; break; case 1: // Alpha blending not supported in the opaque draw pool. diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 474e6b862e..cb628447bf 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -96,10 +96,12 @@ void LLMaterialsResponder::result(const LLSD& pContent) void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) { - LL_WARNS("Materials") << "--------------------------------------------------------------------------" << LL_ENDL; - LL_WARNS("Materials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME - << "' with url '" << mCapabilityURL << "' because " << pReason << LL_ENDL; - LL_WARNS("Materials") << "--------------------------------------------------------------------------" << LL_ENDL; + LL_WARNS("Materials") + << "\n--------------------------------------------------------------------------\n" + << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME + << "'\n with url '" << mCapabilityURL << "' because " << pReason + << "\n--------------------------------------------------------------------------" + << LL_ENDL; LLSD emptyResult; mCallback(false, emptyResult); @@ -144,6 +146,7 @@ const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterial get_queue_t::iterator itQueue = mGetQueue.find(region_id); if (mGetQueue.end() == itQueue) { + LL_DEBUGS("Materials") << "mGetQueue add region " << region_id << " pending " << material_id << LL_ENDL; std::pair ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); itQueue = ret.first; } @@ -171,6 +174,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL get_queue_t::iterator itQueue = mGetQueue.find(region_id); if (mGetQueue.end() == itQueue) { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); itQueue = ret.first; } @@ -223,10 +227,10 @@ boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMat void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) { - LL_DEBUGS("Materials") << "object " << object_id << LL_ENDL; put_queue_t::iterator itQueue = mPutQueue.find(object_id); if (mPutQueue.end() == itQueue) { + LL_DEBUGS("Materials") << "mPutQueue insert object " << object_id << LL_ENDL; mPutQueue.insert(std::pair(object_id, facematerial_map_t())); itQueue = mPutQueue.find(object_id); } @@ -372,7 +376,9 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL { mGetQueue.erase(itQueue); } - mGetAllRequested.insert(region_id); + + LL_DEBUGS("Materials")<< "recording that getAll has been done for region id " << region_id << LL_ENDL; + mGetAllRequested.insert(region_id); // prevents subsequent getAll requests for this region mGetAllPending.erase(region_id); // Invalidates region_id } @@ -477,6 +483,7 @@ void LLMaterialMgr::processGetQueue() } else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) { + LL_DEBUGS("Materials") << "calling getAll for " << regionp->getName() << LL_ENDL; getAll(region_id); continue; } @@ -496,7 +503,7 @@ void LLMaterialMgr::processGetQueue() material_queue_t::iterator loopMaterial = materials.begin(); if (materials.end() == loopMaterial) { - //LL_INFOS("Material") << "Get queue for region empty, trying next region." << LL_ENDL; + LL_DEBUGS("Material") << "Get queue for region empty, trying next region." << LL_ENDL; continue; } while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) @@ -506,7 +513,7 @@ void LLMaterialMgr::processGetQueue() materials.erase(itMaterial); mGetPending.insert(std::pair(pending_material_t(region_id, *itMaterial), LLFrameTimer::getTotalSeconds())); } - + std::string materialString = zip_llsd(materialsData); S32 materialSize = materialString.size(); @@ -524,6 +531,7 @@ void LLMaterialMgr::processGetQueue() postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); + LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << "'\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; LLHTTPClient::post(capURL, postData, materialsResponder); } } @@ -557,7 +565,7 @@ void LLMaterialMgr::processGetAllQueue() continue; } - LL_DEBUGS("Materials") << "getAll for region " << region_id << LL_ENDL; + LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); LLHTTPClient::get(capURL, materialsResponder); mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); @@ -657,6 +665,7 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) } } + LL_DEBUGS("Materials") << regionp->getName() << " id " << region_id << LL_ENDL; // Get all mGetAllQueue.erase(region_id); mGetAllRequested.erase(region_id); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 7e9fe212dd..5c4c2693f8 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1290,6 +1290,7 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate void LLPanelFace::updateMaterial() { + LL_WARNS("Materials") << LL_ENDL; if (mUpdateInFlight) { LL_WARNS("Materials") << "Attempt to update material while a previous update is pending ignored." << LL_ENDL; @@ -1351,7 +1352,7 @@ void LLPanelFace::updateMaterial() mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); - llinfos << "Updating material: " << mMaterial->asLLSD() << llendl; + LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); // We've sent an update. Need to hold off on any more until @@ -1363,7 +1364,7 @@ void LLPanelFace::updateMaterial() // The user has specified settings that don't need a material. if (mMaterial || !mMaterialID.isNull()) { - llinfos << "Resetting material entry" << llendl; + LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial.reset(); mMaterialID = LLMaterialID::null; // Delete existing material entry... @@ -1657,6 +1658,7 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitMaterialTexture( const LLSD& data ) { + LL_DEBUGS("Materials") << data << "\n" << (mUpdateInFlight ? "In Flight" : "Now Pending" ) << LL_ENDL; if (!mUpdateInFlight) { updateMaterial(); @@ -1682,6 +1684,7 @@ void LLPanelFace::onCancelMaterialTexture(const LLSD& data) void LLPanelFace::onSelectMaterialTexture(const LLSD& data) { + LL_DEBUGS("Materials") << data << LL_ENDL; if (!mUpdateInFlight) { updateMaterial(); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 55d63601e6..f1b54e0e01 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3947,8 +3947,8 @@ void LLViewerObject::setNumTEs(const U8 num_tes) else if (getNumTEs()) { new_images[i] = mTEImages[getNumTEs()-1]; - new_normmaps[i] = mTENormalMaps[i]; - new_specmaps[i] = mTESpecularMaps[i]; + new_normmaps[i] = mTENormalMaps[getNumTEs()-1]; + new_specmaps[i] = mTESpecularMaps[getNumTEs()-1]; } else { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 45814a1aa3..f2ede46cfc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2016,10 +2016,10 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { if (!pMaterialID.isNull()) { - LL_INFOS("Materials") << " " << pMaterialID.asString() << LL_ENDL; S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); if (res) { + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); gPipeline.markTextured(mDrawable); mFaceMappingChanged = TRUE; -- cgit v1.3 From b4a87776d4207c4268b5c0d546790eeb45db1e75 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 18 Feb 2013 19:37:19 +0100 Subject: Prevent a failed GET from causing an infinite material request loop when there are still pending POST requests for the same region --- indra/newview/llmaterialmgr.cpp | 15 +++++++-------- indra/newview/llmaterialmgr.h | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index cb628447bf..de82ec80c8 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -548,7 +548,7 @@ void LLMaterialMgr::processGetAllQueue() if (regionp == NULL) { LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; - mGetAllQueue.erase(itRegion); + clearGetQueues(region_id); // Invalidates region_id continue; } else if (!regionp->capabilitiesReceived()) @@ -561,7 +561,7 @@ void LLMaterialMgr::processGetAllQueue() { LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; - mGetAllQueue.erase(itRegion); + clearGetQueues(region_id); // Invalidates region_id continue; } @@ -647,11 +647,8 @@ void LLMaterialMgr::processPutQueue() } } -void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) +void LLMaterialMgr::clearGetQueues(const LLUUID& region_id) { - const LLUUID& region_id = regionp->getRegionID(); - - // Get mGetQueue.erase(region_id); for (get_pending_map_t::iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) { @@ -665,12 +662,14 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) } } - LL_DEBUGS("Materials") << regionp->getName() << " id " << region_id << LL_ENDL; - // Get all mGetAllQueue.erase(region_id); mGetAllRequested.erase(region_id); mGetAllPending.erase(region_id); mGetAllCallbacks.erase(region_id); +} +void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) +{ + clearGetQueues(regionp->getRegionID()); // Put doesn't need clearing: objects that can't be found will clean up in processPutQueue() } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 0b7217445a..1672d11d38 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -52,6 +52,7 @@ public: void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); protected: + void clearGetQueues(const LLUUID& region_id); bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id); bool isGetAllPending(const LLUUID& region_id); const LLMaterialPtr setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data); -- cgit v1.3 From fbf8e51c6059791b12f60602b4dda0d72dc2d847 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 25 Feb 2013 00:16:14 +0100 Subject: Added LLMaterialMgr::remove() to remove material information from a face --- indra/llprimitive/llmaterial.cpp | 43 ++++++++++++++++++++++++++++------------ indra/llprimitive/llmaterial.h | 3 +++ indra/newview/llmaterialmgr.cpp | 5 +++++ indra/newview/llmaterialmgr.h | 1 + 4 files changed, 39 insertions(+), 13 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index 645fcf7b46..f6fd8e557a 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -55,11 +55,6 @@ * Materials constants */ -const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); -const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; -const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; -const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; -const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; const F32 MATERIALS_MULTIPLIER = 10000.f; /** @@ -94,11 +89,20 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) - , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) - , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) - , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) - , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) + : mNormalOffsetX(.0f) + , mNormalOffsetY(.0f) + , mNormalRepeatX(.0f) + , mNormalRepeatY(.0f) + , mNormalRotation(.0f) + , mSpecularOffsetX(.0f) + , mSpecularOffsetY(.0f) + , mSpecularRepeatX(.0f) + , mSpecularRepeatY(.0f) + , mSpecularRotation(.0f) + , mSpecularLightExponent(0) + , mEnvironmentIntensity(0) + , mDiffuseAlphaMode(0) + , mAlphaMaskCutoff(0) { } @@ -159,8 +163,21 @@ void LLMaterial::fromLLSD(const LLSD& material_data) bool LLMaterial::isNull() const { - // *TODO: find a better way of defining a 'null' material? + return (*this == null); +} + +bool LLMaterial::operator == (const LLMaterial& rhs) const +{ return - (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && - (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); + (mNormalID == rhs.mNormalID) && (mNormalOffsetX == rhs.mNormalOffsetX) && (mNormalOffsetY == rhs.mNormalOffsetY) && + (mNormalRepeatX == rhs.mNormalRepeatX) && (mNormalRepeatY == rhs.mNormalRepeatY) && (mNormalRotation == rhs.mNormalRotation) && + (mSpecularID == rhs.mSpecularID) && (mSpecularOffsetX == rhs.mSpecularOffsetX) && (mSpecularOffsetY == rhs.mSpecularOffsetY) && + (mSpecularRepeatX == rhs.mSpecularRepeatX) && (mSpecularRepeatY == rhs.mSpecularRepeatY) && (mSpecularRotation == rhs.mSpecularRotation) && + (mSpecularLightColor == rhs.mSpecularLightColor) && (mSpecularLightExponent == rhs.mSpecularLightExponent) && + (mEnvironmentIntensity == rhs.mEnvironmentIntensity) && (mDiffuseAlphaMode == rhs.mDiffuseAlphaMode) && (mAlphaMaskCutoff == rhs.mAlphaMaskCutoff); +} + +bool LLMaterial::operator != (const LLMaterial& rhs) const +{ + return !(*this == rhs); } diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index 6f94cfda17..5b56d11cd2 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -74,6 +74,9 @@ public: bool isNull() const; static const LLMaterial null; + bool operator == (const LLMaterial& rhs) const; + bool operator != (const LLMaterial& rhs) const; + protected: LLUUID mNormalID; F32 mNormalOffsetX; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index de82ec80c8..253b0c124e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -246,6 +246,11 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& } } +void LLMaterialMgr::remove(const LLUUID& object_id, const U8 te) +{ + put(object_id, te, LLMaterial::null); +} + const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data) { LL_DEBUGS("Materials") << "region " << region_id << " material id " << material_id << LL_ENDL; diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 1672d11d38..6f444309d3 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -50,6 +50,7 @@ public: void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); + void remove(const LLUUID& object_id, const U8 te); protected: void clearGetQueues(const LLUUID& region_id); -- cgit v1.3 From 5ba7be081273d4eb4dac3f66e82b33b44f62580a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 28 Feb 2013 23:19:41 +0100 Subject: Mark a material as 'pending' from the very first call to LLMaterialMgr::get() --- indra/newview/llmaterialmgr.cpp | 21 ++++++++++++++++++--- indra/newview/llmaterialmgr.h | 5 +++-- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 253b0c124e..d7f4a465a7 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -122,12 +122,25 @@ LLMaterialMgr::~LLMaterialMgr() gIdleCallbacks.deleteFunction(&LLMaterialMgr::onIdle, NULL); } -bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) +bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) const { get_pending_map_t::const_iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT); } +void LLMaterialMgr::markGetPending(const LLUUID& region_id, const LLMaterialID& material_id) +{ + get_pending_map_t::iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); + if (mGetPending.end() == itPending) + { + mGetPending.insert(std::pair(pending_material_t(region_id, material_id), LLFrameTimer::getTotalSeconds())); + } + else + { + itPending->second = LLFrameTimer::getTotalSeconds(); + } +} + const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id) { LL_DEBUGS("Materials") << "region " << region_id << " material id " << material_id << LL_ENDL; @@ -151,6 +164,7 @@ const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterial itQueue = ret.first; } itQueue->second.insert(material_id); + markGetPending(region_id, material_id); } LL_DEBUGS("Materials") << " returning empty material " << LL_ENDL; material = LLMaterialPtr(); @@ -179,6 +193,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL itQueue = ret.first; } itQueue->second.insert(material_id); + markGetPending(region_id, material_id); } get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); @@ -190,7 +205,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return itCallback->second->connect(cb);; } -bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) +bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); return (mGetAllPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_GET_TIMEOUT); @@ -516,7 +531,7 @@ void LLMaterialMgr::processGetQueue() material_queue_t::iterator itMaterial = loopMaterial++; materialsData.append((*itMaterial).asLLSD()); materials.erase(itMaterial); - mGetPending.insert(std::pair(pending_material_t(region_id, *itMaterial), LLFrameTimer::getTotalSeconds())); + markGetPending(region_id, *itMaterial); } std::string materialString = zip_llsd(materialsData); diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 6f444309d3..39be5cab29 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -54,8 +54,9 @@ public: protected: void clearGetQueues(const LLUUID& region_id); - bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id); - bool isGetAllPending(const LLUUID& region_id); + bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) const; + bool isGetAllPending(const LLUUID& region_id) const; + void markGetPending(const LLUUID& region_id, const LLMaterialID& material_id); const LLMaterialPtr setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data); static void onIdle(void*); -- cgit v1.3 From 7a3a74b3d4eb6159a2edb86c8e967369cada78b9 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 28 Feb 2013 23:42:12 +0100 Subject: Group multiple material PUT requests together and throttle requests to the region --- indra/newview/llmaterialmgr.cpp | 54 ++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index d7f4a465a7..ffd7f1f1af 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -55,6 +55,8 @@ #define MATERIALS_GET_TIMEOUT (60.f * 20) #define MATERIALS_POST_MAX_ENTRIES 50 #define MATERIALS_POST_TIMEOUT (60.f * 5) +#define MATERIALS_PUT_THROTTLE_SECS 1.f +#define MATERIALS_PUT_MAX_ENTRIES 50 /** * LLMaterialsResponder helper class @@ -471,9 +473,11 @@ void LLMaterialMgr::onIdle(void*) instancep->processGetAllQueue(); } - if (!instancep->mPutQueue.empty()) + static LLFrameTimer mPutTimer; + if ( (!instancep->mPutQueue.empty()) && (mPutTimer.hasExpired()) ) { instancep->processPutQueue(); + mPutTimer.resetWithExpiry(MATERIALS_PUT_THROTTLE_SECS); } } @@ -521,11 +525,6 @@ void LLMaterialMgr::processGetQueue() material_queue_t& materials = itRegionQueue->second; material_queue_t::iterator loopMaterial = materials.begin(); - if (materials.end() == loopMaterial) - { - LL_DEBUGS("Material") << "Get queue for region empty, trying next region." << LL_ENDL; - continue; - } while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) { material_queue_t::iterator itMaterial = loopMaterial++; @@ -533,6 +532,10 @@ void LLMaterialMgr::processGetQueue() materials.erase(itMaterial); markGetPending(region_id, *itMaterial); } + if (materials.empty()) + { + mGetQueue.erase(itRegionQueue); + } std::string materialString = zip_llsd(materialsData); @@ -595,6 +598,9 @@ void LLMaterialMgr::processGetAllQueue() void LLMaterialMgr::processPutQueue() { + typedef std::map regionput_request_map; + regionput_request_map requests; + put_queue_t::iterator loopQueue = mPutQueue.begin(); while (mPutQueue.end() != loopQueue) { @@ -616,18 +622,11 @@ void LLMaterialMgr::processPutQueue() continue; } - std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); - if (capURL.empty()) - { - LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + LLSD& facesData = requests[regionp]; - mPutQueue.erase(itQueue); - continue; - } - - LLSD facesData = LLSD::emptyArray(); - for (facematerial_map_t::const_iterator itFace = itQueue->second.begin(); itFace != itQueue->second.end(); ++itFace) + facematerial_map_t& face_map = itQueue->second; + facematerial_map_t::iterator itFace = face_map.begin(); + while ( (face_map.end() != itFace) && (facesData.size() < MATERIALS_GET_MAX_ENTRIES) ) { LLSD faceData = LLSD::emptyMap(); faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); @@ -637,10 +636,26 @@ void LLMaterialMgr::processPutQueue() faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); } facesData.append(faceData); + face_map.erase(itFace++); + } + if (face_map.empty()) + { + mPutQueue.erase(itQueue); + } + } + + for (regionput_request_map::const_iterator itRequest = requests.begin(); itRequest != requests.end(); ++itRequest) + { + std::string capURL = itRequest->first->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << itRequest->first->getName() << "'" << LL_ENDL; + continue; } LLSD materialsData = LLSD::emptyMap(); - materialsData[MATERIALS_CAP_FULL_PER_FACE_FIELD] = facesData; + materialsData[MATERIALS_CAP_FULL_PER_FACE_FIELD] = itRequest->second; std::string materialString = zip_llsd(materialsData); @@ -655,7 +670,7 @@ void LLMaterialMgr::processPutQueue() LLSD putData = LLSD::emptyMap(); putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - LL_DEBUGS("Materials") << "put for " << facesData.size() << " faces; object " << object_id << LL_ENDL; + LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces" << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); } @@ -663,7 +678,6 @@ void LLMaterialMgr::processPutQueue() { LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; } - mPutQueue.erase(itQueue); } } -- cgit v1.3 From a4510f5b1ce72a639889431d6f86e10b6fff96ad Mon Sep 17 00:00:00 2001 From: Maestro Linden Date: Wed, 27 Mar 2013 17:50:26 +0000 Subject: NORSPEC-56 Added some extra details to debug logs for RenderMaterials cap access. Reviewed by Graham. --- indra/newview/llmaterialmgr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index ffd7f1f1af..25e92e27d9 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -554,7 +554,8 @@ void LLMaterialMgr::processGetQueue() postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); - LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << "'\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; + LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialSize << " materials." + << "'\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; LLHTTPClient::post(capURL, postData, materialsResponder); } } @@ -670,7 +671,7 @@ void LLMaterialMgr::processPutQueue() LLSD putData = LLSD::emptyMap(); putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces" << LL_ENDL; + LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); LLHTTPClient::put(capURL, putData, materialsResponder); } -- cgit v1.3 From 250175a0fa1dd1811e7b27a8cd8e6f99ff20ced9 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Wed, 10 Apr 2013 13:12:15 -0700 Subject: NORSPEC-56 slight tweak to log formatting to correct material count --- indra/newview/llmaterialmgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 25e92e27d9..81284e42dd 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -554,8 +554,8 @@ void LLMaterialMgr::processGetQueue() postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); - LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialSize << " materials." - << "'\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; + LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialsData.size() << " materials." + << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; LLHTTPClient::post(capURL, postData, materialsResponder); } } -- cgit v1.3 From e66a32b4e2fe212b9044397a2283708e0eb8e5a4 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 25 Apr 2013 16:14:45 -0400 Subject: add some debug logging, make a single return in "get" method --- indra/newview/llmaterialmgr.cpp | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 81284e42dd..fb8cffa4ef 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -93,6 +93,7 @@ LLMaterialsResponder::~LLMaterialsResponder() void LLMaterialsResponder::result(const LLSD& pContent) { + LL_DEBUGS("Materials") << LL_ENDL; mCallback(true, pContent); } @@ -176,35 +177,43 @@ const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterial boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) { + boost::signals2::connection connection; + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); if (itMaterial != mMaterials.end()) { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; get_callback_t signal; signal.connect(cb); signal(material_id, itMaterial->second); - return boost::signals2::connection(); + connection = boost::signals2::connection(); } - - if (!isGetPending(region_id, material_id)) + else { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) + if (!isGetPending(region_id, material_id)) { - LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); } - itQueue->second.insert(material_id); - markGetPending(region_id, material_id); - } - get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); - if (itCallback == mGetCallbacks.end()) - { - std::pair ret = mGetCallbacks.insert(std::pair(material_id, new get_callback_t())); - itCallback = ret.first; + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback == mGetCallbacks.end()) + { + std::pair ret = mGetCallbacks.insert(std::pair(material_id, new get_callback_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb);; } - return itCallback->second->connect(cb);; + + return connection; } bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const -- cgit v1.3 From f356d7eb9fd730f5f6f5a29fb0706e20876ad3bd Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sat, 11 May 2013 19:58:56 -0700 Subject: Fix many issues with selection misapplication and rendering not matching applied materials --- indra/llprimitive/llprimitive.cpp | 18 ++ indra/llprimitive/llprimitive.h | 2 + indra/llprimitive/lltextureentry.cpp | 25 +- indra/llprimitive/lltextureentry.h | 6 + indra/newview/llmaterialmgr.cpp | 61 ++++ indra/newview/llmaterialmgr.h | 24 ++ indra/newview/llpanelface.cpp | 318 +++++++++------------ indra/newview/llpanelface.h | 2 +- indra/newview/llselectmgr.cpp | 5 + indra/newview/llviewerobject.cpp | 78 ++--- indra/newview/llviewerobject.h | 2 +- indra/newview/llvovolume.cpp | 47 +-- indra/newview/llvovolume.h | 2 +- .../skins/default/xui/en/panel_tools_texture.xml | 8 +- 14 files changed, 338 insertions(+), 260 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index e5905c3a3b..2fa77177f5 100755 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -374,6 +374,24 @@ S32 LLPrimitive::setTEGlow(const U8 index, const F32 glow) return mTextureList.setGlow(index, glow); } +void LLPrimitive::setAllTESelected(bool sel) +{ + for (int i = 0, cnt = getNumTEs(); i < cnt; i++) + { + setTESelected(i, sel); + } +} + +void LLPrimitive::setTESelected(const U8 te, bool sel) +{ + LLTextureEntry* tep = getTE(te); + if ( (tep) && (tep->setSelected(sel)) && (!sel) && (tep->hasPendingMaterialUpdate()) ) + { + LLMaterialID material_id = tep->getMaterialID(); + setTEMaterialID(te, material_id); + } +} + LLPCode LLPrimitive::legacyToPCode(const U8 legacy) { // TODO: Should this default to something valid? diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index b1f8090416..47a21beaaf 100755 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -361,6 +361,7 @@ public: LLTextureEntry* getTE(const U8 te_num) const; virtual void setNumTEs(const U8 num_tes); + virtual void setAllTESelected(bool sel); virtual void setAllTETextures(const LLUUID &tex_id); virtual void setTE(const U8 index, const LLTextureEntry& te); virtual S32 setTEColor(const U8 te, const LLColor4 &color); @@ -386,6 +387,7 @@ public: virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed + virtual void setTESelected(const U8 te, bool sel); void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 53816266eb..1d581da897 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -67,12 +67,16 @@ LLTextureEntry::LLTextureEntry() LLTextureEntry::LLTextureEntry(const LLUUID& tex_id) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { init(tex_id,1.f,1.f,0.f,0.f,0.f,DEFAULT_BUMP_CODE); } LLTextureEntry::LLTextureEntry(const LLTextureEntry &rhs) : mMediaEntry(NULL) + , mSelected(false) + , mMaterialUpdatePending(false) { mID = rhs.mID; mScaleS = rhs.mScaleS; @@ -536,23 +540,20 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) if (mMaterialID != pMaterialID) { mMaterialID = pMaterialID; - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + } - return TEM_CHANGE_NONE; + if (mMaterialID.isNull()) + { + setMaterialParams(NULL); + } + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mMaterial != pMaterialParams) - { - mMaterial = pMaterialParams; - return TEM_CHANGE_TEXTURE; - } - return TEM_CHANGE_NONE; + + mMaterial = pMaterialParams; + return TEM_CHANGE_TEXTURE; } void LLTextureEntry::setMediaData(const LLMediaEntry &media_entry) diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index c443ebcb30..5cc76cfe82 100755 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -100,6 +100,10 @@ public: void init(const LLUUID& tex_id, F32 scale_s, F32 scale_t, F32 offset_s, F32 offset_t, F32 rotation, U8 bump); + bool hasPendingMaterialUpdate() const { return mMaterialUpdatePending; } + bool isSelected() const { return mSelected; } + bool setSelected(bool sel) { bool prev_sel = mSelected; mSelected = sel; return prev_sel; } + // These return a TEM_ flag from above to indicate if something changed. S32 setID (const LLUUID &tex_id); S32 setColor(const LLColor4 &color); @@ -194,11 +198,13 @@ public: static const char* TEXTURE_MEDIA_DATA_KEY; protected: + bool mSelected; LLUUID mID; // Texture GUID LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. F32 mGlow; + bool mMaterialUpdatePending; LLMaterialID mMaterialID; LLMaterialPtr mMaterial; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..e41a46038f 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -216,6 +216,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -300,6 +345,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 39be5cab29..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,8 +44,12 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); + typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); @@ -78,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9c40ff06cc..837b8687e8 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1562,36 +1562,108 @@ void LLPanelFace::getState() // Materials { - mMaterialID = LLMaterialID::null; - mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor + { + LLMaterialPtr get(LLViewerObject* object, S32 te_index) + { + return object->getTE(te_index)->getMaterialParams(); + } + } func; - struct f1 : public LLSelectedTEGetFunctor + LLMaterialPtr material; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, mMaterial ); + + if (mMaterial && editable) { - LLMaterialID get(LLViewerObject* object, S32 te_index) + LL_DEBUGS("Materials: OnMatererialsLoaded:") << material->asLLSD() << LL_ENDL; + + // Alpha + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - LLMaterialID material_id; + combobox_alphamode->selectNthItem(mMaterial->getDiffuseAlphaMode()); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + getChild("maskcutoff")->setValue(mMaterial->getAlphaMaskCutoff()); + updateAlphaControls(getChild("combobox alphamode"),this); + + LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; + bool identical_texgen = true; + bool identical_planar_texgen = false; - return object->getTE(te_index)->getMaterialID(); + struct f44 : public LLSelectedTEGetFunctor + { + LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) + { + return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); + } + } func; + identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); + identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); + + // Shiny (specular) + F32 offset_x, offset_y, repeat_x, repeat_y, rot; + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); + texture_ctrl->setImageAssetID(material->getSpecularID()); + LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) + { + mMaterial->getSpecularOffset(offset_x,offset_y); + mMaterial->getSpecularRepeat(repeat_x,repeat_y); + + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = mMaterial->getSpecularRotation(); + getChild("shinyScaleU")->setValue(repeat_x); + getChild("shinyScaleV")->setValue(repeat_y); + getChild("shinyRot")->setValue(rot*RAD_TO_DEG); + getChild("shinyOffsetU")->setValue(offset_x); + getChild("shinyOffsetV")->setValue(offset_y); + getChild("glossiness")->setValue(mMaterial->getSpecularLightExponent()); + getChild("environment")->setValue(mMaterial->getEnvironmentIntensity()); } - } func; + updateShinyControls(combobox_shininess,this, !mMaterial->getSpecularID().isNull(), true); - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) + // Assert desired colorswatch color to match material AFTER updateShinyControls + // to avoid getting overwritten with the default on some UI state changes. + // + if (!material->getSpecularID().isNull()) { - mMaterialID = node->getObject()->getTE(selected_te)->getMaterialID(); + getChild("shinycolorswatch")->setOriginal(mMaterial->getSpecularLightColor()); + getChild("shinycolorswatch")->set(mMaterial->getSpecularLightColor(),TRUE); } - } - llinfos << "Material ID returned: '" << mMaterialID.asString() << "', isNull? " << (mMaterialID.isNull()?"TRUE":"FALSE") << llendl; + // Bumpy (normal) + texture_ctrl = getChild("bumpytexture control"); + texture_ctrl->setImageAssetID(mMaterial->getNormalID()); + LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!mMaterial->getNormalID().isNull()) + { + mMaterial->getNormalOffset(offset_x,offset_y); + mMaterial->getNormalRepeat(repeat_x,repeat_y); - if (!mMaterialID.isNull() && editable) - { - llinfos << "Requesting material ID " << mMaterialID.asString() << llendl; - LLMaterialMgr::getInstance()->get(objectp->getRegion()->getRegionID(),mMaterialID,boost::bind(&LLPanelFace::onMaterialLoaded, this, _1, _2)); + if (identical_planar_texgen) + { + repeat_x *= 2.0f; + repeat_y *= 2.0f; + } + + rot = material->getNormalRotation(); + getChild("bumpyScaleU")->setValue(repeat_x); + getChild("bumpyScaleV")->setValue(repeat_y); + getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); + getChild("bumpyOffsetU")->setValue(offset_x); + getChild("bumpyOffsetV")->setValue(offset_y); + } + updateBumpyControls(combobox_bumpiness,this, !mMaterial->getNormalID().isNull(), true); } } @@ -1658,104 +1730,6 @@ void LLPanelFace::refresh() getState(); } -void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ //laying out UI based on material parameters (calls setVisible on various components) - LL_DEBUGS("Materials") << "material id " << material_id.asString() << " data " << material->asLLSD() << LL_ENDL; - - //make a local copy of the material for editing - // (prevents local edits from overwriting client state on shared materials) - mMaterial = new LLMaterial(*material); - mMaterialID = material_id; - - // Alpha - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) - { - combobox_alphamode->selectNthItem(material->getDiffuseAlphaMode()); - } - else - { - llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; - } - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); - - LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; - bool identical_texgen = true; - bool identical_planar_texgen = false; - - struct f44 : public LLSelectedTEGetFunctor - { - LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face) - { - return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen()); - } - } func; - identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); - identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - - // Shiny (specular) - F32 offset_x, offset_y, repeat_x, repeat_y, rot; - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); - if (!material->getSpecularID().isNull()) - { - material->getSpecularOffset(offset_x,offset_y); - material->getSpecularRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getSpecularRotation(); - getChild("shinyScaleU")->setValue(repeat_x); - getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot*RAD_TO_DEG); - getChild("shinyOffsetU")->setValue(offset_x); - getChild("shinyOffsetV")->setValue(offset_y); - getChild("glossiness")->setValue(material->getSpecularLightExponent()); - getChild("environment")->setValue(material->getEnvironmentIntensity()); - } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); - - // Assert desired colorswatch color to match material AFTER updateShinyControls - // to avoid getting overwritten with the default on some UI state changes. - // - if (!material->getSpecularID().isNull()) - { - getChild("shinycolorswatch")->setOriginal(material->getSpecularLightColor()); - getChild("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE); - } - - // Bumpy (normal) - texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); - if (!material->getNormalID().isNull()) - { - material->getNormalOffset(offset_x,offset_y); - material->getNormalRepeat(repeat_x,repeat_y); - - if (identical_planar_texgen) - { - repeat_x *= 2.0f; - repeat_y *= 2.0f; - } - - rot = material->getNormalRotation(); - getChild("bumpyScaleU")->setValue(repeat_x); - getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); - getChild("bumpyOffsetU")->setValue(offset_x); - getChild("bumpyOffsetV")->setValue(offset_y); - } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); -} - void LLPanelFace::updateMaterial() { // assign current state of UI to material definition for submit to sim LL_DEBUGS("Materials") << "Entered." << LL_ENDL; @@ -1781,53 +1755,38 @@ void LLPanelFace::updateMaterial() bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen ); bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) + bool is_default_blend_mode = mIsAlpha ? (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + : (alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_NONE); + + if ( !is_default_blend_mode || (bumpiness == BUMPY_TEXTURE) || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. bool new_material = false; - if (!mMaterial) + + // Create new or clone material + // + if (mMaterial.isNull()) { - new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); + new_material = true; } - - LLMaterialPtr material_to_set = mMaterial; - - bool subselection = false; - - // If we're editing a single face and not the entire material for an object, - // we need to clone the material so that our changes to the material's settings - // don't automatically propagate to the non-selected faces - // NORSPEC-92 - // - LLObjectSelectionHandle sel = LLSelectMgr::getInstance()->getSelection(); - LLSelectNode* node = sel->getFirstNode(); - if (node) + else { - if (node->getTESelectMask() != TE_SELECT_MASK_ALL) - { - llinfos << "Cloning material to apply to subselection." << llendl; - material_to_set = new LLMaterial(mMaterial->asLLSD()); - subselection = true; - } - else - { - llinfos << "Apply material change to whole selection." << llendl; - } + mMaterial = LLMaterialPtr(new LLMaterial(mMaterial->asLLSD())); } - llassert(!material_to_set.isNull()); + llassert_always(mMaterial); - material_to_set->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - material_to_set->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); LLUUID norm_map_id = getChild("bumpytexture control")->getImageAssetID(); if (!norm_map_id.isNull() && (bumpiness == BUMPY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(norm_map_id); + mMaterial->setNormalID(norm_map_id); F32 bumpy_scale_u = getChild("bumpyScaleU")->getValue().asReal(); F32 bumpy_scale_v = getChild("bumpyScaleV")->getValue().asReal(); @@ -1838,18 +1797,18 @@ void LLPanelFace::updateMaterial() bumpy_scale_v *= 0.5f; } - material_to_set->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), + mMaterial->setNormalOffset(getChild("bumpyOffsetU")->getValue().asReal(), getChild("bumpyOffsetV")->getValue().asReal()); - material_to_set->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); - material_to_set->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setNormalRepeat(bumpy_scale_u, bumpy_scale_v); + mMaterial->setNormalRotation(getChild("bumpyRot")->getValue().asReal()*DEG_TO_RAD); } else { LL_DEBUGS("Materials") << "Removing bumpy texture, bumpiness = " << bumpiness << LL_ENDL; - material_to_set->setNormalID(LLUUID()); - material_to_set->setNormalOffset(0.0f,0.0f); - material_to_set->setNormalRepeat(1.0f,1.0f); - material_to_set->setNormalRotation(0.0f); + mMaterial->setNormalID(LLUUID()); + mMaterial->setNormalOffset(0.0f,0.0f); + mMaterial->setNormalRepeat(1.0f,1.0f); + mMaterial->setNormalRotation(0.0f); } LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); @@ -1857,8 +1816,8 @@ void LLPanelFace::updateMaterial() if (!spec_map_id.isNull() && (shininess == SHINY_TEXTURE)) { LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(spec_map_id); - material_to_set->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), + mMaterial->setSpecularID(spec_map_id); + mMaterial->setSpecularOffset(getChild("shinyOffsetU")->getValue().asReal(), getChild("shinyOffsetV")->getValue().asReal()); F32 shiny_scale_u = getChild("shinyScaleU")->getValue().asReal(); @@ -1870,55 +1829,42 @@ void LLPanelFace::updateMaterial() shiny_scale_v *= 0.5f; } - material_to_set->setSpecularRepeat(shiny_scale_u, shiny_scale_v); - material_to_set->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + mMaterial->setSpecularRepeat(shiny_scale_u, shiny_scale_v); + mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); //override shininess to 0.2f if this is a new material if (!new_material) { - material_to_set->setSpecularLightColor(getChild("shinycolorswatch")->get()); - material_to_set->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); - material_to_set->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent(getChild("glossiness")->getValue().asInteger()); + mMaterial->setEnvironmentIntensity(getChild("environment")->getValue().asInteger()); } } else { LL_DEBUGS("Materials") << "Removing shiny texture, shininess = " << shininess << LL_ENDL; - material_to_set->setSpecularID(LLUUID()); - material_to_set->setSpecularOffset(0.0f,0.0f); - material_to_set->setSpecularRepeat(1.0f,1.0f); - material_to_set->setSpecularRotation(0.0f); - material_to_set->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); - material_to_set->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - material_to_set->setEnvironmentIntensity(0); + mMaterial->setSpecularID(LLUUID()); + mMaterial->setSpecularOffset(0.0f,0.0f); + mMaterial->setSpecularRepeat(1.0f,1.0f); + mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR); + mMaterial->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + mMaterial->setEnvironmentIntensity(0); } - LL_DEBUGS("Materials") << "Updating material: " << material_to_set->asLLSD() << LL_ENDL; - + LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; - if (node && node->getObject() && node->getObject()->permModify() && subselection) - { - int selected_te = node->getLastSelectedTE(); - if (selected_te >= 0) - { - LLMaterialMgr::getInstance()->put(node->getObject()->getID(),selected_te,*material_to_set); - node->getObject()->getTE(selected_te)->setMaterialParams(material_to_set); - node->getObject()->sendTEUpdate(); - } - } - else - { - LLSelectMgr::getInstance()->selectionSetMaterial( material_to_set ); - } + LLSelectMgr::getInstance()->selectionSetMaterial( mMaterial ); } else { // The user has specified settings that don't need a material. - if (mMaterial || !mMaterialID.isNull()) + //if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; mMaterial = NULL; mMaterialID = LLMaterialID::null; + // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 7fbeef223b..401dbd1e94 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -87,7 +87,7 @@ protected: void onCommitAlpha(const LLSD& data); void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material); + void updateMaterial(); static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 5a65623b91..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -815,6 +815,7 @@ void LLSelectMgr::addAsFamily(std::vector& objects, BOOL add_to if (objectp->getNumTEs() > 0) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else { @@ -872,10 +873,12 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab else if (face == SELECT_ALL_TES) { nodep->selectAllTEs(TRUE); + objectp->setAllTESelected(true); } else if (0 <= face && face < SELECT_MAX_TES) { nodep->selectTE(face, TRUE); + objectp->setTESelected(face, true); } else { @@ -1095,6 +1098,7 @@ LLObjectSelectionHandle LLSelectMgr::selectHighlightedObjects() // flag this object as selected objectp->setSelected(TRUE); + objectp->setAllTESelected(true); mSelectedObjects->mSelectType = getSelectTypeForObject(objectp); @@ -1318,6 +1322,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable) if (nodep->isTESelected(te)) { nodep->selectTE(te, FALSE); + objectp->setTESelected(te, false); } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 2965d968a3..548fb236d6 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -530,6 +530,17 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) } } +void LLViewerObject::setSelected(BOOL sel) +{ + mUserSelected = sel; + resetRot(); + + if (!sel) + { + setAllTESelected(false); + } +} + // This method returns true if the object is over land owned by the // agent. bool LLViewerObject::isReturnable() @@ -4116,14 +4127,8 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, LLViewerTexture *image) { mat->setNormalID(uuid); } - - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } } - mTENormalMaps[te] = image; + changeTENormalMap(te,image); return retval; } @@ -4144,14 +4149,9 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, LLViewerTexture *image) if (mat) { mat->setSpecularID(uuid); - } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); } } - mTESpecularMaps[te] = image; + changeTESpecularMap(te, image); return retval; } @@ -4171,6 +4171,11 @@ void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTENormalMaps[index] = new_image ; } @@ -4180,6 +4185,11 @@ void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) { return ; } + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } mTESpecularMaps[index] = new_image ; } @@ -4375,18 +4385,21 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; } - else if (pMaterialID != tep->getMaterialID()) + //else if (pMaterialID != tep->getMaterialID()) { LL_DEBUGS("Material") << "Changing texture entry for te " << (S32)te << ", object " << mID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); } return retval; } @@ -4398,22 +4411,23 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri if (!tep) { llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; + return 0; } - else if (pMaterialParams != tep->getMaterialParams()) + + retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); + LL_DEBUGS("Material") << "Changing material params for te " << (S32)te + << ", object " << mID + << " (" << retval << ")" + << LL_ENDL; + setTENormalMap(te, tep->getMaterialParams()->getNormalID()); + setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + + setChanged(TEXTURE); + if (mDrawable.notNull()) { - retval = LLPrimitive::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("Material") << "Changing material params for te " << (S32)te - << ", object " << mID - << " (" << retval << ")" - << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } + return retval; } diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index ba23ad97b0..bcb74a8d1f 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -211,7 +211,7 @@ public: LLViewerRegion* getRegion() const { return mRegionp; } BOOL isSelected() const { return mUserSelected; } - virtual void setSelected(BOOL sel) { mUserSelected = sel; resetRot();} + virtual void setSelected(BOOL sel); const LLUUID &getID() const { return mID; } U32 getLocalID() const { return mLocalID; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 941892a597..df014513ad 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,33 +1973,34 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) +void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + LLTextureEntry* texture_entry = getTE(te); + if (texture_entry && (texture_entry->getMaterialID().isNull() || (texture_entry->getMaterialID() == pMaterialID))) { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) - { - setTEMaterialParams(i, pMaterialParams); - } + setTEMaterialParams(te, pMaterialParams); } } S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res - << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) - << LL_ENDL; - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + LL_DEBUGS("MaterialTEs") << "te "<< (S32)te << " materialid " << pMaterialID.asString() << " res " << res + << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) + << LL_ENDL; + + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); } + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; +} S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { @@ -2007,13 +2008,13 @@ S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialPa LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; - if (res) + setChanged(TEXTURE); + if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; } - - return res; + mFaceMappingChanged = TRUE; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEScale(const U8 te, const F32 s, const F32 t) diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index d1bfefdc70..a5f933c319 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,7 +187,7 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); + void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index b6fc48212a..a5425062ec 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -644,8 +644,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="bumpyRot" width="265" /> @@ -707,8 +707,8 @@ layout="topleft" label_width="205" left="10" - max_val="9999" - min_val="-9999" + max_val="180" + min_val="-180" name="shinyRot" width="265" /> -- cgit v1.3 From c2c9380fe135fd8b191ebe3c9a38129af4994ed8 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 13:02:54 +0200 Subject: Avoid code duplication in LLMaterialMgr --- indra/newview/llmaterialmgr.cpp | 61 ----------------------------------------- indra/newview/llmaterialmgr.h | 22 --------------- indra/newview/llvovolume.cpp | 2 +- 3 files changed, 1 insertion(+), 84 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index e41a46038f..fb8cffa4ef 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -216,51 +216,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) -{ - boost::signals2::connection connection; - - material_map_t::const_iterator itMaterial = mMaterials.find(material_id); - if (itMaterial != mMaterials.end()) - { - LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; - get_callback_te_t signal; - signal.connect(cb); - signal(material_id, itMaterial->second, te); - connection = boost::signals2::connection(); - } - else - { - if (!isGetPending(region_id, material_id)) - { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) - { - LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; - } - LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; - itQueue->second.insert(material_id); - markGetPending(region_id, material_id); - } - - TEMaterialPair te_mat_pair; - te_mat_pair.te = te; - te_mat_pair.materialID = material_id; - - get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); - if (itCallback == mGetTECallbacks.end()) - { - std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); - itCallback = ret.first; - } - connection = itCallback->second->connect(cb); - } - - return connection; -} - bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -345,22 +300,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; - - U32 i = 0; - while (i < LLTEContents::MAX_TES) - { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) - { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); - } - } - return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 922b16f1cf..a6a7a5d1d7 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,11 +44,9 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); - boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -82,26 +80,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; - // struct for TE-specific material ID query - struct TEMaterialPair - { - U32 te; - LLMaterialID materialID; - }; - - // needed for std::map compliance only - // - friend inline bool operator<( - const struct LLMaterialMgr::TEMaterialPair& lhs, - const struct LLMaterialMgr::TEMaterialPair& rhs) - { - return (lhs.materialID < rhs.materialID) ? TRUE : - (lhs.te < rhs.te) ? TRUE : FALSE; - } - - typedef std::map get_callback_te_map_t; - get_callback_te_map_t mGetTECallbacks; - typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index df014513ad..734ac2afc8 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1992,7 +1992,7 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); setChanged(TEXTURE); if (!mDrawable.isNull()) { -- cgit v1.3 From 5ac9d9cb05f22099bea8c9312f5e0b234430022a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 12 May 2013 16:10:31 +0200 Subject: LLMaterialMgr::get() doesn't handle a callback request for LLMaterialID::null --- indra/llprimitive/lltextureentry.cpp | 7 ++----- indra/newview/llmaterialmgr.cpp | 1 + indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 23 +++++++++++++---------- indra/newview/llvovolume.cpp | 18 ++++++++++-------- 5 files changed, 27 insertions(+), 24 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 8365c9d7b6..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -550,12 +550,9 @@ S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) mMaterialUpdatePending = false; mMaterialID = pMaterialID; + return TEM_CHANGE_TEXTURE; } - if (mMaterialID.isNull()) - { - setMaterialParams(NULL); - } - return TEM_CHANGE_TEXTURE; + return TEM_CHANGE_NONE; } S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fb8cffa4ef..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -116,6 +116,7 @@ void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) LLMaterialMgr::LLMaterialMgr() { + mMaterials.insert(std::pair(LLMaterialID::null, LLMaterialPtr(NULL))); gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index d56df96c44..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } @@ -4420,11 +4423,11 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri << ", object " << mID << " (" << retval << ")" << LL_ENDL; - setTENormalMap(te, tep->getMaterialParams()->getNormalID()); - setTESpecularMap(te, tep->getMaterialParams()->getSpecularID()); + setTENormalMap(te, (pMaterialParams) ? pMaterialParams->getNormalID() : LLUUID::null); + setTESpecularMap(te, (pMaterialParams) ? pMaterialParams->getSpecularID() : LLUUID::null); setChanged(TEXTURE); - if (mDrawable.notNull()) + if (mDrawable.notNull()) { gPipeline.markTextured(mDrawable); } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 734ac2afc8..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,21 +1991,23 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); - setChanged(TEXTURE); - if (!mDrawable.isNull()) + if (res) { - gPipeline.markTextured(mDrawable); + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + setChanged(TEXTURE); + if (!mDrawable.isNull()) + { + gPipeline.markTextured(mDrawable); + } + mFaceMappingChanged = TRUE; } - mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) { S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams); - LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << pMaterialParams->asLLSD() << " res " << res + LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res << ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast(this), te) ? " selected" : " not selected" ) << LL_ENDL; setChanged(TEXTURE); -- cgit v1.3 From d9e8ee7cfd323872145c23e4032989f9b7770f55 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Mon, 13 May 2013 13:02:53 -0700 Subject: NORSPEC-178 NORSPEC-179 NORSPEC-180 made enable/disable handling more consistent and increased max range on repeats per meter --- indra/llprimitive/lltextureentry.cpp | 21 +- indra/newview/llmaterialmgr.cpp | 61 ++++++ indra/newview/llmaterialmgr.h | 22 ++ indra/newview/llpanelface.cpp | 241 +++++++++------------ indra/newview/llpanelface.h | 52 +++-- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +- indra/newview/llvovolume.cpp | 8 +- .../skins/default/xui/en/panel_tools_texture.xml | 2 +- 9 files changed, 244 insertions(+), 182 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 597f078490..ca57f1edbd 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,28 +539,21 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) + if (mMaterialID != pMaterialID) { - if (mSelected) + mMaterialID = pMaterialID; + + } + if (mMaterialID.isNull()) { - mMaterialUpdatePending = true; - mMaterialID = pMaterialID; - return TEM_CHANGE_NONE; + setMaterialParams(NULL); } - - mMaterialUpdatePending = false; - mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } - return TEM_CHANGE_NONE; -} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - if (mSelected) - { - mMaterialUpdatePending = true; - } + mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f217ff160e..59e5d05736 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,6 +217,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -301,6 +346,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index a6a7a5d1d7..922b16f1cf 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,9 +44,11 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -80,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index d108a260bc..b2f76e2114 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -596,6 +596,11 @@ void LLPanelFace::sendTextureInfo() } void LLPanelFace::getState() +{ + updateUI(); +} + +void LLPanelFace::updateUI() { //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible) LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); @@ -636,12 +641,12 @@ void LLPanelFace::getState() } getChildView("combobox mattype")->setEnabled(editable); - onCommitMaterialsMedia(NULL, this); + updateVisibility(); bool identical; - bool identical_diffuse; - bool identical_norm; - bool identical_spec; + bool identical_diffuse; + bool identical_norm; + bool identical_spec; LLTextureCtrl* texture_ctrl = getChild("texture control"); LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); @@ -798,7 +803,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); } if(texture_ctrl && !texture_ctrl->isPickerShown()) @@ -1587,7 +1592,7 @@ void LLPanelFace::getState() llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); - updateAlphaControls(getChild("combobox alphamode"),this); + updateAlphaControls(); LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; bool identical_texgen = true; @@ -1607,7 +1612,7 @@ void LLPanelFace::getState() F32 offset_x, offset_y, repeat_x, repeat_y, rot; LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); texture_ctrl->setImageAssetID(material->getSpecularID()); - LLComboBox* combobox_shininess = getChild("combobox shininess"); + if (!material->getSpecularID().isNull()) { material->getSpecularOffset(offset_x,offset_y); @@ -1628,7 +1633,7 @@ void LLPanelFace::getState() getChild("glossiness")->setValue(material->getSpecularLightExponent()); getChild("environment")->setValue(material->getEnvironmentIntensity()); } - updateShinyControls(combobox_shininess,this, !material->getSpecularID().isNull(), true); + updateShinyControls(!material->getSpecularID().isNull(), true); // Assert desired colorswatch color to match material AFTER updateShinyControls // to avoid getting overwritten with the default on some UI state changes. @@ -1642,7 +1647,7 @@ void LLPanelFace::getState() // Bumpy (normal) texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); - LLComboBox* combobox_bumpiness = getChild("combobox bumpiness"); + if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); @@ -1661,7 +1666,7 @@ void LLPanelFace::getState() getChild("bumpyOffsetU")->setValue(offset_x); getChild("bumpyOffsetV")->setValue(offset_y); } - updateBumpyControls(combobox_bumpiness,this, !material->getNormalID().isNull(), true); + updateBumpyControls(!material->getNormalID().isNull(), true); } } @@ -1702,12 +1707,11 @@ void LLPanelFace::getState() getChildView("tex gen")->setEnabled(FALSE); getChildView("label shininess")->setEnabled(FALSE); getChildView("label bumpiness")->setEnabled(FALSE); - getChildView("button align")->setEnabled(FALSE); //getChildView("has media")->setEnabled(FALSE); //getChildView("media info set")->setEnabled(FALSE); - onCommitMaterialsMedia(NULL,this); + updateVisibility(); // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -1904,10 +1908,16 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); - LLComboBox* combo_shininess = self->getChild("combobox shininess"); - LLComboBox* combo_bumpiness = self->getChild("combobox bumpiness"); + self->updateUI(); +} + +// static +void LLPanelFace::updateVisibility() +{ + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); + LLComboBox* combo_shininess = getChild("combobox shininess"); + LLComboBox* combo_bumpiness = getChild("combobox bumpiness"); if (!combo_mattype || !combo_matmedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; @@ -1919,93 +1929,66 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) bool show_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); - self->getChildView("combobox mattype")->setVisible(!show_media); - self->getChildView("rptctrl")->setVisible(true); + getChildView("combobox mattype")->setVisible(!show_media); + getChildView("rptctrl")->setVisible(true); // Media controls - self->getChildView("media_info")->setVisible(show_media); - self->getChildView("add_media")->setVisible(show_media); - self->getChildView("delete_media")->setVisible(show_media); - self->getChildView("button align")->setVisible(show_media); + getChildView("media_info")->setVisible(show_media); + getChildView("add_media")->setVisible(show_media); + getChildView("delete_media")->setVisible(show_media); + getChildView("button align")->setVisible(show_media); // Diffuse texture controls - self->getChildView("texture control")->setVisible(show_texture && !show_media); - self->getChildView("label alphamode")->setVisible(show_texture && !show_media); - self->getChildView("combobox alphamode")->setVisible(show_texture && !show_media); - self->getChildView("label maskcutoff")->setVisible(false); - self->getChildView("maskcutoff")->setVisible(false); + getChildView("texture control")->setVisible(show_texture && !show_media); + getChildView("label alphamode")->setVisible(show_texture && !show_media); + getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + getChildView("label maskcutoff")->setVisible(false); + getChildView("maskcutoff")->setVisible(false); if (show_texture && !show_media) { - updateAlphaControls(ctrl, userdata); + updateAlphaControls(); } - self->getChildView("TexScaleU")->setVisible(show_texture); - self->getChildView("TexScaleV")->setVisible(show_texture); - self->getChildView("TexRot")->setVisible(show_texture); - self->getChildView("TexOffsetU")->setVisible(show_texture); - self->getChildView("TexOffsetV")->setVisible(show_texture); + getChildView("TexScaleU")->setVisible(show_texture); + getChildView("TexScaleV")->setVisible(show_texture); + getChildView("TexRot")->setVisible(show_texture); + getChildView("TexOffsetU")->setVisible(show_texture); + getChildView("TexOffsetV")->setVisible(show_texture); // Specular map controls - self->getChildView("shinytexture control")->setVisible(show_shininess); - self->getChildView("combobox shininess")->setVisible(show_shininess); - self->getChildView("label shininess")->setVisible(show_shininess); - self->getChildView("label glossiness")->setVisible(false); - self->getChildView("glossiness")->setVisible(false); - self->getChildView("label environment")->setVisible(false); - self->getChildView("environment")->setVisible(false); - self->getChildView("label shinycolor")->setVisible(false); - self->getChildView("shinycolorswatch")->setVisible(false); + getChildView("shinytexture control")->setVisible(show_shininess); + getChildView("combobox shininess")->setVisible(show_shininess); + getChildView("label shininess")->setVisible(show_shininess); + getChildView("label glossiness")->setVisible(false); + getChildView("glossiness")->setVisible(false); + getChildView("label environment")->setVisible(false); + getChildView("environment")->setVisible(false); + getChildView("label shinycolor")->setVisible(false); + getChildView("shinycolorswatch")->setVisible(false); if (show_shininess) { - updateShinyControls(ctrl, userdata); + updateShinyControls(); } - self->getChildView("shinyScaleU")->setVisible(show_shininess); - self->getChildView("shinyScaleV")->setVisible(show_shininess); - self->getChildView("shinyRot")->setVisible(show_shininess); - self->getChildView("shinyOffsetU")->setVisible(show_shininess); - self->getChildView("shinyOffsetV")->setVisible(show_shininess); + getChildView("shinyScaleU")->setVisible(show_shininess); + getChildView("shinyScaleV")->setVisible(show_shininess); + getChildView("shinyRot")->setVisible(show_shininess); + getChildView("shinyOffsetU")->setVisible(show_shininess); + getChildView("shinyOffsetV")->setVisible(show_shininess); // Normal map controls if (show_bumpiness) { - updateBumpyControls(ctrl, userdata); + updateBumpyControls(); } - self->getChildView("bumpytexture control")->setVisible(show_bumpiness); - self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); - self->getChildView("label bumpiness")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleU")->setVisible(show_bumpiness); - self->getChildView("bumpyScaleV")->setVisible(show_bumpiness); - self->getChildView("bumpyRot")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - self->getChildView("bumpyOffsetV")->setVisible(show_bumpiness); - - // Enable texture scale/rotation/offset parameters if there's one - // present to set for - bool texParmsEnable = show_texture || - (show_shininess && (combo_shininess->getCurrentIndex() == SHINY_TEXTURE)) || - (show_bumpiness && (combo_bumpiness->getCurrentIndex() == BUMPY_TEXTURE)); - self->getChildView("tex gen")->setEnabled(texParmsEnable); - self->getChildView("combobox texgen")->setEnabled(texParmsEnable); - self->getChildView("rptctrl")->setEnabled(texParmsEnable); - self->getChildView("TexScaleU")->setEnabled(texParmsEnable); - self->getChildView("TexScaleV")->setEnabled(texParmsEnable); - self->getChildView("TexRot")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetU")->setEnabled(texParmsEnable); - self->getChildView("TexOffsetV")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleU")->setEnabled(texParmsEnable); - self->getChildView("shinyScaleV")->setEnabled(texParmsEnable); - self->getChildView("shinyRot")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("shinyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleU")->setEnabled(texParmsEnable); - self->getChildView("bumpyScaleV")->setEnabled(texParmsEnable); - self->getChildView("bumpyRot")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetU")->setEnabled(texParmsEnable); - self->getChildView("bumpyOffsetV")->setEnabled(texParmsEnable); - self->getChildView("checkbox planar align")->setEnabled(texParmsEnable); - - // Needed to handle transitions to/from media mode - // NORSPEC-84 - updateAlphaControls(ctrl,userdata); + getChildView("bumpytexture control")->setVisible(show_bumpiness); + getChildView("combobox bumpiness")->setVisible(show_bumpiness); + getChildView("label bumpiness")->setVisible(show_bumpiness); + getChildView("bumpyScaleU")->setVisible(show_bumpiness); + getChildView("bumpyScaleV")->setVisible(show_bumpiness); + getChildView("bumpyRot")->setVisible(show_bumpiness); + getChildView("bumpyOffsetU")->setVisible(show_bumpiness); + getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + + } // static @@ -2016,7 +1999,7 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) // like the texture ctrls for diffuse/norm/spec so that they are correct // when switching modes // - self->getState(); + self->updateUI(); } // static @@ -2024,10 +2007,7 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendBump(); - - LLComboBox* combo_bumpy = self->getChild("combobox bumpiness"); - - updateBumpyControls(combo_bumpy,self, false, true); + self->updateBumpyControls(false, true); self->updateMaterial(); } @@ -2039,13 +2019,12 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) } // static -void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_shiny_combobox) +void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_shiny_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("shinytexture control"); + LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; - LLComboBox* comboShiny = self->getChild("combobox shininess"); + LLComboBox* comboShiny = getChild("combobox shininess"); if(mess_with_shiny_combobox) { @@ -2061,15 +2040,15 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se // NORSPEC-94: Set default specular color to white // - LLColorSwatchCtrl* mShinyColorSwatch = self->getChild("shinycolorswatch"); + LLColorSwatchCtrl* mShinyColorSwatch = getChild("shinycolorswatch"); if(mShinyColorSwatch) { LL_DEBUGS("Materials") << "Resetting specular color to default of white" << LL_ENDL; mShinyColorSwatch->setOriginal(LLColor4::white); mShinyColorSwatch->set(LLColor4::white, TRUE); } - self->getChild("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); - self->getChild("environment")->setValue(0); + getChild("glossiness")->setValue(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT); + getChild("environment")->setValue(0); } comboShiny->setSimple(USE_TEXTURE); } @@ -2084,30 +2063,29 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool is_se } } - LLComboBox* combo_matmedia = self->getChild("combobox matmedia"); - LLComboBox* combo_mattype = self->getChild("combobox mattype"); + LLComboBox* combo_matmedia = getChild("combobox matmedia"); + LLComboBox* combo_mattype = getChild("combobox mattype"); U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = combo_mattype->getCurrentIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture - self->getChildView("label glossiness")->setVisible(show_shinyctrls); - self->getChildView("glossiness")->setVisible(show_shinyctrls); - self->getChildView("label environment")->setVisible(show_shinyctrls); - self->getChildView("environment")->setVisible(show_shinyctrls); - self->getChildView("label shinycolor")->setVisible(show_shinyctrls); - self->getChildView("shinycolorswatch")->setVisible(show_shinyctrls); + getChildView("label glossiness")->setVisible(show_shinyctrls); + getChildView("glossiness")->setVisible(show_shinyctrls); + getChildView("label environment")->setVisible(show_shinyctrls); + getChildView("environment")->setVisible(show_shinyctrls); + getChildView("label shinycolor")->setVisible(show_shinyctrls); + getChildView("shinycolorswatch")->setVisible(show_shinyctrls); } // static -void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_setting_texture, bool mess_with_combobox) +void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_combobox) { - LLPanelFace* self = (LLPanelFace*) userdata; - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; - LLComboBox* comboBumpy = self->getChild("combobox bumpiness"); + LLComboBox* comboBumpy = getChild("combobox bumpiness"); if (!comboBumpy) { return; @@ -2115,7 +2093,7 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool is_se if (mess_with_combobox) { - LLTextureCtrl* texture_ctrl = self->getChild("bumpytexture control"); + LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; @@ -2144,19 +2122,17 @@ void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; self->sendShiny(); - LLComboBox* combo_shiny = self->getChild("combobox shininess"); // Need 'true' here to insure that the 'Use Texture' choice is removed // when we select something other than a spec texture // - updateShinyControls(combo_shiny,self, false, true); + self->updateShinyControls(false, true); self->updateMaterial(); } // static -void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::updateAlphaControls() { - LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* comboAlphaMode = self->getChild("combobox alphamode"); + LLComboBox* comboAlphaMode = getChild("combobox alphamode"); if (!comboAlphaMode) { return; @@ -2164,14 +2140,14 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) U32 alpha_value = comboAlphaMode->getCurrentIndex(); bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking - LLComboBox* combobox_matmedia = self->getChild("combobox matmedia"); + LLComboBox* combobox_matmedia = getChild("combobox matmedia"); U32 mat_media = MATMEDIA_MATERIAL; if (combobox_matmedia) { mat_media = combobox_matmedia->getCurrentIndex(); } - LLComboBox* combobox_mattype = self->getChild("combobox mattype"); + LLComboBox* combobox_mattype = getChild("combobox mattype"); U32 mat_type = MATTYPE_DIFFUSE; if (combobox_mattype) { @@ -2181,15 +2157,15 @@ void LLPanelFace::updateAlphaControls(LLUICtrl* ctrl, void* userdata) show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); show_alphactrls = show_alphactrls && (mat_type == MATTYPE_DIFFUSE); - self->getChildView("label maskcutoff")->setVisible(show_alphactrls); - self->getChildView("maskcutoff")->setVisible(show_alphactrls); + getChildView("label maskcutoff")->setVisible(show_alphactrls); + getChildView("maskcutoff")->setVisible(show_alphactrls); } // static void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - updateAlphaControls(ctrl,userdata); + self->updateAlphaControls(); self->updateMaterial(); } @@ -2245,46 +2221,40 @@ void LLPanelFace::onSelectTexture(const LLSD& data) void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); updateMaterial(); } void LLPanelFace::onCommitNormalTexture( const LLSD& data ) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy, this, true, true); + updateBumpyControls(true, true); updateMaterial(); } void LLPanelFace::onCancelSpecularTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, false, true); + updateShinyControls(false, true); } void LLPanelFace::onCancelNormalTexture(const LLSD& data) { updateMaterial(); - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, false, true); + updateBumpyControls(false, true); } void LLPanelFace::onSelectSpecularTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; updateMaterial(); - LLComboBox* combo_shiny = getChild("combobox shininess"); - updateShinyControls(combo_shiny,this, true, true); + updateShinyControls(true, true); } void LLPanelFace::onSelectNormalTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; - LLComboBox* combo_bumpy = getChild("combobox bumpiness"); - updateBumpyControls(combo_bumpy,this, true, true); + updateBumpyControls(true, true); updateMaterial(); } @@ -2310,9 +2280,10 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) gFocusMgr.setKeyboardFocus( NULL ); - //F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get(); - F32 repeats_per_meter = (F32)self->getChild("rptctrl")->getValue().asReal();//self->mCtrlRepeatsPerMeter->get(); + LLUICtrl* repeats_ctrl = self->getChild("rptctrl"); + F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); + LLComboBox* combo_mattype = self->getChild("combobox mattype"); F32 obj_scale_s = 1.0f; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 4e97295b84..88f32e45f8 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -67,7 +67,7 @@ protected: void sendTexGen(); // applies and sends bump map void sendShiny(); // applies and sends shininess void sendFullbright(); // applies and sends full bright - void sendGlow(); + void sendGlow(); void sendMedia(); // this function is to return TRUE if the drag should succeed. @@ -88,29 +88,49 @@ protected: void onCancelColor(const LLSD& data); void onSelectColor(const LLSD& data); - void updateMaterial(); - - static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); - static void onCommitBump( LLUICtrl* ctrl, void* userdata); + // Make UI reflect state of currently selected material (refresh) + // and UI mode (e.g. editing normal map v diffuse map) + // + void updateUI(); + + // Callback funcs for individual controls + // + static void onCommitTextureInfo( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterial( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); + static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); - static void updateShinyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void updateBumpyControls( LLUICtrl* ctrl, void* userdata, bool is_setting_texture = false, bool mess_with_combobox = false); - static void onCommitShiny( LLUICtrl* ctrl, void* userdata); - static void updateAlphaControls( LLUICtrl* ctrl, void* userdata); + static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitGlow( LLUICtrl* ctrl, void *userdata); - static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); - + static void onCommitGlow( LLUICtrl* ctrl, void *userdata); + static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); static void onClickAutoFix(void*); - static F32 valueGlow(LLViewerObject* object, S32 face); + + static F32 valueGlow(LLViewerObject* object, S32 face); private: + // Update visibility of controls to match current UI mode + // (e.g. materials vs media editing) + // + // Do NOT call updateUI from within this function. + // + void updateVisibility(); + + // Make material reflect current state of UI (apply edit) + // + void updateMaterial(); + + // Update vis and enabling of specific subsets of controls based on material params + // (e.g. hide the spec controls if no spec texture is applied) + // + void updateShinyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateBumpyControls(bool is_setting_texture = false, bool mess_with_combobox = false); + void updateAlphaControls(); + /* * Checks whether the selected texture from the LLFloaterTexturePicker can be applied to the currently selected object. * If agent selects texture which is not allowed to be applied for the currently selected object, diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index e80ad6976e..3f60b5f642 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialParams(face, NULL); + object->setTEMaterialID(face,LLMaterialID::null); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e233d479a..f8bc6ef4d3 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,18 +4393,15 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - if (retval) + } + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) { - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } + gPipeline.markTextured(mDrawable); } - } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8e811527eb..1021615255 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,17 +1991,15 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - if (res) - { - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - } - return res; + return TEM_CHANGE_TEXTURE; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index a5425062ec..5be3ca9d9f 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -567,7 +567,7 @@ layout="topleft" label_width="205" left="10" - max_val="10" + max_val="100" min_val="0.1" name="rptctrl" width="265" /> -- cgit v1.3 From ad09e2111cd980117ae937b79155ef6c24e4567c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 14 May 2013 21:14:46 +0200 Subject: NORSPEC-102 & Co Reloaded --- indra/llprimitive/lltextureentry.cpp | 21 ++++++++----- indra/newview/llmaterialmgr.cpp | 61 ------------------------------------ indra/newview/llmaterialmgr.h | 22 ------------- indra/newview/llselectmgr.cpp | 2 +- indra/newview/llviewerobject.cpp | 17 +++++----- indra/newview/llvovolume.cpp | 8 +++-- 6 files changed, 30 insertions(+), 101 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index ca57f1edbd..597f078490 100755 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -539,21 +539,28 @@ S32 LLTextureEntry::setGlow(F32 glow) S32 LLTextureEntry::setMaterialID(const LLMaterialID& pMaterialID) { - if (mMaterialID != pMaterialID) + if ( (mMaterialID != pMaterialID) || (mMaterialUpdatePending && !mSelected) ) { - mMaterialID = pMaterialID; - - } - if (mMaterialID.isNull()) + if (mSelected) { - setMaterialParams(NULL); + mMaterialUpdatePending = true; + mMaterialID = pMaterialID; + return TEM_CHANGE_NONE; } + + mMaterialUpdatePending = false; + mMaterialID = pMaterialID; return TEM_CHANGE_TEXTURE; } + return TEM_CHANGE_NONE; +} S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) { - + if (mSelected) + { + mMaterialUpdatePending = true; + } mMaterial = pMaterialParams; return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 59e5d05736..f217ff160e 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,51 +217,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) -{ - boost::signals2::connection connection; - - material_map_t::const_iterator itMaterial = mMaterials.find(material_id); - if (itMaterial != mMaterials.end()) - { - LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; - get_callback_te_t signal; - signal.connect(cb); - signal(material_id, itMaterial->second, te); - connection = boost::signals2::connection(); - } - else - { - if (!isGetPending(region_id, material_id)) - { - get_queue_t::iterator itQueue = mGetQueue.find(region_id); - if (mGetQueue.end() == itQueue) - { - LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); - itQueue = ret.first; - } - LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; - itQueue->second.insert(material_id); - markGetPending(region_id, material_id); - } - - TEMaterialPair te_mat_pair; - te_mat_pair.te = te; - te_mat_pair.materialID = material_id; - - get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); - if (itCallback == mGetTECallbacks.end()) - { - std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); - itCallback = ret.first; - } - connection = itCallback->second->connect(cb); - } - - return connection; -} - bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -346,22 +301,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; - - U32 i = 0; - while (i < LLTEContents::MAX_TES) - { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) - { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); - } - } - return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 922b16f1cf..a6a7a5d1d7 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,11 +44,9 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); - boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -82,26 +80,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; - // struct for TE-specific material ID query - struct TEMaterialPair - { - U32 te; - LLMaterialID materialID; - }; - - // needed for std::map compliance only - // - friend inline bool operator<( - const struct LLMaterialMgr::TEMaterialPair& lhs, - const struct LLMaterialMgr::TEMaterialPair& rhs) - { - return (lhs.materialID < rhs.materialID) ? TRUE : - (lhs.te < rhs.te) ? TRUE : FALSE; - } - - typedef std::map get_callback_te_map_t; - get_callback_te_map_t mGetTECallbacks; - typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3f60b5f642..e80ad6976e 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2052,7 +2052,7 @@ void LLSelectMgr::selectionRemoveMaterial() { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face,LLMaterialID::null); + object->setTEMaterialParams(face, NULL); } return true; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f8bc6ef4d3..4e233d479a 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4393,15 +4393,18 @@ S32 LLViewerObject::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID << ", material " << pMaterialID << LL_ENDL; retval = LLPrimitive::setTEMaterialID(te, pMaterialID); - } - // Kitty would like to know if this is necessary? - // Since we should get a setTEMaterialParams that does it anyway? - // - setChanged(TEXTURE); - if (mDrawable.notNull()) + if (retval) { - gPipeline.markTextured(mDrawable); + // Kitty would like to know if this is necessary? + // Since we should get a setTEMaterialParams that does it anyway? + // + setChanged(TEXTURE); + if (mDrawable.notNull()) + { + gPipeline.markTextured(mDrawable); + } } + } return retval; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 1021615255..8e811527eb 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1991,15 +1991,17 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) << LL_ENDL; LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - // Use TE-specific version of boost CB hook-up to avoid cross-contaminatin' - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); + if (res) + { + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); setChanged(TEXTURE); if (!mDrawable.isNull()) { gPipeline.markTextured(mDrawable); } mFaceMappingChanged = TRUE; - return TEM_CHANGE_TEXTURE; + } + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) -- cgit v1.3 From 666896ac4efa0575c82cd58c9fe041f354ccbbfc Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 15 May 2013 17:00:13 -0700 Subject: NORSPEC-119 put back TE-specific get registration in material manager stomped during 'reloading'. --- indra/newview/llmaterialmgr.cpp | 61 +++++++++++++++++++++++++++++++++++++++++ indra/newview/llmaterialmgr.h | 22 +++++++++++++++ indra/newview/llvovolume.cpp | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index f217ff160e..59e5d05736 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,6 +217,51 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) +{ + boost::signals2::connection connection; + + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + LL_DEBUGS("Materials") << "region " << region_id << " found materialid " << material_id << LL_ENDL; + get_callback_te_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second, te); + connection = boost::signals2::connection(); + } + else + { + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + LL_DEBUGS("Materials") << "mGetQueue inserting region "< ret = mGetQueue.insert(std::pair(region_id, material_queue_t())); + itQueue = ret.first; + } + LL_DEBUGS("Materials") << "adding material id " << material_id << LL_ENDL; + itQueue->second.insert(material_id); + markGetPending(region_id, material_id); + } + + TEMaterialPair te_mat_pair; + te_mat_pair.te = te; + te_mat_pair.materialID = material_id; + + get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair); + if (itCallback == mGetTECallbacks.end()) + { + std::pair ret = mGetTECallbacks.insert(std::pair(te_mat_pair, new get_callback_te_t())); + itCallback = ret.first; + } + connection = itCallback->second->connect(cb); + } + + return connection; +} + bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); @@ -301,6 +346,22 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; + + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + return itMaterial->second; } diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index a6a7a5d1d7..b5ba8ab680 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,9 +44,11 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; + typedef boost::signals2::signal get_callback_te_t; const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -80,6 +82,26 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; + // struct for TE-specific material ID query + struct TEMaterialPair + { + U32 te; + LLMaterialID materialID; + }; + + // needed for std::map compliance only + // + friend inline bool operator<( + const struct LLMaterialMgr::TEMaterialPair& lhs, + const struct LLMaterialMgr::TEMaterialPair& rhs) + { + return (lhs.materialID < rhs.materialID) ? TRUE : + (lhs.te < rhs.te) ? TRUE : FALSE; + } + + typedef std::map get_callback_te_map_t; + get_callback_te_map_t mGetTECallbacks; + typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; getall_queue_t mGetAllRequested; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 694ad82914..a9b540507f 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1993,7 +1993,7 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; if (res) { - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, te)); + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); setChanged(TEXTURE); if (!mDrawable.isNull()) { -- cgit v1.3 From 74c1bc29e7dc566c7bb1a654b1dbf632d39dcb17 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Fri, 17 May 2013 14:02:31 -0700 Subject: NORSPEC-189 restore old mat param update registration --- indra/newview/llmaterialmgr.cpp | 5 +++++ indra/newview/llmaterialmgr.h | 9 +++++++-- indra/newview/llvovolume.cpp | 19 +++++++++++++++++-- indra/newview/llvovolume.h | 4 +++- 4 files changed, 32 insertions(+), 5 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 59e5d05736..edf8e83038 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,6 +217,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } +#if USE_TE_SPECIFIC_REGISTRATION boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) { boost::signals2::connection connection; @@ -261,6 +262,7 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const return connection; } +#endif bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { @@ -346,6 +348,7 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetCallbacks.erase(itCallback); } +#if USE_TE_SPECIFIC_REGISTRATION TEMaterialPair te_mat_pair; te_mat_pair.materialID = material_id; @@ -361,6 +364,7 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetTECallbacks.erase(itCallbackTE); } } +#endif return itMaterial->second; } @@ -779,3 +783,4 @@ void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) clearGetQueues(regionp->getRegionID()); // Put doesn't need clearing: objects that can't be found will clean up in processPutQueue() } + diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index b5ba8ab680..9b3d7a0246 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -44,11 +44,13 @@ public: typedef std::map material_map_t; typedef boost::signals2::signal get_callback_t; - typedef boost::signals2::signal get_callback_te_t; - const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + +#if USE_TE_SPECIFIC_REGISTRATION + typedef boost::signals2::signal get_callback_te_t; boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); +#endif typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -82,6 +84,7 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; +#if USE_TE_SPECIFIC_REGISTRATION // struct for TE-specific material ID query struct TEMaterialPair { @@ -101,6 +104,7 @@ protected: typedef std::map get_callback_te_map_t; get_callback_te_map_t mGetTECallbacks; +#endif typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; @@ -118,3 +122,4 @@ protected: }; #endif // LL_LLMATERIALMGR_H + diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c3c6747e99..d8f1896654 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,7 +1973,7 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) +void LLVOVolume::setTEMaterialParamsCallbackTE(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; if (te >= getNumTEs()) @@ -1986,6 +1986,18 @@ void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, co } } +void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) +{ + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; + for (U8 i = 0; i < getNumTEs(); i++) + { + if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) + { + setTEMaterialParams(i, pMaterialParams); + } + } +} + S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); @@ -1996,7 +2008,11 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; if (res) { +#if USE_TE_SPECIFIC_REGISTRATION LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2, _3)); +#else + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); +#endif setChanged(TEXTURE); if (!mDrawable.isNull()) { @@ -5553,4 +5569,3 @@ void LLHUDPartition::shift(const LLVector4a &offset) //HUD objects don't shift with region crossing. That would be silly. } - diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index a5f933c319..52539ab8d5 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,7 +187,8 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); + void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); + void setTEMaterialParamsCallbackTE(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); @@ -382,3 +383,4 @@ protected: }; #endif // LL_LLVOVOLUME_H + -- cgit v1.3 From 260afbcece7db436af411abcba28495bf99fa08b Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 23 May 2013 16:24:34 -0700 Subject: NORSPEC-192 fix more incorrect batching, fix bug in reflecting normal map state in build tool, and protect against callback crashes when switching regions --- indra/newview/llmaterialmgr.cpp | 53 +++++++++++++++++++++----------------- indra/newview/llpanelface.cpp | 2 +- indra/newview/llspatialpartition.h | 1 + indra/newview/llvovolume.cpp | 10 ++++--- 4 files changed, 39 insertions(+), 27 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index edf8e83038..5c0173c7a7 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -337,34 +337,41 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL itMaterial = ret.first; } - mGetPending.erase(pending_material_t(region_id, material_id)); - - get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); - if (itCallback != mGetCallbacks.end()) - { - (*itCallback->second)(material_id, itMaterial->second); - - delete itCallback->second; - mGetCallbacks.erase(itCallback); - } + // we may have cleared our queues on leaving a region before we recv'd our + // update for this material...too late now! + // + if (isGetPending(region_id, material_id)) + { + + #if USE_TE_SPECIFIC_REGISTRATION + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; -#if USE_TE_SPECIFIC_REGISTRATION - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) + { + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); + } + } + #endif - U32 i = 0; - while (i < LLTEContents::MAX_TES) - { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback != mGetCallbacks.end()) { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); + (*itCallback->second)(material_id, itMaterial->second); + + delete itCallback->second; + mGetCallbacks.erase(itCallback); } } -#endif + + mGetPending.erase(pending_material_t(region_id, material_id)); return itMaterial->second; } diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 33c77ed98f..27ca13fcf1 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1683,7 +1683,7 @@ void LLPanelFace::updateUI() texture_ctrl = getChild("bumpytexture control"); texture_ctrl->setImageAssetID(material->getNormalID()); - if (!material->getNormalID().isNull() && (bumpy == BUMPY_TEXTURE)) + if (!material->getNormalID().isNull()) { material->getNormalOffset(offset_x,offset_y); material->getNormalRepeat(repeat_x,repeat_y); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 8d3e8499da..8ccc3efd66 100755 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -121,6 +121,7 @@ public: F32 mDistance; U32 mDrawMode; LLMaterialPtr mMaterial; // If this is null, the following parameters are unused. + LLMaterialID mMaterialID; U32 mShaderMask; LLPointer mSpecularMap; const LLMatrix4* mSpecularMapMatrix; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 91a5a082c1..5663d474bd 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4109,6 +4109,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U8 index = facep->getTextureIndex(); LLMaterial* mat = facep->getTextureEntry()->getMaterialParams().get(); + LLMaterialID mat_id = facep->getTextureEntry()->getMaterialID(); bool batchable = false; @@ -4159,12 +4160,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && #endif + draw_vec[idx]->mMaterial == mat && + draw_vec[idx]->mMaterialID == mat_id && draw_vec[idx]->mFullbright == fullbright && - draw_vec[idx]->mBump == bump && + draw_vec[idx]->mBump == bump && + (!mat || (draw_vec[idx]->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different draw_vec[idx]->mTextureMatrix == tex_mat && draw_vec[idx]->mModelMatrix == model_mat && - draw_vec[idx]->mMaterial == mat && - (!mat || (draw_vec[idx]->mShiny == shiny)) && // need to break batches when a material is shared, but legacy shiny is different draw_vec[idx]->mShaderMask == shader_mask) { draw_vec[idx]->mCount += facep->getIndicesCount(); @@ -4213,6 +4215,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (mat) { + draw_info->mMaterialID = mat_id; + // We have a material. Update our draw info accordingly. if (!mat->getSpecularID().isNull()) -- cgit v1.3 From 66e53759679910e2c3720cda92ba6e917c66d12c Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 24 May 2013 15:07:23 -0700 Subject: NORSPEC-96 NORSPEC-189 another attempt at planar stretch across all 3 channels and make the materials CB use a UUID instead of this pointer for safety --- indra/newview/llmaterialmgr.cpp | 4 - indra/newview/llmaterialmgr.h | 6 -- indra/newview/llselectmgr.cpp | 163 ++++++++++++++++++---------------------- indra/newview/llselectmgr.h | 2 +- indra/newview/llvovolume.cpp | 33 +++----- indra/newview/llvovolume.h | 5 +- 6 files changed, 90 insertions(+), 123 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 5c0173c7a7..fdc1dfd749 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -217,7 +217,6 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL return connection; } -#if USE_TE_SPECIFIC_REGISTRATION boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, LLMaterialMgr::get_callback_te_t::slot_type cb) { boost::signals2::connection connection; @@ -262,7 +261,6 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const return connection; } -#endif bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const { @@ -343,7 +341,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL if (isGetPending(region_id, material_id)) { - #if USE_TE_SPECIFIC_REGISTRATION TEMaterialPair te_mat_pair; te_mat_pair.materialID = material_id; @@ -359,7 +356,6 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL mGetTECallbacks.erase(itCallbackTE); } } - #endif get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); if (itCallback != mGetCallbacks.end()) diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index 8a2a9be255..e317a791ad 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -31,8 +31,6 @@ #include "llmaterialid.h" #include "llsingleton.h" -#define USE_TE_SPECIFIC_REGISTRATION 1 - class LLViewerRegion; class LLMaterialMgr : public LLSingleton @@ -49,10 +47,8 @@ public: const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); -#if USE_TE_SPECIFIC_REGISTRATION typedef boost::signals2::signal get_callback_te_t; boost::signals2::connection getTE(const LLUUID& region_id, const LLMaterialID& material_id, U32 te, get_callback_te_t::slot_type cb); -#endif typedef boost::signals2::signal getall_callback_t; void getAll(const LLUUID& region_id); @@ -86,7 +82,6 @@ protected: typedef std::map get_callback_map_t; get_callback_map_t mGetCallbacks; -#if USE_TE_SPECIFIC_REGISTRATION // struct for TE-specific material ID query class TEMaterialPair { @@ -115,7 +110,6 @@ protected: typedef boost::unordered_map get_callback_te_map_t; get_callback_te_map_t mGetTECallbacks; -#endif typedef std::set getall_queue_t; getall_queue_t mGetAllQueue; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 1bb12e495d..372dfb0f0c 100755 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2501,57 +2501,41 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) continue; } - LLVector3 scale_ratio = selectNode->mTextureScaleRatios[te_num]; LLVector3 object_scale = object->getScale(); + LLVector3 diffuse_scale_ratio = selectNode->mTextureScaleRatios[LLRender::DIFFUSE_MAP][te_num]; + LLVector3 normal_scale_ratio = selectNode->mTextureScaleRatios[LLRender::NORMAL_MAP][te_num]; + LLVector3 specular_scale_ratio = selectNode->mTextureScaleRatios[LLRender::SPECULAR_MAP][te_num]; // Apply new scale to face if (planar) { - F32 scale_s = scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; - F32 scale_t = scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + F32 diffuse_scale_s = diffuse_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 diffuse_scale_t = diffuse_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; - switch (mTextureChannel) + F32 normal_scale_s = normal_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 normal_scale_t = normal_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + + F32 specular_scale_s = specular_scale_ratio.mV[s_axis]/object_scale.mV[s_axis]; + F32 specular_scale_t = specular_scale_ratio.mV[t_axis]/object_scale.mV[t_axis]; + + + object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t); + + LLTextureEntry* tep = object->getTE(te_num); + + if (tep && !tep->getMaterialParams().isNull()) { - case LLRender::DIFFUSE_MAP: - { - object->setTEScale(te_num, scale_s, scale_t); - } - break; - - case LLRender::NORMAL_MAP: - { - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) - { - LLMaterialPtr orig = tep->getMaterialParams(); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); - p->setNormalRepeat(scale_s * 0.5f, scale_t * 0.5f); - selectionSetMaterial( p ); - } - } - break; - - case LLRender::SPECULAR_MAP: - { - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) - { - LLMaterialPtr orig = tep->getMaterialParams(); - LLMaterialPtr p = new LLMaterial(orig->asLLSD()); - p->setSpecularRepeat(scale_s * 0.5f, scale_t * 0.5f); - selectionSetMaterial( p ); - } - } - break; - default: - break; + LLMaterialPtr orig = tep->getMaterialParams(); + LLMaterialPtr p = new LLMaterial(orig->asLLSD()); + p->setNormalRepeat(normal_scale_s, normal_scale_t); + p->setSpecularRepeat(specular_scale_s, specular_scale_t); + selectionSetMaterial( p ); } - } else { - object->setTEScale(te_num, scale_ratio.mV[s_axis]*object_scale.mV[s_axis], - scale_ratio.mV[t_axis]*object_scale.mV[t_axis]); + object->setTEScale(te_num, diffuse_scale_ratio.mV[s_axis]*object_scale.mV[s_axis], + diffuse_scale_ratio.mV[t_axis]*object_scale.mV[t_axis]); } send = send_to_sim; } @@ -5876,7 +5860,10 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures) void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { - mTextureScaleRatios.clear(); + mTextureScaleRatios[LLRender::DIFFUSE_MAP].clear(); + mTextureScaleRatios[LLRender::NORMAL_MAP].clear(); + mTextureScaleRatios[LLRender::SPECULAR_MAP].clear(); + if (mObject.notNull()) { @@ -5884,9 +5871,15 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) for (U8 i = 0; i < mObject->getNumTEs(); i++) { - F32 s = 1.0f; - F32 t = 1.0f; + F32 diffuse_s = 1.0f; + F32 diffuse_t = 1.0f; + F32 normal_s = 1.0f; + F32 normal_t = 1.0f; + + F32 specular_s = 1.0f; + F32 specular_t = 1.0f; + LLVector3 v; const LLTextureEntry* tep = mObject->getTE(i); @@ -5899,60 +5892,54 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) U32 t_axis = VY; LLPrimitive::getTESTAxes(i, &s_axis, &t_axis); - switch(index_to_query) + tep->getScale(&diffuse_s,&diffuse_t); + + if (mat) { - case LLRender::DIFFUSE_MAP: - { - tep->getScale(&s,&t); - } - break; - - case LLRender::NORMAL_MAP: - { - if (mat) - { - mat->getNormalRepeat(s, t); - } - else - { - tep->getScale(&s,&t); - } - - } - break; - - case LLRender::SPECULAR_MAP: - { - if (mat) - { - mat->getSpecularRepeat(s, t); - } - else - { - tep->getScale(&s,&t); - } - } - break; - - default: - // should never be. - // - llassert_always(false); - break; + mat->getNormalRepeat(normal_s, normal_t); + } + else + { + tep->getScale(&normal_s,&normal_t); } - if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + if (mat) { - v.mV[s_axis] = s*scale.mV[s_axis]; - v.mV[t_axis] = t*scale.mV[t_axis]; + mat->getSpecularRepeat(specular_s, specular_t); } else { - v.mV[s_axis] = s/scale.mV[s_axis]; - v.mV[t_axis] = t/scale.mV[t_axis]; + tep->getScale(&specular_s,&specular_t); } - mTextureScaleRatios.push_back(v); + if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + { + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); + + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); + + v.mV[s_axis] = diffuse_s*scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t*scale.mV[t_axis]; + mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + } + else + { + v.mV[s_axis] = diffuse_s/scale.mV[s_axis]; + v.mV[t_axis] = diffuse_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::DIFFUSE_MAP].push_back(v); + + v.mV[s_axis] = normal_s/scale.mV[s_axis]; + v.mV[t_axis] = normal_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::NORMAL_MAP].push_back(v); + + v.mV[s_axis] = specular_s/scale.mV[s_axis]; + v.mV[t_axis] = specular_t/scale.mV[t_axis]; + mTextureScaleRatios[LLRender::SPECULAR_MAP].push_back(v); + } } } } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f9b97cebdd..a750d8ce72 100755 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -183,7 +183,7 @@ public: U64 mCreationDate; std::vector mSavedColors; uuid_vec_t mSavedTextures; - std::vector mTextureScaleRatios; + std::vector mTextureScaleRatios[LLRender::NUM_TEXTURE_CHANNELS]; std::vector mSilhouetteVertices; // array of vertices to render silhouette of object std::vector mSilhouetteNormals; // array of normals to render silhouette of object BOOL mSilhouetteExists; // need to generate silhouette? diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 5663d474bd..7ce0343022 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1973,27 +1973,19 @@ S32 LLVOVolume::setTEGlow(const U8 te, const F32 glow) return res; } -void LLVOVolume::setTEMaterialParamsCallbackTE(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) +void LLVOVolume::setTEMaterialParamsCallbackTE(const LLUUID& objectID, const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams, U32 te) { - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; - if (te >= getNumTEs()) - return; - - LLTextureEntry* texture_entry = getTE(te); - if (texture_entry && (texture_entry->getMaterialID() == pMaterialID)) + LLVOVolume* pVol = (LLVOVolume*)gObjectList.findObject(objectID); + if (pVol && pVol->getVolume()) { - setTEMaterialParams(te, pMaterialParams); - } -} + LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << " to TE " << te << LL_ENDL; + if (te >= pVol->getNumTEs()) + return; -void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, const LLMaterialPtr pMaterialParams) -{ - LL_DEBUGS("MaterialTEs") << "materialid " << pMaterialID.asString() << LL_ENDL; - for (U8 i = 0; i < getNumTEs(); i++) - { - if (getTE(i) && (getTE(i)->getMaterialID().isNull() || (getTE(i)->getMaterialID() == pMaterialID))) + LLTextureEntry* texture_entry = pVol->getTE(te); + if (texture_entry && (texture_entry->getMaterialID() == pMaterialID)) { - setTEMaterialParams(i, pMaterialParams); + pVol->setTEMaterialParams(te, pMaterialParams); } } } @@ -2008,11 +2000,8 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; if (res) { -#if USE_TE_SPECIFIC_REGISTRATION - LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallbackTE, this, _1, _2, _3)); -#else - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); -#endif + LLMaterialMgr::instance().getTE(getRegion()->getRegionID(), pMaterialID, te, boost::bind(&LLVOVolume::setTEMaterialParamsCallbackTE, getID(), _1, _2, _3)); + setChanged(TEXTURE); if (!mDrawable.isNull()) { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 52539ab8d5..56c552ab9f 100755 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -187,8 +187,9 @@ public: /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - void setTEMaterialParamsCallback(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams); - void setTEMaterialParamsCallbackTE(const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); + + static void setTEMaterialParamsCallbackTE(const LLUUID& objectID, const LLMaterialID& pMaterialID, const LLMaterialPtr pMaterialParams, U32 te); + /*virtual*/ S32 setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams); /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t); /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s); -- cgit v1.3 From f04e9363b9daca52c1fd2e675c2646f7e1d05054 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 14 Jun 2013 09:41:33 -0700 Subject: NORSPEC-266 fix issues with observer feedback on edits of material map parameters --- indra/newview/llmaterialmgr.cpp | 43 ++++++++++++++------------------ indra/newview/llpanelface.cpp | 53 ++++++++++++++++++++++++---------------- indra/newview/llpanelface.h | 2 +- indra/newview/llviewerobject.cpp | 12 ++------- indra/newview/llvovolume.cpp | 19 ++++++++------ indra/newview/pipeline.cpp | 11 ++++++--- 6 files changed, 71 insertions(+), 69 deletions(-) (limited to 'indra/newview/llmaterialmgr.cpp') diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index fdc1dfd749..16871adc4d 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -335,36 +335,29 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL itMaterial = ret.first; } - // we may have cleared our queues on leaving a region before we recv'd our - // update for this material...too late now! - // - if (isGetPending(region_id, material_id)) - { - - TEMaterialPair te_mat_pair; - te_mat_pair.materialID = material_id; + TEMaterialPair te_mat_pair; + te_mat_pair.materialID = material_id; - U32 i = 0; - while (i < LLTEContents::MAX_TES) + U32 i = 0; + while (i < LLTEContents::MAX_TES) + { + te_mat_pair.te = i++; + get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); + if (itCallbackTE != mGetTECallbacks.end()) { - te_mat_pair.te = i++; - get_callback_te_map_t::iterator itCallbackTE = mGetTECallbacks.find(te_mat_pair); - if (itCallbackTE != mGetTECallbacks.end()) - { - (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); - delete itCallbackTE->second; - mGetTECallbacks.erase(itCallbackTE); - } + (*itCallbackTE->second)(material_id, itMaterial->second, te_mat_pair.te); + delete itCallbackTE->second; + mGetTECallbacks.erase(itCallbackTE); } + } - get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); - if (itCallback != mGetCallbacks.end()) - { - (*itCallback->second)(material_id, itMaterial->second); + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback != mGetCallbacks.end()) + { + (*itCallback->second)(material_id, itMaterial->second); - delete itCallback->second; - mGetCallbacks.erase(itCallback); - } + delete itCallback->second; + mGetCallbacks.erase(itCallback); } mGetPending.erase(pending_material_t(region_id, material_id)); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f4226c0a7f..911af9df04 100755 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -327,16 +327,25 @@ void LLPanelFace::sendBump(U32 bumpiness) { LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; bumpytexture_ctrl->clear(); - bumpytexture_ctrl->setImageAssetID(LLUUID()); + bumpytexture_ctrl->setImageAssetID(LLUUID()); } - U8 bump = (U8) bumpiness & TEM_BUMP_MASK; - LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); - updateBumpyControls(bumpiness == BUMPY_TEXTURE, true); LLUUID current_normal_map = bumpytexture_ctrl->getImageAssetID(); + + U8 bump = (U8) bumpiness & TEM_BUMP_MASK; + + // Clear legacy bump to None when using an actual normal map + // + if (!current_normal_map.isNull()) + bump = 0; + + // Set the normal map or reset it to null as appropriate + // LLSelectedTEMaterial::setNormalID(this, current_normal_map); + + LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); } void LLPanelFace::sendTexGen() @@ -354,13 +363,21 @@ void LLPanelFace::sendShiny(U32 shininess) if (shininess < SHINY_TEXTURE) { texture_ctrl->clear(); - texture_ctrl->setImageAssetID(LLUUID()); - - U8 shiny = (U8) shininess & TEM_SHINY_MASK; - LLSelectMgr::getInstance()->selectionSetShiny( shiny ); + texture_ctrl->setImageAssetID(LLUUID()); } - updateShinyControls(!texture_ctrl->getImageAssetID().isNull(), true); - LLSelectedTEMaterial::setSpecularID(this, texture_ctrl->getImageAssetID()); + + LLUUID specmap = getCurrentSpecularMap(); + + U8 shiny = (U8) shininess & TEM_SHINY_MASK; + if (!specmap.isNull()) + shiny = 0; + + LLSelectedTEMaterial::setSpecularID(this, specmap); + + LLSelectMgr::getInstance()->selectionSetShiny( shiny ); + + updateShinyControls(!specmap.isNull(), true); + } void LLPanelFace::sendFullbright() @@ -752,21 +769,18 @@ void LLPanelFace::updateUI() LLUUID norm_map_id = getCurrentNormalMap(); LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness"); + + bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE; + if (combobox_bumpiness) { - if ((bumpy == BUMPY_TEXTURE) && !norm_map_id.isNull()) - { - combobox_bumpiness->selectNthItem((S32)BUMPY_TEXTURE); - } - else - { - combobox_bumpiness->selectNthItem((S32)((bumpy < BUMPY_TEXTURE) ? bumpy : 0)); - } + combobox_bumpiness->selectNthItem((S32)bumpy); } else { llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl; } + getChildView("combobox bumpiness")->setEnabled(editable); getChild("combobox bumpiness")->setTentative(!identical_bumpy); getChildView("label bumpiness")->setEnabled(editable); @@ -876,8 +890,6 @@ void LLPanelFace::updateUI() if (shinytexture_ctrl) { - // Can't use this test as we can't actually store SHINY_TEXTURE in the TEs *sigh* - // if (identical_spec && (shiny == SHINY_TEXTURE)) { shinytexture_ctrl->setTentative( FALSE ); @@ -2314,7 +2326,6 @@ void LLPanelFace::LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(U8& diffuse_a if (tep) { LLMaterial* mat = tep->getMaterialParams().get(); - mat = (tep->getMaterialID().isNull() ? NULL : mat); if (mat) { diffuse_mode = mat->getDiffuseAlphaMode(); diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 222f8f3688..42c1f6bd48 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -261,7 +261,7 @@ private: { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); - object->setTEMaterialID(face, LLMaterialID::null); + new_material = NULL; } else { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6c20f638e5..6f7b2f40e6 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4168,12 +4168,8 @@ void LLViewerObject::changeTENormalMap(S32 index, LLViewerTexture* new_image) { return ; } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } mTENormalMaps[index] = new_image ; + refreshMaterials(); } void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) @@ -4182,12 +4178,8 @@ void LLViewerObject::changeTESpecularMap(S32 index, LLViewerTexture* new_image) { return ; } - setChanged(TEXTURE); - if (mDrawable.notNull()) - { - gPipeline.markTextured(mDrawable); - } mTESpecularMaps[index] = new_image ; + refreshMaterials(); } S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 83ffd3e695..007c2b9003 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4115,8 +4115,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLMaterial* mat = facep->getTextureEntry()->getMaterialParams().get(); LLMaterialID mat_id = facep->getTextureEntry()->getMaterialID(); - mat = mat_id.isNull() ? NULL : mat; - bool batchable = false; U32 shader_mask = 0xFFFFFFFF; //no shader @@ -4547,7 +4545,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } LLMaterial* mat = te->getMaterialParams().get(); - mat = te->getMaterialID().isNull() ? NULL : mat; if (mat && LLPipeline::sRenderDeferred) { @@ -5343,7 +5340,6 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; LLMaterial* mat = te->getMaterialParams().get(); - mat = te->getMaterialID().isNull() ? NULL : mat; bool can_be_shiny = true; if (mat) @@ -5353,6 +5349,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: mode == LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE; } + bool use_legacy_bump = te->getBumpmap() && (!mat || mat->getNormalID().isNull()); + if (mat && LLPipeline::sRenderDeferred && !hud_group) { bool material_pass = false; @@ -5395,6 +5393,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { registerFace(group, facep, LLRenderPass::PASS_ALPHA); } + else if (use_legacy_bump) + { + // we have a material AND legacy bump settings, but no normal map + registerFace(group, facep, LLRenderPass::PASS_BUMP); + } else { material_pass = true; @@ -5502,7 +5505,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } } - else if (te->getBumpmap() && !mat) + else if (use_legacy_bump) { //register in deferred bump pass registerFace(group, facep, LLRenderPass::PASS_BUMP); } @@ -5537,14 +5540,14 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } - if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && te->getBumpmap()) + if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && use_legacy_bump) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } } else { - if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && (te->getBumpmap() && !mat)) + if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && use_legacy_bump) { //non-shiny or fullbright deferred bump registerFace(group, facep, LLRenderPass::PASS_BUMP); } @@ -5578,7 +5581,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); - if (!force_simple && te->getBumpmap() && !mat && LLPipeline::sRenderBump) + if (!force_simple && LLPipeline::sRenderBump && use_legacy_bump) { registerFace(group, facep, LLRenderPass::PASS_BUMP); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3255f5821f..8942092221 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1696,6 +1696,8 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima return 0; } + LLMaterial* mat = te->getMaterialParams().get(); + bool color_alpha = te->getColor().mV[3] < 0.999f; bool alpha = color_alpha; if (imagep) @@ -1703,9 +1705,9 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima alpha = alpha || (imagep->getComponents() == 4 && imagep->getType() != LLViewerTexture::MEDIA_TEXTURE) || (imagep->getComponents() == 2); } - if (alpha && te->getMaterialParams()) + if (alpha && mat) { - switch (te->getMaterialParams()->getDiffuseAlphaMode()) + switch (mat->getDiffuseAlphaMode()) { case 1: alpha = true; // Material's alpha mode is set to blend. Toss it into the alpha draw pool. @@ -1724,10 +1726,11 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima { return LLDrawPool::POOL_ALPHA; } - else if ((te->getBumpmap() || te->getShiny()) && !te->getMaterialParams().isNull()) + else if ((te->getBumpmap() || te->getShiny()) && (!mat || mat->getNormalID().isNull())) { return LLDrawPool::POOL_BUMP; - } else if (!te->getMaterialParams().isNull() && !alpha) + } + else if (mat && !alpha) { return LLDrawPool::POOL_MATERIALS; } -- cgit v1.3