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

@@ -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");