summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/CMakeLists.txt21
-rwxr-xr-xindra/newview/llagentwearables.cpp120
-rwxr-xr-xindra/newview/llagentwearables.h49
-rwxr-xr-xindra/newview/llappearancemgr.cpp28
-rwxr-xr-xindra/newview/llappearancemgr.h1
-rw-r--r--indra/newview/llassetuploadresponders.cpp2
-rwxr-xr-xindra/newview/llavatariconctrl.cpp2
-rw-r--r--indra/newview/lldriverparam.cpp17
-rw-r--r--indra/newview/llfloaterauction.cpp1
-rw-r--r--indra/newview/llfloateravatartextures.cpp5
-rw-r--r--indra/newview/llgroupiconctrl.cpp1
-rw-r--r--indra/newview/llinventorybridge.cpp6
-rw-r--r--indra/newview/llinventorybridge.h8
-rw-r--r--indra/newview/llinventoryicon.cpp183
-rw-r--r--indra/newview/llinventoryicon.h102
-rw-r--r--indra/newview/lllocalbitmaps.cpp4
-rw-r--r--indra/newview/lllocalbitmaps.h1
-rw-r--r--indra/newview/lllocaltextureobject.cpp212
-rw-r--r--indra/newview/lllocaltextureobject.h87
-rw-r--r--indra/newview/llpanelclassified.cpp1
-rw-r--r--indra/newview/llpaneleditwearable.cpp10
-rw-r--r--indra/newview/llpaneleditwearable.h10
-rw-r--r--indra/newview/llpostcard.cpp1
-rw-r--r--indra/newview/llsidepanelappearance.cpp10
-rw-r--r--indra/newview/llsidepanelappearance.h8
-rw-r--r--indra/newview/lltexglobalcolor.cpp152
-rw-r--r--indra/newview/lltexglobalcolor.h83
-rw-r--r--indra/newview/lltexlayer.cpp2508
-rw-r--r--indra/newview/lltexlayer.h380
-rw-r--r--indra/newview/lltexlayerparams.cpp568
-rw-r--r--indra/newview/lltexlayerparams.h193
-rwxr-xr-xindra/newview/lltextureview.cpp4
-rw-r--r--indra/newview/llviewerjoint.h20
-rwxr-xr-xindra/newview/llviewerjointmesh.cpp4
-rwxr-xr-xindra/newview/llviewerjointmesh.h6
-rw-r--r--indra/newview/llviewershadermgr.h1
-rwxr-xr-xindra/newview/llviewerstats.cpp2
-rw-r--r--indra/newview/llviewertexlayer.cpp791
-rw-r--r--indra/newview/llviewertexlayer.h172
-rw-r--r--indra/newview/llviewertexture.cpp25
-rwxr-xr-xindra/newview/llviewertexture.h48
-rw-r--r--indra/newview/llviewervisualparam.cpp164
-rw-r--r--indra/newview/llviewervisualparam.h109
-rw-r--r--indra/newview/llviewerwearable.cpp900
-rw-r--r--indra/newview/llviewerwearable.h116
-rwxr-xr-xindra/newview/llvoavatar.cpp171
-rwxr-xr-xindra/newview/llvoavatar.h69
-rw-r--r--indra/newview/llvoavatardefines.cpp262
-rw-r--r--indra/newview/llvoavatardefines.h228
-rwxr-xr-xindra/newview/llvoavatarself.cpp65
-rwxr-xr-xindra/newview/llvoavatarself.h18
-rw-r--r--indra/newview/llwearablelist.cpp24
-rw-r--r--indra/newview/llwearablelist.h12
-rw-r--r--indra/newview/llwearabletype.cpp159
-rw-r--r--indra/newview/llwearabletype.h76
55 files changed, 2307 insertions, 5913 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index ff3fb0038c..a40f7cd3d3 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -302,7 +302,6 @@ set(viewer_SOURCE_FILES
llinventorybridge.cpp
llinventoryfilter.cpp
llinventoryfunctions.cpp
- llinventoryicon.cpp
llinventoryitemslist.cpp
llinventorylistitem.cpp
llinventorymodel.cpp
@@ -316,7 +315,6 @@ set(viewer_SOURCE_FILES
lllistcontextmenu.cpp
lllistview.cpp
lllocalbitmaps.cpp
- lllocaltextureobject.cpp
lllocationhistory.cpp
lllocationinputctrl.cpp
lllogchat.cpp
@@ -495,9 +493,6 @@ set(viewer_SOURCE_FILES
llsyswellwindow.cpp
llteleporthistory.cpp
llteleporthistorystorage.cpp
- lltexglobalcolor.cpp
- lltexlayer.cpp
- lltexlayerparams.cpp
lltextureatlas.cpp
lltextureatlasmanager.cpp
lltexturecache.cpp
@@ -595,18 +590,18 @@ set(viewer_SOURCE_FILES
llviewershadermgr.cpp
llviewerstats.cpp
llviewerstatsrecorder.cpp
+ llviewertexlayer.cpp
llviewertexteditor.cpp
llviewertexture.cpp
llviewertextureanim.cpp
llviewertexturelist.cpp
llviewerthrottle.cpp
- llviewervisualparam.cpp
+ llviewerwearable.cpp
llviewerwindow.cpp
llviewerwindowlistener.cpp
llvlcomposition.cpp
llvlmanager.cpp
llvoavatar.cpp
- llvoavatardefines.cpp
llvoavatarself.cpp
llvocache.cpp
llvograss.cpp
@@ -629,7 +624,6 @@ set(viewer_SOURCE_FILES
llwaterparamset.cpp
llwearableitemslist.cpp
llwearablelist.cpp
- llwearabletype.cpp
llweb.cpp
llwebprofile.cpp
llwebsharing.cpp
@@ -877,7 +871,6 @@ set(viewer_HEADER_FILES
llinventorybridge.h
llinventoryfilter.h
llinventoryfunctions.h
- llinventoryicon.h
llinventoryitemslist.h
llinventorylistitem.h
llinventorymodel.h
@@ -892,7 +885,6 @@ set(viewer_HEADER_FILES
lllistcontextmenu.h
lllistview.h
lllocalbitmaps.h
- lllocaltextureobject.h
lllocationhistory.h
lllocationinputctrl.h
lllogchat.h
@@ -1062,9 +1054,6 @@ set(viewer_HEADER_FILES
lltable.h
llteleporthistory.h
llteleporthistorystorage.h
- lltexglobalcolor.h
- lltexlayer.h
- lltexlayerparams.h
lltextureatlas.h
lltextureatlasmanager.h
lltexturecache.h
@@ -1163,18 +1152,18 @@ set(viewer_HEADER_FILES
llviewershadermgr.h
llviewerstats.h
llviewerstatsrecorder.h
+ llviewertexlayer.h
llviewertexteditor.h
llviewertexture.h
llviewertextureanim.h
llviewertexturelist.h
llviewerthrottle.h
- llviewervisualparam.h
+ llviewerwearable.h
llviewerwindow.h
llviewerwindowlistener.h
llvlcomposition.h
llvlmanager.h
llvoavatar.h
- llvoavatardefines.h
llvoavatarself.h
llvocache.h
llvograss.h
@@ -1197,7 +1186,6 @@ set(viewer_HEADER_FILES
llwaterparamset.h
llwearableitemslist.h
llwearablelist.h
- llwearabletype.h
llweb.h
llwebprofile.h
llwebsharing.h
@@ -1834,6 +1822,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${LLPHYSICS_LIBRARIES}
${LLPHYSICSEXTENSIONS_LIBRARIES}
${TCMALLOC_LIBRARIES}
+ ${LLAPPEARANCE_LIBRARIES}
)
if (USE_KDU)
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index e44b27c6af..e4f02b9f0b 100755
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -47,7 +47,7 @@
#include "lltooldraganddrop.h"
#include "llviewerregion.h"
#include "llvoavatarself.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
#include "llwearablelist.h"
#include <boost/scoped_ptr.hpp>
@@ -82,7 +82,7 @@ class LLWearAndEditCallback : public LLInventoryCallback
// wearable type stored in asset is some other value.
// Calling this function whenever a wearable is added to increase visibility if this problem
// turns up in other inventories.
-void checkWearableAgainstInventory(LLWearable *wearable)
+void checkWearableAgainstInventory(LLViewerWearable *wearable)
{
if (wearable->getItemID().isNull())
return;
@@ -119,7 +119,7 @@ void LLAgentWearables::dump()
llinfos << "Type: " << i << " count " << count << llendl;
for (U32 j=0; j<count; j++)
{
- LLWearable* wearable = getWearable((LLWearableType::EType)i,j);
+ LLViewerWearable* wearable = getWearable((LLWearableType::EType)i,j);
if (wearable == NULL)
{
llinfos << " " << j << " NULL wearable" << llendl;
@@ -213,7 +213,7 @@ LLAgentWearables::sendAgentWearablesUpdateCallback::~sendAgentWearablesUpdateCal
* @param todo Bitmask of actions to take on completion.
*/
LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback(
- LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLWearable* wearable, U32 todo) :
+ LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLViewerWearable* wearable, U32 todo) :
mType(type),
mIndex(index),
mWearable(wearable),
@@ -265,7 +265,7 @@ void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& i
void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::EType type,
const U32 index,
const LLUUID& item_id,
- LLWearable* wearable)
+ LLViewerWearable* wearable)
{
llinfos << "type " << type << " index " << index << " item " << item_id.asString() << llendl;
@@ -312,7 +312,7 @@ void LLAgentWearables::sendAgentWearablesUpdate()
{
for (U32 index=0; index < getWearableCount((LLWearableType::EType)type); ++index)
{
- LLWearable* wearable = getWearable((LLWearableType::EType)type,index);
+ LLViewerWearable* wearable = getWearable((LLWearableType::EType)type,index);
if (wearable)
{
if (wearable->getItemID().isNull())
@@ -354,7 +354,7 @@ void LLAgentWearables::sendAgentWearablesUpdate()
U8 type_u8 = (U8)type;
gMessageSystem->addU8Fast(_PREHASH_WearableType, type_u8);
- LLWearable* wearable = getWearable((LLWearableType::EType)type, 0);
+ LLViewerWearable* wearable = getWearable((LLWearableType::EType)type, 0);
if (wearable)
{
//llinfos << "Sending wearable " << wearable->getName() << llendl;
@@ -382,14 +382,14 @@ void LLAgentWearables::sendAgentWearablesUpdate()
void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32 index, BOOL send_update,
const std::string new_name)
{
- LLWearable* old_wearable = getWearable(type, index);
+ LLViewerWearable* old_wearable = getWearable(type, index);
if(!old_wearable) return;
bool name_changed = !new_name.empty() && (new_name != old_wearable->getName());
if (name_changed || old_wearable->isDirty() || old_wearable->isOldVersion())
{
LLUUID old_item_id = old_wearable->getItemID();
- LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
- new_wearable->setItemID(old_item_id); // should this be in LLWearable::copyDataFrom()?
+ LLViewerWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
+ new_wearable->setItemID(old_item_id); // should this be in LLViewerWearable::copyDataFrom()?
setWearable(type,index,new_wearable);
// old_wearable may still be referred to by other inventory items. Revert
@@ -465,7 +465,7 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
llwarns << "LLAgent::saveWearableAs() not copyable." << llendl;
return;
}
- LLWearable* old_wearable = getWearable(type, index);
+ LLViewerWearable* old_wearable = getWearable(type, index);
if (!old_wearable)
{
llwarns << "LLAgent::saveWearableAs() no old wearable." << llendl;
@@ -480,7 +480,7 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
}
std::string trunc_name(new_name);
LLStringUtil::truncate(trunc_name, DB_INV_ITEM_NAME_STR_LEN);
- LLWearable* new_wearable = LLWearableList::instance().createCopy(
+ LLViewerWearable* new_wearable = LLWearableList::instance().createCopy(
old_wearable,
trunc_name);
LLPointer<LLInventoryCallback> cb =
@@ -518,7 +518,7 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
void LLAgentWearables::revertWearable(const LLWearableType::EType type, const U32 index)
{
- LLWearable* wearable = getWearable(type, index);
+ LLViewerWearable* wearable = getWearable(type, index);
llassert(wearable);
if (wearable)
{
@@ -553,13 +553,13 @@ void LLAgentWearables::setWearableName(const LLUUID& item_id, const std::string&
LLUUID curr_item_id = getWearableItemID((LLWearableType::EType)i,j);
if (curr_item_id == item_id)
{
- LLWearable* old_wearable = getWearable((LLWearableType::EType)i,j);
+ LLViewerWearable* old_wearable = getWearable((LLWearableType::EType)i,j);
llassert(old_wearable);
if (!old_wearable) continue;
std::string old_name = old_wearable->getName();
old_wearable->setName(new_name);
- LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
+ LLViewerWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
new_wearable->setItemID(item_id);
LLInventoryItem* item = gInventory.getItem(item_id);
if (item)
@@ -640,14 +640,14 @@ LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::ETyp
return item;
}
-const LLWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id) const
+const LLViewerWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id) const
{
const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id);
for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{
for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
{
- const LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
+ const LLViewerWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{
return curr_wearable;
@@ -657,14 +657,14 @@ const LLWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id)
return NULL;
}
-LLWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id)
+LLViewerWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id)
{
const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id);
for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{
for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
{
- LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
+ LLViewerWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{
return curr_wearable;
@@ -674,13 +674,13 @@ LLWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id)
return NULL;
}
-LLWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id)
+LLViewerWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id)
{
for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{
for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
{
- LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
+ LLViewerWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getAssetID() == asset_id))
{
return curr_wearable;
@@ -705,7 +705,7 @@ BOOL LLAgentWearables::selfHasWearable(LLWearableType::EType type)
return (gAgentWearables.getWearableCount(type) > 0);
}
-LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index)
+LLViewerWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index)
{
wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end())
@@ -723,10 +723,10 @@ LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32
}
}
-void LLAgentWearables::setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable)
+void LLAgentWearables::setWearable(const LLWearableType::EType type, U32 index, LLViewerWearable *wearable)
{
- LLWearable *old_wearable = getWearable(type,index);
+ LLViewerWearable *old_wearable = getWearable(type,index);
if (!old_wearable)
{
pushWearable(type,wearable);
@@ -753,7 +753,7 @@ void LLAgentWearables::setWearable(const LLWearableType::EType type, U32 index,
}
}
-U32 LLAgentWearables::pushWearable(const LLWearableType::EType type, LLWearable *wearable)
+U32 LLAgentWearables::pushWearable(const LLWearableType::EType type, LLViewerWearable *wearable)
{
if (wearable == NULL)
{
@@ -771,7 +771,7 @@ U32 LLAgentWearables::pushWearable(const LLWearableType::EType type, LLWearable
return MAX_CLOTHING_PER_TYPE;
}
-void LLAgentWearables::wearableUpdated(LLWearable *wearable)
+void LLAgentWearables::wearableUpdated(LLViewerWearable *wearable)
{
gAgentAvatarp->wearableUpdated(wearable->getType(), FALSE);
wearable->refreshName();
@@ -794,7 +794,7 @@ void LLAgentWearables::wearableUpdated(LLWearable *wearable)
}
-void LLAgentWearables::popWearable(LLWearable *wearable)
+void LLAgentWearables::popWearable(LLViewerWearable *wearable)
{
if (wearable == NULL)
{
@@ -813,7 +813,7 @@ void LLAgentWearables::popWearable(LLWearable *wearable)
void LLAgentWearables::popWearable(const LLWearableType::EType type, U32 index)
{
- LLWearable *wearable = getWearable(type, index);
+ LLViewerWearable *wearable = getWearable(type, index);
if (wearable)
{
mWearableDatas[type].erase(mWearableDatas[type].begin() + index);
@@ -825,7 +825,7 @@ void LLAgentWearables::popWearable(const LLWearableType::EType type, U32 index)
}
}
-U32 LLAgentWearables::getWearableIndex(const LLWearable *wearable) const
+U32 LLAgentWearables::getWearableIndex(const LLViewerWearable *wearable) const
{
if (wearable == NULL)
{
@@ -851,7 +851,7 @@ U32 LLAgentWearables::getWearableIndex(const LLWearable *wearable) const
return MAX_CLOTHING_PER_TYPE;
}
-const LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index) const
+const LLViewerWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index) const
{
wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end())
@@ -869,7 +869,7 @@ const LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type
}
}
-LLWearable* LLAgentWearables::getTopWearable(const LLWearableType::EType type)
+LLViewerWearable* LLAgentWearables::getTopWearable(const LLWearableType::EType type)
{
U32 count = getWearableCount(type);
if ( count == 0)
@@ -880,7 +880,7 @@ LLWearable* LLAgentWearables::getTopWearable(const LLWearableType::EType type)
return getWearable(type, count-1);
}
-LLWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type)
+LLViewerWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type)
{
if (getWearableCount(type) == 0)
{
@@ -920,7 +920,7 @@ U32 LLAgentWearables::itemUpdatePendingCount() const
const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type, U32 index) const
{
- const LLWearable *wearable = getWearable(type,index);
+ const LLViewerWearable *wearable = getWearable(type,index);
if (wearable)
return wearable->getItemID();
else
@@ -929,7 +929,7 @@ const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type, U32
const LLUUID LLAgentWearables::getWearableAssetID(LLWearableType::EType type, U32 index) const
{
- const LLWearable *wearable = getWearable(type,index);
+ const LLViewerWearable *wearable = getWearable(type,index);
if (wearable)
return wearable->getAssetID();
else
@@ -1012,7 +1012,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
gMessageSystem->getUUIDFast(_PREHASH_WearableData, _PREHASH_AssetID, asset_id, i);
if (asset_id.isNull())
{
- LLWearable::removeFromAvatar(type, FALSE);
+ LLViewerWearable::removeFromAvatar(type, FALSE);
}
else
{
@@ -1058,7 +1058,7 @@ void LLAgentWearables::recoverMissingWearable(const LLWearableType::EType type,
// Try to recover by replacing missing wearable with a new one.
LLNotificationsUtil::add("ReplacedMissingWearable");
lldebugs << "Wearable " << LLWearableType::getTypeLabel(type) << " could not be downloaded. Replaced inventory item with default wearable." << llendl;
- LLWearable* new_wearable = LLWearableList::instance().createNewWearable(type);
+ LLViewerWearable* new_wearable = LLWearableList::instance().createNewWearable(type);
setWearable(type,index,new_wearable);
//new_wearable->writeToAvatar(TRUE);
@@ -1095,7 +1095,7 @@ void LLAgentWearables::recoverMissingWearableDone()
void LLAgentWearables::addLocalTextureObject(const LLWearableType::EType wearable_type, const LLVOAvatarDefines::ETextureIndex texture_type, U32 wearable_index)
{
- LLWearable* wearable = getWearable((LLWearableType::EType)wearable_type, wearable_index);
+ LLViewerWearable* wearable = getWearable((LLWearableType::EType)wearable_type, wearable_index);
if (!wearable)
{
llerrs << "Tried to add local texture object to invalid wearable with type " << wearable_type << " and index " << wearable_index << llendl;
@@ -1128,7 +1128,7 @@ public:
mItemsToLink,
link_waiter);
}
- void addPendingWearable(LLWearable *wearable)
+ void addPendingWearable(LLViewerWearable *wearable)
{
if (!wearable)
{
@@ -1163,7 +1163,7 @@ public:
LLWearableType::EType type = item->getWearableType();
if (type < LLWearableType::WT_COUNT)
{
- LLWearable *wearable = mWearablesAwaitingItems[type];
+ LLViewerWearable *wearable = mWearablesAwaitingItems[type];
if (wearable)
wearable->setItemID(inv_item);
}
@@ -1176,7 +1176,7 @@ public:
private:
LLInventoryModel::item_array_t mItemsToLink;
- std::vector<LLWearable*> mWearablesAwaitingItems;
+ std::vector<LLViewerWearable*> mWearablesAwaitingItems;
};
void LLAgentWearables::createStandardWearables()
@@ -1208,7 +1208,7 @@ void LLAgentWearables::createStandardWearables()
if (create[i])
{
llassert(getWearableCount((LLWearableType::EType)i) == 0);
- LLWearable* wearable = LLWearableList::instance().createNewWearable((LLWearableType::EType)i);
+ LLViewerWearable* wearable = LLWearableList::instance().createNewWearable((LLWearableType::EType)i);
((OnWearableItemCreatedCB*)(&(*cb)))->addPendingWearable(wearable);
// no need to update here...
LLUUID category_id = LLUUID::null;
@@ -1267,7 +1267,7 @@ void LLAgentWearables::makeNewOutfitDone(S32 type, U32 index)
void LLAgentWearables::addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
- LLWearable* wearable,
+ LLViewerWearable* wearable,
const LLUUID& category_id,
BOOL notify)
{
@@ -1305,7 +1305,7 @@ void LLAgentWearables::removeWearable(const LLWearableType::EType type, bool do_
}
else
{
- LLWearable* old_wearable = getWearable(type,index);
+ LLViewerWearable* old_wearable = getWearable(type,index);
if (old_wearable)
{
@@ -1363,7 +1363,7 @@ void LLAgentWearables::removeWearableFinal(const LLWearableType::EType type, boo
S32 max_entry = mWearableDatas[type].size()-1;
for (S32 i=max_entry; i>=0; i--)
{
- LLWearable* old_wearable = getWearable(type,i);
+ LLViewerWearable* old_wearable = getWearable(type,i);
//queryWearableCache(); // moved below
if (old_wearable)
{
@@ -1375,7 +1375,7 @@ void LLAgentWearables::removeWearableFinal(const LLWearableType::EType type, boo
}
else
{
- LLWearable* old_wearable = getWearable(type, index);
+ LLViewerWearable* old_wearable = getWearable(type, index);
//queryWearableCache(); // moved below
if (old_wearable)
@@ -1394,7 +1394,7 @@ void LLAgentWearables::removeWearableFinal(const LLWearableType::EType type, boo
// Assumes existing wearables are not dirty.
void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& items,
- const LLDynamicArray< LLWearable* >& wearables,
+ const LLDynamicArray< LLViewerWearable* >& wearables,
BOOL remove)
{
llinfos << "setWearableOutfit() start" << llendl;
@@ -1419,7 +1419,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
S32 i;
for (i = 0; i < count; i++)
{
- LLWearable* new_wearable = wearables[i];
+ LLViewerWearable* new_wearable = wearables[i];
LLPointer<LLInventoryItem> new_item = items[i];
llassert(new_wearable);
@@ -1476,7 +1476,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
// User has picked "wear on avatar" from a menu.
-void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append)
+void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append)
{
//LLAgentDumper dumper("setWearableItem");
if (isWearingItem(new_item->getUUID()))
@@ -1491,7 +1491,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* ne
{
// Remove old wearable, if any
// MULTI_WEARABLE: hardwired to 0
- LLWearable* old_wearable = getWearable(type,0);
+ LLViewerWearable* old_wearable = getWearable(type,0);
if (old_wearable)
{
const LLUUID& old_item_id = old_wearable->getItemID();
@@ -1517,7 +1517,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLWearable* ne
}
// static
-bool LLAgentWearables::onSetWearableDialog(const LLSD& notification, const LLSD& response, LLWearable* wearable)
+bool LLAgentWearables::onSetWearableDialog(const LLSD& notification, const LLSD& response, LLViewerWearable* wearable)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLInventoryItem* new_item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
@@ -1553,7 +1553,7 @@ bool LLAgentWearables::onSetWearableDialog(const LLSD& notification, const LLSD&
// Called from setWearableItem() and onSetWearableDialog() to actually set the wearable.
// MULTI_WEARABLE: unify code after null objects are gone.
-void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append)
+void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append)
{
const LLWearableType::EType type = new_wearable->getType();
@@ -1570,7 +1570,7 @@ void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLWearable* n
// Replace the old wearable with a new one.
llassert(new_item->getAssetUUID() == new_wearable->getAssetID());
- LLWearable *old_wearable = getWearable(type,0);
+ LLViewerWearable *old_wearable = getWearable(type,0);
LLUUID old_item_id;
if (old_wearable)
{
@@ -1666,7 +1666,7 @@ LLUUID LLAgentWearables::computeBakedTextureHash(LLVOAvatarDefines::EBakedTextur
const U32 num_wearables = getWearableCount(baked_type);
for (U32 index = 0; index < num_wearables; ++index)
{
- const LLWearable* wearable = getWearable(baked_type,index);
+ const LLViewerWearable* wearable = getWearable(baked_type,index);
if (wearable)
{
LLUUID asset_id = wearable->getAssetID();
@@ -1902,11 +1902,11 @@ void LLAgentWearables::checkWearablesLoaded() const
// (depending on closer_to_body parameter).
bool LLAgentWearables::canMoveWearable(const LLUUID& item_id, bool closer_to_body)
{
- const LLWearable* wearable = getWearableFromItemID(item_id);
+ const LLViewerWearable* wearable = getWearableFromItemID(item_id);
if (!wearable) return false;
LLWearableType::EType wtype = wearable->getType();
- const LLWearable* marginal_wearable = closer_to_body ? getBottomWearable(wtype) : getTopWearable(wtype);
+ const LLViewerWearable* marginal_wearable = closer_to_body ? getBottomWearable(wtype) : getTopWearable(wtype);
if (!marginal_wearable) return false;
return wearable != marginal_wearable;
@@ -1928,7 +1928,7 @@ void LLAgentWearables::updateWearablesLoaded()
}
}
-bool LLAgentWearables::canWearableBeRemoved(const LLWearable* wearable) const
+bool LLAgentWearables::canWearableBeRemoved(const LLViewerWearable* wearable) const
{
if (!wearable) return false;
@@ -1943,7 +1943,7 @@ void LLAgentWearables::animateAllWearableParams(F32 delta, BOOL upload_bake)
{
for (S32 count = 0; count < (S32)getWearableCount((LLWearableType::EType)type); ++count)
{
- LLWearable *wearable = getWearable((LLWearableType::EType)type,count);
+ LLViewerWearable *wearable = getWearable((LLWearableType::EType)type,count);
llassert(wearable);
if (wearable)
{
@@ -1972,7 +1972,7 @@ bool LLAgentWearables::moveWearable(const LLViewerInventoryItem* item, bool clos
for (U32 i = 0; i < wearable_vec.size(); ++i)
{
- LLWearable* wearable = wearable_vec[i];
+ LLViewerWearable* wearable = wearable_vec[i];
if (!wearable) continue;
if (wearable->getAssetID() != asset_id) continue;
@@ -1991,7 +1991,7 @@ void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, con
{
if (type == LLWearableType::WT_INVALID || type == LLWearableType::WT_NONE) return;
- LLWearable* wearable = LLWearableList::instance().createNewWearable(type);
+ LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type);
LLAssetType::EType asset_type = wearable->getAssetType();
LLInventoryType::EType inv_type = LLInventoryType::IT_WEARABLE;
LLPointer<LLInventoryCallback> cb = wear ? new LLWearAndEditCallback : NULL;
@@ -2024,7 +2024,7 @@ void LLAgentWearables::editWearable(const LLUUID& item_id)
return;
}
- LLWearable* wearable = gAgentWearables.getWearableFromItemID(item_id);
+ LLViewerWearable* wearable = gAgentWearables.getWearableFromItemID(item_id);
if (!wearable)
{
llwarns << "Cannot get wearable" << llendl;
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index 5932be21c6..3df552544b 100755
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -40,10 +40,9 @@
class LLInventoryItem;
class LLVOAvatarSelf;
-class LLWearable;
+class LLViewerWearable;
class LLInitialWearablesFetch;
class LLViewerObject;
-class LLTexLayerTemplate;
class LLAgentWearables : public LLInitClass<LLAgentWearables>
{
@@ -82,7 +81,7 @@ public:
bool canMoveWearable(const LLUUID& item_id, bool closer_to_body);
// Note: False for shape, skin, eyes, and hair, unless you have MORE than 1.
- bool canWearableBeRemoved(const LLWearable* wearable) const;
+ bool canWearableBeRemoved(const LLViewerWearable* wearable) const;
void animateAllWearableParams(F32 delta, BOOL upload_bake);
@@ -92,15 +91,15 @@ public:
public:
const LLUUID getWearableItemID(LLWearableType::EType type, U32 index /*= 0*/) const;
const LLUUID getWearableAssetID(LLWearableType::EType type, U32 index /*= 0*/) const;
- const LLWearable* getWearableFromItemID(const LLUUID& item_id) const;
- LLWearable* getWearableFromItemID(const LLUUID& item_id);
- LLWearable* getWearableFromAssetID(const LLUUID& asset_id);
+ const LLViewerWearable* getWearableFromItemID(const LLUUID& item_id) const;
+ LLViewerWearable* getWearableFromItemID(const LLUUID& item_id);
+ LLViewerWearable* getWearableFromAssetID(const LLUUID& asset_id);
LLInventoryItem* getWearableInventoryItem(LLWearableType::EType type, U32 index /*= 0*/);
static BOOL selfHasWearable(LLWearableType::EType type);
- LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/);
- const LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const;
- LLWearable* getTopWearable(const LLWearableType::EType type);
- LLWearable* getBottomWearable(const LLWearableType::EType type);
+ LLViewerWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/);
+ const LLViewerWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const;
+ LLViewerWearable* getTopWearable(const LLWearableType::EType type);
+ LLViewerWearable* getBottomWearable(const LLWearableType::EType type);
U32 getWearableCount(const LLWearableType::EType type) const;
U32 getWearableCount(const U32 tex_index) const;
@@ -113,31 +112,31 @@ public:
private:
// Low-level data structure setter - public access is via setWearableItem, etc.
- void setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable);
- U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable);
- void wearableUpdated(LLWearable *wearable);
- void popWearable(LLWearable *wearable);
+ void setWearable(const LLWearableType::EType type, U32 index, LLViewerWearable *wearable);
+ U32 pushWearable(const LLWearableType::EType type, LLViewerWearable *wearable);
+ void wearableUpdated(LLViewerWearable *wearable);
+ void popWearable(LLViewerWearable *wearable);
void popWearable(const LLWearableType::EType type, U32 index);
public:
- void setWearableItem(LLInventoryItem* new_item, LLWearable* wearable, bool do_append = false);
- void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove);
+ void setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false);
+ void setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove);
void setWearableName(const LLUUID& item_id, const std::string& new_name);
void addLocalTextureObject(const LLWearableType::EType wearable_type, const LLVOAvatarDefines::ETextureIndex texture_type, U32 wearable_index);
- U32 getWearableIndex(const LLWearable *wearable) const;
+ U32 getWearableIndex(const LLViewerWearable *wearable) const;
protected:
- void setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append = false);
- static bool onSetWearableDialog(const LLSD& notification, const LLSD& response, LLWearable* wearable);
+ void setWearableFinal(LLInventoryItem* new_item, LLViewerWearable* new_wearable, bool do_append = false);
+ static bool onSetWearableDialog(const LLSD& notification, const LLSD& response, LLViewerWearable* wearable);
void addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
- LLWearable* wearable,
+ LLViewerWearable* wearable,
const LLUUID& category_id = LLUUID::null,
BOOL notify = TRUE);
void addWearabletoAgentInventoryDone(const LLWearableType::EType type,
const U32 index,
const LLUUID& item_id,
- LLWearable* wearable);
+ LLViewerWearable* wearable);
void recoverMissingWearable(const LLWearableType::EType type, U32 index /*= 0*/);
void recoverMissingWearableDone();
@@ -180,7 +179,7 @@ protected:
void sendAgentWearablesRequest();
void queryWearableCache();
void updateServer();
- static void onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
+ static void onInitialWearableAssetArrived(LLViewerWearable* wearable, void* userdata);
//--------------------------------------------------------------------
// Outfits
@@ -245,7 +244,7 @@ private:
// Member variables
//--------------------------------------------------------------------
private:
- typedef std::vector<LLWearable*> wearableentry_vec_t; // all wearables of a certain type (EG all shirts)
+ typedef std::vector<LLViewerWearable*> wearableentry_vec_t; // all wearables of a certain type (EG all shirts)
typedef std::map<LLWearableType::EType, wearableentry_vec_t> wearableentry_map_t; // wearable "categories" arranged by wearable type
wearableentry_map_t mWearableDatas;
@@ -289,13 +288,13 @@ private:
addWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb,
LLWearableType::EType type,
U32 index,
- LLWearable* wearable,
+ LLViewerWearable* wearable,
U32 todo = CALL_NONE);
virtual void fire(const LLUUID& inv_item);
private:
LLWearableType::EType mType;
U32 mIndex;
- LLWearable* mWearable;
+ LLViewerWearable* mWearable;
U32 mTodo;
LLPointer<LLRefCount> mCB;
};
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 3e02f98933..58a0b0fa5b 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -277,7 +277,7 @@ struct LLFoundData
std::string mName;
LLAssetType::EType mAssetType;
LLWearableType::EType mWearableType;
- LLWearable* mWearable;
+ LLViewerWearable* mWearable;
bool mIsReplacement;
};
@@ -301,7 +301,7 @@ public:
void recoverMissingWearable(LLWearableType::EType type);
void clearCOFLinksForMissingWearables();
- void onWearableAssetFetch(LLWearable *wearable);
+ void onWearableAssetFetch(LLViewerWearable *wearable);
void onAllComplete();
typedef std::list<LLFoundData> found_list_t;
@@ -327,7 +327,7 @@ private:
typedef std::set<LLWearableHoldingPattern*> type_set_hp;
static type_set_hp sActiveHoldingPatterns;
bool mIsMostRecent;
- std::set<LLWearable*> mLateArrivals;
+ std::set<LLViewerWearable*> mLateArrivals;
bool mIsAllComplete;
};
@@ -561,7 +561,7 @@ bool LLWearableHoldingPattern::pollFetchCompletion()
class RecoveredItemLinkCB: public LLInventoryCallback
{
public:
- RecoveredItemLinkCB(LLWearableType::EType type, LLWearable *wearable, LLWearableHoldingPattern* holder):
+ RecoveredItemLinkCB(LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder):
mHolder(holder),
mWearable(wearable),
mType(type)
@@ -609,14 +609,14 @@ public:
}
private:
LLWearableHoldingPattern* mHolder;
- LLWearable *mWearable;
+ LLViewerWearable *mWearable;
LLWearableType::EType mType;
};
class RecoveredItemCB: public LLInventoryCallback
{
public:
- RecoveredItemCB(LLWearableType::EType type, LLWearable *wearable, LLWearableHoldingPattern* holder):
+ RecoveredItemCB(LLWearableType::EType type, LLViewerWearable *wearable, LLWearableHoldingPattern* holder):
mHolder(holder),
mWearable(wearable),
mType(type)
@@ -649,7 +649,7 @@ public:
}
private:
LLWearableHoldingPattern* mHolder;
- LLWearable *mWearable;
+ LLViewerWearable *mWearable;
LLWearableType::EType mType;
};
@@ -665,7 +665,7 @@ void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type
LLNotificationsUtil::add("ReplacedMissingWearable");
lldebugs << "Wearable " << LLWearableType::getTypeLabel(type)
<< " could not be downloaded. Replaced inventory item with default wearable." << llendl;
- LLWearable* wearable = LLWearableList::instance().createNewWearable(type);
+ LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type);
// Add a new one in the lost and found folder.
const LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
@@ -772,11 +772,11 @@ void LLWearableHoldingPattern::handleLateArrivals()
iter != getFoundList().end(); ++iter)
{
LLFoundData& data = *iter;
- for (std::set<LLWearable*>::iterator wear_it = mLateArrivals.begin();
+ for (std::set<LLViewerWearable*>::iterator wear_it = mLateArrivals.begin();
wear_it != mLateArrivals.end();
++wear_it)
{
- LLWearable *wearable = *wear_it;
+ LLViewerWearable *wearable = *wear_it;
if(wearable->getAssetID() == data.mAssetID)
{
@@ -836,7 +836,7 @@ void LLWearableHoldingPattern::resetTime(F32 timeout)
mWaitTime.setTimerExpirySec(timeout);
}
-void LLWearableHoldingPattern::onWearableAssetFetch(LLWearable *wearable)
+void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable)
{
if (!isMostRecent())
{
@@ -887,7 +887,7 @@ void LLWearableHoldingPattern::onWearableAssetFetch(LLWearable *wearable)
}
}
-static void onWearableAssetFetch(LLWearable* wearable, void* data)
+static void onWearableAssetFetch(LLViewerWearable* wearable, void* data)
{
LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data;
holder->onWearableAssetFetch(wearable);
@@ -1588,7 +1588,7 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo
{
lldebugs << "updateAgentWearables()" << llendl;
LLInventoryItem::item_array_t items;
- LLDynamicArray< LLWearable* > wearables;
+ LLDynamicArray< LLViewerWearable* > wearables;
// For each wearable type, find the wearables of that type.
for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
@@ -1597,7 +1597,7 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo
iter != holder->getFoundList().end(); ++iter)
{
LLFoundData& data = *iter;
- LLWearable* wearable = data.mWearable;
+ LLViewerWearable* wearable = data.mWearable;
if( wearable && ((S32)wearable->getType() == i) )
{
LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID);
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 742833211a..370aec8a8f 100755
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -35,7 +35,6 @@
#include "llinventoryobserver.h"
#include "llviewerinventory.h"
-class LLWearable;
class LLWearableHoldingPattern;
class LLInventoryCallback;
class LLOutfitUnLockTimer;
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 65bfc990d1..35e44d73d4 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -48,8 +48,8 @@
#include "llviewercontrol.h"
#include "llviewerobjectlist.h"
#include "llviewermenufile.h"
+#include "llviewertexlayer.h"
#include "llviewerwindow.h"
-#include "lltexlayer.h"
#include "lltrans.h"
// library includes
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index b539ac38ed..d2acd32713 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -37,6 +37,8 @@
#include "lluictrlfactory.h"
#include "llagentdata.h"
#include "llimfloater.h"
+#include "llviewertexture.h"
+#include "llvoavatardefines.h"
// library includes
#include "llavatarnamecache.h"
diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp
index 885cae1737..0ae9acd1af 100644
--- a/indra/newview/lldriverparam.cpp
+++ b/indra/newview/lldriverparam.cpp
@@ -32,7 +32,7 @@
#include "llvoavatar.h"
#include "llvoavatarself.h"
#include "llagent.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
#include "llagentwearables.h"
//-----------------------------------------------------------------------------
@@ -623,10 +623,19 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight
void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake)
{
+ bool use_self = false;
if(isAgentAvatarValid() &&
- mWearablep &&
- driven->mParam->getCrossWearable() &&
- mWearablep->isOnTop())
+ mWearablep &&
+ driven->mParam->getCrossWearable())
+ {
+ LLViewerWearable* wearable = dynamic_cast<LLViewerWearable*> (mWearablep);
+ if (!wearable->isOnTop())
+ {
+ use_self = false;
+ }
+ }
+
+ if (use_self)
{
// call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values
gAgentAvatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake );
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index 2939d31087..3c40e2d4bc 100644
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -38,6 +38,7 @@
#include "message.h"
#include "llagent.h"
+#include "llassetstorage.h"
#include "llcombobox.h"
#include "llestateinfomodel.h"
#include "llmimetypes.h"
diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp
index 4e10b4fc2c..b26b302ea6 100644
--- a/indra/newview/llfloateravatartextures.cpp
+++ b/indra/newview/llfloateravatartextures.cpp
@@ -32,6 +32,7 @@
#include "llagent.h"
#include "llagentwearables.h"
+#include "llviewerwearable.h"
#include "lltexturectrl.h"
#include "lluictrlfactory.h"
#include "llviewerobjectlist.h"
@@ -81,7 +82,7 @@ static void update_texture_ctrl(LLVOAvatar* avatarp,
if (avatarp->isSelf())
{
const LLWearableType::EType wearable_type = tex_entry->mWearableType;
- LLWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
+ LLViewerWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
if (wearable)
{
LLLocalTextureObject *lto = wearable->getLocalTextureObject(te);
@@ -173,7 +174,7 @@ void LLFloaterAvatarTextures::onClickDump(void* data)
LLWearableType::EType wearable_type = LLVOAvatarDictionary::getInstance()->getTEWearableType((ETextureIndex)i);
if (avatarp->isSelf())
{
- LLWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
+ LLViewerWearable *wearable = gAgentWearables.getWearable(wearable_type, 0);
if (wearable)
{
LLLocalTextureObject *lto = wearable->getLocalTextureObject(i);
diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp
index 2f9810775b..97f72b020c 100644
--- a/indra/newview/llgroupiconctrl.cpp
+++ b/indra/newview/llgroupiconctrl.cpp
@@ -29,6 +29,7 @@
#include "llgroupiconctrl.h"
#include "llagent.h"
+#include "llviewertexture.h"
/*
#include "llavatarconstants.h"
#include "llcallingcard.h" // for LLAvatarTracker
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index b819100b9b..17e9b8026a 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -5692,7 +5692,7 @@ void LLWearableBridge::wearAddOnAvatar()
}
// static
-void LLWearableBridge::onWearOnAvatarArrived( LLWearable* wearable, void* userdata )
+void LLWearableBridge::onWearOnAvatarArrived( LLViewerWearable* wearable, void* userdata )
{
LLUUID* item_id = (LLUUID*) userdata;
if(wearable)
@@ -5718,7 +5718,7 @@ void LLWearableBridge::onWearOnAvatarArrived( LLWearable* wearable, void* userda
// static
// BAP remove the "add" code path once everything is fully COF-ified.
-void LLWearableBridge::onWearAddOnAvatarArrived( LLWearable* wearable, void* userdata )
+void LLWearableBridge::onWearAddOnAvatarArrived( LLViewerWearable* wearable, void* userdata )
{
LLUUID* item_id = (LLUUID*) userdata;
if(wearable)
@@ -5799,7 +5799,7 @@ void LLWearableBridge::onRemoveFromAvatar(void* user_data)
}
// static
-void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable,
+void LLWearableBridge::onRemoveFromAvatarArrived(LLViewerWearable* wearable,
void* userdata)
{
OnRemoveStruct *on_remove_struct = (OnRemoveStruct*) userdata;
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index dc9e88d54d..067e4bdf3d 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -33,7 +33,7 @@
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llviewercontrol.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
class LLInventoryFilter;
class LLInventoryPanel;
@@ -486,10 +486,10 @@ public:
static void onWearOnAvatar( void* userdata ); // Access to wearOnAvatar() from menu
static BOOL canWearOnAvatar( void* userdata );
- static void onWearOnAvatarArrived( LLWearable* wearable, void* userdata );
+ static void onWearOnAvatarArrived( LLViewerWearable* wearable, void* userdata );
void wearOnAvatar();
- static void onWearAddOnAvatarArrived( LLWearable* wearable, void* userdata );
+ static void onWearAddOnAvatarArrived( LLViewerWearable* wearable, void* userdata );
void wearAddOnAvatar();
static BOOL canEditOnAvatar( void* userdata ); // Access to editOnAvatar() from menu
@@ -498,7 +498,7 @@ public:
static BOOL canRemoveFromAvatar( void* userdata );
static void onRemoveFromAvatar( void* userdata );
- static void onRemoveFromAvatarArrived( LLWearable* wearable, void* userdata );
+ static void onRemoveFromAvatarArrived( LLViewerWearable* wearable, void* userdata );
static void removeItemFromAvatar(LLViewerInventoryItem *item);
static void removeAllClothesFromAvatar();
void removeFromAvatar();
diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp
deleted file mode 100644
index 34734d57c5..0000000000
--- a/indra/newview/llinventoryicon.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * @file llinventoryicon.cpp
- * @brief Implementation of the inventory icon.
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llinventoryicon.h"
-
-#include "lldictionary.h"
-#include "llinventorydefines.h"
-#include "llui.h"
-#include "llwearabletype.h"
-
-struct IconEntry : public LLDictionaryEntry
-{
- IconEntry(const std::string &item_name)
- :
- LLDictionaryEntry(item_name)
- {}
-};
-
-class LLIconDictionary : public LLSingleton<LLIconDictionary>,
- public LLDictionary<LLInventoryIcon::EIconName, IconEntry>
-{
-public:
- LLIconDictionary();
-};
-
-LLIconDictionary::LLIconDictionary()
-{
- addEntry(LLInventoryIcon::ICONNAME_TEXTURE, new IconEntry("Inv_Texture"));
- addEntry(LLInventoryIcon::ICONNAME_SOUND, new IconEntry("Inv_Sound"));
- addEntry(LLInventoryIcon::ICONNAME_CALLINGCARD_ONLINE, new IconEntry("Inv_CallingCard"));
- addEntry(LLInventoryIcon::ICONNAME_CALLINGCARD_OFFLINE, new IconEntry("Inv_CallingCard"));
- addEntry(LLInventoryIcon::ICONNAME_LANDMARK, new IconEntry("Inv_Landmark"));
- addEntry(LLInventoryIcon::ICONNAME_LANDMARK_VISITED, new IconEntry("Inv_Landmark"));
- addEntry(LLInventoryIcon::ICONNAME_SCRIPT, new IconEntry("Inv_Script"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING, new IconEntry("Inv_Clothing"));
- addEntry(LLInventoryIcon::ICONNAME_OBJECT, new IconEntry("Inv_Object"));
- addEntry(LLInventoryIcon::ICONNAME_OBJECT_MULTI, new IconEntry("Inv_Object_Multi"));
- addEntry(LLInventoryIcon::ICONNAME_NOTECARD, new IconEntry("Inv_Notecard"));
- addEntry(LLInventoryIcon::ICONNAME_BODYPART, new IconEntry("Inv_Skin"));
- addEntry(LLInventoryIcon::ICONNAME_SNAPSHOT, new IconEntry("Inv_Snapshot"));
-
- addEntry(LLInventoryIcon::ICONNAME_BODYPART_SHAPE, new IconEntry("Inv_BodyShape"));
- addEntry(LLInventoryIcon::ICONNAME_BODYPART_SKIN, new IconEntry("Inv_Skin"));
- addEntry(LLInventoryIcon::ICONNAME_BODYPART_HAIR, new IconEntry("Inv_Hair"));
- addEntry(LLInventoryIcon::ICONNAME_BODYPART_EYES, new IconEntry("Inv_Eye"));
-
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_SHIRT, new IconEntry("Inv_Shirt"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_PANTS, new IconEntry("Inv_Pants"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_SHOES, new IconEntry("Inv_Shoe"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_SOCKS, new IconEntry("Inv_Socks"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_JACKET, new IconEntry("Inv_Jacket"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_GLOVES, new IconEntry("Inv_Gloves"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_UNDERSHIRT, new IconEntry("Inv_Undershirt"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_UNDERPANTS, new IconEntry("Inv_Underpants"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_SKIRT, new IconEntry("Inv_Skirt"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_ALPHA, new IconEntry("Inv_Alpha"));
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_TATTOO, new IconEntry("Inv_Tattoo"));
- addEntry(LLInventoryIcon::ICONNAME_ANIMATION, new IconEntry("Inv_Animation"));
- addEntry(LLInventoryIcon::ICONNAME_GESTURE, new IconEntry("Inv_Gesture"));
-
- addEntry(LLInventoryIcon::ICONNAME_CLOTHING_PHYSICS, new IconEntry("Inv_Physics"));
-
- addEntry(LLInventoryIcon::ICONNAME_LINKITEM, new IconEntry("Inv_LinkItem"));
- addEntry(LLInventoryIcon::ICONNAME_LINKFOLDER, new IconEntry("Inv_LinkFolder"));
- addEntry(LLInventoryIcon::ICONNAME_MESH, new IconEntry("Inv_Mesh"));
-
- addEntry(LLInventoryIcon::ICONNAME_INVALID, new IconEntry("Inv_Invalid"));
-
- addEntry(LLInventoryIcon::ICONNAME_NONE, new IconEntry("NONE"));
-}
-
-LLUIImagePtr LLInventoryIcon::getIcon(LLAssetType::EType asset_type,
- LLInventoryType::EType inventory_type,
- U32 misc_flag,
- BOOL item_is_multi)
-{
- const std::string& icon_name = getIconName(asset_type, inventory_type, misc_flag, item_is_multi);
- return LLUI::getUIImage(icon_name);
-}
-
-LLUIImagePtr LLInventoryIcon::getIcon(EIconName idx)
-{
- return LLUI::getUIImage(getIconName(idx));
-}
-
-const std::string& LLInventoryIcon::getIconName(LLAssetType::EType asset_type,
- LLInventoryType::EType inventory_type,
- U32 misc_flag,
- BOOL item_is_multi)
-{
- EIconName idx = ICONNAME_OBJECT;
- if (item_is_multi)
- {
- idx = ICONNAME_OBJECT_MULTI;
- return getIconName(idx);
- }
-
- switch(asset_type)
- {
- case LLAssetType::AT_TEXTURE:
- idx = (inventory_type == LLInventoryType::IT_SNAPSHOT) ? ICONNAME_SNAPSHOT : ICONNAME_TEXTURE;
- break;
- case LLAssetType::AT_SOUND:
- idx = ICONNAME_SOUND;
- break;
- case LLAssetType::AT_CALLINGCARD:
- idx = (misc_flag != 0) ? ICONNAME_CALLINGCARD_ONLINE : ICONNAME_CALLINGCARD_OFFLINE;
- break;
- case LLAssetType::AT_LANDMARK:
- idx = (misc_flag != 0) ? ICONNAME_LANDMARK_VISITED : ICONNAME_LANDMARK;
- break;
- case LLAssetType::AT_SCRIPT:
- case LLAssetType::AT_LSL_TEXT:
- case LLAssetType::AT_LSL_BYTECODE:
- idx = ICONNAME_SCRIPT;
- break;
- case LLAssetType::AT_CLOTHING:
- case LLAssetType::AT_BODYPART:
- idx = assignWearableIcon(misc_flag);
- break;
- case LLAssetType::AT_NOTECARD:
- idx = ICONNAME_NOTECARD;
- break;
- case LLAssetType::AT_ANIMATION:
- idx = ICONNAME_ANIMATION;
- break;
- case LLAssetType::AT_GESTURE:
- idx = ICONNAME_GESTURE;
- break;
- case LLAssetType::AT_LINK:
- idx = ICONNAME_LINKITEM;
- break;
- case LLAssetType::AT_LINK_FOLDER:
- idx = ICONNAME_LINKFOLDER;
- break;
- case LLAssetType::AT_OBJECT:
- idx = ICONNAME_OBJECT;
- break;
- case LLAssetType::AT_MESH:
- idx = ICONNAME_MESH;
- default:
- break;
- }
-
- return getIconName(idx);
-}
-
-
-const std::string& LLInventoryIcon::getIconName(EIconName idx)
-{
- const IconEntry *entry = LLIconDictionary::instance().lookup(idx);
- return entry->mName;
-}
-
-LLInventoryIcon::EIconName LLInventoryIcon::assignWearableIcon(U32 misc_flag)
-{
- const LLWearableType::EType wearable_type = LLWearableType::EType(LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK & misc_flag);
- return LLWearableType::getIconName(wearable_type);
-}
diff --git a/indra/newview/llinventoryicon.h b/indra/newview/llinventoryicon.h
deleted file mode 100644
index c7e2998a20..0000000000
--- a/indra/newview/llinventoryicon.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * @file llinventoryfunctions.h
- * @brief Miscellaneous inventory-related functions and classes
- * class definition
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLINVENTORYICON_H
-#define LL_LLINVENTORYICON_H
-
-#include "llassettype.h"
-#include "llinventorytype.h"
-#include "lluiimage.h"
-
-class LLInventoryIcon
-{
-public:
- enum EIconName
- {
- ICONNAME_TEXTURE,
- ICONNAME_SOUND,
- ICONNAME_CALLINGCARD_ONLINE,
- ICONNAME_CALLINGCARD_OFFLINE,
- ICONNAME_LANDMARK,
- ICONNAME_LANDMARK_VISITED,
- ICONNAME_SCRIPT,
- ICONNAME_CLOTHING,
- ICONNAME_OBJECT,
- ICONNAME_OBJECT_MULTI,
- ICONNAME_NOTECARD,
- ICONNAME_BODYPART,
- ICONNAME_SNAPSHOT,
-
- ICONNAME_BODYPART_SHAPE,
- ICONNAME_BODYPART_SKIN,
- ICONNAME_BODYPART_HAIR,
- ICONNAME_BODYPART_EYES,
- ICONNAME_CLOTHING_SHIRT,
- ICONNAME_CLOTHING_PANTS,
- ICONNAME_CLOTHING_SHOES,
- ICONNAME_CLOTHING_SOCKS,
- ICONNAME_CLOTHING_JACKET,
- ICONNAME_CLOTHING_GLOVES,
- ICONNAME_CLOTHING_UNDERSHIRT,
- ICONNAME_CLOTHING_UNDERPANTS,
- ICONNAME_CLOTHING_SKIRT,
- ICONNAME_CLOTHING_ALPHA,
- ICONNAME_CLOTHING_TATTOO,
-
- ICONNAME_ANIMATION,
- ICONNAME_GESTURE,
-
- ICONNAME_CLOTHING_PHYSICS,
-
- ICONNAME_LINKITEM,
- ICONNAME_LINKFOLDER,
- ICONNAME_MESH,
-
- ICONNAME_INVALID,
- ICONNAME_COUNT,
- ICONNAME_NONE = -1
- };
-
- static const std::string& getIconName(LLAssetType::EType asset_type,
- LLInventoryType::EType inventory_type = LLInventoryType::IT_NONE,
- U32 misc_flag = 0, // different meanings depending on item type
- BOOL item_is_multi = FALSE);
- static const std::string& getIconName(EIconName idx);
-
- static LLUIImagePtr getIcon(LLAssetType::EType asset_type,
- LLInventoryType::EType inventory_type = LLInventoryType::IT_NONE,
- U32 misc_flag = 0, // different meanings depending on item type
- BOOL item_is_multi = FALSE);
- static LLUIImagePtr getIcon(EIconName idx);
-
-protected:
- static EIconName assignWearableIcon(U32 misc_flag);
-};
-#endif // LL_LLINVENTORYICON_H
-
-
-
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 459e52c4f4..097c751386 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -55,7 +55,7 @@
#include "llviewerobject.h"
#include "llface.h"
#include "llvoavatarself.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
#include "llagentwearables.h"
#include "lltexlayerparams.h"
#include "llvovolume.h"
@@ -483,7 +483,7 @@ void LLLocalBitmap::updateUserLayers(LLUUID old_id, LLUUID new_id, LLWearableTyp
U32 count = gAgentWearables.getWearableCount(type);
for(U32 wearable_iter = 0; wearable_iter < count; wearable_iter++)
{
- LLWearable* wearable = gAgentWearables.getWearable(type, wearable_iter);
+ LLViewerWearable* wearable = gAgentWearables.getWearable(type, wearable_iter);
if (wearable)
{
std::vector<LLLocalTextureObject*> texture_list = wearable->getLocalTextureListSeq();
diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h
index 7a23c7ef6e..df031de3cb 100644
--- a/indra/newview/lllocalbitmaps.h
+++ b/indra/newview/lllocalbitmaps.h
@@ -33,6 +33,7 @@
#include "llvoavatardefines.h"
class LLScrollListCtrl;
+class LLViewerObject;
class LLLocalBitmap
{
diff --git a/indra/newview/lllocaltextureobject.cpp b/indra/newview/lllocaltextureobject.cpp
deleted file mode 100644
index 07ec0fab95..0000000000
--- a/indra/newview/lllocaltextureobject.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * @file lllocaltextureobject.cpp
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lllocaltextureobject.h"
-
-#include "lltexlayer.h"
-#include "llviewertexture.h"
-#include "lltextureentry.h"
-#include "lluuid.h"
-#include "llwearable.h"
-
-
-LLLocalTextureObject::LLLocalTextureObject() :
- mIsBakedReady(FALSE),
- mDiscard(MAX_DISCARD_LEVEL+1)
-{
- mImage = NULL;
-}
-
-LLLocalTextureObject::LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id) :
- mIsBakedReady(FALSE),
- mDiscard(MAX_DISCARD_LEVEL+1)
-{
- mImage = image;
- gGL.getTexUnit(0)->bind(mImage);
- mID = id;
-}
-
-LLLocalTextureObject::LLLocalTextureObject(const LLLocalTextureObject& lto) :
- mImage(lto.mImage),
- mID(lto.mID),
- mIsBakedReady(lto.mIsBakedReady),
- mDiscard(lto.mDiscard)
-{
- U32 num_layers = lto.getNumTexLayers();
- mTexLayers.reserve(num_layers);
- for (U32 index = 0; index < num_layers; index++)
- {
- LLTexLayer* original_layer = lto.getTexLayer(index);
- if (!original_layer)
- {
- llerrs << "could not clone Local Texture Object: unable to extract texlayer!" << llendl;
- continue;
- }
-
- LLTexLayer* new_layer = new LLTexLayer(*original_layer);
- new_layer->setLTO(this);
- mTexLayers.push_back(new_layer);
- }
-}
-
-LLLocalTextureObject::~LLLocalTextureObject()
-{
-}
-
-LLViewerFetchedTexture* LLLocalTextureObject::getImage() const
-{
- return mImage;
-}
-
-LLTexLayer* LLLocalTextureObject::getTexLayer(U32 index) const
-{
- if (index >= getNumTexLayers())
- {
- return NULL;
- }
-
- return mTexLayers[index];
-}
-
-LLTexLayer* LLLocalTextureObject::getTexLayer(const std::string &name)
-{
- for( tex_layer_vec_t::iterator iter = mTexLayers.begin(); iter != mTexLayers.end(); iter++)
- {
- LLTexLayer *layer = *iter;
- if (layer->getName().compare(name) == 0)
- {
- return layer;
- }
- }
-
- return NULL;
-}
-
-U32 LLLocalTextureObject::getNumTexLayers() const
-{
- return mTexLayers.size();
-}
-
-LLUUID LLLocalTextureObject::getID() const
-{
- return mID;
-}
-
-S32 LLLocalTextureObject::getDiscard() const
-{
- return mDiscard;
-}
-
-BOOL LLLocalTextureObject::getBakedReady() const
-{
- return mIsBakedReady;
-}
-
-void LLLocalTextureObject::setImage(LLViewerFetchedTexture* new_image)
-{
- mImage = new_image;
-}
-
-BOOL LLLocalTextureObject::setTexLayer(LLTexLayer *new_tex_layer, U32 index)
-{
- if (index >= getNumTexLayers() )
- {
- return FALSE;
- }
-
- if (new_tex_layer == NULL)
- {
- return removeTexLayer(index);
- }
-
- LLTexLayer *layer = new LLTexLayer(*new_tex_layer);
- layer->setLTO(this);
-
- if (mTexLayers[index])
- {
- delete mTexLayers[index];
- }
- mTexLayers[index] = layer;
-
- return TRUE;
-}
-
-BOOL LLLocalTextureObject::addTexLayer(LLTexLayer *new_tex_layer, LLWearable *wearable)
-{
- if (new_tex_layer == NULL)
- {
- return FALSE;
- }
-
- LLTexLayer *layer = new LLTexLayer(*new_tex_layer, wearable);
- layer->setLTO(this);
- mTexLayers.push_back(layer);
- return TRUE;
-}
-
-BOOL LLLocalTextureObject::addTexLayer(LLTexLayerTemplate *new_tex_layer, LLWearable *wearable)
-{
- if (new_tex_layer == NULL)
- {
- return FALSE;
- }
-
- LLTexLayer *layer = new LLTexLayer(*new_tex_layer, this, wearable);
- layer->setLTO(this);
- mTexLayers.push_back(layer);
- return TRUE;
-}
-
-BOOL LLLocalTextureObject::removeTexLayer(U32 index)
-{
- if (index >= getNumTexLayers())
- {
- return FALSE;
- }
- tex_layer_vec_t::iterator iter = mTexLayers.begin();
- iter += index;
-
- delete *iter;
- mTexLayers.erase(iter);
- return TRUE;
-}
-
-void LLLocalTextureObject::setID(LLUUID new_id)
-{
- mID = new_id;
-}
-
-void LLLocalTextureObject::setDiscard(S32 new_discard)
-{
- mDiscard = new_discard;
-}
-
-void LLLocalTextureObject::setBakedReady(BOOL ready)
-{
- mIsBakedReady = ready;
-}
-
diff --git a/indra/newview/lllocaltextureobject.h b/indra/newview/lllocaltextureobject.h
deleted file mode 100644
index b9bfc5472f..0000000000
--- a/indra/newview/lllocaltextureobject.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * @file lllocaltextureobject.h
- * @brief LLLocalTextureObject class header file
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LOCALTEXTUREOBJECT_H
-#define LL_LOCALTEXTUREOBJECT_H
-
-#include <boost/shared_ptr.hpp>
-
-#include "llviewertexture.h"
-
-class LLUUID;
-class LLTexLayer;
-class LLTextureEntry;
-class LLTexLayerTemplate;
-class LLWearable;
-
-// Stores all relevant information for a single texture
-// assumed to have ownership of all objects referred to -
-// will delete objects when being replaced or if object is destroyed.
-class LLLocalTextureObject
-{
-public:
- LLLocalTextureObject();
- LLLocalTextureObject(LLViewerFetchedTexture* image, const LLUUID& id);
- LLLocalTextureObject(const LLLocalTextureObject& lto);
- ~LLLocalTextureObject();
-
- LLViewerFetchedTexture* getImage() const;
- LLTexLayer* getTexLayer(U32 index) const;
- LLTexLayer* getTexLayer(const std::string &name);
- U32 getNumTexLayers() const;
- LLUUID getID() const;
- S32 getDiscard() const;
- BOOL getBakedReady() const;
-
- void setImage(LLViewerFetchedTexture* new_image);
- BOOL setTexLayer(LLTexLayer *new_tex_layer, U32 index);
- BOOL addTexLayer(LLTexLayer *new_tex_layer, LLWearable *wearable);
- BOOL addTexLayer(LLTexLayerTemplate *new_tex_layer, LLWearable *wearable);
- BOOL removeTexLayer(U32 index);
-
- void setID(LLUUID new_id);
- void setDiscard(S32 new_discard);
- void setBakedReady(BOOL ready);
-
-protected:
-
-private:
-
- LLPointer<LLViewerFetchedTexture> mImage;
- // NOTE: LLLocalTextureObject should be the exclusive owner of mTexEntry and mTexLayer
- // using shared pointers here only for smart assignment & cleanup
- // do NOT create new shared pointers to these objects, or keep pointers to them around
- typedef std::vector<LLTexLayer*> tex_layer_vec_t;
- tex_layer_vec_t mTexLayers;
-
- LLUUID mID;
-
- BOOL mIsBakedReady;
- S32 mDiscard;
-};
-
- #endif // LL_LOCALTEXTUREOBJECT_H
-
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 6889b98ab1..862e4be203 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -55,6 +55,7 @@
#include "lltrans.h"
#include "llscrollcontainer.h"
#include "llstatusbar.h"
+#include "llviewertexture.h"
const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index d58d6d536c..44b56afb1a 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -28,7 +28,7 @@
#include "llpaneleditwearable.h"
#include "llpanel.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
#include "lluictrl.h"
#include "llscrollingpanellist.h"
#include "llvisualparam.h"
@@ -865,7 +865,7 @@ void LLPanelEditWearable::setVisible(BOOL visible)
LLPanel::setVisible(visible);
}
-void LLPanelEditWearable::setWearable(LLWearable *wearable, BOOL disable_camera_switch)
+void LLPanelEditWearable::setWearable(LLViewerWearable *wearable, BOOL disable_camera_switch)
{
showWearable(mWearablePtr, FALSE, disable_camera_switch);
mWearablePtr = wearable;
@@ -922,7 +922,7 @@ void LLPanelEditWearable::onCommitSexChange()
}
bool is_new_sex_male = (gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE) == SEX_MALE;
- LLWearable* wearable = gAgentWearables.getWearable(type, index);
+ LLViewerWearable* wearable = gAgentWearables.getWearable(type, index);
if (wearable)
{
wearable->setVisualParamWeight(param->getID(), is_new_sex_male, FALSE);
@@ -1069,7 +1069,7 @@ void LLPanelEditWearable::revertChanges()
gAgentAvatarp->wearableUpdated(mWearablePtr->getType(), FALSE);
}
-void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show, BOOL disable_camera_switch)
+void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, BOOL show, BOOL disable_camera_switch)
{
if (!wearable)
{
@@ -1445,7 +1445,7 @@ void LLPanelEditWearable::buildParamList(LLScrollingPanelList *panel_list, value
{
LLPanel::Params p;
p.name("LLScrollingPanelParam");
- LLWearable *wearable = this->getWearable();
+ LLViewerWearable *wearable = this->getWearable();
LLScrollingPanelParamBase *panel_param = NULL;
if (wearable && wearable->getType() == LLWearableType::WT_PHYSICS) // Hack to show a different panel for physics. Should generalize this later.
{
diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h
index 692a7ce90f..85e43c8ebd 100644
--- a/indra/newview/llpaneleditwearable.h
+++ b/indra/newview/llpaneleditwearable.h
@@ -35,7 +35,7 @@
class LLAccordionCtrl;
class LLCheckBoxCtrl;
-class LLWearable;
+class LLViewerWearable;
class LLTextBox;
class LLViewerInventoryItem;
class LLViewerVisualParam;
@@ -58,8 +58,8 @@ public:
// changes camera angle to default for selected subpart
void changeCamera(U8 subpart);
- LLWearable* getWearable() { return mWearablePtr; }
- void setWearable(LLWearable *wearable, BOOL disable_camera_switch = FALSE);
+ LLViewerWearable* getWearable() { return mWearablePtr; }
+ void setWearable(LLViewerWearable *wearable, BOOL disable_camera_switch = FALSE);
void saveChanges(bool force_save_as = false);
void revertChanges();
@@ -80,7 +80,7 @@ public:
private:
typedef std::map<F32, LLViewerVisualParam*> value_map_t;
- void showWearable(LLWearable* wearable, BOOL show, BOOL disable_camera_switch = FALSE);
+ void showWearable(LLViewerWearable* wearable, BOOL show, BOOL disable_camera_switch = FALSE);
void updateScrollingPanelUI();
LLPanel* getPanel(LLWearableType::EType type);
void getSortedParams(value_map_t &sorted_params, const std::string &edit_group);
@@ -115,7 +115,7 @@ private:
void setWearablePanelVisibilityChangeCallback(LLPanel* bodypart_panel);
// the pointer to the wearable we're editing. NULL means we're not editing a wearable.
- LLWearable *mWearablePtr;
+ LLViewerWearable *mWearablePtr;
LLViewerInventoryItem* mWearableItem;
// these are constant no matter what wearable we're editing
diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp
index 4f2d6da7e5..aebe636f59 100644
--- a/indra/newview/llpostcard.cpp
+++ b/indra/newview/llpostcard.cpp
@@ -35,6 +35,7 @@
#include "message.h"
#include "llagent.h"
+#include "llassetstorage.h"
#include "llassetuploadresponders.h"
///////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 9267444534..6a692209e9 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -47,7 +47,7 @@
#include "llviewercontrol.h"
#include "llviewerregion.h"
#include "llvoavatarself.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
static LLRegisterPanelClassWrapper<LLSidepanelAppearance> t_appearance("sidepanel_appearance");
@@ -198,7 +198,7 @@ void LLSidepanelAppearance::updateToVisibility(const LLSD &new_visibility)
if (is_outfit_edit_visible || is_wearable_edit_visible)
{
- const LLWearable *wearable_ptr = mEditWearable->getWearable();
+ const LLViewerWearable *wearable_ptr = mEditWearable->getWearable();
if (!wearable_ptr)
{
llwarns << "Visibility change to invalid wearable" << llendl;
@@ -326,7 +326,7 @@ void LLSidepanelAppearance::showOutfitEditPanel()
toggleOutfitEditPanel(TRUE);
}
-void LLSidepanelAppearance::showWearableEditPanel(LLWearable *wearable /* = NULL*/, BOOL disable_camera_switch)
+void LLSidepanelAppearance::showWearableEditPanel(LLViewerWearable *wearable /* = NULL*/, BOOL disable_camera_switch)
{
toggleMyOutfitsPanel(FALSE);
toggleOutfitEditPanel(FALSE, TRUE); // don't switch out of edit appearance mode
@@ -379,7 +379,7 @@ void LLSidepanelAppearance::toggleOutfitEditPanel(BOOL visible, BOOL disable_cam
}
}
-void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLWearable *wearable, BOOL disable_camera_switch)
+void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLViewerWearable *wearable, BOOL disable_camera_switch)
{
if (!mEditWearable || mEditWearable->getVisible() == visible)
{
@@ -445,7 +445,7 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name)
}
//static
-void LLSidepanelAppearance::editWearable(LLWearable *wearable, LLView *data, BOOL disable_camera_switch)
+void LLSidepanelAppearance::editWearable(LLViewerWearable *wearable, LLView *data, BOOL disable_camera_switch)
{
LLFloaterSidePanelContainer::showPanel("appearance", LLSD());
diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h
index 6dd3520266..32bbb8a776 100644
--- a/indra/newview/llsidepanelappearance.h
+++ b/indra/newview/llsidepanelappearance.h
@@ -36,7 +36,7 @@
class LLFilterEditor;
class LLCurrentlyWornFetchObserver;
class LLPanelEditWearable;
-class LLWearable;
+class LLViewerWearable;
class LLPanelOutfitsInventory;
class LLSidepanelAppearance : public LLPanel
@@ -51,7 +51,7 @@ public:
void refreshCurrentOutfitName(const std::string& name = "");
- static void editWearable(LLWearable *wearable, LLView *data, BOOL disable_camera_switch = FALSE);
+ static void editWearable(LLViewerWearable *wearable, LLView *data, BOOL disable_camera_switch = FALSE);
void fetchInventory();
void inventoryFetched();
@@ -59,7 +59,7 @@ public:
void showOutfitsInventoryPanel();
void showOutfitEditPanel();
- void showWearableEditPanel(LLWearable *wearable = NULL, BOOL disable_camera_switch = FALSE);
+ void showWearableEditPanel(LLViewerWearable *wearable = NULL, BOOL disable_camera_switch = FALSE);
void setWearablesLoading(bool val);
void showDefaultSubpart();
void updateScrollingPanelList();
@@ -74,7 +74,7 @@ private:
void toggleMyOutfitsPanel(BOOL visible);
void toggleOutfitEditPanel(BOOL visible, BOOL disable_camera_switch = FALSE);
- void toggleWearableEditPanel(BOOL visible, LLWearable* wearable = NULL, BOOL disable_camera_switch = FALSE);
+ void toggleWearableEditPanel(BOOL visible, LLViewerWearable* wearable = NULL, BOOL disable_camera_switch = FALSE);
LLFilterEditor* mFilterEditor;
LLPanelOutfitsInventory* mPanelOutfitsInventory;
diff --git a/indra/newview/lltexglobalcolor.cpp b/indra/newview/lltexglobalcolor.cpp
deleted file mode 100644
index ebe5ccd6c0..0000000000
--- a/indra/newview/lltexglobalcolor.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * @file lltexlayerglobalcolor.cpp
- * @brief Color for texture layers.
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llagent.h"
-#include "lltexlayer.h"
-#include "llvoavatar.h"
-#include "llwearable.h"
-#include "lltexglobalcolor.h"
-
-//-----------------------------------------------------------------------------
-// LLTexGlobalColor
-//-----------------------------------------------------------------------------
-
-LLTexGlobalColor::LLTexGlobalColor(LLVOAvatar* avatar)
- :
- mAvatar(avatar),
- mInfo(NULL)
-{
-}
-
-LLTexGlobalColor::~LLTexGlobalColor()
-{
- // mParamColorList are LLViewerVisualParam's and get deleted with ~LLCharacter()
- //std::for_each(mParamColorList.begin(), mParamColorList.end(), DeletePointer());
-}
-
-BOOL LLTexGlobalColor::setInfo(LLTexGlobalColorInfo *info)
-{
- llassert(mInfo == NULL);
- mInfo = info;
- //mID = info->mID; // No ID
-
- mParamGlobalColorList.reserve(mInfo->mParamColorInfoList.size());
- for (param_color_info_list_t::iterator iter = mInfo->mParamColorInfoList.begin();
- iter != mInfo->mParamColorInfoList.end();
- iter++)
- {
- LLTexParamGlobalColor* param_color = new LLTexParamGlobalColor(this);
- if (!param_color->setInfo(*iter, TRUE))
- {
- mInfo = NULL;
- return FALSE;
- }
- mParamGlobalColorList.push_back(param_color);
- }
-
- return TRUE;
-}
-
-LLColor4 LLTexGlobalColor::getColor() const
-{
- // Sum of color params
- if (mParamGlobalColorList.empty())
- return LLColor4(1.f, 1.f, 1.f, 1.f);
-
- LLColor4 net_color(0.f, 0.f, 0.f, 0.f);
- LLTexLayer::calculateTexLayerColor(mParamGlobalColorList, net_color);
- return net_color;
-}
-
-const std::string& LLTexGlobalColor::getName() const
-{
- return mInfo->mName;
-}
-
-//-----------------------------------------------------------------------------
-// LLTexParamGlobalColor
-//-----------------------------------------------------------------------------
-LLTexParamGlobalColor::LLTexParamGlobalColor(LLTexGlobalColor* tex_global_color) :
- LLTexLayerParamColor(tex_global_color->getAvatar()),
- mTexGlobalColor(tex_global_color)
-{
-}
-
-/*virtual*/ LLViewerVisualParam* LLTexParamGlobalColor::cloneParam(LLWearable* wearable) const
-{
- LLTexParamGlobalColor *new_param = new LLTexParamGlobalColor(mTexGlobalColor);
- *new_param = *this;
- return new_param;
-}
-
-void LLTexParamGlobalColor::onGlobalColorChanged(bool upload_bake)
-{
- mAvatar->onGlobalColorChanged(mTexGlobalColor, upload_bake);
-}
-
-//-----------------------------------------------------------------------------
-// LLTexGlobalColorInfo
-//-----------------------------------------------------------------------------
-
-LLTexGlobalColorInfo::LLTexGlobalColorInfo()
-{
-}
-
-
-LLTexGlobalColorInfo::~LLTexGlobalColorInfo()
-{
- for_each(mParamColorInfoList.begin(), mParamColorInfoList.end(), DeletePointer());
-}
-
-BOOL LLTexGlobalColorInfo::parseXml(LLXmlTreeNode* node)
-{
- // name attribute
- static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
- if (!node->getFastAttributeString(name_string, mName))
- {
- llwarns << "<global_color> element is missing name attribute." << llendl;
- return FALSE;
- }
- // <param> sub-element
- for (LLXmlTreeNode* child = node->getChildByName("param");
- child;
- child = node->getNextNamedChild())
- {
- if (child->getChildByName("param_color"))
- {
- // <param><param_color/></param>
- LLTexLayerParamColorInfo* info = new LLTexLayerParamColorInfo();
- if (!info->parseXml(child))
- {
- delete info;
- return FALSE;
- }
- mParamColorInfoList.push_back(info);
- }
- }
- return TRUE;
-}
diff --git a/indra/newview/lltexglobalcolor.h b/indra/newview/lltexglobalcolor.h
deleted file mode 100644
index ae04798445..0000000000
--- a/indra/newview/lltexglobalcolor.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * @file lltexglobalcolor.h
- * @brief This is global texture color info used by llvoavatar.
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTEXGLOBALCOLOR_H
-#define LL_LLTEXGLOBALCOLOR_H
-
-#include "lltexlayer.h"
-#include "lltexlayerparams.h"
-
-class LLVOAvatar;
-class LLWearable;
-class LLTexGlobalColorInfo;
-
-class LLTexGlobalColor
-{
-public:
- LLTexGlobalColor( LLVOAvatar* avatar );
- ~LLTexGlobalColor();
-
- LLTexGlobalColorInfo* getInfo() const { return mInfo; }
- // This sets mInfo and calls initialization functions
- BOOL setInfo(LLTexGlobalColorInfo *info);
-
- LLVOAvatar* getAvatar() const { return mAvatar; }
- LLColor4 getColor() const;
- const std::string& getName() const;
-
-private:
- param_color_list_t mParamGlobalColorList;
- LLVOAvatar* mAvatar; // just backlink, don't LLPointer
- LLTexGlobalColorInfo *mInfo;
-};
-
-// Used by llvoavatar to determine skin/eye/hair color.
-class LLTexGlobalColorInfo
-{
- friend class LLTexGlobalColor;
-public:
- LLTexGlobalColorInfo();
- ~LLTexGlobalColorInfo();
-
- BOOL parseXml(LLXmlTreeNode* node);
-
-private:
- param_color_info_list_t mParamColorInfoList;
- std::string mName;
-};
-
-class LLTexParamGlobalColor : public LLTexLayerParamColor
-{
-public:
- LLTexParamGlobalColor(LLTexGlobalColor *tex_color);
- /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
-protected:
- /*virtual*/ void onGlobalColorChanged(bool upload_bake);
-private:
- LLTexGlobalColor* mTexGlobalColor;
-};
-
-#endif
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
deleted file mode 100644
index 467115c928..0000000000
--- a/indra/newview/lltexlayer.cpp
+++ /dev/null
@@ -1,2508 +0,0 @@
-/**
- * @file lltexlayer.cpp
- * @brief A texture layer. Used for avatars.
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lltexlayer.h"
-
-#include "llagent.h"
-#include "llimagej2c.h"
-#include "llimagetga.h"
-#include "llnotificationsutil.h"
-#include "llvfile.h"
-#include "llvfs.h"
-#include "llviewerstats.h"
-#include "llviewerregion.h"
-#include "llvoavatar.h"
-#include "llvoavatarself.h"
-#include "pipeline.h"
-#include "llassetuploadresponders.h"
-#include "lltexlayerparams.h"
-#include "llui.h"
-#include "llagentwearables.h"
-#include "llwearable.h"
-#include "llviewercontrol.h"
-#include "llviewershadermgr.h"
-#include "llviewervisualparam.h"
-
-//#include "../tools/imdebug/imdebug.h"
-
-using namespace LLVOAvatarDefines;
-
-static const S32 BAKE_UPLOAD_ATTEMPTS = 7;
-static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power of 2 each attempt
-
-// runway consolidate
-extern std::string self_av_string();
-
-class LLTexLayerInfo
-{
- friend class LLTexLayer;
- friend class LLTexLayerTemplate;
- friend class LLTexLayerInterface;
-public:
- LLTexLayerInfo();
- ~LLTexLayerInfo();
-
- BOOL parseXml(LLXmlTreeNode* node);
- BOOL createVisualParams(LLVOAvatar *avatar);
- BOOL isUserSettable() { return mLocalTexture != -1; }
- S32 getLocalTexture() const { return mLocalTexture; }
- BOOL getOnlyAlpha() const { return mUseLocalTextureAlphaOnly; }
- std::string getName() const { return mName; }
-
-private:
- std::string mName;
-
- BOOL mWriteAllChannels; // Don't use masking. Just write RGBA into buffer,
- LLTexLayerInterface::ERenderPass mRenderPass;
-
- std::string mGlobalColor;
- LLColor4 mFixedColor;
-
- S32 mLocalTexture;
- std::string mStaticImageFileName;
- BOOL mStaticImageIsMask;
- BOOL mUseLocalTextureAlphaOnly; // Ignore RGB channels from the input texture. Use alpha as a mask
- BOOL mIsVisibilityMask;
-
- typedef std::vector< std::pair< std::string,BOOL > > morph_name_list_t;
- morph_name_list_t mMorphNameList;
- param_color_info_list_t mParamColorInfoList;
- param_alpha_info_list_t mParamAlphaInfoList;
-};
-
-//-----------------------------------------------------------------------------
-// LLBakedUploadData()
-//-----------------------------------------------------------------------------
-LLBakedUploadData::LLBakedUploadData(const LLVOAvatarSelf* avatar,
- LLTexLayerSet* layerset,
- const LLUUID& id,
- bool highest_res) :
- mAvatar(avatar),
- mTexLayerSet(layerset),
- mID(id),
- mStartTime(LLFrameTimer::getTotalTime()), // Record starting time
- mIsHighestRes(highest_res)
-{
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayerSetBuffer
-// The composite image that a LLTexLayerSet writes to. Each LLTexLayerSet has one.
-//-----------------------------------------------------------------------------
-
-// static
-S32 LLTexLayerSetBuffer::sGLByteCount = 0;
-
-LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLTexLayerSet* const owner,
- S32 width, S32 height) :
- // ORDER_LAST => must render these after the hints are created.
- LLViewerDynamicTexture( width, height, 4, LLViewerDynamicTexture::ORDER_LAST, TRUE ),
- mUploadPending(FALSE), // Not used for any logic here, just to sync sending of updates
- mNeedsUpload(FALSE),
- mNumLowresUploads(0),
- mUploadFailCount(0),
- mNeedsUpdate(TRUE),
- mNumLowresUpdates(0),
- mTexLayerSet(owner)
-{
- LLTexLayerSetBuffer::sGLByteCount += getSize();
- mNeedsUploadTimer.start();
- mNeedsUpdateTimer.start();
-}
-
-LLTexLayerSetBuffer::~LLTexLayerSetBuffer()
-{
- LLTexLayerSetBuffer::sGLByteCount -= getSize();
- destroyGLTexture();
- for( S32 order = 0; order < ORDER_COUNT; order++ )
- {
- LLViewerDynamicTexture::sInstances[order].erase(this); // will fail in all but one case.
- }
-}
-
-//virtual
-S8 LLTexLayerSetBuffer::getType() const
-{
- return LLViewerDynamicTexture::LL_TEX_LAYER_SET_BUFFER ;
-}
-
-//virtual
-void LLTexLayerSetBuffer::restoreGLTexture()
-{
- LLViewerDynamicTexture::restoreGLTexture() ;
-}
-
-//virtual
-void LLTexLayerSetBuffer::destroyGLTexture()
-{
- LLViewerDynamicTexture::destroyGLTexture() ;
-}
-
-// static
-void LLTexLayerSetBuffer::dumpTotalByteCount()
-{
- llinfos << "Composite System GL Buffers: " << (LLTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl;
-}
-
-void LLTexLayerSetBuffer::requestUpdate()
-{
- restartUpdateTimer();
- mNeedsUpdate = TRUE;
- mNumLowresUpdates = 0;
- // If we're in the middle of uploading a baked texture, we don't care about it any more.
- // When it's downloaded, ignore it.
- mUploadID.setNull();
-}
-
-void LLTexLayerSetBuffer::requestUpload()
-{
- conditionalRestartUploadTimer();
- mNeedsUpload = TRUE;
- mNumLowresUploads = 0;
- mUploadPending = TRUE;
-}
-
-void LLTexLayerSetBuffer::conditionalRestartUploadTimer()
-{
- // If we requested a new upload but haven't even uploaded
- // a low res version of our last upload request, then
- // keep the timer ticking instead of resetting it.
- if (mNeedsUpload && (mNumLowresUploads == 0))
- {
- mNeedsUploadTimer.unpause();
- }
- else
- {
- mNeedsUploadTimer.reset();
- mNeedsUploadTimer.start();
- }
-}
-
-void LLTexLayerSetBuffer::restartUpdateTimer()
-{
- mNeedsUpdateTimer.reset();
- mNeedsUpdateTimer.start();
-}
-
-void LLTexLayerSetBuffer::cancelUpload()
-{
- mNeedsUpload = FALSE;
- mUploadPending = FALSE;
- mNeedsUploadTimer.pause();
- mUploadRetryTimer.reset();
-}
-
-void LLTexLayerSetBuffer::pushProjection() const
-{
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f);
-
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.pushMatrix();
- gGL.loadIdentity();
-}
-
-void LLTexLayerSetBuffer::popProjection() const
-{
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.popMatrix();
-
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
-}
-
-BOOL LLTexLayerSetBuffer::needsRender()
-{
- llassert(mTexLayerSet->getAvatar() == gAgentAvatarp);
- if (!isAgentAvatarValid()) return FALSE;
-
- const BOOL upload_now = mNeedsUpload && isReadyToUpload();
- const BOOL update_now = mNeedsUpdate && isReadyToUpdate();
-
- // Don't render if we don't want to (or aren't ready to) upload or update.
- if (!(update_now || upload_now))
- {
- return FALSE;
- }
-
- // Don't render if we're animating our appearance.
- if (gAgentAvatarp->getIsAppearanceAnimating())
- {
- return FALSE;
- }
-
- // Don't render if we are trying to create a shirt texture but aren't wearing a skirt.
- if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLVOAvatarDefines::TEX_SKIRT_BAKED &&
- !gAgentAvatarp->isWearingWearableType(LLWearableType::WT_SKIRT))
- {
- cancelUpload();
- return FALSE;
- }
-
- // Render if we have at least minimal level of detail for each local texture.
- return mTexLayerSet->isLocalTextureDataAvailable();
-}
-
-void LLTexLayerSetBuffer::preRender(BOOL clear_depth)
-{
- // Set up an ortho projection
- pushProjection();
-
- // keep depth buffer, we don't need to clear it
- LLViewerDynamicTexture::preRender(FALSE);
-}
-
-void LLTexLayerSetBuffer::postRender(BOOL success)
-{
- popProjection();
-
- LLViewerDynamicTexture::postRender(success);
-}
-
-BOOL LLTexLayerSetBuffer::render()
-{
- // Default color mask for tex layer render
- gGL.setColorMask(true, true);
-
- // do we need to upload, and do we have sufficient data to create an uploadable composite?
- // TODO: When do we upload the texture if gAgent.mNumPendingQueries is non-zero?
- const BOOL upload_now = mNeedsUpload && isReadyToUpload();
- const BOOL update_now = mNeedsUpdate && isReadyToUpdate();
-
- BOOL success = TRUE;
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- if (use_shaders)
- {
- gAlphaMaskProgram.bind();
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
-
- LLVertexBuffer::unbind();
-
- // Composite the color data
- LLGLSUIDefault gls_ui;
- success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight );
- gGL.flush();
-
- if(upload_now)
- {
- if (!success)
- {
- llinfos << "Failed attempt to bake " << mTexLayerSet->getBodyRegionName() << llendl;
- mUploadPending = FALSE;
- }
- else
- {
- if (mTexLayerSet->isVisible())
- {
- mTexLayerSet->getAvatar()->debugBakedTextureUpload(mTexLayerSet->getBakedTexIndex(), FALSE); // FALSE for start of upload, TRUE for finish.
- doUpload();
- }
- else
- {
- mUploadPending = FALSE;
- mNeedsUpload = FALSE;
- mNeedsUploadTimer.pause();
- mTexLayerSet->getAvatar()->setNewBakedTexture(mTexLayerSet->getBakedTexIndex(),IMG_INVISIBLE);
- }
- }
- }
-
- if (update_now)
- {
- doUpdate();
- }
-
- if (use_shaders)
- {
- gAlphaMaskProgram.unbind();
- }
-
- LLVertexBuffer::unbind();
-
- // reset GL state
- gGL.setColorMask(true, true);
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
-
- // we have valid texture data now
- mGLTexturep->setGLTextureCreated(true);
-
- return success;
-}
-
-BOOL LLTexLayerSetBuffer::isInitialized(void) const
-{
- return mGLTexturep.notNull() && mGLTexturep->isGLTextureCreated();
-}
-
-BOOL LLTexLayerSetBuffer::uploadPending() const
-{
- return mUploadPending;
-}
-
-BOOL LLTexLayerSetBuffer::uploadNeeded() const
-{
- return mNeedsUpload;
-}
-
-BOOL LLTexLayerSetBuffer::uploadInProgress() const
-{
- return !mUploadID.isNull();
-}
-
-BOOL LLTexLayerSetBuffer::isReadyToUpload() const
-{
- if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries.
- if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures()) return FALSE; // Don't upload if avatar is using composites.
-
- BOOL ready = FALSE;
- if (mTexLayerSet->isLocalTextureDataFinal())
- {
- // If we requested an upload and have the final LOD ready, upload (or wait a while if this is a retry)
- if (mUploadFailCount == 0)
- {
- ready = TRUE;
- }
- else
- {
- ready = mUploadRetryTimer.getElapsedTimeF32() >= BAKE_UPLOAD_RETRY_DELAY * (1 << (mUploadFailCount - 1));
- }
- }
- else
- {
- // Upload if we've hit a timeout. Upload is a pretty expensive process so we need to make sure
- // we aren't doing uploads too frequently.
- const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureUploadTimeout");
- if (texture_timeout != 0)
- {
- // The timeout period increases exponentially between every lowres upload in order to prevent
- // spamming the server with frequent uploads.
- const U32 texture_timeout_threshold = texture_timeout*(1 << mNumLowresUploads);
-
- // If we hit our timeout and have textures available at even lower resolution, then upload.
- const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout_threshold;
- const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable();
- ready = has_lower_lod && is_upload_textures_timeout;
- }
- }
-
- return ready;
-}
-
-BOOL LLTexLayerSetBuffer::isReadyToUpdate() const
-{
- // If we requested an update and have the final LOD ready, then update.
- if (mTexLayerSet->isLocalTextureDataFinal()) return TRUE;
-
- // If we haven't done an update yet, then just do one now regardless of state of textures.
- if (mNumLowresUpdates == 0) return TRUE;
-
- // Update if we've hit a timeout. Unlike for uploads, we can make this timeout fairly small
- // since render unnecessarily doesn't cost much.
- const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedLocalTextureUpdateTimeout");
- if (texture_timeout != 0)
- {
- // If we hit our timeout and have textures available at even lower resolution, then update.
- const BOOL is_update_textures_timeout = mNeedsUpdateTimer.getElapsedTimeF32() >= texture_timeout;
- const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable();
- if (has_lower_lod && is_update_textures_timeout) return TRUE;
- }
-
- return FALSE;
-}
-
-BOOL LLTexLayerSetBuffer::requestUpdateImmediate()
-{
- mNeedsUpdate = TRUE;
- BOOL result = FALSE;
-
- if (needsRender())
- {
- preRender(FALSE);
- result = render();
- postRender(result);
- }
-
- return result;
-}
-
-// Create the baked texture, send it out to the server, then wait for it to come
-// back so we can switch to using it.
-void LLTexLayerSetBuffer::doUpload()
-{
- llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl;
- LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES);
-
- // Don't need caches since we're baked now. (note: we won't *really* be baked
- // until this image is sent to the server and the Avatar Appearance message is received.)
- mTexLayerSet->deleteCaches();
-
- // Get the COLOR information from our texture
- U8* baked_color_data = new U8[ mFullWidth * mFullHeight * 4 ];
- glReadPixels(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_color_data );
- stop_glerror();
-
- // Get the MASK information from our texture
- LLGLSUIDefault gls_ui;
- LLPointer<LLImageRaw> baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 );
- U8* baked_mask_data = baked_mask_image->getData();
- mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight);
-
-
- // Create the baked image from our color and mask information
- const S32 baked_image_components = 5; // red green blue [bump] clothing
- LLPointer<LLImageRaw> baked_image = new LLImageRaw( mFullWidth, mFullHeight, baked_image_components );
- U8* baked_image_data = baked_image->getData();
- S32 i = 0;
- for (S32 u=0; u < mFullWidth; u++)
- {
- for (S32 v=0; v < mFullHeight; v++)
- {
- baked_image_data[5*i + 0] = baked_color_data[4*i + 0];
- baked_image_data[5*i + 1] = baked_color_data[4*i + 1];
- baked_image_data[5*i + 2] = baked_color_data[4*i + 2];
- baked_image_data[5*i + 3] = baked_color_data[4*i + 3]; // alpha should be correct for eyelashes.
- baked_image_data[5*i + 4] = baked_mask_data[i];
- i++;
- }
- }
-
- LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C;
- const char* comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // writes into baked_color_data. 5 channels (rgb, heightfield/alpha, mask)
- if (compressedImage->encode(baked_image, comment_text))
- {
- LLTransactionID tid;
- tid.generate();
- const LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- if (LLVFile::writeFile(compressedImage->getData(), compressedImage->getDataSize(),
- gVFS, asset_id, LLAssetType::AT_TEXTURE))
- {
- // Read back the file and validate.
- BOOL valid = FALSE;
- LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C;
- S32 file_size = 0;
- U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size);
- if (data)
- {
- valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'
- }
- else
- {
- integrity_test->setLastError("Unable to read entire file");
- }
-
- if (valid)
- {
- const bool highest_lod = mTexLayerSet->isLocalTextureDataFinal();
- // Baked_upload_data is owned by the responder and deleted after the request completes.
- LLBakedUploadData* baked_upload_data = new LLBakedUploadData(gAgentAvatarp,
- this->mTexLayerSet,
- asset_id,
- highest_lod);
- // upload ID is used to avoid overlaps, e.g. when the user rapidly makes two changes outside of Face Edit.
- mUploadID = asset_id;
-
- // Upload the image
- const std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture");
- if(!url.empty()
- && !LLPipeline::sForceOldBakedUpload // toggle debug setting UploadBakedTexOld to change between the new caps method and old method
- && (mUploadFailCount < (BAKE_UPLOAD_ATTEMPTS - 1))) // Try last ditch attempt via asset store if cap upload is failing.
- {
- LLSD body = LLSD::emptyMap();
- // The responder will call LLTexLayerSetBuffer::onTextureUploadComplete()
- LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
- llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl;
- }
- else
- {
- gAssetStorage->storeAssetData(tid,
- LLAssetType::AT_TEXTURE,
- LLTexLayerSetBuffer::onTextureUploadComplete,
- baked_upload_data,
- TRUE, // temp_file
- TRUE, // is_priority
- TRUE); // store_local
- llinfos << "Baked texture upload via Asset Store." << llendl;
- }
-
- if (highest_lod)
- {
- // Sending the final LOD for the baked texture. All done, pause
- // the upload timer so we know how long it took.
- mNeedsUpload = FALSE;
- mNeedsUploadTimer.pause();
- }
- else
- {
- // Sending a lower level LOD for the baked texture. Restart the upload timer.
- mNumLowresUploads++;
- mNeedsUploadTimer.unpause();
- mNeedsUploadTimer.reset();
- }
-
- // Print out notification that we uploaded this texture.
- if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
- {
- const std::string lod_str = highest_lod ? "HighRes" : "LowRes";
- LLSD args;
- args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32());
- args["TIME"] = llformat("%d",(U32)mNeedsUploadTimer.getElapsedTimeF32());
- args["BODYREGION"] = mTexLayerSet->getBodyRegionName();
- args["RESOLUTION"] = lod_str;
- LLNotificationsUtil::add("AvatarRezSelfBakedTextureUploadNotification",args);
- LL_DEBUGS("Avatar") << self_av_string() << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << LL_ENDL;
- }
- }
- else
- {
- // The read back and validate operation failed. Remove the uploaded file.
- mUploadPending = FALSE;
- LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE, LLVFile::WRITE);
- file.remove();
- llinfos << "Unable to create baked upload file (reason: corrupted)." << llendl;
- }
- }
- }
- else
- {
- // The VFS write file operation failed.
- mUploadPending = FALSE;
- llinfos << "Unable to create baked upload file (reason: failed to write file)" << llendl;
- }
-
- delete [] baked_color_data;
-}
-
-// Mostly bookkeeping; don't need to actually "do" anything since
-// render() will actually do the update.
-void LLTexLayerSetBuffer::doUpdate()
-{
- const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
- if (highest_lod)
- {
- mNeedsUpdate = FALSE;
- }
- else
- {
- mNumLowresUpdates++;
- }
-
- restartUpdateTimer();
-
- // need to swtich to using this layerset if this is the first update
- // after getting the lowest LOD
- mTexLayerSet->getAvatar()->updateMeshTextures();
-
- // Print out notification that we uploaded this texture.
- if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
- {
- const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
- const std::string lod_str = highest_lod ? "HighRes" : "LowRes";
- LLSD args;
- args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32());
- args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32());
- args["BODYREGION"] = mTexLayerSet->getBodyRegionName();
- args["RESOLUTION"] = lod_str;
- LLNotificationsUtil::add("AvatarRezSelfBakedTextureUpdateNotification",args);
- LL_DEBUGS("Avatar") << self_av_string() << "Locally updating [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUpdateTimer.getElapsedTimeF32() << " ]" << LL_ENDL;
- }
-}
-
-// static
-void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
- void* userdata,
- S32 result,
- LLExtStat ext_status) // StoreAssetData callback (not fixed)
-{
- LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata;
-
- if (isAgentAvatarValid() &&
- !gAgentAvatarp->isDead() &&
- (baked_upload_data->mAvatar == gAgentAvatarp) && // Sanity check: only the user's avatar should be uploading textures.
- (baked_upload_data->mTexLayerSet->hasComposite()))
- {
- LLTexLayerSetBuffer* layerset_buffer = baked_upload_data->mTexLayerSet->getComposite();
- S32 failures = layerset_buffer->mUploadFailCount;
- layerset_buffer->mUploadFailCount = 0;
-
- if (layerset_buffer->mUploadID.isNull())
- {
- // The upload got canceled, we should be in the
- // process of baking a new texture so request an
- // upload with the new data
-
- // BAP: does this really belong in this callback, as
- // opposed to where the cancellation takes place?
- // suspect this does nothing.
- layerset_buffer->requestUpload();
- }
- else if (baked_upload_data->mID == layerset_buffer->mUploadID)
- {
- // This is the upload we're currently waiting for.
- layerset_buffer->mUploadID.setNull();
- const std::string name(baked_upload_data->mTexLayerSet->getBodyRegionName());
- const std::string resolution = baked_upload_data->mIsHighestRes ? " full res " : " low res ";
- if (result >= 0)
- {
- layerset_buffer->mUploadPending = FALSE; // Allows sending of AgentSetAppearance later
- LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet);
- // Update baked texture info with the new UUID
- U64 now = LLFrameTimer::getTotalTime(); // Record starting time
- llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl;
- gAgentAvatarp->setNewBakedTexture(baked_te, uuid);
- }
- else
- {
- ++failures;
- S32 max_attempts = baked_upload_data->mIsHighestRes ? BAKE_UPLOAD_ATTEMPTS : 1; // only retry final bakes
- llwarns << "Baked" << resolution << "texture upload for " << name << " failed (attempt " << failures << "/" << max_attempts << ")" << llendl;
- if (failures < max_attempts)
- {
- layerset_buffer->mUploadFailCount = failures;
- layerset_buffer->mUploadRetryTimer.start();
- layerset_buffer->requestUpload();
- }
- }
- }
- else
- {
- llinfos << "Received baked texture out of date, ignored." << llendl;
- }
-
- gAgentAvatarp->dirtyMesh();
- }
- else
- {
- // Baked texture failed to upload (in which case since we
- // didn't set the new baked texture, it means that they'll try
- // and rebake it at some point in the future (after login?)),
- // or this response to upload is out of date, in which case a
- // current response should be on the way or already processed.
- llwarns << "Baked upload failed" << llendl;
- }
-
- delete baked_upload_data;
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayerSet
-// An ordered set of texture layers that get composited into a single texture.
-//-----------------------------------------------------------------------------
-
-LLTexLayerSetInfo::LLTexLayerSetInfo() :
- mBodyRegion( "" ),
- mWidth( 512 ),
- mHeight( 512 ),
- mClearAlpha( TRUE )
-{
-}
-
-LLTexLayerSetInfo::~LLTexLayerSetInfo( )
-{
- std::for_each(mLayerInfoList.begin(), mLayerInfoList.end(), DeletePointer());
-}
-
-BOOL LLTexLayerSetInfo::parseXml(LLXmlTreeNode* node)
-{
- llassert( node->hasName( "layer_set" ) );
- if( !node->hasName( "layer_set" ) )
- {
- return FALSE;
- }
-
- // body_region
- static LLStdStringHandle body_region_string = LLXmlTree::addAttributeString("body_region");
- if( !node->getFastAttributeString( body_region_string, mBodyRegion ) )
- {
- llwarns << "<layer_set> is missing body_region attribute" << llendl;
- return FALSE;
- }
-
- // width, height
- static LLStdStringHandle width_string = LLXmlTree::addAttributeString("width");
- if( !node->getFastAttributeS32( width_string, mWidth ) )
- {
- return FALSE;
- }
-
- static LLStdStringHandle height_string = LLXmlTree::addAttributeString("height");
- if( !node->getFastAttributeS32( height_string, mHeight ) )
- {
- return FALSE;
- }
-
- // Optional alpha component to apply after all compositing is complete.
- static LLStdStringHandle alpha_tga_file_string = LLXmlTree::addAttributeString("alpha_tga_file");
- node->getFastAttributeString( alpha_tga_file_string, mStaticAlphaFileName );
-
- static LLStdStringHandle clear_alpha_string = LLXmlTree::addAttributeString("clear_alpha");
- node->getFastAttributeBOOL( clear_alpha_string, mClearAlpha );
-
- // <layer>
- for (LLXmlTreeNode* child = node->getChildByName( "layer" );
- child;
- child = node->getNextNamedChild())
- {
- LLTexLayerInfo* info = new LLTexLayerInfo();
- if( !info->parseXml( child ))
- {
- delete info;
- return FALSE;
- }
- mLayerInfoList.push_back( info );
- }
- return TRUE;
-}
-
-// creates visual params without generating layersets or layers
-void LLTexLayerSetInfo::createVisualParams(LLVOAvatar *avatar)
-{
- //layer_info_list_t mLayerInfoList;
- for (layer_info_list_t::iterator layer_iter = mLayerInfoList.begin();
- layer_iter != mLayerInfoList.end();
- layer_iter++)
- {
- LLTexLayerInfo *layer_info = *layer_iter;
- layer_info->createVisualParams(avatar);
- }
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayerSet
-// An ordered set of texture layers that get composited into a single texture.
-//-----------------------------------------------------------------------------
-
-BOOL LLTexLayerSet::sHasCaches = FALSE;
-
-LLTexLayerSet::LLTexLayerSet(LLVOAvatarSelf* const avatar) :
- mComposite( NULL ),
- mAvatar( avatar ),
- mUpdatesEnabled( FALSE ),
- mIsVisible( TRUE ),
- mBakedTexIndex(LLVOAvatarDefines::BAKED_HEAD),
- mInfo( NULL )
-{
-}
-
-LLTexLayerSet::~LLTexLayerSet()
-{
- deleteCaches();
- std::for_each(mLayerList.begin(), mLayerList.end(), DeletePointer());
- std::for_each(mMaskLayerList.begin(), mMaskLayerList.end(), DeletePointer());
-}
-
-//-----------------------------------------------------------------------------
-// setInfo
-//-----------------------------------------------------------------------------
-
-BOOL LLTexLayerSet::setInfo(const LLTexLayerSetInfo *info)
-{
- llassert(mInfo == NULL);
- mInfo = info;
- //mID = info->mID; // No ID
-
- mLayerList.reserve(info->mLayerInfoList.size());
- for (LLTexLayerSetInfo::layer_info_list_t::const_iterator iter = info->mLayerInfoList.begin();
- iter != info->mLayerInfoList.end();
- iter++)
- {
- LLTexLayerInterface *layer = NULL;
- if ( (*iter)->isUserSettable() )
- {
- layer = new LLTexLayerTemplate( this );
- }
- else
- {
- layer = new LLTexLayer(this);
- }
- // this is the first time this layer (of either type) is being created - make sure you add the parameters to the avatar
- if (!layer->setInfo(*iter, NULL))
- {
- mInfo = NULL;
- return FALSE;
- }
- if (!layer->isVisibilityMask())
- {
- mLayerList.push_back( layer );
- }
- else
- {
- mMaskLayerList.push_back(layer);
- }
- }
-
- requestUpdate();
-
- stop_glerror();
-
- return TRUE;
-}
-
-#if 0 // obsolete
-//-----------------------------------------------------------------------------
-// parseData
-//-----------------------------------------------------------------------------
-
-BOOL LLTexLayerSet::parseData(LLXmlTreeNode* node)
-{
- LLTexLayerSetInfo *info = new LLTexLayerSetInfo;
-
- if (!info->parseXml(node))
- {
- delete info;
- return FALSE;
- }
- if (!setInfo(info))
- {
- delete info;
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
-void LLTexLayerSet::deleteCaches()
-{
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- layer->deleteCaches();
- }
- for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++)
- {
- LLTexLayerInterface* layer = *iter;
- layer->deleteCaches();
- }
-}
-
-// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on.
-BOOL LLTexLayerSet::isLocalTextureDataAvailable() const
-{
- if (!mAvatar->isSelf()) return FALSE;
- return ((LLVOAvatarSelf *)mAvatar)->isLocalTextureDataAvailable(this);
-}
-
-
-// Returns TRUE if all of the data for the textures that this layerset depends on have arrived.
-BOOL LLTexLayerSet::isLocalTextureDataFinal() const
-{
- if (!mAvatar->isSelf()) return FALSE;
- return ((LLVOAvatarSelf *)mAvatar)->isLocalTextureDataFinal(this);
-}
-
-
-BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
-{
- BOOL success = TRUE;
- mIsVisible = TRUE;
-
- if (mMaskLayerList.size() > 0)
- {
- for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++)
- {
- LLTexLayerInterface* layer = *iter;
- if (layer->isInvisibleAlphaMask())
- {
- mIsVisible = FALSE;
- }
- }
- }
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- LLGLSUIDefault gls_ui;
- LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE);
- gGL.setColorMask(true, true);
-
- // clear buffer area to ensure we don't pick up UI elements
- {
- gGL.flush();
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.0f);
- }
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4f( 0.f, 0.f, 0.f, 1.f );
-
- gl_rect_2d_simple( width, height );
-
- gGL.flush();
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
-
- if (mIsVisible)
- {
- // composite color layers
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- if (layer->getRenderPass() == LLTexLayer::RP_COLOR)
- {
- gGL.flush();
- success &= layer->render(x, y, width, height);
- gGL.flush();
- }
- }
-
- renderAlphaMaskTextures(x, y, width, height, false);
-
- stop_glerror();
- }
- else
- {
- gGL.flush();
-
- gGL.setSceneBlendType(LLRender::BT_REPLACE);
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
-
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4f( 0.f, 0.f, 0.f, 0.f );
-
- gl_rect_2d_simple( width, height );
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
-
- gGL.flush();
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
-
- return success;
-}
-
-
-BOOL LLTexLayerSet::isBodyRegion(const std::string& region) const
-{
- return mInfo->mBodyRegion == region;
-}
-
-const std::string LLTexLayerSet::getBodyRegionName() const
-{
- return mInfo->mBodyRegion;
-}
-
-void LLTexLayerSet::requestUpdate()
-{
- if( mUpdatesEnabled )
- {
- createComposite();
- mComposite->requestUpdate();
- }
-}
-
-void LLTexLayerSet::requestUpload()
-{
- createComposite();
- mComposite->requestUpload();
-}
-
-void LLTexLayerSet::cancelUpload()
-{
- if(mComposite)
- {
- mComposite->cancelUpload();
- }
-}
-
-void LLTexLayerSet::createComposite()
-{
- if(!mComposite)
- {
- S32 width = mInfo->mWidth;
- S32 height = mInfo->mHeight;
- // Composite other avatars at reduced resolution
- if( !mAvatar->isSelf() )
- {
- llerrs << "composites should not be created for non-self avatars!" << llendl;
- }
- mComposite = new LLTexLayerSetBuffer( this, width, height );
- }
-}
-
-void LLTexLayerSet::destroyComposite()
-{
- if( mComposite )
- {
- mComposite = NULL;
- }
-}
-
-void LLTexLayerSet::setUpdatesEnabled( BOOL b )
-{
- mUpdatesEnabled = b;
-}
-
-
-void LLTexLayerSet::updateComposite()
-{
- createComposite();
- mComposite->requestUpdateImmediate();
-}
-
-LLTexLayerSetBuffer* LLTexLayerSet::getComposite()
-{
- if (!mComposite)
- {
- createComposite();
- }
- return mComposite;
-}
-
-const LLTexLayerSetBuffer* LLTexLayerSet::getComposite() const
-{
- return mComposite;
-}
-
-void LLTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height)
-{
- memset(data, 255, width * height);
-
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height);
- }
-
- // Set alpha back to that of our alpha masks.
- renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true);
-}
-
-void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear)
-{
- const LLTexLayerSetInfo *info = getInfo();
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- gGL.setColorMask(false, true);
- gGL.setSceneBlendType(LLRender::BT_REPLACE);
-
- // (Optionally) replace alpha with a single component image from a tga file.
- if (!info->mStaticAlphaFileName.empty())
- {
- gGL.flush();
- {
- LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE);
- if( tex )
- {
- LLGLSUIDefault gls_ui;
- gGL.getTexUnit(0)->bind(tex);
- gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE );
- gl_rect_2d_simple_tex( width, height );
- }
- }
- gGL.flush();
- }
- else if (forceClear || info->mClearAlpha || (mMaskLayerList.size() > 0))
- {
- // Set the alpha channel to one (clean up after previous blending)
- gGL.flush();
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4f( 0.f, 0.f, 0.f, 1.f );
-
- gl_rect_2d_simple( width, height );
-
- gGL.flush();
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
-
- // (Optional) Mask out part of the baked texture with alpha masks
- // will still have an effect even if mClearAlpha is set or the alpha component was replaced
- if (mMaskLayerList.size() > 0)
- {
- gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA);
- gGL.getTexUnit(0)->setTextureBlendType( LLTexUnit::TB_REPLACE );
- for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++)
- {
- LLTexLayerInterface* layer = *iter;
- gGL.flush();
- layer->blendAlphaTexture(x,y,width, height);
- gGL.flush();
- }
-
- }
-
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
- gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
- gGL.setColorMask(true, true);
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
-}
-
-void LLTexLayerSet::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components)
-{
- mAvatar->applyMorphMask(tex_data, width, height, num_components, mBakedTexIndex);
-}
-
-BOOL LLTexLayerSet::isMorphValid() const
-{
- for(layer_list_t::const_iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- const LLTexLayerInterface* layer = *iter;
- if (layer && !layer->isMorphValid())
- {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-void LLTexLayerSet::invalidateMorphMasks()
-{
- for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- if (layer)
- {
- layer->invalidateMorphMasks();
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// LLTexLayerInfo
-//-----------------------------------------------------------------------------
-LLTexLayerInfo::LLTexLayerInfo() :
- mWriteAllChannels( FALSE ),
- mRenderPass(LLTexLayer::RP_COLOR),
- mFixedColor( 0.f, 0.f, 0.f, 0.f ),
- mLocalTexture( -1 ),
- mStaticImageIsMask( FALSE ),
- mUseLocalTextureAlphaOnly(FALSE),
- mIsVisibilityMask(FALSE)
-{
-}
-
-LLTexLayerInfo::~LLTexLayerInfo( )
-{
- std::for_each(mParamColorInfoList.begin(), mParamColorInfoList.end(), DeletePointer());
- std::for_each(mParamAlphaInfoList.begin(), mParamAlphaInfoList.end(), DeletePointer());
-}
-
-BOOL LLTexLayerInfo::parseXml(LLXmlTreeNode* node)
-{
- llassert( node->hasName( "layer" ) );
-
- // name attribute
- static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
- if( !node->getFastAttributeString( name_string, mName ) )
- {
- return FALSE;
- }
-
- static LLStdStringHandle write_all_channels_string = LLXmlTree::addAttributeString("write_all_channels");
- node->getFastAttributeBOOL( write_all_channels_string, mWriteAllChannels );
-
- std::string render_pass_name;
- static LLStdStringHandle render_pass_string = LLXmlTree::addAttributeString("render_pass");
- if( node->getFastAttributeString( render_pass_string, render_pass_name ) )
- {
- if( render_pass_name == "bump" )
- {
- mRenderPass = LLTexLayer::RP_BUMP;
- }
- }
-
- // Note: layers can have either a "global_color" attrib, a "fixed_color" attrib, or a <param_color> child.
- // global color attribute (optional)
- static LLStdStringHandle global_color_string = LLXmlTree::addAttributeString("global_color");
- node->getFastAttributeString( global_color_string, mGlobalColor );
-
- // Visibility mask (optional)
- BOOL is_visibility;
- static LLStdStringHandle visibility_mask_string = LLXmlTree::addAttributeString("visibility_mask");
- if (node->getFastAttributeBOOL(visibility_mask_string, is_visibility))
- {
- mIsVisibilityMask = is_visibility;
- }
-
- // color attribute (optional)
- LLColor4U color4u;
- static LLStdStringHandle fixed_color_string = LLXmlTree::addAttributeString("fixed_color");
- if( node->getFastAttributeColor4U( fixed_color_string, color4u ) )
- {
- mFixedColor.setVec( color4u );
- }
-
- // <texture> optional sub-element
- for (LLXmlTreeNode* texture_node = node->getChildByName( "texture" );
- texture_node;
- texture_node = node->getNextNamedChild())
- {
- std::string local_texture_name;
- static LLStdStringHandle tga_file_string = LLXmlTree::addAttributeString("tga_file");
- static LLStdStringHandle local_texture_string = LLXmlTree::addAttributeString("local_texture");
- static LLStdStringHandle file_is_mask_string = LLXmlTree::addAttributeString("file_is_mask");
- static LLStdStringHandle local_texture_alpha_only_string = LLXmlTree::addAttributeString("local_texture_alpha_only");
- if( texture_node->getFastAttributeString( tga_file_string, mStaticImageFileName ) )
- {
- texture_node->getFastAttributeBOOL( file_is_mask_string, mStaticImageIsMask );
- }
- else if (texture_node->getFastAttributeString(local_texture_string, local_texture_name))
- {
- texture_node->getFastAttributeBOOL( local_texture_alpha_only_string, mUseLocalTextureAlphaOnly );
-
- /* if ("upper_shirt" == local_texture_name)
- mLocalTexture = TEX_UPPER_SHIRT; */
- mLocalTexture = TEX_NUM_INDICES;
- for (LLVOAvatarDictionary::Textures::const_iterator iter = LLVOAvatarDictionary::getInstance()->getTextures().begin();
- iter != LLVOAvatarDictionary::getInstance()->getTextures().end();
- iter++)
- {
- const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second;
- if (local_texture_name == texture_dict->mName)
- {
- mLocalTexture = iter->first;
- break;
- }
- }
- if (mLocalTexture == TEX_NUM_INDICES)
- {
- llwarns << "<texture> element has invalid local_texture attribute: " << mName << " " << local_texture_name << llendl;
- return FALSE;
- }
- }
- else
- {
- llwarns << "<texture> element is missing a required attribute. " << mName << llendl;
- return FALSE;
- }
- }
-
- for (LLXmlTreeNode* maskNode = node->getChildByName( "morph_mask" );
- maskNode;
- maskNode = node->getNextNamedChild())
- {
- std::string morph_name;
- static LLStdStringHandle morph_name_string = LLXmlTree::addAttributeString("morph_name");
- if (maskNode->getFastAttributeString(morph_name_string, morph_name))
- {
- BOOL invert = FALSE;
- static LLStdStringHandle invert_string = LLXmlTree::addAttributeString("invert");
- maskNode->getFastAttributeBOOL(invert_string, invert);
- mMorphNameList.push_back(std::pair<std::string,BOOL>(morph_name,invert));
- }
- }
-
- // <param> optional sub-element (color or alpha params)
- for (LLXmlTreeNode* child = node->getChildByName( "param" );
- child;
- child = node->getNextNamedChild())
- {
- if( child->getChildByName( "param_color" ) )
- {
- // <param><param_color/></param>
- LLTexLayerParamColorInfo* info = new LLTexLayerParamColorInfo();
- if (!info->parseXml(child))
- {
- delete info;
- return FALSE;
- }
- mParamColorInfoList.push_back(info);
- }
- else if( child->getChildByName( "param_alpha" ) )
- {
- // <param><param_alpha/></param>
- LLTexLayerParamAlphaInfo* info = new LLTexLayerParamAlphaInfo( );
- if (!info->parseXml(child))
- {
- delete info;
- return FALSE;
- }
- mParamAlphaInfoList.push_back(info);
- }
- }
-
- return TRUE;
-}
-
-BOOL LLTexLayerInfo::createVisualParams(LLVOAvatar *avatar)
-{
- BOOL success = TRUE;
- for (param_color_info_list_t::iterator color_info_iter = mParamColorInfoList.begin();
- color_info_iter != mParamColorInfoList.end();
- color_info_iter++)
- {
- LLTexLayerParamColorInfo * color_info = *color_info_iter;
- LLTexLayerParamColor* param_color = new LLTexLayerParamColor(avatar);
- if (!param_color->setInfo(color_info, TRUE))
- {
- llwarns << "NULL TexLayer Color Param could not be added to visual param list. Deleting." << llendl;
- delete param_color;
- success = FALSE;
- }
- }
-
- for (param_alpha_info_list_t::iterator alpha_info_iter = mParamAlphaInfoList.begin();
- alpha_info_iter != mParamAlphaInfoList.end();
- alpha_info_iter++)
- {
- LLTexLayerParamAlphaInfo * alpha_info = *alpha_info_iter;
- LLTexLayerParamAlpha* param_alpha = new LLTexLayerParamAlpha(avatar);
- if (!param_alpha->setInfo(alpha_info, TRUE))
- {
- llwarns << "NULL TexLayer Alpha Param could not be added to visual param list. Deleting." << llendl;
- delete param_alpha;
- success = FALSE;
- }
- }
-
- return success;
-}
-
-LLTexLayerInterface::LLTexLayerInterface(LLTexLayerSet* const layer_set):
- mTexLayerSet( layer_set ),
- mMorphMasksValid( FALSE ),
- mInfo(NULL),
- mHasMorph(FALSE)
-{
-}
-
-LLTexLayerInterface::LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable):
- mTexLayerSet( layer.mTexLayerSet ),
- mInfo(NULL)
-{
- // don't add visual params for cloned layers
- setInfo(layer.getInfo(), wearable);
-
- mHasMorph = layer.mHasMorph;
-}
-
-BOOL LLTexLayerInterface::setInfo(const LLTexLayerInfo *info, LLWearable* wearable ) // This sets mInfo and calls initialization functions
-{
- // setInfo should only be called once. Code is not robust enough to handle redefinition of a texlayer.
- // Not a critical warning, but could be useful for debugging later issues. -Nyx
- if (mInfo != NULL)
- {
- llwarns << "mInfo != NULL" << llendl;
- }
- mInfo = info;
- //mID = info->mID; // No ID
-
- mParamColorList.reserve(mInfo->mParamColorInfoList.size());
- for (param_color_info_list_t::const_iterator iter = mInfo->mParamColorInfoList.begin();
- iter != mInfo->mParamColorInfoList.end();
- iter++)
- {
- LLTexLayerParamColor* param_color;
- if (!wearable)
- {
- param_color = new LLTexLayerParamColor(this);
- if (!param_color->setInfo(*iter, TRUE))
- {
- mInfo = NULL;
- return FALSE;
- }
- }
- else
- {
- param_color = (LLTexLayerParamColor*)wearable->getVisualParam((*iter)->getID());
- if (!param_color)
- {
- mInfo = NULL;
- return FALSE;
- }
- }
- mParamColorList.push_back( param_color );
- }
-
- mParamAlphaList.reserve(mInfo->mParamAlphaInfoList.size());
- for (param_alpha_info_list_t::const_iterator iter = mInfo->mParamAlphaInfoList.begin();
- iter != mInfo->mParamAlphaInfoList.end();
- iter++)
- {
- LLTexLayerParamAlpha* param_alpha;
- if (!wearable)
- {
- param_alpha = new LLTexLayerParamAlpha( this );
- if (!param_alpha->setInfo(*iter, TRUE))
- {
- mInfo = NULL;
- return FALSE;
- }
- }
- else
- {
- param_alpha = (LLTexLayerParamAlpha*) wearable->getVisualParam((*iter)->getID());
- if (!param_alpha)
- {
- mInfo = NULL;
- return FALSE;
- }
- }
- mParamAlphaList.push_back( param_alpha );
- }
-
- return TRUE;
-}
-
-/*virtual*/ void LLTexLayerInterface::requestUpdate()
-{
- mTexLayerSet->requestUpdate();
-}
-
-const std::string& LLTexLayerInterface::getName() const
-{
- return mInfo->mName;
-}
-
-LLTexLayerInterface::ERenderPass LLTexLayerInterface::getRenderPass() const
-{
- return mInfo->mRenderPass;
-}
-
-const std::string& LLTexLayerInterface::getGlobalColor() const
-{
- return mInfo->mGlobalColor;
-}
-
-BOOL LLTexLayerInterface::isVisibilityMask() const
-{
- return mInfo->mIsVisibilityMask;
-}
-
-void LLTexLayerInterface::invalidateMorphMasks()
-{
- mMorphMasksValid = FALSE;
-}
-
-LLViewerVisualParam* LLTexLayerInterface::getVisualParamPtr(S32 index) const
-{
- LLViewerVisualParam *result = NULL;
- for (param_color_list_t::const_iterator color_iter = mParamColorList.begin(); color_iter != mParamColorList.end() && !result; ++color_iter)
- {
- if ((*color_iter)->getID() == index)
- {
- result = *color_iter;
- }
- }
- for (param_alpha_list_t::const_iterator alpha_iter = mParamAlphaList.begin(); alpha_iter != mParamAlphaList.end() && !result; ++alpha_iter)
- {
- if ((*alpha_iter)->getID() == index)
- {
- result = *alpha_iter;
- }
- }
-
- return result;
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayer
-// A single texture layer, consisting of:
-// * color, consisting of either
-// * one or more color parameters (weighted colors)
-// * a reference to a global color
-// * a fixed color with non-zero alpha
-// * opaque white (the default)
-// * (optional) a texture defined by either
-// * a GUID
-// * a texture entry index (TE)
-// * (optional) one or more alpha parameters (weighted alpha textures)
-//-----------------------------------------------------------------------------
-LLTexLayer::LLTexLayer(LLTexLayerSet* const layer_set) :
- LLTexLayerInterface( layer_set ),
- mLocalTextureObject(NULL)
-{
-}
-
-LLTexLayer::LLTexLayer(const LLTexLayer &layer, LLWearable *wearable) :
- LLTexLayerInterface( layer, wearable ),
- mLocalTextureObject(NULL)
-{
-}
-
-LLTexLayer::LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable) :
- LLTexLayerInterface( layer_template, wearable ),
- mLocalTextureObject(lto)
-{
-}
-
-LLTexLayer::~LLTexLayer()
-{
- // mParamAlphaList and mParamColorList are LLViewerVisualParam's and get
- // deleted with ~LLCharacter()
- //std::for_each(mParamAlphaList.begin(), mParamAlphaList.end(), DeletePointer());
- //std::for_each(mParamColorList.begin(), mParamColorList.end(), DeletePointer());
-
- for( alpha_cache_t::iterator iter = mAlphaCache.begin();
- iter != mAlphaCache.end(); iter++ )
- {
- U8* alpha_data = iter->second;
- delete [] alpha_data;
- }
-
-}
-
-//-----------------------------------------------------------------------------
-// setInfo
-//-----------------------------------------------------------------------------
-
-BOOL LLTexLayer::setInfo(const LLTexLayerInfo* info, LLWearable* wearable )
-{
- return LLTexLayerInterface::setInfo(info, wearable);
-}
-
-//static
-void LLTexLayer::calculateTexLayerColor(const param_color_list_t &param_list, LLColor4 &net_color)
-{
- for (param_color_list_t::const_iterator iter = param_list.begin();
- iter != param_list.end(); iter++)
- {
- const LLTexLayerParamColor* param = *iter;
- LLColor4 param_net = param->getNetColor();
- const LLTexLayerParamColorInfo *info = (LLTexLayerParamColorInfo *)param->getInfo();
- switch(info->getOperation())
- {
- case LLTexLayerParamColor::OP_ADD:
- net_color += param_net;
- break;
- case LLTexLayerParamColor::OP_MULTIPLY:
- net_color = net_color * param_net;
- break;
- case LLTexLayerParamColor::OP_BLEND:
- net_color = lerp(net_color, param_net, param->getWeight());
- break;
- default:
- llassert(0);
- break;
- }
- }
- net_color.clamp();
-}
-
-/*virtual*/ void LLTexLayer::deleteCaches()
-{
- // Only need to delete caches for alpha params. Color params don't hold extra memory
- for (param_alpha_list_t::iterator iter = mParamAlphaList.begin();
- iter != mParamAlphaList.end(); iter++ )
- {
- LLTexLayerParamAlpha* param = *iter;
- param->deleteCaches();
- }
-}
-
-BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height)
-{
- LLGLEnable color_mat(GL_COLOR_MATERIAL);
- gPipeline.disableLights();
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- LLColor4 net_color;
- BOOL color_specified = findNetColor(&net_color);
-
- if (mTexLayerSet->getAvatar()->mIsDummy)
- {
- color_specified = true;
- net_color = LLVOAvatar::getDummyColor();
- }
-
- BOOL success = TRUE;
-
- // If you can't see the layer, don't render it.
- if( is_approx_zero( net_color.mV[VW] ) )
- {
- return success;
- }
-
- BOOL alpha_mask_specified = FALSE;
- param_alpha_list_t::const_iterator iter = mParamAlphaList.begin();
- if( iter != mParamAlphaList.end() )
- {
- // If we have alpha masks, but we're skipping all of them, skip the whole layer.
- // However, we can't do this optimization if we have morph masks that need updating.
-/* if (!mHasMorph)
- {
- BOOL skip_layer = TRUE;
-
- while( iter != mParamAlphaList.end() )
- {
- const LLTexLayerParamAlpha* param = *iter;
-
- if( !param->getSkip() )
- {
- skip_layer = FALSE;
- break;
- }
-
- iter++;
- }
-
- if( skip_layer )
- {
- return success;
- }
- }//*/
-
- renderMorphMasks(x, y, width, height, net_color);
- alpha_mask_specified = TRUE;
- gGL.flush();
- gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ONE_MINUS_DEST_ALPHA);
- }
-
- gGL.color4fv( net_color.mV);
-
- if( getInfo()->mWriteAllChannels )
- {
- gGL.flush();
- gGL.setSceneBlendType(LLRender::BT_REPLACE);
- }
-
- if( (getInfo()->mLocalTexture != -1) && !getInfo()->mUseLocalTextureAlphaOnly )
- {
- {
- LLViewerTexture* tex = NULL;
- if (mLocalTextureObject && mLocalTextureObject->getImage())
- {
- tex = mLocalTextureObject->getImage();
- if (mLocalTextureObject->getID() == IMG_DEFAULT_AVATAR)
- {
- tex = NULL;
- }
- }
- else
- {
- llinfos << "lto not defined or image not defined: " << getInfo()->getLocalTexture() << " lto: " << mLocalTextureObject << llendl;
- }
-// if( mTexLayerSet->getAvatar()->getLocalTextureGL((ETextureIndex)getInfo()->mLocalTexture, &image_gl ) )
- {
- if( tex )
- {
- bool no_alpha_test = getInfo()->mWriteAllChannels;
- LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0);
- if (use_shaders && no_alpha_test)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
-
- LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode();
-
- gGL.getTexUnit(0)->bind(tex, TRUE);
- gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
-
- gl_rect_2d_simple_tex( width, height );
-
- gGL.getTexUnit(0)->setTextureAddressMode(old_mode);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- if (use_shaders && no_alpha_test)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
-
- }
- }
-// else
-// {
-// success = FALSE;
-// }
- }
- }
-
- if( !getInfo()->mStaticImageFileName.empty() )
- {
- {
- LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask);
- if( tex )
- {
- gGL.getTexUnit(0)->bind(tex, TRUE);
- gl_rect_2d_simple_tex( width, height );
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- }
- else
- {
- success = FALSE;
- }
- }
- }
-
- if(((-1 == getInfo()->mLocalTexture) ||
- getInfo()->mUseLocalTextureAlphaOnly) &&
- getInfo()->mStaticImageFileName.empty() &&
- color_specified )
- {
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4fv( net_color.mV );
- gl_rect_2d_simple( width, height );
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
-
- if( alpha_mask_specified || getInfo()->mWriteAllChannels )
- {
- // Restore standard blend func value
- gGL.flush();
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
- stop_glerror();
- }
-
- if( !success )
- {
- llinfos << "LLTexLayer::render() partial: " << getInfo()->mName << llendl;
- }
- return success;
-}
-
-const U8* LLTexLayer::getAlphaData() const
-{
- LLCRC alpha_mask_crc;
- const LLUUID& uuid = getUUID();
- alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES);
-
- for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++)
- {
- const LLTexLayerParamAlpha* param = *iter;
- // MULTI-WEARABLE: verify visual parameters used here
- F32 param_weight = param->getWeight();
- alpha_mask_crc.update((U8*)&param_weight, sizeof(F32));
- }
-
- U32 cache_index = alpha_mask_crc.getCRC();
-
- alpha_cache_t::const_iterator iter2 = mAlphaCache.find(cache_index);
- return (iter2 == mAlphaCache.end()) ? 0 : iter2->second;
-}
-
-BOOL LLTexLayer::findNetColor(LLColor4* net_color) const
-{
- // Color is either:
- // * one or more color parameters (weighted colors) (which may make use of a global color or fixed color)
- // * a reference to a global color
- // * a fixed color with non-zero alpha
- // * opaque white (the default)
-
- if( !mParamColorList.empty() )
- {
- if( !getGlobalColor().empty() )
- {
- net_color->setVec( mTexLayerSet->getAvatar()->getGlobalColor( getInfo()->mGlobalColor ) );
- }
- else if (getInfo()->mFixedColor.mV[VW])
- {
- net_color->setVec( getInfo()->mFixedColor );
- }
- else
- {
- net_color->setVec( 0.f, 0.f, 0.f, 0.f );
- }
-
- calculateTexLayerColor(mParamColorList, *net_color);
- return TRUE;
- }
-
- if( !getGlobalColor().empty() )
- {
- net_color->setVec( mTexLayerSet->getAvatar()->getGlobalColor( getGlobalColor() ) );
- return TRUE;
- }
-
- if( getInfo()->mFixedColor.mV[VW] )
- {
- net_color->setVec( getInfo()->mFixedColor );
- return TRUE;
- }
-
- net_color->setToWhite();
-
- return FALSE; // No need to draw a separate colored polygon
-}
-
-BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height)
-{
- BOOL success = TRUE;
-
- gGL.flush();
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- if( !getInfo()->mStaticImageFileName.empty() )
- {
- LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask );
- if( tex )
- {
- LLGLSNoAlphaTest gls_no_alpha_test;
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
- gGL.getTexUnit(0)->bind(tex, TRUE);
- gl_rect_2d_simple_tex( width, height );
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
- else
- {
- success = FALSE;
- }
- }
- else
- {
- if (getInfo()->mLocalTexture >=0 && getInfo()->mLocalTexture < TEX_NUM_INDICES)
- {
- LLViewerTexture* tex = mLocalTextureObject->getImage();
- if (tex)
- {
- LLGLSNoAlphaTest gls_no_alpha_test;
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
- gGL.getTexUnit(0)->bind(tex);
- gl_rect_2d_simple_tex( width, height );
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- success = TRUE;
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
- }
- }
- }
-
- return success;
-}
-
-/*virtual*/ void LLTexLayer::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height)
-{
- addAlphaMask(data, originX, originY, width, height);
-}
-
-BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color)
-{
- BOOL success = TRUE;
-
- llassert( !mParamAlphaList.empty() );
-
- bool use_shaders = LLGLSLShader::sNoFixedFunction;
-
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.f);
- }
-
- gGL.setColorMask(false, true);
-
- LLTexLayerParamAlpha* first_param = *mParamAlphaList.begin();
- // Note: if the first param is a mulitply, multiply against the current buffer's alpha
- if( !first_param || !first_param->getMultiplyBlend() )
- {
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
- // Clear the alpha
- gGL.flush();
- gGL.setSceneBlendType(LLRender::BT_REPLACE);
-
- gGL.color4f( 0.f, 0.f, 0.f, 0.f );
- gl_rect_2d_simple( width, height );
- }
-
- // Accumulate alphas
- LLGLSNoAlphaTest gls_no_alpha_test;
- gGL.color4f( 1.f, 1.f, 1.f, 1.f );
- for (param_alpha_list_t::iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++)
- {
- LLTexLayerParamAlpha* param = *iter;
- success &= param->render( x, y, width, height );
- }
-
- // Approximates a min() function
- gGL.flush();
- gGL.setSceneBlendType(LLRender::BT_MULT_ALPHA);
-
- // Accumulate the alpha component of the texture
- if( getInfo()->mLocalTexture != -1 )
- {
- LLViewerTexture* tex = mLocalTextureObject->getImage();
- if( tex && (tex->getComponents() == 4) )
- {
- LLGLSNoAlphaTest gls_no_alpha_test;
- LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode();
-
- gGL.getTexUnit(0)->bind(tex, TRUE);
- gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
-
- gl_rect_2d_simple_tex( width, height );
-
- gGL.getTexUnit(0)->setTextureAddressMode(old_mode);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- }
- }
-
- if( !getInfo()->mStaticImageFileName.empty() )
- {
- LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask);
- if( tex )
- {
- if( (tex->getComponents() == 4) ||
- ( (tex->getComponents() == 1) && getInfo()->mStaticImageIsMask ) )
- {
- LLGLSNoAlphaTest gls_no_alpha_test;
- gGL.getTexUnit(0)->bind(tex, TRUE);
- gl_rect_2d_simple_tex( width, height );
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- }
- }
- }
-
- // Draw a rectangle with the layer color to multiply the alpha by that color's alpha.
- // Note: we're still using gGL.blendFunc( GL_DST_ALPHA, GL_ZERO );
- if (layer_color.mV[VW] != 1.f)
- {
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4fv(layer_color.mV);
- gl_rect_2d_simple( width, height );
- }
-
- if (use_shaders)
- {
- gAlphaMaskProgram.setMinimumAlpha(0.004f);
- }
-
- LLGLSUIDefault gls_ui;
-
- gGL.setColorMask(true, true);
-
- if (hasMorph() && success)
- {
- LLCRC alpha_mask_crc;
- const LLUUID& uuid = getUUID();
- alpha_mask_crc.update((U8*)(&uuid.mData), UUID_BYTES);
-
- for (param_alpha_list_t::const_iterator iter = mParamAlphaList.begin(); iter != mParamAlphaList.end(); iter++)
- {
- const LLTexLayerParamAlpha* param = *iter;
- F32 param_weight = param->getWeight();
- alpha_mask_crc.update((U8*)&param_weight, sizeof(F32));
- }
-
- U32 cache_index = alpha_mask_crc.getCRC();
- U8* alpha_data = get_if_there(mAlphaCache,cache_index,(U8*)NULL);
- if (!alpha_data)
- {
- // clear out a slot if we have filled our cache
- S32 max_cache_entries = getTexLayerSet()->getAvatar()->isSelf() ? 4 : 1;
- while ((S32)mAlphaCache.size() >= max_cache_entries)
- {
- alpha_cache_t::iterator iter2 = mAlphaCache.begin(); // arbitrarily grab the first entry
- alpha_data = iter2->second;
- delete [] alpha_data;
- mAlphaCache.erase(iter2);
- }
- alpha_data = new U8[width * height];
- mAlphaCache[cache_index] = alpha_data;
- glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data);
- }
-
- getTexLayerSet()->getAvatar()->dirtyMesh();
-
- mMorphMasksValid = TRUE;
- getTexLayerSet()->applyMorphMask(alpha_data, width, height, 1);
- }
-
- return success;
-}
-
-void LLTexLayer::addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height)
-{
- S32 size = width * height;
- const U8* alphaData = getAlphaData();
- if (!alphaData && hasAlphaParams())
- {
- LLColor4 net_color;
- findNetColor( &net_color );
- // TODO: eliminate need for layer morph mask valid flag
- invalidateMorphMasks();
- renderMorphMasks(originX, originY, width, height, net_color);
- alphaData = getAlphaData();
- }
- if (alphaData)
- {
- for( S32 i = 0; i < size; i++ )
- {
- U8 curAlpha = data[i];
- U16 resultAlpha = curAlpha;
- resultAlpha *= (alphaData[i] + 1);
- resultAlpha = resultAlpha >> 8;
- data[i] = (U8)resultAlpha;
- }
- }
-}
-
-/*virtual*/ BOOL LLTexLayer::isInvisibleAlphaMask() const
-{
- if (mLocalTextureObject)
- {
- if (mLocalTextureObject->getID() == IMG_INVISIBLE)
- {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-LLUUID LLTexLayer::getUUID() const
-{
- LLUUID uuid;
- if( getInfo()->mLocalTexture != -1 )
- {
- LLViewerTexture* tex = mLocalTextureObject->getImage();
- if (tex)
- {
- uuid = mLocalTextureObject->getID();
- }
- }
- if( !getInfo()->mStaticImageFileName.empty() )
- {
- LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask);
- if( tex )
- {
- uuid = tex->getID();
- }
- }
- return uuid;
-}
-
-
-//-----------------------------------------------------------------------------
-// LLTexLayerTemplate
-// A single texture layer, consisting of:
-// * color, consisting of either
-// * one or more color parameters (weighted colors)
-// * a reference to a global color
-// * a fixed color with non-zero alpha
-// * opaque white (the default)
-// * (optional) a texture defined by either
-// * a GUID
-// * a texture entry index (TE)
-// * (optional) one or more alpha parameters (weighted alpha textures)
-//-----------------------------------------------------------------------------
-LLTexLayerTemplate::LLTexLayerTemplate(LLTexLayerSet* layer_set) :
- LLTexLayerInterface(layer_set)
-{
-}
-
-LLTexLayerTemplate::LLTexLayerTemplate(const LLTexLayerTemplate &layer) :
- LLTexLayerInterface(layer)
-{
-}
-
-LLTexLayerTemplate::~LLTexLayerTemplate()
-{
-}
-
-//-----------------------------------------------------------------------------
-// setInfo
-//-----------------------------------------------------------------------------
-
-/*virtual*/ BOOL LLTexLayerTemplate::setInfo(const LLTexLayerInfo* info, LLWearable* wearable )
-{
- return LLTexLayerInterface::setInfo(info, wearable);
-}
-
-U32 LLTexLayerTemplate::updateWearableCache() const
-{
- mWearableCache.clear();
-
- S32 te = mInfo->mLocalTexture;
- if (te == -1)
- {
- //this isn't a cloneable layer
- return 0;
- }
- LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType((ETextureIndex)te);
- U32 num_wearables = gAgentWearables.getWearableCount(wearable_type);
- U32 added = 0;
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLWearable* wearable = gAgentWearables.getWearable(wearable_type, i);
- if (!wearable)
- {
- continue;
- }
- mWearableCache.push_back(wearable);
- added++;
- }
- return added;
-}
-LLTexLayer* LLTexLayerTemplate::getLayer(U32 i) const
-{
- if (mWearableCache.size() <= i)
- {
- return NULL;
- }
- LLWearable *wearable = mWearableCache[i];
- LLLocalTextureObject *lto = NULL;
- LLTexLayer *layer = NULL;
- if (wearable)
- {
- lto = wearable->getLocalTextureObject(mInfo->mLocalTexture);
- }
- if (lto)
- {
- layer = lto->getTexLayer(getName());
- }
- return layer;
-}
-
-/*virtual*/ BOOL LLTexLayerTemplate::render(S32 x, S32 y, S32 width, S32 height)
-{
- if(!mInfo)
- {
- return FALSE ;
- }
-
- BOOL success = TRUE;
- updateWearableCache();
- for (wearable_cache_t::const_iterator iter = mWearableCache.begin(); iter!= mWearableCache.end(); iter++)
- {
- LLWearable* wearable = NULL;
- LLLocalTextureObject *lto = NULL;
- LLTexLayer *layer = NULL;
- wearable = *iter;
- if (wearable)
- {
- lto = wearable->getLocalTextureObject(mInfo->mLocalTexture);
- }
- if (lto)
- {
- layer = lto->getTexLayer(getName());
- }
- if (layer)
- {
- wearable->writeToAvatar();
- layer->setLTO(lto);
- success &= layer->render(x,y,width,height);
- }
- }
-
- return success;
-}
-
-/*virtual*/ BOOL LLTexLayerTemplate::blendAlphaTexture( S32 x, S32 y, S32 width, S32 height) // Multiplies a single alpha texture against the frame buffer
-{
- BOOL success = TRUE;
- U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- success &= layer->blendAlphaTexture(x,y,width,height);
- }
- }
- return success;
-}
-
-/*virtual*/ void LLTexLayerTemplate::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height)
-{
- U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- layer->addAlphaMask(data, originX, originY, width, height);
- }
- }
-}
-
-/*virtual*/ void LLTexLayerTemplate::setHasMorph(BOOL newval)
-{
- mHasMorph = newval;
- U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- layer->setHasMorph(newval);
- }
- }
-}
-
-/*virtual*/ void LLTexLayerTemplate::deleteCaches()
-{
- U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- layer->deleteCaches();
- }
- }
-}
-
-/*virtual*/ BOOL LLTexLayerTemplate::isInvisibleAlphaMask() const
-{
- U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
- {
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- if (layer->isInvisibleAlphaMask())
- {
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-
-//-----------------------------------------------------------------------------
-// finds a specific layer based on a passed in name
-//-----------------------------------------------------------------------------
-LLTexLayerInterface* LLTexLayerSet::findLayerByName(const std::string& name)
-{
- for (layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- if (layer->getName() == name)
- {
- return layer;
- }
- }
- for (layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ )
- {
- LLTexLayerInterface* layer = *iter;
- if (layer->getName() == name)
- {
- return layer;
- }
- }
- return NULL;
-}
-
-void LLTexLayerSet::cloneTemplates(LLLocalTextureObject *lto, LLVOAvatarDefines::ETextureIndex tex_index, LLWearable *wearable)
-{
- // initialize all texlayers with this texture type for this LTO
- for( LLTexLayerSet::layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
- {
- LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter;
- if (layer->getInfo()->getLocalTexture() == (S32) tex_index)
- {
- lto->addTexLayer(layer, wearable);
- }
- }
- for( LLTexLayerSet::layer_list_t::iterator iter = mMaskLayerList.begin(); iter != mMaskLayerList.end(); iter++ )
- {
- LLTexLayerTemplate* layer = (LLTexLayerTemplate*)*iter;
- if (layer->getInfo()->getLocalTexture() == (S32) tex_index)
- {
- lto->addTexLayer(layer, wearable);
- }
- }
-}
-//-----------------------------------------------------------------------------
-// LLTexLayerStaticImageList
-//-----------------------------------------------------------------------------
-
-LLTexLayerStaticImageList::LLTexLayerStaticImageList() :
- mGLBytes(0),
- mTGABytes(0),
- mImageNames(16384)
-{
-}
-
-LLTexLayerStaticImageList::~LLTexLayerStaticImageList()
-{
- deleteCachedImages();
-}
-
-void LLTexLayerStaticImageList::dumpByteCount() const
-{
- llinfos << "Avatar Static Textures " <<
- "KB GL:" << (mGLBytes / 1024) <<
- "KB TGA:" << (mTGABytes / 1024) << "KB" << llendl;
-}
-
-void LLTexLayerStaticImageList::deleteCachedImages()
-{
- if( mGLBytes || mTGABytes )
- {
- llinfos << "Clearing Static Textures " <<
- "KB GL:" << (mGLBytes / 1024) <<
- "KB TGA:" << (mTGABytes / 1024) << "KB" << llendl;
-
- //mStaticImageLists uses LLPointers, clear() will cause deletion
-
- mStaticImageListTGA.clear();
- mStaticImageList.clear();
-
- mGLBytes = 0;
- mTGABytes = 0;
- }
-}
-
-// Note: in general, for a given image image we'll call either getImageTga() or getTexture().
-// We call getImageTga() if the image is used as an alpha gradient.
-// Otherwise, we call getTexture()
-
-// Returns an LLImageTGA that contains the encoded data from a tga file named file_name.
-// Caches the result to speed identical subsequent requests.
-LLImageTGA* LLTexLayerStaticImageList::getImageTGA(const std::string& file_name)
-{
- const char *namekey = mImageNames.addString(file_name);
- image_tga_map_t::const_iterator iter = mStaticImageListTGA.find(namekey);
- if( iter != mStaticImageListTGA.end() )
- {
- return iter->second;
- }
- else
- {
- std::string path;
- path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name);
- LLPointer<LLImageTGA> image_tga = new LLImageTGA( path );
- if( image_tga->getDataSize() > 0 )
- {
- mStaticImageListTGA[ namekey ] = image_tga;
- mTGABytes += image_tga->getDataSize();
- return image_tga;
- }
- else
- {
- return NULL;
- }
- }
-}
-
-// Returns a GL Image (without a backing ImageRaw) that contains the decoded data from a tga file named file_name.
-// Caches the result to speed identical subsequent requests.
-LLViewerTexture* LLTexLayerStaticImageList::getTexture(const std::string& file_name, BOOL is_mask)
-{
- LLPointer<LLViewerTexture> tex;
- const char *namekey = mImageNames.addString(file_name);
-
- texture_map_t::const_iterator iter = mStaticImageList.find(namekey);
- if( iter != mStaticImageList.end() )
- {
- tex = iter->second;
- }
- else
- {
- tex = LLViewerTextureManager::getLocalTexture( FALSE );
- LLPointer<LLImageRaw> image_raw = new LLImageRaw;
- if( loadImageRaw( file_name, image_raw ) )
- {
- if( (image_raw->getComponents() == 1) && is_mask )
- {
- // Note: these are static, unchanging images so it's ok to assume
- // that once an image is a mask it's always a mask.
- tex->setExplicitFormat( GL_ALPHA8, GL_ALPHA );
- }
- tex->createGLTexture(0, image_raw, 0, TRUE, LLViewerTexture::LOCAL);
-
- gGL.getTexUnit(0)->bind(tex);
- tex->setAddressMode(LLTexUnit::TAM_CLAMP);
-
- mStaticImageList [ namekey ] = tex;
- mGLBytes += (S32)tex->getWidth() * tex->getHeight() * tex->getComponents();
- }
- else
- {
- tex = NULL;
- }
- }
-
- return tex;
-}
-
-// Reads a .tga file, decodes it, and puts the decoded data in image_raw.
-// Returns TRUE if successful.
-BOOL LLTexLayerStaticImageList::loadImageRaw(const std::string& file_name, LLImageRaw* image_raw)
-{
- BOOL success = FALSE;
- std::string path;
- path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,file_name);
- LLPointer<LLImageTGA> image_tga = new LLImageTGA( path );
- if( image_tga->getDataSize() > 0 )
- {
- // Copy data from tga to raw.
- success = image_tga->decode( image_raw );
- }
-
- return success;
-}
-
-const std::string LLTexLayerSetBuffer::dumpTextureInfo() const
-{
- if (!isAgentAvatarValid()) return "";
-
- const BOOL is_high_res = !mNeedsUpload;
- const U32 num_low_res = mNumLowresUploads;
- const U32 upload_time = (U32)mNeedsUploadTimer.getElapsedTimeF32();
- const std::string local_texture_info = gAgentAvatarp->debugDumpLocalTextureDataInfo(mTexLayerSet);
-
- std::string status = "CREATING ";
- if (!uploadNeeded()) status = "DONE ";
- if (uploadInProgress()) status = "UPLOADING";
-
- std::string text = llformat("[%s] [HiRes:%d LoRes:%d] [Elapsed:%d] %s",
- status.c_str(),
- is_high_res, num_low_res,
- upload_time,
- local_texture_info.c_str());
- return text;
-}
diff --git a/indra/newview/lltexlayer.h b/indra/newview/lltexlayer.h
deleted file mode 100644
index 4f43547dae..0000000000
--- a/indra/newview/lltexlayer.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * @file lltexlayer.h
- * @brief Texture layer classes. Used for avatars.
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTEXLAYER_H
-#define LL_LLTEXLAYER_H
-
-#include <deque>
-#include "lldynamictexture.h"
-#include "llvoavatardefines.h"
-#include "lltexlayerparams.h"
-
-class LLVOAvatar;
-class LLVOAvatarSelf;
-class LLImageTGA;
-class LLImageRaw;
-class LLXmlTreeNode;
-class LLTexLayerSet;
-class LLTexLayerSetInfo;
-class LLTexLayerInfo;
-class LLTexLayerSetBuffer;
-class LLWearable;
-class LLViewerVisualParam;
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerInterface
-//
-// Interface class to generalize functionality shared by LLTexLayer
-// and LLTexLayerTemplate.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerInterface
-{
-public:
- enum ERenderPass
- {
- RP_COLOR,
- RP_BUMP,
- RP_SHINE
- };
-
- LLTexLayerInterface(LLTexLayerSet* const layer_set);
- LLTexLayerInterface(const LLTexLayerInterface &layer, LLWearable *wearable);
- virtual ~LLTexLayerInterface() {}
-
- virtual BOOL render(S32 x, S32 y, S32 width, S32 height) = 0;
- virtual void deleteCaches() = 0;
- virtual BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) = 0;
- virtual BOOL isInvisibleAlphaMask() const = 0;
-
- const LLTexLayerInfo* getInfo() const { return mInfo; }
- virtual BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // sets mInfo, calls initialization functions
-
- const std::string& getName() const;
- const LLTexLayerSet* const getTexLayerSet() const { return mTexLayerSet; }
- LLTexLayerSet* const getTexLayerSet() { return mTexLayerSet; }
-
- void invalidateMorphMasks();
- virtual void setHasMorph(BOOL newval) { mHasMorph = newval; }
- BOOL hasMorph() const { return mHasMorph; }
- BOOL isMorphValid() const { return mMorphMasksValid; }
-
- void requestUpdate();
- virtual void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height) = 0;
- BOOL hasAlphaParams() const { return !mParamAlphaList.empty(); }
-
- ERenderPass getRenderPass() const;
- BOOL isVisibilityMask() const;
-
-protected:
- const std::string& getGlobalColor() const;
- LLViewerVisualParam* getVisualParamPtr(S32 index) const;
-
-protected:
- LLTexLayerSet* const mTexLayerSet;
- const LLTexLayerInfo* mInfo;
- BOOL mMorphMasksValid;
- BOOL mHasMorph;
-
- // Layers can have either mParamColorList, mGlobalColor, or mFixedColor. They are looked for in that order.
- param_color_list_t mParamColorList;
- param_alpha_list_t mParamAlphaList;
- // mGlobalColor name stored in mInfo
- // mFixedColor value stored in mInfo
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerTemplate
-//
-// Only exists for llvoavatarself.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerTemplate : public LLTexLayerInterface
-{
-public:
- LLTexLayerTemplate(LLTexLayerSet* const layer_set);
- LLTexLayerTemplate(const LLTexLayerTemplate &layer);
- /*virtual*/ ~LLTexLayerTemplate();
- /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height);
- /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions
- /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer
- /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height);
- /*virtual*/ void setHasMorph(BOOL newval);
- /*virtual*/ void deleteCaches();
- /*virtual*/ BOOL isInvisibleAlphaMask() const;
-protected:
- U32 updateWearableCache() const;
- LLTexLayer* getLayer(U32 i) const;
-private:
- typedef std::vector<LLWearable*> wearable_cache_t;
- mutable wearable_cache_t mWearableCache; // mutable b/c most get- require updating this cache
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayer
-//
-// A single texture layer. Only exists for llvoavatarself.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayer : public LLTexLayerInterface
-{
-public:
- LLTexLayer(LLTexLayerSet* const layer_set);
- LLTexLayer(const LLTexLayer &layer, LLWearable *wearable);
- LLTexLayer(const LLTexLayerTemplate &layer_template, LLLocalTextureObject *lto, LLWearable *wearable);
- /*virtual*/ ~LLTexLayer();
-
- /*virtual*/ BOOL setInfo(const LLTexLayerInfo *info, LLWearable* wearable); // This sets mInfo and calls initialization functions
- /*virtual*/ BOOL render(S32 x, S32 y, S32 width, S32 height);
-
- /*virtual*/ void deleteCaches();
- const U8* getAlphaData() const;
-
- BOOL findNetColor(LLColor4* color) const;
- /*virtual*/ BOOL blendAlphaTexture(S32 x, S32 y, S32 width, S32 height); // Multiplies a single alpha texture against the frame buffer
- /*virtual*/ void gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height);
- BOOL renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLColor4 &layer_color);
- void addAlphaMask(U8 *data, S32 originX, S32 originY, S32 width, S32 height);
- /*virtual*/ BOOL isInvisibleAlphaMask() const;
-
- void setLTO(LLLocalTextureObject *lto) { mLocalTextureObject = lto; }
- LLLocalTextureObject* getLTO() { return mLocalTextureObject; }
-
- static void calculateTexLayerColor(const param_color_list_t &param_list, LLColor4 &net_color);
-protected:
- LLUUID getUUID() const;
-private:
- typedef std::map<U32, U8*> alpha_cache_t;
- alpha_cache_t mAlphaCache;
- LLLocalTextureObject* mLocalTextureObject;
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerSet
-//
-// An ordered set of texture layers that gets composited into a single texture.
-// Only exists for llvoavatarself.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerSet
-{
- friend class LLTexLayerSetBuffer;
-public:
- LLTexLayerSet(LLVOAvatarSelf* const avatar);
- ~LLTexLayerSet();
-
- const LLTexLayerSetInfo* getInfo() const { return mInfo; }
- BOOL setInfo(const LLTexLayerSetInfo *info); // This sets mInfo and calls initialization functions
-
- BOOL render(S32 x, S32 y, S32 width, S32 height);
- void renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear = false);
-
- BOOL isBodyRegion(const std::string& region) const;
- LLTexLayerSetBuffer* getComposite();
- const LLTexLayerSetBuffer* getComposite() const; // Do not create one if it doesn't exist.
- void requestUpdate();
- void requestUpload();
- void cancelUpload();
- void updateComposite();
- BOOL isLocalTextureDataAvailable() const;
- BOOL isLocalTextureDataFinal() const;
- void createComposite();
- void destroyComposite();
- void setUpdatesEnabled(BOOL b);
- BOOL getUpdatesEnabled() const { return mUpdatesEnabled; }
- void deleteCaches();
- void gatherMorphMaskAlpha(U8 *data, S32 width, S32 height);
- void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components);
- BOOL isMorphValid() const;
- void invalidateMorphMasks();
- LLTexLayerInterface* findLayerByName(const std::string& name);
- void cloneTemplates(LLLocalTextureObject *lto, LLVOAvatarDefines::ETextureIndex tex_index, LLWearable* wearable);
-
- LLVOAvatarSelf* getAvatar() const { return mAvatar; }
- const std::string getBodyRegionName() const;
- BOOL hasComposite() const { return (mComposite.notNull()); }
- LLVOAvatarDefines::EBakedTextureIndex getBakedTexIndex() { return mBakedTexIndex; }
- void setBakedTexIndex(LLVOAvatarDefines::EBakedTextureIndex index) { mBakedTexIndex = index; }
- BOOL isVisible() const { return mIsVisible; }
-
- static BOOL sHasCaches;
-
-private:
- typedef std::vector<LLTexLayerInterface *> layer_list_t;
- layer_list_t mLayerList;
- layer_list_t mMaskLayerList;
- LLPointer<LLTexLayerSetBuffer> mComposite;
- LLVOAvatarSelf* const mAvatar; // note: backlink only; don't make this an LLPointer.
- BOOL mUpdatesEnabled;
- BOOL mIsVisible;
-
- LLVOAvatarDefines::EBakedTextureIndex mBakedTexIndex;
- const LLTexLayerSetInfo* mInfo;
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerSetInfo
-//
-// Contains shared layer set data.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerSetInfo
-{
- friend class LLTexLayerSet;
-public:
- LLTexLayerSetInfo();
- ~LLTexLayerSetInfo();
- BOOL parseXml(LLXmlTreeNode* node);
- void createVisualParams(LLVOAvatar *avatar);
-private:
- std::string mBodyRegion;
- S32 mWidth;
- S32 mHeight;
- std::string mStaticAlphaFileName;
- BOOL mClearAlpha; // Set alpha to 1 for this layerset (if there is no mStaticAlphaFileName)
- typedef std::vector<LLTexLayerInfo*> layer_info_list_t;
- layer_info_list_t mLayerInfoList;
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerSetBuffer
-//
-// The composite image that a LLTexLayerSet writes to. Each LLTexLayerSet has one.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerSetBuffer : public LLViewerDynamicTexture
-{
- LOG_CLASS(LLTexLayerSetBuffer);
-
-public:
- LLTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height);
- virtual ~LLTexLayerSetBuffer();
-
-public:
- /*virtual*/ S8 getType() const;
- BOOL isInitialized(void) const;
- static void dumpTotalByteCount();
- const std::string dumpTextureInfo() const;
- virtual void restoreGLTexture();
- virtual void destroyGLTexture();
-protected:
- void pushProjection() const;
- void popProjection() const;
-private:
- LLTexLayerSet* const mTexLayerSet;
- static S32 sGLByteCount;
-
- //--------------------------------------------------------------------
- // Render
- //--------------------------------------------------------------------
-public:
- /*virtual*/ BOOL needsRender();
-protected:
- BOOL render(S32 x, S32 y, S32 width, S32 height);
- virtual void preRender(BOOL clear_depth);
- virtual void postRender(BOOL success);
- virtual BOOL render();
-
- //--------------------------------------------------------------------
- // Uploads
- //--------------------------------------------------------------------
-public:
- void requestUpload();
- void cancelUpload();
- BOOL uploadNeeded() const; // We need to upload a new texture
- BOOL uploadInProgress() const; // We have started uploading a new texture and are awaiting the result
- BOOL uploadPending() const; // We are expecting a new texture to be uploaded at some point
- static void onTextureUploadComplete(const LLUUID& uuid,
- void* userdata,
- S32 result, LLExtStat ext_status);
-protected:
- BOOL isReadyToUpload() const;
- void doUpload(); // Does a read back and upload.
- void conditionalRestartUploadTimer();
-private:
- BOOL mNeedsUpload; // Whether we need to send our baked textures to the server
- U32 mNumLowresUploads; // Number of times we've sent a lowres version of our baked textures to the server
- BOOL mUploadPending; // Whether we have received back the new baked textures
- LLUUID mUploadID; // The current upload process (null if none).
- LLFrameTimer mNeedsUploadTimer; // Tracks time since upload was requested and performed.
- S32 mUploadFailCount; // Number of consecutive upload failures
- LLFrameTimer mUploadRetryTimer; // Tracks time since last upload failure.
-
- //--------------------------------------------------------------------
- // Updates
- //--------------------------------------------------------------------
-public:
- void requestUpdate();
- BOOL requestUpdateImmediate();
-protected:
- BOOL isReadyToUpdate() const;
- void doUpdate();
- void restartUpdateTimer();
-private:
- BOOL mNeedsUpdate; // Whether we need to locally update our baked textures
- U32 mNumLowresUpdates; // Number of times we've locally updated with lowres version of our baked textures
- LLFrameTimer mNeedsUpdateTimer; // Tracks time since update was requested and performed.
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerStaticImageList
-//
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerStaticImageList : public LLSingleton<LLTexLayerStaticImageList>
-{
-public:
- LLTexLayerStaticImageList();
- ~LLTexLayerStaticImageList();
- LLViewerTexture* getTexture(const std::string& file_name, BOOL is_mask);
- LLImageTGA* getImageTGA(const std::string& file_name);
- void deleteCachedImages();
- void dumpByteCount() const;
-protected:
- BOOL loadImageRaw(const std::string& file_name, LLImageRaw* image_raw);
-private:
- LLStringTable mImageNames;
- typedef std::map<const char*, LLPointer<LLViewerTexture> > texture_map_t;
- texture_map_t mStaticImageList;
- typedef std::map<const char*, LLPointer<LLImageTGA> > image_tga_map_t;
- image_tga_map_t mStaticImageListTGA;
- S32 mGLBytes;
- S32 mTGABytes;
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLBakedUploadData
-//
-// Used by LLTexLayerSetBuffer for a callback.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-struct LLBakedUploadData
-{
- LLBakedUploadData(const LLVOAvatarSelf* avatar,
- LLTexLayerSet* layerset,
- const LLUUID& id,
- bool highest_res);
- ~LLBakedUploadData() {}
- const LLUUID mID;
- const LLVOAvatarSelf* mAvatar; // note: backlink only; don't LLPointer
- LLTexLayerSet* mTexLayerSet;
- const U64 mStartTime; // for measuring baked texture upload time
- const bool mIsHighestRes; // whether this is a "final" bake, or intermediate low res
-};
-
-#endif // LL_LLTEXLAYER_H
diff --git a/indra/newview/lltexlayerparams.cpp b/indra/newview/lltexlayerparams.cpp
deleted file mode 100644
index 8972827eff..0000000000
--- a/indra/newview/lltexlayerparams.cpp
+++ /dev/null
@@ -1,568 +0,0 @@
-/**
- * @file lltexlayerparams.cpp
- * @brief Texture layer parameters
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lltexlayerparams.h"
-
-#include "llagentcamera.h"
-#include "llimagetga.h"
-#include "lltexlayer.h"
-#include "llvoavatarself.h"
-#include "llwearable.h"
-#include "llui.h"
-
-//-----------------------------------------------------------------------------
-// LLTexLayerParam
-//-----------------------------------------------------------------------------
-LLTexLayerParam::LLTexLayerParam(LLTexLayerInterface *layer) :
- mTexLayer(layer),
- mAvatar(NULL)
-{
- if (mTexLayer != NULL)
- {
- mAvatar = mTexLayer->getTexLayerSet()->getAvatar();
- }
- else
- {
- llerrs << "LLTexLayerParam constructor passed with NULL reference for layer!" << llendl;
- }
-}
-
-LLTexLayerParam::LLTexLayerParam(LLVOAvatar *avatar) :
- mTexLayer(NULL)
-{
- mAvatar = avatar;
-}
-
-
-BOOL LLTexLayerParam::setInfo(LLViewerVisualParamInfo *info, BOOL add_to_avatar )
-{
- LLViewerVisualParam::setInfo(info);
-
- if (add_to_avatar)
- {
- mAvatar->addVisualParam( this);
- }
-
- return TRUE;
-}
-
-
-//-----------------------------------------------------------------------------
-// LLTexLayerParamAlpha
-//-----------------------------------------------------------------------------
-
-// static
-LLTexLayerParamAlpha::param_alpha_ptr_list_t LLTexLayerParamAlpha::sInstances;
-
-// static
-void LLTexLayerParamAlpha::dumpCacheByteCount()
-{
- S32 gl_bytes = 0;
- getCacheByteCount( &gl_bytes);
- llinfos << "Processed Alpha Texture Cache GL:" << (gl_bytes/1024) << "KB" << llendl;
-}
-
-// static
-void LLTexLayerParamAlpha::getCacheByteCount(S32* gl_bytes)
-{
- *gl_bytes = 0;
-
- for (param_alpha_ptr_list_t::iterator iter = sInstances.begin();
- iter != sInstances.end(); iter++)
- {
- LLTexLayerParamAlpha* instance = *iter;
- LLViewerTexture* tex = instance->mCachedProcessedTexture;
- if (tex)
- {
- S32 bytes = (S32)tex->getWidth() * tex->getHeight() * tex->getComponents();
-
- if (tex->hasGLTexture())
- {
- *gl_bytes += bytes;
- }
- }
- }
-}
-
-LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLTexLayerInterface* layer) :
- LLTexLayerParam(layer),
- mCachedProcessedTexture(NULL),
- mNeedsCreateTexture(FALSE),
- mStaticImageInvalid(FALSE),
- mAvgDistortionVec(1.f, 1.f, 1.f),
- mCachedEffectiveWeight(0.f)
-{
- sInstances.push_front(this);
-}
-
-LLTexLayerParamAlpha::LLTexLayerParamAlpha(LLVOAvatar* avatar) :
- LLTexLayerParam(avatar),
- mCachedProcessedTexture(NULL),
- mNeedsCreateTexture(FALSE),
- mStaticImageInvalid(FALSE),
- mAvgDistortionVec(1.f, 1.f, 1.f),
- mCachedEffectiveWeight(0.f)
-{
- sInstances.push_front(this);
-}
-
-
-LLTexLayerParamAlpha::~LLTexLayerParamAlpha()
-{
- deleteCaches();
- sInstances.remove(this);
-}
-
-/*virtual*/ LLViewerVisualParam* LLTexLayerParamAlpha::cloneParam(LLWearable* wearable) const
-{
- LLTexLayerParamAlpha *new_param = new LLTexLayerParamAlpha(mTexLayer);
- *new_param = *this;
- return new_param;
-}
-
-void LLTexLayerParamAlpha::deleteCaches()
-{
- mStaticImageTGA = NULL; // deletes image
- mCachedProcessedTexture = NULL;
- mStaticImageRaw = NULL;
- mNeedsCreateTexture = FALSE;
-}
-
-BOOL LLTexLayerParamAlpha::getMultiplyBlend() const
-{
- return ((LLTexLayerParamAlphaInfo *)getInfo())->mMultiplyBlend;
-}
-
-void LLTexLayerParamAlpha::setWeight(F32 weight, BOOL upload_bake)
-{
- if (mIsAnimating || mTexLayer == NULL)
- {
- return;
- }
- F32 min_weight = getMinWeight();
- F32 max_weight = getMaxWeight();
- F32 new_weight = llclamp(weight, min_weight, max_weight);
- U8 cur_u8 = F32_to_U8(mCurWeight, min_weight, max_weight);
- U8 new_u8 = F32_to_U8(new_weight, min_weight, max_weight);
- if (cur_u8 != new_u8)
- {
- mCurWeight = new_weight;
-
- if ((mAvatar->getSex() & getSex()) && (mAvatar->isSelf() && !mIsDummy)) // only trigger a baked texture update if we're changing a wearable's visual param.
- {
- if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures())
- {
- upload_bake = FALSE;
- }
- mAvatar->invalidateComposite(mTexLayer->getTexLayerSet(), upload_bake);
- mTexLayer->invalidateMorphMasks();
- }
- }
-}
-
-void LLTexLayerParamAlpha::setAnimationTarget(F32 target_value, BOOL upload_bake)
-{
- // do not animate dummy parameters
- if (mIsDummy)
- {
- setWeight(target_value, upload_bake);
- return;
- }
-
- mTargetWeight = target_value;
- setWeight(target_value, upload_bake);
- mIsAnimating = TRUE;
- if (mNext)
- {
- mNext->setAnimationTarget(target_value, upload_bake);
- }
-}
-
-void LLTexLayerParamAlpha::animate(F32 delta, BOOL upload_bake)
-{
- if (mNext)
- {
- mNext->animate(delta, upload_bake);
- }
-}
-
-BOOL LLTexLayerParamAlpha::getSkip() const
-{
- if (!mTexLayer)
- {
- return TRUE;
- }
-
- const LLVOAvatar *avatar = mTexLayer->getTexLayerSet()->getAvatar();
-
- if (((LLTexLayerParamAlphaInfo *)getInfo())->mSkipIfZeroWeight)
- {
- F32 effective_weight = (avatar->getSex() & getSex()) ? mCurWeight : getDefaultWeight();
- if (is_approx_zero(effective_weight))
- {
- return TRUE;
- }
- }
-
- LLWearableType::EType type = (LLWearableType::EType)getWearableType();
- if ((type != LLWearableType::WT_INVALID) && !avatar->isWearingWearableType(type))
- {
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height)
-{
- BOOL success = TRUE;
-
- if (!mTexLayer)
- {
- return success;
- }
-
- F32 effective_weight = (mTexLayer->getTexLayerSet()->getAvatar()->getSex() & getSex()) ? mCurWeight : getDefaultWeight();
- BOOL weight_changed = effective_weight != mCachedEffectiveWeight;
- if (getSkip())
- {
- return success;
- }
-
- LLTexLayerParamAlphaInfo *info = (LLTexLayerParamAlphaInfo *)getInfo();
- gGL.flush();
- if (info->mMultiplyBlend)
- {
- gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ZERO); // Multiplication: approximates a min() function
- }
- else
- {
- gGL.setSceneBlendType(LLRender::BT_ADD); // Addition: approximates a max() function
- }
-
- if (!info->mStaticImageFileName.empty() && !mStaticImageInvalid)
- {
- if (mStaticImageTGA.isNull())
- {
- // Don't load the image file until we actually need it the first time. Like now.
- mStaticImageTGA = LLTexLayerStaticImageList::getInstance()->getImageTGA(info->mStaticImageFileName);
- // We now have something in one of our caches
- LLTexLayerSet::sHasCaches |= mStaticImageTGA.notNull() ? TRUE : FALSE;
-
- if (mStaticImageTGA.isNull())
- {
- llwarns << "Unable to load static file: " << info->mStaticImageFileName << llendl;
- mStaticImageInvalid = TRUE; // don't try again.
- return FALSE;
- }
- }
-
- const S32 image_tga_width = mStaticImageTGA->getWidth();
- const S32 image_tga_height = mStaticImageTGA->getHeight();
- if (!mCachedProcessedTexture ||
- (mCachedProcessedTexture->getWidth() != image_tga_width) ||
- (mCachedProcessedTexture->getHeight() != image_tga_height) ||
- (weight_changed))
- {
-// llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl;
- mCachedEffectiveWeight = effective_weight;
-
- if (!mCachedProcessedTexture)
- {
- mCachedProcessedTexture = LLViewerTextureManager::getLocalTexture(image_tga_width, image_tga_height, 1, FALSE);
-
- // We now have something in one of our caches
- LLTexLayerSet::sHasCaches |= mCachedProcessedTexture ? TRUE : FALSE;
-
- mCachedProcessedTexture->setExplicitFormat(GL_ALPHA8, GL_ALPHA);
- }
-
- // Applies domain and effective weight to data as it is decoded. Also resizes the raw image if needed.
- mStaticImageRaw = NULL;
- mStaticImageRaw = new LLImageRaw;
- mStaticImageTGA->decodeAndProcess(mStaticImageRaw, info->mDomain, effective_weight);
- mNeedsCreateTexture = TRUE;
- }
-
- if (mCachedProcessedTexture)
- {
- {
- // Create the GL texture, and then hang onto it for future use.
- if (mNeedsCreateTexture)
- {
- mCachedProcessedTexture->createGLTexture(0, mStaticImageRaw);
- mNeedsCreateTexture = FALSE;
- gGL.getTexUnit(0)->bind(mCachedProcessedTexture);
- mCachedProcessedTexture->setAddressMode(LLTexUnit::TAM_CLAMP);
- }
-
- LLGLSNoAlphaTest gls_no_alpha_test;
- gGL.getTexUnit(0)->bind(mCachedProcessedTexture);
- gl_rect_2d_simple_tex(width, height);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- stop_glerror();
- }
- }
-
- // Don't keep the cache for other people's avatars
- // (It's not really a "cache" in that case, but the logic is the same)
- if (!mAvatar->isSelf())
- {
- mCachedProcessedTexture = NULL;
- }
- }
- else
- {
- LLGLDisable no_alpha(GL_ALPHA_TEST);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.color4f(0.f, 0.f, 0.f, effective_weight);
- gl_rect_2d_simple(width, height);
- }
-
- return success;
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayerParamAlphaInfo
-//-----------------------------------------------------------------------------
-LLTexLayerParamAlphaInfo::LLTexLayerParamAlphaInfo() :
- mMultiplyBlend(FALSE),
- mSkipIfZeroWeight(FALSE),
- mDomain(0.f)
-{
-}
-
-BOOL LLTexLayerParamAlphaInfo::parseXml(LLXmlTreeNode* node)
-{
- llassert(node->hasName("param") && node->getChildByName("param_alpha"));
-
- if (!LLViewerVisualParamInfo::parseXml(node))
- return FALSE;
-
- LLXmlTreeNode* param_alpha_node = node->getChildByName("param_alpha");
- if (!param_alpha_node)
- {
- return FALSE;
- }
-
- static LLStdStringHandle tga_file_string = LLXmlTree::addAttributeString("tga_file");
- if (param_alpha_node->getFastAttributeString(tga_file_string, mStaticImageFileName))
- {
- // Don't load the image file until it's actually needed.
- }
-// else
-// {
-// llwarns << "<param_alpha> element is missing tga_file attribute." << llendl;
-// }
-
- static LLStdStringHandle multiply_blend_string = LLXmlTree::addAttributeString("multiply_blend");
- param_alpha_node->getFastAttributeBOOL(multiply_blend_string, mMultiplyBlend);
-
- static LLStdStringHandle skip_if_zero_string = LLXmlTree::addAttributeString("skip_if_zero");
- param_alpha_node->getFastAttributeBOOL(skip_if_zero_string, mSkipIfZeroWeight);
-
- static LLStdStringHandle domain_string = LLXmlTree::addAttributeString("domain");
- param_alpha_node->getFastAttributeF32(domain_string, mDomain);
-
- return TRUE;
-}
-
-
-
-
-LLTexLayerParamColor::LLTexLayerParamColor(LLTexLayerInterface* layer) :
- LLTexLayerParam(layer),
- mAvgDistortionVec(1.f, 1.f, 1.f)
-{
-}
-
-LLTexLayerParamColor::LLTexLayerParamColor(LLVOAvatar *avatar) :
- LLTexLayerParam(avatar),
- mAvgDistortionVec(1.f, 1.f, 1.f)
-{
-}
-
-LLTexLayerParamColor::~LLTexLayerParamColor()
-{
-}
-
-/*virtual*/ LLViewerVisualParam* LLTexLayerParamColor::cloneParam(LLWearable* wearable) const
-{
- LLTexLayerParamColor *new_param = new LLTexLayerParamColor(mTexLayer);
- *new_param = *this;
- return new_param;
-}
-
-LLColor4 LLTexLayerParamColor::getNetColor() const
-{
- const LLTexLayerParamColorInfo *info = (LLTexLayerParamColorInfo *)getInfo();
-
- llassert(info->mNumColors >= 1);
-
- F32 effective_weight = (mAvatar && (mAvatar->getSex() & getSex())) ? mCurWeight : getDefaultWeight();
-
- S32 index_last = info->mNumColors - 1;
- F32 scaled_weight = effective_weight * index_last;
- S32 index_start = (S32) scaled_weight;
- S32 index_end = index_start + 1;
- if (index_start == index_last)
- {
- return info->mColors[index_last];
- }
- else
- {
- F32 weight = scaled_weight - index_start;
- const LLColor4 *start = &info->mColors[ index_start ];
- const LLColor4 *end = &info->mColors[ index_end ];
- return LLColor4((1.f - weight) * start->mV[VX] + weight * end->mV[VX],
- (1.f - weight) * start->mV[VY] + weight * end->mV[VY],
- (1.f - weight) * start->mV[VZ] + weight * end->mV[VZ],
- (1.f - weight) * start->mV[VW] + weight * end->mV[VW]);
- }
-}
-
-void LLTexLayerParamColor::setWeight(F32 weight, BOOL upload_bake)
-{
- if (mIsAnimating)
- {
- return;
- }
-
- const LLTexLayerParamColorInfo *info = (LLTexLayerParamColorInfo *)getInfo();
- F32 min_weight = getMinWeight();
- F32 max_weight = getMaxWeight();
- F32 new_weight = llclamp(weight, min_weight, max_weight);
- U8 cur_u8 = F32_to_U8(mCurWeight, min_weight, max_weight);
- U8 new_u8 = F32_to_U8(new_weight, min_weight, max_weight);
- if (cur_u8 != new_u8)
- {
- mCurWeight = new_weight;
-
- if (info->mNumColors <= 0)
- {
- // This will happen when we set the default weight the first time.
- return;
- }
-
- if ((mAvatar->getSex() & getSex()) && (mAvatar->isSelf() && !mIsDummy)) // only trigger a baked texture update if we're changing a wearable's visual param.
- {
- onGlobalColorChanged(upload_bake);
- if (mTexLayer)
- {
- mAvatar->invalidateComposite(mTexLayer->getTexLayerSet(), upload_bake);
- }
- }
-
-// llinfos << "param " << mName << " = " << new_weight << llendl;
- }
-}
-
-void LLTexLayerParamColor::setAnimationTarget(F32 target_value, BOOL upload_bake)
-{
- // set value first then set interpolating flag to ignore further updates
- mTargetWeight = target_value;
- setWeight(target_value, upload_bake);
- mIsAnimating = TRUE;
- if (mNext)
- {
- mNext->setAnimationTarget(target_value, upload_bake);
- }
-}
-
-void LLTexLayerParamColor::animate(F32 delta, BOOL upload_bake)
-{
- if (mNext)
- {
- mNext->animate(delta, upload_bake);
- }
-}
-
-//-----------------------------------------------------------------------------
-// LLTexLayerParamColorInfo
-//-----------------------------------------------------------------------------
-LLTexLayerParamColorInfo::LLTexLayerParamColorInfo() :
- mOperation(LLTexLayerParamColor::OP_ADD),
- mNumColors(0)
-{
-}
-
-BOOL LLTexLayerParamColorInfo::parseXml(LLXmlTreeNode *node)
-{
- llassert(node->hasName("param") && node->getChildByName("param_color"));
-
- if (!LLViewerVisualParamInfo::parseXml(node))
- return FALSE;
-
- LLXmlTreeNode* param_color_node = node->getChildByName("param_color");
- if (!param_color_node)
- {
- return FALSE;
- }
-
- std::string op_string;
- static LLStdStringHandle operation_string = LLXmlTree::addAttributeString("operation");
- if (param_color_node->getFastAttributeString(operation_string, op_string))
- {
- LLStringUtil::toLower(op_string);
- if (op_string == "add") mOperation = LLTexLayerParamColor::OP_ADD;
- else if (op_string == "multiply") mOperation = LLTexLayerParamColor::OP_MULTIPLY;
- else if (op_string == "blend") mOperation = LLTexLayerParamColor::OP_BLEND;
- }
-
- mNumColors = 0;
-
- LLColor4U color4u;
- for (LLXmlTreeNode* child = param_color_node->getChildByName("value");
- child;
- child = param_color_node->getNextNamedChild())
- {
- if ((mNumColors < MAX_COLOR_VALUES))
- {
- static LLStdStringHandle color_string = LLXmlTree::addAttributeString("color");
- if (child->getFastAttributeColor4U(color_string, color4u))
- {
- mColors[ mNumColors ].setVec(color4u);
- mNumColors++;
- }
- }
- }
- if (!mNumColors)
- {
- llwarns << "<param_color> is missing <value> sub-elements" << llendl;
- return FALSE;
- }
-
- if ((mOperation == LLTexLayerParamColor::OP_BLEND) && (mNumColors != 1))
- {
- llwarns << "<param_color> with operation\"blend\" must have exactly one <value>" << llendl;
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h
deleted file mode 100644
index 2c0da60b48..0000000000
--- a/indra/newview/lltexlayerparams.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * @file lltexlayerparams.h
- * @brief Texture layer parameters, used by lltexlayer.
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTEXLAYERPARAMS_H
-#define LL_LLTEXLAYERPARAMS_H
-
-#include "llviewervisualparam.h"
-
-class LLImageRaw;
-class LLImageTGA;
-class LLTexLayer;
-class LLTexLayerInterface;
-class LLViewerTexture;
-class LLVOAvatar;
-class LLWearable;
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerParam
-//
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerParam : public LLViewerVisualParam
-{
-public:
- LLTexLayerParam(LLTexLayerInterface *layer);
- LLTexLayerParam(LLVOAvatar *avatar);
- /*virtual*/ BOOL setInfo(LLViewerVisualParamInfo *info, BOOL add_to_avatar );
- /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const = 0;
-
-protected:
- LLTexLayerInterface* mTexLayer;
- LLVOAvatar* mAvatar;
-};
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerParamAlpha
-//
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerParamAlpha : public LLTexLayerParam
-{
-public:
- LLTexLayerParamAlpha( LLTexLayerInterface* layer );
- LLTexLayerParamAlpha( LLVOAvatar* avatar );
- /*virtual*/ ~LLTexLayerParamAlpha();
-
- /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
-
- // LLVisualParam Virtual functions
- ///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
- /*virtual*/ void apply( ESex avatar_sex ) {}
- /*virtual*/ void setWeight(F32 weight, BOOL upload_bake);
- /*virtual*/ void setAnimationTarget(F32 target_value, BOOL upload_bake);
- /*virtual*/ void animate(F32 delta, BOOL upload_bake);
-
- // LLViewerVisualParam Virtual functions
- /*virtual*/ F32 getTotalDistortion() { return 1.f; }
- /*virtual*/ const LLVector4a& getAvgDistortion() { return mAvgDistortionVec; }
- /*virtual*/ F32 getMaxDistortion() { return 3.f; }
- /*virtual*/ LLVector4a getVertexDistortion(S32 index, LLPolyMesh *poly_mesh) { return LLVector4a(1.f, 1.f, 1.f);}
- /*virtual*/ const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh) { index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
- /*virtual*/ const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh) { index = 0; poly_mesh = NULL; return NULL;};
-
- // New functions
- BOOL render( S32 x, S32 y, S32 width, S32 height );
- BOOL getSkip() const;
- void deleteCaches();
- BOOL getMultiplyBlend() const;
-
-private:
- LLPointer<LLViewerTexture> mCachedProcessedTexture;
- LLPointer<LLImageTGA> mStaticImageTGA;
- LLPointer<LLImageRaw> mStaticImageRaw;
- BOOL mNeedsCreateTexture;
- BOOL mStaticImageInvalid;
- LLVector4a mAvgDistortionVec;
- F32 mCachedEffectiveWeight;
-
-public:
- // Global list of instances for gathering statistics
- static void dumpCacheByteCount();
- static void getCacheByteCount( S32* gl_bytes );
-
- typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t;
- static param_alpha_ptr_list_t sInstances;
-};
-class LLTexLayerParamAlphaInfo : public LLViewerVisualParamInfo
-{
- friend class LLTexLayerParamAlpha;
-public:
- LLTexLayerParamAlphaInfo();
- /*virtual*/ ~LLTexLayerParamAlphaInfo() {};
-
- /*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
-
-private:
- std::string mStaticImageFileName;
- BOOL mMultiplyBlend;
- BOOL mSkipIfZeroWeight;
- F32 mDomain;
-};
-//
-// LLTexLayerParamAlpha
-//-----------------------------------------------------------------------------
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// LLTexLayerParamColor
-//
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-class LLTexLayerParamColor : public LLTexLayerParam
-{
-public:
- enum EColorOperation
- {
- OP_ADD = 0,
- OP_MULTIPLY = 1,
- OP_BLEND = 2,
- OP_COUNT = 3 // Number of operations
- };
-
- LLTexLayerParamColor( LLTexLayerInterface* layer );
- LLTexLayerParamColor( LLVOAvatar* avatar );
- /* virtual */ ~LLTexLayerParamColor();
-
- /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
-
- // LLVisualParam Virtual functions
- ///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
- /*virtual*/ void apply( ESex avatar_sex ) {}
- /*virtual*/ void setWeight(F32 weight, BOOL upload_bake);
- /*virtual*/ void setAnimationTarget(F32 target_value, BOOL upload_bake);
- /*virtual*/ void animate(F32 delta, BOOL upload_bake);
-
-
- // LLViewerVisualParam Virtual functions
- /*virtual*/ F32 getTotalDistortion() { return 1.f; }
- /*virtual*/ const LLVector4a& getAvgDistortion() { return mAvgDistortionVec; }
- /*virtual*/ F32 getMaxDistortion() { return 3.f; }
- /*virtual*/ LLVector4a getVertexDistortion(S32 index, LLPolyMesh *poly_mesh) { return LLVector4a(1.f, 1.f, 1.f); }
- /*virtual*/ const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh) { index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
- /*virtual*/ const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh) { index = 0; poly_mesh = NULL; return NULL;};
-
- // New functions
- LLColor4 getNetColor() const;
-protected:
- virtual void onGlobalColorChanged(bool upload_bake) {}
-private:
- LLVector4a mAvgDistortionVec;
-};
-
-class LLTexLayerParamColorInfo : public LLViewerVisualParamInfo
-{
- friend class LLTexLayerParamColor;
-
-public:
- LLTexLayerParamColorInfo();
- virtual ~LLTexLayerParamColorInfo() {};
- BOOL parseXml( LLXmlTreeNode* node );
- LLTexLayerParamColor::EColorOperation getOperation() const { return mOperation; }
-private:
- enum { MAX_COLOR_VALUES = 20 };
- LLTexLayerParamColor::EColorOperation mOperation;
- LLColor4 mColors[MAX_COLOR_VALUES];
- S32 mNumColors;
-};
-
-typedef std::vector<LLTexLayerParamColor *> param_color_list_t;
-typedef std::vector<LLTexLayerParamAlpha *> param_alpha_list_t;
-typedef std::vector<LLTexLayerParamColorInfo *> param_color_info_list_t;
-typedef std::vector<LLTexLayerParamAlphaInfo *> param_alpha_info_list_t;
-
-#endif
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c60b4155a0..4611107bc2 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -40,7 +40,7 @@
#include "lltooltip.h"
#include "llappviewer.h"
#include "llselectmgr.h"
-#include "lltexlayer.h"
+#include "llviewertexlayer.h"
#include "lltexturecache.h"
#include "lltexturefetch.h"
#include "llviewercontrol.h"
@@ -423,7 +423,7 @@ void LLAvatarTexBar::draw()
++baked_iter)
{
const LLVOAvatarDefines::EBakedTextureIndex baked_index = baked_iter->first;
- const LLTexLayerSet *layerset = avatarp->debugGetLayerSet(baked_index);
+ const LLViewerTexLayerSet *layerset = avatarp->debugGetLayerSet(baked_index);
if (!layerset) continue;
const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite();
if (!layerset_buffer) continue;
diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h
index 76e3833acb..531c0f765c 100644
--- a/indra/newview/llviewerjoint.h
+++ b/indra/newview/llviewerjoint.h
@@ -31,6 +31,7 @@
// Header Files
//-----------------------------------------------------------------------------
#include "lljoint.h"
+#include "lljointpickname.h"
class LLFace;
class LLViewerJointMesh;
@@ -103,21 +104,8 @@ public:
F32 getLOD() { return mMinPixelArea; }
void setLOD( F32 pixelArea ) { mMinPixelArea = pixelArea; }
- // Sets the OpenGL selection stack name that is pushed and popped
- // with this joint state. The default value indicates that no name
- // should be pushed/popped.
- enum PickName
- {
- PN_DEFAULT = -1,
- PN_0 = 0,
- PN_1 = 1,
- PN_2 = 2,
- PN_3 = 3,
- PN_4 = 4,
- PN_5 = 5
- };
- void setPickName(PickName name) { mPickName = name; }
- PickName getPickName() { return mPickName; }
+ void setPickName(LLJointPickName name) { mPickName = name; }
+ LLJointPickName getPickName() { return mPickName; }
virtual void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area);
virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false);
@@ -141,7 +129,7 @@ protected:
BOOL mValid;
U32 mComponents;
F32 mMinPixelArea;
- PickName mPickName;
+ LLJointPickName mPickName;
BOOL mVisible;
S32 mMeshID;
};
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 5d1aa870a3..79800c1df3 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -42,7 +42,7 @@
#include "llface.h"
#include "llgldbg.h"
#include "llglheaders.h"
-#include "lltexlayer.h"
+#include "llviewertexlayer.h"
#include "llviewercamera.h"
#include "llviewercontrol.h"
#include "llviewertexturelist.h"
@@ -248,7 +248,7 @@ void LLViewerJointMesh::setTexture( LLViewerTexture *texture )
// LLViewerJointMesh::setLayerSet()
// Sets the shape texture (takes precedence over normal texture)
//--------------------------------------------------------------------
-void LLViewerJointMesh::setLayerSet( LLTexLayerSet* layer_set )
+void LLViewerJointMesh::setLayerSet( LLViewerTexLayerSet* layer_set )
{
mLayerSet = layer_set;
diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h
index dd5dae1dc1..ff6bed4f0f 100755
--- a/indra/newview/llviewerjointmesh.h
+++ b/indra/newview/llviewerjointmesh.h
@@ -35,7 +35,7 @@
class LLDrawable;
class LLFace;
class LLCharacter;
-class LLTexLayerSet;
+class LLViewerTexLayerSet;
typedef enum e_avatar_render_pass
{
@@ -67,7 +67,7 @@ protected:
// LLColor4 mSpecular; // specular color (always white for now)
F32 mShiny; // shiny value
LLPointer<LLViewerTexture> mTexture; // ptr to a global texture
- LLTexLayerSet* mLayerSet; // ptr to a layer set owned by the avatar
+ LLViewerTexLayerSet* mLayerSet; // ptr to a layer set owned by the avatar
U32 mTestImageName; // handle to a temporary texture for previewing uploads
LLPolyMesh* mMesh; // ptr to a global polymesh
BOOL mCullBackFaces; // true by default
@@ -109,7 +109,7 @@ public:
void setTestTexture( U32 name ) { mTestImageName = name; }
// Sets layer set responsible for a dynamic shape texture (takes precedence over normal texture)
- void setLayerSet( LLTexLayerSet* layer_set );
+ void setLayerSet( LLViewerTexLayerSet* layer_set );
// Gets the poly mesh
LLPolyMesh *getMesh();
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index d6dd645e8c..e3d28f2f5c 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -229,7 +229,6 @@ extern LLGLSLShader gSplatTextureRectProgram;
extern LLGLSLShader gGlowCombineFXAAProgram;
extern LLGLSLShader gDebugProgram;
extern LLGLSLShader gClipProgram;
-extern LLGLSLShader gAlphaMaskProgram;
//output tex0[tc0] + tex1[tc1]
extern LLGLSLShader gTwoTextureAddProgram;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index d1c6b7ea79..f049130f3a 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -41,7 +41,6 @@
#include "lltexturefetch.h"
#include "llviewerobjectlist.h"
#include "llviewertexturelist.h"
-#include "lltexlayer.h"
#include "lltexlayerparams.h"
#include "llsurface.h"
#include "llvlmanager.h"
@@ -55,6 +54,7 @@
#include "llviewerregion.h"
#include "llvoavatar.h"
#include "llvoavatarself.h"
+#include "llviewertexlayer.h"
#include "llviewerwindow.h" // *TODO: remove, only used for width/height
#include "llworld.h"
#include "llfeaturemanager.h"
diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp
new file mode 100644
index 0000000000..f805083aaa
--- /dev/null
+++ b/indra/newview/llviewertexlayer.cpp
@@ -0,0 +1,791 @@
+/**
+ * @file llviewertexlayer.cpp
+ * @brief Viewer texture layer. Used for avatars.
+ *
+ * $LicenseInfo:firstyear=2012&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llagent.h"
+#include "llassetuploadresponders.h"
+#include "llavatarappearance.h"
+#include "llglslshader.h"
+#include "llimagej2c.h"
+#include "llnotificationsutil.h"
+#include "llviewercontrol.h"
+#include "llviewerregion.h"
+#include "llviewertexlayer.h"
+#include "llvfile.h"
+#include "llvfs.h"
+#include "llvoavatarself.h"
+#include "pipeline.h"
+
+static const S32 BAKE_UPLOAD_ATTEMPTS = 7;
+static const F32 BAKE_UPLOAD_RETRY_DELAY = 2.f; // actual delay grows by power of 2 each attempt
+
+// runway consolidate
+extern std::string self_av_string();
+
+LLViewerTexLayerSet::LLViewerTexLayerSet(LLAvatarAppearance* const appearance) :
+ LLTexLayerSet(appearance),
+ mComposite( NULL ),
+ mUpdatesEnabled( FALSE )
+{
+}
+
+// virtual
+LLViewerTexLayerSet::~LLViewerTexLayerSet()
+{
+}
+
+void LLViewerTexLayerSet::gatherMorphMaskAlpha(U8 *data, S32 width, S32 height)
+{
+ memset(data, 255, width * height);
+
+ for( layer_list_t::iterator iter = mLayerList.begin(); iter != mLayerList.end(); iter++ )
+ {
+ LLTexLayerInterface* layer = *iter;
+ layer->gatherAlphaMasks(data, mComposite->getOriginX(),mComposite->getOriginY(), width, height);
+ }
+
+ // Set alpha back to that of our alpha masks.
+ renderAlphaMaskTextures(mComposite->getOriginX(), mComposite->getOriginY(), width, height, true);
+}
+
+LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite()
+{
+ if (!mComposite)
+ {
+ createComposite();
+ }
+ return mComposite;
+}
+
+const LLTexLayerSetBuffer* LLViewerTexLayerSet::getComposite() const
+{
+ return mComposite;
+}
+
+// virtual
+void LLViewerTexLayerSet::requestUpdate()
+{
+ if( mUpdatesEnabled )
+ {
+ createComposite();
+ mComposite->requestUpdate();
+ }
+}
+
+void LLViewerTexLayerSet::requestUpload()
+{
+ createComposite();
+ mComposite->requestUpload();
+}
+
+void LLViewerTexLayerSet::cancelUpload()
+{
+ if(mComposite)
+ {
+ mComposite->cancelUpload();
+ }
+}
+
+
+void LLViewerTexLayerSet::createComposite()
+{
+ if(!mComposite)
+ {
+ S32 width = mInfo->getWidth();
+ S32 height = mInfo->getHeight();
+ // Composite other avatars at reduced resolution
+ if( !mAvatarAppearance->isSelf() )
+ {
+ llerrs << "composites should not be created for non-self avatars!" << llendl;
+ }
+ mComposite = new LLTexLayerSetBuffer( this, width, height );
+ }
+}
+
+void LLViewerTexLayerSet::updateComposite()
+{
+ createComposite();
+ mComposite->requestUpdateImmediate();
+}
+
+// Returns TRUE if at least one packet of data has been received for each of the textures that this layerset depends on.
+BOOL LLViewerTexLayerSet::isLocalTextureDataAvailable() const
+{
+ if (!mAvatarAppearance->isSelf()) return FALSE;
+ LLVOAvatarSelf* self = dynamic_cast<LLVOAvatarSelf *>(mAvatarAppearance);
+ return self->isLocalTextureDataAvailable(this);
+}
+
+
+// Returns TRUE if all of the data for the textures that this layerset depends on have arrived.
+BOOL LLViewerTexLayerSet::isLocalTextureDataFinal() const
+{
+ if (!mAvatarAppearance->isSelf()) return FALSE;
+ LLVOAvatarSelf* self = dynamic_cast<LLVOAvatarSelf *>(mAvatarAppearance);
+ return self->isLocalTextureDataFinal(this);
+}
+
+void LLViewerTexLayerSet::destroyComposite()
+{
+ if( mComposite )
+ {
+ mComposite = NULL;
+ }
+}
+
+void LLViewerTexLayerSet::setUpdatesEnabled( BOOL b )
+{
+ mUpdatesEnabled = b;
+}
+
+LLVOAvatarSelf* LLViewerTexLayerSet::getAvatar() const
+{
+ return dynamic_cast<LLVOAvatarSelf*> (mAvatarAppearance);
+}
+
+//-----------------------------------------------------------------------------
+// LLBakedUploadData()
+//-----------------------------------------------------------------------------
+LLBakedUploadData::LLBakedUploadData(const LLVOAvatarSelf* avatar,
+ LLViewerTexLayerSet* layerset,
+ const LLUUID& id,
+ bool highest_res) :
+ mAvatar(avatar),
+ mTexLayerSet(layerset),
+ mID(id),
+ mStartTime(LLFrameTimer::getTotalTime()), // Record starting time
+ mIsHighestRes(highest_res)
+{
+}
+
+//-----------------------------------------------------------------------------
+// LLTexLayerSetBuffer
+// The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one.
+//-----------------------------------------------------------------------------
+
+// static
+S32 LLTexLayerSetBuffer::sGLByteCount = 0;
+
+LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLViewerTexLayerSet* const owner,
+ S32 width, S32 height) :
+ // ORDER_LAST => must render these after the hints are created.
+ LLViewerDynamicTexture( width, height, 4, LLViewerDynamicTexture::ORDER_LAST, TRUE ),
+ mUploadPending(FALSE), // Not used for any logic here, just to sync sending of updates
+ mNeedsUpload(FALSE),
+ mNumLowresUploads(0),
+ mUploadFailCount(0),
+ mNeedsUpdate(TRUE),
+ mNumLowresUpdates(0),
+ mTexLayerSet(owner)
+{
+ LLTexLayerSetBuffer::sGLByteCount += getSize();
+ mNeedsUploadTimer.start();
+ mNeedsUpdateTimer.start();
+}
+
+LLTexLayerSetBuffer::~LLTexLayerSetBuffer()
+{
+ LLTexLayerSetBuffer::sGLByteCount -= getSize();
+ destroyGLTexture();
+ for( S32 order = 0; order < ORDER_COUNT; order++ )
+ {
+ LLViewerDynamicTexture::sInstances[order].erase(this); // will fail in all but one case.
+ }
+}
+
+//virtual
+S8 LLTexLayerSetBuffer::getType() const
+{
+ return LLViewerDynamicTexture::LL_TEX_LAYER_SET_BUFFER ;
+}
+
+//virtual
+void LLTexLayerSetBuffer::restoreGLTexture()
+{
+ LLViewerDynamicTexture::restoreGLTexture() ;
+}
+
+//virtual
+void LLTexLayerSetBuffer::destroyGLTexture()
+{
+ LLViewerDynamicTexture::destroyGLTexture() ;
+}
+
+// static
+void LLTexLayerSetBuffer::dumpTotalByteCount()
+{
+ llinfos << "Composite System GL Buffers: " << (LLTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl;
+}
+
+void LLTexLayerSetBuffer::requestUpdate()
+{
+ restartUpdateTimer();
+ mNeedsUpdate = TRUE;
+ mNumLowresUpdates = 0;
+ // If we're in the middle of uploading a baked texture, we don't care about it any more.
+ // When it's downloaded, ignore it.
+ mUploadID.setNull();
+}
+
+void LLTexLayerSetBuffer::requestUpload()
+{
+ conditionalRestartUploadTimer();
+ mNeedsUpload = TRUE;
+ mNumLowresUploads = 0;
+ mUploadPending = TRUE;
+}
+
+void LLTexLayerSetBuffer::conditionalRestartUploadTimer()
+{
+ // If we requested a new upload but haven't even uploaded
+ // a low res version of our last upload request, then
+ // keep the timer ticking instead of resetting it.
+ if (mNeedsUpload && (mNumLowresUploads == 0))
+ {
+ mNeedsUploadTimer.unpause();
+ }
+ else
+ {
+ mNeedsUploadTimer.reset();
+ mNeedsUploadTimer.start();
+ }
+}
+
+void LLTexLayerSetBuffer::restartUpdateTimer()
+{
+ mNeedsUpdateTimer.reset();
+ mNeedsUpdateTimer.start();
+}
+
+void LLTexLayerSetBuffer::cancelUpload()
+{
+ mNeedsUpload = FALSE;
+ mUploadPending = FALSE;
+ mNeedsUploadTimer.pause();
+ mUploadRetryTimer.reset();
+}
+
+void LLTexLayerSetBuffer::pushProjection() const
+{
+ gGL.matrixMode(LLRender::MM_PROJECTION);
+ gGL.pushMatrix();
+ gGL.loadIdentity();
+ gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f);
+
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.pushMatrix();
+ gGL.loadIdentity();
+}
+
+void LLTexLayerSetBuffer::popProjection() const
+{
+ gGL.matrixMode(LLRender::MM_PROJECTION);
+ gGL.popMatrix();
+
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.popMatrix();
+}
+
+// virtual
+BOOL LLTexLayerSetBuffer::needsRender()
+{
+ llassert(mTexLayerSet->getAvatarAppearance() == gAgentAvatarp);
+ if (!isAgentAvatarValid()) return FALSE;
+
+ const BOOL upload_now = mNeedsUpload && isReadyToUpload();
+ const BOOL update_now = mNeedsUpdate && isReadyToUpdate();
+
+ // Don't render if we don't want to (or aren't ready to) upload or update.
+ if (!(update_now || upload_now))
+ {
+ return FALSE;
+ }
+
+ // Don't render if we're animating our appearance.
+ if (gAgentAvatarp->getIsAppearanceAnimating())
+ {
+ return FALSE;
+ }
+
+ // Don't render if we are trying to create a shirt texture but aren't wearing a skirt.
+ if (gAgentAvatarp->getBakedTE(mTexLayerSet) == LLVOAvatarDefines::TEX_SKIRT_BAKED &&
+ !gAgentAvatarp->isWearingWearableType(LLWearableType::WT_SKIRT))
+ {
+ cancelUpload();
+ return FALSE;
+ }
+
+ // Render if we have at least minimal level of detail for each local texture.
+ return mTexLayerSet->isLocalTextureDataAvailable();
+}
+
+void LLTexLayerSetBuffer::preRender(BOOL clear_depth)
+{
+ // Set up an ortho projection
+ pushProjection();
+
+ // keep depth buffer, we don't need to clear it
+ LLViewerDynamicTexture::preRender(FALSE);
+}
+
+void LLTexLayerSetBuffer::postRender(BOOL success)
+{
+ popProjection();
+
+ LLViewerDynamicTexture::postRender(success);
+}
+
+BOOL LLTexLayerSetBuffer::render()
+{
+ // Default color mask for tex layer render
+ gGL.setColorMask(true, true);
+
+ // do we need to upload, and do we have sufficient data to create an uploadable composite?
+ // TODO: When do we upload the texture if gAgent.mNumPendingQueries is non-zero?
+ const BOOL upload_now = mNeedsUpload && isReadyToUpload();
+ const BOOL update_now = mNeedsUpdate && isReadyToUpdate();
+
+ BOOL success = TRUE;
+
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.bind();
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
+
+ LLVertexBuffer::unbind();
+
+ // Composite the color data
+ LLGLSUIDefault gls_ui;
+ success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight );
+ gGL.flush();
+
+ if(upload_now)
+ {
+ if (!success)
+ {
+ llinfos << "Failed attempt to bake " << mTexLayerSet->getBodyRegionName() << llendl;
+ mUploadPending = FALSE;
+ }
+ else
+ {
+ if (mTexLayerSet->isVisible())
+ {
+ mTexLayerSet->getAvatar()->debugBakedTextureUpload(mTexLayerSet->getBakedTexIndex(), FALSE); // FALSE for start of upload, TRUE for finish.
+ doUpload();
+ }
+ else
+ {
+ mUploadPending = FALSE;
+ mNeedsUpload = FALSE;
+ mNeedsUploadTimer.pause();
+ mTexLayerSet->getAvatar()->setNewBakedTexture(mTexLayerSet->getBakedTexIndex(),IMG_INVISIBLE);
+ }
+ }
+ }
+
+ if (update_now)
+ {
+ doUpdate();
+ }
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.unbind();
+ }
+
+ LLVertexBuffer::unbind();
+
+ // reset GL state
+ gGL.setColorMask(true, true);
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
+
+ // we have valid texture data now
+ mGLTexturep->setGLTextureCreated(true);
+
+ return success;
+}
+
+BOOL LLTexLayerSetBuffer::isInitialized(void) const
+{
+ return mGLTexturep.notNull() && mGLTexturep->isGLTextureCreated();
+}
+
+BOOL LLTexLayerSetBuffer::uploadPending() const
+{
+ return mUploadPending;
+}
+
+BOOL LLTexLayerSetBuffer::uploadNeeded() const
+{
+ return mNeedsUpload;
+}
+
+BOOL LLTexLayerSetBuffer::uploadInProgress() const
+{
+ return !mUploadID.isNull();
+}
+
+BOOL LLTexLayerSetBuffer::isReadyToUpload() const
+{
+ if (!gAgentQueryManager.hasNoPendingQueries()) return FALSE; // Can't upload if there are pending queries.
+ if (isAgentAvatarValid() && !gAgentAvatarp->isUsingBakedTextures()) return FALSE; // Don't upload if avatar is using composites.
+
+ BOOL ready = FALSE;
+ if (mTexLayerSet->isLocalTextureDataFinal())
+ {
+ // If we requested an upload and have the final LOD ready, upload (or wait a while if this is a retry)
+ if (mUploadFailCount == 0)
+ {
+ ready = TRUE;
+ }
+ else
+ {
+ ready = mUploadRetryTimer.getElapsedTimeF32() >= BAKE_UPLOAD_RETRY_DELAY * (1 << (mUploadFailCount - 1));
+ }
+ }
+ else
+ {
+ // Upload if we've hit a timeout. Upload is a pretty expensive process so we need to make sure
+ // we aren't doing uploads too frequently.
+ const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedTextureUploadTimeout");
+ if (texture_timeout != 0)
+ {
+ // The timeout period increases exponentially between every lowres upload in order to prevent
+ // spamming the server with frequent uploads.
+ const U32 texture_timeout_threshold = texture_timeout*(1 << mNumLowresUploads);
+
+ // If we hit our timeout and have textures available at even lower resolution, then upload.
+ const BOOL is_upload_textures_timeout = mNeedsUploadTimer.getElapsedTimeF32() >= texture_timeout_threshold;
+ const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable();
+ ready = has_lower_lod && is_upload_textures_timeout;
+ }
+ }
+
+ return ready;
+}
+
+BOOL LLTexLayerSetBuffer::isReadyToUpdate() const
+{
+ // If we requested an update and have the final LOD ready, then update.
+ if (mTexLayerSet->isLocalTextureDataFinal()) return TRUE;
+
+ // If we haven't done an update yet, then just do one now regardless of state of textures.
+ if (mNumLowresUpdates == 0) return TRUE;
+
+ // Update if we've hit a timeout. Unlike for uploads, we can make this timeout fairly small
+ // since render unnecessarily doesn't cost much.
+ const U32 texture_timeout = gSavedSettings.getU32("AvatarBakedLocalTextureUpdateTimeout");
+ if (texture_timeout != 0)
+ {
+ // If we hit our timeout and have textures available at even lower resolution, then update.
+ const BOOL is_update_textures_timeout = mNeedsUpdateTimer.getElapsedTimeF32() >= texture_timeout;
+ const BOOL has_lower_lod = mTexLayerSet->isLocalTextureDataAvailable();
+ if (has_lower_lod && is_update_textures_timeout) return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL LLTexLayerSetBuffer::requestUpdateImmediate()
+{
+ mNeedsUpdate = TRUE;
+ BOOL result = FALSE;
+
+ if (needsRender())
+ {
+ preRender(FALSE);
+ result = render();
+ postRender(result);
+ }
+
+ return result;
+}
+
+// Create the baked texture, send it out to the server, then wait for it to come
+// back so we can switch to using it.
+void LLTexLayerSetBuffer::doUpload()
+{
+ llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl;
+ LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES);
+
+ // Don't need caches since we're baked now. (note: we won't *really* be baked
+ // until this image is sent to the server and the Avatar Appearance message is received.)
+ mTexLayerSet->deleteCaches();
+
+ // Get the COLOR information from our texture
+ U8* baked_color_data = new U8[ mFullWidth * mFullHeight * 4 ];
+ glReadPixels(mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, GL_RGBA, GL_UNSIGNED_BYTE, baked_color_data );
+ stop_glerror();
+
+ // Get the MASK information from our texture
+ LLGLSUIDefault gls_ui;
+ LLPointer<LLImageRaw> baked_mask_image = new LLImageRaw(mFullWidth, mFullHeight, 1 );
+ U8* baked_mask_data = baked_mask_image->getData();
+ mTexLayerSet->gatherMorphMaskAlpha(baked_mask_data, mFullWidth, mFullHeight);
+
+
+ // Create the baked image from our color and mask information
+ const S32 baked_image_components = 5; // red green blue [bump] clothing
+ LLPointer<LLImageRaw> baked_image = new LLImageRaw( mFullWidth, mFullHeight, baked_image_components );
+ U8* baked_image_data = baked_image->getData();
+ S32 i = 0;
+ for (S32 u=0; u < mFullWidth; u++)
+ {
+ for (S32 v=0; v < mFullHeight; v++)
+ {
+ baked_image_data[5*i + 0] = baked_color_data[4*i + 0];
+ baked_image_data[5*i + 1] = baked_color_data[4*i + 1];
+ baked_image_data[5*i + 2] = baked_color_data[4*i + 2];
+ baked_image_data[5*i + 3] = baked_color_data[4*i + 3]; // alpha should be correct for eyelashes.
+ baked_image_data[5*i + 4] = baked_mask_data[i];
+ i++;
+ }
+ }
+
+ LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C;
+ const char* comment_text = LINDEN_J2C_COMMENT_PREFIX "RGBHM"; // writes into baked_color_data. 5 channels (rgb, heightfield/alpha, mask)
+ if (compressedImage->encode(baked_image, comment_text))
+ {
+ LLTransactionID tid;
+ tid.generate();
+ const LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
+ if (LLVFile::writeFile(compressedImage->getData(), compressedImage->getDataSize(),
+ gVFS, asset_id, LLAssetType::AT_TEXTURE))
+ {
+ // Read back the file and validate.
+ BOOL valid = FALSE;
+ LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C;
+ S32 file_size = 0;
+ U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size);
+ if (data)
+ {
+ valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'
+ }
+ else
+ {
+ integrity_test->setLastError("Unable to read entire file");
+ }
+
+ if (valid)
+ {
+ const bool highest_lod = mTexLayerSet->isLocalTextureDataFinal();
+ // Baked_upload_data is owned by the responder and deleted after the request completes.
+ LLBakedUploadData* baked_upload_data = new LLBakedUploadData(gAgentAvatarp,
+ this->mTexLayerSet,
+ asset_id,
+ highest_lod);
+ // upload ID is used to avoid overlaps, e.g. when the user rapidly makes two changes outside of Face Edit.
+ mUploadID = asset_id;
+
+ // Upload the image
+ const std::string url = gAgent.getRegion()->getCapability("UploadBakedTexture");
+ if(!url.empty()
+ && !LLPipeline::sForceOldBakedUpload // toggle debug setting UploadBakedTexOld to change between the new caps method and old method
+ && (mUploadFailCount < (BAKE_UPLOAD_ATTEMPTS - 1))) // Try last ditch attempt via asset store if cap upload is failing.
+ {
+ LLSD body = LLSD::emptyMap();
+ // The responder will call LLTexLayerSetBuffer::onTextureUploadComplete()
+ LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
+ llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl;
+ }
+ else
+ {
+ gAssetStorage->storeAssetData(tid,
+ LLAssetType::AT_TEXTURE,
+ LLTexLayerSetBuffer::onTextureUploadComplete,
+ baked_upload_data,
+ TRUE, // temp_file
+ TRUE, // is_priority
+ TRUE); // store_local
+ llinfos << "Baked texture upload via Asset Store." << llendl;
+ }
+
+ if (highest_lod)
+ {
+ // Sending the final LOD for the baked texture. All done, pause
+ // the upload timer so we know how long it took.
+ mNeedsUpload = FALSE;
+ mNeedsUploadTimer.pause();
+ }
+ else
+ {
+ // Sending a lower level LOD for the baked texture. Restart the upload timer.
+ mNumLowresUploads++;
+ mNeedsUploadTimer.unpause();
+ mNeedsUploadTimer.reset();
+ }
+
+ // Print out notification that we uploaded this texture.
+ if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
+ {
+ const std::string lod_str = highest_lod ? "HighRes" : "LowRes";
+ LLSD args;
+ args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatar()->debugGetExistenceTimeElapsedF32());
+ args["TIME"] = llformat("%d",(U32)mNeedsUploadTimer.getElapsedTimeF32());
+ args["BODYREGION"] = mTexLayerSet->getBodyRegionName();
+ args["RESOLUTION"] = lod_str;
+ LLNotificationsUtil::add("AvatarRezSelfBakedTextureUploadNotification",args);
+ LL_DEBUGS("Avatar") << self_av_string() << "Uploading [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUploadTimer.getElapsedTimeF32() << " ]" << LL_ENDL;
+ }
+ }
+ else
+ {
+ // The read back and validate operation failed. Remove the uploaded file.
+ mUploadPending = FALSE;
+ LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE, LLVFile::WRITE);
+ file.remove();
+ llinfos << "Unable to create baked upload file (reason: corrupted)." << llendl;
+ }
+ }
+ }
+ else
+ {
+ // The VFS write file operation failed.
+ mUploadPending = FALSE;
+ llinfos << "Unable to create baked upload file (reason: failed to write file)" << llendl;
+ }
+
+ delete [] baked_color_data;
+}
+
+// Mostly bookkeeping; don't need to actually "do" anything since
+// render() will actually do the update.
+void LLTexLayerSetBuffer::doUpdate()
+{
+ const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
+ if (highest_lod)
+ {
+ mNeedsUpdate = FALSE;
+ }
+ else
+ {
+ mNumLowresUpdates++;
+ }
+
+ restartUpdateTimer();
+
+ // need to switch to using this layerset if this is the first update
+ // after getting the lowest LOD
+ mTexLayerSet->getAvatarAppearance()->updateMeshTextures();
+
+ // Print out notification that we updated this texture.
+ if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
+ {
+ const BOOL highest_lod = mTexLayerSet->isLocalTextureDataFinal();
+ const std::string lod_str = highest_lod ? "HighRes" : "LowRes";
+ LLSD args;
+ args["EXISTENCE"] = llformat("%d",(U32)mTexLayerSet->getAvatarAppearance()->debugGetExistenceTimeElapsedF32());
+ args["TIME"] = llformat("%d",(U32)mNeedsUpdateTimer.getElapsedTimeF32());
+ args["BODYREGION"] = mTexLayerSet->getBodyRegionName();
+ args["RESOLUTION"] = lod_str;
+ LLNotificationsUtil::add("AvatarRezSelfBakedTextureUpdateNotification",args);
+ LL_DEBUGS("Avatar") << self_av_string() << "Locally updating [ name: " << mTexLayerSet->getBodyRegionName() << " res:" << lod_str << " time:" << (U32)mNeedsUpdateTimer.getElapsedTimeF32() << " ]" << LL_ENDL;
+ }
+}
+
+// static
+void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
+ void* userdata,
+ S32 result,
+ LLExtStat ext_status) // StoreAssetData callback (not fixed)
+{
+ LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata;
+
+ if (isAgentAvatarValid() &&
+ !gAgentAvatarp->isDead() &&
+ (baked_upload_data->mAvatar == gAgentAvatarp) && // Sanity check: only the user's avatar should be uploading textures.
+ (baked_upload_data->mTexLayerSet->hasComposite()))
+ {
+ LLTexLayerSetBuffer* layerset_buffer = baked_upload_data->mTexLayerSet->getComposite();
+ S32 failures = layerset_buffer->mUploadFailCount;
+ layerset_buffer->mUploadFailCount = 0;
+
+ if (layerset_buffer->mUploadID.isNull())
+ {
+ // The upload got canceled, we should be in the
+ // process of baking a new texture so request an
+ // upload with the new data
+
+ // BAP: does this really belong in this callback, as
+ // opposed to where the cancellation takes place?
+ // suspect this does nothing.
+ layerset_buffer->requestUpload();
+ }
+ else if (baked_upload_data->mID == layerset_buffer->mUploadID)
+ {
+ // This is the upload we're currently waiting for.
+ layerset_buffer->mUploadID.setNull();
+ const std::string name(baked_upload_data->mTexLayerSet->getBodyRegionName());
+ const std::string resolution = baked_upload_data->mIsHighestRes ? " full res " : " low res ";
+ if (result >= 0)
+ {
+ layerset_buffer->mUploadPending = FALSE; // Allows sending of AgentSetAppearance later
+ LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet);
+ // Update baked texture info with the new UUID
+ U64 now = LLFrameTimer::getTotalTime(); // Record starting time
+ llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl;
+ gAgentAvatarp->setNewBakedTexture(baked_te, uuid);
+ }
+ else
+ {
+ ++failures;
+ S32 max_attempts = baked_upload_data->mIsHighestRes ? BAKE_UPLOAD_ATTEMPTS : 1; // only retry final bakes
+ llwarns << "Baked" << resolution << "texture upload for " << name << " failed (attempt " << failures << "/" << max_attempts << ")" << llendl;
+ if (failures < max_attempts)
+ {
+ layerset_buffer->mUploadFailCount = failures;
+ layerset_buffer->mUploadRetryTimer.start();
+ layerset_buffer->requestUpload();
+ }
+ }
+ }
+ else
+ {
+ llinfos << "Received baked texture out of date, ignored." << llendl;
+ }
+
+ gAgentAvatarp->dirtyMesh();
+ }
+ else
+ {
+ // Baked texture failed to upload (in which case since we
+ // didn't set the new baked texture, it means that they'll try
+ // and rebake it at some point in the future (after login?)),
+ // or this response to upload is out of date, in which case a
+ // current response should be on the way or already processed.
+ llwarns << "Baked upload failed" << llendl;
+ }
+
+ delete baked_upload_data;
+}
+
+
+
+
diff --git a/indra/newview/llviewertexlayer.h b/indra/newview/llviewertexlayer.h
new file mode 100644
index 0000000000..ff3def5a82
--- /dev/null
+++ b/indra/newview/llviewertexlayer.h
@@ -0,0 +1,172 @@
+/**
+ * @file llviewertexlayer.h
+ * @brief Viewer Texture layer classes. Used for avatars.
+ *
+ * $LicenseInfo:firstyear=2012&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_VIEWER_TEXLAYER_H
+#define LL_VIEWER_TEXLAYER_H
+
+#include "lldynamictexture.h"
+#include "lltexlayer.h"
+
+class LLTexLayerSetBuffer;
+class LLVOAvatarSelf;
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// LLViewerTexLayerSet
+//
+// An ordered set of texture layers that gets composited into a single texture.
+// Only exists for llavatarappearanceself.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+class LLViewerTexLayerSet : public LLTexLayerSet
+{
+ friend class LLTexLayerSetBuffer;
+public:
+ LLViewerTexLayerSet(LLAvatarAppearance* const appearance);
+ virtual ~LLViewerTexLayerSet();
+
+ LLTexLayerSetBuffer* getComposite();
+ const LLTexLayerSetBuffer* getComposite() const; // Do not create one if it doesn't exist.
+ virtual void requestUpdate();
+ void requestUpload();
+ void cancelUpload();
+ void updateComposite();
+ BOOL isLocalTextureDataAvailable() const;
+ BOOL isLocalTextureDataFinal() const;
+ void createComposite();
+ void destroyComposite();
+ void setUpdatesEnabled(BOOL b);
+ BOOL getUpdatesEnabled() const { return mUpdatesEnabled; }
+ void gatherMorphMaskAlpha(U8 *data, S32 width, S32 height);
+
+ LLVOAvatarSelf* getAvatar() const;
+ BOOL hasComposite() const { return (mComposite.notNull()); }
+
+private:
+ LLPointer<LLTexLayerSetBuffer> mComposite;
+ BOOL mUpdatesEnabled;
+
+};
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// LLTexLayerSetBuffer
+//
+// The composite image that a LLViewerTexLayerSet writes to. Each LLTexLayerSet has one.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+class LLTexLayerSetBuffer : public LLViewerDynamicTexture
+{
+ LOG_CLASS(LLTexLayerSetBuffer);
+
+public:
+ LLTexLayerSetBuffer(LLViewerTexLayerSet* const owner, S32 width, S32 height);
+ virtual ~LLTexLayerSetBuffer();
+
+public:
+ /*virtual*/ S8 getType() const;
+ BOOL isInitialized(void) const;
+ static void dumpTotalByteCount();
+ const std::string dumpTextureInfo() const;
+ virtual void restoreGLTexture();
+ virtual void destroyGLTexture();
+protected:
+ void pushProjection() const;
+ void popProjection() const;
+private:
+ LLViewerTexLayerSet* const mTexLayerSet;
+ static S32 sGLByteCount;
+
+ //--------------------------------------------------------------------
+ // Render
+ //--------------------------------------------------------------------
+public:
+ /*virtual*/ BOOL needsRender();
+protected:
+ BOOL render(S32 x, S32 y, S32 width, S32 height);
+ virtual void preRender(BOOL clear_depth);
+ virtual void postRender(BOOL success);
+ virtual BOOL render();
+
+ //--------------------------------------------------------------------
+ // Uploads
+ //--------------------------------------------------------------------
+public:
+ void requestUpload();
+ void cancelUpload();
+ BOOL uploadNeeded() const; // We need to upload a new texture
+ BOOL uploadInProgress() const; // We have started uploading a new texture and are awaiting the result
+ BOOL uploadPending() const; // We are expecting a new texture to be uploaded at some point
+ static void onTextureUploadComplete(const LLUUID& uuid,
+ void* userdata,
+ S32 result, LLExtStat ext_status);
+protected:
+ BOOL isReadyToUpload() const;
+ void doUpload(); // Does a read back and upload.
+ void conditionalRestartUploadTimer();
+private:
+ BOOL mNeedsUpload; // Whether we need to send our baked textures to the server
+ U32 mNumLowresUploads; // Number of times we've sent a lowres version of our baked textures to the server
+ BOOL mUploadPending; // Whether we have received back the new baked textures
+ LLUUID mUploadID; // The current upload process (null if none).
+ LLFrameTimer mNeedsUploadTimer; // Tracks time since upload was requested and performed.
+ S32 mUploadFailCount; // Number of consecutive upload failures
+ LLFrameTimer mUploadRetryTimer; // Tracks time since last upload failure.
+
+ //--------------------------------------------------------------------
+ // Updates
+ //--------------------------------------------------------------------
+public:
+ void requestUpdate();
+ BOOL requestUpdateImmediate();
+protected:
+ BOOL isReadyToUpdate() const;
+ void doUpdate();
+ void restartUpdateTimer();
+private:
+ BOOL mNeedsUpdate; // Whether we need to locally update our baked textures
+ U32 mNumLowresUpdates; // Number of times we've locally updated with lowres version of our baked textures
+ LLFrameTimer mNeedsUpdateTimer; // Tracks time since update was requested and performed.
+};
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// LLBakedUploadData
+//
+// Used by LLTexLayerSetBuffer for a callback.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+struct LLBakedUploadData
+{
+ LLBakedUploadData(const LLVOAvatarSelf* avatar,
+ LLViewerTexLayerSet* layerset,
+ const LLUUID& id,
+ bool highest_res);
+ ~LLBakedUploadData() {}
+ const LLUUID mID;
+ const LLVOAvatarSelf* mAvatar; // note: backlink only; don't LLPointer
+ LLViewerTexLayerSet* mTexLayerSet;
+ const U64 mStartTime; // for measuring baked texture upload time
+ const bool mIsHighestRes; // whether this is a "final" bake, or intermediate low res
+};
+
+#endif // LL_VIEWER_TEXLAYER_H
+
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 8eb8717de2..c362269b81 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -59,6 +59,7 @@
#include "lltextureatlas.h"
#include "lltextureatlasmanager.h"
#include "lltextureentry.h"
+#include "lltexturemanagerbridge.h"
#include "llmediaentry.h"
#include "llvovolume.h"
#include "llviewermedia.h"
@@ -305,6 +306,26 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const
return gTextureList.getImageFromHost(image_id, host) ;
}
+// Create a bridge to the viewer texture manager.
+class LLViewerTextureManagerBridge : public LLTextureManagerBridge
+{
+ /*virtual*/ LLPointer<LLTexture> getLocalTexture(BOOL usemipmaps = TRUE, BOOL generate_gl_tex = TRUE)
+ {
+ return LLViewerTextureManager::getLocalTexture(usemipmaps, generate_gl_tex);
+ }
+
+ /*virtual*/ LLPointer<LLTexture> getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex = TRUE)
+ {
+ return LLViewerTextureManager::getLocalTexture(width, height, components, usemipmaps, generate_gl_tex);
+ }
+
+ /*virtual*/ LLTexture* getFetchedTexture(const LLUUID &image_id)
+ {
+ return LLViewerTextureManager::getFetchedTexture(image_id);
+ }
+};
+
+
void LLViewerTextureManager::init()
{
{
@@ -374,6 +395,9 @@ void LLViewerTextureManager::init()
LLViewerTexture::sCheckerBoardImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE);
LLViewerTexture::initClass() ;
+
+ // Create a texture manager bridge.
+ gTextureManagerBridgep = new LLViewerTextureManagerBridge();
if (LLMetricPerformanceTesterBasic::isMetricLogRequested(sTesterName) && !LLMetricPerformanceTesterBasic::getTester(sTesterName))
{
@@ -390,6 +414,7 @@ void LLViewerTextureManager::cleanup()
{
stop_glerror();
+ delete gTextureManagerBridgep;
LLImageGL::sDefaultGLTexture = NULL ;
LLViewerTexture::sNullImagep = NULL;
LLViewerTexture::sBlackImagep = NULL;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 2ea9a07e9a..4b92a2bf8a 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -107,39 +107,6 @@ public:
INVALID_TEXTURE_TYPE
};
- enum EBoostLevel
- {
- BOOST_NONE = 0,
- BOOST_AVATAR_BAKED ,
- BOOST_AVATAR ,
- BOOST_CLOUDS ,
- BOOST_SCULPTED ,
-
- BOOST_HIGH = 10,
- BOOST_BUMP ,
- BOOST_TERRAIN , // has to be high priority for minimap / low detail
- BOOST_SELECTED ,
- BOOST_AVATAR_BAKED_SELF ,
- BOOST_AVATAR_SELF , // needed for baking avatar
- BOOST_SUPER_HIGH , //textures higher than this need to be downloaded at the required resolution without delay.
- BOOST_HUD ,
- BOOST_ICON ,
- BOOST_UI ,
- BOOST_PREVIEW ,
- BOOST_MAP ,
- BOOST_MAP_VISIBLE ,
- BOOST_MAX_LEVEL,
-
- //other texture Categories
- LOCAL = BOOST_MAX_LEVEL,
- AVATAR_SCRATCH_TEX,
- DYNAMIC_TEX,
- MEDIA,
- ATLAS,
- OTHER,
- MAX_GL_IMAGE_CATEGORY
- };
-
static S32 getTotalNumOfCategories() ;
static S32 getIndexFromCategory(S32 category) ;
static S32 getCategoryFromIndex(S32 index) ;
@@ -168,7 +135,7 @@ public:
/*virtual*/ bool bindDefaultImage(const S32 stage = 0) ;
/*virtual*/ void forceImmediateUpdate() ;
- const LLUUID& getID() const { return mID; }
+ /*virtual*/ const LLUUID& getID() const { return mID; }
void setBoostLevel(S32 level);
S32 getBoostLevel() { return mBoostLevel; }
@@ -205,24 +172,24 @@ public:
/*virtual*/S32 getWidth(S32 discard_level = -1) const;
/*virtual*/S32 getHeight(S32 discard_level = -1) const;
- BOOL hasGLTexture() const ;
+ /*virtual*/BOOL hasGLTexture() const ;
LLGLuint getTexName() const ;
BOOL createGLTexture() ;
- BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE, S32 category = LLViewerTexture::OTHER);
+ /*virtual*/ BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE, S32 category = LLTexture::OTHER);
virtual void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ;
void setFilteringOption(LLTexUnit::eTextureFilterOptions option);
- void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
- void setAddressMode(LLTexUnit::eTextureAddressMode mode);
+ /*virtual*/ void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
+ /*virtual*/ void setAddressMode(LLTexUnit::eTextureAddressMode mode);
BOOL setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height);
BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height);
void setGLTextureCreated (bool initialized);
void setCategory(S32 category) ;
- LLTexUnit::eTextureAddressMode getAddressMode(void) const ;
+ /*virtual*/ LLTexUnit::eTextureAddressMode getAddressMode(void) const ;
S32 getMaxDiscardLevel() const;
S32 getDiscardLevel() const;
- S8 getComponents() const ;
+ /*virtual*/ S8 getComponents() const;
BOOL getBoundRecently() const;
S32 getTextureMemory() const ;
LLGLenum getPrimaryFormat() const;
@@ -761,6 +728,7 @@ public:
static void init() ;
static void cleanup() ;
};
+
//
//this class is used for test/debug only
//it tracks the activities of the texture pipeline
diff --git a/indra/newview/llviewervisualparam.cpp b/indra/newview/llviewervisualparam.cpp
deleted file mode 100644
index f0cf9b7692..0000000000
--- a/indra/newview/llviewervisualparam.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * @file llviewervisualparam.cpp
- * @brief Implementation of LLViewerVisualParam class
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-//-----------------------------------------------------------------------------
-// Header Files
-//-----------------------------------------------------------------------------
-#include "llviewerprecompiledheaders.h"
-
-#include "llviewervisualparam.h"
-#include "llxmltree.h"
-#include "llui.h"
-#include "llwearable.h"
-
-//-----------------------------------------------------------------------------
-// LLViewerVisualParamInfo()
-//-----------------------------------------------------------------------------
-LLViewerVisualParamInfo::LLViewerVisualParamInfo()
- :
- mWearableType( LLWearableType::WT_INVALID ),
- mCrossWearable(FALSE),
- mCamDist( 0.5f ),
- mCamAngle( 0.f ),
- mCamElevation( 0.f ),
- mEditGroupDisplayOrder( 0 ),
- mShowSimple(FALSE),
- mSimpleMin(0.f),
- mSimpleMax(100.f)
-{
-}
-
-LLViewerVisualParamInfo::~LLViewerVisualParamInfo()
-{
-}
-
-//-----------------------------------------------------------------------------
-// parseXml()
-//-----------------------------------------------------------------------------
-BOOL LLViewerVisualParamInfo::parseXml(LLXmlTreeNode *node)
-{
- llassert( node->hasName( "param" ) );
-
- if (!LLVisualParamInfo::parseXml(node))
- return FALSE;
-
- // VIEWER SPECIFIC PARAMS
-
- std::string wearable;
- static LLStdStringHandle wearable_string = LLXmlTree::addAttributeString("wearable");
- if( node->getFastAttributeString( wearable_string, wearable) )
- {
- mWearableType = LLWearableType::typeNameToType( wearable );
- }
-
- static LLStdStringHandle edit_group_string = LLXmlTree::addAttributeString("edit_group");
- if (!node->getFastAttributeString( edit_group_string, mEditGroup))
- {
- mEditGroup = "";
- }
-
- static LLStdStringHandle cross_wearable_string = LLXmlTree::addAttributeString("cross_wearable");
- if (!node->getFastAttributeBOOL(cross_wearable_string, mCrossWearable))
- {
- mCrossWearable = FALSE;
- }
-
- // Optional camera offsets from the current joint center. Used for generating "hints" (thumbnails).
- static LLStdStringHandle camera_distance_string = LLXmlTree::addAttributeString("camera_distance");
- node->getFastAttributeF32( camera_distance_string, mCamDist );
- static LLStdStringHandle camera_angle_string = LLXmlTree::addAttributeString("camera_angle");
- node->getFastAttributeF32( camera_angle_string, mCamAngle ); // in degrees
- static LLStdStringHandle camera_elevation_string = LLXmlTree::addAttributeString("camera_elevation");
- node->getFastAttributeF32( camera_elevation_string, mCamElevation );
-
- mCamAngle += 180;
-
- static S32 params_loaded = 0;
-
- // By default, parameters are displayed in the order in which they appear in the xml file.
- // "edit_group_order" overriddes.
- static LLStdStringHandle edit_group_order_string = LLXmlTree::addAttributeString("edit_group_order");
- if( !node->getFastAttributeF32( edit_group_order_string, mEditGroupDisplayOrder ) )
- {
- mEditGroupDisplayOrder = (F32)params_loaded;
- }
-
- params_loaded++;
-
- return TRUE;
-}
-
-/*virtual*/ void LLViewerVisualParamInfo::toStream(std::ostream &out)
-{
- LLVisualParamInfo::toStream(out);
-
- out << mWearableType << "\t";
- out << mEditGroup << "\t";
- out << mEditGroupDisplayOrder << "\t";
-}
-
-//-----------------------------------------------------------------------------
-// LLViewerVisualParam()
-//-----------------------------------------------------------------------------
-LLViewerVisualParam::LLViewerVisualParam()
-{
-}
-
-//-----------------------------------------------------------------------------
-// setInfo()
-//-----------------------------------------------------------------------------
-
-BOOL LLViewerVisualParam::setInfo(LLViewerVisualParamInfo *info)
-{
- llassert(mInfo == NULL);
- if (info->mID < 0)
- return FALSE;
- mInfo = info;
- mID = info->mID;
- setWeight(getDefaultWeight(), FALSE );
- return TRUE;
-}
-
-/*
-//=============================================================================
-// These virtual functions should always be overridden,
-// but are included here for use as templates
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// parseData()
-//-----------------------------------------------------------------------------
-BOOL LLViewerVisualParam::parseData(LLXmlTreeNode *node)
-{
- LLViewerVisualParamInfo* info = new LLViewerVisualParamInfo;
-
- info->parseXml(node);
- if (!setInfo(info))
- return FALSE;
-
- return TRUE;
-}
-*/
diff --git a/indra/newview/llviewervisualparam.h b/indra/newview/llviewervisualparam.h
deleted file mode 100644
index 3bc95cbfbf..0000000000
--- a/indra/newview/llviewervisualparam.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * @file llviewervisualparam.h
- * @brief viewer side visual params (with data file parsing)
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLViewerVisualParam_H
-#define LL_LLViewerVisualParam_H
-
-#include "v3math.h"
-#include "llstring.h"
-#include "llvisualparam.h"
-
-class LLWearable;
-
-//-----------------------------------------------------------------------------
-// LLViewerVisualParamInfo
-//-----------------------------------------------------------------------------
-class LLViewerVisualParamInfo : public LLVisualParamInfo
-{
- friend class LLViewerVisualParam;
-public:
- LLViewerVisualParamInfo();
- /*virtual*/ ~LLViewerVisualParamInfo();
-
- /*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
-
- /*virtual*/ void toStream(std::ostream &out);
-
-protected:
- S32 mWearableType;
- BOOL mCrossWearable;
- std::string mEditGroup;
- F32 mCamDist;
- F32 mCamAngle; // degrees
- F32 mCamElevation;
- F32 mEditGroupDisplayOrder;
- BOOL mShowSimple; // show edit controls when in "simple ui" mode?
- F32 mSimpleMin; // when in simple UI, apply this minimum, range 0.f to 100.f
- F32 mSimpleMax; // when in simple UI, apply this maximum, range 0.f to 100.f
-};
-
-//-----------------------------------------------------------------------------
-// LLViewerVisualParam
-// VIRTUAL CLASS
-// a viewer side interface class for a generalized parametric modification of the avatar mesh
-//-----------------------------------------------------------------------------
-class LLViewerVisualParam : public LLVisualParam
-{
-public:
- LLViewerVisualParam();
- /*virtual*/ ~LLViewerVisualParam(){};
-
- // Special: These functions are overridden by child classes
- LLViewerVisualParamInfo *getInfo() const { return (LLViewerVisualParamInfo*)mInfo; };
- // This sets mInfo and calls initialization functions
- BOOL setInfo(LLViewerVisualParamInfo *info);
-
- virtual LLViewerVisualParam* cloneParam(LLWearable* wearable) const = 0;
-
- // LLVisualParam Virtual functions
- ///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
-
- // New Virtual functions
- virtual F32 getTotalDistortion() = 0;
- virtual const LLVector4a& getAvgDistortion() = 0;
- virtual F32 getMaxDistortion() = 0;
- virtual LLVector4a getVertexDistortion(S32 index, LLPolyMesh *mesh) = 0;
- virtual const LLVector4a* getFirstDistortion(U32 *index, LLPolyMesh **mesh) = 0;
- virtual const LLVector4a* getNextDistortion(U32 *index, LLPolyMesh **mesh) = 0;
-
- // interface methods
- F32 getDisplayOrder() const { return getInfo()->mEditGroupDisplayOrder; }
- S32 getWearableType() const { return getInfo()->mWearableType; }
- const std::string& getEditGroup() const { return getInfo()->mEditGroup; }
-
- F32 getCameraDistance() const { return getInfo()->mCamDist; }
- F32 getCameraAngle() const { return getInfo()->mCamAngle; } // degrees
- F32 getCameraElevation() const { return getInfo()->mCamElevation; }
-
- BOOL getShowSimple() const { return getInfo()->mShowSimple; }
- F32 getSimpleMin() const { return getInfo()->mSimpleMin; }
- F32 getSimpleMax() const { return getInfo()->mSimpleMax; }
-
- BOOL getCrossWearable() const { return getInfo()->mCrossWearable; }
-
-};
-
-#endif // LL_LLViewerVisualParam_H
diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp
new file mode 100644
index 0000000000..b63f1f57cb
--- /dev/null
+++ b/indra/newview/llviewerwearable.cpp
@@ -0,0 +1,900 @@
+/**
+ * @file llviewerwearable.cpp
+ * @brief LLViewerWearable class implementation
+ *
+ * $LicenseInfo:firstyear=2012&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llagent.h"
+#include "llagentcamera.h"
+#include "llagentwearables.h"
+#include "llfloatersidepanelcontainer.h"
+#include "llnotificationsutil.h"
+#include "llsidepanelappearance.h"
+#include "lltextureentry.h"
+#include "llviewercontrol.h"
+#include "llviewertexlayer.h"
+#include "llviewerwearable.h"
+#include "llvoavatarself.h"
+#include "llvoavatardefines.h"
+
+using namespace LLVOAvatarDefines;
+
+// support class - remove for 2.1 (hackity hack hack)
+class LLOverrideBakedTextureUpdate
+{
+public:
+ LLOverrideBakedTextureUpdate(bool temp_state)
+ {
+ U32 num_bakes = (U32) LLVOAvatarDefines::BAKED_NUM_INDICES;
+ for( U32 index = 0; index < num_bakes; ++index )
+ {
+ composite_enabled[index] = gAgentAvatarp->isCompositeUpdateEnabled(index);
+ }
+ gAgentAvatarp->setCompositeUpdatesEnabled(temp_state);
+ }
+
+ ~LLOverrideBakedTextureUpdate()
+ {
+ U32 num_bakes = (U32)LLVOAvatarDefines::BAKED_NUM_INDICES;
+ for( U32 index = 0; index < num_bakes; ++index )
+ {
+ gAgentAvatarp->setCompositeUpdatesEnabled(index, composite_enabled[index]);
+ }
+ }
+private:
+ bool composite_enabled[LLVOAvatarDefines::BAKED_NUM_INDICES];
+};
+
+// Private local functions
+static std::string asset_id_to_filename(const LLUUID &asset_id);
+
+LLViewerWearable::LLViewerWearable(const LLTransactionID& transaction_id) :
+ LLWearable()
+{
+ mTransactionID = transaction_id;
+ mAssetID = mTransactionID.makeAssetID(gAgent.getSecureSessionID());
+}
+
+LLViewerWearable::LLViewerWearable(const LLAssetID& asset_id) :
+ LLWearable()
+{
+ mAssetID = asset_id;
+ mTransactionID.setNull();
+}
+
+// virtual
+LLViewerWearable::~LLViewerWearable()
+{
+}
+
+void LLViewerWearable::setItemID(const LLUUID& item_id)
+{
+ mItemID = item_id;
+}
+
+// virtual
+BOOL LLViewerWearable::exportFile(LLFILE* file) const
+{
+ mTextureIDMap.clear();
+ for (te_map_t::const_iterator iter = mTEMap.begin(); iter != mTEMap.end(); ++iter)
+ {
+ S32 te = iter->first;
+ const LLUUID& image_id = iter->second->getID();
+ mTextureIDMap[te] = image_id;
+ }
+ return LLWearable::exportFile(file);
+}
+
+// virtual
+LLWearable::EImportResult LLViewerWearable::importFile( LLFILE* file )
+{
+ // suppress texlayerset updates while wearables are being imported. Layersets will be updated
+ // when the wearables are "worn", not loaded. Note state will be restored when this object is destroyed.
+ LLOverrideBakedTextureUpdate stop_bakes(false);
+
+ LLWearable::EImportResult result = LLWearable::importFile(file);
+ if (LLWearable::FAILURE == result) return result;
+ if (LLWearable::BAD_HEADER == result)
+ {
+ // Shouldn't really log the asset id for security reasons, but
+ // we need it in this case.
+ llwarns << "Bad Wearable asset header: " << mAssetID << llendl;
+ //gVFS->dumpMap();
+ return result;
+ }
+
+ LLStringUtil::truncate(mName, DB_INV_ITEM_NAME_STR_LEN );
+ LLStringUtil::truncate(mDescription, DB_INV_ITEM_DESC_STR_LEN );
+
+ texture_id_map_t::const_iterator iter = mTextureIDMap.begin();
+ texture_id_map_t::const_iterator end = mTextureIDMap.end();
+ for (; iter != end; ++iter)
+ {
+ S32 te = iter->first;
+ const LLUUID& textureid = iter->second;
+ if( mTEMap.find(te) != mTEMap.end() )
+ {
+ delete mTEMap[te];
+ }
+ if( mSavedTEMap.find(te) != mSavedTEMap.end() )
+ {
+ delete mSavedTEMap[te];
+ }
+
+ LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture( textureid );
+ if(gSavedSettings.getBOOL("DebugAvatarLocalTexLoadedTime"))
+ {
+ image->setLoadedCallback(LLVOAvatarSelf::debugOnTimingLocalTexLoaded,0,TRUE,FALSE, new LLVOAvatarSelf::LLAvatarTexData(textureid, (LLVOAvatarDefines::ETextureIndex)te), NULL);
+ }
+ mTEMap[te] = new LLLocalTextureObject(image, textureid);
+ mSavedTEMap[te] = new LLLocalTextureObject(image, textureid);
+ createLayers(te);
+ }
+
+ // copy all saved param values to working params
+ revertValues();
+
+ return result;
+}
+
+// Avatar parameter and texture definitions can change over time.
+// This function returns true if parameters or textures have been added or removed
+// since this wearable was created.
+BOOL LLViewerWearable::isOldVersion() const
+{
+ if (!isAgentAvatarValid()) return FALSE;
+
+ if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion )
+ {
+ llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << llendl;
+ llassert(0);
+ }
+
+ if( LLWearable::sCurrentDefinitionVersion != mDefinitionVersion )
+ {
+ return TRUE;
+ }
+
+ S32 param_count = 0;
+ for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
+ {
+ if( (param->getWearableType() == mType) && (param->isTweakable() ) )
+ {
+ param_count++;
+ if( !is_in_map(mVisualParamIndexMap, param->getID() ) )
+ {
+ return TRUE;
+ }
+ }
+ }
+ if( param_count != mVisualParamIndexMap.size() )
+ {
+ return TRUE;
+ }
+
+
+ S32 te_count = 0;
+ for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ te_count++;
+ if( !is_in_map(mTEMap, te ) )
+ {
+ return TRUE;
+ }
+ }
+ }
+ if( te_count != mTEMap.size() )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+// Avatar parameter and texture definitions can change over time.
+// * If parameters or textures have been REMOVED since the wearable was created,
+// they're just ignored, so we consider the wearable clean even though isOldVersion()
+// will return true.
+// * If parameters or textures have been ADDED since the wearable was created,
+// they are taken to have default values, so we consider the wearable clean
+// only if those values are the same as the defaults.
+BOOL LLViewerWearable::isDirty() const
+{
+ if (!isAgentAvatarValid()) return FALSE;
+
+ for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
+ {
+ if( (param->getWearableType() == mType)
+ && (param->isTweakable() )
+ && !param->getCrossWearable())
+ {
+ F32 current_weight = getVisualParamWeight(param->getID());
+ current_weight = llclamp( current_weight, param->getMinWeight(), param->getMaxWeight() );
+ F32 saved_weight = get_if_there(mSavedVisualParamMap, param->getID(), param->getDefaultWeight());
+ saved_weight = llclamp( saved_weight, param->getMinWeight(), param->getMaxWeight() );
+
+ U8 a = F32_to_U8( saved_weight, param->getMinWeight(), param->getMaxWeight() );
+ U8 b = F32_to_U8( current_weight, param->getMinWeight(), param->getMaxWeight() );
+ if( a != b )
+ {
+ return TRUE;
+ }
+ }
+ }
+
+ for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ te_map_t::const_iterator current_iter = mTEMap.find(te);
+ if(current_iter != mTEMap.end())
+ {
+ const LLUUID& current_image_id = current_iter->second->getID();
+ te_map_t::const_iterator saved_iter = mSavedTEMap.find(te);
+ if(saved_iter != mSavedTEMap.end())
+ {
+ const LLUUID& saved_image_id = saved_iter->second->getID();
+ if (saved_image_id != current_image_id)
+ {
+ // saved vs current images are different, wearable is dirty
+ return TRUE;
+ }
+ }
+ else
+ {
+ // image found in current image list but not saved image list
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
+void LLViewerWearable::setParamsToDefaults()
+{
+ if (!isAgentAvatarValid()) return;
+
+ for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
+ {
+ if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->isTweakable() ) )
+ {
+ setVisualParamWeight(param->getID(),param->getDefaultWeight(), FALSE);
+ }
+ }
+}
+
+void LLViewerWearable::setTexturesToDefaults()
+{
+ for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ LLUUID id = getDefaultTextureImageID((ETextureIndex) te);
+ LLViewerFetchedTexture * image = LLViewerTextureManager::getFetchedTexture( id );
+ if( mTEMap.find(te) == mTEMap.end() )
+ {
+ mTEMap[te] = new LLLocalTextureObject(image, id);
+ createLayers(te);
+ }
+ else
+ {
+ // Local Texture Object already created, just set image and UUID
+ LLLocalTextureObject *lto = mTEMap[te];
+ lto->setID(id);
+ lto->setImage(image);
+ }
+ }
+ }
+}
+
+
+//static
+const LLUUID LLViewerWearable::getDefaultTextureImageID(ETextureIndex index)
+{
+ const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(index);
+ const std::string &default_image_name = texture_dict->mDefaultImageName;
+ if (default_image_name == "")
+ {
+ return IMG_DEFAULT_AVATAR;
+ }
+ else
+ {
+ return LLUUID(gSavedSettings.getString(default_image_name));
+ }
+}
+
+
+// Updates the user's avatar's appearance
+void LLViewerWearable::writeToAvatar()
+{
+ if (!isAgentAvatarValid()) return;
+
+ ESex old_sex = gAgentAvatarp->getSex();
+
+ // Pull params
+ for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
+ {
+ // cross-wearable parameters are not authoritative, as they are driven by a different wearable. So don't copy the values to the
+ // avatar object if cross wearable. Cross wearable params get their values from the avatar, they shouldn't write the other way.
+ if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (!((LLViewerVisualParam*)param)->getCrossWearable()) )
+ {
+ S32 param_id = param->getID();
+ F32 weight = getVisualParamWeight(param_id);
+
+ gAgentAvatarp->setVisualParamWeight( param_id, weight, FALSE );
+ }
+ }
+
+ // Pull texture entries
+ for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ te_map_t::const_iterator iter = mTEMap.find(te);
+ LLUUID image_id;
+ if(iter != mTEMap.end())
+ {
+ image_id = iter->second->getID();
+ }
+ else
+ {
+ image_id = getDefaultTextureImageID((ETextureIndex) te);
+ }
+ LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE );
+ // MULTI-WEARABLE: assume index 0 will be used when writing to avatar. TODO: eliminate the need for this.
+ gAgentAvatarp->setLocalTextureTE(te, image, 0);
+ }
+ }
+
+ ESex new_sex = gAgentAvatarp->getSex();
+ if( old_sex != new_sex )
+ {
+ gAgentAvatarp->updateSexDependentLayerSets( FALSE );
+ }
+
+// if( upload_bake )
+// {
+// gAgent.sendAgentSetAppearance();
+// }
+}
+
+
+// Updates the user's avatar's appearance, replacing this wearables' parameters and textures with default values.
+// static
+void LLViewerWearable::removeFromAvatar( LLWearableType::EType type, BOOL upload_bake )
+{
+ if (!isAgentAvatarValid()) return;
+
+ // You can't just remove body parts.
+ if( (type == LLWearableType::WT_SHAPE) ||
+ (type == LLWearableType::WT_SKIN) ||
+ (type == LLWearableType::WT_HAIR) ||
+ (type == LLWearableType::WT_EYES) )
+ {
+ return;
+ }
+
+ // Pull params
+ for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
+ {
+ if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->isTweakable() ) )
+ {
+ S32 param_id = param->getID();
+ gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
+ }
+ }
+
+ if(gAgentCamera.cameraCustomizeAvatar())
+ {
+ LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit"));
+ }
+
+ gAgentAvatarp->updateVisualParams();
+ gAgentAvatarp->wearableUpdated(type, FALSE);
+
+// if( upload_bake )
+// {
+// gAgent.sendAgentSetAppearance();
+// }
+}
+
+// Does not copy mAssetID.
+// Definition version is current: removes obsolete enties and creates default values for new ones.
+void LLViewerWearable::copyDataFrom(const LLViewerWearable* src)
+{
+ if (!isAgentAvatarValid()) return;
+
+ mDefinitionVersion = LLWearable::sCurrentDefinitionVersion;
+
+ mName = src->mName;
+ mDescription = src->mDescription;
+ mPermissions = src->mPermissions;
+ mSaleInfo = src->mSaleInfo;
+
+ setType(src->mType);
+
+ mSavedVisualParamMap.clear();
+ // Deep copy of mVisualParamMap (copies only those params that are current, filling in defaults where needed)
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
+ {
+ if( (param->getWearableType() == mType) )
+ {
+ S32 id = param->getID();
+ F32 weight = src->getVisualParamWeight(id);
+ mSavedVisualParamMap[id] = weight;
+ }
+ }
+
+ destroyTextures();
+ // Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed)
+ for (S32 te = 0; te < TEX_NUM_INDICES; te++)
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ te_map_t::const_iterator iter = src->mTEMap.find(te);
+ LLUUID image_id;
+ LLViewerFetchedTexture *image = NULL;
+ if(iter != src->mTEMap.end())
+ {
+ image = dynamic_cast<LLViewerFetchedTexture*> (src->getLocalTextureObject(te)->getImage());
+ image_id = src->getLocalTextureObject(te)->getID();
+ mTEMap[te] = new LLLocalTextureObject(image, image_id);
+ mSavedTEMap[te] = new LLLocalTextureObject(image, image_id);
+ mTEMap[te]->setBakedReady(src->getLocalTextureObject(te)->getBakedReady());
+ mTEMap[te]->setDiscard(src->getLocalTextureObject(te)->getDiscard());
+ }
+ else
+ {
+ image_id = getDefaultTextureImageID((ETextureIndex) te);
+ image = LLViewerTextureManager::getFetchedTexture( image_id );
+ mTEMap[te] = new LLLocalTextureObject(image, image_id);
+ mSavedTEMap[te] = new LLLocalTextureObject(image, image_id);
+ }
+ createLayers(te);
+ }
+ }
+
+ // Probably reduntant, but ensure that the newly created wearable is not dirty by setting current value of params in new wearable
+ // to be the same as the saved values (which were loaded from src at param->cloneParam(this))
+ revertValues();
+}
+
+
+LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index)
+{
+ te_map_t::iterator iter = mTEMap.find(index);
+ if( iter != mTEMap.end() )
+ {
+ LLLocalTextureObject* lto = iter->second;
+ return lto;
+ }
+ return NULL;
+}
+
+const LLLocalTextureObject* LLViewerWearable::getLocalTextureObject(S32 index) const
+{
+ te_map_t::const_iterator iter = mTEMap.find(index);
+ if( iter != mTEMap.end() )
+ {
+ const LLLocalTextureObject* lto = iter->second;
+ return lto;
+ }
+ return NULL;
+}
+
+std::vector<LLLocalTextureObject*> LLViewerWearable::getLocalTextureListSeq()
+{
+ std::vector<LLLocalTextureObject*> result;
+
+ for(te_map_t::const_iterator iter = mTEMap.begin();
+ iter != mTEMap.end(); iter++)
+ {
+ LLLocalTextureObject* lto = iter->second;
+ result.push_back(lto);
+ }
+
+ return result;
+}
+
+void LLViewerWearable::setLocalTextureObject(S32 index, LLLocalTextureObject &lto)
+{
+ if( mTEMap.find(index) != mTEMap.end() )
+ {
+ mTEMap.erase(index);
+ }
+ mTEMap[index] = new LLLocalTextureObject(lto);
+}
+
+void LLViewerWearable::revertValues()
+{
+ //update saved settings so wearable is no longer dirty
+ // non-driver params first
+ for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
+ {
+ S32 id = iter->first;
+ F32 value = iter->second;
+ LLVisualParam *param = getVisualParam(id);
+ if(param && !dynamic_cast<LLDriverParam*>(param) )
+ {
+ setVisualParamWeight(id, value, TRUE);
+ }
+ }
+
+ //then driver params
+ for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
+ {
+ S32 id = iter->first;
+ F32 value = iter->second;
+ LLVisualParam *param = getVisualParam(id);
+ if(param && dynamic_cast<LLDriverParam*>(param) )
+ {
+ setVisualParamWeight(id, value, TRUE);
+ }
+ }
+
+ // make sure that saved values are sane
+ for (param_map_t::const_iterator iter = mSavedVisualParamMap.begin(); iter != mSavedVisualParamMap.end(); iter++)
+ {
+ S32 id = iter->first;
+ LLVisualParam *param = getVisualParam(id);
+ if( param )
+ {
+ mSavedVisualParamMap[id] = param->getWeight();
+ }
+ }
+
+ syncImages(mSavedTEMap, mTEMap);
+
+
+ LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLFloaterSidePanelContainer::getPanel("appearance"));
+ if( panel )
+ {
+ panel->updateScrollingPanelList();
+ }
+}
+
+BOOL LLViewerWearable::isOnTop() const
+{
+ return (this == gAgentWearables.getTopWearable(mType));
+}
+
+void LLViewerWearable::saveValues()
+{
+ //update saved settings so wearable is no longer dirty
+ mSavedVisualParamMap.clear();
+ for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); ++iter)
+ {
+ S32 id = iter->first;
+ LLVisualParam *wearable_param = iter->second;
+ F32 value = wearable_param->getWeight();
+ mSavedVisualParamMap[id] = value;
+ }
+
+ // Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed)
+ syncImages(mTEMap, mSavedTEMap);
+
+
+ LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(LLFloaterSidePanelContainer::getPanel("appearance"));
+ if( panel )
+ {
+ panel->updateScrollingPanelList();
+ }
+}
+
+void LLViewerWearable::syncImages(te_map_t &src, te_map_t &dst)
+{
+ // Deep copy of src (copies only those tes that are current, filling in defaults where needed)
+ for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ {
+ if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
+ {
+ te_map_t::const_iterator iter = src.find(te);
+ LLUUID image_id;
+ LLViewerFetchedTexture *image = NULL;
+ LLLocalTextureObject *lto = NULL;
+ if(iter != src.end())
+ {
+ // there's a Local Texture Object in the source image map. Use this to populate the values to store in the destination image map.
+ lto = iter->second;
+ image = dynamic_cast<LLViewerFetchedTexture*> (lto->getImage());
+ image_id = lto->getID();
+ }
+ else
+ {
+ // there is no Local Texture Object in the source image map. Get defaults values for populating the destination image map.
+ image_id = getDefaultTextureImageID((ETextureIndex) te);
+ image = LLViewerTextureManager::getFetchedTexture( image_id );
+ }
+
+ if( dst.find(te) != dst.end() )
+ {
+ // there's already an entry in the destination map for the texture. Just update its values.
+ dst[te]->setImage(image);
+ dst[te]->setID(image_id);
+ }
+ else
+ {
+ // no entry found in the destination map, we need to create a new Local Texture Object
+ dst[te] = new LLLocalTextureObject(image, image_id);
+ }
+
+ if( lto )
+ {
+ // If we pulled values from a Local Texture Object in the source map, make sure the proper flags are set in the new (or updated) entry in the destination map.
+ dst[te]->setBakedReady(lto->getBakedReady());
+ dst[te]->setDiscard(lto->getDiscard());
+ }
+ }
+ }
+}
+
+void LLViewerWearable::destroyTextures()
+{
+ for( te_map_t::iterator iter = mTEMap.begin(); iter != mTEMap.end(); ++iter )
+ {
+ LLLocalTextureObject *lto = iter->second;
+ delete lto;
+ }
+ mTEMap.clear();
+ for( te_map_t::iterator iter = mSavedTEMap.begin(); iter != mSavedTEMap.end(); ++iter )
+ {
+ LLLocalTextureObject *lto = iter->second;
+ delete lto;
+ }
+ mSavedTEMap.clear();
+}
+
+void LLViewerWearable::pullCrossWearableValues()
+{
+ // scan through all of the avatar's visual parameters
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
+ {
+ if( param )
+ {
+ LLDriverParam *driver_param = dynamic_cast<LLDriverParam*>(param);
+ if(driver_param)
+ {
+ // parameter is a driver parameter, have it update its
+ driver_param->updateCrossDrivenParams(getType());
+ }
+ }
+ }
+}
+
+
+void LLViewerWearable::setLabelUpdated() const
+{
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, getItemID());
+}
+
+
+void LLViewerWearable::refreshName()
+{
+ LLUUID item_id = getItemID();
+ LLInventoryItem* item = gInventory.getItem(item_id);
+ if( item )
+ {
+ mName = item->getName();
+ }
+}
+
+struct LLWearableSaveData
+{
+ LLWearableType::EType mType;
+};
+
+void LLViewerWearable::saveNewAsset() const
+{
+// llinfos << "LLViewerWearable::saveNewAsset() type: " << getTypeName() << llendl;
+ //llinfos << *this << llendl;
+
+ const std::string filename = asset_id_to_filename(mAssetID);
+ LLFILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */
+ BOOL successful_save = FALSE;
+ if(fp && exportFile(fp))
+ {
+ successful_save = TRUE;
+ }
+ if(fp)
+ {
+ fclose(fp);
+ fp = NULL;
+ }
+ if(!successful_save)
+ {
+ std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str());
+ llwarns << buffer << llendl;
+
+ LLSD args;
+ args["NAME"] = mName;
+ LLNotificationsUtil::add("CannotSaveWearableOutOfSpace", args);
+ return;
+ }
+
+ // save it out to database
+ if( gAssetStorage )
+ {
+ /*
+ std::string url = gAgent.getRegion()->getCapability("NewAgentInventory");
+ if (!url.empty())
+ {
+ llinfos << "Update Agent Inventory via capability" << llendl;
+ LLSD body;
+ body["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::assetToFolderType(getAssetType()));
+ body["asset_type"] = LLAssetType::lookup(getAssetType());
+ body["inventory_type"] = LLInventoryType::lookup(LLInventoryType::IT_WEARABLE);
+ body["name"] = getName();
+ body["description"] = getDescription();
+ LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, filename));
+ }
+ else
+ {
+ }
+ */
+ LLWearableSaveData* data = new LLWearableSaveData;
+ data->mType = mType;
+ gAssetStorage->storeAssetData(filename, mTransactionID, getAssetType(),
+ &LLViewerWearable::onSaveNewAssetComplete,
+ (void*)data);
+ }
+}
+
+// static
+void LLViewerWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userdata, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
+{
+ LLWearableSaveData* data = (LLWearableSaveData*)userdata;
+ const std::string& type_name = LLWearableType::getTypeName(data->mType);
+ if(0 == status)
+ {
+ // Success
+ llinfos << "Saved wearable " << type_name << llendl;
+ }
+ else
+ {
+ std::string buffer = llformat("Unable to save %s to central asset store.", type_name.c_str());
+ llwarns << buffer << " Status: " << status << llendl;
+ LLSD args;
+ args["NAME"] = type_name;
+ LLNotificationsUtil::add("CannotSaveToAssetStore", args);
+ }
+
+ // Delete temp file
+ const std::string src_filename = asset_id_to_filename(new_asset_id);
+ LLFile::remove(src_filename);
+
+ // delete the context data
+ delete data;
+
+}
+
+void LLViewerWearable::createLayers(S32 te)
+{
+ LLViewerTexLayerSet *layer_set = gAgentAvatarp->getLayerSet((ETextureIndex)te);
+ if (layer_set)
+ {
+ layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
+ }
+ else
+ {
+ llerrs << "could not find layerset for LTO in wearable!" << llendl;
+ }
+}
+
+void LLViewerWearable::createVisualParams()
+{
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
+ {
+ if (param->getWearableType() == mType)
+ {
+ addVisualParam(param->cloneParam(this));
+ }
+ }
+
+ // resync driver parameters to point to the newly cloned driven parameters
+ for (visual_param_index_map_t::iterator param_iter = mVisualParamIndexMap.begin();
+ param_iter != mVisualParamIndexMap.end();
+ ++param_iter)
+ {
+ LLVisualParam* param = param_iter->second;
+ LLVisualParam*(LLWearable::*wearable_function)(S32)const = &LLWearable::getVisualParam;
+ // need this line to disambiguate between versions of LLCharacter::getVisualParam()
+ LLVisualParam*(LLAvatarAppearance::*param_function)(S32)const = &LLAvatarAppearance::getVisualParam;
+ param->resetDrivenParams();
+ if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false))
+ {
+ if( !param->linkDrivenParams(boost::bind(param_function,gAgentAvatarp.get(),_1 ), true))
+ {
+ llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl;
+ continue;
+ }
+ }
+ }
+}
+
+void LLViewerWearable::setVisualParams()
+{
+ for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++)
+ {
+ S32 id = iter->first;
+ LLVisualParam *wearable_param = iter->second;
+ F32 value = wearable_param->getWeight();
+ gAgentAvatarp->setVisualParamWeight(id, value, FALSE);
+ }
+}
+
+
+
+std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w)
+{
+ s << "wearable " << LLWearableType::getTypeName(w.mType) << "\n";
+ s << " Name: " << w.mName << "\n";
+ s << " Desc: " << w.mDescription << "\n";
+ //w.mPermissions
+ //w.mSaleInfo
+
+ s << " Params:" << "\n";
+ for (LLWearable::visual_param_index_map_t::const_iterator iter = w.mVisualParamIndexMap.begin();
+ iter != w.mVisualParamIndexMap.end(); ++iter)
+ {
+ S32 param_id = iter->first;
+ LLVisualParam *wearable_param = iter->second;
+ F32 param_weight = wearable_param->getWeight();
+ s << " " << param_id << " " << param_weight << "\n";
+ }
+
+ s << " Textures:" << "\n";
+ for (LLViewerWearable::te_map_t::const_iterator iter = w.mTEMap.begin();
+ iter != w.mTEMap.end(); ++iter)
+ {
+ S32 te = iter->first;
+ const LLUUID& image_id = iter->second->getID();
+ s << " " << te << " " << image_id << "\n";
+ }
+ return s;
+}
+
+std::string asset_id_to_filename(const LLUUID &asset_id)
+{
+ std::string asset_id_string;
+ asset_id.toString(asset_id_string);
+ std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_id_string) + ".wbl";
+ return filename;
+}
+
diff --git a/indra/newview/llviewerwearable.h b/indra/newview/llviewerwearable.h
new file mode 100644
index 0000000000..857900f583
--- /dev/null
+++ b/indra/newview/llviewerwearable.h
@@ -0,0 +1,116 @@
+/**
+ * @file llviewerwearable.h
+ * @brief LLViewerWearable class header file
+ *
+ * $LicenseInfo:firstyear=2012&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_VIEWER_WEARABLE_H
+#define LL_VIEWER_WEARABLE_H
+
+#include "llwearable.h"
+#include "llvoavatardefines.h"
+
+class LLViewerWearable : public LLWearable
+{
+ friend class LLWearableList;
+
+ //--------------------------------------------------------------------
+ // Constructors and destructors
+ //--------------------------------------------------------------------
+private:
+ // Private constructors used by LLViewerWearableList
+ LLViewerWearable(const LLTransactionID& transactionID);
+ LLViewerWearable(const LLAssetID& assetID);
+public:
+ virtual ~LLViewerWearable();
+
+ //--------------------------------------------------------------------
+ // Accessors
+ //--------------------------------------------------------------------
+public:
+ const LLUUID& getItemID() const { return mItemID; }
+ const LLAssetID& getAssetID() const { return mAssetID; }
+ const LLTransactionID& getTransactionID() const { return mTransactionID; }
+ void setItemID(const LLUUID& item_id);
+
+public:
+ /*virtual*/ BOOL exportFile(LLFILE* file) const;
+ /*virtual*/ EImportResult importFile(LLFILE* file);
+
+ BOOL isDirty() const;
+ BOOL isOldVersion() const;
+
+ /*virtual*/ void writeToAvatar();
+ void removeFromAvatar( BOOL upload_bake ) { LLViewerWearable::removeFromAvatar( mType, upload_bake ); }
+ static void removeFromAvatar( LLWearableType::EType type, BOOL upload_bake );
+
+ void setParamsToDefaults();
+ void setTexturesToDefaults();
+
+ static const LLUUID getDefaultTextureImageID(LLVOAvatarDefines::ETextureIndex index);
+
+
+ void saveNewAsset() const;
+ static void onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status );
+
+ void copyDataFrom(const LLViewerWearable* src);
+
+ friend std::ostream& operator<<(std::ostream &s, const LLViewerWearable &w);
+
+ /*virtual*/ LLLocalTextureObject* getLocalTextureObject(S32 index);
+ const LLLocalTextureObject* getLocalTextureObject(S32 index) const;
+ std::vector<LLLocalTextureObject*> getLocalTextureListSeq();
+ void setLocalTextureObject(S32 index, LLLocalTextureObject &lto);
+
+ void revertValues();
+ void saveValues();
+ void pullCrossWearableValues();
+
+ BOOL isOnTop() const;
+
+ // Something happened that requires the wearable's label to be updated (e.g. worn/unworn).
+ void setLabelUpdated() const;
+
+ // the wearable was worn. make sure the name of the wearable object matches the LLViewerInventoryItem,
+ // not the wearable asset itself.
+ void refreshName();
+
+protected:
+ void createLayers(S32 te);
+ /*virtual*/void createVisualParams();
+ void setVisualParams();
+
+ typedef std::map<S32, LLLocalTextureObject*> te_map_t;
+ void syncImages(te_map_t &src, te_map_t &dst);
+ void destroyTextures();
+ LLTransactionID mTransactionID;
+ LLAssetID mAssetID;
+ LLUUID mItemID; // ID of the inventory item in the agent's inventory
+
+ te_map_t mTEMap; // maps TE to LocalTextureObject
+ te_map_t mSavedTEMap; // last saved version of TEMap
+};
+
+
+#endif // LL_VIEWER_WEARABLE_H
+
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 4894f21e67..dac479b2e0 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -77,15 +77,16 @@
#include "llselectmgr.h"
#include "llsprite.h"
#include "lltargetingmotion.h"
-#include "lltexlayer.h"
#include "lltoolmorph.h"
#include "llviewercamera.h"
+#include "llviewertexlayer.h"
#include "llviewertexturelist.h"
#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewershadermgr.h"
#include "llviewerstats.h"
+#include "llviewerwearable.h"
#include "llvoavatarself.h"
#include "llvovolume.h"
#include "llworld.h"
@@ -192,8 +193,6 @@ const S32 MAX_BUBBLE_CHAT_UTTERANCES = 12;
const F32 CHAT_FADE_TIME = 8.0;
const F32 BUBBLE_CHAT_TIME = CHAT_FADE_TIME * 3.f;
-const LLColor4 DUMMY_COLOR = LLColor4(0.5,0.5,0.5,1.0);
-
enum ERenderName
{
RENDER_NAME_NEVER,
@@ -645,8 +644,8 @@ static F32 calc_bouncy_animation(F32 x);
LLVOAvatar::LLVOAvatar(const LLUUID& id,
const LLPCode pcode,
LLViewerRegion* regionp) :
+ LLAvatarAppearance(),
LLViewerObject(id, pcode, regionp),
- mIsDummy(FALSE),
mSpecialRenderMode(0),
mAttachmentGeometryBytes(0),
mAttachmentSurfaceArea(0.f),
@@ -678,9 +677,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mFirstAppearanceMessageReceived( FALSE ),
mCulled( FALSE ),
mVisibilityRank(0),
- mTexSkinColor( NULL ),
- mTexHairColor( NULL ),
- mTexEyeColor( NULL ),
mNeedsSkin(FALSE),
mLastSkinTime(0.f),
mUpdatePeriod(1),
@@ -768,7 +764,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mRuthTimer.reset();
mRuthDebugTimer.reset();
- mDebugExistenceTimer.reset();
mPelvisOffset = LLVector3(0.0f,0.0f,0.0f);
mLastPelvisToFoot = 0.0f;
mPelvisFixup = 0.0f;
@@ -1133,7 +1128,7 @@ void LLVOAvatar::resetImpostors()
// static
void LLVOAvatar::deleteCachedImages(bool clearAll)
{
- if (LLTexLayerSet::sHasCaches)
+ if (LLViewerTexLayerSet::sHasCaches)
{
lldebugs << "Deleting layer set caches" << llendl;
for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
@@ -1142,7 +1137,7 @@ void LLVOAvatar::deleteCachedImages(bool clearAll)
LLVOAvatar* inst = (LLVOAvatar*) *iter;
inst->deleteLayerSetCaches(clearAll);
}
- LLTexLayerSet::sHasCaches = FALSE;
+ LLViewerTexLayerSet::sHasCaches = FALSE;
}
LLVOAvatarSelf::deleteScratchTextures();
LLTexLayerStaticImageList::getInstance()->deleteCachedImages();
@@ -5864,6 +5859,30 @@ void LLVOAvatar::updateVisualParams()
updateHeadOffset();
}
+// virtual
+U32 LLVOAvatar::getWearableCount(const LLWearableType::EType type) const
+{
+ return gAgentWearables.getWearableCount(type);
+}
+
+// virtual
+U32 LLVOAvatar::getWearableCount(const U32 tex_index) const
+{
+ return gAgentWearables.getWearableCount(tex_index);
+}
+
+// virtual
+LLWearable* LLVOAvatar::getWearable(const LLWearableType::EType type, U32 index /*= 0*/)
+{
+ return gAgentWearables.getWearable(type, index);
+}
+
+// virtual
+const LLWearable* LLVOAvatar::getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const
+{
+ return gAgentWearables.getWearable(type, index);
+}
+
//-----------------------------------------------------------------------------
// isActive()
//-----------------------------------------------------------------------------
@@ -6453,26 +6472,6 @@ S32 LLVOAvatar::getAttachmentCount()
return count;
}
-LLColor4 LLVOAvatar::getGlobalColor( const std::string& color_name ) const
-{
- if (color_name=="skin_color" && mTexSkinColor)
- {
- return mTexSkinColor->getColor();
- }
- else if(color_name=="hair_color" && mTexHairColor)
- {
- return mTexHairColor->getColor();
- }
- if(color_name=="eye_color" && mTexEyeColor)
- {
- return mTexEyeColor->getColor();
- }
- else
- {
-// return LLColor4( .5f, .5f, .5f, .5f );
- return LLColor4( 0.f, 1.f, 1.f, 1.f ); // good debugging color
- }
-}
// virtual
void LLVOAvatar::invalidateComposite( LLTexLayerSet* layerset, BOOL upload_result )
@@ -6483,6 +6482,7 @@ void LLVOAvatar::invalidateAll()
{
}
+// virtual
void LLVOAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake )
{
if (global_color == mTexSkinColor)
@@ -6682,6 +6682,7 @@ LLMotion* LLVOAvatar::findMotion(const LLUUID& id) const
// updateMeshTextures()
// Uses the current TE values to set the meshes' and layersets' textures.
//-----------------------------------------------------------------------------
+// virtual
void LLVOAvatar::updateMeshTextures()
{
// llinfos << "updateMeshTextures" << llendl;
@@ -6903,7 +6904,7 @@ BOOL LLVOAvatar::morphMaskNeedsUpdate(LLVOAvatarDefines::EBakedTextureIndex inde
{
if (isSelf())
{
- LLTexLayerSet *layer_set = mBakedTextureDatas[index].mTexLayerSet;
+ LLViewerTexLayerSet *layer_set = mBakedTextureDatas[index].mTexLayerSet;
if (layer_set)
{
return !layer_set->isMorphValid();
@@ -6973,112 +6974,6 @@ void LLVOAvatar::releaseComponentTextures()
}
}
-//static
-BOOL LLVOAvatar::teToColorParams( ETextureIndex te, U32 *param_name )
-{
- switch( te )
- {
- case TEX_UPPER_SHIRT:
- param_name[0] = 803; //"shirt_red";
- param_name[1] = 804; //"shirt_green";
- param_name[2] = 805; //"shirt_blue";
- break;
-
- case TEX_LOWER_PANTS:
- param_name[0] = 806; //"pants_red";
- param_name[1] = 807; //"pants_green";
- param_name[2] = 808; //"pants_blue";
- break;
-
- case TEX_LOWER_SHOES:
- param_name[0] = 812; //"shoes_red";
- param_name[1] = 813; //"shoes_green";
- param_name[2] = 817; //"shoes_blue";
- break;
-
- case TEX_LOWER_SOCKS:
- param_name[0] = 818; //"socks_red";
- param_name[1] = 819; //"socks_green";
- param_name[2] = 820; //"socks_blue";
- break;
-
- case TEX_UPPER_JACKET:
- case TEX_LOWER_JACKET:
- param_name[0] = 834; //"jacket_red";
- param_name[1] = 835; //"jacket_green";
- param_name[2] = 836; //"jacket_blue";
- break;
-
- case TEX_UPPER_GLOVES:
- param_name[0] = 827; //"gloves_red";
- param_name[1] = 829; //"gloves_green";
- param_name[2] = 830; //"gloves_blue";
- break;
-
- case TEX_UPPER_UNDERSHIRT:
- param_name[0] = 821; //"undershirt_red";
- param_name[1] = 822; //"undershirt_green";
- param_name[2] = 823; //"undershirt_blue";
- break;
-
- case TEX_LOWER_UNDERPANTS:
- param_name[0] = 824; //"underpants_red";
- param_name[1] = 825; //"underpants_green";
- param_name[2] = 826; //"underpants_blue";
- break;
-
- case TEX_SKIRT:
- param_name[0] = 921; //"skirt_red";
- param_name[1] = 922; //"skirt_green";
- param_name[2] = 923; //"skirt_blue";
- break;
-
- case TEX_HEAD_TATTOO:
- case TEX_LOWER_TATTOO:
- case TEX_UPPER_TATTOO:
- param_name[0] = 1071; //"tattoo_red";
- param_name[1] = 1072; //"tattoo_green";
- param_name[2] = 1073; //"tattoo_blue";
- break;
-
- default:
- llassert(0);
- return FALSE;
- }
-
- return TRUE;
-}
-
-void LLVOAvatar::setClothesColor( ETextureIndex te, const LLColor4& new_color, BOOL upload_bake )
-{
- U32 param_name[3];
- if( teToColorParams( te, param_name ) )
- {
- setVisualParamWeight( param_name[0], new_color.mV[VX], upload_bake );
- setVisualParamWeight( param_name[1], new_color.mV[VY], upload_bake );
- setVisualParamWeight( param_name[2], new_color.mV[VZ], upload_bake );
- }
-}
-
-LLColor4 LLVOAvatar::getClothesColor( ETextureIndex te )
-{
- LLColor4 color;
- U32 param_name[3];
- if( teToColorParams( te, param_name ) )
- {
- color.mV[VX] = getVisualParamWeight( param_name[0] );
- color.mV[VY] = getVisualParamWeight( param_name[1] );
- color.mV[VZ] = getVisualParamWeight( param_name[2] );
- }
- return color;
-}
-
-// static
-LLColor4 LLVOAvatar::getDummyColor()
-{
- return DUMMY_COLOR;
-}
-
void LLVOAvatar::dumpAvatarTEs( const std::string& context ) const
{
LL_DEBUGS("Avatar") << avString() << (isSelf() ? "Self: " : "Other: ") << context << LL_ENDL;
@@ -8787,7 +8682,7 @@ BOOL LLVOAvatar::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 ind
}
//virtual
-BOOL LLVOAvatar::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const
+BOOL LLVOAvatar::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLViewerWearable *wearable) const
{
// non-self avatars don't have wearables
return FALSE;
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 3f65dec11c..023711d81b 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -25,8 +25,8 @@
* $/LicenseInfo$
*/
-#ifndef LL_LLVOAVATAR_H
-#define LL_LLVOAVATAR_H
+#ifndef LL_VOAVATAR_H
+#define LL_VOAVATAR_H
#include <map>
#include <deque>
@@ -36,6 +36,7 @@
#include <boost/signals2.hpp>
#include "imageids.h" // IMG_INVISIBLE
+#include "llavatarappearance.h"
#include "llchat.h"
#include "lldrawpoolalpha.h"
#include "llviewerobject.h"
@@ -62,7 +63,8 @@ extern const LLUUID ANIM_AGENT_PELVIS_FIX;
extern const LLUUID ANIM_AGENT_TARGET;
extern const LLUUID ANIM_AGENT_WALK_ADJUST;
-class LLTexLayerSet;
+class LLViewerTexLayerSet;
+class LLViewerWearable;
class LLVoiceVisualizer;
class LLHUDNameTag;
class LLHUDEffectSpiral;
@@ -75,8 +77,8 @@ class LLVOAvatarSkeletonInfo;
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLVOAvatar :
+ public LLAvatarAppearance,
public LLViewerObject,
- public LLCharacter,
public boost::signals2::trackable
{
LOG_CLASS(LLVOAvatar);
@@ -222,8 +224,20 @@ public:
public:
virtual bool isSelf() const { return false; } // True if this avatar is for this viewer's agent
+ /*virtual*/BOOL isUsingBakedTextures() const { return mUseServerBakes; } // e.g. false if in appearance edit mode
bool isBuilt() const { return mIsBuilt; }
+/********************************************************************************
+ ** **
+ ** WEARABLES
+ **/
+public:
+ /*virtual*/ U32 getWearableCount(const LLWearableType::EType type) const;
+ /*virtual*/ U32 getWearableCount(const U32 tex_index) const;
+
+ /*virtual*/ LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/);
+ /*virtual*/ const LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const;
+
private: //aligned members
LL_ALIGN_16(LLVector4a mImpostorExtents[2]);
@@ -440,7 +454,7 @@ public:
static void deleteCachedImages(bool clearAll=true);
static void destroyGL();
static void restoreGL();
- BOOL mIsDummy; // for special views
+ BOOL mIsDummy; // for special views
S32 mSpecialRenderMode; // special lighting
U32 mAttachmentGeometryBytes; //number of bytes in attached geometry
F32 mAttachmentSurfaceArea; //estimated surface area of attachments
@@ -460,7 +474,14 @@ private:
public:
BOOL morphMaskNeedsUpdate(LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
void addMaskedMorph(LLVOAvatarDefines::EBakedTextureIndex index, LLPolyMorphTarget* morph_target, BOOL invert, std::string layer);
- void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
+ virtual void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLVOAvatarDefines::EBakedTextureIndex index = LLVOAvatarDefines::BAKED_NUM_INDICES);
+
+
+ //--------------------------------------------------------------------
+ // Global colors
+ //--------------------------------------------------------------------
+public:
+ virtual void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake);
//--------------------------------------------------------------------
// Visibility
@@ -563,7 +584,7 @@ public:
public:
virtual BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
- virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const;
+ virtual BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLViewerWearable *wearable) const;
BOOL isFullyBaked();
static BOOL areAllNearbyInstancesBaked(S32& grey_avatars);
@@ -586,7 +607,7 @@ protected:
struct BakedTextureData
{
LLUUID mLastTextureIndex;
- LLTexLayerSet* mTexLayerSet; // Only exists for self
+ LLViewerTexLayerSet* mTexLayerSet; // Only exists for self
bool mIsLoaded;
bool mIsUsed;
LLVOAvatarDefines::ETextureIndex mTextureIndex;
@@ -668,15 +689,15 @@ private:
**/
public:
- void updateMeshTextures();
+ virtual void updateMeshTextures();
void updateSexDependentLayerSets(BOOL upload_bake);
- void dirtyMesh(); // Dirty the avatar mesh
+ virtual void dirtyMesh(); // Dirty the avatar mesh
void updateMeshData();
protected:
void releaseMeshData();
virtual void restoreMeshData();
private:
- void dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority
+ virtual void dirtyMesh(S32 priority); // Dirty the avatar mesh, with priority
S32 mDirtyMesh; // 0 -- not dirty, 1 -- morphed, 2 -- LOD
BOOL mMeshTexturesDirty;
@@ -710,7 +731,6 @@ public:
//--------------------------------------------------------------------
public:
BOOL getIsAppearanceAnimating() const { return mAppearanceAnimating; }
- BOOL isUsingBakedTextures() const { return mUseServerBakes; } // e.g. false if in appearance edit mode
private:
BOOL mAppearanceAnimating;
LLFrameTimer mAppearanceMorphTimer;
@@ -720,25 +740,6 @@ private:
BOOL mUseServerBakes; // flag for if baked textures should be fetched from baking service (false if they're temporary uploads)
//--------------------------------------------------------------------
- // Clothing colors (convenience functions to access visual parameters)
- //--------------------------------------------------------------------
-public:
- void setClothesColor(LLVOAvatarDefines::ETextureIndex te, const LLColor4& new_color, BOOL upload_bake);
- LLColor4 getClothesColor(LLVOAvatarDefines::ETextureIndex te);
- static BOOL teToColorParams(LLVOAvatarDefines::ETextureIndex te, U32 *param_name);
-
- //--------------------------------------------------------------------
- // Global colors
- //--------------------------------------------------------------------
-public:
- LLColor4 getGlobalColor(const std::string& color_name ) const;
- void onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL upload_bake);
-private:
- LLTexGlobalColor* mTexSkinColor;
- LLTexGlobalColor* mTexHairColor;
- LLTexGlobalColor* mTexEyeColor;
-
- //--------------------------------------------------------------------
// Visibility
//--------------------------------------------------------------------
public:
@@ -746,7 +747,6 @@ public:
void setVisibilityRank(U32 rank);
U32 getVisibilityRank() const { return mVisibilityRank; } // unused
static S32 sNumVisibleAvatars; // Number of instances of this class
- static LLColor4 getDummyColor();
/** Appearance
** **
*******************************************************************************/
@@ -1038,11 +1038,9 @@ private:
//--------------------------------------------------------------------
public:
void debugAvatarRezTime(std::string notification_name, std::string comment = "");
- F32 debugGetExistenceTimeElapsedF32() const { return mDebugExistenceTimer.getElapsedTimeF32(); }
protected:
LLFrameTimer mRuthDebugTimer; // For tracking how long it takes for av to rez
- LLFrameTimer mDebugExistenceTimer; // Debugging for how long the avatar has been in memory.
/** Diagnostics
** **
@@ -1163,4 +1161,5 @@ protected: // Shared with LLVOAvatarSelf
extern const F32 SELF_ADDITIONAL_PRI;
extern const S32 MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL;
-#endif // LL_VO_AVATAR_H
+#endif // LL_VOAVATAR_H
+
diff --git a/indra/newview/llvoavatardefines.cpp b/indra/newview/llvoavatardefines.cpp
deleted file mode 100644
index ef96a9e923..0000000000
--- a/indra/newview/llvoavatardefines.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * @file llvoavatar.cpp
- * @brief Implementation of LLVOAvatar class which is a derivation fo LLViewerObject
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llvoavatardefines.h"
-#include "llviewercontrol.h" // gSavedSettings
-
-const S32 LLVOAvatarDefines::SCRATCH_TEX_WIDTH = 512;
-const S32 LLVOAvatarDefines::SCRATCH_TEX_HEIGHT = 512;
-const S32 LLVOAvatarDefines::IMPOSTOR_PERIOD = 2;
-
-using namespace LLVOAvatarDefines;
-
-/*********************************************************************************
- * Edit this function to add/remove/change textures and mesh definitions for avatars.
- */
-
-LLVOAvatarDictionary::Textures::Textures()
-{
- addEntry(TEX_HEAD_BODYPAINT, new TextureEntry("head_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
- addEntry(TEX_UPPER_SHIRT, new TextureEntry("upper_shirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultShirtUUID", LLWearableType::WT_SHIRT));
- addEntry(TEX_LOWER_PANTS, new TextureEntry("lower_pants", TRUE, BAKED_NUM_INDICES, "UIImgDefaultPantsUUID", LLWearableType::WT_PANTS));
- addEntry(TEX_EYES_IRIS, new TextureEntry("eyes_iris", TRUE, BAKED_NUM_INDICES, "UIImgDefaultEyesUUID", LLWearableType::WT_EYES));
- addEntry(TEX_HAIR, new TextureEntry("hair_grain", TRUE, BAKED_NUM_INDICES, "UIImgDefaultHairUUID", LLWearableType::WT_HAIR));
- addEntry(TEX_UPPER_BODYPAINT, new TextureEntry("upper_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
- addEntry(TEX_LOWER_BODYPAINT, new TextureEntry("lower_bodypaint", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_SKIN));
- addEntry(TEX_LOWER_SHOES, new TextureEntry("lower_shoes", TRUE, BAKED_NUM_INDICES, "UIImgDefaultShoesUUID", LLWearableType::WT_SHOES));
- addEntry(TEX_LOWER_SOCKS, new TextureEntry("lower_socks", TRUE, BAKED_NUM_INDICES, "UIImgDefaultSocksUUID", LLWearableType::WT_SOCKS));
- addEntry(TEX_UPPER_JACKET, new TextureEntry("upper_jacket", TRUE, BAKED_NUM_INDICES, "UIImgDefaultJacketUUID", LLWearableType::WT_JACKET));
- addEntry(TEX_LOWER_JACKET, new TextureEntry("lower_jacket", TRUE, BAKED_NUM_INDICES, "UIImgDefaultJacketUUID", LLWearableType::WT_JACKET));
- addEntry(TEX_UPPER_GLOVES, new TextureEntry("upper_gloves", TRUE, BAKED_NUM_INDICES, "UIImgDefaultGlovesUUID", LLWearableType::WT_GLOVES));
- addEntry(TEX_UPPER_UNDERSHIRT, new TextureEntry("upper_undershirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultUnderwearUUID", LLWearableType::WT_UNDERSHIRT));
- addEntry(TEX_LOWER_UNDERPANTS, new TextureEntry("lower_underpants", TRUE, BAKED_NUM_INDICES, "UIImgDefaultUnderwearUUID", LLWearableType::WT_UNDERPANTS));
- addEntry(TEX_SKIRT, new TextureEntry("skirt", TRUE, BAKED_NUM_INDICES, "UIImgDefaultSkirtUUID", LLWearableType::WT_SKIRT));
-
- addEntry(TEX_LOWER_ALPHA, new TextureEntry("lower_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
- addEntry(TEX_UPPER_ALPHA, new TextureEntry("upper_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
- addEntry(TEX_HEAD_ALPHA, new TextureEntry("head_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
- addEntry(TEX_EYES_ALPHA, new TextureEntry("eyes_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
- addEntry(TEX_HAIR_ALPHA, new TextureEntry("hair_alpha", TRUE, BAKED_NUM_INDICES, "UIImgDefaultAlphaUUID", LLWearableType::WT_ALPHA));
-
- addEntry(TEX_HEAD_TATTOO, new TextureEntry("head_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
- addEntry(TEX_UPPER_TATTOO, new TextureEntry("upper_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
- addEntry(TEX_LOWER_TATTOO, new TextureEntry("lower_tattoo", TRUE, BAKED_NUM_INDICES, "", LLWearableType::WT_TATTOO));
-
- addEntry(TEX_HEAD_BAKED, new TextureEntry("head-baked", FALSE, BAKED_HEAD, "head"));
- addEntry(TEX_UPPER_BAKED, new TextureEntry("upper-baked", FALSE, BAKED_UPPER, "upper"));
- addEntry(TEX_LOWER_BAKED, new TextureEntry("lower-baked", FALSE, BAKED_LOWER, "lower"));
- addEntry(TEX_EYES_BAKED, new TextureEntry("eyes-baked", FALSE, BAKED_EYES, "eyes"));
- addEntry(TEX_HAIR_BAKED, new TextureEntry("hair-baked", FALSE, BAKED_HAIR, "hair"));
- addEntry(TEX_SKIRT_BAKED, new TextureEntry("skirt-baked", FALSE, BAKED_SKIRT, "skirt"));
-}
-
-LLVOAvatarDictionary::BakedTextures::BakedTextures()
-{
- // Baked textures
- addEntry(BAKED_HEAD, new BakedEntry(TEX_HEAD_BAKED,
- "head", "a4b9dc38-e13b-4df9-b284-751efb0566ff",
- 3, TEX_HEAD_BODYPAINT, TEX_HEAD_TATTOO, TEX_HEAD_ALPHA,
- 5, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_HAIR, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
-
- addEntry(BAKED_UPPER, new BakedEntry(TEX_UPPER_BAKED,
- "upper_body", "5943ff64-d26c-4a90-a8c0-d61f56bd98d4",
- 7, TEX_UPPER_SHIRT,TEX_UPPER_BODYPAINT, TEX_UPPER_JACKET,
- TEX_UPPER_GLOVES, TEX_UPPER_UNDERSHIRT, TEX_UPPER_TATTOO, TEX_UPPER_ALPHA,
- 8, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_SHIRT, LLWearableType::WT_JACKET, LLWearableType::WT_GLOVES, LLWearableType::WT_UNDERSHIRT, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
-
- addEntry(BAKED_LOWER, new BakedEntry(TEX_LOWER_BAKED,
- "lower_body", "2944ee70-90a7-425d-a5fb-d749c782ed7d",
- 8, TEX_LOWER_PANTS,TEX_LOWER_BODYPAINT,TEX_LOWER_SHOES, TEX_LOWER_SOCKS,
- TEX_LOWER_JACKET, TEX_LOWER_UNDERPANTS, TEX_LOWER_TATTOO, TEX_LOWER_ALPHA,
- 9, LLWearableType::WT_SHAPE, LLWearableType::WT_SKIN, LLWearableType::WT_PANTS, LLWearableType::WT_SHOES, LLWearableType::WT_SOCKS, LLWearableType::WT_JACKET, LLWearableType::WT_UNDERPANTS, LLWearableType::WT_TATTOO, LLWearableType::WT_ALPHA));
-
- addEntry(BAKED_EYES, new BakedEntry(TEX_EYES_BAKED,
- "eyes", "27b1bc0f-979f-4b13-95fe-b981c2ba9788",
- 2, TEX_EYES_IRIS, TEX_EYES_ALPHA,
- 2, LLWearableType::WT_EYES, LLWearableType::WT_ALPHA));
-
- addEntry(BAKED_SKIRT, new BakedEntry(TEX_SKIRT_BAKED,
- "skirt", "03e7e8cb-1368-483b-b6f3-74850838ba63",
- 1, TEX_SKIRT,
- 1, LLWearableType::WT_SKIRT));
-
- addEntry(BAKED_HAIR, new BakedEntry(TEX_HAIR_BAKED,
- "hair", "a60e85a9-74e8-48d8-8a2d-8129f28d9b61",
- 2, TEX_HAIR, TEX_HAIR_ALPHA,
- 2, LLWearableType::WT_HAIR, LLWearableType::WT_ALPHA));
-}
-
-LLVOAvatarDictionary::Meshes::Meshes()
-{
- // Meshes
- addEntry(MESH_ID_HAIR, new MeshEntry(BAKED_HAIR, "hairMesh", 6, LLViewerJoint::PN_4));
- addEntry(MESH_ID_HEAD, new MeshEntry(BAKED_HEAD, "headMesh", 5, LLViewerJoint::PN_5));
- addEntry(MESH_ID_EYELASH, new MeshEntry(BAKED_HEAD, "eyelashMesh", 1, LLViewerJoint::PN_0)); // no baked mesh associated currently
- addEntry(MESH_ID_UPPER_BODY, new MeshEntry(BAKED_UPPER, "upperBodyMesh", 5, LLViewerJoint::PN_1));
- addEntry(MESH_ID_LOWER_BODY, new MeshEntry(BAKED_LOWER, "lowerBodyMesh", 5, LLViewerJoint::PN_2));
- addEntry(MESH_ID_EYEBALL_LEFT, new MeshEntry(BAKED_EYES, "eyeBallLeftMesh", 2, LLViewerJoint::PN_3));
- addEntry(MESH_ID_EYEBALL_RIGHT, new MeshEntry(BAKED_EYES, "eyeBallRightMesh", 2, LLViewerJoint::PN_3));
- addEntry(MESH_ID_SKIRT, new MeshEntry(BAKED_SKIRT, "skirtMesh", 5, LLViewerJoint::PN_5));
-}
-
-/*
- *
- *********************************************************************************/
-
-LLVOAvatarDictionary::LLVOAvatarDictionary()
-{
- createAssociations();
-}
-
-//virtual
-LLVOAvatarDictionary::~LLVOAvatarDictionary()
-{
-}
-
-// Baked textures are composites of textures; for each such composited texture,
-// map it to the baked texture.
-void LLVOAvatarDictionary::createAssociations()
-{
- for (BakedTextures::const_iterator iter = mBakedTextures.begin(); iter != mBakedTextures.end(); iter++)
- {
- const EBakedTextureIndex baked_index = (iter->first);
- const BakedEntry *dict = (iter->second);
-
- // For each texture that this baked texture index affects, associate those textures
- // with this baked texture index.
- for (texture_vec_t::const_iterator local_texture_iter = dict->mLocalTextures.begin();
- local_texture_iter != dict->mLocalTextures.end();
- local_texture_iter++)
- {
- const ETextureIndex local_texture_index = (ETextureIndex) *local_texture_iter;
- mTextures[local_texture_index]->mIsUsedByBakedTexture = true;
- mTextures[local_texture_index]->mBakedTextureIndex = baked_index;
- }
- }
-
-}
-
-LLVOAvatarDictionary::TextureEntry::TextureEntry(const std::string &name,
- bool is_local_texture,
- EBakedTextureIndex baked_texture_index,
- const std::string &default_image_name,
- LLWearableType::EType wearable_type) :
- LLDictionaryEntry(name),
- mIsLocalTexture(is_local_texture),
- mIsBakedTexture(!is_local_texture),
- mIsUsedByBakedTexture(baked_texture_index != BAKED_NUM_INDICES),
- mBakedTextureIndex(baked_texture_index),
- mDefaultImageName(default_image_name),
- mWearableType(wearable_type)
-{
-}
-
-LLVOAvatarDictionary::MeshEntry::MeshEntry(EBakedTextureIndex baked_index,
- const std::string &name,
- U8 level,
- LLViewerJoint::PickName pick) :
- LLDictionaryEntry(name),
- mBakedID(baked_index),
- mLOD(level),
- mPickName(pick)
-{
-}
-LLVOAvatarDictionary::BakedEntry::BakedEntry(ETextureIndex tex_index,
- const std::string &name,
- const std::string &hash_name,
- U32 num_local_textures,
- ... ) :
- LLDictionaryEntry(name),
- mWearablesHashID(LLUUID(hash_name)),
- mTextureIndex(tex_index)
-{
- va_list argp;
-
- va_start(argp, num_local_textures);
-
- // Read in local textures
- for (U8 i=0; i < num_local_textures; i++)
- {
- ETextureIndex t = (ETextureIndex)va_arg(argp,int);
- mLocalTextures.push_back(t);
- }
-
- // Read in number of wearables
- const U32 num_wearables = (U32)va_arg(argp,int);
- // Read in wearables
- for (U8 i=0; i < num_wearables; i++)
- {
- LLWearableType::EType t = (LLWearableType::EType)va_arg(argp,int);
- mWearables.push_back(t);
- }
-}
-
-// static
-ETextureIndex LLVOAvatarDictionary::bakedToLocalTextureIndex(EBakedTextureIndex index)
-{
- return LLVOAvatarDictionary::getInstance()->getBakedTexture(index)->mTextureIndex;
-}
-
-//static
-EBakedTextureIndex LLVOAvatarDictionary::findBakedByRegionName(std::string name)
-{
- U8 index = 0;
- while (index < BAKED_NUM_INDICES)
- {
- const BakedEntry *be = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex) index);
- if (be && be->mName.compare(name) == 0)
- {
- // baked texture found
- return (EBakedTextureIndex) index;
- }
- index++;
- }
- // baked texture could not be found
- return BAKED_NUM_INDICES;
-}
-
-//static
-const LLUUID LLVOAvatarDictionary::getDefaultTextureImageID(ETextureIndex index)
-{
- const TextureEntry *texture_dict = getInstance()->getTexture(index);
- const std::string &default_image_name = texture_dict->mDefaultImageName;
- if (default_image_name == "")
- {
- return IMG_DEFAULT_AVATAR;
- }
- else
- {
- return LLUUID(gSavedSettings.getString(default_image_name));
- }
-}
-
-// static
-LLWearableType::EType LLVOAvatarDictionary::getTEWearableType(ETextureIndex index )
-{
- return getInstance()->getTexture(index)->mWearableType;
-}
-
diff --git a/indra/newview/llvoavatardefines.h b/indra/newview/llvoavatardefines.h
deleted file mode 100644
index 35bb37463a..0000000000
--- a/indra/newview/llvoavatardefines.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * @file llvoavatar.h
- * @brief Declaration of LLVOAvatar class which is a derivation fo
- * LLViewerObject
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LLVOAVATAR_DEFINES_H
-#define LLVOAVATAR_DEFINES_H
-
-#include <vector>
-#include "llwearable.h"
-#include "llviewerjoint.h"
-#include "lldictionary.h"
-
-namespace LLVOAvatarDefines
-{
-
-extern const S32 SCRATCH_TEX_WIDTH;
-extern const S32 SCRATCH_TEX_HEIGHT;
-extern const S32 IMPOSTOR_PERIOD;
-
-//--------------------------------------------------------------------
-// Enums
-//--------------------------------------------------------------------
-enum ETextureIndex
-{
- TEX_HEAD_BODYPAINT = 0,
- TEX_UPPER_SHIRT,
- TEX_LOWER_PANTS,
- TEX_EYES_IRIS,
- TEX_HAIR,
- TEX_UPPER_BODYPAINT,
- TEX_LOWER_BODYPAINT,
- TEX_LOWER_SHOES,
- TEX_HEAD_BAKED, // Pre-composited
- TEX_UPPER_BAKED, // Pre-composited
- TEX_LOWER_BAKED, // Pre-composited
- TEX_EYES_BAKED, // Pre-composited
- TEX_LOWER_SOCKS,
- TEX_UPPER_JACKET,
- TEX_LOWER_JACKET,
- TEX_UPPER_GLOVES,
- TEX_UPPER_UNDERSHIRT,
- TEX_LOWER_UNDERPANTS,
- TEX_SKIRT,
- TEX_SKIRT_BAKED, // Pre-composited
- TEX_HAIR_BAKED, // Pre-composited
- TEX_LOWER_ALPHA,
- TEX_UPPER_ALPHA,
- TEX_HEAD_ALPHA,
- TEX_EYES_ALPHA,
- TEX_HAIR_ALPHA,
- TEX_HEAD_TATTOO,
- TEX_UPPER_TATTOO,
- TEX_LOWER_TATTOO,
- TEX_NUM_INDICES
-};
-
-enum EBakedTextureIndex
-{
- BAKED_HEAD = 0,
- BAKED_UPPER,
- BAKED_LOWER,
- BAKED_EYES,
- BAKED_SKIRT,
- BAKED_HAIR,
- BAKED_NUM_INDICES
-};
-
-// Reference IDs for each mesh. Used as indices for vector of joints
-enum EMeshIndex
-{
- MESH_ID_HAIR = 0,
- MESH_ID_HEAD,
- MESH_ID_EYELASH,
- MESH_ID_UPPER_BODY,
- MESH_ID_LOWER_BODY,
- MESH_ID_EYEBALL_LEFT,
- MESH_ID_EYEBALL_RIGHT,
- MESH_ID_SKIRT,
- MESH_ID_NUM_INDICES
-};
-
-//--------------------------------------------------------------------
-// Vector Types
-//--------------------------------------------------------------------
-typedef std::vector<ETextureIndex> texture_vec_t;
-typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t;
-typedef std::vector<EMeshIndex> mesh_vec_t;
-typedef std::vector<LLWearableType::EType> wearables_vec_t;
-
-//------------------------------------------------------------------------
-// LLVOAvatarDictionary
-//
-// Holds dictionary static entries for textures, baked textures, meshes, etc.; i.e.
-// information that is common to all avatars.
-//
-// This holds const data - it is initialized once and the contents never change after that.
-//------------------------------------------------------------------------
-class LLVOAvatarDictionary : public LLSingleton<LLVOAvatarDictionary>
-{
- //--------------------------------------------------------------------
- // Constructors and Destructors
- //--------------------------------------------------------------------
-public:
- LLVOAvatarDictionary();
- virtual ~LLVOAvatarDictionary();
-private:
- void createAssociations();
-
- //--------------------------------------------------------------------
- // Local and baked textures
- //--------------------------------------------------------------------
-public:
- struct TextureEntry : public LLDictionaryEntry
- {
- TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml
- bool is_local_texture,
- EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES,
- const std::string& default_image_name = "",
- LLWearableType::EType wearable_type = LLWearableType::WT_INVALID);
- const std::string mDefaultImageName;
- const LLWearableType::EType mWearableType;
- // It's either a local texture xor baked
- BOOL mIsLocalTexture;
- BOOL mIsBakedTexture;
- // If it's a local texture, it may be used by a baked texture
- BOOL mIsUsedByBakedTexture;
- EBakedTextureIndex mBakedTextureIndex;
- };
-
- struct Textures : public LLDictionary<ETextureIndex, TextureEntry>
- {
- Textures();
- } mTextures;
- const TextureEntry* getTexture(ETextureIndex index) const { return mTextures.lookup(index); }
- const Textures& getTextures() const { return mTextures; }
-
- //--------------------------------------------------------------------
- // Meshes
- //--------------------------------------------------------------------
-public:
- struct MeshEntry : public LLDictionaryEntry
- {
- MeshEntry(EBakedTextureIndex baked_index,
- const std::string &name, // names of mesh types as they are used in avatar_lad.xml
- U8 level,
- LLViewerJoint::PickName pick);
- // Levels of Detail for each mesh. Must match levels of detail present in avatar_lad.xml
- // Otherwise meshes will be unable to be found, or levels of detail will be ignored
- const U8 mLOD;
- const EBakedTextureIndex mBakedID;
- const LLViewerJoint::PickName mPickName;
- };
-
- struct Meshes : public LLDictionary<EMeshIndex, MeshEntry>
- {
- Meshes();
- } mMeshes;
- const MeshEntry* getMesh(EMeshIndex index) const { return mMeshes.lookup(index); }
- const Meshes& getMeshes() const { return mMeshes; }
-
- //--------------------------------------------------------------------
- // Baked Textures
- //--------------------------------------------------------------------
-public:
- struct BakedEntry : public LLDictionaryEntry
- {
- BakedEntry(ETextureIndex tex_index,
- const std::string &name, // unused, but necessary for templating.
- const std::string &hash_name,
- U32 num_local_textures, ... ); // # local textures, local texture list, # wearables, wearable list
- // Local Textures
- const ETextureIndex mTextureIndex;
- texture_vec_t mLocalTextures;
- // Wearables
- const LLUUID mWearablesHashID;
- wearables_vec_t mWearables;
- };
-
- struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry>
- {
- BakedTextures();
- } mBakedTextures;
- const BakedEntry* getBakedTexture(EBakedTextureIndex index) const { return mBakedTextures.lookup(index); }
- const BakedTextures& getBakedTextures() const { return mBakedTextures; }
-
- //--------------------------------------------------------------------
- // Convenience Functions
- //--------------------------------------------------------------------
-public:
- // Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED
- static ETextureIndex bakedToLocalTextureIndex(EBakedTextureIndex t);
-
- // find a baked texture index based on its name
- static EBakedTextureIndex findBakedByRegionName(std::string name);
-
- static const LLUUID getDefaultTextureImageID(ETextureIndex index);
-
- // Given a texture entry, determine which wearable type owns it.
- static LLWearableType::EType getTEWearableType(ETextureIndex index);
-
-}; // End LLVOAvatarDictionary
-
-} // End namespace LLVOAvatarDefines
-
-#endif //LL_VO_AVATARDEFINES_H
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 3604a373ad..0fcf43a501 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -55,6 +55,8 @@
#include "llviewerobjectlist.h"
#include "llviewerstats.h"
#include "llviewerregion.h"
+#include "llviewertexlayer.h"
+#include "llviewerwearable.h"
#include "llappearancemgr.h"
#include "llmeshrepository.h"
#include "llvovolume.h"
@@ -595,7 +597,7 @@ BOOL LLVOAvatarSelf::loadLayersets()
{
// Construct a layerset for each one specified in avatar_lad.xml and initialize it as such.
const LLTexLayerSetInfo *info = *iter;
- LLTexLayerSet* layer_set = new LLTexLayerSet( this );
+ LLViewerTexLayerSet* layer_set = new LLViewerTexLayerSet( this );
if (!layer_set->setInfo(info))
{
@@ -734,7 +736,7 @@ BOOL LLVOAvatarSelf::setParamWeight(LLViewerVisualParam *param, F32 weight, BOOL
U32 size = gAgentWearables.getWearableCount(type);
for (U32 count = 0; count < size; ++count)
{
- LLWearable *wearable = gAgentWearables.getWearable(type,count);
+ LLViewerWearable *wearable = gAgentWearables.getWearable(type,count);
if (wearable)
{
wearable->setVisualParamWeight(param->getID(), weight, upload_bake);
@@ -760,7 +762,7 @@ void LLVOAvatarSelf::idleUpdateAppearanceAnimation()
// apply wearable visual params to avatar
for (U32 type = 0; type < LLWearableType::WT_COUNT; type++)
{
- LLWearable *wearable = gAgentWearables.getTopWearable((LLWearableType::EType)type);
+ LLViewerWearable *wearable = gAgentWearables.getTopWearable((LLWearableType::EType)type);
if (wearable)
{
wearable->writeToAvatar();
@@ -1375,7 +1377,7 @@ BOOL LLVOAvatarSelf::getLocalTextureGL(ETextureIndex type, LLViewerTexture** tex
{
return FALSE;
}
- *tex_pp = local_tex_obj->getImage();
+ *tex_pp = dynamic_cast<LLViewerTexture*> (local_tex_obj->getImage());
return TRUE;
}
@@ -1395,7 +1397,7 @@ LLViewerFetchedTexture* LLVOAvatarSelf::getLocalTextureGL(LLVOAvatarDefines::ETe
{
return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR);
}
- return local_tex_obj->getImage();
+ return dynamic_cast<LLViewerFetchedTexture*> (local_tex_obj->getImage());
}
const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) const
@@ -1416,7 +1418,7 @@ const LLUUID& LLVOAvatarSelf::getLocalTextureID(ETextureIndex type, U32 index) c
// Returns true if at least the lowest quality discard level exists for every texture
// in the layerset.
//-----------------------------------------------------------------------------
-BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset) const
+BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLViewerTexLayerSet* layerset) const
{
/* if (layerset == mBakedTextureDatas[BAKED_HEAD].mTexLayerSet)
return getLocalDiscardLevel(TEX_HEAD_BODYPAINT) >= 0; */
@@ -1454,7 +1456,7 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset)
// Returns true if the highest quality discard level exists for every texture
// in the layerset.
//-----------------------------------------------------------------------------
-BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) const
+BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLViewerTexLayerSet* layerset) const
{
const U32 desired_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel");
// const U32 desired_tex_discard_level = 0; // hack to not bake textures on lower discard levels.
@@ -1515,7 +1517,7 @@ BOOL LLVOAvatarSelf::isAllLocalTextureDataFinal() const
BOOL LLVOAvatarSelf::isBakedTextureFinal(const LLVOAvatarDefines::EBakedTextureIndex index) const
{
- const LLTexLayerSet *layerset = mBakedTextureDatas[index].mTexLayerSet;
+ const LLViewerTexLayerSet *layerset = mBakedTextureDatas[index].mTexLayerSet;
if (!layerset) return FALSE;
const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite();
if (!layerset_buffer) return FALSE;
@@ -1568,7 +1570,7 @@ BOOL LLVOAvatarSelf::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32
}
//virtual
-BOOL LLVOAvatarSelf::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const
+BOOL LLVOAvatarSelf::isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLViewerWearable *wearable) const
{
if (isIndexBakedTexture(type))
{
@@ -1611,7 +1613,7 @@ bool LLVOAvatarSelf::hasPendingBakedUploads() const
{
for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
{
- LLTexLayerSet* layerset = mBakedTextureDatas[i].mTexLayerSet;
+ LLViewerTexLayerSet* layerset = mBakedTextureDatas[i].mTexLayerSet;
if (layerset && layerset->getComposite() && layerset->getComposite()->uploadPending())
{
return true;
@@ -1620,7 +1622,7 @@ bool LLVOAvatarSelf::hasPendingBakedUploads() const
return false;
}
-void LLVOAvatarSelf::invalidateComposite( LLTexLayerSet* layerset, BOOL upload_result )
+void LLVOAvatarSelf::invalidateComposite( LLViewerTexLayerSet* layerset, BOOL upload_result )
{
if( !layerset || !layerset->getUpdatesEnabled() )
{
@@ -1712,11 +1714,12 @@ S32 LLVOAvatarSelf::getLocalDiscardLevel(ETextureIndex type, U32 wearable_index)
const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type, wearable_index);
if (local_tex_obj)
{
+ const LLViewerFetchedTexture* image = dynamic_cast<LLViewerFetchedTexture*>( local_tex_obj->getImage() );
if (type >= 0
&& local_tex_obj->getID() != IMG_DEFAULT_AVATAR
- && !local_tex_obj->getImage()->isMissingAsset())
+ && !image->isMissingAsset())
{
- return local_tex_obj->getImage()->getDiscardLevel();
+ return image->getDiscardLevel();
}
else
{
@@ -1741,7 +1744,7 @@ void LLVOAvatarSelf::getLocalTextureByteCount(S32* gl_bytes) const
const LLLocalTextureObject *local_tex_obj = getLocalTextureObject((ETextureIndex) type, num);
if (local_tex_obj)
{
- const LLViewerFetchedTexture* image_gl = local_tex_obj->getImage();
+ const LLViewerFetchedTexture* image_gl = dynamic_cast<LLViewerFetchedTexture*>( local_tex_obj->getImage() );
if (image_gl)
{
S32 bytes = (S32)image_gl->getWidth() * image_gl->getHeight() * image_gl->getComponents();
@@ -1790,7 +1793,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
return;
}
- LLTexLayerSet *layer_set = getLayerSet(type);
+ LLViewerTexLayerSet *layer_set = getLayerSet(type);
if (layer_set)
{
layer_set->cloneTemplates(local_tex_obj, type, gAgentWearables.getWearable(wearable_type,index));
@@ -1814,15 +1817,15 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
if (isSelf())
{
if (gAgentAvatarp->isUsingBakedTextures())
- {
- requestLayerSetUpdate(type);
- }
+ {
+ requestLayerSetUpdate(type);
+ }
else
- {
- LLVisualParamHint::requestHintUpdates();
+ {
+ LLVisualParamHint::requestHintUpdates();
+ }
}
}
- }
else
{
tex->setLoadedCallback(onLocalTextureLoaded, desired_discard, TRUE, FALSE, new LLAvatarTexData(getID(), type), NULL);
@@ -1887,7 +1890,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const
}
else
{
- const LLViewerFetchedTexture* image = local_tex_obj->getImage();
+ const LLViewerFetchedTexture* image = dynamic_cast<LLViewerFetchedTexture*>( local_tex_obj->getImage() );
llinfos << "LocTex " << name << ": "
<< "Discard " << image->getDiscardLevel() << ", "
@@ -2060,7 +2063,7 @@ void LLVOAvatarSelf::debugBakedTextureUpload(EBakedTextureIndex index, BOOL fini
mDebugBakedTextureTimes[index][done] = mDebugSelfLoadTimer.getElapsedTimeF32();
}
-const std::string LLVOAvatarSelf::debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const
+const std::string LLVOAvatarSelf::debugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const
{
std::string text="";
@@ -2283,7 +2286,7 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
for (U32 wearable_index = 0; wearable_index < count; ++wearable_index)
{
- LLWearable *wearable = gAgentWearables.getWearable(wearable_type, wearable_index);
+ LLViewerWearable *wearable = gAgentWearables.getWearable(wearable_type, wearable_index);
if (wearable)
{
const LLLocalTextureObject *texture = wearable->getLocalTextureObject((S32)t_index);
@@ -2358,7 +2361,7 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe
LLLocalTextureObject* LLVOAvatarSelf::getLocalTextureObject(LLVOAvatarDefines::ETextureIndex i, U32 wearable_index) const
{
LLWearableType::EType type = LLVOAvatarDictionary::getInstance()->getTEWearableType(i);
- LLWearable* wearable = gAgentWearables.getWearable(type, wearable_index);
+ LLViewerWearable* wearable = gAgentWearables.getWearable(type, wearable_index);
if (wearable)
{
return wearable->getLocalTextureObject(i);
@@ -2371,7 +2374,7 @@ LLLocalTextureObject* LLVOAvatarSelf::getLocalTextureObject(LLVOAvatarDefines::E
// getBakedTE()
// Used by the LayerSet. (Layer sets don't in general know what textures depend on them.)
//-----------------------------------------------------------------------------
-ETextureIndex LLVOAvatarSelf::getBakedTE( const LLTexLayerSet* layerset ) const
+ETextureIndex LLVOAvatarSelf::getBakedTE( const LLViewerTexLayerSet* layerset ) const
{
for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
{
@@ -2512,7 +2515,7 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
++baked_iter)
{
const LLVOAvatarDefines::EBakedTextureIndex baked_index = baked_iter->first;
- const LLTexLayerSet *layerset = debugGetLayerSet(baked_index);
+ const LLViewerTexLayerSet *layerset = debugGetLayerSet(baked_index);
if (!layerset) continue;
const LLTexLayerSetBuffer *layerset_buffer = layerset->getComposite();
if (!layerset_buffer) continue;
@@ -2590,7 +2593,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
{
if (texture_id == gAgentAvatarp->getTEImage(index)->getID())
{
- LLTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index);
+ LLViewerTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index);
if (layer_set)
{
llinfos << "TAT: rebake - matched entry " << (S32)index << llendl;
@@ -2622,7 +2625,7 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
{
ETextureIndex baked_index = mBakedTextureDatas[i].mTextureIndex;
- LLTexLayerSet* layer_set = getLayerSet(baked_index);
+ LLViewerTexLayerSet* layer_set = getLayerSet(baked_index);
if (layer_set)
{
if (slam_for_debug)
@@ -2664,7 +2667,7 @@ void LLVOAvatarSelf::requestLayerSetUpdate(ETextureIndex index )
}
}
-LLTexLayerSet* LLVOAvatarSelf::getLayerSet(ETextureIndex index) const
+LLViewerTexLayerSet* LLVOAvatarSelf::getLayerSet(ETextureIndex index) const
{
/* switch(index)
case TEX_HEAD_BAKED:
@@ -2679,7 +2682,7 @@ LLTexLayerSet* LLVOAvatarSelf::getLayerSet(ETextureIndex index) const
return NULL;
}
-LLTexLayerSet* LLVOAvatarSelf::getLayerSet(EBakedTextureIndex baked_index) const
+LLViewerTexLayerSet* LLVOAvatarSelf::getLayerSet(EBakedTextureIndex baked_index) const
{
/* switch(index)
case TEX_HEAD_BAKED:
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 92d59dc9e1..26662e8a25 100755
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -197,13 +197,13 @@ public:
/*virtual*/ bool hasPendingBakedUploads() const;
S32 getLocalDiscardLevel(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
bool areTexturesCurrent() const;
- BOOL isLocalTextureDataAvailable(const LLTexLayerSet* layerset) const;
- BOOL isLocalTextureDataFinal(const LLTexLayerSet* layerset) const;
+ BOOL isLocalTextureDataAvailable(const LLViewerTexLayerSet* layerset) const;
+ BOOL isLocalTextureDataFinal(const LLViewerTexLayerSet* layerset) const;
BOOL isBakedTextureFinal(const LLVOAvatarDefines::EBakedTextureIndex index) const;
// If you want to check all textures of a given type, pass gAgentWearables.getWearableCount() for index
/*virtual*/ BOOL isTextureDefined(LLVOAvatarDefines::ETextureIndex type, U32 index) const;
/*virtual*/ BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, U32 index = 0) const;
- /*virtual*/ BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLWearable *wearable) const;
+ /*virtual*/ BOOL isTextureVisible(LLVOAvatarDefines::ETextureIndex type, LLViewerWearable *wearable) const;
//--------------------------------------------------------------------
@@ -233,7 +233,7 @@ private:
// Baked textures
//--------------------------------------------------------------------
public:
- LLVOAvatarDefines::ETextureIndex getBakedTE(const LLTexLayerSet* layerset ) const;
+ LLVOAvatarDefines::ETextureIndex getBakedTE(const LLViewerTexLayerSet* layerset ) const;
void setNewBakedTexture(LLVOAvatarDefines::EBakedTextureIndex i, const LLUUID &uuid);
void setNewBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
void setCachedBakedTexture(LLVOAvatarDefines::ETextureIndex i, const LLUUID& uuid);
@@ -249,14 +249,14 @@ public:
void requestLayerSetUploads();
void requestLayerSetUpload(LLVOAvatarDefines::EBakedTextureIndex i);
void requestLayerSetUpdate(LLVOAvatarDefines::ETextureIndex i);
- LLTexLayerSet* getLayerSet(LLVOAvatarDefines::ETextureIndex index) const;
- LLTexLayerSet* getLayerSet(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
+ LLViewerTexLayerSet* getLayerSet(LLVOAvatarDefines::ETextureIndex index) const;
+ LLViewerTexLayerSet* getLayerSet(LLVOAvatarDefines::EBakedTextureIndex baked_index) const;
//--------------------------------------------------------------------
// Composites
//--------------------------------------------------------------------
public:
- /* virtual */ void invalidateComposite(LLTexLayerSet* layerset, BOOL upload_result);
+ /* virtual */ void invalidateComposite(LLViewerTexLayerSet* layerset, BOOL upload_result);
/* virtual */ void invalidateAll();
/* virtual */ void setCompositeUpdatesEnabled(bool b); // only works for self
/* virtual */ void setCompositeUpdatesEnabled(U32 index, bool b);
@@ -388,8 +388,8 @@ public:
BOOL isAllLocalTextureDataFinal() const;
- const LLTexLayerSet* debugGetLayerSet(LLVOAvatarDefines::EBakedTextureIndex index) const { return mBakedTextureDatas[index].mTexLayerSet; }
- const std::string debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
+ const LLViewerTexLayerSet* debugGetLayerSet(LLVOAvatarDefines::EBakedTextureIndex index) const { return mBakedTextureDatas[index].mTexLayerSet; }
+ const std::string debugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
const std::string debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
LLSD metricsData();
void sendAppearanceChangeMetrics(); // send data associated with completing a change.
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 6f6411ce3c..9f04fbecf0 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -42,7 +42,7 @@ struct LLWearableArrivedData
{
LLWearableArrivedData(LLAssetType::EType asset_type,
const std::string& wearable_name,
- void(*asset_arrived_callback)(LLWearable*, void* userdata),
+ void(*asset_arrived_callback)(LLViewerWearable*, void* userdata),
void* userdata) :
mAssetType( asset_type ),
mCallback( asset_arrived_callback ),
@@ -52,7 +52,7 @@ struct LLWearableArrivedData
{}
LLAssetType::EType mAssetType;
- void (*mCallback)(LLWearable*, void* userdata);
+ void (*mCallback)(LLViewerWearable*, void* userdata);
void* mUserdata;
std::string mName;
S32 mRetries;
@@ -72,10 +72,10 @@ void LLWearableList::cleanup()
mList.clear();
}
-void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata)
+void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata)
{
llassert( (asset_type == LLAssetType::AT_CLOTHING) || (asset_type == LLAssetType::AT_BODYPART) );
- LLWearable* instance = get_if_there(mList, assetID, (LLWearable*)NULL );
+ LLViewerWearable* instance = get_if_there(mList, assetID, (LLViewerWearable*)NULL );
if( instance )
{
asset_arrived_callback( instance, userdata );
@@ -95,7 +95,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
{
BOOL isNewWearable = FALSE;
LLWearableArrivedData* data = (LLWearableArrivedData*) userdata;
- LLWearable* wearable = NULL; // NULL indicates failure
+ LLViewerWearable* wearable = NULL; // NULL indicates failure
if( !filename )
{
@@ -111,7 +111,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
}
else
{
- wearable = new LLWearable(uuid);
+ wearable = new LLViewerWearable(uuid);
bool res = wearable->importFile( fp );
if (!res)
{
@@ -203,11 +203,11 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
}
-LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std::string& new_name)
+LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name)
{
lldebugs << "LLWearableList::createCopy()" << llendl;
- LLWearable *wearable = generateNewWearable();
+ LLViewerWearable *wearable = generateNewWearable();
wearable->copyDataFrom(old_wearable);
LLPermissions perm(old_wearable->getPermissions());
@@ -222,11 +222,11 @@ LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std
return wearable;
}
-LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type )
+LLViewerWearable* LLWearableList::createNewWearable( LLWearableType::EType type )
{
lldebugs << "LLWearableList::createNewWearable()" << llendl;
- LLWearable *wearable = generateNewWearable();
+ LLViewerWearable *wearable = generateNewWearable();
wearable->setType( type );
std::string name = LLTrans::getString( LLWearableType::getTypeDefaultNewName(wearable->getType()) );
@@ -251,13 +251,13 @@ LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type )
return wearable;
}
-LLWearable *LLWearableList::generateNewWearable()
+LLViewerWearable *LLWearableList::generateNewWearable()
{
LLTransactionID tid;
tid.generate();
LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
- LLWearable* wearable = new LLWearable(tid);
+ LLViewerWearable* wearable = new LLViewerWearable(tid);
mList[new_asset_id] = wearable;
return wearable;
}
diff --git a/indra/newview/llwearablelist.h b/indra/newview/llwearablelist.h
index 12d0037aee..0f3078facf 100644
--- a/indra/newview/llwearablelist.h
+++ b/indra/newview/llwearablelist.h
@@ -28,7 +28,7 @@
#define LL_LLWEARABLELIST_H
#include "llmemory.h"
-#include "llwearable.h"
+#include "llviewerwearable.h"
#include "lluuid.h"
#include "llassetstorage.h"
@@ -51,19 +51,19 @@ public:
void getAsset(const LLAssetID& assetID,
const std::string& wearable_name,
LLAssetType::EType asset_type,
- void(*asset_arrived_callback)(LLWearable*, void* userdata),
+ void(*asset_arrived_callback)(LLViewerWearable*, void* userdata),
void* userdata);
- LLWearable* createCopy(const LLWearable* old_wearable, const std::string& new_name = std::string());
- LLWearable* createNewWearable(LLWearableType::EType type);
+ LLViewerWearable* createCopy(const LLViewerWearable* old_wearable, const std::string& new_name = std::string());
+ LLViewerWearable* createNewWearable(LLWearableType::EType type);
// Callback
static void processGetAssetReply(const char* filename, const LLAssetID& assetID, void* user_data, S32 status, LLExtStat ext_status);
protected:
- LLWearable* generateNewWearable(); // used for the create... functions
+ LLViewerWearable* generateNewWearable(); // used for the create... functions
private:
- std::map<LLUUID, LLWearable*> mList;
+ std::map<LLUUID, LLViewerWearable*> mList;
};
#endif // LL_LLWEARABLELIST_H
diff --git a/indra/newview/llwearabletype.cpp b/indra/newview/llwearabletype.cpp
deleted file mode 100644
index c090ab5c3d..0000000000
--- a/indra/newview/llwearabletype.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * @file llwearabletype.cpp
- * @brief LLWearableType class implementation
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llwearabletype.h"
-#include "llinventoryfunctions.h"
-#include "lltrans.h"
-
-struct WearableEntry : public LLDictionaryEntry
-{
- WearableEntry(const std::string &name,
- const std::string& default_new_name,
- LLAssetType::EType assetType,
- LLInventoryIcon::EIconName iconName,
- BOOL disable_camera_switch = FALSE,
- BOOL allow_multiwear = TRUE) :
- LLDictionaryEntry(name),
- mAssetType(assetType),
- mDefaultNewName(default_new_name),
- mLabel(LLTrans::getString(name)),
- mIconName(iconName),
- mDisableCameraSwitch(disable_camera_switch),
- mAllowMultiwear(allow_multiwear)
- {
-
- }
- const LLAssetType::EType mAssetType;
- const std::string mLabel;
- const std::string mDefaultNewName; //keep mLabel for backward compatibility
- LLInventoryIcon::EIconName mIconName;
- BOOL mDisableCameraSwitch;
- BOOL mAllowMultiwear;
-};
-
-class LLWearableDictionary : public LLSingleton<LLWearableDictionary>,
- public LLDictionary<LLWearableType::EType, WearableEntry>
-{
-public:
- LLWearableDictionary();
-};
-
-LLWearableDictionary::LLWearableDictionary()
-{
- addEntry(LLWearableType::WT_SHAPE, new WearableEntry("shape", "New Shape", LLAssetType::AT_BODYPART, LLInventoryIcon::ICONNAME_BODYPART_SHAPE, FALSE, FALSE));
- addEntry(LLWearableType::WT_SKIN, new WearableEntry("skin", "New Skin", LLAssetType::AT_BODYPART, LLInventoryIcon::ICONNAME_BODYPART_SKIN, FALSE, FALSE));
- addEntry(LLWearableType::WT_HAIR, new WearableEntry("hair", "New Hair", LLAssetType::AT_BODYPART, LLInventoryIcon::ICONNAME_BODYPART_HAIR, FALSE, FALSE));
- addEntry(LLWearableType::WT_EYES, new WearableEntry("eyes", "New Eyes", LLAssetType::AT_BODYPART, LLInventoryIcon::ICONNAME_BODYPART_EYES, FALSE, FALSE));
- addEntry(LLWearableType::WT_SHIRT, new WearableEntry("shirt", "New Shirt", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_SHIRT, FALSE, TRUE));
- addEntry(LLWearableType::WT_PANTS, new WearableEntry("pants", "New Pants", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_PANTS, FALSE, TRUE));
- addEntry(LLWearableType::WT_SHOES, new WearableEntry("shoes", "New Shoes", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_SHOES, FALSE, TRUE));
- addEntry(LLWearableType::WT_SOCKS, new WearableEntry("socks", "New Socks", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_SOCKS, FALSE, TRUE));
- addEntry(LLWearableType::WT_JACKET, new WearableEntry("jacket", "New Jacket", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_JACKET, FALSE, TRUE));
- addEntry(LLWearableType::WT_GLOVES, new WearableEntry("gloves", "New Gloves", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_GLOVES, FALSE, TRUE));
- addEntry(LLWearableType::WT_UNDERSHIRT, new WearableEntry("undershirt", "New Undershirt", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_UNDERSHIRT, FALSE, TRUE));
- addEntry(LLWearableType::WT_UNDERPANTS, new WearableEntry("underpants", "New Underpants", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_UNDERPANTS, FALSE, TRUE));
- addEntry(LLWearableType::WT_SKIRT, new WearableEntry("skirt", "New Skirt", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_SKIRT, FALSE, TRUE));
- addEntry(LLWearableType::WT_ALPHA, new WearableEntry("alpha", "New Alpha", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_ALPHA, FALSE, TRUE));
- addEntry(LLWearableType::WT_TATTOO, new WearableEntry("tattoo", "New Tattoo", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_TATTOO, FALSE, TRUE));
-
- addEntry(LLWearableType::WT_PHYSICS, new WearableEntry("physics", "New Physics", LLAssetType::AT_CLOTHING, LLInventoryIcon::ICONNAME_CLOTHING_PHYSICS, TRUE, TRUE));
-
- addEntry(LLWearableType::WT_INVALID, new WearableEntry("invalid", "Invalid Wearable", LLAssetType::AT_NONE, LLInventoryIcon::ICONNAME_NONE, FALSE, FALSE));
- addEntry(LLWearableType::WT_NONE, new WearableEntry("none", "Invalid Wearable", LLAssetType::AT_NONE, LLInventoryIcon::ICONNAME_NONE, FALSE, FALSE));
-}
-
-// static
-LLWearableType::EType LLWearableType::typeNameToType(const std::string& type_name)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const LLWearableType::EType wearable = dict->lookup(type_name);
- return wearable;
-}
-
-// static
-const std::string& LLWearableType::getTypeName(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return getTypeName(WT_INVALID);
- return entry->mName;
-}
-
-//static
-const std::string& LLWearableType::getTypeDefaultNewName(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return getTypeDefaultNewName(WT_INVALID);
- return entry->mDefaultNewName;
-}
-
-// static
-const std::string& LLWearableType::getTypeLabel(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return getTypeLabel(WT_INVALID);
- return entry->mLabel;
-}
-
-// static
-LLAssetType::EType LLWearableType::getAssetType(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return getAssetType(WT_INVALID);
- return entry->mAssetType;
-}
-
-// static
-LLInventoryIcon::EIconName LLWearableType::getIconName(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return getIconName(WT_INVALID);
- return entry->mIconName;
-}
-
-// static
-BOOL LLWearableType::getDisableCameraSwitch(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return FALSE;
- return entry->mDisableCameraSwitch;
-}
-
-// static
-BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
-{
- const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
- const WearableEntry *entry = dict->lookup(type);
- if (!entry) return FALSE;
- return entry->mAllowMultiwear;
-}
-
diff --git a/indra/newview/llwearabletype.h b/indra/newview/llwearabletype.h
deleted file mode 100644
index d633b4807e..0000000000
--- a/indra/newview/llwearabletype.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * @file llwearabletype.h
- * @brief LLWearableType class header file
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLWEARABLETYPE_H
-#define LL_LLWEARABLETYPE_H
-
-#include "llassettype.h"
-#include "lldictionary.h"
-#include "llinventoryicon.h"
-#include "llsingleton.h"
-
-class LLWearableType
-{
-public:
- enum EType
- {
- WT_SHAPE = 0,
- WT_SKIN = 1,
- WT_HAIR = 2,
- WT_EYES = 3,
- WT_SHIRT = 4,
- WT_PANTS = 5,
- WT_SHOES = 6,
- WT_SOCKS = 7,
- WT_JACKET = 8,
- WT_GLOVES = 9,
- WT_UNDERSHIRT = 10,
- WT_UNDERPANTS = 11,
- WT_SKIRT = 12,
- WT_ALPHA = 13,
- WT_TATTOO = 14,
- WT_PHYSICS = 15,
- WT_COUNT = 16,
-
- WT_INVALID = 255,
- WT_NONE = -1,
- };
-
- static const std::string& getTypeName(EType type);
- static const std::string& getTypeDefaultNewName(EType type);
- static const std::string& getTypeLabel(EType type);
- static LLAssetType::EType getAssetType(EType type);
- static EType typeNameToType(const std::string& type_name);
- static LLInventoryIcon::EIconName getIconName(EType type);
- static BOOL getDisableCameraSwitch(EType type);
- static BOOL getAllowMultiwear(EType type);
-
-protected:
- LLWearableType() {}
- ~LLWearableType() {}
-};
-
-#endif // LL_LLWEARABLETYPE_H