diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llaccountingcostmanager.cpp | 66 | ||||
-rw-r--r-- | indra/newview/llaccountingcostmanager.h | 20 | ||||
-rw-r--r-- | indra/newview/llfloaterobjectweights.cpp | 102 | ||||
-rw-r--r-- | indra/newview/llfloaterobjectweights.h | 7 | ||||
-rw-r--r-- | indra/newview/llfloatertools.cpp | 36 | ||||
-rw-r--r-- | indra/newview/llfloatertools.h | 1 | ||||
-rw-r--r-- | indra/newview/llselectmgr.cpp | 34 |
7 files changed, 175 insertions, 91 deletions
diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index 5059efbeec..0669bdfffa 100644 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -29,7 +29,6 @@ #include "llagent.h" #include "llcurl.h" #include "llhttpclient.h" - //=============================================================================== LLAccountingCostManager::LLAccountingCostManager() { @@ -38,8 +37,9 @@ LLAccountingCostManager::LLAccountingCostManager() class LLAccountingCostResponder : public LLCurl::Responder { public: - LLAccountingCostResponder( const LLSD& objectIDs ) - : mObjectIDs( objectIDs ) + LLAccountingCostResponder( const LLSD& objectIDs, const LLHandle<LLAccountingCostObserver>& observer_handle ) + : mObjectIDs( objectIDs ), + mObserverHandle( observer_handle ) { } @@ -55,6 +55,12 @@ public: { llwarns << "Transport error "<<reason<<llendl; clearPendingRequests(); + + LLAccountingCostObserver* observer = mObserverHandle.get(); + if (observer) + { + observer->setErrorStatus(statusNum, reason); + } } void result( const LLSD& content ) @@ -63,43 +69,43 @@ public: if ( !content.isMap() || content.has("error") ) { llwarns << "Error on fetched data"<< llendl; - clearPendingRequests(); - return; } - - bool containsSelection = content.has("selected"); - if ( containsSelection ) + else if (content.has("selected")) { - S32 dataCount = content["selected"].size(); - - for(S32 i = 0; i < dataCount; i++) - { + F32 physicsCost = 0.0f; + F32 networkCost = 0.0f; + F32 simulationCost = 0.0f; + + //LLTransactionID transactionID; - F32 physicsCost = 0.0f; - F32 networkCost = 0.0f; - F32 simulationCost = 0.0f; - - //LLTransactionID transactionID; - - //transactionID = content["selected"][i]["local_id"].asUUID(); - physicsCost = content["selected"][i]["physics"].asReal(); - networkCost = content["selected"][i]["streaming"].asReal(); - simulationCost = content["selected"][i]["simulation"].asReal(); - - SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); - - //How do you want to handle the updating of the invoking object/ui element? + //transactionID = content["selected"][i]["local_id"].asUUID(); + physicsCost = content["selected"]["physics"].asReal(); + networkCost = content["selected"]["streaming"].asReal(); + simulationCost = content["selected"]["simulation"].asReal(); + SelectionCost selectionCost( /*transactionID,*/ physicsCost, networkCost, simulationCost ); + + LLAccountingCostObserver* observer = mObserverHandle.get(); + if (observer) + { + observer->onWeightsUpdate(selectionCost); } } + + clearPendingRequests(); } private: //List of posted objects LLSD mObjectIDs; + + // Cost update observer handle + LLHandle<LLAccountingCostObserver> mObserverHandle; }; //=============================================================================== -void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const std::string& url ) +void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, + const std::string& url, + const LLHandle<LLAccountingCostObserver>& observer_handle ) { // Invoking system must have already determined capability availability if ( !url.empty() ) @@ -115,7 +121,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st // Check to see if a request for this object has already been made. if ( mPendingObjectQuota.find( *IDIter ) == mPendingObjectQuota.end() ) { - mObjectList.insert( *IDIter ); + mPendingObjectQuota.insert( *IDIter ); objectList[objectIndex++] = *IDIter; } } @@ -133,7 +139,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st else if ( selectionType == Prims ) { - keystr="prim_roots"; + keystr="selected_prims"; } else { @@ -146,7 +152,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st LLSD dataToPost = LLSD::emptyMap(); dataToPost[keystr.c_str()] = objectList; - LLHTTPClient::post( url, dataToPost, new LLAccountingCostResponder( objectList )); + LLHTTPClient::post( url, dataToPost, new LLAccountingCostResponder( objectList, observer_handle )); } } else diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h index 8ae696a98d..cccdc2e2d9 100644 --- a/indra/newview/llaccountingcostmanager.h +++ b/indra/newview/llaccountingcostmanager.h @@ -27,8 +27,24 @@ #ifndef LL_ACCOUNTINGQUOTAMANAGER_H #define LL_ACCOUNTINGQUOTAMANAGER_H //=============================================================================== +#include "llhandle.h" + #include "llaccountingcost.h" //=============================================================================== +// An interface class for panels which display the parcel accounting information. +class LLAccountingCostObserver +{ +public: + LLAccountingCostObserver() { mObserverHandle.bind(this); } + virtual ~LLAccountingCostObserver() {} + virtual void onWeightsUpdate(const SelectionCost& selection_cost) = 0; + virtual void setErrorStatus(U32 status, const std::string& reason) = 0; + const LLHandle<LLAccountingCostObserver>& getObserverHandle() const { return mObserverHandle; } + +protected: + LLRootHandle<LLAccountingCostObserver> mObserverHandle; +}; +//=============================================================================== class LLAccountingCostManager : public LLSingleton<LLAccountingCostManager> { public: @@ -37,7 +53,8 @@ public: //Store an object that will be eventually fetched void addObject( const LLUUID& objectID ); //Request quotas for object list - void fetchCosts( eSelectionType selectionType, const std::string& url ); + void fetchCosts( eSelectionType selectionType, const std::string& url, + const LLHandle<LLAccountingCostObserver>& observer_handle ); //Delete a specific object from the pending list void removePendingObject( const LLUUID& objectID ); @@ -52,4 +69,3 @@ private: //=============================================================================== #endif // LLACCOUNTINGCOSTMANAGER - diff --git a/indra/newview/llfloaterobjectweights.cpp b/indra/newview/llfloaterobjectweights.cpp index d39a93991f..7ad34431fb 100644 --- a/indra/newview/llfloaterobjectweights.cpp +++ b/indra/newview/llfloaterobjectweights.cpp @@ -32,16 +32,48 @@ #include "llfloaterreg.h" #include "lltextbox.h" +#include "llagent.h" #include "llselectmgr.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" +/** + * struct LLCrossParcelFunctor + * + * A functor that checks whether a bounding box for all + * selected objects crosses a region or parcel bounds. + */ struct LLCrossParcelFunctor : public LLSelectedObjectFunctor { /*virtual*/ bool apply(LLViewerObject* obj) { - return obj->crossesParcelBounds(); + // Add the root object box. + mBoundingBox.addBBoxAgent(LLBBox(obj->getPositionRegion(), obj->getRotationRegion(), obj->getScale() * -0.5f, obj->getScale() * 0.5f).getAxisAligned()); + + // Extend the bounding box across all the children. + LLViewerObject::const_child_list_t children = obj->getChildren(); + for (LLViewerObject::const_child_list_t::const_iterator iter = children.begin(); + iter != children.end(); iter++) + { + LLViewerObject* child = *iter; + mBoundingBox.addBBoxAgent(LLBBox(child->getPositionRegion(), child->getRotationRegion(), child->getScale() * -0.5f, child->getScale() * 0.5f).getAxisAligned()); + } + + bool result = false; + + LLViewerRegion* region = obj->getRegion(); + if (region) + { + std::vector<LLBBox> boxes; + boxes.push_back(mBoundingBox); + result = region->objectsCrossParcel(boxes); + } + + return result; } + +private: + LLBBox mBoundingBox; }; /** @@ -132,6 +164,32 @@ void LLFloaterObjectWeights::onClose(bool app_quitting) mParcelSelection = NULL; } +// virtual +void LLFloaterObjectWeights::onWeightsUpdate(const SelectionCost& selection_cost) +{ + mSelectedDownloadWeight->setText(llformat("%.1f", selection_cost.mNetworkCost)); + mSelectedPhysicsWeight->setText(llformat("%.1f", selection_cost.mPhysicsCost)); + mSelectedServerWeight->setText(llformat("%.1f", selection_cost.mSimulationCost)); + + S32 render_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectRenderCost(); + mSelectedDisplayWeight->setText(llformat("%d", render_cost)); + + toggleWeightsLoadingIndicators(false); +} + +//virtual +void LLFloaterObjectWeights::setErrorStatus(U32 status, const std::string& reason) +{ + const std::string text = getString("nothing_selected"); + + mSelectedDownloadWeight->setText(text); + mSelectedPhysicsWeight->setText(text); + mSelectedServerWeight->setText(text); + mSelectedDisplayWeight->setText(text); + + toggleWeightsLoadingIndicators(false); +} + void LLFloaterObjectWeights::updateLandImpacts() { LLParcel *parcel = mParcelSelection->getParcel(); @@ -141,11 +199,9 @@ void LLFloaterObjectWeights::updateLandImpacts() } else { - S32 selected_prims = parcel->getSelectedPrimCount(); S32 rezzed_prims = parcel->getSimWidePrimCount(); S32 total_capacity = parcel->getSimWideMaxPrimCapacity(); - mSelectedOnLand->setText(llformat("%d", selected_prims)); mRezzedOnLand->setText(llformat("%d", rezzed_prims)); mRemainingCapacity->setText(llformat("%d", total_capacity - rezzed_prims)); mTotalCapacity->setText(llformat("%d", total_capacity)); @@ -156,26 +212,29 @@ void LLFloaterObjectWeights::updateLandImpacts() void LLFloaterObjectWeights::refresh() { - if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) + LLSelectMgr* sel_mgr = LLSelectMgr::getInstance(); + + if (sel_mgr->getSelection()->isEmpty()) { updateIfNothingSelected(); } else { - S32 prim_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); - S32 link_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount(); + S32 prim_count = sel_mgr->getSelection()->getObjectCount(); + S32 link_count = sel_mgr->getSelection()->getRootObjectCount(); + F32 prim_equiv = sel_mgr->getSelection()->getSelectedLinksetCost(); mSelectedObjects->setText(llformat("%d", link_count)); mSelectedPrims->setText(llformat("%d", prim_count)); + mSelectedOnLand->setText(llformat("%.1d", (S32)prim_equiv)); LLCrossParcelFunctor func; - if (LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, true)) + if (sel_mgr->getSelection()->applyToRootObjects(&func, true)) { // Some of the selected objects cross parcel bounds. - // We don't display land impacts in this case. + // We don't display object weights and land impacts in this case. const std::string text = getString("nothing_selected"); - mSelectedOnLand->setText(text); mRezzedOnLand->setText(text); mRemainingCapacity->setText(text); mTotalCapacity->setText(text); @@ -192,6 +251,31 @@ void LLFloaterObjectWeights::refresh() toggleLandImpactsLoadingIndicators(true); } + else + { + llwarns << "Failed to get selected object" << llendl; + } + } + + LLViewerRegion* region = gAgent.getRegion(); + if (region && region->capabilitiesReceived()) + { + for (LLObjectSelection::valid_root_iterator iter = sel_mgr->getSelection()->valid_root_begin(); + iter != sel_mgr->getSelection()->valid_root_end(); ++iter) + { + LLAccountingCostManager::getInstance()->addObject((*iter)->getObject()->getID()); + } + + std::string url = region->getCapability("ResourceCostSelected"); + if (!url.empty()) + { + LLAccountingCostManager::getInstance()->fetchCosts(Roots, url, getObserverHandle()); + toggleWeightsLoadingIndicators(true); + } + } + else + { + llwarns << "Failed to get region capabilities" << llendl; } } } diff --git a/indra/newview/llfloaterobjectweights.h b/indra/newview/llfloaterobjectweights.h index 82743a8aa7..50d028909e 100644 --- a/indra/newview/llfloaterobjectweights.h +++ b/indra/newview/llfloaterobjectweights.h @@ -29,12 +29,14 @@ #include "llfloater.h" +#include "llaccountingcostmanager.h" + class LLLandImpactsObserver; class LLObjectSelection; class LLParcelSelection; class LLTextBox; -class LLFloaterObjectWeights : public LLFloater +class LLFloaterObjectWeights : public LLFloater, LLAccountingCostObserver { public: LOG_CLASS(LLFloaterObjectWeights); @@ -50,6 +52,9 @@ public: /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ void onClose(bool app_quitting); + /*virtual*/ void onWeightsUpdate(const SelectionCost& selection_cost); + /*virtual*/ void setErrorStatus(U32 status, const std::string& reason); + void updateLandImpacts(); private: diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 00a0da3cde..157b66b0ac 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -435,7 +435,8 @@ void LLFloaterTools::refresh() if (sShowObjectCost) { std::string prim_cost_string; - LLResMgr::getInstance()->getIntegerString(prim_cost_string, calcRenderCost()); + S32 render_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectRenderCost(); + LLResMgr::getInstance()->getIntegerString(prim_cost_string, render_cost); getChild<LLUICtrl>("RenderingCost")->setTextArg("[COUNT]", prim_cost_string); } @@ -479,8 +480,10 @@ void LLFloaterTools::refresh() { selection_info << ","; + S32 render_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectRenderCost(); + childSetTextArg("selection_weight", "[PHYS_WEIGHT]", llformat("%.1f", link_phys_cost)); - childSetTextArg("selection_weight", "[DISP_WEIGHT]", llformat("%.1d", calcRenderCost())); + childSetTextArg("selection_weight", "[DISP_WEIGHT]", llformat("%.1d", render_cost)); } else { @@ -1014,35 +1017,6 @@ void LLFloaterTools::onClickGridOptions() //floaterp->addDependentFloater(LLFloaterBuildOptions::getInstance(), FALSE); } -S32 LLFloaterTools::calcRenderCost() -{ - S32 cost = 0; - std::set<LLUUID> textures; - - for (LLObjectSelection::iterator selection_iter = LLSelectMgr::getInstance()->getSelection()->begin(); - selection_iter != LLSelectMgr::getInstance()->getSelection()->end(); - ++selection_iter) - { - LLSelectNode *select_node = *selection_iter; - if (select_node) - { - LLViewerObject *vobj = select_node->getObject(); - if (vobj->getVolume()) - { - LLVOVolume* volume = (LLVOVolume*) vobj; - - cost += volume->getRenderCost(textures); - cost += textures.size() * LLVOVolume::ARC_TEXTURE_COST; - textures.clear(); - } - } - } - - - return cost; -} - - // static void LLFloaterTools::setEditTool(void* tool_pointer) { diff --git a/indra/newview/llfloatertools.h b/indra/newview/llfloatertools.h index 69636190fc..8c4cb721d3 100644 --- a/indra/newview/llfloatertools.h +++ b/indra/newview/llfloatertools.h @@ -113,7 +113,6 @@ private: static bool multipleFacesSelectedConfirm(const LLSD& notification, const LLSD& response); static void setObjectType( LLPCode pcode ); void onClickGridOptions(); - S32 calcRenderCost(); public: LLButton *mBtnFocus; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 8fa4065fa6..7ff58f5d34 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6522,32 +6522,32 @@ U32 LLObjectSelection::getSelectedObjectTriangleCount() return count; } -/*S32 LLObjectSelection::getSelectedObjectRenderCost() +S32 LLObjectSelection::getSelectedObjectRenderCost() { S32 cost = 0; - LLVOVolume::texture_cost_t textures; - for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter) - { - LLSelectNode* node = *iter; - LLVOVolume* object = (LLVOVolume*)node->getObject(); - - if (object) - { - cost += object->getRenderCost(textures); - } + std::set<LLUUID> textures; - for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + for (list_t::iterator selection_iter = mList.begin(); selection_iter != mList.end(); + ++selection_iter) + { + LLSelectNode *select_node = *selection_iter; + if (select_node) { - // add the cost of each individual texture in the linkset - cost += iter->second; + LLViewerObject *vobj = select_node->getObject(); + if (vobj->getVolume()) + { + LLVOVolume* volume = (LLVOVolume*) vobj; + + cost += volume->getRenderCost(textures); + cost += textures.size() * LLVOVolume::ARC_TEXTURE_COST; + textures.clear(); + } } - textures.clear(); } return cost; -}*/ - +} //----------------------------------------------------------------------------- // getTECount() |