summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerregion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerregion.cpp')
-rwxr-xr-xindra/newview/llviewerregion.cpp108
1 files changed, 101 insertions, 7 deletions
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ad7321ca4b..402d03bc6e 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"
@@ -214,6 +215,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?
@@ -782,7 +784,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;
@@ -807,14 +812,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()
@@ -1142,6 +1151,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
@@ -1242,6 +1253,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)
@@ -1782,7 +1833,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)
@@ -1812,6 +1863,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;
}
@@ -2557,7 +2611,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);
@@ -2574,7 +2628,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;
@@ -2592,6 +2646,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)
@@ -2616,7 +2676,7 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id, bool valid)
}
}
return NULL;
- }
+}
void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type)
{
@@ -2690,6 +2750,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
@@ -2805,6 +2868,7 @@ void LLViewerRegion::dumpCache()
{
LL_INFOS() << "Changes " << i << " " << change_bin[i] << LL_ENDL;
}
+ // TODO - add overrides cache too
}
void LLViewerRegion::unpackRegionHandshake()
@@ -3050,6 +3114,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");
@@ -3092,6 +3157,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");
@@ -3470,3 +3537,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);
+ }
+ }
+}
+