From 8a2232bda799babc38552df3be27343166a15c5e Mon Sep 17 00:00:00 2001 From: thickbrick Date: Fri, 13 May 2011 18:50:40 +0300 Subject: Refix #772: Rebuild all volumes that use a sculpt image when that image has more data Previous fix was lost in merge of 8431725c0bf08da2b909cefe2f3ecfb43a2aecad --- linden/indra/newview/llface.cpp | 1 + linden/indra/newview/llface.h | 2 +- linden/indra/newview/llvovolume.cpp | 54 ++++++++++++++++++++++++++++--------- linden/indra/newview/llvovolume.h | 4 +-- 4 files changed, 45 insertions(+), 16 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llface.cpp b/linden/indra/newview/llface.cpp index aa8cd15..cf681fa 100644 --- a/linden/indra/newview/llface.cpp +++ b/linden/indra/newview/llface.cpp @@ -159,6 +159,7 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mIndicesIndex = 0; mTexture = NULL; mTEOffset = -1; + mIndexInTex = 0; setDrawable(drawablep); mVObjp = objp; diff --git a/linden/indra/newview/llface.h b/linden/indra/newview/llface.h index e31b93f..f870370 100644 --- a/linden/indra/newview/llface.h +++ b/linden/indra/newview/llface.h @@ -228,7 +228,7 @@ private: U16 mGeomIndex; // index into draw pool U32 mIndicesCount; U32 mIndicesIndex; // index into draw pool for indices (yeah, I know!) - S32 mIndexInTex ; + S32 mIndexInTex ; // index of this face in the texture's face list //previous rebuild's geometry info U16 mLastGeomCount; diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 4a53d4e..8d5bfb4 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp @@ -93,7 +93,6 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re mRelativeXformInvTrans.setIdentity(); mLOD = MIN_LOD; - mSculptLevel = -2; mTextureAnimp = NULL; mVObjRadius = LLVector3(1,1,0.5f).length(); mNumFaces = 0; @@ -507,9 +506,8 @@ void LLVOVolume::updateTextureVirtualSize() if (isSculpted()) { - LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); - LLUUID id = sculpt_params->getSculptTexture(); - mSculptTexture = gImageList.getImage(id); + updateSculptTexture(); + if (mSculptTexture.notNull()) { mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), @@ -532,14 +530,14 @@ 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 current_discard < 0)) //no previous rebuild { - markForUpdate(FALSE); + gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); mSculptChanged = TRUE; } @@ -687,19 +685,17 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail mVolumeImpl->onSetVolume(volume_params, detail); } + updateSculptTexture(); if (isSculpted()) { - mSculptTexture = gImageList.getImage(volume_params.getSculptID()); if (mSculptTexture.notNull()) { sculpt(); - mSculptLevel = getVolume()->getSculptLevel(); mSculptSurfaceArea = getVolume()->sculptGetSurfaceArea(); } } else { - mSculptTexture = NULL; mSculptSurfaceArea = 0.0; } @@ -708,6 +704,38 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail return FALSE; } + +void LLVOVolume::updateSculptTexture() +{ + LLPointer old_sculpt = mSculptTexture; + if (isSculpted()) + { + LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); + LLUUID id = sculpt_params->getSculptTexture(); + if (id.notNull()) + { + mSculptTexture = gImageList.getImage(id); + } + } + else + { + mSculptTexture = NULL; + } + + if (mSculptTexture != old_sculpt) + { + if (old_sculpt.notNull()) + { + old_sculpt->removeVolume(this); + } + if (mSculptTexture.notNull()) + { + mSculptTexture->addVolume(this); + } + } +} + + // sculpt replaces generate() for sculpted surfaces void LLVOVolume::sculpt() { @@ -718,7 +746,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(); @@ -762,7 +790,7 @@ void LLVOVolume::sculpt() } getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level); - /*//notify rebuild any other VOVolumes that reference this sculpty volume + //notify rebuild any other VOVolumes that reference this sculpty volume for (S32 i = 0; i < mSculptTexture->getNumVolumes(); ++i) { LLVOVolume* volume = (*(mSculptTexture->getVolumeList()))[i]; @@ -770,7 +798,7 @@ void LLVOVolume::sculpt() { gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY, FALSE); } - }*/ + } } } diff --git a/linden/indra/newview/llvovolume.h b/linden/indra/newview/llvovolume.h index 7fba28c..2da1d7a 100644 --- a/linden/indra/newview/llvovolume.h +++ b/linden/indra/newview/llvovolume.h @@ -171,6 +171,7 @@ public: void setTexture(const S32 face); S32 getIndexInTex() const {return mIndexInTex ;} /*virtual*/ BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false); + void updateSculptTexture(); void setIndexInTex(S32 index) { mIndexInTex = index ;} void sculpt(); void updateRelativeXform(); @@ -232,7 +233,6 @@ private: LLFrameTimer mTextureUpdateTimer; S32 mLOD; BOOL mLODChanged; - S32 mSculptLevel; BOOL mSculptChanged; LLMatrix4 mRelativeXform; LLMatrix3 mRelativeXformInvTrans; @@ -240,7 +240,7 @@ private: F32 mVObjRadius; LLVolumeInterface *mVolumeImpl; LLPointer mSculptTexture; - S32 mIndexInTex; + S32 mIndexInTex; // index of this volume in the texture's volume list // statics public: -- cgit v1.1