A bunch of supersize sculpty fixes by Thickbrick

This commit is contained in:
Siana Gearz
2011-02-16 20:59:00 +01:00
parent da61fc8195
commit 94c13d3131
5 changed files with 208 additions and 34 deletions

View File

@@ -61,6 +61,7 @@
#include "llappviewer.h"
#include "llface.h"
#include "llviewercamera.h"
#include "llvovolume.h"
// <edit>
#include "llimagemetadatareader.h"
@@ -357,6 +358,11 @@ void LLViewerImage::init(bool firstinit)
mDesiredSavedRawDiscardLevel = -1 ;
mCanUseHTTP = true; //default on if cap/settings allows us
mNumFaces = 0 ;
mNumVolumes = 0;
mFaceList.clear() ;
mVolumeList.clear();
}
// virtual
@@ -393,6 +399,7 @@ LLViewerImage::~LLViewerImage()
void LLViewerImage::cleanup()
{
mFaceList.clear() ;
mVolumeList.clear();
for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
iter != mLoadedCallbackList.end(); )
{
@@ -753,19 +760,19 @@ void LLViewerImage::updateVirtualSize()
{
addTextureStats(0.f, FALSE) ;//reset
}
if(mFaceList.size() > 0)
for(U32 i = 0 ; i < mNumFaces ; i++)
{
for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter)
LLFace* facep = mFaceList[i] ;
if(facep->getDrawable()->isRecentlyVisible())
{
LLFace* facep = *iter ;
if(facep->getDrawable()->isRecentlyVisible())
{
addTextureStats(facep->getVirtualSize()) ;
setAdditionalDecodePriority(facep->getImportanceToCamera()) ;
}
}
addTextureStats(facep->getVirtualSize()) ;
setAdditionalDecodePriority(facep->getImportanceToCamera()) ;
}
}
mNeedsResetMaxVirtualSize = TRUE ;
reorganizeFaceList();
reorganizeVolumeList();
#endif
}
void LLViewerImage::scaleDown()
@@ -1755,13 +1762,19 @@ void LLViewerImage::setCachedRawImage()
if(mForSculpt)
{
max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA ;
// Even though we don't use the full pixel size, we want to decode up to discard 0,
// because some legacy sculpts are weird like that.
mCachedRawImageReady = !mRawDiscardLevel ;
}
else
{
mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)) ;
}
while(((w >> i) * (h >> i)) > max_size)
{
++i ;
}
mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)) ;
if(i)
{
@@ -1772,7 +1785,8 @@ void LLViewerImage::setCachedRawImage()
mRawImage->scale(w >> i, h >> i) ;
}
mCachedRawImage = mRawImage ;
mCachedRawDiscardLevel = mRawDiscardLevel + i ;
mRawDiscardLevel += i ;
mCachedRawDiscardLevel = mRawDiscardLevel ;
}
}
@@ -1780,7 +1794,7 @@ void LLViewerImage::checkCachedRawSculptImage()
{
if(mCachedRawImageReady && mCachedRawDiscardLevel > 0)
{
if(mCachedRawImage->getWidth() * mCachedRawImage->getHeight() < MAX_CACHED_RAW_SCULPT_IMAGE_AREA)
if(getDiscardLevel() != 0)
{
mCachedRawImageReady = FALSE ;
}
@@ -1806,11 +1820,111 @@ void LLViewerImage::setForSculpt()
checkCachedRawSculptImage() ;
}
//virtual
void LLViewerImage::addFace(LLFace* facep)
{
mFaceList.push_back(facep) ;
if(mNumFaces >= mFaceList.size())
{
mFaceList.resize(2 * mNumFaces + 1) ;
}
mFaceList[mNumFaces] = facep ;
facep->setIndexInTex(mNumFaces) ;
mNumFaces++ ;
mLastFaceListUpdateTimer.reset() ;
}
void LLViewerImage::removeFace(LLFace* facep)
//virtual
void LLViewerImage::removeFace(LLFace* facep)
{
mFaceList.remove(facep) ;
if(mNumFaces > 1)
{
S32 index = facep->getIndexInTex() ;
mFaceList[index] = mFaceList[--mNumFaces] ;
mFaceList[index]->setIndexInTex(index) ;
}
else
{
mFaceList.clear() ;
mNumFaces = 0 ;
}
mLastFaceListUpdateTimer.reset() ;
}
S32 LLViewerImage::getNumFaces() const
{
return mNumFaces ;
}
//virtual
void LLViewerImage::addVolume(LLVOVolume* volumep)
{
if( mNumVolumes >= mVolumeList.size())
{
mVolumeList.resize(2 * mNumVolumes + 1) ;
}
mVolumeList[mNumVolumes] = volumep ;
volumep->setIndexInTex(mNumVolumes) ;
mNumVolumes++ ;
mLastVolumeListUpdateTimer.reset() ;
}
//virtual
void LLViewerImage::removeVolume(LLVOVolume* volumep)
{
if(mNumVolumes > 1)
{
S32 index = volumep->getIndexInTex() ;
mVolumeList[index] = mVolumeList[--mNumVolumes] ;
mVolumeList[index]->setIndexInTex(index) ;
}
else
{
mVolumeList.clear() ;
mNumVolumes = 0 ;
}
mLastVolumeListUpdateTimer.reset() ;
}
S32 LLViewerImage::getNumVolumes() const
{
return mNumVolumes ;
}
void LLViewerImage::reorganizeFaceList()
{
static const F32 MAX_WAIT_TIME = 20.f; // seconds
static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ;
if(mNumFaces + MAX_EXTRA_BUFFER_SIZE > mFaceList.size())
{
return ;
}
if(mLastFaceListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME)
{
return ;
}
mLastFaceListUpdateTimer.reset() ;
mFaceList.erase(mFaceList.begin() + mNumFaces, mFaceList.end());
}
void LLViewerImage::reorganizeVolumeList()
{
static const F32 MAX_WAIT_TIME = 20.f; // seconds
static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ;
if(mNumVolumes + MAX_EXTRA_BUFFER_SIZE > mVolumeList.size())
{
return ;
}
if(mLastVolumeListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME)
{
return ;
}
mLastVolumeListUpdateTimer.reset() ;
mVolumeList.erase(mVolumeList.begin() + mNumVolumes, mVolumeList.end());
}