diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp
index b1a7ebb159612bdbde8e68b3178c6c8d2f62d383..c430a73f6b2585975e00d184de7c644ece38559c 100644
--- a/indra/llcharacter/llpose.cpp
+++ b/indra/llcharacter/llpose.cpp
@@ -195,7 +195,7 @@ LLJointStateBlender::~LLJointStateBlender()
 //-----------------------------------------------------------------------------
 // addJointState()
 //-----------------------------------------------------------------------------
-BOOL LLJointStateBlender::addJointState(const LLPointer<LLJointState>& joint_state, S32 priority, BOOL additive_blend)
+BOOL LLJointStateBlender::addJointState(const LLPointer<LLJointState>& joint_state, LLUUID source_id, S32 priority, BOOL additive_blend)
 {
 	llassert(joint_state);
 
@@ -210,23 +210,26 @@ BOOL LLJointStateBlender::addJointState(const LLPointer<LLJointState>& joint_sta
 			mJointStates[i] = joint_state;
 			mPriorities[i] = priority;
 			mAdditiveBlends[i] = additive_blend;
+			mMoutionIds[i] = source_id;
 			return TRUE;
 		} 
-		else if (priority > mPriorities[i])
+		else if (priority > mPriorities[i] || (priority == mPriorities[i] && source_id > mMoutionIds[i]))
 		{
 			// we're at a higher priority than the current joint state in this slot
 			// so shift everyone over
-			// previous joint states (newer motions) with same priority should stay in place
+			// previous joint states (newer motions) with same priority and source motion should stay in place
 			for (S32 j = JSB_NUM_JOINT_STATES - 1; j > i; j--)
 			{
 				mJointStates[j] = mJointStates[j - 1];
 				mPriorities[j] = mPriorities[j - 1];
 				mAdditiveBlends[j] = mAdditiveBlends[j - 1];
+				mMoutionIds[j] = mMoutionIds[j - 1];
 			}
 			// now store ourselves in this slot
 			mJointStates[i] = joint_state;
 			mPriorities[i] = priority;
 			mAdditiveBlends[i] = additive_blend;
+			mMoutionIds[i] = source_id;
 			return TRUE;
 		}
 	}
@@ -489,11 +492,11 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion)
 
 		if (jsp->getPriority() == LLJoint::USE_MOTION_PRIORITY)
 		{
-			joint_blender->addJointState(jsp, motion->getPriority(), motion->getBlendType() == LLMotion::ADDITIVE_BLEND);
+			joint_blender->addJointState(jsp, motion->getID(), motion->getPriority(), motion->getBlendType() == LLMotion::ADDITIVE_BLEND);
 		}
 		else
 		{
-			joint_blender->addJointState(jsp, jsp->getPriority(), motion->getBlendType() == LLMotion::ADDITIVE_BLEND);
+			joint_blender->addJointState(jsp, motion->getID(), jsp->getPriority(), motion->getBlendType() == LLMotion::ADDITIVE_BLEND);
 		}
 
 		// add it to our list of active blenders
diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h
index c004a0f3b74388b3ceb7999eca33b2dff6a59fb9..28f560ed9f4893bbe9d4c36a5d13939e7cb1f2cb 100644
--- a/indra/llcharacter/llpose.h
+++ b/indra/llcharacter/llpose.h
@@ -85,12 +85,13 @@ class LLJointStateBlender
 protected:
 	LLPointer<LLJointState>	mJointStates[JSB_NUM_JOINT_STATES];
 	S32				mPriorities[JSB_NUM_JOINT_STATES];
+	LLUUID			mMoutionIds[JSB_NUM_JOINT_STATES];
 	BOOL			mAdditiveBlends[JSB_NUM_JOINT_STATES];
 public:
 	LLJointStateBlender();
 	~LLJointStateBlender();
 	void blendJointStates(BOOL apply_now = TRUE);
-	BOOL addJointState(const LLPointer<LLJointState>& joint_state, S32 priority, BOOL additive_blend);
+	BOOL addJointState(const LLPointer<LLJointState>& joint_state, LLUUID source_id, S32 priority, BOOL additive_blend);
 	void interpolate(F32 u);
 	void clear();
 	void resetCachedJoint();