summaryrefslogtreecommitdiff
path: root/indra/newview/llwearable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llwearable.cpp')
-rw-r--r--indra/newview/llwearable.cpp112
1 files changed, 36 insertions, 76 deletions
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 3334c17a8f..63f99273fe 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -62,13 +62,12 @@ class LLOverrideBakedTextureUpdate
public:
LLOverrideBakedTextureUpdate(bool temp_state)
{
- mAvatar = gAgent.getAvatarObject();
U32 num_bakes = (U32) LLVOAvatarDefines::BAKED_NUM_INDICES;
for( U32 index = 0; index < num_bakes; ++index )
{
- composite_enabled[index] = mAvatar->isCompositeUpdateEnabled(index);
+ composite_enabled[index] = gAgentAvatarp->isCompositeUpdateEnabled(index);
}
- mAvatar->setCompositeUpdatesEnabled(temp_state);
+ gAgentAvatarp->setCompositeUpdatesEnabled(temp_state);
}
~LLOverrideBakedTextureUpdate()
@@ -76,13 +75,11 @@ public:
U32 num_bakes = (U32)LLVOAvatarDefines::BAKED_NUM_INDICES;
for( U32 index = 0; index < num_bakes; ++index )
{
- mAvatar->setCompositeUpdatesEnabled(index, composite_enabled[index]);
- }
+ gAgentAvatarp->setCompositeUpdatesEnabled(index, composite_enabled[index]);
+ }
}
-
private:
bool composite_enabled[LLVOAvatarDefines::BAKED_NUM_INDICES];
- LLVOAvatarSelf *mAvatar;
};
// Private local functions
@@ -205,10 +202,9 @@ BOOL LLWearable::exportFile(LLFILE* file) const
void LLWearable::createVisualParams()
{
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam();
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam())
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
{
if (param->getWearableType() == mType)
{
@@ -228,7 +224,7 @@ void LLWearable::createVisualParams()
param->resetDrivenParams();
if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false))
{
- if( !param->linkDrivenParams(boost::bind(avatar_function,(LLVOAvatarSelf*)avatar,_1 ), true))
+ if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatarp,_1 ), true))
{
llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl;
continue;
@@ -464,12 +460,7 @@ BOOL LLWearable::importFile( LLFILE* file )
// since this wearable was created.
BOOL LLWearable::isOldVersion() const
{
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- return FALSE;
- }
+ if (!isAgentAvatarValid()) return FALSE;
if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion )
{
@@ -483,9 +474,9 @@ BOOL LLWearable::isOldVersion() const
}
S32 param_count = 0;
- for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam();
+ for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam() )
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
{
if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
{
@@ -531,17 +522,11 @@ BOOL LLWearable::isOldVersion() const
// only if those values are the same as the defaults.
BOOL LLWearable::isDirty() const
{
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- return FALSE;
- }
-
+ if (!isAgentAvatarValid()) return FALSE;
- for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam();
+ for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam() )
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
{
if( (param->getWearableType() == mType)
&& (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE )
@@ -602,14 +587,9 @@ BOOL LLWearable::isDirty() const
void LLWearable::setParamsToDefaults()
{
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- return;
- }
+ if (!isAgentAvatarValid()) return;
- for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
+ for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
{
if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
{
@@ -645,18 +625,12 @@ void LLWearable::setTexturesToDefaults()
// Updates the user's avatar's appearance
void LLWearable::writeToAvatar()
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- llerrs << "could not get avatar object to write to for wearable " << this->getName() << llendl;
- return;
- }
+ if (!isAgentAvatarValid()) return;
- ESex old_sex = avatar->getSex();
+ ESex old_sex = gAgentAvatarp->getSex();
// Pull params
- for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
+ 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.
@@ -665,7 +639,7 @@ void LLWearable::writeToAvatar()
S32 param_id = param->getID();
F32 weight = getVisualParamWeight(param_id);
- avatar->setVisualParamWeight( param_id, weight, FALSE );
+ gAgentAvatarp->setVisualParamWeight( param_id, weight, FALSE );
}
}
@@ -686,14 +660,14 @@ void LLWearable::writeToAvatar()
}
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE );
// MULTI-WEARABLE: replace hard-coded 0
- avatar->setLocalTextureTE(te, image, 0);
+ gAgentAvatarp->setLocalTextureTE(te, image, 0);
}
}
- ESex new_sex = avatar->getSex();
+ ESex new_sex = gAgentAvatarp->getSex();
if( old_sex != new_sex )
{
- avatar->updateSexDependentLayerSets( FALSE );
+ gAgentAvatarp->updateSexDependentLayerSets( FALSE );
}
// if( upload_bake )
@@ -707,12 +681,7 @@ void LLWearable::writeToAvatar()
// static
void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- return;
- }
+ if (!isAgentAvatarValid()) return;
// You can't just remove body parts.
if( (type == WT_SHAPE) ||
@@ -724,12 +693,12 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
}
// Pull params
- for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
+ for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
{
if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
{
S32 param_id = param->getID();
- avatar->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
+ gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
}
}
@@ -738,8 +707,8 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE);
}
- avatar->updateVisualParams();
- avatar->wearableUpdated(type, TRUE);
+ gAgentAvatarp->updateVisualParams();
+ gAgentAvatarp->wearableUpdated(type, TRUE);
// if( upload_bake )
// {
@@ -751,12 +720,7 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
// Definition version is current: removes obsolete enties and creates default values for new ones.
void LLWearable::copyDataFrom(const LLWearable* src)
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
- {
- return;
- }
+ if (!isAgentAvatarValid()) return;
mDefinitionVersion = LLWearable::sCurrentDefinitionVersion;
@@ -769,9 +733,9 @@ void LLWearable::copyDataFrom(const LLWearable* src)
mSavedVisualParamMap.clear();
// Deep copy of mVisualParamMap (copies only those params that are current, filling in defaults where needed)
- for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam();
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam() )
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
{
if( (param->getWearableType() == mType) )
{
@@ -783,7 +747,7 @@ void LLWearable::copyDataFrom(const LLWearable* src)
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++ )
+ for (S32 te = 0; te < TEX_NUM_INDICES; te++)
{
if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
{
@@ -876,14 +840,12 @@ void LLWearable::addVisualParam(LLVisualParam *param)
void LLWearable::setVisualParams()
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
-
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();
- avatar->setVisualParamWeight(id, value, FALSE);
+ gAgentAvatarp->setVisualParamWeight(id, value, FALSE);
}
}
@@ -1024,9 +986,8 @@ BOOL LLWearable::isOnTop() const
void LLWearable::createLayers(S32 te)
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- LLTexLayerSet *layer_set = avatar->getLayerSet((ETextureIndex)te);
- if( layer_set )
+ LLTexLayerSet *layer_set = gAgentAvatarp->getLayerSet((ETextureIndex)te);
+ if (layer_set)
{
layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
}
@@ -1123,10 +1084,9 @@ void LLWearable::destroyTextures()
void LLWearable::pullCrossWearableValues()
{
// scan through all of the avatar's visual parameters
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam();
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam())
+ param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
{
if( param )
{