diff options
Diffstat (limited to 'indra/newview/llavatarrenderinfoaccountant.cpp')
| -rw-r--r-- | indra/newview/llavatarrenderinfoaccountant.cpp | 160 | 
1 files changed, 80 insertions, 80 deletions
diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index b95b971890..ec9cf2c8b7 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -2,26 +2,26 @@   * @file   llavatarrenderinfoaccountant.cpp   * @author Dave Simmons   * @date   2013-02-28 - * @brief   - *  + * @brief + *   * $LicenseInfo:firstyear=2013&license=viewerlgpl$   * Second Life Viewer Source Code   * Copyright (C) 2013, 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. - *  + *   * 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. - *  + *   * 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 - *  + *   * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA   * $/LicenseInfo$   */ @@ -48,20 +48,20 @@  #include "httpoptions.h"  #include "llcorehttputil.h" -static	const std::string KEY_AGENTS = "agents";			// map -static 	const std::string KEY_WEIGHT = "weight";			// integer -static 	const std::string KEY_TOO_COMPLEX  = "tooComplex";  // bool +static  const std::string KEY_AGENTS = "agents";            // map +static  const std::string KEY_WEIGHT = "weight";            // integer +static  const std::string KEY_TOO_COMPLEX  = "tooComplex";  // bool  static  const std::string KEY_OVER_COMPLEXITY_LIMIT = "overlimit";  // integer  static  const std::string KEY_REPORTING_COMPLEXITY_LIMIT = "reportinglimit";  // integer -static	const std::string KEY_IDENTIFIER = "identifier"; -static	const std::string KEY_MESSAGE = "message"; -static	const std::string KEY_ERROR = "error"; +static  const std::string KEY_IDENTIFIER = "identifier"; +static  const std::string KEY_MESSAGE = "message"; +static  const std::string KEY_ERROR = "error"; + +static const F32 SECS_BETWEEN_REGION_SCANS   =  5.f;        // Scan the region list every 5 seconds +static const F32 SECS_BETWEEN_REGION_REQUEST = 15.0;        // Look for new avs every 15 seconds +static const F32 SECS_BETWEEN_REGION_REPORTS = 60.0;        // Update each region every 60 seconds -static const F32 SECS_BETWEEN_REGION_SCANS   =  5.f;		// Scan the region list every 5 seconds -static const F32 SECS_BETWEEN_REGION_REQUEST = 15.0;		// Look for new avs every 15 seconds -static const F32 SECS_BETWEEN_REGION_REPORTS = 60.0;		// Update each region every 60 seconds -	  //=========================================================================  LLAvatarRenderInfoAccountant::LLAvatarRenderInfoAccountant() @@ -76,7 +76,7 @@ LLAvatarRenderInfoAccountant::~LLAvatarRenderInfoAccountant()  void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 regionHandle)  {      LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); -    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t  +    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t          httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AvatarRenderInfoAccountant", httpPolicy));      LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);      LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); @@ -99,7 +99,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64      LLViewerRegion * regionp = world_inst->getRegionFromHandle(regionHandle);      if (!regionp)      { -        LL_WARNS("AvatarRenderInfoAccountant") << "Avatar render weight info received but region not found for "  +        LL_WARNS("AvatarRenderInfoAccountant") << "Avatar render weight info received but region not found for "                  << regionHandle << LL_ENDL;          return;      } @@ -137,7 +137,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64                      const LLSD & agent_info_map = agent_iter->second;                      if (agent_info_map.isMap())                      { -                        LL_DEBUGS("AvatarRenderInfo") << " Agent " << target_agent_id  +                        LL_DEBUGS("AvatarRenderInfo") << " Agent " << target_agent_id                                                        << ": " << agent_info_map << LL_ENDL;                          if (agent_info_map.has(KEY_WEIGHT)) @@ -163,7 +163,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64          {              LL_WARNS("AvatarRenderInfo") << "malformed get response '" << KEY_AGENTS << "' is not map" << LL_ENDL;          } -    }	// has "agents" +    }   // has "agents"      else      {          LL_INFOS("AvatarRenderInfo") << "no '"<< KEY_AGENTS << "' key in get response" << LL_ENDL; @@ -225,18 +225,18 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U      U32 num_avs = 0;      // Build the render info to POST to the region      LLSD agents = LLSD::emptyMap(); -				 +      std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();      while( iter != LLCharacter::sInstances.end() )      {          LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*iter);          if (avatar && -            avatar->getRezzedStatus() >= 2 &&					// Mostly rezzed (maybe without baked textures downloaded) -            !avatar->isDead() &&								// Not dead yet -            !avatar->isControlAvatar() &&						// Not part of an animated object -            avatar->getObjectHost() == regionp->getHost())		// Ensure it's on the same region +            avatar->getRezzedStatus() >= 2 &&                   // Mostly rezzed (maybe without baked textures downloaded) +            !avatar->isDead() &&                                // Not dead yet +            !avatar->isControlAvatar() &&                       // Not part of an animated object +            avatar->getObjectHost() == regionp->getHost())      // Ensure it's on the same region          { -            avatar->calculateUpdateRenderComplexity();			// Make sure the numbers are up-to-date +            avatar->calculateUpdateRenderComplexity();          // Make sure the numbers are up-to-date              LLSD info = LLSD::emptyMap();              U32 avatar_complexity = avatar->getVisualComplexity(); @@ -261,7 +261,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U      if (num_avs == 0)          return; // nothing to report -     +      LLSD report = LLSD::emptyMap();      report[KEY_AGENTS] = agents; @@ -300,7 +300,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U              const LLSD & error = result[KEY_ERROR];              LL_WARNS("AvatarRenderInfoAccountant") << "POST error: "                  << error[KEY_IDENTIFIER] -                << ": " << error[KEY_MESSAGE]  +                << ": " << error[KEY_MESSAGE]                  << " from region " << regionp->getName()                  << LL_ENDL;          } @@ -323,11 +323,11 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U  // called when the mRenderInfoScanTimer expires (forced when entering a new region)  void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regionp)  { -	std::string url = regionp->getCapability("AvatarRenderInfo"); -	if (   !url.empty() // we have the capability +    std::string url = regionp->getCapability("AvatarRenderInfo"); +    if (   !url.empty() // we have the capability          && regionp->getRenderInfoReportTimer().hasExpired() // Time to make request)          ) -	{ +    {          // make sure we won't re-report, coro will update timer with correct time later          regionp->getRenderInfoReportTimer().resetWithExpiry(SECS_BETWEEN_REGION_REPORTS); @@ -342,20 +342,20 @@ void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regio              LLError::LLUserWarningMsg::showOutOfMemory();              LL_ERRS() << "LLCoros::launch() allocation failure" << LL_ENDL;          } -	} +    }  }  // Send request for avatar weights in one region  // called when the mRenderInfoScanTimer expires (forced when entering a new region)  void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regionp)  { -	std::string url = regionp->getCapability("AvatarRenderInfo"); -	if (   !url.empty() +    std::string url = regionp->getCapability("AvatarRenderInfo"); +    if (   !url.empty()          && regionp->getRenderInfoRequestTimer().hasExpired()          ) -	{ +    {          LL_DEBUGS("AvatarRenderInfo") -            << "Requesting avatar render info for region " << regionp->getName()  +            << "Requesting avatar render info for region " << regionp->getName()              << " from " << url              << LL_ENDL; @@ -374,44 +374,44 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi              LLError::LLUserWarningMsg::showOutOfMemory();              LL_ERRS() << "LLCoros::launch() allocation failure" << LL_ENDL;          } -	} +    }  }  // Called every frame - send render weight requests to every region  void LLAvatarRenderInfoAccountant::idle()  { -	if (mRenderInfoScanTimer.hasExpired() && !LLApp::isExiting()) -	{ -		LL_DEBUGS("AvatarRenderInfo") << "Scanning regions for render info updates" -									  << LL_ENDL; - -		// Check all regions -		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); -			 iter != LLWorld::getInstance()->getRegionList().end(); -			 ++iter) -		{ -			LLViewerRegion* regionp = *iter; -			if (   regionp -				&& regionp->isAlive() -				&& regionp->capabilitiesReceived()) -			{ -				// each of these is further governed by and resets its own timer +    if (mRenderInfoScanTimer.hasExpired() && !LLApp::isExiting()) +    { +        LL_DEBUGS("AvatarRenderInfo") << "Scanning regions for render info updates" +                                      << LL_ENDL; + +        // Check all regions +        for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); +             iter != LLWorld::getInstance()->getRegionList().end(); +             ++iter) +        { +            LLViewerRegion* regionp = *iter; +            if (   regionp +                && regionp->isAlive() +                && regionp->capabilitiesReceived()) +            { +                // each of these is further governed by and resets its own timer                  // Note: We can have multiple regions, each launches up to two coroutines,                  // it likely is expensive -				sendRenderInfoToRegion(regionp); -				getRenderInfoFromRegion(regionp); -			} -		} - -		// We scanned all the regions, reset the request timer. -		mRenderInfoScanTimer.resetWithExpiry(SECS_BETWEEN_REGION_SCANS); -	} +                sendRenderInfoToRegion(regionp); +                getRenderInfoFromRegion(regionp); +            } +        } + +        // We scanned all the regions, reset the request timer. +        mRenderInfoScanTimer.resetWithExpiry(SECS_BETWEEN_REGION_SCANS); +    }  }  void LLAvatarRenderInfoAccountant::resetRenderInfoScanTimer()  { -	// this will force the next frame to rescan -	mRenderInfoScanTimer.reset(); +    // this will force the next frame to rescan +    mRenderInfoScanTimer.reset();  }  // static @@ -419,21 +419,21 @@ void LLAvatarRenderInfoAccountant::resetRenderInfoScanTimer()  // are returned for a new LLViewerRegion, and is the earliest time to get render info  void LLAvatarRenderInfoAccountant::scanNewRegion(const LLUUID& region_id)  { -	LL_DEBUGS("AvatarRenderInfo") << region_id << LL_ENDL; - -	// Reset the global timer so it will scan regions on the next call to ::idle -	LLAvatarRenderInfoAccountant::getInstance()->resetRenderInfoScanTimer(); -	 -	LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); -	if (regionp) -	{	// Reset the region's timers so we will: -		//  * request render info from it immediately -		//  * report on the following scan -		regionp->getRenderInfoRequestTimer().reset(); -		regionp->getRenderInfoReportTimer().resetWithExpiry(SECS_BETWEEN_REGION_SCANS); -	} -	else -	{ -		LL_WARNS("AvatarRenderInfo") << "unable to resolve region "<<region_id<<LL_ENDL; -	} +    LL_DEBUGS("AvatarRenderInfo") << region_id << LL_ENDL; + +    // Reset the global timer so it will scan regions on the next call to ::idle +    LLAvatarRenderInfoAccountant::getInstance()->resetRenderInfoScanTimer(); + +    LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); +    if (regionp) +    {   // Reset the region's timers so we will: +        //  * request render info from it immediately +        //  * report on the following scan +        regionp->getRenderInfoRequestTimer().reset(); +        regionp->getRenderInfoReportTimer().resetWithExpiry(SECS_BETWEEN_REGION_SCANS); +    } +    else +    { +        LL_WARNS("AvatarRenderInfo") << "unable to resolve region "<<region_id<<LL_ENDL; +    }  }  | 
