diff options
Diffstat (limited to 'indra/newview/llviewerregion.cpp')
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 115 |
1 files changed, 108 insertions, 7 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 4a1dd1b8d6..870639c754 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -53,6 +53,7 @@ #include "llfloatergodtools.h" #include "llfloaterreporter.h" #include "llfloaterregioninfo.h" +#include "llgltfmateriallist.h" #include "llhttpnode.h" #include "llregioninfomodel.h" #include "llsdutil.h" @@ -221,6 +222,7 @@ public: LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation. LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation. std::set<U32> mNonCacheableCreatedList; //list of local ids of all non-cacheable objects + LLVOCacheEntry::vocache_gltf_overrides_map_t mGLTFOverridesJson; // for materials // time? // LRU info? @@ -722,6 +724,7 @@ static LLTrace::BlockTimerStatHandle FTM_SAVE_REGION_CACHE("Save Region Cache"); LLViewerRegion::~LLViewerRegion() { + LL_PROFILE_ZONE_SCOPED; mDead = TRUE; mImpl->mActiveSet.clear(); mImpl->mVisibleEntries.clear(); @@ -790,7 +793,10 @@ void LLViewerRegion::loadObjectCache() if(LLVOCache::instanceExists()) { - LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ; + LLVOCache & vocache = LLVOCache::instance(); + vocache.readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap); + vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesJson); + if (mImpl->mCacheMap.empty()) { mCacheDirty = TRUE; @@ -815,14 +821,18 @@ void LLViewerRegion::saveObjectCache() { const F32 start_time_threshold = 600.0f; //seconds bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file. - - LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled) ; + + LLVOCache & instance = LLVOCache::instance(); + + instance.writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled); + instance.writeGenericExtrasToCache(mHandle, mImpl->mCacheID, mImpl->mGLTFOverridesJson, mCacheDirty, removal_enabled); mCacheDirty = FALSE; } // Map of LLVOCacheEntry takes time to release, store map for cleanup on idle sRegionCacheCleanup.insert(mImpl->mCacheMap.begin(), mImpl->mCacheMap.end()); mImpl->mCacheMap.clear(); + // TODO - probably need to do the same for overrides cache } void LLViewerRegion::sendMessage() @@ -1150,6 +1160,8 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry, bool for_rendering) entry->setState(LLVOCacheEntry::INACTIVE); entry->removeOctreeEntry(); entry->setValid(FALSE); + + // TODO kill extras/material overrides cache too } //physically delete the cache entry @@ -1250,6 +1262,46 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const return mImpl ? mImpl->mVisibleGroups.size() : 0; } +void LLViewerRegion::updateReflectionProbes() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + const F32 probe_spacing = 32.f; + const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); + const F32 hover_height = 2.f; + + F32 start = probe_spacing * 0.5f; + + U32 grid_width = REGION_WIDTH_METERS / probe_spacing; + + mReflectionMaps.resize(grid_width * grid_width); + + F32 water_height = getWaterHeight(); + LLVector3 origin = getOriginAgent(); + + for (U32 i = 0; i < grid_width; ++i) + { + F32 x = i * probe_spacing + start; + for (U32 j = 0; j < grid_width; ++j) + { + F32 y = j * probe_spacing + start; + + U32 idx = i * grid_width + j; + + if (mReflectionMaps[idx].isNull()) + { + mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe(); + } + + LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); + probe_origin.mV[2] += hover_height; + probe_origin += origin; + + mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); + mReflectionMaps[idx]->mRadius = probe_radius; + } + } +} + void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry) { if(!sVOCacheCullingEnabled) @@ -1547,6 +1599,7 @@ void LLViewerRegion::lightIdleUpdate() void LLViewerRegion::idleUpdate(F32 max_update_time) { + LL_PROFILE_ZONE_SCOPED; LLTimer update_timer; F32 max_time; @@ -1650,6 +1703,10 @@ BOOL LLViewerRegion::isViewerCameraStatic() void LLViewerRegion::killInvisibleObjects(F32 max_time) { +#if 1 // TODO: kill this. This is ill-conceived, objects that aren't in the camera frustum should not be deleted from memory. + // because of this, every time you turn around the simulator sends a swarm of full object update messages from cache + // probe misses and objects have to be reloaded from scratch. From some reason, disabling this causes holes to + // appear in the scene when flying back and forth between regions if(!sVOCacheCullingEnabled) { return; @@ -1726,6 +1783,7 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time) } return; +#endif } void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list) @@ -1790,7 +1848,7 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry) LLViewerObject* obj = NULL; if(!entry->getEntry()->hasDrawable()) //not added to the rendering pipeline yet - { + { //add the object obj = gObjectList.processObjectUpdateFromCache(entry, this); if(obj) @@ -1820,6 +1878,9 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry) //should not hit here any more, but does not hurt either, just put it back to active list addActiveCacheEntry(entry); } + + loadCacheMiscExtras(entry->getLocalID()); + return obj; } @@ -2565,7 +2626,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB LL_DEBUGS("AnimatedObjects") << " got update for local_id " << local_id << LL_ENDL; dumpStack("AnimatedObjectsStack"); - // Update the cache entry + // Update the cache entry entry->updateEntry(crc, dp); decodeBoundingInfo(entry); @@ -2582,7 +2643,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB // Create new entry and add to map result = CACHE_UPDATE_ADDED; entry = new LLVOCacheEntry(local_id, crc, dp); - record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(0)); + record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(0)); mImpl->mCacheMap[local_id] = entry; @@ -2600,6 +2661,12 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec return result; } +void LLViewerRegion::cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry &override_data) +{ + U32 local_id = override_data.mLocalId; + mImpl->mGLTFOverridesJson[local_id] = override_data; +} + LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id) { if(!sVOCacheCullingEnabled) @@ -2624,7 +2691,7 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id, bool valid) } } return NULL; - } +} void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType cache_miss_type) { @@ -2694,6 +2761,9 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss entry->setValid(); decodeBoundingInfo(entry); + + //loadCacheMiscExtras(local_id, entry, crc); + return true; } else @@ -2808,6 +2878,7 @@ void LLViewerRegion::dumpCache() { LL_INFOS() << "Changes " << i << " " << change_bin[i] << LL_ENDL; } + // TODO - add overrides cache too } void LLViewerRegion::unpackRegionHandshake() @@ -3053,6 +3124,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("MapLayer"); capabilityNames.append("MapLayerGod"); capabilityNames.append("MeshUploadFlag"); + capabilityNames.append("ModifyMaterialParams"); capabilityNames.append("NavMeshGenerationStatus"); capabilityNames.append("NewFileAgentInventory"); capabilityNames.append("ObjectAnimation"); @@ -3095,6 +3167,8 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("UpdateSettingsAgentInventory"); capabilityNames.append("UpdateSettingsTaskInventory"); capabilityNames.append("UploadAgentProfileImage"); + capabilityNames.append("UpdateMaterialAgentInventory"); + capabilityNames.append("UpdateMaterialTaskInventory"); capabilityNames.append("UploadBakedTexture"); capabilityNames.append("UserInfo"); capabilityNames.append("ViewerAsset"); @@ -3580,3 +3654,30 @@ std::string LLViewerRegion::getSimHostName() return std::string("..."); } +void LLViewerRegion::loadCacheMiscExtras(U32 local_id) +{ + auto iter = mImpl->mGLTFOverridesJson.find(local_id); + if (iter != mImpl->mGLTFOverridesJson.end()) + { + LLGLTFMaterialList::loadCacheOverrides(iter->second); + } +} + +void LLViewerRegion::applyCacheMiscExtras(LLViewerObject* obj) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(obj); + + U32 local_id = obj->getLocalID(); + auto iter = mImpl->mGLTFOverridesJson.find(local_id); + if (iter != mImpl->mGLTFOverridesJson.end()) + { + llassert(iter->second.mGLTFMaterial.size() == iter->second.mSides.size()); + + for (auto& side : iter->second.mGLTFMaterial) + { + obj->setTEGLTFMaterialOverride(side.first, side.second); + } + } +} + |