diff options
Diffstat (limited to 'indra/newview/llviewerregion.cpp')
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 217 |
1 files changed, 158 insertions, 59 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index eba7189a82..8b5ffcb5e9 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -100,14 +100,11 @@ const S32 MAX_CAP_REQUEST_ATTEMPTS = 30; const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000; -BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE; +bool LLViewerRegion::sVOCacheCullingEnabled = false; S32 LLViewerRegion::sLastCameraUpdated = 0; S32 LLViewerRegion::sNewObjectCreationThrottle = -1; LLViewerRegion::vocache_entry_map_t LLViewerRegion::sRegionCacheCleanup; -const std::string LLViewerRegion::IL_MODE_DEFAULT = "default"; -const std::string LLViewerRegion::IL_MODE_360 = "360"; - typedef std::map<std::string, std::string> CapabilityMap; static void log_capabilities(const CapabilityMap &capmap); @@ -626,7 +623,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mTimeDilation(1.0f), mName(""), mZoning(""), - mIsEstateManager(FALSE), + mIsEstateManager(false), mRegionFlags( REGION_FLAGS_DEFAULT ), mRegionProtocols( 0 ), mSimAccess( SIM_ACCESS_MIN ), @@ -639,17 +636,17 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mProductSKU("unknown"), mProductName("unknown"), mViewerAssetUrl(""), - mCacheLoaded(FALSE), - mCacheDirty(FALSE), - mReleaseNotesRequested(FALSE), + mCacheLoaded(false), + mCacheDirty(false), + mReleaseNotesRequested(false), mCapabilitiesState(CAPABILITIES_STATE_INIT), mSimulatorFeaturesReceived(false), mBitsReceived(0.f), mPacketsReceived(0.f), - mDead(FALSE), + mDead(false), mLastVisitedEntry(NULL), mInvisibilityCheckHistory(-1), - mPaused(FALSE), + mPaused(false), mRegionCacheHitCount(0), mRegionCacheMissCount(0), mInterestListMode(IL_MODE_DEFAULT) @@ -725,7 +722,7 @@ static LLTrace::BlockTimerStatHandle FTM_SAVE_REGION_CACHE("Save Region Cache"); LLViewerRegion::~LLViewerRegion() { LL_PROFILE_ZONE_SCOPED; - mDead = TRUE; + mDead = true; mImpl->mActiveSet.clear(); mImpl->mVisibleEntries.clear(); mImpl->mVisibleGroups.clear(); @@ -789,17 +786,18 @@ void LLViewerRegion::loadObjectCache() } // Presume success. If it fails, we don't want to try again. - mCacheLoaded = TRUE; + mCacheLoaded = true; if(LLVOCache::instanceExists()) { LLVOCache & vocache = LLVOCache::instance(); - vocache.readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap); - vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesLLSD); + // Without this a "corrupted" vocache persists until a cache clear or other rewrite. Mark as dirty hereif read fails to force a rewrite. + mCacheDirty = !vocache.readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap); + vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesLLSD, mImpl->mCacheMap); if (mImpl->mCacheMap.empty()) { - mCacheDirty = TRUE; + mCacheDirty = true; } } } @@ -826,7 +824,7 @@ void LLViewerRegion::saveObjectCache() instance.writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled); instance.writeGenericExtrasToCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesLLSD, mCacheDirty, removal_enabled); - mCacheDirty = FALSE; + mCacheDirty = false; } if (LLAppViewer::instance()->isQuitting()) @@ -862,7 +860,7 @@ F32 LLViewerRegion::getWaterHeight() const return mImpl->mLandp->getWaterHeight(); } -BOOL LLViewerRegion::isVoiceEnabled() const +bool LLViewerRegion::isVoiceEnabled() const { return getRegionFlag(REGION_FLAGS_ALLOW_VOICE); } @@ -941,7 +939,7 @@ void LLViewerRegion::setRegionNameAndZone (const std::string& name_zone) LLStringUtil::stripNonprintable(mZoning); } -BOOL LLViewerRegion::canManageEstate() const +bool LLViewerRegion::canManageEstate() const { return gAgent.isGodlike() || isEstateManager() @@ -1112,6 +1110,11 @@ void LLViewerRegion::dirtyHeights() } } +void LLViewerRegion::dirtyAllPatches() +{ + getLand().dirtyAllPatches(); +} + //physically delete the cache entry void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry, bool for_rendering) { @@ -1162,13 +1165,13 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry, bool for_rendering) child = entry->getChild(); } } - + // Kill the assocaited overrides + mImpl->mGLTFOverridesLLSD.erase(entry->getLocalID()); //will remove it from the object cache, real deletion entry->setState(LLVOCacheEntry::INACTIVE); entry->removeOctreeEntry(); - entry->setValid(FALSE); + entry->setValid(false); - // TODO kill extras/material overrides cache too } //physically delete the cache entry @@ -1495,12 +1498,12 @@ void LLViewerRegion::createVisibleObjects(F32 max_time) } if(mImpl->mWaitingList.empty()) { - mImpl->mVOCachePartition->setCullHistory(FALSE); + mImpl->mVOCachePartition->setCullHistory(false); return; } S32 throttle = sNewObjectCreationThrottle; - BOOL has_new_obj = FALSE; + bool has_new_obj = false; LLTimer update_timer; for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin(); iter != mImpl->mWaitingList.end(); ++iter) @@ -1510,7 +1513,7 @@ void LLViewerRegion::createVisibleObjects(F32 max_time) if(vo_entry->getState() < LLVOCacheEntry::WAITING) { addNewObject(vo_entry); - has_new_obj = TRUE; + has_new_obj = true; if(throttle > 0 && !(--throttle) && update_timer.getElapsedTimeF32() > max_time) { break; @@ -1530,7 +1533,7 @@ void LLViewerRegion::clearCachedVisibleObjects() //reset all occluders mImpl->mVOCachePartition->resetOccluders(); - mPaused = TRUE; + mPaused = true; //clean visible entries for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();) @@ -1612,7 +1615,19 @@ void LLViewerRegion::idleUpdate(F32 max_update_time) mLastUpdate = LLViewerOctreeEntryData::getCurrentFrame(); - mImpl->mLandp->idleUpdate(max_update_time); + static LLCachedControl<bool> pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); + static LLCachedControl<bool> pbr_terrain_experimental_normals(gSavedSettings, "RenderTerrainPBRNormalsEnabled", false); + bool pbr_material = mImpl->mCompositionp && (mImpl->mCompositionp->getMaterialType() == LLTerrainMaterials::Type::PBR); + bool pbr_land = pbr_material && pbr_terrain_enabled && pbr_terrain_experimental_normals; + + if (!pbr_land) + { + mImpl->mLandp->idleUpdate</*PBR=*/false>(max_update_time); + } + else + { + mImpl->mLandp->idleUpdate</*PBR=*/true>(max_update_time); + } if (mParcelOverlay) { @@ -1630,7 +1645,7 @@ void LLViewerRegion::idleUpdate(F32 max_update_time) } if(mPaused) { - mPaused = FALSE; //unpause. + mPaused = false; //unpause. } LLViewerCamera::eCameraID old_camera_id = LLViewerCamera::sCurCameraID; @@ -1703,7 +1718,7 @@ void LLViewerRegion::calcNewObjectCreationThrottle() LLVOCacheEntry::updateDebugSettings(); } -BOOL LLViewerRegion::isViewerCameraStatic() +bool LLViewerRegion::isViewerCameraStatic() { return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame(); } @@ -1913,7 +1928,21 @@ LLViewerObject* LLViewerRegion::updateCacheEntry(U32 local_id, LLViewerObject* o // As above, but forcibly do the update. void LLViewerRegion::forceUpdate() { - mImpl->mLandp->idleUpdate(0.f); + constexpr F32 max_update_time = 0.f; + + static LLCachedControl<bool> pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); + static LLCachedControl<bool> pbr_terrain_experimental_normals(gSavedSettings, "RenderTerrainPBRNormalsEnabled", false); + bool pbr_material = mImpl->mCompositionp && (mImpl->mCompositionp->getMaterialType() == LLTerrainMaterials::Type::PBR); + bool pbr_land = pbr_material && pbr_terrain_enabled && pbr_terrain_experimental_normals; + + if (!pbr_land) + { + mImpl->mLandp->idleUpdate</*PBR=*/false>(max_update_time); + } + else + { + mImpl->mLandp->idleUpdate</*PBR=*/true>(max_update_time); + } if (mParcelOverlay) { @@ -2110,27 +2139,27 @@ S32 LLViewerRegion::getHttpResponderID() const return mImpl->mHttpResponderID; } -BOOL LLViewerRegion::pointInRegionGlobal(const LLVector3d &point_global) const +bool LLViewerRegion::pointInRegionGlobal(const LLVector3d &point_global) const { LLVector3 pos_region = getPosRegionFromGlobal(point_global); if (pos_region.mV[VX] < 0) { - return FALSE; + return false; } if (pos_region.mV[VX] >= mWidth) { - return FALSE; + return false; } if (pos_region.mV[VY] < 0) { - return FALSE; + return false; } if (pos_region.mV[VY] >= mWidth) { - return FALSE; + return false; } - return TRUE; + return true; } LLVector3 LLViewerRegion::getPosRegionFromGlobal(const LLVector3d &point_global) const @@ -2169,24 +2198,24 @@ bool LLViewerRegion::isAlive() return mAlive; } -BOOL LLViewerRegion::isOwnedSelf(const LLVector3& pos) +bool LLViewerRegion::isOwnedSelf(const LLVector3& pos) { if (mParcelOverlay) { return mParcelOverlay->isOwnedSelf(pos); } else { - return FALSE; + return false; } } // Owned by a group you belong to? (officer or member) -BOOL LLViewerRegion::isOwnedGroup(const LLVector3& pos) +bool LLViewerRegion::isOwnedGroup(const LLVector3& pos) { if (mParcelOverlay) { return mParcelOverlay->isOwnedGroup(pos); } else { - return FALSE; + return false; } } @@ -2231,7 +2260,7 @@ public: LLSD::array_iterator locs_it = locs.beginArray(), agents_it = agents.beginArray(); - BOOL has_agent_data = input["body"].has("AgentData"); + bool has_agent_data = input["body"].has("AgentData"); for(int i=0; locs_it != locs.endArray(); @@ -2299,7 +2328,7 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg) msg->getS16Fast(_PREHASH_Index, _PREHASH_You, agent_index); msg->getS16Fast(_PREHASH_Index, _PREHASH_Prey, target_index); - BOOL has_agent_data = msg->has(_PREHASH_AgentData); + bool has_agent_data = msg->has(_PREHASH_AgentData); S32 count = msg->getNumberOfBlocksFast(_PREHASH_Location); for(S32 i = 0; i < count; i++) { @@ -2414,7 +2443,60 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features) mSimulatorFeatures = sim_features; setSimulatorFeaturesReceived(true); - + + // WARNING: this is called from a coroutine, and flipping saved settings has a LOT of side effects, shuttle + // the work below back to the main loop + // + + // copy features to lambda in case the region is deleted before the lambda is executed + LLSD features = mSimulatorFeatures; + + auto work = [=]() + { + // if region has MaxTextureResolution, set max_texture_dimension settings, otherwise use default + if (features.has("MaxTextureResolution")) + { + S32 max_texture_resolution = features["MaxTextureResolution"].asInteger(); + gSavedSettings.setS32("max_texture_dimension_X", max_texture_resolution); + gSavedSettings.setS32("max_texture_dimension_Y", max_texture_resolution); + } + else + { + gSavedSettings.setS32("max_texture_dimension_X", 1024); + gSavedSettings.setS32("max_texture_dimension_Y", 1024); + } + + bool mirrors_enabled = false; + if (features.has("MirrorsEnabled")) + { + mirrors_enabled = features["MirrorsEnabled"].asBoolean(); + } + + gSavedSettings.setBOOL("RenderMirrors", mirrors_enabled); + + if (features.has("PBRTerrainEnabled")) + { + bool enabled = features["PBRTerrainEnabled"]; + gSavedSettings.setBOOL("RenderTerrainPBREnabled", enabled); + } + else + { + gSavedSettings.setBOOL("RenderTerrainPBREnabled", false); + } + + if (features.has("PBRMaterialSwatchEnabled")) + { + bool enabled = features["PBRMaterialSwatchEnabled"]; + gSavedSettings.setBOOL("UIPreviewMaterial", enabled); + } + else + { + gSavedSettings.setBOOL("UIPreviewMaterial", false); + } + }; + + + LLAppViewer::instance()->postToMainCoro(work); } //this is called when the parent is not cacheable. @@ -2672,7 +2754,14 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec void LLViewerRegion::cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry &override_data) { U32 local_id = override_data.mLocalId; - mImpl->mGLTFOverridesLLSD[local_id] = override_data; + if (override_data.mSides.size() > 0) + { // empty override means overrides were removed from this object + mImpl->mGLTFOverridesLLSD[local_id] = override_data; + } + else + { + mImpl->mGLTFOverridesLLSD.erase(local_id); + } } LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id) @@ -2805,7 +2894,7 @@ void LLViewerRegion::requestCacheMisses() } LLMessageSystem* msg = gMessageSystem; - BOOL start_new_message = TRUE; + bool start_new_message = true; S32 blocks = 0; //send requests for all cache-missed objects @@ -2817,7 +2906,7 @@ void LLViewerRegion::requestCacheMisses() msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - start_new_message = FALSE; + start_new_message = false; } msg->nextBlockFast(_PREHASH_ObjectData); @@ -2831,7 +2920,7 @@ void LLViewerRegion::requestCacheMisses() if (blocks >= 255) { sendReliableMessage(); - start_new_message = TRUE; + start_new_message = true; blocks = 0; } } @@ -2842,7 +2931,7 @@ void LLViewerRegion::requestCacheMisses() sendReliableMessage(); } - mCacheDirty = TRUE ; + mCacheDirty = true ; // LL_INFOS() << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << LL_ENDL; LLViewerStatsRecorder::instance().requestCacheMissesEvent(mCacheMissList.size()); @@ -2889,6 +2978,11 @@ void LLViewerRegion::dumpCache() // TODO - add overrides cache too } +void LLViewerRegion::clearVOCacheFromMemory() +{ + mImpl->mCacheMap.clear(); +} + void LLViewerRegion::unpackRegionHandshake() { LLMessageSystem *msg = gMessageSystem; @@ -2898,7 +2992,7 @@ void LLViewerRegion::unpackRegionHandshake() U8 sim_access; std::string sim_name; LLUUID sim_owner; - BOOL is_estate_manager; + bool is_estate_manager; F32 water_height; F32 billable_factor; LLUUID cache_id; @@ -2973,20 +3067,20 @@ void LLViewerRegion::unpackRegionHandshake() // Get the 4 textures for land msg->getUUID("RegionInfo", "TerrainDetail0", tmp_id); - changed |= (tmp_id != compp->getDetailTextureID(0)); - compp->setDetailTextureID(0, tmp_id); + changed |= (tmp_id != compp->getDetailAssetID(0)); + compp->setDetailAssetID(0, tmp_id); msg->getUUID("RegionInfo", "TerrainDetail1", tmp_id); - changed |= (tmp_id != compp->getDetailTextureID(1)); - compp->setDetailTextureID(1, tmp_id); + changed |= (tmp_id != compp->getDetailAssetID(1)); + compp->setDetailAssetID(1, tmp_id); msg->getUUID("RegionInfo", "TerrainDetail2", tmp_id); - changed |= (tmp_id != compp->getDetailTextureID(2)); - compp->setDetailTextureID(2, tmp_id); + changed |= (tmp_id != compp->getDetailAssetID(2)); + compp->setDetailAssetID(2, tmp_id); msg->getUUID("RegionInfo", "TerrainDetail3", tmp_id); - changed |= (tmp_id != compp->getDetailTextureID(3)); - compp->setDetailTextureID(3, tmp_id); + changed |= (tmp_id != compp->getDetailAssetID(3)); + compp->setDetailAssetID(3, tmp_id); // Get the start altitude and range values for land textures F32 tmp_f32; @@ -3446,7 +3540,7 @@ void LLViewerRegion::setInterestListMode(const std::string &new_mode) { mInterestListMode = new_mode; - if (mInterestListMode != std::string(IL_MODE_DEFAULT) && mInterestListMode != std::string(IL_MODE_360)) + if (mInterestListMode != IL_MODE_DEFAULT && mInterestListMode != IL_MODE_360) { LL_WARNS("360Capture") << "Region " << getRegionID() << " setInterestListMode() invalid interest list mode: " << mInterestListMode << ", setting to default" << LL_ENDL; @@ -3554,12 +3648,12 @@ void LLViewerRegion::showReleaseNotes() if (url.empty()) { // HACK haven't received the capability yet, we'll wait until // it arives. - mReleaseNotesRequested = TRUE; + mReleaseNotesRequested = true; return; } LLWeb::loadURL(url); - mReleaseNotesRequested = FALSE; + mReleaseNotesRequested = false; } std::string LLViewerRegion::getDescription() const @@ -3672,6 +3766,11 @@ void LLViewerRegion::applyCacheMiscExtras(LLViewerObject* obj) auto iter = mImpl->mGLTFOverridesLLSD.find(local_id); if (iter != mImpl->mGLTFOverridesLLSD.end()) { + // UUID can be inserted null, so backfill the UUID if it was left empty + if (iter->second.mObjectId.isNull()) + { + iter->second.mObjectId = obj->getID(); + } llassert(iter->second.mGLTFMaterial.size() == iter->second.mSides.size()); for (auto& side : iter->second.mGLTFMaterial) |