From c6aaf115ade4b335df9ca479992b08e028ffd910 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 16 Dec 2009 09:26:53 -0600 Subject: Quick 'n dirty prioritization scheme for mesh loading. Sprinkling of fast timers in areas that are likely to stall. --- indra/newview/llviewerobjectlist.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 96828ee1b6..7a6f479685 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -866,8 +866,12 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) mNumDeadObjects++; } +static LLFastTimer::DeclareTimer FTM_REMOVE_DRAWABLE("Remove Drawable"); + void LLViewerObjectList::removeDrawable(LLDrawable* drawablep) { + LLFastTimer t(FTM_REMOVE_DRAWABLE); + if (!drawablep) { return; -- cgit v1.2.3 From 827c1adc917d832b577b37e37b0eb3f26705c29d Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Sat, 13 Feb 2010 12:48:42 +0000 Subject: Backed out changeset d89b00b44ab6 --- indra/newview/llviewerobjectlist.cpp | 171 ++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 84 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 96828ee1b6..6347090f71 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -93,7 +93,7 @@ extern LLPipeline gPipeline; // Statics for object lookup tables. U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. -LLMap LLViewerObjectList::sIPAndPortToIndex; +std::map LLViewerObjectList::sIPAndPortToIndex; std::map LLViewerObjectList::sIndexAndLocalIDToUUID; LLViewerObjectList::LLViewerObjectList() @@ -571,10 +571,9 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys, void LLViewerObjectList::dirtyAllObjectInventory() { - S32 count = mObjects.count(); - for(S32 i = 0; i < count; ++i) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - mObjects[i]->dirtyInventory(); + (*iter)->dirtyInventory(); } } @@ -587,14 +586,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) S32 num_updates, max_value; if (NUM_BINS - 1 == mCurBin) { - num_updates = mObjects.count() - mCurLazyUpdateIndex; - max_value = mObjects.count(); + num_updates = (S32) mObjects.size() - mCurLazyUpdateIndex; + max_value = (S32) mObjects.size(); gTextureList.setUpdateStats(TRUE); } else { - num_updates = (mObjects.count() / NUM_BINS) + 1; - max_value = llmin(mObjects.count(), mCurLazyUpdateIndex + num_updates); + num_updates = ((S32) mObjects.size() / NUM_BINS) + 1; + max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates); } @@ -647,7 +646,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) } mCurLazyUpdateIndex = max_value; - if (mCurLazyUpdateIndex == mObjects.count()) + if (mCurLazyUpdateIndex == mObjects.size()) { mCurLazyUpdateIndex = 0; } @@ -694,20 +693,26 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) // Make a copy of the list in case something in idleUpdate() messes with it std::vector idle_list; - idle_list.reserve( mActiveObjects.size() ); + + static LLFastTimer::DeclareTimer idle_copy("Idle Copy"); - for (std::set >::iterator active_iter = mActiveObjects.begin(); - active_iter != mActiveObjects.end(); active_iter++) { - objectp = *active_iter; - if (objectp) + LLFastTimer t(idle_copy); + idle_list.reserve( mActiveObjects.size() ); + + for (std::set >::iterator active_iter = mActiveObjects.begin(); + active_iter != mActiveObjects.end(); active_iter++) { - idle_list.push_back( objectp ); - } - else - { // There shouldn't be any NULL pointers in the list, but they have caused - // crashes before. This may be idleUpdate() messing with the list. - llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl; + objectp = *active_iter; + if (objectp) + { + idle_list.push_back( objectp ); + } + else + { // There shouldn't be any NULL pointers in the list, but they have caused + // crashes before. This may be idleUpdate() messing with the list. + llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl; + } } } @@ -807,7 +812,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } */ - LLViewerStats::getInstance()->mNumObjectsStat.addValue(mObjects.count()); + LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size()); LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(num_active_objects); LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled); LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); @@ -815,9 +820,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) void LLViewerObjectList::clearDebugText() { - for (S32 i = 0; i < mObjects.count(); i++) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - mObjects[i]->setDebugText(""); + (*iter)->setDebugText(""); } } @@ -856,7 +861,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) if (objectp->isOnMap()) { - mMapObjects.removeObj(objectp); + removeFromMap(objectp); } // Don't clean up mObject references, these will be cleaned up more efficiently later! @@ -913,10 +918,10 @@ void LLViewerObjectList::killObjects(LLViewerRegion *regionp) { LLViewerObject *objectp; - S32 i; - for (i = 0; i < mObjects.count(); i++) + + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - objectp = mObjects[i]; + objectp = *iter; if (objectp->mRegionp == regionp) { @@ -933,10 +938,9 @@ void LLViewerObjectList::killAllObjects() // Used only on global destruction. LLViewerObject *objectp; - for (S32 i = 0; i < mObjects.count(); i++) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - objectp = mObjects[i]; - + objectp = *iter; killObject(objectp); llassert(objectp->isDead()); } @@ -945,7 +949,7 @@ void LLViewerObjectList::killAllObjects() if(!mObjects.empty()) { - llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.count() << llendl; + llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.size() << llendl; mObjects.clear(); } @@ -970,16 +974,15 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) return; } - S32 i = 0; S32 num_removed = 0; LLViewerObject *objectp; - while (i < mObjects.count()) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ) { // Scan for all of the dead objects and remove any "global" references to them. - objectp = mObjects[i]; + objectp = *iter; if (objectp->isDead()) { - mObjects.remove(i); + iter = mObjects.erase(iter); num_removed++; if (num_removed == mNumDeadObjects) @@ -990,8 +993,7 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) } else { - // iterate, this isn't a dead object. - i++; + ++iter; } } @@ -1041,12 +1043,11 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset) } LLViewerObject *objectp; - S32 i; - for (i = 0; i < mObjects.count(); i++) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - objectp = getObject(i); + objectp = *iter; // There could be dead objects on the object list, so don't update stuff if the object is dead. - if (objectp) + if (!objectp->isDead()) { objectp->updatePositionCaches(); @@ -1076,9 +1077,9 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius"); - for (S32 i = 0; i < mMapObjects.count(); i++) + for (vobj_list_t::iterator iter = mMapObjects.begin(); iter != mMapObjects.end(); ++iter) { - LLViewerObject* objectp = mMapObjects[i]; + LLViewerObject* objectp = *iter; if (!objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment()) { continue; @@ -1144,21 +1145,14 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) { } -void LLViewerObjectList::renderObjectsForSelect(LLCamera &camera, const LLRect& screen_rect, BOOL pick_parcel_wall, BOOL render_transparent) -{ - generatePickList(camera); - renderPickList(screen_rect, pick_parcel_wall, render_transparent); -} - void LLViewerObjectList::generatePickList(LLCamera &camera) { LLViewerObject *objectp; S32 i; // Reset all of the GL names to zero. - for (i = 0; i < mObjects.count(); i++) + for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - objectp = mObjects[i]; - objectp->mGLName = 0; + (*iter)->mGLName = 0; } mSelectPickList.clear(); @@ -1321,17 +1315,19 @@ void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent, const LLColor4 &text_color, S32 line_width) { - LLDebugBeacon *beaconp = mDebugBeacons.reserve_block(1); - beaconp->mPositionAgent = pos_agent; - beaconp->mString = string; - beaconp->mColor = color; - beaconp->mTextColor = text_color; - beaconp->mLineWidth = line_width; + LLDebugBeacon beacon; + beacon.mPositionAgent = pos_agent; + beacon.mString = string; + beacon.mColor = color; + beacon.mTextColor = text_color; + beacon.mLineWidth = line_width; + + mDebugBeacons.push_back(beacon); } void LLViewerObjectList::resetObjectBeacons() { - mDebugBeacons.reset(); + mDebugBeacons.clear(); } LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp) @@ -1349,7 +1345,7 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi mUUIDObjectMap[fullid] = objectp; - mObjects.put(objectp); + mObjects.push_back(objectp); updateActive(objectp); @@ -1388,7 +1384,7 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe gMessageSystem->getSenderIP(), gMessageSystem->getSenderPort()); - mObjects.put(objectp); + mObjects.push_back(objectp); updateActive(objectp); @@ -1411,11 +1407,11 @@ LLViewerObject *LLViewerObjectList::replaceObject(const LLUUID &id, const LLPCod S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const { LLViewerObject *objectp; - S32 i; S32 num_refs = 0; - for (i = 0; i < mObjects.count(); i++) + + for (vobj_list_t::const_iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) { - objectp = mObjects[i]; + objectp = *iter; if (objectp->mDrawable.notNull()) { num_refs += objectp->mDrawable->findReferences(drawablep); @@ -1460,15 +1456,15 @@ void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip // Unknown parent, add to orpaned child list U64 parent_info = getIndex(parent_id, ip, port); - if (-1 == mOrphanParents.find(parent_info)) + if (std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info) == mOrphanParents.end()) { - mOrphanParents.put(parent_info); + mOrphanParents.push_back(parent_info); } LLViewerObjectList::OrphanInfo oi(parent_info, childp->mID); - if (-1 == mOrphanChildren.find(oi)) + if (std::find(mOrphanChildren.begin(), mOrphanChildren.end(), oi) == mOrphanChildren.end()) { - mOrphanChildren.put(oi); + mOrphanChildren.push_back(oi); mNumOrphans++; } } @@ -1491,28 +1487,29 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port) // See if we are a parent of an orphan. // Note: This code is fairly inefficient but it should happen very rarely. // It can be sped up if this is somehow a performance issue... - if (0 == mOrphanParents.count()) + if (mOrphanParents.empty()) { // no known orphan parents return; } - if (-1 == mOrphanParents.find(getIndex(objectp->mLocalID, ip, port))) + if (std::find(mOrphanParents.begin(), mOrphanParents.end(), getIndex(objectp->mLocalID, ip, port)) == mOrphanParents.end()) { // did not find objectp in OrphanParent list return; } - S32 i; U64 parent_info = getIndex(objectp->mLocalID, ip, port); BOOL orphans_found = FALSE; // Iterate through the orphan list, and set parents of matching children. - for (i = 0; i < mOrphanChildren.count(); i++) - { - if (mOrphanChildren[i].mParentInfo != parent_info) + + for (std::vector::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); ) + { + if (iter->mParentInfo != parent_info) { + ++iter; continue; } - LLViewerObject *childp = findObject(mOrphanChildren[i].mChildInfo); + LLViewerObject *childp = findObject(iter->mChildInfo); if (childp) { if (childp == objectp) @@ -1546,29 +1543,35 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port) objectp->addChild(childp); orphans_found = TRUE; + ++iter; } else { llinfos << "Missing orphan child, removing from list" << llendl; - mOrphanChildren.remove(i); - i--; + + iter = mOrphanChildren.erase(iter); } } // Remove orphan parent and children from lists now that they've been found - mOrphanParents.remove(mOrphanParents.find(parent_info)); - - i = 0; - while (i < mOrphanChildren.count()) { - if (mOrphanChildren[i].mParentInfo == parent_info) + std::vector::iterator iter = std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info); + if (iter != mOrphanParents.end()) + { + mOrphanParents.erase(iter); + } + } + + for (std::vector::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); ) + { + if (iter->mParentInfo == parent_info) { - mOrphanChildren.remove(i); + iter = mOrphanChildren.erase(iter); mNumOrphans--; } else { - i++; + ++iter; } } -- cgit v1.2.3 From d334a9e645ab14c2822f35ee67d2c1e0f2a646a6 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 May 2010 14:54:56 -0500 Subject: Vis that works and first pass at fetching prim cost. --- indra/newview/llviewerobjectlist.cpp | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 7ba28fef32..047241fffb 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -656,6 +656,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent) LLVOAvatar::cullAvatarsByPixelArea(); } +class LLObjectCostResponder : public LLCurl::Responder +{ +public: + void result(const LLSD& content) + { + llinfos << content << llendl; + } +}; void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { @@ -753,6 +761,40 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } } + //issue http request for stale object physics costs + if (!mStaleObjectCost.empty()) + { + LLViewerRegion* regionp = gAgent.getRegion(); + + if (regionp) + { + std::string url; // = regionp->getCapability("GetObjectCost"); + + if (!url.empty()) + { + LLSD id_list; + U32 idx = 0; + for (std::set::iterator iter = mStaleObjectCost.begin(); iter != mStaleObjectCost.end(); ++iter) + { + if (mPendingObjectCost.find(*iter) == mPendingObjectCost.end()) + { + mPendingObjectCost.insert(*iter); + id_list[idx++] = *iter; + } + } + mPendingObjectCost = mStaleObjectCost; + mStaleObjectCost.clear(); + + LLHTTPClient::post(url, id_list, new LLObjectCostResponder()); + } + else + { + mStaleObjectCost.clear(); + mPendingObjectCost.clear(); + } + } + } + mNumSizeCulled = 0; mNumVisCulled = 0; @@ -1041,7 +1083,10 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp) } } - +void LLViewerObjectList::updateObjectCost(LLViewerObject* object) +{ + mStaleObjectCost.insert(object->getID()); +} void LLViewerObjectList::shiftObjects(const LLVector3 &offset) { -- cgit v1.2.3 From 8be6ad300a320b8a9debbd3abbf4b5c252db70a9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 14 May 2010 17:36:57 -0500 Subject: Actually update object cost based on result. --- indra/newview/llviewerobjectlist.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 047241fffb..422ac4e84f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -60,6 +60,7 @@ #include "llviewercamera.h" #include "llselectmgr.h" #include "llresmgr.h" +#include "llsdutil.h" #include "llviewerregion.h" #include "llviewerstats.h" #include "llvoavatarself.h" @@ -661,7 +662,14 @@ class LLObjectCostResponder : public LLCurl::Responder public: void result(const LLSD& content) { - llinfos << content << llendl; + for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter) + { + LLUUID object_id = LLUUID(iter->first); + S32 link_cost = iter->second["LinkResourceCost"].asInteger(); + S32 prim_cost = iter->second["PrimResourceCost"].asInteger(); + + gObjectList.updateObjectCost(object_id, prim_cost, link_cost); + } } }; @@ -768,7 +776,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) if (regionp) { - std::string url; // = regionp->getCapability("GetObjectCost"); + std::string url = regionp->getCapability("GetObjectCost"); if (!url.empty()) { @@ -785,7 +793,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) mPendingObjectCost = mStaleObjectCost; mStaleObjectCost.clear(); - LLHTTPClient::post(url, id_list, new LLObjectCostResponder()); + if (id_list.size() > 0) + { + LLHTTPClient::post(url, id_list, new LLObjectCostResponder()); + } } else { @@ -1088,6 +1099,17 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object) mStaleObjectCost.insert(object->getID()); } +void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost) +{ + mPendingObjectCost.erase(object_id); + + LLViewerObject* object = findObject(object_id); + if (object) + { + object->setObjectCost(prim_cost); + } +} + void LLViewerObjectList::shiftObjects(const LLVector3 &offset) { // This is called when we shift our origin when we cross region boundaries... -- cgit v1.2.3 From 246dd9c168550bfe4b1b71bba75f5af9456e86dd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 15 May 2010 02:45:58 -0500 Subject: Highlight for object cost and proper retrieval/display of prim object cost and linkset cost. --- indra/newview/llviewerobjectlist.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 422ac4e84f..9d41e2a530 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -665,8 +665,8 @@ public: for (LLSD::map_const_iterator iter = content.beginMap(); iter != content.endMap(); ++iter) { LLUUID object_id = LLUUID(iter->first); - S32 link_cost = iter->second["LinkResourceCost"].asInteger(); - S32 prim_cost = iter->second["PrimResourceCost"].asInteger(); + F32 link_cost = iter->second["LinksetResourceCost"].asReal(); + F32 prim_cost = iter->second["PrimResourceCost"].asReal(); gObjectList.updateObjectCost(object_id, prim_cost, link_cost); } @@ -1099,7 +1099,7 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object) mStaleObjectCost.insert(object->getID()); } -void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 link_cost) +void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 prim_cost, F32 link_cost) { mPendingObjectCost.erase(object_id); @@ -1107,6 +1107,7 @@ void LLViewerObjectList::updateObjectCost(LLUUID object_id, S32 prim_cost, S32 l if (object) { object->setObjectCost(prim_cost); + object->setLinksetCost(link_cost); } } -- cgit v1.2.3 From 671609239f63bc6dc293a0580e6f1b8e48239b26 Mon Sep 17 00:00:00 2001 From: jwolk Date: Fri, 13 Aug 2010 17:30:09 -0700 Subject: 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 --- indra/newview/llviewerobjectlist.cpp | 123 ++++++++++++++++++++++++++++++----- 1 file changed, 108 insertions(+), 15 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') 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::iterator iter = mStaleObjectCost.begin(); iter != mStaleObjectCost.end(); ++iter) + U32 object_index = 0; + + for ( + std::set::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... -- cgit v1.2.3 From b70ccfe8e31cd253069a6e0ae0ec03e301d26578 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 7 Oct 2010 14:00:43 -0500 Subject: Add pure physics cost to UI --- indra/newview/llviewerobjectlist.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index e6f1d8e728..97b102a6a3 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -728,7 +728,10 @@ public: F32 object_cost = content[iter->asString()]["resource_cost"].asReal(); - gObjectList.updateObjectCost(object_id, object_cost, link_cost); + F32 physics_cost = content[iter->asString()]["physics_cost"].asReal(); + F32 link_physics_cost = content[iter->asString()]["linked_set_physics_cost"].asReal(); + + gObjectList.updateObjectCost(object_id, object_cost, link_cost, physics_cost, link_physics_cost); } else { @@ -1187,7 +1190,7 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object) mStaleObjectCost.insert(object->getID()); } -void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost) +void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost, F32 physics_cost, F32 link_physics_cost) { mPendingObjectCost.erase(object_id); @@ -1196,6 +1199,8 @@ void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 { object->setObjectCost(object_cost); object->setLinksetCost(link_cost); + object->setPhysicsCost(physics_cost); + object->setLinksetPhysicsCost(link_physics_cost); } } -- cgit v1.2.3 From a5619d16f74863168f45b04b37cc6383e1a92263 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 13 Oct 2010 07:24:37 -0400 Subject: correct licenses (fix problem with license change merge) --- indra/newview/llviewerobjectlist.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 97b102a6a3..87df037662 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -2,31 +2,25 @@ * @file llviewerobjectlist.cpp * @brief Implementation of LLViewerObjectList class. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -- cgit v1.2.3 From 30b44b238ba6ff8ff6dc29161f3ff6ee85a27f06 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 19 Oct 2010 23:19:55 -0500 Subject: First stab at using GetObjectPhysicsData --- indra/newview/llviewerobjectlist.cpp | 314 ++++++++++++++++++++++++++++------- 1 file changed, 255 insertions(+), 59 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 87df037662..c1d179fa40 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -675,7 +675,7 @@ public: void error(U32 statusNum, const std::string& reason) { - lldebugs + llwarns << "Transport error requesting object cost " << "HTTP status: " << statusNum << ", reason: " << reason << "." << llendl; @@ -691,7 +691,7 @@ public: { // Improper response or the request had an error, // show an error to the user? - lldebugs + llwarns << "Application level error when fetching object " << "cost. Message: " << content["error"]["message"].asString() << ", identifier: " << content["error"]["identifier"].asString() @@ -739,6 +739,102 @@ private: LLSD mObjectIDs; }; + +class LLPhysicsFlagsResponder : public LLCurl::Responder +{ +public: + LLPhysicsFlagsResponder(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.onPhysicsFlagsFetchFailure(iter->asUUID()); + } + } + + void error(U32 statusNum, const std::string& reason) + { + llwarns + << "Transport error requesting object physics flags " + << "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) + { + if ( !content.isMap() || content.has("error") ) + { + // Improper response or the request had an error, + // show an error to the user? + llwarns + << "Application level error when fetching object " + << "physics flags. 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 = iter->asUUID(); + + // Check to see if the request contains data for the object + if ( content.has(iter->asString()) ) + { + const LLSD& data = content[iter->asString()]; + + S32 shape_type = data["PhysicsShapeType"].asInteger(); + + gObjectList.updatePhysicsShapeType(object_id, shape_type); + + if (data.has("Density")) + { + F32 density = data["Density"].asReal(); + F32 friction = data["Friction"].asReal(); + F32 restitution = data["Restitution"].asReal(); + F32 gravity_multiplier = data["GravityMultiplier"].asReal(); + + gObjectList.updatePhysicsProperties(object_id, + density, friction, restitution, gravity_multiplier); + } + } + else + { + // TODO*: Give user feedback about the missing data? + gObjectList.onPhysicsFlagsFetchFailure(object_id); + } + } + } + +private: + LLSD mObjectIDs; +}; + void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { LLMemType mt(LLMemType::MTYPE_OBJECT); @@ -835,61 +931,8 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } } - // issue http request for stale object physics costs - if (!mStaleObjectCost.empty()) - { - LLViewerRegion* regionp = gAgent.getRegion(); - - if (regionp) - { - std::string url = regionp->getCapability("GetObjectCost"); - - if (!url.empty()) - { - LLSD id_list; - U32 object_index = 0; - - for ( - std::set::iterator iter = mStaleObjectCost.begin(); - iter != mStaleObjectCost.end(); - ++iter) - { - // 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[object_index++] = *iter; - } - } - - // id_list should now contain all - // requests in mStaleObjectCost before, so clear - // it now - mStaleObjectCost.clear(); - - if ( id_list.size() > 0 ) - { - LLSD post_data = LLSD::emptyMap(); - - post_data["object_ids"] = id_list; - LLHTTPClient::post( - url, - post_data, - new LLObjectCostResponder(id_list)); - } - } - else - { - mStaleObjectCost.clear(); - mPendingObjectCost.clear(); - } - } - } + fetchObjectCosts(); + fetchPhysicsFlags(); mNumSizeCulled = 0; mNumVisCulled = 0; @@ -956,6 +999,119 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); } +void LLViewerObjectList::fetchObjectCosts() +{ + // issue http request for stale object physics costs + if (!mStaleObjectCost.empty()) + { + LLViewerRegion* regionp = gAgent.getRegion(); + + if (regionp) + { + std::string url = regionp->getCapability("GetObjectCost"); + + if (!url.empty()) + { + LLSD id_list; + U32 object_index = 0; + + for ( + std::set::iterator iter = mStaleObjectCost.begin(); + iter != mStaleObjectCost.end(); + ++iter) + { + // Check to see if a request for this object + // has already been made. + if ( mPendingObjectCost.find(*iter) == + mPendingObjectCost.end() ) + { + mPendingObjectCost.insert(*iter); + id_list[object_index++] = *iter; + } + } + + // id_list should now contain all + // requests in mStaleObjectCost before, so clear + // it now + mStaleObjectCost.clear(); + + if ( id_list.size() > 0 ) + { + LLSD post_data = LLSD::emptyMap(); + + post_data["object_ids"] = id_list; + LLHTTPClient::post( + url, + post_data, + new LLObjectCostResponder(id_list)); + } + } + else + { + mStaleObjectCost.clear(); + mPendingObjectCost.clear(); + } + } + } +} + +void LLViewerObjectList::fetchPhysicsFlags() +{ + // issue http request for stale object physics flags + if (!mStalePhysicsFlags.empty()) + { + LLViewerRegion* regionp = gAgent.getRegion(); + + if (regionp) + { + std::string url = regionp->getCapability("GetObjectPhysicsData"); + + if (!url.empty()) + { + LLSD id_list; + U32 object_index = 0; + + for ( + std::set::iterator iter = mStalePhysicsFlags.begin(); + iter != mStalePhysicsFlags.end(); + ++iter) + { + // Check to see if a request for this object + // has already been made. + if ( mPendingPhysicsFlags.find(*iter) == + mPendingPhysicsFlags.end() ) + { + mPendingPhysicsFlags.insert(*iter); + id_list[object_index++] = *iter; + } + } + + // id_list should now contain all + // requests in mStalePhysicsFlags before, so clear + // it now + mStalePhysicsFlags.clear(); + + if ( id_list.size() > 0 ) + { + LLSD post_data = LLSD::emptyMap(); + + post_data["object_ids"] = id_list; + LLHTTPClient::post( + url, + post_data, + new LLPhysicsFlagsResponder(id_list)); + } + } + else + { + mStalePhysicsFlags.clear(); + mPendingPhysicsFlags.clear(); + } + } + } +} + + void LLViewerObjectList::clearDebugText() { for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter) @@ -1184,7 +1340,7 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object) mStaleObjectCost.insert(object->getID()); } -void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 link_cost, F32 physics_cost, F32 link_physics_cost) +void LLViewerObjectList::updateObjectCost(const LLUUID& object_id, F32 object_cost, F32 link_cost, F32 physics_cost, F32 link_physics_cost) { mPendingObjectCost.erase(object_id); @@ -1198,11 +1354,51 @@ void LLViewerObjectList::updateObjectCost(LLUUID object_id, F32 object_cost, F32 } } -void LLViewerObjectList::onObjectCostFetchFailure(LLUUID object_id) +void LLViewerObjectList::onObjectCostFetchFailure(const LLUUID& object_id) { + llwarns << "Failed to fetch object cost for object: " << object_id << llendl; mPendingObjectCost.erase(object_id); } +void LLViewerObjectList::updatePhysicsFlags(const LLViewerObject* object) +{ + mStalePhysicsFlags.insert(object->getID()); +} + +void LLViewerObjectList::updatePhysicsShapeType(const LLUUID& object_id, S32 type) +{ + mPendingPhysicsFlags.erase(object_id); + LLViewerObject* object = findObject(object_id); + if (object) + { + object->setPhysicsShapeType(type); + } +} + +void LLViewerObjectList::updatePhysicsProperties(const LLUUID& object_id, + F32 density, + F32 friction, + F32 restitution, + F32 gravity_multiplier) +{ + mPendingPhysicsFlags.erase(object_id); + + LLViewerObject* object = findObject(object_id); + if (object) + { + object->setPhysicsDensity(density); + object->setPhysicsFriction(friction); + object->setPhysicsGravity(gravity_multiplier); + object->setPhysicsRestitution(restitution); + } +} + +void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id) +{ + llwarns << "Failed to fetch physics flags for object: " << object_id << llendl; + mPendingPhysicsFlags.erase(object_id); +} + void LLViewerObjectList::shiftObjects(const LLVector3 &offset) { // This is called when we shift our origin when we cross region boundaries... -- cgit v1.2.3 From aeec987f565f916c9919f8cc861a82b4caab9a46 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 18 Jan 2011 14:49:14 -0600 Subject: SH-571 work in progress. --- indra/newview/llviewerobjectlist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerobjectlist.cpp') diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 7682d71e7f..e4da9cca04 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1376,7 +1376,7 @@ void LLViewerObjectList::updateObjectCost(const LLUUID& object_id, F32 object_co void LLViewerObjectList::onObjectCostFetchFailure(const LLUUID& object_id) { - llwarns << "Failed to fetch object cost for object: " << object_id << llendl; + //llwarns << "Failed to fetch object cost for object: " << object_id << llendl; mPendingObjectCost.erase(object_id); } @@ -1415,7 +1415,7 @@ void LLViewerObjectList::updatePhysicsProperties(const LLUUID& object_id, void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id) { - llwarns << "Failed to fetch physics flags for object: " << object_id << llendl; + //llwarns << "Failed to fetch physics flags for object: " << object_id << llendl; mPendingPhysicsFlags.erase(object_id); } -- cgit v1.2.3