Added explicit texture reloading. Accessable in the 'tools' submenus for the agent, avatars, and selected objects.

This commit is contained in:
Shyotl
2012-12-02 17:06:54 -06:00
parent 8b19f82c0b
commit 0554ecae5c
9 changed files with 156 additions and 5 deletions

View File

@@ -1329,6 +1329,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
llassert(mCurrentDiscardLevel >= 0);
discard_level = mCurrentDiscardLevel;
}
discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel);
if (mTexName != 0 && discard_level == mCurrentDiscardLevel)
{
@@ -1586,7 +1587,18 @@ void LLImageGL::destroyGLTexture()
}
}
//force to invalidate the gl texture, most likely a sculpty texture
void LLImageGL::forceToInvalidateGLTexture()
{
if (mTexName != 0)
{
destroyGLTexture();
}
else
{
mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel.
}
}
//----------------------------------------------------------------------------

View File

@@ -119,6 +119,7 @@ public:
// Read back a raw image for this discard level, if it exists
BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok);
void destroyGLTexture();
void forceToInvalidateGLTexture();
void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
void setComponents(S8 ncomponents) { mComponents = ncomponents; }

View File

@@ -392,9 +392,7 @@ void LLDrawPoolWater::renderOpaqueLegacyWater()
if(sRefetch)
{
sRefetch = false;
gTextureList.deleteImage(gTextureList.findImage( mOpaqueWaterImagep->getID() ));
mOpaqueWaterImagep = NULL;
mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
((LLViewerFetchedTexture*)mOpaqueWaterImagep.get())->forceRefetch();
}
else
mOpaqueWaterImagep = mWaterImagep;

View File

@@ -264,6 +264,10 @@
#include "llagentui.h"
#include "llpathfindingmanager.h"
#include "lltexturecache.h"
#include "llvovolume.h"
#include <map>
#include "hippogridmanager.h"
using namespace LLOldEvents;
@@ -2265,6 +2269,105 @@ class LLObjectDerender : public view_listener_t
}
};
class LLTextureReloader
{
public:
~LLTextureReloader()
{
for(std::set< LLViewerFetchedTexture*>::iterator it=mTextures.begin();it!=mTextures.end();++it)
{
LLViewerFetchedTexture* img = *it;
const LLUUID& id = img->getID();
if(id.notNull() && id != IMG_DEFAULT && id != IMG_DEFAULT_AVATAR && img != LLViewerFetchedTexture::sDefaultImagep)
{
LLAppViewer::getTextureCache()->removeFromCache(id);
img->forceRefetch();
for (S32 i = 0; i < img->getNumVolumes(); ++i)
{
LLVOVolume* volume = (*(img->getVolumeList()))[i];
if (volume && volume->isSculpted() && !volume->isMesh())
volume->notifyMeshLoaded();
}
}
}
}
void addTexture(LLViewerTexture* texture)
{
if(!texture)
return;
const LLUUID& id = texture->getID();
if(id.notNull() && id != IMG_DEFAULT && id != IMG_DEFAULT_AVATAR && texture != LLViewerFetchedTexture::sDefaultImagep)
{
LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(texture);
if(img)
mTextures.insert(img);
}
}
private:
std::set< LLViewerFetchedTexture*> mTextures;
};
class LLAvatarReloadTextures : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() );
if(avatar)
{
LLAvatarPropertiesProcessor::getInstance()->sendAvatarTexturesRequest(avatar->getID());
LLTextureReloader texture_list;
for (U32 i = 0; i < LLVOAvatarDefines::TEX_NUM_INDICES; ++i)
{
if (LLVOAvatar::isIndexLocalTexture((ETextureIndex)i))
{
if(avatar->isSelf())
{
LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType((ETextureIndex)i);
U32 num_wearables = gAgentWearables.getWearableCount(wearable_type);
for (U32 wearable_index = 0; wearable_index < num_wearables; wearable_index++)
{
texture_list.addTexture(((LLVOAvatarSelf*)avatar)->getLocalTextureGL((ETextureIndex)i,wearable_index));
}
}
}
else
{
texture_list.addTexture(avatar->getTEImage((ETextureIndex)i));
}
}
}
return true;
}
};
class LLObjectReloadTextures : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
LLTextureReloader texture_list;
for (LLObjectSelection::valid_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_begin();
iter != LLSelectMgr::getInstance()->getSelection()->valid_end(); iter++)
{
LLViewerObject* object = (*iter)->getObject();
for (U8 i = 0; i < object->getNumTEs(); i++)
{
if((*iter)->isTESelected(i))
{
texture_list.addTexture(object->getTEImage(i));
}
if(object->isSculpted() && !object->isMesh())
{
LLSculptParams *sculpt_params = (LLSculptParams *)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
if(sculpt_params)
{
texture_list.addTexture(LLViewerTextureManager::getFetchedTexture(sculpt_params->getSculptTexture()));
}
}
}
}
return true;
}
};
//---------------------------------------------------------------------------
// Land pie menu
@@ -9468,6 +9571,8 @@ void initialize_menus()
addMenu(new LLObjectInspect(), "Object.Inspect");
// <dogmode> Visual mute, originally by Phox.
addMenu(new LLObjectDerender(), "Object.DERENDER");
addMenu(new LLAvatarReloadTextures(), "Avatar.ReloadTextures");
addMenu(new LLObjectReloadTextures(), "Object.ReloadTextures");
addMenu(new LLObjectExport(), "Object.Export");
addMenu(new LLObjectImport(), "Object.Import");
addMenu(new LLObjectImportUpload(), "Object.ImportUpload");

