diff options
author | jwolk <none@none> | 2010-08-13 17:30:09 -0700 |
---|---|---|
committer | jwolk <none@none> | 2010-08-13 17:30:09 -0700 |
commit | 671609239f63bc6dc293a0580e6f1b8e48239b26 (patch) | |
tree | e81cbd3b5ea45564d6f51b0e9e00d463741623ad /indra/newview/llviewerobjectlist.cpp | |
parent | 62943202a7c4334ce7b7be96f8f64133444ee925 (diff) |
Added new UI to show linked set cost and object cost. Changed terminology in edit tools. Updated request payload when requesting object cost. Paired with davep
Diffstat (limited to 'indra/newview/llviewerobjectlist.cpp')
-rw-r--r-- | indra/newview/llviewerobjectlist.cpp | 123 |
1 files changed, 108 insertions, 15 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 900aa3ce12..e6f1d8e728 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -660,17 +660,86 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) class LLObjectCostResponder : public LLCurl::Responder { public: + LLObjectCostResponder(const LLSD& object_ids) + : mObjectIDs(object_ids) + { + } + + // Clear's the global object list's pending + // request list for all objects requested + void clear_object_list_pending_requests() + { + // TODO*: No more hard coding + for ( + LLSD::array_iterator iter = mObjectIDs.beginArray(); + iter != mObjectIDs.endArray(); + ++iter) + { + gObjectList.onObjectCostFetchFailure(iter->asUUID()); + } + } + + void error(U32 statusNum, const std::string& reason) + { + lldebugs + << "Transport error requesting object cost " + << "HTTP status: " << statusNum << ", reason: " + << reason << "." << llendl; + + // TODO*: Error message to user + // For now just clear the request from the pending list + clear_object_list_pending_requests(); + } + void result(const LLSD& content) { - for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter) + if ( !content.isMap() || content.has("error") ) + { + // Improper response or the request had an error, + // show an error to the user? + lldebugs + << "Application level error when fetching object " + << "cost. Message: " << content["error"]["message"].asString() + << ", identifier: " << content["error"]["identifier"].asString() + << llendl; + + // TODO*: Adaptively adjust request size if the + // service says we've requested too many and retry + + // TODO*: Error message if not retrying + clear_object_list_pending_requests(); + return; + } + + // Success, grab the resource cost and linked set costs + // for an object if one was returned + for ( + LLSD::array_iterator iter = mObjectIDs.beginArray(); + iter != mObjectIDs.endArray(); + ++iter) { - LLUUID object_id = LLUUID(iter->first); - F32 link_cost = iter->second["LinksetResourceCost"].asReal(); - F32 prim_cost = iter->second["PrimResourceCost"].asReal(); + LLUUID object_id = iter->asUUID(); - gObjectList.updateObjectCost(object_id, prim_cost, link_cost); + // Check to see if the request contains data for the object + if ( content.has(iter->asString()) ) + { + F32 link_cost = + content[iter->asString()]["linked_set_resource_cost"].asReal(); + F32 object_cost = + content[iter->asString()]["resource_cost"].asReal(); + + gObjectList.updateObjectCost(object_id, object_cost, link_cost); + } + else + { + // TODO*: Give user feedback about the missing data? + gObjectList.onObjectCostFetchFailure(object_id); + } } } + +private: + LLSD mObjectIDs; }; void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) @@ -769,7 +838,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } } - //issue http request for stale object physics costs + // issue http request for stale object physics costs if (!mStaleObjectCost.empty()) { LLViewerRegion* regionp = gAgent.getRegion(); @@ -781,21 +850,40 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) if (!url.empty()) { LLSD id_list; - U32 idx = 0; - for (std::set<LLUUID>::iterator iter = mStaleObjectCost.begin(); iter != mStaleObjectCost.end(); ++iter) + U32 object_index = 0; + + for ( + std::set<LLUUID>::iterator iter = mStaleObjectCost.begin(); + iter != mStaleObjectCost.end(); + ++iter) { - if (mPendingObjectCost.find(*iter) == mPendingObjectCost.end()) + // Check to see if a request for this object + // has already been made. + if ( mPendingObjectCost.find(*iter) == + mPendingObjectCost.end() ) { + // Why is this line here if + // we set mPendingObjectCost to be + // mStaleObjectCost below? mPendingObjectCost.insert(*iter); - id_list[idx++] = *iter; + id_list[object_index++] = *iter; } } - mPendingObjectCost = mStaleObjectCost; + + // id_list should now contain all + // requests in mStaleObjectCost before, so clear + // it now mStaleObjectCost.clear(); - if (id_list.size() > 0) + if ( id_list.size() > 0 ) { - LLHTTPClient::post(url, id_list, new LLObjectCostResponder()); + LLSD post_data = LLSD::emptyMap(); + + post_data["object_ids"] = id_list; + LLHTTPClient::post( + url, + post_data, + new LLObjectCostResponder(id_list)); } } else @@ -1099,18 +1187,23 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object) mStaleObjectCost.insert(object->getID()); } -void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost) +void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost) { mPendingObjectCost.erase(object_id); LLViewerObject* object = findObject(object_id); if (object) { - object->setObjectCost(prim_cost); + object->setObjectCost(object_cost); object->setLinksetCost(link_cost); } } +void LLViewerObjectList::onObjectCostFetchFailure(LLUUID object_id) +{ + mPendingObjectCost.erase(object_id); +} + void LLViewerObjectList::shiftObjects(const LLVector3 &offset) { // This is called when we shift our origin when we cross region boundaries... |