From 4e577785ba1417cd9ef6742a33e818016697b508 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Fri, 21 Jan 2011 15:10:56 +0200 Subject: Partial fix #772: Large sculpt maps are deformed This is a partial fix for cases where the sculpt map is larger than 128x128, like in some old sculpted trees. This was done by content creators to beat bugs in old viewers. The sculpties still need a lod change to trigger a rebuild once they are fully decoded, and that doesn't always happen, because we abuse RenderVolumeLODFactor. Ported from Snowglobe2 (GPL) --- linden/indra/newview/llviewerimage.cpp | 13 ++++++++++--- linden/indra/newview/llvovolume.cpp | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index 671a359..a600dc5 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp @@ -1759,13 +1759,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) { @@ -1776,7 +1782,8 @@ void LLViewerImage::setCachedRawImage() mRawImage->scale(w >> i, h >> i) ; } mCachedRawImage = mRawImage ; - mCachedRawDiscardLevel = mRawDiscardLevel + i ; + mRawDiscardLevel += i ; + mCachedRawDiscardLevel = mRawDiscardLevel ; } } @@ -1784,7 +1791,7 @@ void LLViewerImage::checkCachedRawSculptImage() { if(mCachedRawImageReady && mCachedRawDiscardLevel > 0) { - if(mCachedRawImage->getWidth() * mCachedRawImage->getHeight() < MAX_CACHED_RAW_SCULPT_IMAGE_AREA) + if(getDiscardLevel() != 0) { mCachedRawImageReady = FALSE ; } diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 73ff860..632bca2 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp @@ -527,8 +527,8 @@ void LLVOVolume::updateTextureVirtualSize() } } - S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture - S32 current_discard = mSculptLevel; + S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture + S32 current_discard = getVolume() ? getVolume()->getSculptLevel() : -2 ; if (texture_discard >= 0 && //texture has some data available (texture_discard < current_discard || //texture has more data than last rebuild @@ -711,7 +711,7 @@ void LLVOVolume::sculpt() S8 sculpt_components = 0; const U8* sculpt_data = NULL; - S32 discard_level = mSculptTexture->getCachedRawImageLevel() ; + S32 discard_level = mSculptTexture->getDiscardLevel(); LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ; S32 max_discard = mSculptTexture->getMaxDiscardLevel(); -- cgit v1.1