View File

@@ -1333,6 +1333,30 @@ void LLViewerFetchedTexture::cleanup()
mSavedRawDiscardLevel = -1;
}
void LLViewerFetchedTexture::forceRefetch()
{
bool needs_aux = mNeedsAux;
bool save_raw = mForceToSaveRawImage;
S32 raw_discard = mDesiredSavedRawDiscardLevel;
F32 raw_time = mKeptSavedRawImageTime;
callback_list_t callback_list = mLoadedCallbackList;
mLoadedCallbackList.clear();
LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
if(mGLTexturep)
mGLTexturep->forceToInvalidateGLTexture();
init(false);
mRawImage = NULL;
mAuxRawImage = NULL;
if(save_raw)
forceToSaveRawImage(raw_discard,raw_time);
for(callback_list_t::iterator iter = callback_list.begin();
iter != callback_list.end(); ++iter)
{
LLLoadedCallbackEntry *entryp = *iter;
setLoadedCallback(entryp->mCallback,entryp->mDesiredDiscard,entryp->mNeedsImageRaw,needs_aux,entryp->mUserData,entryp->mSourceCallbackList,entryp->mPaused);
}
}
void LLViewerFetchedTexture::setForSculpt()
{
static const S32 MAX_INTERVAL = 8 ; //frames

View File

@@ -504,6 +504,8 @@ public:
void setCanUseHTTP(bool can_use_http) {mCanUseHTTP = can_use_http;}
void forceToDeleteRequest();
void forceRefetch();
protected:
/*virtual*/ void switchToCachedImage();
S32 getCurrentDiscardLevelForFetching() ;

View File

@@ -46,6 +46,9 @@
<menu_item_call enabled="true" label="Derender" mouse_opaque="true" name="Derender">
<on_click function="Object.DERENDER" />
</menu_item_call>
<menu_item_call enabled="true" label="Reload" mouse_opaque="true" name="Reload Textures">
<on_click function="Avatar.ReloadTextures" />
</menu_item_call>
</pie_menu>
<menu_item_call enabled="false" label="Eject..." mouse_opaque="true" name="Eject...">
<on_click function="Avatar.Eject" />

View File

@@ -72,7 +72,10 @@
<menu_item_call enabled="false" hidden="false" label="Export" mouse_opaque="true" name="Export">
<on_click function="Object.Export" />
<on_enable function="Object.EnableExport" />
</menu_item_call>
</menu_item_call>
<menu_item_call enabled="true" label="Reload" mouse_opaque="true" name="Reload Textures">
<on_click function="Object.ReloadTextures" />
</menu_item_call>
</pie_menu>
<menu_item_call enabled="false" label="Mute" mouse_opaque="true" name="Object Mute">
<on_click function="Object.Mute" />

View File

@@ -86,6 +86,9 @@
</menu_item_call>
</pie_menu>
<pie_menu label="Tools &gt;" name="Tools &gt;">
<menu_item_call enabled="true" label="Reload" mouse_opaque="true" name="Reload Textures">
<on_click function="Avatar.ReloadTextures" />
</menu_item_call>
<menu_item_call enabled="true" hidden="false" label="Anims..." mouse_opaque="true"
name="Anims...">
<on_click function="Avatar.Anims" />