SL-790 - Adding UI checks for actions that would increase the animated object attachment count

meow-7.2.2
Brad Payne (Vir Linden) 2017-09-18 19:51:44 +01:00
parent e360423598
commit 3346281be3
6 changed files with 57 additions and 10 deletions

View File

@ -154,6 +154,7 @@ const U8 SIM_ACCESS_MAX = SIM_ACCESS_ADULT;
// attachment constants
const S32 MAX_AGENT_ATTACHMENTS = 38;
const S32 MAX_AGENT_ANIMATED_OBJECT_ATTACHMENTS = 1;
const U8 ATTACHMENT_ADD = 0x80;
// god levels

View File

@ -78,6 +78,8 @@
#include "llviewercontrol.h"
#include "llmeshrepository.h"
#include "llvoavatarself.h"
#include <boost/bind.hpp>
// "Features" Tab
@ -366,6 +368,12 @@ void LLPanelVolume::getState( )
if (root_volobjp && root_volobjp == volobjp)
{
enabled_animated_object_box = single_root_volume && root_volobjp && root_volobjp->canBeAnimatedObject() && editable;
if (enabled_animated_object_box && !is_animated_mesh &&
root_volobjp->isAttachment() && !gAgentAvatarp->canAttachMoreAnimatedObjects())
{
// Turning this attachment animated would cause us to exceed the limit.
enabled_animated_object_box = false;
}
}
getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(enabled_animated_object_box);

View File

@ -356,6 +356,25 @@ void LLViewerJointAttachment::setOriginalPosition(LLVector3& position)
setPosition(position);
}
//-----------------------------------------------------------------------------
// getNumAnimatedObjects()
//-----------------------------------------------------------------------------
S32 LLViewerJointAttachment::getNumAnimatedObjects() const
{
S32 count = 0;
for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
iter != mAttachedObjects.end();
++iter)
{
const LLViewerObject *attached_object = *iter;
if (attached_object->isAnimatedObject())
{
count++;
}
}
return count;
}
//-----------------------------------------------------------------------------
// clampObjectPosition()
//-----------------------------------------------------------------------------

View File

@ -77,6 +77,7 @@ public:
S32 getGroup() const { return mGroup; }
S32 getPieSlice() const { return mPieSlice; }
S32 getNumObjects() const { return mAttachedObjects.size(); }
S32 getNumAnimatedObjects() const;
void clampObjectPosition();

View File

@ -6577,14 +6577,6 @@ U32 LLVOAvatar::getNumAttachments() const
return num_attachments;
}
//-----------------------------------------------------------------------------
// canAttachMoreObjects()
//-----------------------------------------------------------------------------
BOOL LLVOAvatar::canAttachMoreObjects() const
{
return (getNumAttachments() < MAX_AGENT_ATTACHMENTS);
}
//-----------------------------------------------------------------------------
// canAttachMoreObjects()
// Returns true if we can attach <n> more objects.
@ -6594,6 +6586,31 @@ BOOL LLVOAvatar::canAttachMoreObjects(U32 n) const
return (getNumAttachments() + n) <= MAX_AGENT_ATTACHMENTS;
}
//-----------------------------------------------------------------------------
// getNumAnimatedObjectAttachments()
//-----------------------------------------------------------------------------
U32 LLVOAvatar::getNumAnimatedObjectAttachments() const
{
U32 num_attachments = 0;
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
iter != mAttachmentPoints.end();
++iter)
{
const LLViewerJointAttachment *attachment_pt = (*iter).second;
num_attachments += attachment_pt->getNumAnimatedObjects();
}
return num_attachments;
}
//-----------------------------------------------------------------------------
// canAttachMoreAnimatedObjects()
// Returns true if we can attach <n> more animated objects.
//-----------------------------------------------------------------------------
BOOL LLVOAvatar::canAttachMoreAnimatedObjects(U32 n) const
{
return (getNumAnimatedObjectAttachments() + n) <= MAX_AGENT_ANIMATED_OBJECT_ATTACHMENTS;
}
//-----------------------------------------------------------------------------
// lazyAttach()
//-----------------------------------------------------------------------------

View File

@ -777,10 +777,11 @@ public:
BOOL hasHUDAttachment() const;
LLBBox getHUDBBox() const;
void resetHUDAttachments();
BOOL canAttachMoreObjects() const;
BOOL canAttachMoreObjects(U32 n) const;
BOOL canAttachMoreObjects(U32 n=1) const;
BOOL canAttachMoreAnimatedObjects(U32 n=1) const;
protected:
U32 getNumAttachments() const; // O(N), not O(1)
U32 getNumAnimatedObjectAttachments() const; // O(N), not O(1)
/** Wearables
** **