From 4046a9082d793e71cac26a31d44c127decd6821f Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Fri, 11 Feb 2011 17:37:07 -0500 Subject: re-applying render cost changes for experimentations --- indra/newview/llselectmgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 93c9131424..90c2cf1eb4 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6391,7 +6391,7 @@ U32 LLObjectSelection::getSelectedObjectTriangleCount() return count; } -/*S32 LLObjectSelection::getSelectedObjectRenderCost() +S32 LLObjectSelection::getSelectedObjectRenderCost() { S32 cost = 0; LLVOVolume::texture_cost_t textures; @@ -6415,7 +6415,7 @@ U32 LLObjectSelection::getSelectedObjectTriangleCount() return cost; -}*/ +} //----------------------------------------------------------------------------- -- cgit v1.3 From 543df6736fb0ae312b9a5e056a35bf8fffd2b6c9 Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Wed, 17 Aug 2011 01:42:21 +0300 Subject: SH-2171 FIXED New prim weights added to weights detail floater. - Fixed detecting cross-parcel objects selection. - Various fixes in LLAccountingCostManager. - getSelectedObjectRenderCost() moved from LLFloaterTools to LLObjectSelection where it used to reside. Previous commented out implementation of this method removed. --- indra/newview/llaccountingcostmanager.cpp | 66 ++++++++++--------- indra/newview/llaccountingcostmanager.h | 20 +++++- indra/newview/llfloaterobjectweights.cpp | 102 +++++++++++++++++++++++++++--- indra/newview/llfloaterobjectweights.h | 7 +- indra/newview/llfloatertools.cpp | 36 ++--------- indra/newview/llfloatertools.h | 1 - indra/newview/llselectmgr.cpp | 34 +++++----- 7 files changed, 175 insertions(+), 91 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') 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& observer_handle ) + : mObjectIDs( objectIDs ), + mObserverHandle( observer_handle ) { } @@ -55,6 +55,12 @@ public: { llwarns << "Transport error "<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 mObserverHandle; }; //=============================================================================== -void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const std::string& url ) +void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, + const std::string& url, + const LLHandle& 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& getObserverHandle() const { return mObserverHandle; } + +protected: + LLRootHandle mObserverHandle; +}; +//=============================================================================== class LLAccountingCostManager : public LLSingleton { 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& 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 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("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 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 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() -- cgit v1.3 From cfe0a3cbe445900574b82e8c843bddc347f1b269 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Thu, 18 Aug 2011 19:16:08 -0400 Subject: BUILDFIX SH-1246 fixed a bug in the ARC computations, and texture cost computations in build tools Minor bug in ARC display computations, where wrong numbers were being used for child prims Feature enhancement to not double-count textures reused within a linkset. --- indra/newview/llselectmgr.cpp | 62 ++++++++++++++++++++++++++++++++++++------- indra/newview/llvoavatar.cpp | 3 ++- 2 files changed, 55 insertions(+), 10 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 9c85817a28..1880bb87d3 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -6526,24 +6526,68 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() { S32 cost = 0; LLVOVolume::texture_cost_t textures; + typedef std::set uuid_list_t; + uuid_list_t computed_objects; + + typedef std::list > child_list_t; + typedef const child_list_t const_child_list_t; + + // add render cost of complete linksets first, to get accurate texture counts 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); - } - - for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + if (object && object->isRootEdit()) { - // add the cost of each individual texture in the linkset - cost += iter->second; + cost += object->getRenderCost(textures); + computed_objects.insert(object->getID()); + + const_child_list_t children = object->getChildren(); + for (const_child_list_t::const_iterator child_iter = children.begin(); + child_iter != children.end(); + ++child_iter) + { + LLViewerObject* child_obj = *child_iter; + LLVOVolume *child = dynamic_cast( child_obj ); + if (child) + { + cost += child->getRenderCost(textures); + computed_objects.insert(child->getID()); + } + } + + for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + { + // add the cost of each individual texture in the linkset + cost += iter->second; + } + + textures.clear(); } - textures.clear(); } + + // add any partial linkset objects, texture cost may be slightly misleading + for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter) + { + LLSelectNode* node = *iter; + LLVOVolume* object = (LLVOVolume*)node->getObject(); + if (object && computed_objects.find(object->getID()) == computed_objects.end() ) + { + cost += object->getRenderCost(textures); + computed_objects.insert(object->getID()); + } + + for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) + { + // add the cost of each individual texture in the linkset + cost += iter->second; + } + + textures.clear(); + } return cost; } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index c77c4f167b..2efc9060dd 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8354,6 +8354,7 @@ void LLVOAvatar::idleUpdateRenderCost() } } + for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter) @@ -8384,7 +8385,7 @@ void LLVOAvatar::idleUpdateRenderCost() LLVOVolume *child = dynamic_cast( child_obj ); if (child) { - cost += volume->getRenderCost(textures); + cost += child->getRenderCost(textures); } } -- cgit v1.3