diff options
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rw-r--r-- | indra/newview/llvocache.cpp | 137 |
1 files changed, 55 insertions, 82 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 86cfbb1d74..1dd149631a 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,6 +34,8 @@ #include "llviewerregion.h" #include "pipeline.h" +LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); + BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { return apr_file->read(src, n_bytes) == n_bytes ; @@ -53,13 +55,16 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), + mUpdateFlags(-1), mHitCount(0), mDupeCount(0), mCRCChangeCount(0), mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(TRUE), + mParentID(0) { mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); @@ -70,6 +75,7 @@ LLVOCacheEntry::LLVOCacheEntry() : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), + mUpdateFlags(-1), mHitCount(0), mDupeCount(0), mCRCChangeCount(0), @@ -77,7 +83,9 @@ LLVOCacheEntry::LLVOCacheEntry() mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(TRUE), + mParentID(0) { mDP.assignBuffer(mBuffer, 0); } @@ -85,10 +93,13 @@ LLVOCacheEntry::LLVOCacheEntry() LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), + mUpdateFlags(-1), mState(INACTIVE), mRepeatedVisCounter(0), mVisFrameRange(64), - mSceneContrib(0.f) + mSceneContrib(0.f), + mTouched(FALSE), + mParentID(0) { S32 size = -1; BOOL success; @@ -115,36 +126,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) } if(success) { - success = check_read(apr_file, &mState, sizeof(U32)); - } - if(success) - { - F32 ext[8]; - success = check_read(apr_file, (void*)ext, sizeof(F32) * 8); - - LLVector4a exts[2]; - exts[0].load4a(ext); - exts[1].load4a(&ext[4]); - - setSpatialExtents(exts[0], exts[1]); - } - if(success) - { - LLVector4 pos; - success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4)); - - LLVector4a pos_; - pos_.load4a(pos.mV); - setPositionGroup(pos_); - } - if(success) - { - F32 rad; - success = check_read(apr_file, &rad, sizeof(F32)); - setBinRadius(rad); - } - if(success) - { success = check_read(apr_file, &size, sizeof(S32)); // Corruption in the cache entries @@ -198,10 +179,8 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry) if(!entry && mDP.getBufferSize() > 0) { LLUUID fullid; - mDP.reset(); - mDP.unpackUUID(fullid, "ID"); - mDP.reset(); - + LLViewerObject::unpackUUID(&mDP, fullid, "ID"); + LLViewerObject* obj = gObjectList.findObject(fullid); if(obj && obj->mDrawable) { @@ -231,9 +210,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry) void LLVOCacheEntry::setState(U32 state) { - mState &= 0xffff0000; //clear the low 16 bits - state &= 0x0000ffff; //clear the high 16 bits; - mState |= state; + mState = state; if(getState() == ACTIVE) { @@ -300,6 +277,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP() void LLVOCacheEntry::recordHit() { + setTouched(); mHitCount++; } @@ -341,33 +319,6 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const } if(success) { - U32 state = mState & 0xffff0000; //only store the high 16 bits. - success = check_write(apr_file, (void*)&state, sizeof(U32)); - } - if(success) - { - const LLVector4a* exts = getSpatialExtents() ; - LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]); - success = check_write(apr_file, ext.mV, sizeof(LLVector4)); - if(success) - { - ext.set(exts[1][0], exts[1][1], exts[1][2], exts[1][3]); - success = check_write(apr_file, ext.mV, sizeof(LLVector4)); - } - } - if(success) - { - const LLVector4a pos_ = getPositionGroup() ; - LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]); - success = check_write(apr_file, pos.mV, sizeof(LLVector4)); - } - if(success) - { - F32 rad = getBinRadius(); - success = check_write(apr_file, (void*)&rad, sizeof(F32)); - } - if(success) - { S32 size = mDP.getBufferSize(); success = check_write(apr_file, (void*)&size, sizeof(S32)); @@ -402,6 +353,28 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool setVisible(); } +void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale) +{ + LLVector4a center, newMin, newMax; + center.load3(pos.mV); + LLVector4a size; + size.load3(scale.mV); + newMin.setSub(center, size); + newMax.setAdd(center, size); + + setPositionGroup(center); + setSpatialExtents(newMin, newMax); + setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); +} + +void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent) +{ + //LLVector4a old_pos = getPositionGroup(); + //parent->getPositionRegion() + (getPosition() * parent->getRotation()); + + shift(parent->getPositionGroup()); +} + //------------------------------------------------------------------- //LLVOCachePartition //------------------------------------------------------------------- @@ -409,8 +382,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) { mRegionp = regionp; mPartitionType = LLViewerRegion::PARTITION_VO_CACHE; - mVisitedTime = 0; - + new LLviewerOctreeGroup(mOctree); } @@ -477,12 +449,6 @@ S32 LLVOCachePartition::cull(LLCamera &camera) return 0; } - if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame()) - { - return 0; //already visited. - } - mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame(); - ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); //localize the camera @@ -599,13 +565,19 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) } } -void LLVOCache::removeCache(ELLPath location) +void LLVOCache::removeCache(ELLPath location, bool started) { + if(started) + { + removeCache(); + return; + } + if(mReadOnly) { llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl; return ; - } + } llinfos << "about to remove the object cache due to settings." << llendl ; @@ -628,10 +600,8 @@ void LLVOCache::removeCache() return ; } - llinfos << "about to remove the object cache due to some error." << llendl ; - std::string mask = "*"; - llinfos << "Removing cache at " << mObjectCacheDirName << llendl; + llinfos << "Removing object cache at " << mObjectCacheDirName << llendl; gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); clearCacheInMemory() ; @@ -938,7 +908,7 @@ void LLVOCache::purgeEntries(U32 size) mNumEntries = mHandleEntryMap.size() ; } -void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) +void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled) { if(!mEnabled) { @@ -1011,7 +981,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter) { - success = iter->second->writeToFile(&apr_file) ; + if(!removal_enabled || iter->second->isTouched()) + { + success = iter->second->writeToFile(&apr_file) ; + } } } } |