diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloaterdebugmaterials.cpp | 342 | ||||
-rw-r--r-- | indra/newview/llfloaterdebugmaterials.h | 11 | ||||
-rw-r--r-- | indra/newview/llmaterialmgr.cpp | 145 | ||||
-rw-r--r-- | indra/newview/llmaterialmgr.h | 17 | ||||
-rw-r--r-- | indra/newview/llworld.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llworld.h | 1 |
6 files changed, 293 insertions, 236 deletions
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<LLFloaterDebugMaterials>("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<LLFloaterDebugMaterials>("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<S32>(getDataBinary.size()); - std::string getDataString(reinterpret_cast<const char*>(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<const LLStringExplicit>(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<LLUUID, getall_callback_t*>(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<const char*>(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<LLMaterialID, LLMaterialPtr> material_map_t; + typedef boost::signals2::signal<void (const LLMaterialID&, const LLMaterialPtr)> 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<void (const LLUUID&, const material_map_t&)> 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<LLMaterialID, get_callback_t*> get_callback_map_t; get_callback_map_t mGetCallbacks; + typedef std::set<LLUUID> getall_queue_t; + getall_queue_t mGetAllQueue; + typedef std::map<LLUUID, F64> getall_pending_map_t; + getall_pending_map_t mGetAllPending; + typedef std::map<LLUUID, getall_callback_t*> getall_callback_map_t; + getall_callback_map_t mGetAllCallbacks; + typedef std::map<U8, LLMaterial> facematerial_map_t; typedef std::map<LLUUID, facematerial_map_t> put_queue_t; put_queue_t mPutQueue; - typedef std::map<LLMaterialID, LLMaterialPtr> 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); |