summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerjointattachment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerjointattachment.cpp')
-rw-r--r--indra/newview/llviewerjointattachment.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 01d07f93ef..ecb7e2064d 100644
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -29,12 +29,11 @@
#include "llviewerjointattachment.h"
#include "llagentconstants.h"
-
#include "llviewercontrol.h"
#include "lldrawable.h"
#include "llgl.h"
#include "llrender.h"
-#include "llvoavatar.h"
+#include "llvoavatarself.h"
#include "llvolume.h"
#include "pipeline.h"
#include "llspatialpartition.h"
@@ -158,6 +157,9 @@ void LLViewerJointAttachment::setupDrawable(LLViewerObject *object)
//-----------------------------------------------------------------------------
BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
{
+ object->extractAttachmentItemID();
+
+ // Same object reattached
if (isObjectAttached(object))
{
llinfos << "(same object re-attached)" << llendl;
@@ -165,20 +167,19 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
// Pass through anyway to let setupDrawable()
// re-connect object to the joint correctly
}
-
- // Find the inventory item ID of the attached object
- LLNameValue* item_id_nv = object->getNVPair("AttachItemID");
- if( item_id_nv )
+
+ // Two instances of the same inventory item attached --
+ // Request detach, and kill the object in the meantime.
+ if (getAttachedObject(object->getAttachmentItemID()))
{
- const char* s = item_id_nv->getString();
- if( s )
- {
- LLUUID item_id;
- item_id.set(s);
- object->setItemID(item_id);
- lldebugs << "getNVPair( AttachItemID ) = " << item_id << llendl;
- }
+ llinfos << "(same object re-attached)" << llendl;
+ object->markDead();
+
+ // If this happens to be attached to self, then detach.
+ LLVOAvatarSelf::detachAttachmentIntoInventory(object->getAttachmentItemID());
+ return FALSE;
}
+
mAttachedObjects.push_back(object);
setupDrawable(object);
@@ -201,7 +202,7 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
}
calcLOD();
mUpdateXform = TRUE;
-
+
return TRUE;
}
@@ -297,7 +298,7 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object)
{
mUpdateXform = FALSE;
}
- object->setItemID(LLUUID::null);
+ object->setAttachmentItemID(LLUUID::null);
}
//-----------------------------------------------------------------------------
@@ -423,7 +424,7 @@ const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &o
++iter)
{
const LLViewerObject* attached_object = (*iter);
- if (attached_object->getItemID() == object_id)
+ if (attached_object->getAttachmentItemID() == object_id)
{
return attached_object;
}
@@ -438,7 +439,7 @@ LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_
++iter)
{
LLViewerObject* attached_object = (*iter);
- if (attached_object->getItemID() == object_id)
+ if (attached_object->getAttachmentItemID() == object_id)
{
return attached_object;
}