FIRE-35161: Revert all joint state when animation stops

Collision volumes always needed it, but some infrequently posed joints do too, and it simiplifies the code.
master
Angeldark Raymaker 2025-02-25 20:09:21 +00:00
parent e132dd4a3d
commit 257a1d3bd4
4 changed files with 9 additions and 48 deletions

View File

@ -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);

View File

@ -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(); }

View File

@ -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)
@ -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);
}

View File

@ -173,7 +173,7 @@ private:
/// 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.