diff options
author | Dave Parks <davep@lindenlab.com> | 2010-02-05 11:19:14 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2010-02-05 11:19:14 -0600 |
commit | 43ca4e104b613c95a1147751122f7ff007542e5c (patch) | |
tree | 62af085abb58aff625a806ef5edfd2c894daee93 /indra | |
parent | 92e07a0c5eb97ea4f839eaf824699d403ac56c6d (diff) |
EXT-4209 Fix for sculptie prims not updating geometry when texture is loaded.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llviewertexture.cpp | 63 | ||||
-rw-r--r-- | indra/newview/llviewertexture.h | 15 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 73 | ||||
-rw-r--r-- | indra/newview/llvovolume.h | 6 |
4 files changed, 134 insertions, 23 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 0ad269392d..06fdb2a3b2 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -496,7 +496,9 @@ void LLViewerTexture::init(bool firstinit) mAdditionalDecodePriority = 0.f ; mParcelMedia = NULL ; mNumFaces = 0 ; + mNumVolumes = 0; mFaceList.clear() ; + mVolumeList.clear(); } //virtual @@ -508,7 +510,7 @@ S8 LLViewerTexture::getType() const void LLViewerTexture::cleanup() { mFaceList.clear() ; - + mVolumeList.clear(); if(mGLTexturep) { mGLTexturep->cleanup(); @@ -661,6 +663,42 @@ S32 LLViewerTexture::getNumFaces() const return mNumFaces ; } + +//virtual +void LLViewerTexture::addVolume(LLVOVolume* volumep) +{ + if( mNumVolumes >= mVolumeList.size()) + { + mVolumeList.resize(2 * mNumVolumes + 1) ; + } + mVolumeList[mNumVolumes] = volumep ; + volumep->setIndexInTex(mNumVolumes) ; + mNumVolumes++ ; + mLastVolumeListUpdateTimer.reset() ; +} + +//virtual +void LLViewerTexture::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 LLViewerTexture::getNumVolumes() const +{ + return mNumVolumes ; +} + void LLViewerTexture::reorganizeFaceList() { static const F32 MAX_WAIT_TIME = 20.f; // seconds @@ -680,6 +718,27 @@ void LLViewerTexture::reorganizeFaceList() mFaceList.erase(mFaceList.begin() + mNumFaces, mFaceList.end()); } +void LLViewerTexture::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()); +} + + + //virtual void LLViewerTexture::switchToCachedImage() { @@ -1598,6 +1657,7 @@ void LLViewerFetchedTexture::updateVirtualSize() } mNeedsResetMaxVirtualSize = TRUE ; reorganizeFaceList() ; + reorganizeVolumeList(); } bool LLViewerFetchedTexture::updateFetch() @@ -3252,6 +3312,7 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() mNeedsResetMaxVirtualSize = TRUE ; reorganizeFaceList() ; + reorganizeVolumeList(); return mMaxVirtualSize ; } diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 79d9c4e7bb..85f03b5839 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -134,7 +134,9 @@ public: static S32 getIndexFromCategory(S32 category) ; static S32 getCategoryFromIndex(S32 index) ; - typedef std::vector<LLFace*> ll_face_list_t ; + typedef std::vector<LLFace*> ll_face_list_t; + typedef std::vector<LLVOVolume*> ll_volume_list_t; + protected: virtual ~LLViewerTexture(); @@ -178,6 +180,11 @@ public: S32 getNumFaces() const; const ll_face_list_t* getFaceList() const {return &mFaceList;} + virtual void addVolume(LLVOVolume* volumep); + virtual void removeVolume(LLVOVolume* volumep); + S32 getNumVolumes() const; + const ll_volume_list_t* getVolumeList() const { return &mVolumeList; } + void generateGLTexture() ; void destroyGLTexture() ; @@ -242,7 +249,7 @@ protected: void cleanup() ; void init(bool firstinit) ; void reorganizeFaceList() ; - + void reorganizeVolumeList() ; private: //note: do not make this function public. /*virtual*/ LLImageGL* getGLTexture() const ; @@ -269,6 +276,10 @@ protected: U32 mNumFaces ; LLFrameTimer mLastFaceListUpdateTimer ; + ll_volume_list_t mVolumeList; + U32 mNumVolumes; + LLFrameTimer mLastVolumeListUpdateTimer; + //do not use LLPointer here. LLViewerMediaTexture* mParcelMedia ; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 3cdf485d7d..25ed931fb5 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -192,6 +192,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re mMediaImplList.resize(getNumTEs()); mLastFetchedMediaVersion = -1; + mIndexInTex = 0; } LLVOVolume::~LLVOVolume() @@ -226,6 +227,11 @@ void LLVOVolume::markDead() { removeMediaImpl(i); } + + if (mSculptTexture.notNull()) + { + mSculptTexture->removeVolume(this); + } } LLViewerObject::markDead(); @@ -740,7 +746,9 @@ void LLVOVolume::updateTextureVirtualSize() { LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); LLUUID id = sculpt_params->getSculptTexture(); - mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + + updateSculptTexture(); + if (mSculptTexture.notNull()) { mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), @@ -929,35 +937,53 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail { mVolumeImpl->onSetVolume(volume_params, detail); } - + + updateSculptTexture(); + if (isSculpted()) { - mSculptTexture = LLViewerTextureManager::getFetchedTexture(volume_params.getSculptID(), TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + updateSculptTexture(); + if (mSculptTexture.notNull()) { - //ignore sculpt GL usage since bao fixed this in a separate branch - if (!gGLActive) - { - gGLActive = TRUE; - sculpt(); - gGLActive = FALSE; - } - else - { - sculpt(); - } + sculpt(); } } - else - { - mSculptTexture = NULL; - } return TRUE; } return FALSE; } +void LLVOVolume::updateSculptTexture() +{ + LLPointer<LLViewerFetchedTexture> old_sculpt = mSculptTexture; + + if (isSculpted()) + { + LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); + LLUUID id = sculpt_params->getSculptTexture(); + mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + } + 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() { @@ -1021,6 +1047,17 @@ 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 + for (S32 i = 0; i < mSculptTexture->getNumVolumes(); ++i) + { + LLVOVolume* volume = (*(mSculptTexture->getVolumeList()))[i]; + if (volume != this && volume->getVolume() == getVolume()) + { + gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY, FALSE); + volume->mSculptChanged = TRUE; + } + } } } diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index a287d34402..a8bb597f93 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -179,8 +179,10 @@ public: /*virtual*/ BOOL setMaterial(const U8 material); 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(); /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); @@ -303,7 +305,7 @@ private: LLPointer<LLViewerFetchedTexture> mLightTexture; media_list_t mMediaImplList; S32 mLastFetchedMediaVersion; // as fetched from the server, starts as -1 - + S32 mIndexInTex; // statics public: static F32 sLODSlopDistanceFactor;// Changing this to zero, effectively disables the LOD transition slop |