diff options
| author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2014-11-14 09:25:43 -0500 | 
|---|---|---|
| committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2014-11-14 09:25:43 -0500 | 
| commit | 30c1d67d957ec7f895dd690ec34b5459fc9082de (patch) | |
| tree | 04e19456f28d8fd5f893ceec1e4f935195c68cf9 | |
| parent | c977268ff53ea362bc3b089945c9aa9a438cb63f (diff) | |
MAINT-4537 WIP - order of operations during outfit change
| -rwxr-xr-x | indra/newview/llagentwearables.cpp | 22 | ||||
| -rwxr-xr-x | indra/newview/llagentwearables.h | 3 | ||||
| -rwxr-xr-x | indra/newview/llappearancemgr.cpp | 18 | ||||
| -rwxr-xr-x | indra/newview/llvoavatar.cpp | 28 | ||||
| -rwxr-xr-x | indra/newview/llvoavatar.h | 1 | ||||
| -rwxr-xr-x | indra/newview/llvoavatarself.cpp | 2 | ||||
| -rwxr-xr-x | indra/newview/llvoavatarself.h | 2 | 
7 files changed, 66 insertions, 10 deletions
| diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 3928bbadc8..a7acdb0520 100755 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -1248,9 +1248,11 @@ void LLAgentWearables::userRemoveWearablesOfType(const LLWearableType::EType &ty  	}  } -// Combines userRemoveMulipleAttachments() and userAttachMultipleAttachments() logic to -// get attachments into desired state with minimal number of adds/removes. -void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj_item_array) +// Given a desired set of attachments, find what objects need to be +// removed, and what additional inventory items need to be added. +void LLAgentWearables::findAttachmentsAddRemoveInfo(LLInventoryModel::item_array_t& obj_item_array, +													llvo_vec_t& objects_to_remove, +													LLInventoryModel::item_array_t& items_to_add)  {  	// Possible cases:  	// already wearing but not in request set -> take off. @@ -1269,7 +1271,6 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj  	}  	// Build up list of objects to be removed and items currently attached. -	llvo_vec_t objects_to_remove;  	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();   		 iter != gAgentAvatarp->mAttachmentPoints.end();)  	{ @@ -1309,7 +1310,6 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj  		}  	} -	LLInventoryModel::item_array_t items_to_add;  	for (LLInventoryModel::item_array_t::iterator it = obj_item_array.begin();  		 it != obj_item_array.end();  		 ++it) @@ -1328,6 +1328,17 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj  	// S32 remove_count = objects_to_remove.size();  	// S32 add_count = items_to_add.size();  	// LL_INFOS() << "remove " << remove_count << " add " << add_count << LL_ENDL; +} + +// Combines userRemoveMulipleAttachments() and userAttachMultipleAttachments() logic to +// get attachments into desired state with minimal number of adds/removes. +void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj_item_array) +{ +	llvo_vec_t objects_to_remove; +	LLInventoryModel::item_array_t items_to_add; +	findAttachmentsAddRemoveInfo(obj_item_array, +								 objects_to_remove, +								 items_to_add);  	// Remove everything in objects_to_remove  	userRemoveMultipleAttachments(objects_to_remove); @@ -1353,6 +1364,7 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo  		 ++it)  	{  		LLViewerObject *objectp = *it; +		gAgentAvatarp->resetJointPositionsOnDetach(objectp);  		gMessageSystem->nextBlockFast(_PREHASH_ObjectData);  		gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, objectp->getLocalID());  	} diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h index cdb1bdbe05..10e3dbf8c6 100755 --- a/indra/newview/llagentwearables.h +++ b/indra/newview/llagentwearables.h @@ -178,6 +178,9 @@ public:  	typedef std::vector<LLViewerObject*> llvo_vec_t; +	static void     findAttachmentsAddRemoveInfo(LLInventoryModel::item_array_t& obj_item_array, +												 llvo_vec_t& objects_to_remove, +												 LLInventoryModel::item_array_t& items_to_add);  	static void 	userUpdateAttachments(LLInventoryModel::item_array_t& obj_item_array);  	static void		userRemoveMultipleAttachments(llvo_vec_t& llvo_array);  	static void		userAttachMultipleAttachments(LLInventoryModel::item_array_t& obj_item_array); diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index fba2b9d3a4..69efb20f79 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -807,6 +807,20 @@ void LLWearableHoldingPattern::onAllComplete()  		}  	} +	LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; +	LLAgentWearables::llvo_vec_t objects_to_remove; +	LLInventoryModel::item_array_t items_to_add; +	if (isAgentAvatarValid()) +	{ +		LLAgentWearables::findAttachmentsAddRemoveInfo(mObjItems, +													   objects_to_remove, +													   items_to_add); + +		LL_DEBUGS("Avatar") << self_av_string() << "Removing " << objects_to_remove.size() +							<< " attachments" << LL_ENDL; +		LLAgentWearables::userRemoveMultipleAttachments(objects_to_remove); +	} +  	// Update wearables.  	LL_INFOS("Avatar") << self_av_string() << "HP " << index() << " updating agent wearables with " << mResolved << " wearable items " << LL_ENDL;  	LLAppearanceMgr::instance().updateAgentWearables(this); @@ -814,8 +828,8 @@ void LLWearableHoldingPattern::onAllComplete()  	// Update attachments to match those requested.  	if (isAgentAvatarValid())  	{ -		LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL; -		LLAgentWearables::userUpdateAttachments(mObjItems); +		LL_DEBUGS("Avatar") << self_av_string() << "Adding " << items_to_add.size() << " attachments" << LL_ENDL; +		LLAgentWearables::userAttachMultipleAttachments(items_to_add);  	}  	if (isFetchCompleted() && isMissingCompleted()) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index dd5941191a..646ca25a0e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -5064,6 +5064,34 @@ bool LLVOAvatar::getRiggedMeshID(LLViewerObject* pVO, LLUUID& mesh_id)  //-----------------------------------------------------------------------------  // resetJointPositionsOnDetach  //----------------------------------------------------------------------------- +void LLVOAvatar::resetJointPositionsOnDetach(LLViewerObject *vo) +{ +	LLVOAvatar *av = vo->getAvatarAncestor(); +	if (!av || (av != this)) +	{ +		LL_WARNS("Avatar") << "called with invalid avatar" << LL_ENDL; +	} +		 +	// Process all children +	LLViewerObject::const_child_list_t& children = vo->getChildren(); +	for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); +		 it != children.end(); ++it) +	{ +		LLViewerObject *childp = *it; +		resetJointPositionsOnDetach(childp); +	} + +	// Process self. +	LLUUID mesh_id; +	if (getRiggedMeshID(vo,mesh_id)) +	{ +		resetJointPositionsOnDetach(mesh_id); +	} +} + +//----------------------------------------------------------------------------- +// resetJointPositionsOnDetach +//-----------------------------------------------------------------------------  void LLVOAvatar::resetJointPositionsOnDetach(const LLUUID& mesh_id)  {	  	//Subsequent joints are relative to pelvis diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index d7cf4a2c0c..ce1f0dd152 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -200,6 +200,7 @@ public:  	virtual LLJoint*		getJoint(const std::string &name);  	void					resetJointPositionsOnDetach(const LLUUID& mesh_id); +	void					resetJointPositionsOnDetach(LLViewerObject *vo);  	/*virtual*/ const LLUUID&	getID() const;  	/*virtual*/ void			addDebugText(const std::string& text); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 77fda25537..4335df66a1 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -262,7 +262,7 @@ void LLVOAvatarSelf::markDead()  {  	BOOL success = LLVOAvatar::loadAvatar(); -	// set all parameters sotred directly in the avatar to have +	// set all parameters stored directly in the avatar to have  	// the isSelfParam to be TRUE - this is used to prevent  	// them from being animated or trigger accidental rebakes  	// when we copy params from the wearable to the base avatar. diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 369c15d0f9..a9c01933b7 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -86,8 +86,6 @@ public:  	/*virtual*/ void 		requestStopMotion(LLMotion* motion);  	/*virtual*/ LLJoint*	getJoint(const std::string &name); -				void		resetJointPositions( void ); -	  	/*virtual*/ BOOL setVisualParamWeight(const LLVisualParam *which_param, F32 weight);  	/*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight);  	/*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight); | 
