From 257a1d3bd4d3cefdc0e8463ab166a6377b13cb5e Mon Sep 17 00:00:00 2001 From: Angeldark Raymaker Date: Tue, 25 Feb 2025 20:09:21 +0000 Subject: [PATCH] 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. --- indra/newview/fsjointpose.cpp | 23 +---------------------- indra/newview/fsjointpose.h | 16 +++------------- indra/newview/fsposingmotion.cpp | 16 ++++------------ indra/newview/fsposingmotion.h | 2 +- 4 files changed, 9 insertions(+), 48 deletions(-) diff --git a/indra/newview/fsjointpose.cpp b/indra/newview/fsjointpose.cpp index b6bb99bf95..285e1c5322 100644 --- a/indra/newview/fsjointpose.cpp +++ b/indra/newview/fsjointpose.cpp @@ -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); diff --git a/indra/newview/fsjointpose.h b/indra/newview/fsjointpose.h index 3983eef773..1b50f908bd 100644 --- a/indra/newview/fsjointpose.h +++ b/indra/newview/fsjointpose.h @@ -163,20 +163,10 @@ class FSJointPose void recaptureJoint(); /// - /// 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. /// - void revertJointScale(); - - /// - /// Restores the joint represented by this to the position it had when this motion started. - /// - void revertJointPosition(); - - /// - /// 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. - /// - void revertCollisionVolume(); + void revertJoint(); LLVector3 getTargetPosition() const { return mPositionDelta + mBeginningPosition; } LLQuaternion getTargetRotation() const { return mRotation.getTargetRotation(); } diff --git a/indra/newview/fsposingmotion.cpp b/indra/newview/fsposingmotion.cpp index e39c6569b0..fab282552c 100644 --- a/indra/newview/fsposingmotion.cpp +++ b/indra/newview/fsposingmotion.cpp @@ -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); } diff --git a/indra/newview/fsposingmotion.h b/indra/newview/fsposingmotion.h index 103e9bda6a..3b9d3a7a0d 100644 --- a/indra/newview/fsposingmotion.h +++ b/indra/newview/fsposingmotion.h @@ -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. /// - void revertChangesToPositionsScalesAndCollisionVolumes(); + void revertJointsAndCollisionVolumes(); /// /// Queries whether the supplied joint is being animated.