Skip to content

Commit

Permalink
FIRE-35161: Revert all joint state when animation stops
Browse files Browse the repository at this point in the history
Collision volumes always needed it, but some infrequently posed joints do too, and it simiplifies the code.
  • Loading branch information
AngeldarkRaymaker committed Feb 25, 2025
1 parent e132dd4 commit 257a1d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 48 deletions.
23 changes: 1 addition & 22 deletions indra/newview/fsjointpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,12 @@ void FSJointPose::mirrorRotationFrom(FSJointPose* fromJoint)
mRotation.deltaRotation.mQ[VW]);
}

void FSJointPose::revertJointScale()
void FSJointPose::revertJoint()
{
LLJoint* joint = mJointState->getJoint();
if (!joint)
return;

joint->setScale(mBeginningScale);
}

void FSJointPose::revertJointPosition()
{
LLJoint* joint = mJointState->getJoint();
if (!joint)
return;

joint->setPosition(mBeginningPosition);
}

void FSJointPose::revertCollisionVolume()
{
if (!mIsCollisionVolume)
return;

LLJoint* joint = mJointState->getJoint();
if (!joint)
return;

joint->setRotation(mRotation.baseRotation);
joint->setPosition(mBeginningPosition);
joint->setScale(mBeginningScale);
Expand Down
16 changes: 3 additions & 13 deletions indra/newview/fsjointpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,10 @@ class FSJointPose
void recaptureJoint();

/// <summary>
/// Restores the joint represented by this to the scale it had when this motion started.
/// Reverts the position/rotation/scale to their values when the animation begun.
/// This treatment is required for certain joints, particularly Collision Volumes and those bones not commonly animated by an AO.
/// </summary>
void revertJointScale();

/// <summary>
/// Restores the joint represented by this to the position it had when this motion started.
/// </summary>
void revertJointPosition();

/// <summary>
/// Collision Volumes do not 'reset' their position/rotation when the animation stops.
/// This requires special treatment to revert changes we've made this animation session.
/// </summary>
void revertCollisionVolume();
void revertJoint();

LLVector3 getTargetPosition() const { return mPositionDelta + mBeginningPosition; }
LLQuaternion getTargetRotation() const { return mRotation.getTargetRotation(); }
Expand Down
16 changes: 4 additions & 12 deletions indra/newview/fsposingmotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,13 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask)
return true;
}

void FSPosingMotion::onDeactivate() { revertChangesToPositionsScalesAndCollisionVolumes(); }
void FSPosingMotion::onDeactivate() { revertJointsAndCollisionVolumes(); }

void FSPosingMotion::revertChangesToPositionsScalesAndCollisionVolumes()
void FSPosingMotion::revertJointsAndCollisionVolumes()
{
for (FSJointPose jointPose : mJointPoses)
{
jointPose.revertJointScale();
jointPose.revertJointPosition();

if (jointPose.isCollisionVolume())
jointPose.revertCollisionVolume();
jointPose.revertJoint();

LLJoint* joint = jointPose.getJointState()->getJoint();
if (!joint)
Expand Down Expand Up @@ -170,11 +166,7 @@ void FSPosingMotion::removeJointFromState(FSJointPose* joint)
if (!avJoint)
return;

joint->revertJointScale();
joint->revertJointPosition();

if (joint->isCollisionVolume())
joint->revertCollisionVolume();
joint->revertJoint();

setJointState(avJoint, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion indra/newview/fsposingmotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FSPosingMotion :
/// Because changes to positions, scales and collision volumes do not end when the animation stops,
/// this is required to revert them manually.
/// </summary>
void revertChangesToPositionsScalesAndCollisionVolumes();
void revertJointsAndCollisionVolumes();

/// <summary>
/// Queries whether the supplied joint is being animated.
Expand Down

0 comments on commit 257a1d3

Please sign in to comment.