Anonymous avatar Anonymous committed acd1cf8

STORM-1899: Avatar hand poses randomly get stuck in spread position

Comments (0)

Files changed (2)

doc/contributions.txt

 	VWR-26150
 	STORM-1685
 	STORM-1713
+	STORM-1899
 Aralara Rajal
 Ardy Lay
 	STORM-859

indra/llcharacter/llhandmotion.cpp

 	{
 		if (mNewPose != HAND_POSE_RELAXED && mNewPose != mCurrentPose)
 		{
-			mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
+			// Only set param weight for poses other than
+			// default (HAND_POSE_SPREAD); HAND_POSE_SPREAD
+			// is not an animatable morph!
+			if (mNewPose != HAND_POSE_SPREAD)
+			{
+				mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
+			}
+
+			// Reset morph weight for current pose back to its
+			// full extend or it might be stuck somewhere in the middle if a
+			// pose is requested and the old pose is requested again shortly
+			// after while still blending to the other pose!
+			if (mCurrentPose != HAND_POSE_SPREAD)
+			{
+				mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], 1.f);
+			}
+
+			// Update visual params now if we won't blend
+			if (mCurrentPose == HAND_POSE_RELAXED)
+			{
+				mCharacter->updateVisualParams();
+			}
 		}
 		mNewPose = HAND_POSE_RELAXED;
 	}
 	else
 	{
-		// this is a new morph we didn't know about before
-		if (*requestedHandPose != mNewPose && mNewPose != mCurrentPose && mNewPose != HAND_POSE_SPREAD)
+		// Sometimes we seem to get garbage here, with poses that are out of bounds.
+		// So check for a valid pose first.
+		if (*requestedHandPose >= 0 && *requestedHandPose < NUM_HAND_POSES)
 		{
-			mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
+			// This is a new morph we didn't know about before:
+			// Reset morph weight for both current and new pose
+			// back their starting values while still blending.
+			if (*requestedHandPose != mNewPose && mNewPose != mCurrentPose)
+			{
+				if (mNewPose != HAND_POSE_SPREAD)
+				{
+					mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
+				}
+
+				// Reset morph weight for current pose back to its full extend
+				// or it might be stuck somewhere in the middle if a pose is
+				// requested and the old pose is requested again shortly after
+				// while still blending to the other pose!
+				if (mCurrentPose != HAND_POSE_SPREAD)
+				{
+					mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], 1.f);
+				}
+
+				// Update visual params now if we won't blend
+				if (mCurrentPose == *requestedHandPose)
+				{
+					mCharacter->updateVisualParams();
+				}
+			}
+			mNewPose = *requestedHandPose;
 		}
-		mNewPose = *requestedHandPose;
+		else
+		{
+			llwarns << "Requested hand pose out of range. Ignoring requested pose." << llendl;
+		}
 	}
 
 	mCharacter->removeAnimationData("Hand Pose");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.