All submissions to this site are governed by the Second Life Viewer Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.

Review Board 1.6.11

Welcome to the Second Life Viewer Code Review tool.
See the documentation on our wiki for how to use this site.

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

Review Request #592 - Created July 19, 2012 and submitted

Ansariel Hiller Reviewers
viewer
STORM-1899
None viewer-release
A proposed solution for STORM-1899 and the issue, where the handpose of avatars randomly get stuck in the spread hand position.

In the current implementation, this case might happen under the following circumstances:
* Avatar uses an animation with hand pose A
* A request is issued to change hand pose to B
* Before the viewer has blended pose A over to pose B, the original pose A is requested again
* In this case, the hand pose will not be properly (re)set and because mNewPose == mCurrentPose, there will be no further blending, leaving the hand in it's current pose

The patch will properly reset the hand pose in this case and update the visual parameters of the avatar.

 

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

1 2
1 2

  1. indra/llcharacter/llhandmotion.cpp: Loading...
indra/llcharacter/llhandmotion.cpp
Revision 4d9106153407 New Change
... 124 lines hidden [Expand]
BOOL LLHandMotion::onUpdate(F32 time, U8* joint_mask)
125

   
125

   
126
	F32 timeDelta = time - mLastTime;
126
	F32 timeDelta = time - mLastTime;
127
	mLastTime = time;
127
	mLastTime = time;
128

   
128

   
129
	requestedHandPose = (eHandPose *)mCharacter->getAnimationData("Hand Pose");
129
	requestedHandPose = (eHandPose *)mCharacter->getAnimationData("Hand Pose");
130
	// check to see if requested pose has changed
130
	// check to see if requested pose has changed
131
	if (!requestedHandPose)
131
	if (!requestedHandPose)
132
	{
132
	{
133
		if (mNewPose != HAND_POSE_RELAXED && mNewPose != mCurrentPose)
133
		if (mNewPose != HAND_POSE_RELAXED && mNewPose != mCurrentPose)
134
		{
134
		{

   
135
			// Only set param weight for poses other than

   
136
			// default (HAND_POSE_SPREAD); HAND_POSE_SPREAD

   
137
			// is not an animatable morph!

   
138
			if (mNewPose != HAND_POSE_SPREAD)

   
139
			{
135
			mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
140
				mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
136
		}
141
			}

   
142

   

   
143
			// Reset morph weight for current pose back to its

   
144
			// full extend or it might be stuck somewhere in the middle if a

   
145
			// pose is requested and the old pose is requested again shortly

   
146
			// after while still blending to the other pose!

   
147
			if (mCurrentPose != HAND_POSE_SPREAD)

   
148
			{

   
149
				mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], 1.f);

   
150
			}

   
151

   

   
152
			// Update visual params now if we won't blend

   
153
			if (mCurrentPose == HAND_POSE_RELAXED)

   
154
			{

   
155
				mCharacter->updateVisualParams();

   
156
			}

   
157
		}
137
		mNewPose = HAND_POSE_RELAXED;
158
		mNewPose = HAND_POSE_RELAXED;
138
	}
159
	}
139
	else
160
	else
140
	{
161
	{
141
		// this is a new morph we didn't know about before
162
		// Sometimes we seem to get garbage here, with poses that are out of bounds.
142
		if (*requestedHandPose != mNewPose && mNewPose != mCurrentPose && mNewPose != HAND_POSE_SPREAD)
163
		// Clamp requested pose before setting the new pose and request

   
164
		// relaxed hand pose instead as default.

   
165
		if (*requestedHandPose < 0 || *requestedHandPose >= NUM_HAND_POSES)

   
166
		{

   
167
			llwarns << "Requested hand pose out of range. Using HAND_POSE_RELAXED." << llendl;

   
168
			*requestedHandPose = HAND_POSE_RELAXED;

   
169
		}

   
170

   

   
171
		// This is a new morph we didn't know about before:

   
172
		// Reset morph weight for both current and new pose

   
173
		// back their starting values while still blending.

   
174
		if (*requestedHandPose != mNewPose && mNewPose != mCurrentPose)

   
175
		{

   
176
			if (mNewPose != HAND_POSE_SPREAD)
143
		{
177
			{
144
			mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
178
				mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f);
145
		}
179
			}

   
180

   

   
181
			// Reset morph weight for current pose back to its full extend

   
182
			// or it might be stuck somewhere in the middle if a pose is

   
183
			// requested and the old pose is requested again shortly after

   
184
			// while still blending to the other pose!

   
185
			if (mCurrentPose != HAND_POSE_SPREAD)

   
186
			{

   
187
				mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], 1.f);

   
188
			}

   
189

   

   
190
			// Update visual params now if we won't blend

   
191
			if (mCurrentPose == *requestedHandPose)

   
192
			{

   
193
				mCharacter->updateVisualParams();

   
194
			}

   
195
		}
146
		mNewPose = *requestedHandPose;
196
		mNewPose = *requestedHandPose;
147
	}
197
	}
148

   
198

   
149
	mCharacter->removeAnimationData("Hand Pose");
199
	mCharacter->removeAnimationData("Hand Pose");
150
	mCharacter->removeAnimationData("Hand Pose Priority");
200
	mCharacter->removeAnimationData("Hand Pose Priority");
151

   
201

   
152
//	if (requestedHandPose)
202
//	if (requestedHandPose)
153
//		llinfos << "Hand Pose " << *requestedHandPose << llendl;
203
//		llinfos << "Hand Pose " << *requestedHandPose << llendl;
154

   
204

   
155
	// if we are still blending...
205
	// if we are still blending...
... 65 lines hidden [Expand]
  1. indra/llcharacter/llhandmotion.cpp: Loading...