From 3f6231fe79a564150d5b25775314c93679609c65 Mon Sep 17 00:00:00 2001 From: Angeldark Raymaker Date: Tue, 22 Oct 2024 19:43:50 +0100 Subject: [PATCH] FIRE-30873: Refactor delta mode to enum choice --- indra/newview/fsfloaterposer.cpp | 54 ++++++++++--------- indra/newview/fsfloaterposer.h | 5 +- indra/newview/fsposeranimator.cpp | 36 ++++++------- indra/newview/fsposeranimator.h | 3 +- .../skins/default/xui/en/floater_poser.xml | 2 + 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/indra/newview/fsfloaterposer.cpp b/indra/newview/fsfloaterposer.cpp index a804aaa2ca..171a29e27a 100644 --- a/indra/newview/fsfloaterposer.cpp +++ b/indra/newview/fsfloaterposer.cpp @@ -129,6 +129,7 @@ FSFloaterPoser::FSFloaterPoser(const LLSD& key) : LLFloater(key) mCommitCallbackRegistrar.add("Poser.RedoLastRotation", boost::bind(&FSFloaterPoser::onRedoLastRotation, this)); mCommitCallbackRegistrar.add("Poser.ToggleMirrorChanges", boost::bind(&FSFloaterPoser::onToggleMirrorChange, this)); mCommitCallbackRegistrar.add("Poser.ToggleSympatheticChanges", boost::bind(&FSFloaterPoser::onToggleSympatheticChange, this)); + mCommitCallbackRegistrar.add("Poser.ToggleDeltaModeChanges", boost::bind(&FSFloaterPoser::onToggleDeltaModeChange, this)); mCommitCallbackRegistrar.add("Poser.AdjustTrackPadSensitivity", boost::bind(&FSFloaterPoser::onAdjustTrackpadSensitivity, this)); mCommitCallbackRegistrar.add("Poser.PositionSet", boost::bind(&FSFloaterPoser::onAvatarPositionSet, this)); @@ -167,7 +168,7 @@ bool FSFloaterPoser::postBuild() [this](LLUICtrl*, const LLSD&) { onJointSelect(); - setRotationChangeButtons(false, false); + setRotationChangeButtons(false, false, false); }); LLScrollListCtrl *scrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); @@ -591,7 +592,7 @@ void FSFloaterPoser::onClickRecaptureSelectedBones() _poserAnimator.setPosingAvatarJoint(avatar, *item, true); - _poserAnimator.setJointRotation(avatar, item, newRotation, false, NONE, getJointTranslation(item->jointName()), + _poserAnimator.setJointRotation(avatar, item, newRotation, NONE, getJointTranslation(item->jointName()), getJointNegation(item->jointName())); _poserAnimator.setJointPosition(avatar, item, newPosition, NONE); _poserAnimator.setJointScale(avatar, item, newScale, NONE); @@ -732,7 +733,7 @@ void FSFloaterPoser::loadPoseFromXml(LLVOAvatar* avatar, std::string poseFileNam if (loadRotations && control_map.has("rotation")) { vec3.setValue(control_map["rotation"]); - _poserAnimator.setJointRotation(avatar, poserJoint, vec3, false, NONE, SWAP_NOTHING, NEGATE_NOTHING); // If we keep defaults BD poses mostly load, except fingers + _poserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); // If we keep defaults BD poses mostly load, except fingers } if (loadPositions && control_map.has("position")) @@ -1040,11 +1041,13 @@ void FSFloaterPoser::showOrHideAdvancedSaveOptions() advSavePanel->setVisible(loadSavePanelExpanded && advancedPanelExpanded); } -void FSFloaterPoser::onToggleMirrorChange() { setRotationChangeButtons(true, false); } +void FSFloaterPoser::onToggleMirrorChange() { setRotationChangeButtons(true, false, false); } -void FSFloaterPoser::onToggleSympatheticChange() { setRotationChangeButtons(false, true); } +void FSFloaterPoser::onToggleSympatheticChange() { setRotationChangeButtons(false, true, false); } -void FSFloaterPoser::setRotationChangeButtons(bool togglingMirror, bool togglingSympathetic) +void FSFloaterPoser::onToggleDeltaModeChange() { setRotationChangeButtons(false, false, true); } + +void FSFloaterPoser::setRotationChangeButtons(bool togglingMirror, bool togglingSympathetic, bool togglingDelta) { LLButton *toggleMirrorButton = getChild(POSER_AVATAR_TOGGLEBUTTON_MIRROR); if (!toggleMirrorButton) @@ -1052,24 +1055,18 @@ void FSFloaterPoser::setRotationChangeButtons(bool togglingMirror, bool toggling LLButton *toggleSympatheticButton = getChild(POSER_AVATAR_TOGGLEBUTTON_SYMPATH); if (!toggleSympatheticButton) return; - - if (!togglingMirror && !togglingSympathetic) // turn off both buttons - { - toggleMirrorButton->setValue(false); - toggleSympatheticButton->setValue(false); + LLButton* deltaModeToggleButton = getChild(POSER_AVATAR_BUTTON_DELTAMODE); + if (!deltaModeToggleButton) return; - } - bool useMirror = toggleMirrorButton->getValue().asBoolean(); - bool useSympathetic = toggleSympatheticButton->getValue().asBoolean(); - if (useMirror && useSympathetic) // if both buttons are down, turn one of them off - { - if (togglingSympathetic) - toggleMirrorButton->setValue(false); + if (togglingSympathetic || togglingDelta) + toggleMirrorButton->setValue(false); - if (togglingMirror) - toggleSympatheticButton->setValue(false); - } + if (togglingMirror || togglingDelta) + toggleSympatheticButton->setValue(false); + + if (togglingMirror || togglingSympathetic) + deltaModeToggleButton->setValue(false); } void FSFloaterPoser::onUndoLastRotation() @@ -1397,11 +1394,16 @@ E_BoneDeflectionStyles FSFloaterPoser::getUiSelectedBoneDeflectionStyle() LLButton *toggleSympatheticButton = getChild(POSER_AVATAR_TOGGLEBUTTON_SYMPATH); if (!toggleSympatheticButton) return NONE; + LLButton* deltaModeToggleButton = getChild(POSER_AVATAR_BUTTON_DELTAMODE); + if (!deltaModeToggleButton) + return NONE; if (toggleMirrorButton->getValue().asBoolean()) return MIRROR; if (toggleSympatheticButton->getValue().asBoolean()) return SYMPATHETIC; + if (deltaModeToggleButton->getValue().asBoolean()) + return DELTAMODE; return NONE; } @@ -1575,11 +1577,11 @@ void FSFloaterPoser::onLimbTrackballChanged() deltaYaw *= trackPadSensitivity; deltaPitch *= trackPadSensitivity; - setSelectedJointsRotation(deltaYaw, deltaPitch, deltaRoll, true); + setSelectedJointsRotation(deltaYaw, deltaPitch, deltaRoll); } } else - setSelectedJointsRotation(yaw, pitch, roll, false); + setSelectedJointsRotation(yaw, pitch, roll); // WARNING! // as tempting as it is to refactor the following to refreshRotationSliders(), don't. @@ -1626,7 +1628,7 @@ void FSFloaterPoser::onLimbYawPitchRollChanged() pitch *= DEG_TO_RAD; roll *= DEG_TO_RAD; - setSelectedJointsRotation(yaw, pitch, roll, false); + setSelectedJointsRotation(yaw, pitch, roll); // WARNING! // as tempting as it is to refactor the following to refreshTrackpadCursor(), don't. @@ -1784,7 +1786,7 @@ void FSFloaterPoser::setSelectedJointsPosition(F32 x, F32 y, F32 z) } } -void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadians, F32 rollInRadians, bool isDelta) +void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadians, F32 rollInRadians) { LLVOAvatar *avatar = getUiSelectedAvatar(); if (!avatar) @@ -1802,7 +1804,7 @@ void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadi if (!currentlyPosingJoint) continue; - _poserAnimator.setJointRotation(avatar, item, vec3, isDelta, defl, getJointTranslation(item->jointName()), + _poserAnimator.setJointRotation(avatar, item, vec3, defl, getJointTranslation(item->jointName()), getJointNegation(item->jointName())); } } diff --git a/indra/newview/fsfloaterposer.h b/indra/newview/fsfloaterposer.h index a2a6545753..0fa12c42c1 100644 --- a/indra/newview/fsfloaterposer.h +++ b/indra/newview/fsfloaterposer.h @@ -167,7 +167,7 @@ class FSFloaterPoser : public LLFloater /// There may be +/- PI difference two axes, because harmonics. /// Thus keep your UI synced with less gets. /// - void setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadians, F32 rollInRadians, bool isDelta); + void setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadians, F32 rollInRadians); void setSelectedJointsPosition(F32 x, F32 y, F32 z); void setSelectedJointsScale(F32 x, F32 y, F32 z); @@ -203,7 +203,8 @@ class FSFloaterPoser : public LLFloater void onToggleAdvancedPanel(); void onToggleMirrorChange(); void onToggleSympatheticChange(); - void setRotationChangeButtons(bool mirror, bool sympathetic); + void onToggleDeltaModeChange(); + void setRotationChangeButtons(bool mirror, bool sympathetic, bool togglingDelta); void onUndoLastRotation(); void onRedoLastRotation(); void onUndoLastPosition(); diff --git a/indra/newview/fsposeranimator.cpp b/indra/newview/fsposeranimator.cpp index f2245c004c..cfb629afd4 100644 --- a/indra/newview/fsposeranimator.cpp +++ b/indra/newview/fsposeranimator.cpp @@ -435,7 +435,7 @@ LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar *avatar, FSPoserJoint joi return translateRotationFromQuaternion(translation, negation, rot); } -void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 rotation, bool isDelta, E_BoneDeflectionStyles style, +void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 rotation, E_BoneDeflectionStyles style, E_BoneAxisTranslation translation, S32 negation) { if (!isAvatarSafeToUse(avatar)) @@ -452,13 +452,22 @@ void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *j return; LLQuaternion rot_quat = translateRotationToQuaternion(translation, negation, rotation); - if (isDelta) - jointPose->applyDeltaRotation(rot_quat); - else - jointPose->setTargetRotation(rot_quat); + switch (style) + { + case SYMPATHETIC: + case MIRROR: + jointPose->setTargetRotation(rot_quat); + break; - if (style == NONE) - return; + case DELTAMODE: + jointPose->applyDeltaRotation(rot_quat); + return; + + case NONE: + default: + jointPose->setTargetRotation(rot_quat); + return; + } FSPosingMotion::FSJointPose* oppositeJointPose = posingMotion->getJointPoseByJointName(joint->mirrorJointName()); if (!oppositeJointPose) @@ -468,21 +477,12 @@ void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *j switch (style) { case SYMPATHETIC: - if (isDelta) - oppositeJointPose->applyDeltaRotation(rot_quat); - else - oppositeJointPose->setTargetRotation(rot_quat); - + oppositeJointPose->setTargetRotation(rot_quat); break; case MIRROR: inv_quat = LLQuaternion(-rot_quat.mQ[VX], rot_quat.mQ[VY], -rot_quat.mQ[VZ], rot_quat.mQ[VW]); - - if (isDelta) - oppositeJointPose->applyDeltaRotation(inv_quat); - else - oppositeJointPose->setTargetRotation(inv_quat); - + oppositeJointPose->setTargetRotation(inv_quat); break; default: diff --git a/indra/newview/fsposeranimator.h b/indra/newview/fsposeranimator.h index f50ebc8e8a..83f9dc5b4e 100644 --- a/indra/newview/fsposeranimator.h +++ b/indra/newview/fsposeranimator.h @@ -53,6 +53,7 @@ typedef enum E_BoneDeflectionStyles NONE = 0, // do nothing additional MIRROR = 1, // change the other joint, like in a mirror, eg: one left one right SYMPATHETIC = 2, // change the other joint, but opposite to a mirrored way, eg: both go right or both go left + DELTAMODE = 3, // each selected joint changes by the same supplied amount relative to their current } E_BoneDeflectionStyles; /// @@ -365,7 +366,7 @@ public: /// The rotation to set the joint to. /// Any ancilliary action to be taken with the change to be made. /// The axial translation form the supplied joint. - void setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, LLVector3 rotation, bool isDelta, E_BoneDeflectionStyles style, + void setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, LLVector3 rotation, E_BoneDeflectionStyles style, E_BoneAxisTranslation translation, S32 negation); /// diff --git a/indra/newview/skins/default/xui/en/floater_poser.xml b/indra/newview/skins/default/xui/en/floater_poser.xml index 7ca39126c8..1f4d00cb7c 100644 --- a/indra/newview/skins/default/xui/en/floater_poser.xml +++ b/indra/newview/skins/default/xui/en/floater_poser.xml @@ -717,6 +717,8 @@ width="565"> width="18" top_delta="0" left_pad="1"> +