summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatarself.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2009-10-21 23:08:48 +0000
committerLoren Shih <seraph@lindenlab.com>2009-10-21 23:08:48 +0000
commit67c4555a3793850ca8a8142b1e3e72c90d5001f4 (patch)
tree4ba917e75afd155c7090ba9b5ed876bb8f9556cc /indra/newview/llvoavatarself.cpp
parent5cb23717816ca7420c6eb5471dbbd386438929cb (diff)
svn merge -r136533:136919 svn+ssh://svn.lindenlab.com/svn/linden/branches/avatar-pipeline/avatar-pipeline-14 into svn+ssh://svn.lindenlab.com/svn/linden/branches/viewer/viewer-2.0.0-3
* Bugs: EXT-1779
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r--indra/newview/llvoavatarself.cpp191
1 files changed, 126 insertions, 65 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index cf7a0b65f6..77ead951cc 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -285,10 +285,10 @@ BOOL LLVOAvatarSelf::buildMenus()
{
BOOL attachment_found = FALSE;
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if (attachment->getGroup() == i)
{
LLMenuItemCallGL::Params item_params;
@@ -304,9 +304,9 @@ BOOL LLVOAvatarSelf::buildMenus()
}
item_params.name =(item_params.label );
item_params.on_click.function_name = "Object.AttachToAvatar";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Object.EnableWear";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
LLMenuItemCallGL* item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);
gAttachPieMenu->addChild(item);
@@ -331,10 +331,10 @@ BOOL LLVOAvatarSelf::buildMenus()
{
BOOL attachment_found = FALSE;
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if (attachment->getGroup() == i)
{
LLMenuItemCallGL::Params item_params;
@@ -349,9 +349,9 @@ BOOL LLVOAvatarSelf::buildMenus()
}
item_params.name =(item_params.label );
item_params.on_click.function_name = "Attachment.Detach";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Attachment.EnableDetach";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
LLMenuItemCallGL* item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);
gDetachPieMenu->addChild(item);
@@ -370,10 +370,10 @@ BOOL LLVOAvatarSelf::buildMenus()
// add screen attachments
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if (attachment->getGroup() == 8)
{
LLMenuItemCallGL::Params item_params;
@@ -388,16 +388,16 @@ BOOL LLVOAvatarSelf::buildMenus()
}
item_params.name =(item_params.label );
item_params.on_click.function_name = "Object.AttachToAvatar";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Object.EnableWear";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
LLMenuItemCallGL* item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);
gAttachScreenPieMenu->addChild(item);
item_params.on_click.function_name = "Attachment.DetachFromPoint";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Attachment.PointFilled";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);
gDetachScreenPieMenu->addChild(item);
}
@@ -411,10 +411,10 @@ BOOL LLVOAvatarSelf::buildMenus()
break;
}
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if (attachment->getIsHUDAttachment() != (pass == 1))
{
continue;
@@ -431,12 +431,12 @@ BOOL LLVOAvatarSelf::buildMenus()
}
item_params.name =(item_params.label );
item_params.on_click.function_name = "Object.AttachToAvatar";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Object.EnableWear";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
//* TODO: Skinning:
//LLSD params;
- //params["index"] = curiter->first;
+ //params["index"] = iter->first;
//params["label"] = attachment->getName();
//item->addEventHandler("on_enable", LLMenuItemCallGL::MenuCallback().function_name("Attachment.Label").parameter(params));
@@ -444,9 +444,9 @@ BOOL LLVOAvatarSelf::buildMenus()
gAttachSubMenu->addChild(item);
item_params.on_click.function_name = "Attachment.DetachFromPoint";
- item_params.on_click.parameter = curiter->first;
+ item_params.on_click.parameter = iter->first;
item_params.on_enable.function_name = "Attachment.PointFilled";
- item_params.on_enable.parameter = curiter->first;
+ item_params.on_enable.parameter = iter->first;
//* TODO: Skinning: item->addEventHandler("on_enable", LLMenuItemCallGL::MenuCallback().function_name("Attachment.Label").parameter(params));
item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params);
@@ -472,15 +472,15 @@ BOOL LLVOAvatarSelf::buildMenus()
// gather up all attachment points assigned to this group, and throw into map sorted by pie slice number
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if(attachment->getGroup() == group)
{
// use multimap to provide a partial order off of the pie slice key
S32 pie_index = attachment->getPieSlice();
- attachment_pie_menu_map.insert(std::make_pair(pie_index, curiter->first));
+ attachment_pie_menu_map.insert(std::make_pair(pie_index, iter->first));
}
}
@@ -545,7 +545,7 @@ BOOL LLVOAvatarSelf::loadLayersets()
BOOL success = TRUE;
for (LLVOAvatarXmlInfo::layer_info_list_t::const_iterator iter = sAvatarXmlInfo->mLayerInfoList.begin();
iter != sAvatarXmlInfo->mLayerInfoList.end();
- iter++)
+ ++iter)
{
// Construct a layerset for each one specified in avatar_lad.xml and initialize it as such.
const LLTexLayerSetInfo *info = *iter;
@@ -563,7 +563,7 @@ BOOL LLVOAvatarSelf::loadLayersets()
EBakedTextureIndex baked_index = BAKED_NUM_INDICES;
for (LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDictionary::getInstance()->getBakedTextures().begin();
baked_iter != LLVOAvatarDictionary::getInstance()->getBakedTextures().end();
- baked_iter++)
+ ++baked_iter)
{
const LLVOAvatarDictionary::BakedEntry *baked_dict = baked_iter->second;
if (layer_set->isBodyRegion(baked_dict->mName))
@@ -586,7 +586,7 @@ BOOL LLVOAvatarSelf::loadLayersets()
// scan morph masks and let any affected layers know they have an associated morph
for (LLVOAvatar::morph_list_t::const_iterator morph_iter = mBakedTextureDatas[baked_index].mMaskedMorphs.begin();
morph_iter != mBakedTextureDatas[baked_index].mMaskedMorphs.end();
- morph_iter++)
+ ++morph_iter)
{
LLMaskedMorph *morph = *morph_iter;
LLTexLayerInterface* layer = layer_set->findLayerByName(morph->mLayer);
@@ -903,10 +903,10 @@ void LLVOAvatarSelf::restoreMeshData()
void LLVOAvatarSelf::updateAttachmentVisibility(U32 camera_mode)
{
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
+ LLViewerJointAttachment* attachment = iter->second;
if (attachment->getIsHUDAttachment())
{
attachment->setAttachmentVisibility(TRUE);
@@ -947,7 +947,7 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type )
{
for (LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDictionary::getInstance()->getBakedTextures().begin();
baked_iter != LLVOAvatarDictionary::getInstance()->getBakedTextures().end();
- baked_iter++)
+ ++baked_iter)
{
const LLVOAvatarDictionary::BakedEntry *baked_dict = baked_iter->second;
const LLVOAvatarDefines::EBakedTextureIndex index = baked_iter->first;
@@ -955,7 +955,7 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type )
{
for (LLVOAvatarDefines::wearables_vec_t::const_iterator type_iter = baked_dict->mWearables.begin();
type_iter != baked_dict->mWearables.end();
- type_iter++)
+ ++type_iter)
{
const EWearableType comp_type = *type_iter;
if (comp_type == type)
@@ -976,14 +976,16 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type )
// isWearingAttachment()
//-----------------------------------------------------------------------------
// Warning: include_linked_items = TRUE makes this operation expensive.
-BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL include_linked_items ) const
+BOOL LLVOAvatarSelf::isWearingAttachment(const LLUUID& inv_item_id, BOOL include_linked_items) const
{
+ const LLUUID& base_inv_item_id = getBaseAttachmentObject(inv_item_id);
+
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::const_iterator curiter = iter++;
- const LLViewerJointAttachment* attachment = curiter->second;
- if (attachment->getAttachedObject(inv_item_id))
+ const LLViewerJointAttachment* attachment = iter->second;
+ if (attachment->getAttachedObject(base_inv_item_id))
{
return TRUE;
}
@@ -992,18 +994,18 @@ BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL inclu
if (include_linked_items)
{
LLInventoryModel::item_array_t item_array;
- gInventory.collectLinkedItems(inv_item_id, item_array);
+ gInventory.collectLinkedItems(base_inv_item_id, item_array);
for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin();
iter != item_array.end();
- iter++)
+ ++iter)
{
const LLViewerInventoryItem *linked_item = (*iter);
const LLUUID &item_id = linked_item->getUUID();
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::const_iterator curiter = iter++;
- const LLViewerJointAttachment* attachment = curiter->second;
+ const LLViewerJointAttachment* attachment = iter->second;
if (attachment->getAttachedObject(item_id))
{
return TRUE;
@@ -1018,14 +1020,15 @@ BOOL LLVOAvatarSelf::isWearingAttachment( const LLUUID& inv_item_id , BOOL inclu
//-----------------------------------------------------------------------------
// getWornAttachment()
//-----------------------------------------------------------------------------
-LLViewerObject* LLVOAvatarSelf::getWornAttachment( const LLUUID& inv_item_id )
+LLViewerObject* LLVOAvatarSelf::getWornAttachment(const LLUUID& inv_item_id)
{
- for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ const LLUUID& base_inv_item_id = getBaseAttachmentObject(inv_item_id);
+ for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::iterator curiter = iter++;
- LLViewerJointAttachment* attachment = curiter->second;
- if (LLViewerObject *attached_object = attachment->getAttachedObject(inv_item_id))
+ LLViewerJointAttachment* attachment = iter->second;
+ if (LLViewerObject *attached_object = attachment->getAttachedObject(base_inv_item_id))
{
return attached_object;
}
@@ -1035,12 +1038,13 @@ LLViewerObject* LLVOAvatarSelf::getWornAttachment( const LLUUID& inv_item_id )
const std::string LLVOAvatarSelf::getAttachedPointName(const LLUUID& inv_item_id) const
{
+ const LLUUID& base_inv_item_id = getBaseAttachmentObject(inv_item_id);
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end(); )
+ iter != mAttachmentPoints.end();
+ ++iter)
{
- attachment_map_t::const_iterator curiter = iter++;
- const LLViewerJointAttachment* attachment = curiter->second;
- if (attachment->getAttachedObject(inv_item_id))
+ const LLViewerJointAttachment* attachment = iter->second;
+ if (attachment->getAttachedObject(base_inv_item_id))
{
return attachment->getName();
}
@@ -1072,14 +1076,71 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Adding attachment link:");
LLAppearanceManager::wearItem(item,false); // Add COF link for item.
gInventory.addChangedMask(LLInventoryObserver::LABEL, attachment_id);
+ gInventory.updateLinkedObjects(attachment_id);
}
}
-
gInventory.notifyObservers();
return attachment;
}
+//virtual
+BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
+{
+ const LLUUID item_id = viewer_object->getItemID();
+ if (LLVOAvatar::detachObject(viewer_object))
+ {
+ // the simulator should automatically handle permission revocation
+
+ stopMotionFromSource(item_id);
+ LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
+
+ LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
+ for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+ iter != child_list.end();
+ ++iter)
+ {
+ LLViewerObject* child_objectp = *iter;
+ // the simulator should automatically handle
+ // permissions revocation
+
+ stopMotionFromSource(child_objectp->getID());
+ LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
+ }
+
+ // Make sure the inventory is in sync with the avatar.
+
+ // Update COF contents, don't trigger appearance update.
+ if (gAgent.getAvatarObject() == NULL)
+ {
+ llinfos << "removeItemLinks skipped, avatar is under destruction" << llendl;
+ }
+ else
+ {
+ LLAppearanceManager::dumpCat(LLAppearanceManager::getCOF(),"Removing attachment link:");
+ LLAppearanceManager::removeItemLinks(item_id, false);
+ }
+
+ // BAP - needs to change for label to track link.
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
+ gInventory.updateLinkedObjects(item_id);
+ gInventory.notifyObservers();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+const LLUUID& LLVOAvatarSelf::getBaseAttachmentObject(const LLUUID &object_id) const
+{
+ const LLInventoryItem *item = gInventory.getItem(object_id);
+ if (!item)
+ return LLUUID::null;
+
+ // Find the base object in case this a link (if it's not a link,
+ // this will just be inv_item_id)
+ return item->getLinkedUUID();
+}
+
void LLVOAvatarSelf::getAllAttachmentsArray(LLDynamicArray<S32>& attachments)
{
for (LLVOAvatar::attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
@@ -1231,7 +1292,7 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset)
return getLocalDiscardLevel(TEX_HEAD_BODYPAINT) >= 0; */
for (LLVOAvatarDictionary::BakedTextures::const_iterator baked_iter = LLVOAvatarDictionary::getInstance()->getBakedTextures().begin();
baked_iter != LLVOAvatarDictionary::getInstance()->getBakedTextures().end();
- baked_iter++)
+ ++baked_iter)
{
const EBakedTextureIndex baked_index = baked_iter->first;
if (layerset == mBakedTextureDatas[baked_index].mTexLayerSet)
@@ -1240,7 +1301,7 @@ BOOL LLVOAvatarSelf::isLocalTextureDataAvailable(const LLTexLayerSet* layerset)
const LLVOAvatarDictionary::BakedEntry *baked_dict = baked_iter->second;
for (texture_vec_t::const_iterator local_tex_iter = baked_dict->mLocalTextures.begin();
local_tex_iter != baked_dict->mLocalTextures.end();
- local_tex_iter++)
+ ++local_tex_iter)
{
const ETextureIndex tex_index = *local_tex_iter;
const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index);
@@ -1272,7 +1333,7 @@ BOOL LLVOAvatarSelf::isLocalTextureDataFinal(const LLTexLayerSet* layerset) cons
const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)i);
for (texture_vec_t::const_iterator local_tex_iter = baked_dict->mLocalTextures.begin();
local_tex_iter != baked_dict->mLocalTextures.end();
- local_tex_iter++)
+ ++local_tex_iter)
{
const ETextureIndex tex_index = *local_tex_iter;
const EWearableType wearable_type = LLVOAvatarDictionary::getTEWearableType(tex_index);
@@ -1558,7 +1619,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
setBakedReady(type,baked_version_ready,index);
}
//virtual
-void LLVOAvatarSelf::setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index)
+void LLVOAvatarSelf::setBakedReady(LLVOAvatarDefines::ETextureIndex type, BOOL baked_version_exists, U32 index)
{
if (!isIndexLocalTexture(type)) return;
LLLocalTextureObject *local_tex_obj = getLocalTextureObject(type,index);
@@ -1579,7 +1640,7 @@ void LLVOAvatarSelf::dumpLocalTextures() const
if (isTextureDefined(baked_equiv[i])) */
for (LLVOAvatarDictionary::Textures::const_iterator iter = LLVOAvatarDictionary::getInstance()->getTextures().begin();
iter != LLVOAvatarDictionary::getInstance()->getTextures().end();
- iter++)
+ ++iter)
{
const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second;
if (!texture_dict->mIsLocalTexture || !texture_dict->mIsUsedByBakedTexture)
@@ -1769,7 +1830,7 @@ BOOL LLVOAvatarSelf::canGrabLocalTexture(ETextureIndex type, U32 index) const
const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index);
for (texture_vec_t::const_iterator iter = baked_dict->mLocalTextures.begin();
iter != baked_dict->mLocalTextures.end();
- iter++)
+ ++iter)
{
const ETextureIndex t_index = (*iter);
lldebugs << "Checking index " << (U32) t_index << llendl;
@@ -1945,7 +2006,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
TEX_UPPER_BAKED, */
for (LLVOAvatarDictionary::Textures::const_iterator iter = LLVOAvatarDictionary::getInstance()->getTextures().begin();
iter != LLVOAvatarDictionary::getInstance()->getTextures().end();
- iter++)
+ ++iter)
{
const ETextureIndex index = iter->first;
const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second;