From 572cea48fcb4e5a4736859f56eb13260ad1aaca1 Mon Sep 17 00:00:00 2001 From: Angeldark Raymaker Date: Tue, 12 Nov 2024 18:41:44 +0000 Subject: [PATCH] FIRE-34747: Tidy up and add UI cues to own work --- indra/newview/fsfloaterposer.cpp | 43 ++++++++++++++++++++++++++++--- indra/newview/fsfloaterposer.h | 1 + indra/newview/fsposeranimator.cpp | 26 +++++++++++++++++-- indra/newview/fsposeranimator.h | 14 +++++++++- 4 files changed, 77 insertions(+), 7 deletions(-) diff --git a/indra/newview/fsfloaterposer.cpp b/indra/newview/fsfloaterposer.cpp index 3a95060b50..2cd660a175 100644 --- a/indra/newview/fsfloaterposer.cpp +++ b/indra/newview/fsfloaterposer.cpp @@ -158,6 +158,11 @@ bool FSFloaterPoser::postBuild() if (gSavedSettings.getBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY)) mToggleAdvancedPanelBtn->setValue(true); + + mStopPosingOnCloseCbx = getChild("stop_posing_on_close_checkbox"); + if (gSavedSettings.getBOOL(POSER_STOPPOSINGWHENCLOSED_SAVE_KEY)) + mAlsoSaveBvhCbx->set(true); + mTrackpadSensitivitySlider = getChild("trackpad_sensitivity_slider"); mTrackpadSensitivitySlider->setValue(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY)); @@ -227,6 +232,9 @@ void FSFloaterPoser::onClose(bool app_quitting) if (mToggleAdvancedPanelBtn) gSavedSettings.setBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY, mToggleAdvancedPanelBtn->getValue().asBoolean()); + if (mStopPosingOnCloseCbx) + gSavedSettings.setBOOL(POSER_STOPPOSINGWHENCLOSED_SAVE_KEY, mStopPosingOnCloseCbx->getValue().asBoolean()); + if (gSavedSettings.getBOOL(POSER_STOPPOSINGWHENCLOSED_SAVE_KEY)) stopPosingSelf(); @@ -655,7 +663,7 @@ void FSFloaterPoser::onClickLoadHandPose(bool isRightHand) continue; vec3.setValue(control_map["rotation"]); - mPoserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); + mPoserAnimator.loadJointRotation(avatar, poserJoint, true, vec3); } } } @@ -996,8 +1004,8 @@ LLSD FSFloaterPoser::createRowForJoint(const std::string& jointName, bool isHead return NULL; std::string headerValue = ""; - if (hasString("icon_category") && hasString("icon_bone")) - headerValue = isHeaderRow ? getString("icon_category") : getString("icon_bone"); + if (isHeaderRow && hasString("icon_category")) + headerValue = getString("icon_category"); std::string jointValue = jointName; std::string parameterName = (isHeaderRow ? XML_LIST_HEADER_STRING_PREFIX : XML_LIST_TITLE_STRING_PREFIX) + jointName; @@ -1154,6 +1162,7 @@ void FSFloaterPoser::onSetAvatarToTpose() setSavePosesButtonText(false); mPoserAnimator.setAllAvatarStartingRotationsToZero(avatar); + refreshTextHighlightingOnAllScrollLists(); } void FSFloaterPoser::onResetPosition() @@ -1718,6 +1727,7 @@ void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadi E_BoneDeflectionStyles defl = getUiSelectedBoneDeflectionStyle(); LLVector3 vec3 = LLVector3(yawInRadians, pitchInRadians, rollInRadians); auto selectedJoints = getUiSelectedPoserJoints(); + bool savingToBvh = getSavingToBvh(); for (auto item : selectedJoints) { @@ -1736,8 +1746,11 @@ void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadi } mPoserAnimator.setJointRotation(avatar, item, vec3, defl, getJointTranslation(item->jointName()), - getJointNegation(item->jointName())); + getJointNegation(item->jointName()), savingToBvh); } + + if (savingToBvh) + refreshTextHighlightingOnAllScrollLists(); } void FSFloaterPoser::setSelectedJointsScale(F32 x, F32 y, F32 z) @@ -2089,15 +2102,37 @@ void FSFloaterPoser::addBoldToScrollList(LLScrollListCtrl* list, LLVOAvatar* ava if (!list) return; + std::string iconValue = ""; + bool considerBvh = getSavingToBvh(); + + if (considerBvh && hasString("icon_will_save_to_bvh")) + iconValue = getString("icon_will_save_to_bvh"); + for (auto listItem : list->getAllData()) { FSPoserAnimator::FSPoserJoint *userData = static_cast(listItem->getUserdata()); if (!userData) continue; + if (considerBvh) + { + if (mPoserAnimator.baseRotationIsZero(avatar, *userData)) + ((LLScrollListText*) listItem->getColumn(COL_ICON))->setValue(iconValue); + else + ((LLScrollListText*) listItem->getColumn(COL_ICON))->setValue(""); + } + if (mPoserAnimator.isPosingAvatarJoint(avatar, *userData)) ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); else ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); } } + +bool FSFloaterPoser::getSavingToBvh() +{ + if (!mAlsoSaveBvhCbx) + return false; + + return mAlsoSaveBvhCbx->getValue().asBoolean(); +} diff --git a/indra/newview/fsfloaterposer.h b/indra/newview/fsfloaterposer.h index f048617a6f..54f79b117c 100644 --- a/indra/newview/fsfloaterposer.h +++ b/indra/newview/fsfloaterposer.h @@ -399,6 +399,7 @@ class FSFloaterPoser : public LLFloater LLPanel* mMiscJointsPnl{ nullptr }; LLPanel* mCollisionVolumesPnl{ nullptr }; LLPanel* mPosesLoadSavePnl{ nullptr }; + LLCheckBoxCtrl* mStopPosingOnCloseCbx{ nullptr }; }; #endif diff --git a/indra/newview/fsposeranimator.cpp b/indra/newview/fsposeranimator.cpp index 0c62f290c2..13ee1990bb 100644 --- a/indra/newview/fsposeranimator.cpp +++ b/indra/newview/fsposeranimator.cpp @@ -407,6 +407,22 @@ void FSPoserAnimator::setJointPosition(LLVOAvatar* avatar, const FSPoserJoint* j } } +bool FSPoserAnimator::baseRotationIsZero(LLVOAvatar* avatar, const FSPoserJoint& joint) const +{ + if (!isAvatarSafeToUse(avatar)) + return false; + + FSPosingMotion* posingMotion = getPosingMotion(avatar); + if (!posingMotion) + return false; + + FSJointPose* jointPose = posingMotion->getJointPoseByJointName(joint.jointName()); + if (!jointPose) + return false; + + return jointPose->isBaseRotationZero(); +} + bool FSPoserAnimator::allBaseRotationsAreZero(LLVOAvatar* avatar) const { if (!isAvatarSafeToUse(avatar)) @@ -469,8 +485,8 @@ LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar* avatar, const FSPoserJoi return translateRotationFromQuaternion(translation, negation, jointPose->getRotationDelta()); } -void FSPoserAnimator::setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& rotation, E_BoneDeflectionStyles style, - E_BoneAxisTranslation translation, S32 negation) +void FSPoserAnimator::setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& rotation, E_BoneDeflectionStyles style, E_BoneAxisTranslation translation, S32 negation, + bool resetBaseRotationToZero) { if (!isAvatarSafeToUse(avatar)) return; @@ -485,6 +501,9 @@ void FSPoserAnimator::setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* j if (!jointPose) return; + if (resetBaseRotationToZero) + jointPose->zeroBaseRotation(); + LLQuaternion rot_quat = translateRotationToQuaternion(translation, negation, rotation); switch (style) { @@ -507,6 +526,9 @@ void FSPoserAnimator::setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* j if (!oppositeJointPose) return; + if (resetBaseRotationToZero) + oppositeJointPose->zeroBaseRotation(); + LLQuaternion inv_quat; switch (style) { diff --git a/indra/newview/fsposeranimator.h b/indra/newview/fsposeranimator.h index 0b5721ebdb..6821e0aaa9 100644 --- a/indra/newview/fsposeranimator.h +++ b/indra/newview/fsposeranimator.h @@ -451,8 +451,9 @@ public: /// Any ancilliary action to be taken with the change to be made. /// The axial translation form the supplied joint. /// The style of negation to apply to the set. + /// Whether to set the base rotation to zero on setting the rotation. void setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& rotation, E_BoneDeflectionStyles style, - E_BoneAxisTranslation translation, S32 negation); + E_BoneAxisTranslation translation, S32 negation, bool resetBaseRotationToZero); /// /// Gets the scale of a joint for the supplied avatar. @@ -499,6 +500,17 @@ public: /// The avatar whose joint rotations should be set to zero. void setAllAvatarStartingRotationsToZero(LLVOAvatar* avatar); + /// + /// Determines if the kind of save to perform should be a 'delta' save, or a complete save. + /// + /// The avatar whose pose-rotations are being considered for saving. + /// True if the save should save only 'deltas' to the rotation, otherwise false. + /// + /// A save of the rotation 'deltas' facilitates a user saving their changes to an existing animation. + /// Thus the save represents 'nothing other than the changes the user made', to some other pose which they may have limited rights to. + /// + bool baseRotationIsZero(LLVOAvatar* avatar, const FSPoserJoint& joint) const; + /// /// Determines if the kind of save to perform should be a 'delta' save, or a complete save. ///