From f4a502de24da1b4321ebb2b443862767feb455cb Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 26 Oct 2024 19:17:30 +0200 Subject: [PATCH 01/16] Refactor the entire poser --- indra/llui/llpanel.cpp | 2 +- indra/llui/llpanel.h | 2 +- indra/newview/fsfloaterposer.cpp | 1257 ++++++++++----------------- indra/newview/fsfloaterposer.h | 132 ++- indra/newview/fsposeranimator.cpp | 86 +- indra/newview/fsposeranimator.h | 268 +++--- indra/newview/fsposingmotion.cpp | 304 ++++++- indra/newview/fsposingmotion.h | 322 ++----- indra/newview/fsvirtualtrackpad.cpp | 248 +++--- indra/newview/fsvirtualtrackpad.h | 70 +- 10 files changed, 1270 insertions(+), 1421 deletions(-) diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 6ed3dd7add..4d5a76416d 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -593,7 +593,7 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return true; } -bool LLPanel::hasString(std::string_view name) +bool LLPanel::hasString(std::string_view name) const { return mUIStrings.find(name) != mUIStrings.end(); } diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index d21ee739f6..4cad520e8e 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -169,7 +169,7 @@ public: void initFromParams(const Params& p); bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - bool hasString(std::string_view name); + bool hasString(std::string_view name) const; std::string getString(std::string_view name, const LLStringUtil::format_map_t& args) const; std::string getString(std::string_view name) const; diff --git a/indra/newview/fsfloaterposer.cpp b/indra/newview/fsfloaterposer.cpp index b2d0aa79e0..902a7ee7e3 100644 --- a/indra/newview/fsfloaterposer.cpp +++ b/indra/newview/fsfloaterposer.cpp @@ -23,108 +23,44 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -#include -#include + #include "fsfloaterposer.h" #include "fsposeranimator.h" +#include "fsvirtualtrackpad.h" #include "llagent.h" -#include "llavatarname.h" #include "llavatarnamecache.h" +#include "llcheckboxctrl.h" +#include "llcommonutils.h" +#include "llcontrolavatar.h" #include "lldiriterator.h" #include "llsdserialize.h" -#include "fsvirtualtrackpad.h" -#include "llfloater.h" -#include "llviewercontrol.h" -#include "llcontrolavatar.h" -#include "llstring.h" -#include "llviewerwindow.h" -#include "llwindow.h" -#include "llcommonutils.h" #include "llscrolllistctrl.h" #include "llsliderctrl.h" #include "lltabcontainer.h" -#include "llcheckboxctrl.h" +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llwindow.h" namespace { -constexpr std::string_view POSE_INTERNAL_FORMAT_FILE_MASK = "*.xml"; -constexpr std::string_view POSE_INTERNAL_FORMAT_FILE_EXT = ".xml"; -constexpr std::string_view POSE_EXTERNAL_FORMAT_FILE_EXT = ".bvh"; -constexpr std::string_view POSE_SAVE_SUBDIRECTORY = "poses"; -constexpr std::string_view POSE_PRESETS_HANDS_SUBDIRECTORY = "poses\\hand_presets"; -constexpr std::string_view XML_LIST_HEADER_STRING_PREFIX = "header_"; -constexpr std::string_view XML_LIST_TITLE_STRING_PREFIX = "title_"; -constexpr std::string_view XML_JOINT_TRANSFORM_STRING_PREFIX = "joint_transform_"; -constexpr std::string_view POSER_ADVANCEDWINDOWSTATE_SAVE_KEY = "FSPoserAdvancedWindowState"; -constexpr std::string_view POSER_ALSOSAVEBVHFILE_SAVE_KEY = "FSPoserSaveBvhFileAlso"; +constexpr char POSE_INTERNAL_FORMAT_FILE_MASK[] = "*.xml"; +constexpr char POSE_INTERNAL_FORMAT_FILE_EXT[] = ".xml"; +constexpr char POSE_EXTERNAL_FORMAT_FILE_EXT[] = ".bvh"; +constexpr char POSE_SAVE_SUBDIRECTORY[] = "poses"; +constexpr std::string_view POSE_PRESETS_HANDS_SUBDIRECTORY = "hand_presets"; +constexpr char XML_LIST_HEADER_STRING_PREFIX[] = "header_"; +constexpr char XML_LIST_TITLE_STRING_PREFIX[] = "title_"; +constexpr char XML_JOINT_TRANSFORM_STRING_PREFIX[] = "joint_transform_"; +constexpr std::string_view POSER_ADVANCEDWINDOWSTATE_SAVE_KEY = "FSPoserAdvancedWindowState"; +constexpr std::string_view POSER_ALSOSAVEBVHFILE_SAVE_KEY = "FSPoserSaveBvhFileAlso"; constexpr std::string_view POSER_TRACKPAD_SENSITIVITY_SAVE_KEY = "FSPoserTrackpadSensitivity"; +} // namespace -constexpr std::string_view POSER_AVATAR_PANEL_JOINTSPARENT = "joints_parent_panel"; -constexpr std::string_view POSER_AVATAR_PANEL_TRACKBALL = "trackball_panel"; -constexpr std::string_view POSER_AVATAR_PANEL_ADVANCED = "advanced_parent_panel"; -constexpr std::string_view POSER_AVATAR_TABGROUP_JOINTS = "joints_tabs"; -constexpr std::string_view POSER_AVATAR_TAB_POSITION = "positionRotation_panel"; -constexpr std::string_view POSER_AVATAR_TAB_BODY = "body_joints_panel"; -constexpr std::string_view POSER_AVATAR_TAB_FACE = "face_joints_panel"; -constexpr std::string_view POSER_AVATAR_TAB_HANDS = "hands_tabs"; -constexpr std::string_view POSER_AVATAR_TAB_HANDJOINTS = "hands_joints_panel"; -constexpr std::string_view POSER_AVATAR_TAB_MISC = "misc_joints_panel"; -constexpr std::string_view POSER_AVATAR_TAB_VOLUMES = "collision_volumes_panel"; - - -// standard controls -constexpr std::string_view POSER_AVATAR_TRACKBALL_NAME = "limb_rotation"; -constexpr std::string_view POSER_TRACKPAD_SENSITIVITY_SLIDER_NAME = "trackpad_sensitivity_slider"; -constexpr std::string_view POSER_AVATAR_SLIDER_YAW_NAME = "limb_yaw"; // turning your nose left or right -constexpr std::string_view POSER_AVATAR_SLIDER_PITCH_NAME = "limb_pitch"; // pointing your nose up or down -constexpr std::string_view POSER_AVATAR_SLIDER_ROLL_NAME = "limb_roll"; // your ear touches your shoulder -constexpr std::string_view POSER_AVATAR_TOGGLEBUTTON_MIRROR = "button_toggleMirrorRotation"; -constexpr std::string_view POSER_AVATAR_TOGGLEBUTTON_SYMPATH = "button_toggleSympatheticRotation"; -constexpr std::string_view POSER_AVATAR_BUTTON_REDO = "button_redo_change"; -constexpr std::string_view POSER_AVATAR_BUTTON_DELTAMODE = "delta_mode_toggle"; -constexpr std::string_view POSER_AVATAR_SLIDER_POSX_NAME = "av_position_inout"; -constexpr std::string_view POSER_AVATAR_SLIDER_POSY_NAME = "av_position_leftright"; -constexpr std::string_view POSER_AVATAR_SLIDER_POSZ_NAME = "av_position_updown"; - - -// Advanced controls -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_ROTX_NAME = "Advanced_Rotation_X"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_ROTY_NAME = "Advanced_Rotation_Y"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_ROTZ_NAME = "Advanced_Rotation_Z"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_POSX_NAME = "Advanced_Position_X"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_POSY_NAME = "Advanced_Position_Y"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_POSZ_NAME = "Advanced_Position_Z"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_SCALEX_NAME = "Advanced_Scale_X"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_SCALEY_NAME = "Advanced_Scale_Y"; -constexpr std::string_view POSER_AVATAR_ADV_SLIDER_SCALEZ_NAME = "Advanced_Scale_Z"; -constexpr std::string_view POSER_AVATAR_ADV_BUTTON_NAME = "start_stop_posing_button"; -constexpr std::string_view POSER_AVATAR_ADVANCED_SAVEOPTIONSPANEL_NAME = "save_file_options"; -constexpr std::string_view POSER_AVATAR_ADVANCED_SAVEBVHCHECKBOX_NAME = "also_save_bvh_checkbox"; - -constexpr std::string_view POSER_AVATAR_SCROLLLIST_AVATARSELECTION = "avatarSelection_scroll"; -constexpr std::string_view POSER_AVATAR_STARTSTOP_POSING_BUTTON_NAME = "start_stop_posing_button"; -constexpr std::string_view POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME = "toggleAdvancedPanel"; -constexpr std::string_view POSER_AVATAR_PANEL_BUTTON_FLIPPOSE_NAME = "FlipPose_avatar"; -constexpr std::string_view POSER_AVATAR_PANEL_BUTTON_FLIPJOINT_NAME = "FlipJoint_avatar"; -constexpr std::string_view POSER_AVATAR_PANEL_BUTTON_RECAPTURE_NAME = "button_RecaptureParts"; -constexpr std::string_view POSER_AVATAR_PANEL_BUTTON_TOGGLEPOSING_NAME = "toggle_PosingSelectedBones"; - -constexpr std::string_view POSER_AVATAR_TOGGLEBUTTON_LOADSAVE = "toggleLoadSavePanel"; -constexpr std::string_view POSER_AVATAR_PANEL_LOADSAVE_NAME = "poses_loadSave"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME = "poses_scroll"; -constexpr std::string_view POSER_AVATAR_BUTTON_BROWSEFOLDER_NAME = "open_poseDir_button"; -constexpr std::string_view POSER_AVATAR_BUTTON_LOAD_NAME = "load_poses_button"; -constexpr std::string_view POSER_AVATAR_BUTTON_SAVE_NAME = "save_poses_button"; -constexpr std::string_view POSER_AVATAR_LINEEDIT_FILESAVENAME = "pose_save_name"; - -constexpr std::string_view POSER_AVATAR_SCROLLLIST_HIDDEN_NAME = "entireAv_joint_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_BODYJOINTS_NAME = "body_joints_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_FACEJOINTS_NAME = "face_joints_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_HANDJOINTS_NAME = "hand_joints_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_MISCJOINTS_NAME = "misc_joints_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_VOLUMES_NAME = "collision_volumes_scroll"; -constexpr std::string_view POSER_AVATAR_SCROLLLIST_HAND_PRESETS_NAME = "hand_presets_scroll"; -} +/// +/// The amount of deflection 'one unit' on the trackpad translates to in radians. +/// The trackpad ordinarily has a range of +1..-1; multiplied by PI, gives PI to -PI, or all 360 degrees of deflection. +/// +constexpr F32 NormalTrackpadRangeInRads = F_PI; FSFloaterPoser::FSFloaterPoser(const LLSD& key) : LLFloater(key) { @@ -140,7 +76,6 @@ FSFloaterPoser::FSFloaterPoser(const LLSD& key) : LLFloater(key) mCommitCallbackRegistrar.add("Poser.ToggleSympatheticChanges", [this](LLUICtrl*, const LLSD&) { onToggleSympatheticChange(); }); mCommitCallbackRegistrar.add("Poser.ToggleDeltaModeChanges", [this](LLUICtrl*, const LLSD &) { onToggleDeltaModeChange(); }); mCommitCallbackRegistrar.add("Poser.AdjustTrackPadSensitivity", [this](LLUICtrl*, const LLSD&) { onAdjustTrackpadSensitivity(); }); - mCommitCallbackRegistrar.add("Poser.PositionSet", [this](LLUICtrl*, const LLSD&) { onAvatarPositionSet(); }); @@ -166,143 +101,155 @@ FSFloaterPoser::FSFloaterPoser(const LLSD& key) : LLFloater(key) mCommitCallbackRegistrar.add("Poser.PoseJointsReset", [this](LLUICtrl*, const LLSD&) { onPoseJointsReset(); }); } - - -FSFloaterPoser::~FSFloaterPoser() {} - bool FSFloaterPoser::postBuild() { + mAvatarTrackball = getChild("limb_rotation"); + mAvatarTrackball->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbTrackballChanged(); }); + + mLimbYawSlider = getChild("limb_yaw"); + mLimbYawSlider->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); + + mLimbPitchSlider = getChild("limb_pitch"); + mLimbPitchSlider->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); + + mLimbRollSlider = getChild("limb_roll"); + mLimbRollSlider->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); + // find-and-binds - getChild(POSER_AVATAR_TRACKBALL_NAME)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbTrackballChanged(); }); - getChild(POSER_AVATAR_SLIDER_YAW_NAME)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); - getChild(POSER_AVATAR_SLIDER_PITCH_NAME)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); - getChild(POSER_AVATAR_SLIDER_ROLL_NAME)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLimbYawPitchRollChanged(); }); - getChild(POSER_AVATAR_TABGROUP_JOINTS) - ->setCommitCallback( - [this](LLUICtrl*, const LLSD&) - { - onJointSelect(); - setRotationChangeButtons(false, false, false); - }); + mJointsTabs = getChild("joints_tabs"); + mJointsTabs->setCommitCallback( + [this](LLUICtrl*, const LLSD&) + { + onJointSelect(); + setRotationChangeButtons(false, false, false); + }); - LLScrollListCtrl *scrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (scrollList) + mAvatarSelectionScrollList = getChild("avatarSelection_scroll"); + mAvatarSelectionScrollList->setCommitOnSelectionChange(true); + mAvatarSelectionScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAvatarSelect(); }); + + mBodyJointsScrollList = getChild("body_joints_scroll"); + mBodyJointsScrollList->setCommitOnSelectionChange(true); + mBodyJointsScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + + mFaceJointsScrollList = getChild("face_joints_scroll"); + mFaceJointsScrollList->setCommitOnSelectionChange(true); + mFaceJointsScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + + mHandJointsScrollList = getChild("hand_joints_scroll"); + mHandJointsScrollList->setCommitOnSelectionChange(true); + mHandJointsScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + + mMiscJointsScrollList = getChild("misc_joints_scroll"); + mMiscJointsScrollList->setCommitOnSelectionChange(true); + mMiscJointsScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + + mCollisionVolumesScrollList = getChild("collision_volumes_scroll"); + mCollisionVolumesScrollList->setCommitOnSelectionChange(true); + mCollisionVolumesScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + + mEntireAvJointScroll = getChild("entireAv_joint_scroll"); + + mPosesScrollList = getChild("poses_scroll"); + mPosesScrollList->setCommitOnSelectionChange(true); + mPosesScrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onPoseFileSelect(); }); + + mToggleAdvancedPanelBtn = getChild("toggleAdvancedPanel"); + if (gSavedSettings.getBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY)) { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAvatarSelect(); }); + mToggleAdvancedPanelBtn->setValue(true); } - scrollList = getChild(POSER_AVATAR_SCROLLLIST_BODYJOINTS_NAME); - if (scrollList) + mAlsoSaveBvhCbx = getChild("also_save_bvh_checkbox"); + if (gSavedSettings.getBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY)) { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); + mAlsoSaveBvhCbx->set(true); } - scrollList = getChild(POSER_AVATAR_SCROLLLIST_FACEJOINTS_NAME); - if (scrollList) - { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); - } + mTrackpadSensitivitySlider = getChild("trackpad_sensitivity_slider"); + mTrackpadSensitivitySlider->setValue(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY)); - scrollList = getChild(POSER_AVATAR_SCROLLLIST_HANDJOINTS_NAME); - if (scrollList) - { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); - } + mPoseSaveNameEditor = getChild("pose_save_name"); + mPoseSaveNameEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); - scrollList = getChild(POSER_AVATAR_SCROLLLIST_MISCJOINTS_NAME); - if (scrollList) - { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); - } + mHandPresetsScrollList = getChild("hand_presets_scroll"); - scrollList = getChild(POSER_AVATAR_SCROLLLIST_VOLUMES_NAME); - if (scrollList) - { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onJointSelect(); }); - } + mPosXSlider = getChild("av_position_inout"); + mPosYSlider = getChild("av_position_leftright"); + mPosZSlider = getChild("av_position_updown"); - scrollList = getChild(POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME); - if (scrollList) - { - scrollList->setCommitOnSelectionChange(true); - scrollList->setCommitCallback([this](LLUICtrl *, const LLSD &) { onPoseFileSelect(); }); - } + mAdvPosXSlider = getChild("Advanced_Position_X"); + mAdvPosYSlider = getChild("Advanced_Position_Y"); + mAdvPosZSlider = getChild("Advanced_Position_Z"); - bool advButtonState = gSavedSettings.getBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY); - if (advButtonState) - { - LLButton *advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (advancedButton) - advancedButton->setValue(true); - } + mAdvScaleXSlider = getChild("Advanced_Scale_X"); + mAdvScaleYSlider = getChild("Advanced_Scale_Y"); + mAdvScaleZSlider = getChild("Advanced_Scale_Z"); - bool saveBvhCheckboxState = gSavedSettings.getBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY); - if (saveBvhCheckboxState) - { - LLCheckBoxCtrl* saveBvhCheckbox = getChild(POSER_AVATAR_ADVANCED_SAVEBVHCHECKBOX_NAME); - if (saveBvhCheckbox) - saveBvhCheckbox->set(true); - } + mSaveFilePptionsPnl = getChild("save_file_options"); + mPosesLoadSavePnl = getChild("poses_loadSave"); + mStartStopPosingBtn = getChild("start_stop_posing_button"); + mToggleLoadSavePanelBtn = getChild("toggleLoadSavePanel"); + mBrowserFolderBtn = getChild("open_poseDir_button"); + mLoadPosesBtn = getChild("load_poses_button"); + mSavePosesBtn = getChild("save_poses_button"); - LLSliderCtrl* trackpadSensitivitySlider = getChild(POSER_TRACKPAD_SENSITIVITY_SLIDER_NAME); - if (trackpadSensitivitySlider) - { - F32 trackPadSensitivity = gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY); - trackpadSensitivitySlider->setValue(trackPadSensitivity); - } + mFlipPoseBtn = getChild("FlipPose_avatar"); + mFlipJointBtn = getChild("FlipJoint_avatar"); + mRecaptureBtn = getChild("button_RecaptureParts"); + mTogglePosingBonesBtn = getChild("toggle_PosingSelectedBones"); - LLLineEditor *poseSaveName = getChild(POSER_AVATAR_LINEEDIT_FILESAVENAME); - if (poseSaveName) - poseSaveName->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); + mToggleMirrorRotationBtn = getChild("button_toggleMirrorRotation"); + mToggleSympatheticRotationBtn = getChild("button_toggleSympatheticRotation"); + mToggleDeltaModeBtn = getChild("delta_mode_toggle"); + mRedoChangeBtn = getChild("button_redo_change"); + + mJointsParentPnl = getChild("joints_parent_panel"); + mAdvancedParentPnl = getChild("advanced_parent_panel"); + mTrackballPnl = getChild("trackball_panel"); + mPositionRotationPnl = getChild("positionRotation_panel"); + mBodyJointsPnl = getChild("body_joints_panel"); + mFaceJointsPnl = getChild("face_joints_panel"); + mHandsTabs = getChild("hands_tabs"); + mHandsJointsPnl = mHandsTabs->getChild("hands_joints_panel"); + mMiscJointsPnl = getChild("misc_joints_panel"); + mCollisionVolumesPnl = getChild("collision_volumes_panel"); return true; } -void FSFloaterPoser::draw() -{ - LLFloater::draw(); -} - void FSFloaterPoser::onOpen(const LLSD& key) { onAvatarsRefresh(); refreshJointScrollListMembers(); onJointSelect(); onOpenSetAdvancedPanel(); - refreshPoseScroll(POSER_AVATAR_SCROLLLIST_HAND_PRESETS_NAME, POSE_PRESETS_HANDS_SUBDIRECTORY); + refreshPoseScroll(mHandPresetsScrollList, POSE_PRESETS_HANDS_SUBDIRECTORY); + + LLFloater::onOpen(key); } void FSFloaterPoser::onClose(bool app_quitting) { - LLButton *advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (advancedButton) - gSavedSettings.setBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY, advancedButton->getValue().asBoolean()); + gSavedSettings.setBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY, mToggleAdvancedPanelBtn->getValue().asBoolean()); + gSavedSettings.setBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY, mAlsoSaveBvhCbx->getValue()); - LLCheckBoxCtrl* saveBvhCheckbox = getChild(POSER_AVATAR_ADVANCED_SAVEBVHCHECKBOX_NAME); - if (saveBvhCheckbox) - gSavedSettings.setBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY, saveBvhCheckbox->getValue()); + LLFloater::onClose(app_quitting); } -void FSFloaterPoser::refreshPoseScroll(std::string_view scrollListName, std::string_view subDirectory) +void FSFloaterPoser::refreshPoseScroll(LLScrollListCtrl* posesScrollList, std::optional subDirectory) { - if (scrollListName.empty() || subDirectory.empty()) - return; - - LLScrollListCtrl* posesScrollList = getChild(scrollListName); if (!posesScrollList) return; posesScrollList->clearRows(); - std::string dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(subDirectory)); + std::string dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY); + if (subDirectory.has_value()) + gDirUtilp->append(dir, std::string(subDirectory.value())); + std::string file; - LLDirIterator dir_iter(dir, std::string(POSE_INTERNAL_FORMAT_FILE_MASK)); + LLDirIterator dir_iter(dir, POSE_INTERNAL_FORMAT_FILE_MASK); while (dir_iter.next(file)) { std::string path = gDirUtilp->add(dir, file); @@ -333,11 +280,7 @@ void FSFloaterPoser::refreshPoseScroll(std::string_view scrollListName, std::str void FSFloaterPoser::onPoseFileSelect() { - LLScrollListCtrl *posesScrollList = getChild(POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME); - if (!posesScrollList) - return; - - LLScrollListItem *item = posesScrollList->getFirstSelected(); + LLScrollListItem* item = mPosesScrollList->getFirstSelected(); if (!item) return; @@ -345,36 +288,22 @@ void FSFloaterPoser::onPoseFileSelect() if (!avatar) return; - bool enableButtons = _poserAnimator.isPosingAvatar(avatar); - - LLButton *loadPosesButton = getChild(POSER_AVATAR_BUTTON_LOAD_NAME); - if (loadPosesButton) - loadPosesButton->setEnabled(enableButtons); - - LLButton *savePosesButton = getChild(POSER_AVATAR_BUTTON_SAVE_NAME); - if (savePosesButton) - savePosesButton->setEnabled(enableButtons); + bool enableButtons = mPoserAnimator.isPosingAvatar(avatar); + mLoadPosesBtn->setEnabled(enableButtons); + mSavePosesBtn->setEnabled(enableButtons); std::string poseName = item->getColumn(0)->getValue().asString(); if (poseName.empty()) return; - LLLineEditor *poseSaveName = getChild(POSER_AVATAR_LINEEDIT_FILESAVENAME); - if (!poseSaveName) - return; - - poseSaveName->setEnabled(enableButtons); LLStringExplicit name = LLStringExplicit(poseName); - poseSaveName->setText(name); + mPoseSaveNameEditor->setEnabled(enableButtons); + mPoseSaveNameEditor->setText(name); } void FSFloaterPoser::onClickPoseSave() { - LLUICtrl *poseSaveName = getChild(POSER_AVATAR_LINEEDIT_FILESAVENAME); - if (!poseSaveName) - return; - - std::string filename = poseSaveName->getValue().asString(); + std::string filename = mPoseSaveNameEditor->getValue().asString(); if (filename.empty()) return; @@ -385,33 +314,29 @@ void FSFloaterPoser::onClickPoseSave() bool successfulSave = savePoseToXml(avatar, filename); if (successfulSave) { - refreshPoseScroll(POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME, POSE_SAVE_SUBDIRECTORY); + refreshPoseScroll(mPosesScrollList); setUiSelectedAvatarSaveFileName(filename); // TODO: provide feedback for save - LLCheckBoxCtrl* saveBvhCheckbox = getChild(POSER_AVATAR_ADVANCED_SAVEBVHCHECKBOX_NAME); - if (!saveBvhCheckbox) - return; - - bool alsoSaveAsBvh = saveBvhCheckbox->getValue().asBoolean(); + bool alsoSaveAsBvh = mAlsoSaveBvhCbx->getValue().asBoolean(); if (alsoSaveAsBvh) savePoseToBvh(avatar, filename); } } -bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, std::string poseFileName) +bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, const std::string& poseFileName) { if (poseFileName.empty()) return false; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return false; bool writeSuccess = false; try { - std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY)); + std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY); if (!gDirUtilp->fileExists(pathname)) { LL_WARNS("Poser") << "Couldn't find folder: " << pathname << " - creating one." << LL_ENDL; @@ -419,7 +344,7 @@ bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, std::string poseFileName) } std::string fullSavePath = - gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY), poseFileName + std::string(POSE_EXTERNAL_FORMAT_FILE_EXT)); + gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, poseFileName + POSE_EXTERNAL_FORMAT_FILE_EXT); llofstream file; file.open(fullSavePath.c_str()); @@ -429,7 +354,7 @@ bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, std::string poseFileName) return false; } - writeSuccess = _poserAnimator.writePoseAsBvh(&file, avatar); + writeSuccess = mPoserAnimator.writePoseAsBvh(&file, avatar); file.close(); } @@ -443,17 +368,17 @@ bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, std::string poseFileName) return true; } -bool FSFloaterPoser::savePoseToXml(LLVOAvatar* avatar, std::string poseFileName) +bool FSFloaterPoser::savePoseToXml(LLVOAvatar* avatar, const std::string& poseFileName) { if (poseFileName.empty()) return false; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return false; try { - std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY)); + std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY); if (!gDirUtilp->fileExists(pathname)) { LL_WARNS("Poser") << "Couldn't find folder: " << pathname << " - creating one." << LL_ENDL; @@ -461,28 +386,28 @@ bool FSFloaterPoser::savePoseToXml(LLVOAvatar* avatar, std::string poseFileName) } std::string fullSavePath = - gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY), poseFileName + std::string(POSE_INTERNAL_FORMAT_FILE_EXT)); + gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, poseFileName + POSE_INTERNAL_FORMAT_FILE_EXT); LLSD record; S32 version = 3; record["version"]["value"] = version; - for (const FSPoserAnimator::FSPoserJoint& pj : _poserAnimator.PoserJoints) + for (const FSPoserAnimator::FSPoserJoint& pj : mPoserAnimator.PoserJoints) { std::string bone_name = pj.jointName(); - LLVector3 vec3 = _poserAnimator.getJointRotation(avatar, pj, SWAP_NOTHING, NEGATE_NOTHING); + LLVector3 vec3 = mPoserAnimator.getJointRotation(avatar, pj, SWAP_NOTHING, NEGATE_NOTHING); record[bone_name] = pj.jointName(); record[bone_name]["rotation"] = vec3.getValue(); - vec3 = _poserAnimator.getJointPosition(avatar, pj); + vec3 = mPoserAnimator.getJointPosition(avatar, pj); record[bone_name]["position"] = vec3.getValue(); - vec3 = _poserAnimator.getJointScale(avatar, pj); + vec3 = mPoserAnimator.getJointScale(avatar, pj); record[bone_name]["scale"] = vec3.getValue(); - record[bone_name]["enabled"] = _poserAnimator.isPosingAvatarJoint(avatar, pj); + record[bone_name]["enabled"] = mPoserAnimator.isPosingAvatarJoint(avatar, pj); } llofstream file; @@ -515,13 +440,13 @@ void FSFloaterPoser::onClickToggleSelectedBoneEnabled() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); - _poserAnimator.setPosingAvatarJoint(avatar, *item, !currentlyPosing); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); + mPoserAnimator.setPosingAvatarJoint(avatar, *item, !currentlyPosing); } refreshRotationSliders(); @@ -539,21 +464,21 @@ void FSFloaterPoser::onClickFlipSelectedJoints() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; for (auto item : selectedJoints) { // need to be posing the joint to flip - bool currentlyPosingJoint = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosingJoint = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (!currentlyPosingJoint) continue; // need to be posing opposite joint too, or don't flip - auto oppositeJoint = _poserAnimator.getPoserJointByName(item->mirrorJointName()); + auto oppositeJoint = mPoserAnimator.getPoserJointByName(item->mirrorJointName()); if (oppositeJoint) { - bool currentlyPosingOppositeJoint = _poserAnimator.isPosingAvatarJoint(avatar, *oppositeJoint); + bool currentlyPosingOppositeJoint = mPoserAnimator.isPosingAvatarJoint(avatar, *oppositeJoint); if (!currentlyPosingOppositeJoint) continue; } @@ -566,7 +491,7 @@ void FSFloaterPoser::onClickFlipSelectedJoints() continue; } - _poserAnimator.reflectJoint(avatar, item); + mPoserAnimator.reflectJoint(avatar, item); } refreshRotationSliders(); @@ -579,10 +504,10 @@ void FSFloaterPoser::onClickFlipPose() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; - _poserAnimator.flipEntirePose(avatar); + mPoserAnimator.flipEntirePose(avatar); refreshRotationSliders(); refreshTrackpadCursor(); @@ -598,26 +523,26 @@ void FSFloaterPoser::onClickRecaptureSelectedBones() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) continue; - LLVector3 newRotation = _poserAnimator.getJointRotation(avatar, *item, getJointTranslation(item->jointName()), + LLVector3 newRotation = mPoserAnimator.getJointRotation(avatar, *item, getJointTranslation(item->jointName()), getJointNegation(item->jointName()), true); - LLVector3 newPosition = _poserAnimator.getJointPosition(avatar, *item, true); - LLVector3 newScale = _poserAnimator.getJointScale(avatar, *item, true); + LLVector3 newPosition = mPoserAnimator.getJointPosition(avatar, *item, true); + LLVector3 newScale = mPoserAnimator.getJointScale(avatar, *item, true); - _poserAnimator.setPosingAvatarJoint(avatar, *item, true); + mPoserAnimator.setPosingAvatarJoint(avatar, *item, true); - _poserAnimator.setJointRotation(avatar, item, newRotation, NONE, getJointTranslation(item->jointName()), + mPoserAnimator.setJointRotation(avatar, item, newRotation, NONE, getJointTranslation(item->jointName()), getJointNegation(item->jointName())); - _poserAnimator.setJointPosition(avatar, item, newPosition, NONE); - _poserAnimator.setJointScale(avatar, item, newScale, NONE); + mPoserAnimator.setJointPosition(avatar, item, newPosition, NONE); + mPoserAnimator.setJointScale(avatar, item, newScale, NONE); } refreshRotationSliders(); @@ -627,7 +552,7 @@ void FSFloaterPoser::onClickRecaptureSelectedBones() void FSFloaterPoser::onClickBrowsePoseCache() { - std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY)); + std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY); if (!gDirUtilp->fileExists(pathname)) LLFile::mkdir(pathname); @@ -637,16 +562,16 @@ void FSFloaterPoser::onClickBrowsePoseCache() void FSFloaterPoser::onPoseJointsReset() { // This is a double-click function: it needs to run twice within some amount of time to complete. - auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - _timeLastClickedJointReset; - _timeLastClickedJointReset = std::chrono::system_clock::now(); - if (timeIntervalSinceLastClick > _doubleClickInterval) + auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - mTimeLastClickedJointReset; + mTimeLastClickedJointReset = std::chrono::system_clock::now(); + if (timeIntervalSinceLastClick > mDoubleClickInterval) return; - LLVOAvatar *avatar = getUiSelectedAvatar(); + LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -655,45 +580,41 @@ void FSFloaterPoser::onPoseJointsReset() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.resetAvatarJoint(avatar, *item); + mPoserAnimator.resetAvatarJoint(avatar, *item); } refreshRotationSliders(); refreshTrackpadCursor(); } -void FSFloaterPoser::onPoseMenuAction(const LLSD ¶m) +void FSFloaterPoser::onPoseMenuAction(const LLSD& param) { std::string loadStyle = param.asString(); if (loadStyle.empty()) return; - LLScrollListCtrl *posesScrollList = getChild(POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME); - if (!posesScrollList) - return; - - LLScrollListItem *item = posesScrollList->getFirstSelected(); + LLScrollListItem* item = mPosesScrollList->getFirstSelected(); if (!item) return; std::string poseName = item->getColumn(0)->getValue().asString(); E_LoadPoseMethods loadType = ROT_POS_AND_SCALES; // the default is to load everything - if (boost::iequals(loadStyle, "rotation")) + if (loadStyle == "rotation") loadType = ROTATIONS; - else if (boost::iequals(loadStyle, "position")) + else if (loadStyle == "position") loadType = POSITIONS; - else if (boost::iequals(loadStyle, "scale")) + else if (loadStyle == "scale") loadType = SCALES; - else if (boost::iequals(loadStyle, "rot_pos")) + else if (loadStyle == "rot_pos") loadType = ROTATIONS_AND_POSITIONS; - else if (boost::iequals(loadStyle, "rot_scale")) + else if (loadStyle == "rot_scale") loadType = ROTATIONS_AND_SCALES; - else if (boost::iequals(loadStyle, "pos_scale")) + else if (loadStyle == "pos_scale") loadType = POSITIONS_AND_SCALES; - else if (boost::iequals(loadStyle, "all")) + else if (loadStyle == "all") loadType = ROT_POS_AND_SCALES; LLVOAvatar* avatar = getUiSelectedAvatar(); @@ -707,9 +628,9 @@ void FSFloaterPoser::onPoseMenuAction(const LLSD ¶m) void FSFloaterPoser::onClickLoadLeftHandPose() { // This is a double-click function: it needs to run twice within some amount of time to complete. - auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - _timeLastClickedJointReset; - _timeLastClickedJointReset = std::chrono::system_clock::now(); - if (timeIntervalSinceLastClick > _doubleClickInterval) + auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - mTimeLastClickedJointReset; + mTimeLastClickedJointReset = std::chrono::system_clock::now(); + if (timeIntervalSinceLastClick > mDoubleClickInterval) return; onClickLoadHandPose(false); @@ -718,9 +639,9 @@ void FSFloaterPoser::onClickLoadLeftHandPose() void FSFloaterPoser::onClickLoadRightHandPose() { // This is a double-click function: it needs to run twice within some amount of time to complete. - auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - _timeLastClickedJointReset; - _timeLastClickedJointReset = std::chrono::system_clock::now(); - if (timeIntervalSinceLastClick > _doubleClickInterval) + auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - mTimeLastClickedJointReset; + mTimeLastClickedJointReset = std::chrono::system_clock::now(); + if (timeIntervalSinceLastClick > mDoubleClickInterval) return; onClickLoadHandPose(true); @@ -728,26 +649,22 @@ void FSFloaterPoser::onClickLoadRightHandPose() void FSFloaterPoser::onClickLoadHandPose(bool isRightHand) { - LLScrollListCtrl* handPosesScrollList = getChild(POSER_AVATAR_SCROLLLIST_HAND_PRESETS_NAME); - if (!handPosesScrollList) - return; - - LLScrollListItem* item = handPosesScrollList->getFirstSelected(); + LLScrollListItem* item = mHandPresetsScrollList->getFirstSelected(); if (!item) return; std::string poseName = item->getColumn(0)->getValue().asString(); - std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_PRESETS_HANDS_SUBDIRECTORY)); + std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, std::string(POSE_PRESETS_HANDS_SUBDIRECTORY)); if (!gDirUtilp->fileExists(pathname)) return; std::string fullPath = - gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_PRESETS_HANDS_SUBDIRECTORY), poseName + std::string(POSE_INTERNAL_FORMAT_FILE_EXT)); + gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, std::string(POSE_PRESETS_HANDS_SUBDIRECTORY), poseName + POSE_INTERNAL_FORMAT_FILE_EXT); LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; try @@ -779,12 +696,12 @@ void FSFloaterPoser::onClickLoadHandPose(bool isRightHand) if (isRightHand != (name.find("Left") == std::string::npos)) continue; - const FSPoserAnimator::FSPoserJoint* poserJoint = _poserAnimator.getPoserJointByName(name); + const FSPoserAnimator::FSPoserJoint* poserJoint = mPoserAnimator.getPoserJointByName(name); if (!poserJoint) continue; vec3.setValue(control_map["rotation"]); - _poserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); + mPoserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); } } } @@ -795,17 +712,17 @@ void FSFloaterPoser::onClickLoadHandPose(bool isRightHand) } -void FSFloaterPoser::loadPoseFromXml(LLVOAvatar* avatar, std::string poseFileName, E_LoadPoseMethods loadMethod) +void FSFloaterPoser::loadPoseFromXml(LLVOAvatar* avatar, const std::string& poseFileName, E_LoadPoseMethods loadMethod) { - std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY)); + std::string pathname = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY); if (!gDirUtilp->fileExists(pathname)) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; std::string fullPath = - gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, std::string(POSE_SAVE_SUBDIRECTORY), poseFileName + std::string(POSE_INTERNAL_FORMAT_FILE_EXT)); + gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, poseFileName + POSE_INTERNAL_FORMAT_FILE_EXT); bool loadRotations = loadMethod == ROTATIONS || loadMethod == ROTATIONS_AND_POSITIONS || loadMethod == ROTATIONS_AND_SCALES || loadMethod == ROT_POS_AND_SCALES; @@ -843,7 +760,7 @@ void FSFloaterPoser::loadPoseFromXml(LLVOAvatar* avatar, std::string poseFileNam if (loadHandsOnly && name.find("Hand") == std::string::npos) continue; - const FSPoserAnimator::FSPoserJoint *poserJoint = _poserAnimator.getPoserJointByName(name); + const FSPoserAnimator::FSPoserJoint *poserJoint = mPoserAnimator.getPoserJointByName(name); if (!poserJoint) continue; @@ -851,32 +768,32 @@ void FSFloaterPoser::loadPoseFromXml(LLVOAvatar* avatar, std::string poseFileNam { vec3.setValue(control_map["rotation"]); - _poserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); + mPoserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); continue; } if (loadRotations && control_map.has("rotation")) { vec3.setValue(control_map["rotation"]); - _poserAnimator.setJointRotation(avatar, poserJoint, vec3, NONE, SWAP_NOTHING, NEGATE_NOTHING); // If we keep defaults BD poses mostly load, except fingers + mPoserAnimator.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")) { vec3.setValue(control_map["position"]); - _poserAnimator.setJointPosition(avatar, poserJoint, vec3, NONE); + mPoserAnimator.setJointPosition(avatar, poserJoint, vec3, NONE); } if (loadScales && control_map.has("scale")) { vec3.setValue(control_map["scale"]); - _poserAnimator.setJointScale(avatar, poserJoint, vec3, NONE); + mPoserAnimator.setJointScale(avatar, poserJoint, vec3, NONE); } if (control_map.has("enabled")) { enabled = control_map["enabled"].asBoolean(); - _poserAnimator.setPosingAvatarJoint(avatar, *poserJoint, enabled); + mPoserAnimator.setPosingAvatarJoint(avatar, *poserJoint, enabled); } } } @@ -895,10 +812,10 @@ void FSFloaterPoser::onPoseStartStop() if (!avatar) return; - bool arePosingSelected = _poserAnimator.isPosingAvatar(avatar); + bool arePosingSelected = mPoserAnimator.isPosingAvatar(avatar); if (arePosingSelected) { - _poserAnimator.stopPosingAvatar(avatar); + mPoserAnimator.stopPosingAvatar(avatar); } else { @@ -908,14 +825,14 @@ void FSFloaterPoser::onPoseStartStop() if (!havePermissionToAnimateAvatar(avatar)) return; - _poserAnimator.tryPosingAvatar(avatar); + mPoserAnimator.tryPosingAvatar(avatar); } onAvatarsRefresh(); onAvatarSelect(); } -bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar *avatar) +bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar *avatar) const { if (!avatar || avatar->isDead()) return false; @@ -925,7 +842,7 @@ bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar *avatar) return true; } -bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar *avatar) +bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar *avatar) const { if (!avatar || avatar->isDead()) return false; @@ -939,126 +856,87 @@ bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar *avatar) void FSFloaterPoser::poseControlsEnable(bool enable) { - LLUICtrl *somePanel = getChild(POSER_AVATAR_PANEL_JOINTSPARENT); - if (somePanel) - somePanel->setEnabled(enable); - - somePanel = getChild(POSER_AVATAR_PANEL_ADVANCED); - if (somePanel) - somePanel->setEnabled(enable); - - LLUICtrl *trackballPanel = getChild(POSER_AVATAR_PANEL_TRACKBALL); - if (trackballPanel) - trackballPanel->setEnabled(enable); - - LLButton *someButton = getChild(POSER_AVATAR_PANEL_BUTTON_FLIPPOSE_NAME); - if (someButton) - someButton->setEnabled(enable); - - someButton = getChild(POSER_AVATAR_PANEL_BUTTON_FLIPJOINT_NAME); - if (someButton) - someButton->setEnabled(enable); - - someButton = getChild(POSER_AVATAR_PANEL_BUTTON_RECAPTURE_NAME); - if (someButton) - someButton->setEnabled(enable); - - someButton = getChild(POSER_AVATAR_PANEL_BUTTON_TOGGLEPOSING_NAME); - if (someButton) - someButton->setEnabled(enable); - - someButton = getChild(POSER_AVATAR_BUTTON_LOAD_NAME); - if (someButton) - someButton->setEnabled(enable); - - someButton = getChild(POSER_AVATAR_BUTTON_SAVE_NAME); - if (someButton) - someButton->setEnabled(enable); - - LLLineEditor* poseSaveName = getChild(POSER_AVATAR_LINEEDIT_FILESAVENAME); - if (poseSaveName) - poseSaveName->setEnabled(enable); + mJointsParentPnl->setEnabled(enable); + mAdvancedParentPnl->setEnabled(enable); + mTrackballPnl->setEnabled(enable); + mFlipPoseBtn->setEnabled(enable); + mFlipJointBtn->setEnabled(enable); + mRecaptureBtn->setEnabled(enable); + mTogglePosingBonesBtn->setEnabled(enable); + mLoadPosesBtn->setEnabled(enable); + mSavePosesBtn->setEnabled(enable); + mPoseSaveNameEditor->setEnabled(enable); } void FSFloaterPoser::refreshJointScrollListMembers() { - LLVOAvatar *avatar = getUiSelectedAvatar(); - - LLScrollListCtrl *hiddenScrollList = getChild(POSER_AVATAR_SCROLLLIST_HIDDEN_NAME); - LLScrollListCtrl *bodyJointsScrollList = getChild(POSER_AVATAR_SCROLLLIST_BODYJOINTS_NAME); - LLScrollListCtrl *faceJointsScrollList = getChild(POSER_AVATAR_SCROLLLIST_FACEJOINTS_NAME); - LLScrollListCtrl *handsJointsScrollList = getChild(POSER_AVATAR_SCROLLLIST_HANDJOINTS_NAME); - LLScrollListCtrl *miscJointsScrollList = getChild(POSER_AVATAR_SCROLLLIST_MISCJOINTS_NAME); - LLScrollListCtrl *collisionVolumesScrollList = getChild(POSER_AVATAR_SCROLLLIST_VOLUMES_NAME); - if (!bodyJointsScrollList || !faceJointsScrollList || !handsJointsScrollList || !miscJointsScrollList || !collisionVolumesScrollList) - return; - - bodyJointsScrollList->clearRows(); - faceJointsScrollList->clearRows(); - handsJointsScrollList->clearRows(); - miscJointsScrollList->clearRows(); - collisionVolumesScrollList->clearRows(); + mBodyJointsScrollList->clearRows(); + mFaceJointsScrollList->clearRows(); + mHandJointsScrollList->clearRows(); + mMiscJointsScrollList->clearRows(); + mCollisionVolumesScrollList->clearRows(); std::vector::const_iterator poserJoint_iter; - for (poserJoint_iter = _poserAnimator.PoserJoints.begin(); - poserJoint_iter != _poserAnimator.PoserJoints.end(); + for (poserJoint_iter = mPoserAnimator.PoserJoints.begin(); + poserJoint_iter != mPoserAnimator.PoserJoints.end(); ++poserJoint_iter) { - LLSD row = createRowForJoint(poserJoint_iter->jointName(), false); + LLSD row = createRowForJoint(poserJoint_iter->jointName(), false); if (!row) continue; LLScrollListItem *item = nullptr; - bool hasListHeader = hasString(std::string(XML_LIST_HEADER_STRING_PREFIX) + poserJoint_iter->jointName()); + bool hasListHeader = hasString(XML_LIST_HEADER_STRING_PREFIX + poserJoint_iter->jointName()); switch (poserJoint_iter->boneType()) { case WHOLEAVATAR: - item = hiddenScrollList->addElement(row); - hiddenScrollList->selectFirstItem(); + item = mEntireAvJointScroll->addElement(row); + mEntireAvJointScroll->selectFirstItem(); break; case BODY: if (hasListHeader) - AddHeaderRowToScrollList(poserJoint_iter->jointName(), bodyJointsScrollList); + addHeaderRowToScrollList(poserJoint_iter->jointName(), mBodyJointsScrollList); - item = bodyJointsScrollList->addElement(row); + item = mBodyJointsScrollList->addElement(row); break; case FACE: if (hasListHeader) - AddHeaderRowToScrollList(poserJoint_iter->jointName(), faceJointsScrollList); + addHeaderRowToScrollList(poserJoint_iter->jointName(), mFaceJointsScrollList); - item = faceJointsScrollList->addElement(row); + item = mFaceJointsScrollList->addElement(row); break; case HANDS: if (hasListHeader) - AddHeaderRowToScrollList(poserJoint_iter->jointName(), handsJointsScrollList); + addHeaderRowToScrollList(poserJoint_iter->jointName(), mHandJointsScrollList); - item = handsJointsScrollList->addElement(row); + item = mHandJointsScrollList->addElement(row); break; case MISC: if (hasListHeader) - AddHeaderRowToScrollList(poserJoint_iter->jointName(), miscJointsScrollList); + addHeaderRowToScrollList(poserJoint_iter->jointName(), mMiscJointsScrollList); - item = miscJointsScrollList->addElement(row); + item = mMiscJointsScrollList->addElement(row); break; case COL_VOLUMES: if (hasListHeader) - AddHeaderRowToScrollList(poserJoint_iter->jointName(), collisionVolumesScrollList); + addHeaderRowToScrollList(poserJoint_iter->jointName(), mCollisionVolumesScrollList); - item = collisionVolumesScrollList->addElement(row); + item = mCollisionVolumesScrollList->addElement(row); break; } if (item) { item->setUserdata((void*) &*poserJoint_iter); + LLVOAvatar* avatar = getUiSelectedAvatar(); - if (_poserAnimator.isPosingAvatarJoint(avatar, *poserJoint_iter)) + if (mPoserAnimator.isPosingAvatarJoint(avatar, *poserJoint_iter)) ((LLScrollListText *) item->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); else ((LLScrollListText *) item->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); @@ -1066,7 +944,7 @@ void FSFloaterPoser::refreshJointScrollListMembers() } } -void FSFloaterPoser::AddHeaderRowToScrollList(std::string jointName, LLScrollListCtrl *bodyJointsScrollList) +void FSFloaterPoser::addHeaderRowToScrollList(const std::string& jointName, LLScrollListCtrl* bodyJointsScrollList) { LLSD headerRow = createRowForJoint(jointName, true); if (!headerRow) @@ -1076,7 +954,7 @@ void FSFloaterPoser::AddHeaderRowToScrollList(std::string jointName, LLScrollLis hdrRow->setEnabled(FALSE); } -LLSD FSFloaterPoser::createRowForJoint(std::string jointName, bool isHeaderRow) +LLSD FSFloaterPoser::createRowForJoint(const std::string& jointName, bool isHeaderRow) { if (jointName.empty()) return NULL; @@ -1086,7 +964,7 @@ LLSD FSFloaterPoser::createRowForJoint(std::string jointName, bool isHeaderRow) headerValue = isHeaderRow ? getString("icon_category") : getString("icon_bone"); std::string jointValue = jointName; - std::string parameterName = (isHeaderRow ? std::string(XML_LIST_HEADER_STRING_PREFIX) : std::string(XML_LIST_TITLE_STRING_PREFIX)) + jointName; + std::string parameterName = (isHeaderRow ? XML_LIST_HEADER_STRING_PREFIX : XML_LIST_TITLE_STRING_PREFIX) + jointName; if (hasString(parameterName)) jointValue = getString(parameterName); @@ -1102,96 +980,67 @@ LLSD FSFloaterPoser::createRowForJoint(std::string jointName, bool isHeaderRow) void FSFloaterPoser::onToggleLoadSavePanel() { - if (this->isMinimized()) + if (isMinimized()) return; // Get the load/save button toggle state, find the load/save panel, and set its visibility - LLButton *yourPosesButton = getChild(POSER_AVATAR_TOGGLEBUTTON_LOADSAVE); - if (!yourPosesButton) - return; - - bool loadSavePanelExpanded = yourPosesButton->getValue().asBoolean(); - LLUICtrl *loadSavePanel = getChild(POSER_AVATAR_PANEL_LOADSAVE_NAME); - if (!loadSavePanel) - return; - - loadSavePanel->setVisible(loadSavePanelExpanded); - LLButton *loadPosesButton = getChild(POSER_AVATAR_BUTTON_LOAD_NAME); - if (loadPosesButton) - loadPosesButton->setVisible(loadSavePanelExpanded); - - LLButton *savePosesButton = getChild(POSER_AVATAR_BUTTON_SAVE_NAME); - if (savePosesButton) - savePosesButton->setVisible(loadSavePanelExpanded); - - LLButton *exploreFolderButton = getChild(POSER_AVATAR_BUTTON_BROWSEFOLDER_NAME); - if (exploreFolderButton) - exploreFolderButton->setVisible(loadSavePanelExpanded); + bool loadSavePanelExpanded = mToggleLoadSavePanelBtn->getValue().asBoolean(); + mPosesLoadSavePnl->setVisible(loadSavePanelExpanded); + mLoadPosesBtn->setVisible(loadSavePanelExpanded); + mSavePosesBtn->setVisible(loadSavePanelExpanded); + mBrowserFolderBtn->setVisible(loadSavePanelExpanded); // change the width of the Poser panel for the (dis)appearance of the load/save panel - S32 currentWidth = this->getRect().getWidth(); - S32 loadSavePanelWidth = loadSavePanel->getRect().getWidth(); + S32 currentWidth = getRect().getWidth(); + S32 loadSavePanelWidth = mPosesLoadSavePnl->getRect().getWidth(); - S32 poserFloaterHeight = this->getRect().getHeight(); + S32 poserFloaterHeight = getRect().getHeight(); S32 poserFloaterWidth = loadSavePanelExpanded ? currentWidth + loadSavePanelWidth : currentWidth - loadSavePanelWidth; if (poserFloaterWidth < 0) return; - this->reshape(poserFloaterWidth, poserFloaterHeight); + reshape(poserFloaterWidth, poserFloaterHeight); if (loadSavePanelExpanded) - refreshPoseScroll(POSER_AVATAR_SCROLLLIST_LOADSAVE_NAME, POSE_SAVE_SUBDIRECTORY); + refreshPoseScroll(mPosesScrollList); showOrHideAdvancedSaveOptions(); } void FSFloaterPoser::showOrHideAdvancedSaveOptions() { - LLButton* yourPosesButton = getChild(POSER_AVATAR_TOGGLEBUTTON_LOADSAVE); - if (!yourPosesButton) - return; + bool loadSavePanelExpanded = mToggleLoadSavePanelBtn->getValue().asBoolean(); + bool advancedPanelExpanded = mToggleAdvancedPanelBtn->getValue().asBoolean(); - LLButton* advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (!advancedButton) - return; - - LLUICtrl* advSavePanel = getChild(POSER_AVATAR_ADVANCED_SAVEOPTIONSPANEL_NAME); - if (!advSavePanel) - return; - - bool loadSavePanelExpanded = yourPosesButton->getValue().asBoolean(); - bool advancedPanelExpanded = advancedButton->getValue().asBoolean(); - - advSavePanel->setVisible(loadSavePanelExpanded && advancedPanelExpanded); + mSaveFilePptionsPnl->setVisible(loadSavePanelExpanded && advancedPanelExpanded); } -void FSFloaterPoser::onToggleMirrorChange() { setRotationChangeButtons(true, false, false); } +void FSFloaterPoser::onToggleMirrorChange() +{ + setRotationChangeButtons(true, false, false); +} -void FSFloaterPoser::onToggleSympatheticChange() { setRotationChangeButtons(false, true, false); } +void FSFloaterPoser::onToggleSympatheticChange() +{ + setRotationChangeButtons(false, true, false); +} -void FSFloaterPoser::onToggleDeltaModeChange() { setRotationChangeButtons(false, false, true); } +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) - return; - LLButton *toggleSympatheticButton = getChild(POSER_AVATAR_TOGGLEBUTTON_SYMPATH); - if (!toggleSympatheticButton) - return; - LLButton* deltaModeToggleButton = getChild(POSER_AVATAR_BUTTON_DELTAMODE); - if (!deltaModeToggleButton) - return; - if (togglingSympathetic || togglingDelta) - toggleMirrorButton->setValue(false); + mToggleMirrorRotationBtn->setValue(false); if (togglingMirror || togglingDelta) - toggleSympatheticButton->setValue(false); + mToggleSympatheticRotationBtn->setValue(false); if (togglingMirror || togglingSympathetic) - deltaModeToggleButton->setValue(false); + mToggleDeltaModeBtn->setValue(false); refreshTrackpadCursor(); } @@ -1202,7 +1051,7 @@ void FSFloaterPoser::onUndoLastRotation() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1211,9 +1060,9 @@ void FSFloaterPoser::onUndoLastRotation() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.undoLastJointRotation(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.undoLastJointRotation(avatar, *item, getUiSelectedBoneDeflectionStyle()); } enableOrDisableRedoButton(); @@ -1227,7 +1076,7 @@ void FSFloaterPoser::onUndoLastPosition() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1236,9 +1085,9 @@ void FSFloaterPoser::onUndoLastPosition() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.undoLastJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.undoLastJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedPositionSliders(); @@ -1251,7 +1100,7 @@ void FSFloaterPoser::onUndoLastScale() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1260,9 +1109,9 @@ void FSFloaterPoser::onUndoLastScale() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.undoLastJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.undoLastJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedScaleSliders(); @@ -1271,16 +1120,16 @@ void FSFloaterPoser::onUndoLastScale() void FSFloaterPoser::onResetPosition() { // This is a double-click function: it needs to run twice within some amount of time to complete. - auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - _timeLastClickedJointReset; - _timeLastClickedJointReset = std::chrono::system_clock::now(); - if (timeIntervalSinceLastClick > _doubleClickInterval) + auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - mTimeLastClickedJointReset; + mTimeLastClickedJointReset = std::chrono::system_clock::now(); + if (timeIntervalSinceLastClick > mDoubleClickInterval) return; LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1289,9 +1138,9 @@ void FSFloaterPoser::onResetPosition() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.resetJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.resetJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedPositionSliders(); @@ -1301,16 +1150,16 @@ void FSFloaterPoser::onResetPosition() void FSFloaterPoser::onResetScale() { // This is a double-click function: it needs to run twice within some amount of time to complete. - auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - _timeLastClickedJointReset; - _timeLastClickedJointReset = std::chrono::system_clock::now(); - if (timeIntervalSinceLastClick > _doubleClickInterval) + auto timeIntervalSinceLastClick = std::chrono::system_clock::now() - mTimeLastClickedJointReset; + mTimeLastClickedJointReset = std::chrono::system_clock::now(); + if (timeIntervalSinceLastClick > mDoubleClickInterval) return; LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1319,9 +1168,9 @@ void FSFloaterPoser::onResetScale() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.resetJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.resetJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedScaleSliders(); @@ -1333,7 +1182,7 @@ void FSFloaterPoser::onRedoLastRotation() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1342,9 +1191,9 @@ void FSFloaterPoser::onRedoLastRotation() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.redoLastJointRotation(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.redoLastJointRotation(avatar, *item, getUiSelectedBoneDeflectionStyle()); } enableOrDisableRedoButton(); @@ -1358,7 +1207,7 @@ void FSFloaterPoser::onRedoLastPosition() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1367,9 +1216,9 @@ void FSFloaterPoser::onRedoLastPosition() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.redoLastJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.redoLastJointPosition(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedPositionSliders(); @@ -1382,7 +1231,7 @@ void FSFloaterPoser::onRedoLastScale() if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1391,9 +1240,9 @@ void FSFloaterPoser::onRedoLastScale() for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - _poserAnimator.redoLastJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); + mPoserAnimator.redoLastJointScale(avatar, *item, getUiSelectedBoneDeflectionStyle()); } refreshAdvancedScaleSliders(); @@ -1401,15 +1250,11 @@ void FSFloaterPoser::onRedoLastScale() void FSFloaterPoser::enableOrDisableRedoButton() { - LLButton* redoButton = getChild(POSER_AVATAR_BUTTON_REDO); - if (!redoButton) - return; - LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; auto selectedJoints = getUiSelectedPoserJoints(); @@ -1419,127 +1264,99 @@ void FSFloaterPoser::enableOrDisableRedoButton() bool shouldEnableRedoButton = false; for (auto item : selectedJoints) { - bool currentlyPosing = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosing = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (currentlyPosing) - shouldEnableRedoButton |= _poserAnimator.canRedoJointRotation(avatar, *item); + shouldEnableRedoButton |= mPoserAnimator.canRedoJointRotation(avatar, *item); } - redoButton->setEnabled(shouldEnableRedoButton); + mRedoChangeBtn->setEnabled(shouldEnableRedoButton); } void FSFloaterPoser::onOpenSetAdvancedPanel() { - LLButton* advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (!advancedButton) - return; - - bool advancedPanelExpanded = advancedButton->getValue().asBoolean(); + bool advancedPanelExpanded = mToggleAdvancedPanelBtn->getValue().asBoolean(); if (advancedPanelExpanded) onToggleAdvancedPanel(); } void FSFloaterPoser::onToggleAdvancedPanel() { - if (this->isMinimized()) + if (isMinimized()) return; - LLButton *advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (!advancedButton) - return; + bool advancedPanelExpanded = mToggleAdvancedPanelBtn->getValue().asBoolean(); - bool advancedPanelExpanded = advancedButton->getValue().asBoolean(); - LLUICtrl* advancedPanel = getChild(POSER_AVATAR_PANEL_ADVANCED); - if (!advancedPanel) - return; - - advancedPanel->setVisible(advancedPanelExpanded); + mAdvancedParentPnl->setVisible(advancedPanelExpanded); // change the height of the Poser panel - S32 currentHeight = this->getRect().getHeight(); - S32 advancedPanelHeight = advancedPanel->getRect().getHeight(); + S32 currentHeight = getRect().getHeight(); + S32 advancedPanelHeight = mAdvancedParentPnl->getRect().getHeight(); S32 poserFloaterHeight = advancedPanelExpanded ? currentHeight + advancedPanelHeight : currentHeight - advancedPanelHeight; - S32 poserFloaterWidth = this->getRect().getWidth(); + S32 poserFloaterWidth = getRect().getWidth(); if (poserFloaterHeight < 0) return; - this->reshape(poserFloaterWidth, poserFloaterHeight); + reshape(poserFloaterWidth, poserFloaterHeight); showOrHideAdvancedSaveOptions(); onJointSelect(); } -std::vector FSFloaterPoser::getUiSelectedPoserJoints() const +std::vector FSFloaterPoser::getUiSelectedPoserJoints() const { - std::vector joints; + std::vector joints; - LLTabContainer *tabGroup = getChild(POSER_AVATAR_TABGROUP_JOINTS); - if (!tabGroup) + auto activeTab = mJointsTabs->getCurrentPanel(); + if (!activeTab) { return joints; } - std::string activeTabName = tabGroup->getCurrentPanel()->getName(); - if (activeTabName.empty()) - { - return joints; - } + LLScrollListCtrl* scrollList{ nullptr }; - std::string scrollListName; - - if (boost::iequals(activeTabName, POSER_AVATAR_TAB_POSITION)) + if (activeTab == mPositionRotationPnl) { - scrollListName = POSER_AVATAR_SCROLLLIST_HIDDEN_NAME; + scrollList = mEntireAvJointScroll; } - else if (boost::iequals(activeTabName, POSER_AVATAR_TAB_BODY)) + else if (activeTab == mBodyJointsPnl) { - scrollListName = POSER_AVATAR_SCROLLLIST_BODYJOINTS_NAME; + scrollList = mBodyJointsScrollList; } - else if (boost::iequals(activeTabName, POSER_AVATAR_TAB_FACE)) + else if (activeTab == mFaceJointsPnl) { - scrollListName = POSER_AVATAR_SCROLLLIST_FACEJOINTS_NAME; + scrollList = mFaceJointsScrollList; } - else if (boost::iequals(activeTabName, POSER_AVATAR_TAB_HANDS)) + else if (activeTab == mHandsTabs) { - tabGroup = getChild(POSER_AVATAR_TAB_HANDS); - if (!tabGroup) + auto activeHandsSubTab = mHandsTabs->getCurrentPanel(); + if (!activeHandsSubTab) { return joints; } - activeTabName = tabGroup->getCurrentPanel()->getName(); - if (activeTabName.empty()) + if (activeHandsSubTab == mHandsJointsPnl) { - return joints; - } - - if (boost::iequals(activeTabName, POSER_AVATAR_TAB_HANDJOINTS)) - { - scrollListName = POSER_AVATAR_SCROLLLIST_HANDJOINTS_NAME; + scrollList = mHandJointsScrollList; } } - else if (boost::iequals(activeTabName, POSER_AVATAR_TAB_MISC)) + else if (activeTab == mMiscJointsPnl) { - scrollListName = POSER_AVATAR_SCROLLLIST_MISCJOINTS_NAME; + scrollList = mMiscJointsScrollList; } - else if (boost::iequals(activeTabName, POSER_AVATAR_TAB_VOLUMES)) + else if (activeTab == mCollisionVolumesPnl) { - scrollListName = POSER_AVATAR_SCROLLLIST_VOLUMES_NAME; + scrollList = mCollisionVolumesScrollList; } - if (scrollListName.empty()) - { - return joints; - } - - LLScrollListCtrl *scrollList = getChild(scrollListName); if (!scrollList) { return joints; } + for (auto item : scrollList->getAllSelected()) { - auto *userData = static_cast(item->getUserdata()); + auto* userData = static_cast(item->getUserdata()); if (userData) { joints.push_back(userData); @@ -1549,27 +1366,17 @@ std::vector FSFloaterPoser::getUiSelectedPoserJ return joints; } -E_BoneDeflectionStyles FSFloaterPoser::getUiSelectedBoneDeflectionStyle() +E_BoneDeflectionStyles FSFloaterPoser::getUiSelectedBoneDeflectionStyle() const { - - // Use early return to reduce nesting and improve readability - auto* toggleMirrorButton = getChild(POSER_AVATAR_TOGGLEBUTTON_MIRROR); - auto* toggleSympatheticButton = getChild(POSER_AVATAR_TOGGLEBUTTON_SYMPATH); - auto* deltaModeToggleButton = getChild(POSER_AVATAR_BUTTON_DELTAMODE); - if (!toggleMirrorButton || !toggleSympatheticButton || !deltaModeToggleButton) - { - return NONE; - } - - if (toggleMirrorButton->getValue().asBoolean()) + if (mToggleMirrorRotationBtn->getValue().asBoolean()) { return MIRROR; } - if (toggleSympatheticButton->getValue().asBoolean()) + if (mToggleSympatheticRotationBtn->getValue().asBoolean()) { return SYMPATHETIC; } - if (deltaModeToggleButton->getValue().asBoolean()) + if (mToggleDeltaModeBtn->getValue().asBoolean()) { return DELTAMODE; } @@ -1577,13 +1384,9 @@ E_BoneDeflectionStyles FSFloaterPoser::getUiSelectedBoneDeflectionStyle() return NONE; } -LLVOAvatar* FSFloaterPoser::getUiSelectedAvatar() +LLVOAvatar* FSFloaterPoser::getUiSelectedAvatar() const { - LLScrollListCtrl *avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return nullptr; - - LLScrollListItem *item = avatarScrollList->getFirstSelected(); + LLScrollListItem* item = mAvatarSelectionScrollList->getFirstSelected(); if (!item) return nullptr; @@ -1598,11 +1401,7 @@ LLVOAvatar* FSFloaterPoser::getUiSelectedAvatar() void FSFloaterPoser::setPoseSaveFileTextBoxToUiSelectedAvatarSaveFileName() { - LLScrollListCtrl* avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return; - - LLScrollListItem* item = avatarScrollList->getFirstSelected(); + LLScrollListItem* item = mAvatarSelectionScrollList->getFirstSelected(); if (!item) return; @@ -1614,21 +1413,13 @@ void FSFloaterPoser::setPoseSaveFileTextBoxToUiSelectedAvatarSaveFileName() if (lastSetName.empty()) return; - LLLineEditor* poseSaveName = getChild(POSER_AVATAR_LINEEDIT_FILESAVENAME); - if (!poseSaveName) - return; - LLStringExplicit name = LLStringExplicit(lastSetName); - poseSaveName->setText(name); + mPoseSaveNameEditor->setText(name); } -void FSFloaterPoser::setUiSelectedAvatarSaveFileName(std::string saveFileName) +void FSFloaterPoser::setUiSelectedAvatarSaveFileName(const std::string& saveFileName) { - LLScrollListCtrl *avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return; - - LLScrollListItem *item = avatarScrollList->getFirstSelected(); + LLScrollListItem* item = mAvatarSelectionScrollList->getFirstSelected(); if (!item) return; @@ -1639,7 +1430,7 @@ void FSFloaterPoser::setUiSelectedAvatarSaveFileName(std::string saveFileName) return cell->setValue(saveFileName); } -LLVOAvatar* FSFloaterPoser::getAvatarByUuid(LLUUID avatarToFind) +LLVOAvatar* FSFloaterPoser::getAvatarByUuid(const LLUUID& avatarToFind) const { for (LLCharacter* character : LLCharacter::sInstances) { @@ -1655,15 +1446,9 @@ LLVOAvatar* FSFloaterPoser::getAvatarByUuid(LLUUID avatarToFind) void FSFloaterPoser::onAdvancedPositionSet() { - LLSliderCtrl *xposAdvSlider = getChild(POSER_AVATAR_ADV_SLIDER_POSX_NAME); - LLSliderCtrl *yposAdvSlider = getChild(POSER_AVATAR_ADV_SLIDER_POSY_NAME); - LLSliderCtrl *zposAdvSlider = getChild(POSER_AVATAR_ADV_SLIDER_POSZ_NAME); - if (!xposAdvSlider || !yposAdvSlider || !zposAdvSlider) - return; - - F32 posX = (F32) xposAdvSlider->getValue().asReal(); - F32 posY = (F32) yposAdvSlider->getValue().asReal(); - F32 posZ = (F32) zposAdvSlider->getValue().asReal(); + F32 posX = (F32)mAdvPosXSlider->getValue().asReal(); + F32 posY = (F32)mAdvPosYSlider->getValue().asReal(); + F32 posZ = (F32)mAdvPosZSlider->getValue().asReal(); setSelectedJointsPosition(posX, posY, posZ); refreshAvatarPositionSliders(); @@ -1671,30 +1456,18 @@ void FSFloaterPoser::onAdvancedPositionSet() void FSFloaterPoser::onAdvancedScaleSet() { - LLSliderCtrl *scalex = getChild(POSER_AVATAR_ADV_SLIDER_SCALEX_NAME); - LLSliderCtrl *scaley = getChild(POSER_AVATAR_ADV_SLIDER_SCALEY_NAME); - LLSliderCtrl *scalez = getChild(POSER_AVATAR_ADV_SLIDER_SCALEZ_NAME); - if (!scalex || !scaley || !scalez) - return; - - F32 scX = (F32) scalex->getValue().asReal(); - F32 scY = (F32) scaley->getValue().asReal(); - F32 scZ = (F32) scalez->getValue().asReal(); + F32 scX = (F32)mAdvScaleXSlider->getValue().asReal(); + F32 scY = (F32)mAdvScaleYSlider->getValue().asReal(); + F32 scZ = (F32)mAdvScaleZSlider->getValue().asReal(); setSelectedJointsScale(scX, scY, scZ); } void FSFloaterPoser::onAvatarPositionSet() { - LLSliderCtrl *xposSlider = getChild(POSER_AVATAR_SLIDER_POSX_NAME); - LLSliderCtrl *yposSlider = getChild(POSER_AVATAR_SLIDER_POSY_NAME); - LLSliderCtrl *zposSlider = getChild(POSER_AVATAR_SLIDER_POSZ_NAME); - if (!xposSlider || !yposSlider || !zposSlider) - return; - - F32 posX = (F32) xposSlider->getValue().asReal(); - F32 posY = (F32) yposSlider->getValue().asReal(); - F32 posZ = (F32) zposSlider->getValue().asReal(); + F32 posX = (F32)mPosXSlider->getValue().asReal(); + F32 posY = (F32)mPosYSlider->getValue().asReal(); + F32 posZ = (F32)mPosZSlider->getValue().asReal(); setSelectedJointsPosition(posX, posY, posZ); refreshAdvancedPositionSliders(); @@ -1702,12 +1475,8 @@ void FSFloaterPoser::onAvatarPositionSet() void FSFloaterPoser::onLimbTrackballChanged() { - FSVirtualTrackpad *trackBall = getChild(POSER_AVATAR_TRACKBALL_NAME); - if (!trackBall) - return; - LLVector3 trackPadPos; - LLSD position = trackBall->getValue(); + LLSD position = mAvatarTrackball->getValue(); if (position.isArray() && position.size() == 3) trackPadPos.setValue(position); else @@ -1723,26 +1492,21 @@ void FSFloaterPoser::onLimbTrackballChanged() pitch *= trackPadSensitivity; // if the trackpad is in 'infinite scroll' mode, it can produce normalized-values outside the range of the sliders; this wraps them to by the slider full-scale - yaw = unWrapScale(yaw) * normalTrackpadRangeInRads; - pitch = unWrapScale(pitch) * normalTrackpadRangeInRads; - roll = unWrapScale(roll) * normalTrackpadRangeInRads; + yaw = unWrapScale(yaw) * NormalTrackpadRangeInRads; + pitch = unWrapScale(pitch) * NormalTrackpadRangeInRads; + roll = unWrapScale(roll) * NormalTrackpadRangeInRads; - bool deltaMode = false; - LLButton* deltaModeToggleButton = getChild(POSER_AVATAR_BUTTON_DELTAMODE); - if (deltaModeToggleButton) - deltaMode = deltaModeToggleButton->getValue().asBoolean(); - - if (deltaMode) + if (mToggleDeltaModeBtn->getValue().asBoolean()) { F32 deltaYaw, deltaPitch, deltaRoll; - LLSD deltaPosition = trackBall->getValueDelta(); + LLSD deltaPosition = mAvatarTrackball->getValueDelta(); LLVector3 trackPadDeltaPos; if (deltaPosition.isArray() && deltaPosition.size() == 3) { trackPadDeltaPos.setValue(deltaPosition); - deltaYaw = trackPadDeltaPos[VX] * normalTrackpadRangeInRads; - deltaPitch = trackPadDeltaPos[VY] * normalTrackpadRangeInRads; - deltaRoll = trackPadDeltaPos[VZ] * normalTrackpadRangeInRads; + deltaYaw = trackPadDeltaPos[VX] * NormalTrackpadRangeInRads; + deltaPitch = trackPadDeltaPos[VY] * NormalTrackpadRangeInRads; + deltaRoll = trackPadDeltaPos[VZ] * NormalTrackpadRangeInRads; deltaYaw *= trackPadSensitivity; deltaPitch *= trackPadSensitivity; @@ -1750,21 +1514,17 @@ void FSFloaterPoser::onLimbTrackballChanged() } } else + { setSelectedJointsRotation(yaw, pitch, roll); + } // WARNING! // as tempting as it is to refactor the following to refreshRotationSliders(), don't. // getRotationOfFirstSelectedJoint/setSelectedJointsRotation are // not necessarily symmetric functions (see their remarks). - LLSliderCtrl *yawSlider = getChild(POSER_AVATAR_SLIDER_YAW_NAME); - LLSliderCtrl *pitchSlider = getChild(POSER_AVATAR_SLIDER_PITCH_NAME); - LLSliderCtrl* rollSlider = getChild(POSER_AVATAR_SLIDER_ROLL_NAME); - if (!yawSlider || !pitchSlider || !rollSlider) - return; - - yawSlider->setValue(yaw *= RAD_TO_DEG); - pitchSlider->setValue(pitch *= RAD_TO_DEG); - rollSlider->setValue(roll *= RAD_TO_DEG); + mLimbYawSlider->setValue(yaw *= RAD_TO_DEG); + mLimbPitchSlider->setValue(pitch *= RAD_TO_DEG); + mLimbRollSlider->setValue(roll *= RAD_TO_DEG); } F32 FSFloaterPoser::unWrapScale(F32 scale) @@ -1783,15 +1543,9 @@ F32 FSFloaterPoser::unWrapScale(F32 scale) void FSFloaterPoser::onLimbYawPitchRollChanged() { - LLSliderCtrl *yawSlider = getChild(POSER_AVATAR_SLIDER_YAW_NAME); - LLSliderCtrl *pitchSlider = getChild(POSER_AVATAR_SLIDER_PITCH_NAME); - LLSliderCtrl *rollSlider = getChild(POSER_AVATAR_SLIDER_ROLL_NAME); - if (!yawSlider || !pitchSlider || !rollSlider) - return; - - F32 yaw = (F32) yawSlider->getValue().asReal(); - F32 pitch = (F32) pitchSlider->getValue().asReal(); - F32 roll = (F32) rollSlider->getValue().asReal(); + F32 yaw = (F32)mLimbYawSlider->getValue().asReal(); + F32 pitch = (F32)mLimbPitchSlider->getValue().asReal(); + F32 roll = (F32)mLimbRollSlider->getValue().asReal(); yaw *= DEG_TO_RAD; pitch *= DEG_TO_RAD; @@ -1803,60 +1557,42 @@ void FSFloaterPoser::onLimbYawPitchRollChanged() // as tempting as it is to refactor the following to refreshTrackpadCursor(), don't. // getRotationOfFirstSelectedJoint/setSelectedJointsRotation are // not necessarily symmetric functions (see their remarks). - FSVirtualTrackpad *trackBall = getChild(POSER_AVATAR_TRACKBALL_NAME); - if (!trackBall) - return; - F32 trackPadSensitivity = llmax(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY), 0.0001f); yaw /= trackPadSensitivity; pitch /= trackPadSensitivity; - yaw /= normalTrackpadRangeInRads; - pitch /= normalTrackpadRangeInRads; - roll /= normalTrackpadRangeInRads; + yaw /= NormalTrackpadRangeInRads; + pitch /= NormalTrackpadRangeInRads; + roll /= NormalTrackpadRangeInRads; - trackBall->setValue(yaw, pitch, roll); + mAvatarTrackball->setValue(yaw, pitch, roll); } void FSFloaterPoser::onAdjustTrackpadSensitivity() { - LLSliderCtrl* trackpadSensitivitySlider = getChild(POSER_TRACKPAD_SENSITIVITY_SLIDER_NAME); - if (!trackpadSensitivitySlider) - return; - - gSavedSettings.setF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY, (F32) trackpadSensitivitySlider->getValue().asReal()); + gSavedSettings.setF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY, (F32)mTrackpadSensitivitySlider->getValue().asReal()); refreshTrackpadCursor(); } void FSFloaterPoser::refreshTrackpadCursor() { - FSVirtualTrackpad *trackBall = getChild(POSER_AVATAR_TRACKBALL_NAME); - if (!trackBall) - return; - - LLSliderCtrl* yawSlider = getChild(POSER_AVATAR_SLIDER_YAW_NAME); - LLSliderCtrl* pitchSlider = getChild(POSER_AVATAR_SLIDER_PITCH_NAME); - LLSliderCtrl* rollSlider = getChild(POSER_AVATAR_SLIDER_ROLL_NAME); - if (!yawSlider || !pitchSlider || !rollSlider) - return; - - F32 axis1 = (F32) yawSlider->getValue().asReal(); - F32 axis2 = (F32) pitchSlider->getValue().asReal(); - F32 axis3 = (F32) rollSlider->getValue().asReal(); + F32 axis1 = (F32)mLimbYawSlider->getValue().asReal(); + F32 axis2 = (F32)mLimbPitchSlider->getValue().asReal(); + F32 axis3 = (F32)mLimbRollSlider->getValue().asReal(); axis1 *= DEG_TO_RAD; axis2 *= DEG_TO_RAD; axis3 *= DEG_TO_RAD; - axis1 /= normalTrackpadRangeInRads; - axis2 /= normalTrackpadRangeInRads; - axis3 /= normalTrackpadRangeInRads; + axis1 /= NormalTrackpadRangeInRads; + axis2 /= NormalTrackpadRangeInRads; + axis3 /= NormalTrackpadRangeInRads; F32 trackPadSensitivity = llmax(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY), 0.0001f); axis1 /= trackPadSensitivity; axis2 /= trackPadSensitivity; - trackBall->setValue(axis1, axis2, axis3); + mAvatarTrackball->setValue(axis1, axis2, axis3); } /// @@ -1864,73 +1600,44 @@ void FSFloaterPoser::refreshTrackpadCursor() /// void FSFloaterPoser::refreshAvatarPositionSliders() { - LLTabContainer *jointTabGroup = getChild(POSER_AVATAR_TABGROUP_JOINTS); - if (!jointTabGroup) + auto activeTab = mJointsTabs->getCurrentPanel(); + if (!activeTab) return; - std::string activeTabName = jointTabGroup->getCurrentPanel()->getName(); - if (activeTabName.empty()) - return; - - if (!boost::iequals(activeTabName, POSER_AVATAR_TAB_POSITION)) + if (activeTab != mPositionRotationPnl) return; // if the active tab isn't the av position one, don't set anything. - LLSliderCtrl *xSlider = getChild(POSER_AVATAR_SLIDER_POSX_NAME); - LLSliderCtrl *ySlider = getChild(POSER_AVATAR_SLIDER_POSY_NAME); - LLSliderCtrl *zSlider = getChild(POSER_AVATAR_SLIDER_POSZ_NAME); - if (!xSlider || !ySlider || !zSlider) - return; - LLVector3 position = getPositionOfFirstSelectedJoint(); - - xSlider->setValue(position.mV[VX]); - ySlider->setValue(position.mV[VY]); - zSlider->setValue(position.mV[VZ]); + mPosXSlider->setValue(position.mV[VX]); + mPosYSlider->setValue(position.mV[VY]); + mPosZSlider->setValue(position.mV[VZ]); } void FSFloaterPoser::refreshRotationSliders() { - LLSliderCtrl *yawSlider = getChild(POSER_AVATAR_SLIDER_YAW_NAME); - LLSliderCtrl *pitchSlider = getChild(POSER_AVATAR_SLIDER_PITCH_NAME); - LLSliderCtrl *rollSlider = getChild(POSER_AVATAR_SLIDER_ROLL_NAME); - if (!yawSlider || !pitchSlider || !rollSlider) - return; - LLVector3 rotation = getRotationOfFirstSelectedJoint(); - yawSlider->setValue(rotation.mV[VX] *= RAD_TO_DEG); - pitchSlider->setValue(rotation.mV[VY] *= RAD_TO_DEG); - rollSlider->setValue(rotation.mV[VZ] *= RAD_TO_DEG); + mLimbYawSlider->setValue(rotation.mV[VX] *= RAD_TO_DEG); + mLimbPitchSlider->setValue(rotation.mV[VY] *= RAD_TO_DEG); + mLimbRollSlider->setValue(rotation.mV[VZ] *= RAD_TO_DEG); } void FSFloaterPoser::refreshAdvancedPositionSliders() { - LLSliderCtrl *xSlider = getChild(POSER_AVATAR_ADV_SLIDER_POSX_NAME); - LLSliderCtrl *ySlider = getChild(POSER_AVATAR_ADV_SLIDER_POSY_NAME); - LLSliderCtrl *zSlider = getChild(POSER_AVATAR_ADV_SLIDER_POSZ_NAME); - if (!xSlider || !ySlider || !zSlider) - return; - LLVector3 position = getPositionOfFirstSelectedJoint(); - xSlider->setValue(position.mV[VX]); - ySlider->setValue(position.mV[VY]); - zSlider->setValue(position.mV[VZ]); + mAdvPosXSlider->setValue(position.mV[VX]); + mAdvPosYSlider->setValue(position.mV[VY]); + mAdvPosZSlider->setValue(position.mV[VZ]); } void FSFloaterPoser::refreshAdvancedScaleSliders() { - LLSliderCtrl *xSlider = getChild(POSER_AVATAR_ADV_SLIDER_SCALEX_NAME); - LLSliderCtrl *ySlider = getChild(POSER_AVATAR_ADV_SLIDER_SCALEY_NAME); - LLSliderCtrl *zSlider = getChild(POSER_AVATAR_ADV_SLIDER_SCALEZ_NAME); - if (!xSlider || !ySlider || !zSlider) - return; - LLVector3 rotation = getScaleOfFirstSelectedJoint(); - xSlider->setValue(rotation.mV[VX]); - ySlider->setValue(rotation.mV[VY]); - zSlider->setValue(rotation.mV[VZ]); + mAdvScaleXSlider->setValue(rotation.mV[VX]); + mAdvScaleYSlider->setValue(rotation.mV[VY]); + mAdvScaleZSlider->setValue(rotation.mV[VZ]); } void FSFloaterPoser::setSelectedJointsPosition(F32 x, F32 y, F32 z) @@ -1939,7 +1646,7 @@ void FSFloaterPoser::setSelectedJointsPosition(F32 x, F32 y, F32 z) if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; E_BoneDeflectionStyles defl = getUiSelectedBoneDeflectionStyle(); @@ -1947,11 +1654,11 @@ void FSFloaterPoser::setSelectedJointsPosition(F32 x, F32 y, F32 z) for (auto item : getUiSelectedPoserJoints()) { - bool currentlyPosingJoint = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosingJoint = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (!currentlyPosingJoint) continue; - _poserAnimator.setJointPosition(avatar, item, vec3, defl); + mPoserAnimator.setJointPosition(avatar, item, vec3, defl); } } @@ -1961,7 +1668,7 @@ void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadi if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; E_BoneDeflectionStyles defl = getUiSelectedBoneDeflectionStyle(); @@ -1969,11 +1676,11 @@ void FSFloaterPoser::setSelectedJointsRotation(F32 yawInRadians, F32 pitchInRadi for (auto item : getUiSelectedPoserJoints()) { - bool currentlyPosingJoint = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosingJoint = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (!currentlyPosingJoint) continue; - _poserAnimator.setJointRotation(avatar, item, vec3, defl, getJointTranslation(item->jointName()), + mPoserAnimator.setJointRotation(avatar, item, vec3, defl, getJointTranslation(item->jointName()), getJointNegation(item->jointName())); } } @@ -1984,7 +1691,7 @@ void FSFloaterPoser::setSelectedJointsScale(F32 x, F32 y, F32 z) if (!avatar) return; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return; E_BoneDeflectionStyles defl = getUiSelectedBoneDeflectionStyle(); @@ -1992,15 +1699,15 @@ void FSFloaterPoser::setSelectedJointsScale(F32 x, F32 y, F32 z) for (auto item : getUiSelectedPoserJoints()) { - bool currentlyPosingJoint = _poserAnimator.isPosingAvatarJoint(avatar, *item); + bool currentlyPosingJoint = mPoserAnimator.isPosingAvatarJoint(avatar, *item); if (!currentlyPosingJoint) continue; - _poserAnimator.setJointScale(avatar, item, vec3, defl); + mPoserAnimator.setJointScale(avatar, item, vec3, defl); } } -LLVector3 FSFloaterPoser::getRotationOfFirstSelectedJoint() +LLVector3 FSFloaterPoser::getRotationOfFirstSelectedJoint() const { LLVector3 rotation; auto selectedJoints = getUiSelectedPoserJoints(); @@ -2011,16 +1718,16 @@ LLVector3 FSFloaterPoser::getRotationOfFirstSelectedJoint() if (!avatar) return rotation; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return rotation; - rotation = _poserAnimator.getJointRotation(avatar, *selectedJoints.front(), getJointTranslation(selectedJoints.front()->jointName()), + rotation = mPoserAnimator.getJointRotation(avatar, *selectedJoints.front(), getJointTranslation(selectedJoints.front()->jointName()), getJointNegation(selectedJoints.front()->jointName())); return rotation; } -LLVector3 FSFloaterPoser::getPositionOfFirstSelectedJoint() +LLVector3 FSFloaterPoser::getPositionOfFirstSelectedJoint() const { LLVector3 position; auto selectedJoints = getUiSelectedPoserJoints(); @@ -2031,14 +1738,14 @@ LLVector3 FSFloaterPoser::getPositionOfFirstSelectedJoint() if (!avatar) return position; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return position; - position = _poserAnimator.getJointPosition(avatar, *selectedJoints.front()); + position = mPoserAnimator.getJointPosition(avatar, *selectedJoints.front()); return position; } -LLVector3 FSFloaterPoser::getScaleOfFirstSelectedJoint() +LLVector3 FSFloaterPoser::getScaleOfFirstSelectedJoint() const { LLVector3 scale; auto selectedJoints = getUiSelectedPoserJoints(); @@ -2049,10 +1756,10 @@ LLVector3 FSFloaterPoser::getScaleOfFirstSelectedJoint() if (!avatar) return scale; - if (!_poserAnimator.isPosingAvatar(avatar)) + if (!mPoserAnimator.isPosingAvatar(avatar)) return scale; - scale = _poserAnimator.getJointScale(avatar, *selectedJoints.front()); + scale = mPoserAnimator.getJointScale(avatar, *selectedJoints.front()); return scale; } @@ -2063,27 +1770,23 @@ void FSFloaterPoser::onJointSelect() refreshTrackpadCursor(); enableOrDisableRedoButton(); - LLButton *advancedButton = getChild(POSER_AVATAR_ADVANCED_TOGGLEBUTTON_NAME); - if (!advancedButton) - return; - - if (advancedButton->getValue().asBoolean()) + if (mToggleAdvancedPanelBtn->getValue().asBoolean()) { refreshAdvancedPositionSliders(); refreshAdvancedScaleSliders(); } } -E_BoneAxisTranslation FSFloaterPoser::getJointTranslation(std::string jointName) +E_BoneAxisTranslation FSFloaterPoser::getJointTranslation(const std::string& jointName) const { if (jointName.empty()) return SWAP_NOTHING; - bool hasTransformParameter = hasString(std::string(XML_JOINT_TRANSFORM_STRING_PREFIX) + jointName); + bool hasTransformParameter = hasString(XML_JOINT_TRANSFORM_STRING_PREFIX + jointName); if (!hasTransformParameter) return SWAP_NOTHING; - std::string paramValue = getString(std::string(XML_JOINT_TRANSFORM_STRING_PREFIX) + jointName); + std::string paramValue = getString(XML_JOINT_TRANSFORM_STRING_PREFIX + jointName); if (strstr(paramValue.c_str(), "SWAP_YAW_AND_ROLL")) return SWAP_YAW_AND_ROLL; @@ -2099,18 +1802,18 @@ E_BoneAxisTranslation FSFloaterPoser::getJointTranslation(std::string jointName) return SWAP_NOTHING; } -S32 FSFloaterPoser::getJointNegation(std::string jointName) +S32 FSFloaterPoser::getJointNegation(const std::string& jointName) const { S32 result = NEGATE_NOTHING; if (jointName.empty()) return result; - bool hasTransformParameter = hasString(std::string(XML_JOINT_TRANSFORM_STRING_PREFIX) + jointName); + bool hasTransformParameter = hasString(XML_JOINT_TRANSFORM_STRING_PREFIX + jointName); if (!hasTransformParameter) return result; - std::string paramValue = getString(std::string(XML_JOINT_TRANSFORM_STRING_PREFIX) + jointName); + std::string paramValue = getString(XML_JOINT_TRANSFORM_STRING_PREFIX + jointName); if (strstr(paramValue.c_str(), "NEGATE_YAW")) result |= NEGATE_YAW; @@ -2130,25 +1833,18 @@ S32 FSFloaterPoser::getJointNegation(std::string jointName) /// void FSFloaterPoser::onAvatarSelect() { - LLButton *startStopButton = getChild(POSER_AVATAR_STARTSTOP_POSING_BUTTON_NAME); - if (!startStopButton) - return; + LLVOAvatar* avatar = getUiSelectedAvatar(); + mStartStopPosingBtn->setEnabled(couldAnimateAvatar(avatar)); - LLVOAvatar *avatar = getUiSelectedAvatar(); - if (couldAnimateAvatar(avatar)) - startStopButton->setEnabled(true); - else - startStopButton->setEnabled(false); - - bool arePosingSelected = _poserAnimator.isPosingAvatar(avatar); - startStopButton->setValue(arePosingSelected); + bool arePosingSelected = mPoserAnimator.isPosingAvatar(avatar); + mStartStopPosingBtn->setValue(arePosingSelected); poseControlsEnable(arePosingSelected); refreshTextEmbiggeningOnAllScrollLists(); onJointSelect(); setPoseSaveFileTextBoxToUiSelectedAvatarSaveFileName(); } -uuid_vec_t FSFloaterPoser::getNearbyAvatarsAndAnimeshes() +uuid_vec_t FSFloaterPoser::getNearbyAvatarsAndAnimeshes() const { uuid_vec_t avatar_ids; @@ -2164,15 +1860,11 @@ uuid_vec_t FSFloaterPoser::getNearbyAvatarsAndAnimeshes() return avatar_ids; } -uuid_vec_t FSFloaterPoser::getCurrentlyListedAvatarsAndAnimeshes() +uuid_vec_t FSFloaterPoser::getCurrentlyListedAvatarsAndAnimeshes() const { uuid_vec_t avatar_ids; - LLScrollListCtrl* avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return avatar_ids; - - for (auto listItem : avatarScrollList->getAllData()) + for (auto listItem : mAvatarSelectionScrollList->getAllData()) { LLScrollListCell* cell = listItem->getColumn(COL_UUID); if (!cell) @@ -2185,14 +1877,10 @@ uuid_vec_t FSFloaterPoser::getCurrentlyListedAvatarsAndAnimeshes() return avatar_ids; } -S32 FSFloaterPoser::getAvatarListIndexForUuid(LLUUID toFind) +S32 FSFloaterPoser::getAvatarListIndexForUuid(const LLUUID& toFind) const { - LLScrollListCtrl* avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return -1; - S32 result = -1; - for (auto listItem : avatarScrollList->getAllData()) + for (auto listItem : mAvatarSelectionScrollList->getAllData()) { result++; @@ -2210,10 +1898,6 @@ S32 FSFloaterPoser::getAvatarListIndexForUuid(LLUUID toFind) void FSFloaterPoser::onAvatarsRefresh() { - LLScrollListCtrl *avatarScrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (!avatarScrollList) - return; - uuid_vec_t avatarsToAddToList, avatarsToRemoveFromList; uuid_vec_t nearbyAvatarIds = getNearbyAvatarsAndAnimeshes(); uuid_vec_t currentlyListedAvatars = getCurrentlyListedAvatarsAndAnimeshes(); @@ -2223,7 +1907,7 @@ void FSFloaterPoser::onAvatarsRefresh() { S32 indexToRemove = getAvatarListIndexForUuid(toRemove); if (indexToRemove >= 0) - avatarScrollList->deleteSingleItem(indexToRemove); + mAvatarSelectionScrollList->deleteSingleItem(indexToRemove); } std::string iconCatagoryName = "Inv_BodyShape"; @@ -2262,7 +1946,7 @@ void FSFloaterPoser::onAvatarsRefresh() row["columns"][COL_UUID]["value"] = uuid; row["columns"][COL_SAVE]["column"] = "saveFileName"; row["columns"][COL_SAVE]["value"] = ""; - LLScrollListItem *item = avatarScrollList->addElement(row); + LLScrollListItem* item = mAvatarSelectionScrollList->addElement(row); } // Add Animesh avatars @@ -2286,58 +1970,53 @@ void FSFloaterPoser::onAvatarsRefresh() row["columns"][COL_UUID]["value"] = avatar->getID(); row["columns"][COL_SAVE]["column"] = "saveFileName"; row["columns"][COL_SAVE]["value"] = ""; - avatarScrollList->addElement(row); + mAvatarSelectionScrollList->addElement(row); } - avatarScrollList->updateLayout(); + mAvatarSelectionScrollList->updateLayout(); refreshTextEmbiggeningOnAllScrollLists(); } void FSFloaterPoser::refreshTextEmbiggeningOnAllScrollLists() { - LLScrollListCtrl *scrollList = getChild(POSER_AVATAR_SCROLLLIST_AVATARSELECTION); - if (scrollList) + // the avatars + for (auto listItem : mAvatarSelectionScrollList->getAllData()) { - // the avatars - for (auto listItem : scrollList->getAllData()) - { - LLScrollListCell* cell = listItem->getColumn(COL_UUID); - if (!cell) - continue; + LLScrollListCell* cell = listItem->getColumn(COL_UUID); + if (!cell) + continue; - LLUUID selectedAvatarId = cell->getValue().asUUID(); - LLVOAvatar* listAvatar = getAvatarByUuid(selectedAvatarId); + LLUUID selectedAvatarId = cell->getValue().asUUID(); + LLVOAvatar* listAvatar = getAvatarByUuid(selectedAvatarId); - if (_poserAnimator.isPosingAvatar(listAvatar)) - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); - else - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); - } + if (mPoserAnimator.isPosingAvatar(listAvatar)) + ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); + else + ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); } LLVOAvatar *avatar = getUiSelectedAvatar(); - addBoldToScrollList(std::string(POSER_AVATAR_SCROLLLIST_BODYJOINTS_NAME), avatar); - addBoldToScrollList(std::string(POSER_AVATAR_SCROLLLIST_FACEJOINTS_NAME), avatar); - addBoldToScrollList(std::string(POSER_AVATAR_SCROLLLIST_HANDJOINTS_NAME), avatar); - addBoldToScrollList(std::string(POSER_AVATAR_SCROLLLIST_MISCJOINTS_NAME), avatar); - addBoldToScrollList(std::string(POSER_AVATAR_SCROLLLIST_VOLUMES_NAME), avatar); + addBoldToScrollList(mBodyJointsScrollList, avatar); + addBoldToScrollList(mFaceJointsScrollList, avatar); + addBoldToScrollList(mHandJointsScrollList, avatar); + addBoldToScrollList(mMiscJointsScrollList, avatar); + addBoldToScrollList(mCollisionVolumesScrollList, avatar); } -void FSFloaterPoser::addBoldToScrollList(std::string listName, LLVOAvatar *avatar) +void FSFloaterPoser::addBoldToScrollList(LLScrollListCtrl* list, LLVOAvatar* avatar) { if (!avatar) return; - LLScrollListCtrl *scrollList = getChild(listName); - if (!scrollList) + if (!list) return; - for (auto listItem : scrollList->getAllData()) + for (auto listItem : list->getAllData()) { FSPoserAnimator::FSPoserJoint *userData = static_cast(listItem->getUserdata()); if (userData) { - if (_poserAnimator.isPosingAvatarJoint(avatar, *userData)) + if (mPoserAnimator.isPosingAvatarJoint(avatar, *userData)) ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); else ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); diff --git a/indra/newview/fsfloaterposer.h b/indra/newview/fsfloaterposer.h index ab610c63a6..be3481e9e5 100644 --- a/indra/newview/fsfloaterposer.h +++ b/indra/newview/fsfloaterposer.h @@ -31,6 +31,14 @@ #include "llfloater.h" #include "fsposeranimator.h" +class FSVirtualTrackpad; +class LLButton; +class LLCheckBoxCtrl; +class LLLineEditor; +class LLScrollListCtrl; +class LLSliderCtrl; +class LLTabContainer; + /// /// Describes how to load a pose file. /// @@ -68,23 +76,16 @@ class FSFloaterPoser : public LLFloater friend class LLFloaterReg; FSFloaterPoser(const LLSD &key); - private: - /*virtual*/ ~FSFloaterPoser(); - /*virtual*/ bool postBuild(); - /*virtual*/ void draw(); - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); + private: + bool postBuild() override; + void onOpen(const LLSD& key) override; + void onClose(bool app_quitting) override; - /// - /// The amount of deflection 'one unit' on the trackpad translates to in radians. - /// The trackpad ordinarily has a range of +1..-1; multiplied by PI, gives PI to -PI, or all 360 degrees of deflection. - /// - const F32 normalTrackpadRangeInRads = F_PI; /// /// Refreshes the supplied pose list from the supplued subdirectory. /// - void refreshPoseScroll(std::string_view scrollListName, std::string_view subDirectory); + void refreshPoseScroll(LLScrollListCtrl* posesScrollList, std::optional subDirectory = std::nullopt); /// /// (Dis)Enables all of the posing controls; such as when you can't pose for reasons. @@ -105,7 +106,7 @@ class FSFloaterPoser : public LLFloater /// This does a lookup into the poser XML for a friendly header title by joint name, if it exists. /// /// The scroll list to add the header-row to. - void AddHeaderRowToScrollList(std::string jointName, LLScrollListCtrl *bodyJointsScrollList); + void addHeaderRowToScrollList(const std::string& jointName, LLScrollListCtrl* bodyJointsScrollList); /// /// Generates the data for a row to add to a scroll-list. @@ -114,52 +115,52 @@ class FSFloaterPoser : public LLFloater /// The well-known joint name of the joint to add the row for, eg: mChest. /// Whether the joint is one which should come immediately after a header. /// The data required to make the row. - LLSD createRowForJoint(std::string jointName, bool isHeaderRow); + LLSD createRowForJoint(const std::string& jointName, bool isHeaderRow); /// /// Gets the collection of poser joints currently selected on the active bones-tab of the UI. /// /// The selected joints - std::vector getUiSelectedPoserJoints() const; + std::vector getUiSelectedPoserJoints() const; /// /// Gets a detectable avatar by its UUID. /// /// The ID of the avatar to find. /// The avatar, if found, otherwise nullptr. - LLVOAvatar* getAvatarByUuid(LLUUID avatarToFind); + LLVOAvatar* getAvatarByUuid(const LLUUID& avatarToFind) const; /// /// Gets the currently selected avatar or animesh. /// /// The currently selected avatar or animesh. - LLVOAvatar *getUiSelectedAvatar(); + LLVOAvatar* getUiSelectedAvatar() const; /// /// Gets the current bone-deflection style: encapsulates 'anything else you want to do' while you're manipulating a joint. /// Such as: fiddle the opposite joint too. /// /// A E_BoneDeflectionStyles member. - E_BoneDeflectionStyles getUiSelectedBoneDeflectionStyle(); + E_BoneDeflectionStyles getUiSelectedBoneDeflectionStyle() const; /// /// Gets the collection of UUIDs for nearby avatars. /// /// A the collection of UUIDs for nearby avatars. - uuid_vec_t getNearbyAvatarsAndAnimeshes(); + uuid_vec_t getNearbyAvatarsAndAnimeshes() const; /// /// Gets a collection of UUIDs for avatars currently being presented on the UI. /// /// A the collection of UUIDs. - uuid_vec_t getCurrentlyListedAvatarsAndAnimeshes(); + uuid_vec_t getCurrentlyListedAvatarsAndAnimeshes() const; /// /// Gets the scroll-list index of the supplied avatar. /// /// The avatar UUID to find on the avatars scroll list. /// The scroll-list index for the supplied avatar, if found, otherwise -1. - S32 getAvatarListIndexForUuid(LLUUID toFind); + S32 getAvatarListIndexForUuid(const LLUUID& toFind) const; /// /// There are several control-callbacks manipulating rotations etc, they all devolve to these. @@ -182,21 +183,21 @@ class FSFloaterPoser : public LLFloater /// There may be +/- PI difference two axes, because harmonics. /// Thus keep your UI synced with less gets. /// - LLVector3 getRotationOfFirstSelectedJoint(); - LLVector3 getPositionOfFirstSelectedJoint(); - LLVector3 getScaleOfFirstSelectedJoint(); + LLVector3 getRotationOfFirstSelectedJoint() const; + LLVector3 getPositionOfFirstSelectedJoint() const; + LLVector3 getScaleOfFirstSelectedJoint() const; // Pose load/save void onToggleLoadSavePanel(); void onClickPoseSave(); void onPoseFileSelect(); - bool savePoseToXml(LLVOAvatar* avatar, std::string posePath); - bool savePoseToBvh(LLVOAvatar* avatar, std::string posePath); + bool savePoseToXml(LLVOAvatar* avatar, const std::string& posePath); + bool savePoseToBvh(LLVOAvatar* avatar, const std::string& posePath); void onClickBrowsePoseCache(); void onPoseMenuAction(const LLSD& param); - void loadPoseFromXml(LLVOAvatar* avatar, std::string poseFileName, E_LoadPoseMethods loadMethod); + void loadPoseFromXml(LLVOAvatar* avatar, const std::string& poseFileName, E_LoadPoseMethods loadMethod); void setPoseSaveFileTextBoxToUiSelectedAvatarSaveFileName(); - void setUiSelectedAvatarSaveFileName(std::string saveFileName); + void setUiSelectedAvatarSaveFileName(const std::string& saveFileName); void showOrHideAdvancedSaveOptions(); // UI Event Handlers: @@ -246,20 +247,20 @@ class FSFloaterPoser : public LLFloater /// /// The avatar to animate. /// True if we have permission to animate, otherwise false. - bool havePermissionToAnimateAvatar(LLVOAvatar *avatar); + bool havePermissionToAnimateAvatar(LLVOAvatar* avatar) const; /// /// Determines if we could animate the supplied avatar. /// /// The avatar to animate. /// True if the avatar is non-null, not dead, in the same region as self, otherwise false. - bool couldAnimateAvatar(LLVOAvatar *avatar); + bool couldAnimateAvatar(LLVOAvatar* avatar) const; /// /// Our instance of the class which lets us do the business of manipulating the avatar. /// This separates that business from the code-behind the UI. /// - FSPoserAnimator _poserAnimator; + FSPoserAnimator mPoserAnimator; /// /// The supplied Joint name has a quaternion describing its rotation. @@ -274,14 +275,14 @@ class FSFloaterPoser : public LLFloater /// No the translation isn't untangling all of that, it's not needed until it is. /// We're not landing on Mars with this code, just offering a user reasonable thumb-twiddlings. /// - E_BoneAxisTranslation getJointTranslation(std::string jointName); + E_BoneAxisTranslation getJointTranslation(const std::string& jointName) const; /// /// Gets the collection of E_BoneAxisNegation values for the supplied joint. /// /// The name of the joind to get the axis transformation for. /// The kind of axis transformation to perform. - S32 getJointNegation(std::string jointName); + S32 getJointNegation(const std::string& jointName) const; /// /// The smallest text embiggens the noble selection. @@ -293,18 +294,18 @@ class FSFloaterPoser : public LLFloater /// /// The name of the list to adjust text-face for. /// The avatar to whom the list is relevant. - void addBoldToScrollList(std::string listName, LLVOAvatar *avatar); + void addBoldToScrollList(LLScrollListCtrl* list, LLVOAvatar* avatar); /// /// The time when the last click of a button was made. /// Utilized for controls needing a 'double click do' function. /// - std::chrono::system_clock::time_point _timeLastClickedJointReset = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point mTimeLastClickedJointReset = std::chrono::system_clock::now(); /// /// The constant time interval, in seconds, a user must click twice within to successfully double-click a button. /// - std::chrono::duration const _doubleClickInterval = std::chrono::duration(0.3); + std::chrono::duration const mDoubleClickInterval = std::chrono::duration(0.3); /// /// Unwraps a normalized value from the trackball to a slider value. @@ -312,6 +313,65 @@ class FSFloaterPoser : public LLFloater /// The scale value from the trackball. /// A value appropriate for fitting a slider. static F32 unWrapScale(F32 scale); + + FSVirtualTrackpad* mAvatarTrackball{ nullptr }; + + LLSliderCtrl* mTrackpadSensitivitySlider{ nullptr }; + LLSliderCtrl* mLimbYawSlider{ nullptr }; + LLSliderCtrl* mLimbPitchSlider{ nullptr }; // pointing your nose up or down + LLSliderCtrl* mLimbRollSlider{ nullptr }; // your ear touches your shoulder + LLSliderCtrl* mPosXSlider{ nullptr }; + LLSliderCtrl* mPosYSlider{ nullptr }; + LLSliderCtrl* mPosZSlider{ nullptr }; + LLSliderCtrl* mAdvPosXSlider{ nullptr }; + LLSliderCtrl* mAdvPosYSlider{ nullptr }; + LLSliderCtrl* mAdvPosZSlider{ nullptr }; + LLSliderCtrl* mAdvScaleXSlider{ nullptr }; + LLSliderCtrl* mAdvScaleYSlider{ nullptr }; + LLSliderCtrl* mAdvScaleZSlider{ nullptr }; + + LLTabContainer* mJointsTabs{ nullptr }; + LLTabContainer* mHandsTabs{ nullptr }; + + LLScrollListCtrl* mAvatarSelectionScrollList{ nullptr }; + LLScrollListCtrl* mBodyJointsScrollList{ nullptr }; + LLScrollListCtrl* mFaceJointsScrollList{ nullptr }; + LLScrollListCtrl* mHandJointsScrollList{ nullptr }; + LLScrollListCtrl* mMiscJointsScrollList{ nullptr }; + LLScrollListCtrl* mCollisionVolumesScrollList{ nullptr }; + LLScrollListCtrl* mEntireAvJointScroll{ nullptr }; + LLScrollListCtrl* mPosesScrollList{ nullptr }; + LLScrollListCtrl* mHandPresetsScrollList{ nullptr }; + + LLButton* mToggleAdvancedPanelBtn{ nullptr }; + LLButton* mStartStopPosingBtn{ nullptr }; + LLButton* mToggleLoadSavePanelBtn{ nullptr }; + LLButton* mBrowserFolderBtn{ nullptr }; + LLButton* mLoadPosesBtn{ nullptr }; + LLButton* mSavePosesBtn{ nullptr }; + LLButton* mFlipPoseBtn{ nullptr }; + LLButton* mFlipJointBtn{ nullptr }; + LLButton* mRecaptureBtn{ nullptr }; + LLButton* mTogglePosingBonesBtn{ nullptr }; + LLButton* mToggleMirrorRotationBtn{ nullptr }; + LLButton* mToggleSympatheticRotationBtn{ nullptr }; + LLButton* mToggleDeltaModeBtn{ nullptr }; + LLButton* mRedoChangeBtn{ nullptr }; + + LLCheckBoxCtrl* mAlsoSaveBvhCbx{ nullptr }; + LLLineEditor* mPoseSaveNameEditor{ nullptr }; + + LLPanel* mAdvancedParentPnl{ nullptr }; + LLPanel* mJointsParentPnl{ nullptr }; + LLPanel* mTrackballPnl{ nullptr }; + LLPanel* mPositionRotationPnl{ nullptr }; + LLPanel* mBodyJointsPnl{ nullptr }; + LLPanel* mFaceJointsPnl{ nullptr }; + LLPanel* mHandsJointsPnl{ nullptr }; + LLPanel* mMiscJointsPnl{ nullptr }; + LLPanel* mCollisionVolumesPnl{ nullptr }; + LLPanel* mSaveFilePptionsPnl{ nullptr }; + LLPanel* mPosesLoadSavePnl{ nullptr }; }; #endif diff --git a/indra/newview/fsposeranimator.cpp b/indra/newview/fsposeranimator.cpp index 929e10b363..8bfb3a313a 100644 --- a/indra/newview/fsposeranimator.cpp +++ b/indra/newview/fsposeranimator.cpp @@ -31,11 +31,9 @@ #include "llagent.h" #include "fsposingmotion.h" -FSPoserAnimator::FSPoserAnimator() {} -FSPoserAnimator::~FSPoserAnimator() {} -std::map FSPoserAnimator::_avatarIdToRegisteredAnimationId; +std::map FSPoserAnimator::sAvatarIdToRegisteredAnimationId; -bool FSPoserAnimator::isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint) +bool FSPoserAnimator::isPosingAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint) { if (!isAvatarSafeToUse(avatar)) return false; @@ -54,7 +52,7 @@ bool FSPoserAnimator::isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint return posingMotion->currentlyPosingJoint(jointPose); } -void FSPoserAnimator::setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint, bool shouldPose) +void FSPoserAnimator::setPosingAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint, bool shouldPose) { if (!isAvatarSafeToUse(avatar)) return; @@ -80,7 +78,7 @@ void FSPoserAnimator::setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint join posingMotion->removeJointFromState(jointPose); } -void FSPoserAnimator::resetAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint) +void FSPoserAnimator::resetAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint) { if (!isAvatarSafeToUse(avatar)) return; @@ -100,7 +98,7 @@ void FSPoserAnimator::resetAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint) jointPose->setTargetRotation(jointPose->getBeginningRotation()); } -void FSPoserAnimator::undoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::undoLastJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -128,7 +126,7 @@ void FSPoserAnimator::undoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joi oppositeJointPose->undoLastRotationSet(); } -void FSPoserAnimator::undoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::undoLastJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -156,7 +154,7 @@ void FSPoserAnimator::undoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joi oppositeJointPose->undoLastPositionSet(); } -void FSPoserAnimator::undoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::undoLastJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -184,7 +182,7 @@ void FSPoserAnimator::undoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, oppositeJointPose->undoLastScaleSet(); } -void FSPoserAnimator::resetJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::resetJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -212,7 +210,7 @@ void FSPoserAnimator::resetJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, oppositeJointPose->setTargetPosition(oppositeJointPose->getBeginningPosition()); } -void FSPoserAnimator::resetJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::resetJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -240,7 +238,7 @@ void FSPoserAnimator::resetJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_ oppositeJointPose->setTargetScale(oppositeJointPose->getBeginningScale()); } -bool FSPoserAnimator::canRedoJointRotation(LLVOAvatar* avatar, FSPoserJoint joint) +bool FSPoserAnimator::canRedoJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint) { if (!isAvatarSafeToUse(avatar)) return false; @@ -259,7 +257,7 @@ bool FSPoserAnimator::canRedoJointRotation(LLVOAvatar* avatar, FSPoserJoint join return jointPose->canRedoRotation(); } -void FSPoserAnimator::redoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::redoLastJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -287,7 +285,7 @@ void FSPoserAnimator::redoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joi oppositeJointPose->redoLastRotationSet(); } -void FSPoserAnimator::redoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::redoLastJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -315,7 +313,7 @@ void FSPoserAnimator::redoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joi oppositeJointPose->redoLastPositionSet(); } -void FSPoserAnimator::redoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style) +void FSPoserAnimator::redoLastJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -343,7 +341,7 @@ void FSPoserAnimator::redoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, oppositeJointPose->redoLastScaleSet(); } -LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture) +LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, bool forRecapture) const { LLVector3 pos; if (!isAvatarSafeToUse(avatar)) @@ -365,7 +363,7 @@ LLVector3 FSPoserAnimator::getJointPosition(LLVOAvatar* avatar, FSPoserJoint joi return pos; } -void FSPoserAnimator::setJointPosition(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style) +void FSPoserAnimator::setJointPosition(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& position, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -414,7 +412,7 @@ void FSPoserAnimator::setJointPosition(LLVOAvatar *avatar, const FSPoserJoint *j } } -LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar *avatar, FSPoserJoint joint, E_BoneAxisTranslation translation, S32 negation, bool forRecapture) +LLVector3 FSPoserAnimator::getJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneAxisTranslation translation, S32 negation, bool forRecapture) const { LLVector3 vec3; if (!isAvatarSafeToUse(avatar)) @@ -437,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, E_BoneDeflectionStyles style, +void FSPoserAnimator::setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& rotation, E_BoneDeflectionStyles style, E_BoneAxisTranslation translation, S32 negation) { if (!isAvatarSafeToUse(avatar)) @@ -492,7 +490,7 @@ void FSPoserAnimator::setJointRotation(LLVOAvatar *avatar, const FSPoserJoint *j } } -void FSPoserAnimator::reflectJoint(LLVOAvatar *avatar, const FSPoserJoint *joint) +void FSPoserAnimator::reflectJoint(LLVOAvatar* avatar, const FSPoserJoint* joint) { if (!isAvatarSafeToUse(avatar)) return; @@ -526,7 +524,7 @@ void FSPoserAnimator::reflectJoint(LLVOAvatar *avatar, const FSPoserJoint *joint oppositeJointPose->setTargetRotation(first_inv); } -void FSPoserAnimator::flipEntirePose(LLVOAvatar *avatar) +void FSPoserAnimator::flipEntirePose(LLVOAvatar* avatar) { if (!isAvatarSafeToUse(avatar)) return; @@ -553,8 +551,7 @@ void FSPoserAnimator::flipEntirePose(LLVOAvatar *avatar) } // from the UI to the bone, the inverse translation, the un-swap, the backwards -LLQuaternion FSPoserAnimator::translateRotationToQuaternion(E_BoneAxisTranslation translation, S32 negation, - LLVector3 rotation) +LLQuaternion FSPoserAnimator::translateRotationToQuaternion(E_BoneAxisTranslation translation, S32 negation, LLVector3 rotation) { if (negation & NEGATE_ALL) { @@ -608,7 +605,7 @@ LLQuaternion FSPoserAnimator::translateRotationToQuaternion(E_BoneAxisTranslatio } // from the bone to the UI; this is the 'forwards' use of the enum -LLVector3 FSPoserAnimator::translateRotationFromQuaternion(E_BoneAxisTranslation translation, S32 negation, LLQuaternion rotation) +LLVector3 FSPoserAnimator::translateRotationFromQuaternion(E_BoneAxisTranslation translation, S32 negation, const LLQuaternion& rotation) const { LLVector3 vec3; @@ -659,7 +656,7 @@ LLVector3 FSPoserAnimator::translateRotationFromQuaternion(E_BoneAxisTranslation return vec3; } -LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture) +LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, bool forRecapture) const { LLVector3 scale; if (!isAvatarSafeToUse(avatar)) @@ -681,7 +678,7 @@ LLVector3 FSPoserAnimator::getJointScale(LLVOAvatar* avatar, FSPoserJoint joint, return scale; } -void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style) +void FSPoserAnimator::setJointScale(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& scale, E_BoneDeflectionStyles style) { if (!isAvatarSafeToUse(avatar)) return; @@ -712,7 +709,7 @@ void FSPoserAnimator::setJointScale(LLVOAvatar *avatar, const FSPoserJoint *join oppositeJointPose->setTargetScale(scale); } -const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByName(std::string jointName) +const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByName(const std::string& jointName) { for (size_t index = 0; index != PoserJoints.size(); ++index) { @@ -758,7 +755,7 @@ void FSPoserAnimator::stopPosingAvatar(LLVOAvatar *avatar) avatar->stopMotion(posingMotion->motionId()); } -bool FSPoserAnimator::isPosingAvatar(LLVOAvatar* avatar) +bool FSPoserAnimator::isPosingAvatar(LLVOAvatar* avatar) const { if (!isAvatarSafeToUse(avatar)) return false; @@ -770,15 +767,15 @@ bool FSPoserAnimator::isPosingAvatar(LLVOAvatar* avatar) return !posingMotion->isStopped(); } -FSPosingMotion* FSPoserAnimator::getPosingMotion(LLVOAvatar* avatar) +FSPosingMotion* FSPoserAnimator::getPosingMotion(LLVOAvatar* avatar) const { if (!isAvatarSafeToUse(avatar)) return nullptr; - if (_avatarIdToRegisteredAnimationId.find(avatar->getID()) == _avatarIdToRegisteredAnimationId.end()) + if (sAvatarIdToRegisteredAnimationId.find(avatar->getID()) == sAvatarIdToRegisteredAnimationId.end()) return nullptr; - return dynamic_cast(avatar->findMotion(_avatarIdToRegisteredAnimationId[avatar->getID()])); + return dynamic_cast(avatar->findMotion(sAvatarIdToRegisteredAnimationId[avatar->getID()])); } FSPosingMotion* FSPoserAnimator::findOrCreatePosingMotion(LLVOAvatar* avatar) @@ -792,7 +789,7 @@ FSPosingMotion* FSPoserAnimator::findOrCreatePosingMotion(LLVOAvatar* avatar) LLAssetID animationAssetId = mTransactionID.makeAssetID(gAgent.getSecureSessionID()); if (avatar->registerMotion(animationAssetId, FSPosingMotion::create)) - _avatarIdToRegisteredAnimationId[avatar->getID()] = animationAssetId; + sAvatarIdToRegisteredAnimationId[avatar->getID()] = animationAssetId; return dynamic_cast(avatar->createMotion(animationAssetId)); } @@ -800,7 +797,7 @@ FSPosingMotion* FSPoserAnimator::findOrCreatePosingMotion(LLVOAvatar* avatar) return motion; } -bool FSPoserAnimator::isAvatarSafeToUse(LLVOAvatar *avatar) +bool FSPoserAnimator::isAvatarSafeToUse(LLVOAvatar* avatar) const { if (!avatar) return false; @@ -829,7 +826,7 @@ bool FSPoserAnimator::writePoseAsBvh(llofstream* fileStream, LLVOAvatar* avatar) return true; } -bool FSPoserAnimator::writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint, int tabStops) +bool FSPoserAnimator::writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint, S32 tabStops) { if (!joint) return false; @@ -903,30 +900,21 @@ bool FSPoserAnimator::writeBvhMotion(llofstream* fileStream, LLVOAvatar* avatar, return true; } -std::string FSPoserAnimator::vec3ToXYZString(LLVector3 val) +std::string FSPoserAnimator::vec3ToXYZString(const LLVector3& val) { - return f32ToString(val[VX]) + " " + f32ToString(val[VY]) + " " + f32ToString(val[VZ]); + return std::to_string(val[VX]) + " " + std::to_string(val[VY]) + " " + std::to_string(val[VZ]); } -std::string FSPoserAnimator::rotationToYZXString(LLVector3 val) +std::string FSPoserAnimator::rotationToYZXString(const LLVector3& val) { - return f32ToString(val[VY] * RAD_TO_DEG) + " " + f32ToString(val[VZ] * RAD_TO_DEG) + " " + f32ToString(val[VX] * RAD_TO_DEG); + return std::to_string(val[VY] * RAD_TO_DEG) + " " + std::to_string(val[VZ] * RAD_TO_DEG) + " " + std::to_string(val[VX] * RAD_TO_DEG); } -std::string FSPoserAnimator::getTabs(int numOfTabstops) +std::string FSPoserAnimator::getTabs(S32 numOfTabstops) { std::string tabSpaces; - for (int i = 0; i < numOfTabstops; i++) + for (S32 i = 0; i < numOfTabstops; i++) tabSpaces += "\t"; return tabSpaces; } - -std::string FSPoserAnimator::f32ToString(F32 val) -{ - std::string str; - char buf[20]; - snprintf(buf, 20, "%f", val); - str = buf; - return str; -} diff --git a/indra/newview/fsposeranimator.h b/indra/newview/fsposeranimator.h index a710e8b01a..21296cfdfb 100644 --- a/indra/newview/fsposeranimator.h +++ b/indra/newview/fsposeranimator.h @@ -88,9 +88,9 @@ typedef enum E_BoneAxisNegation class FSPoserAnimator { public: - FSPoserAnimator(); + FSPoserAnimator() = default; - virtual ~FSPoserAnimator(); + virtual ~FSPoserAnimator() = default; /// /// A class encapsulating 'metadata' for a joint, such as its catagory and its opposite joint name. @@ -98,56 +98,57 @@ public: /// class FSPoserJoint { - std::string _jointName; // expected to be a match to LLJoint.getName() for a joint implementation. - std::string _mirrorJointName; - E_BoneTypes _boneList; - std::vector _bvhChildren; - bool _dontFlipOnMirror = false; + std::string mJointName; // expected to be a match to LLJoint.getName() for a joint implementation. + std::string mMirrorJointName; + E_BoneTypes mBoneList; + std::vector mBvhChildren; + bool mDontFlipOnMirror = false; + public: /// /// Gets the name of the joint. /// - std::string jointName() const { return _jointName; } + std::string jointName() const { return mJointName; } /// /// Gets the name of the mirror of this joint, or an empty string if there is no mirror. /// - std::string mirrorJointName() const { return _mirrorJointName; } + std::string mirrorJointName() const { return mMirrorJointName; } /// /// Gets the E_BoneTypes of the joint. /// - E_BoneTypes boneType() const { return _boneList; } + E_BoneTypes boneType() const { return mBoneList; } /// /// Gets whether when mirroring the entire body, should this joint flip its counterpart. /// - bool dontFlipOnMirror() const { return _dontFlipOnMirror; } + bool dontFlipOnMirror() const { return mDontFlipOnMirror; } /// /// Gets the collection of child bvh joints for this. /// - std::vector bvhChildren() const { return _bvhChildren; } + std::vector bvhChildren() const { return mBvhChildren; } /// /// Creates a new instance of a PoserJoint. /// - /// + /// /// The joint name, should be one of the well known bones/joints/thingos. /// An example for an LLJoints implementation would be what LLJoint.getName() returns, like 'mChest'. /// Very likely case-sensitive. /// - /// The opposite joint name, if any. Also expected to be a well-known name. - /// The type of bone, often determining with which other bones the new instance would appear with. - /// The optional array of joints, needed for BVH saving, which are the direct decendent(s) of this joint. - /// The option for whether this joint should rotation-flip it counterpart when mirroring the pose of the entire body. - FSPoserJoint(std::string a, std::string b, E_BoneTypes c, std::vector d = {}, bool e = false) + /// The opposite joint name, if any. Also expected to be a well-known name. + /// The type of bone, often determining with which other bones the new instance would appear with. + /// The optional array of joints, needed for BVH saving, which are the direct decendent(s) of this joint. + /// The option for whether this joint should rotation-flip it counterpart when mirroring the pose of the entire body. + FSPoserJoint(std::string joint_name, std::string mirror_joint_name, E_BoneTypes bone_list, std::vector bhv_children = {}, bool dont_flip_on_mirror = false) { - _jointName = a; - _mirrorJointName = b; - _boneList = c; - _bvhChildren = d; - _dontFlipOnMirror = e; + mJointName = joint_name; + mMirrorJointName = mirror_joint_name; + mBoneList = bone_list; + mBvhChildren = bhv_children; + mDontFlipOnMirror = dont_flip_on_mirror; } }; @@ -159,56 +160,132 @@ public: /// /// For an implementation of something other than LLJoints, different name(s) may be required. /// - const std::vector PoserJoints { + const std::vector PoserJoints{ // head, torso, legs - {"mHead", "", BODY}, {"mNeck", "", BODY, {"mHead"}}, {"mPelvis", "", WHOLEAVATAR, {"mTorso", "mHipLeft", "mHipRight"}}, {"mChest", "", BODY, {"mNeck", "mCollarLeft", "mCollarRight", "mWingsRoot"}}, {"mTorso", "", BODY, {"mChest"}}, - {"mCollarLeft", "mCollarRight", BODY, {"mShoulderLeft"}}, {"mShoulderLeft", "mShoulderRight", BODY, {"mElbowLeft"}}, {"mElbowLeft", "mElbowRight", BODY, {"mWristLeft"}}, {"mWristLeft", "mWristRight", BODY}, - {"mCollarRight", "mCollarLeft", BODY, {"mShoulderRight"}, true}, {"mShoulderRight", "mShoulderLeft", BODY, {"mElbowRight"}, true}, {"mElbowRight", "mElbowLeft", BODY, {"mWristRight"}, true}, {"mWristRight", "mWristLeft", BODY, {}, true}, - {"mHipLeft", "mHipRight", BODY, {"mKneeLeft"}}, {"mKneeLeft", "mKneeRight", BODY, {"mAnkleLeft"}}, {"mAnkleLeft", "mAnkleRight", BODY}, - {"mHipRight", "mHipLeft", BODY, {"mKneeRight"}, true}, {"mKneeRight", "mKneeLeft", BODY, {"mAnkleRight"}, true}, {"mAnkleRight", "mAnkleLeft", BODY, {}, true}, + { "mHead", "", BODY }, + { "mNeck", "", BODY, { "mHead" } }, + { "mPelvis", "", WHOLEAVATAR, { "mTorso", "mHipLeft", "mHipRight" } }, + { "mChest", "", BODY, { "mNeck", "mCollarLeft", "mCollarRight", "mWingsRoot" } }, + { "mTorso", "", BODY, { "mChest" } }, + { "mCollarLeft", "mCollarRight", BODY, { "mShoulderLeft" } }, + { "mShoulderLeft", "mShoulderRight", BODY, { "mElbowLeft" } }, + { "mElbowLeft", "mElbowRight", BODY, { "mWristLeft" } }, + { "mWristLeft", "mWristRight", BODY }, + { "mCollarRight", "mCollarLeft", BODY, { "mShoulderRight" }, true }, + { "mShoulderRight", "mShoulderLeft", BODY, { "mElbowRight" }, true }, + { "mElbowRight", "mElbowLeft", BODY, { "mWristRight" }, true }, + { "mWristRight", "mWristLeft", BODY, {}, true }, + { "mHipLeft", "mHipRight", BODY, { "mKneeLeft" } }, + { "mKneeLeft", "mKneeRight", BODY, { "mAnkleLeft" } }, + { "mAnkleLeft", "mAnkleRight", BODY }, + { "mHipRight", "mHipLeft", BODY, { "mKneeRight" }, true }, + { "mKneeRight", "mKneeLeft", BODY, { "mAnkleRight" }, true }, + { "mAnkleRight", "mAnkleLeft", BODY, {}, true }, // face - {"mFaceForeheadLeft", "mFaceForeheadRight", FACE}, {"mFaceForeheadCenter", "", FACE}, {"mFaceForeheadRight", "mFaceForeheadLeft", FACE, {}, true}, - {"mFaceEyebrowOuterLeft", "mFaceEyebrowOuterRight", FACE}, {"mFaceEyebrowCenterLeft", "mFaceEyebrowCenterRight", FACE}, {"mFaceEyebrowInnerLeft", "mFaceEyebrowInnerRight", FACE}, - {"mFaceEyebrowOuterRight", "mFaceEyebrowOuterLeft", FACE, {}, true}, {"mFaceEyebrowCenterRight", "mFaceEyebrowCenterLeft", FACE, {}, true}, {"mFaceEyebrowInnerRight", "mFaceEyebrowInnerLeft", FACE, {}, true}, + { "mFaceForeheadLeft", "mFaceForeheadRight", FACE }, + { "mFaceForeheadCenter", "", FACE }, + { "mFaceForeheadRight", "mFaceForeheadLeft", FACE, {}, true }, + { "mFaceEyebrowOuterLeft", "mFaceEyebrowOuterRight", FACE }, + { "mFaceEyebrowCenterLeft", "mFaceEyebrowCenterRight", FACE }, + { "mFaceEyebrowInnerLeft", "mFaceEyebrowInnerRight", FACE }, + { "mFaceEyebrowOuterRight", "mFaceEyebrowOuterLeft", FACE, {}, true }, + { "mFaceEyebrowCenterRight", "mFaceEyebrowCenterLeft", FACE, {}, true }, + { "mFaceEyebrowInnerRight", "mFaceEyebrowInnerLeft", FACE, {}, true }, - {"mEyeLeft", "mEyeRight", FACE}, {"mEyeRight", "mEyeLeft", FACE, {}, true}, - {"mFaceEyeLidUpperLeft", "mFaceEyeLidUpperRight", FACE}, {"mFaceEyeLidLowerLeft", "mFaceEyeLidLowerRight", FACE}, {"mFaceEyeLidUpperRight", "mFaceEyeLidUpperLeft", FACE, {}, true}, {"mFaceEyeLidLowerRight", "mFaceEyeLidLowerLeft", FACE, {}, true}, + { "mEyeLeft", "mEyeRight", FACE }, + { "mEyeRight", "mEyeLeft", FACE, {}, true }, + { "mFaceEyeLidUpperLeft", "mFaceEyeLidUpperRight", FACE }, + { "mFaceEyeLidLowerLeft", "mFaceEyeLidLowerRight", FACE }, + { "mFaceEyeLidUpperRight", "mFaceEyeLidUpperLeft", FACE, {}, true }, + { "mFaceEyeLidLowerRight", "mFaceEyeLidLowerLeft", FACE, {}, true }, - {"mFaceCheekUpperLeft", "mFaceCheekUpperRight", FACE}, {"mFaceCheekLowerLeft", "mFaceCheekLowerRight", FACE}, {"mFaceCheekUpperRight", "mFaceCheekUpperLeft", FACE, {}, true}, {"mFaceCheekLowerRight", "mFaceCheekLowerLeft", FACE, {}, true}, - {"mFaceLipUpperLeft", "mFaceLipUpperRight", FACE}, {"mFaceLipUpperCenter", "", FACE}, {"mFaceLipUpperRight", "mFaceLipUpperLeft", FACE, {}, true}, - {"mFaceLipCornerLeft", "mFaceLipCornerRight", FACE}, {"mFaceLipCornerRight", "mFaceLipCornerLeft", FACE, {}, true}, - {"mFaceTongueBase", "", FACE}, {"mFaceTongueTip", "", FACE, {}, true}, - {"mFaceLipLowerLeft", "mFaceLipLowerRight", FACE}, {"mFaceLipLowerCenter", "", FACE}, {"mFaceLipLowerRight", "mFaceLipLowerLeft", FACE, {}, true}, - {"mFaceJaw", "", FACE}, + { "mFaceCheekUpperLeft", "mFaceCheekUpperRight", FACE }, + { "mFaceCheekLowerLeft", "mFaceCheekLowerRight", FACE }, + { "mFaceCheekUpperRight", "mFaceCheekUpperLeft", FACE, {}, true }, + { "mFaceCheekLowerRight", "mFaceCheekLowerLeft", FACE, {}, true }, + { "mFaceLipUpperLeft", "mFaceLipUpperRight", FACE }, + { "mFaceLipUpperCenter", "", FACE }, + { "mFaceLipUpperRight", "mFaceLipUpperLeft", FACE, {}, true }, + { "mFaceLipCornerLeft", "mFaceLipCornerRight", FACE }, + { "mFaceLipCornerRight", "mFaceLipCornerLeft", FACE, {}, true }, + { "mFaceTongueBase", "", FACE }, + { "mFaceTongueTip", "", FACE, {}, true }, + { "mFaceLipLowerLeft", "mFaceLipLowerRight", FACE }, + { "mFaceLipLowerCenter", "", FACE }, + { "mFaceLipLowerRight", "mFaceLipLowerLeft", FACE, {}, true }, + { "mFaceJaw", "", FACE }, - //left hand - {"mHandThumb1Left", "mHandThumb1Right", HANDS}, {"mHandThumb2Left", "mHandThumb2Right", HANDS}, {"mHandThumb3Left", "mHandThumb3Right", HANDS}, - {"mHandIndex1Left", "mHandIndex1Right", HANDS}, {"mHandIndex2Left", "mHandIndex2Right", HANDS}, {"mHandIndex3Left", "mHandIndex3Right", HANDS}, - {"mHandMiddle1Left", "mHandMiddle1Right", HANDS}, {"mHandMiddle2Left", "mHandMiddle2Right", HANDS}, {"mHandMiddle3Left", "mHandMiddle3Right", HANDS}, - {"mHandRing1Left", "mHandRing1Right", HANDS}, {"mHandRing2Left", "mHandRing2Right", HANDS}, {"mHandRing3Left", "mHandRing3Right", HANDS}, - {"mHandPinky1Left", "mHandPinky1Right", HANDS}, {"mHandPinky2Left", "mHandPinky2Right", HANDS}, {"mHandPinky3Left", "mHandPinky3Right", HANDS}, + // left hand + { "mHandThumb1Left", "mHandThumb1Right", HANDS }, + { "mHandThumb2Left", "mHandThumb2Right", HANDS }, + { "mHandThumb3Left", "mHandThumb3Right", HANDS }, + { "mHandIndex1Left", "mHandIndex1Right", HANDS }, + { "mHandIndex2Left", "mHandIndex2Right", HANDS }, + { "mHandIndex3Left", "mHandIndex3Right", HANDS }, + { "mHandMiddle1Left", "mHandMiddle1Right", HANDS }, + { "mHandMiddle2Left", "mHandMiddle2Right", HANDS }, + { "mHandMiddle3Left", "mHandMiddle3Right", HANDS }, + { "mHandRing1Left", "mHandRing1Right", HANDS }, + { "mHandRing2Left", "mHandRing2Right", HANDS }, + { "mHandRing3Left", "mHandRing3Right", HANDS }, + { "mHandPinky1Left", "mHandPinky1Right", HANDS }, + { "mHandPinky2Left", "mHandPinky2Right", HANDS }, + { "mHandPinky3Left", "mHandPinky3Right", HANDS }, // right hand - {"mHandThumb1Right", "mHandThumb1Left", HANDS, {}, true}, {"mHandThumb2Right", "mHandThumb2Left", HANDS, {}, true}, {"mHandThumb3Right", "mHandThumb3Left", HANDS, {}, true}, - {"mHandIndex1Right", "mHandIndex1Left", HANDS, {}, true}, {"mHandIndex2Right", "mHandIndex2Left", HANDS, {}, true}, {"mHandIndex3Right", "mHandIndex3Left", HANDS, {}, true}, - {"mHandMiddle1Right", "mHandMiddle1Left", HANDS, {}, true}, {"mHandMiddle2Right", "mHandMiddle2Left", HANDS, {}, true}, {"mHandMiddle3Right", "mHandMiddle3Left", HANDS, {}, true}, - {"mHandRing1Right", "mHandRing1Left", HANDS, {}, true}, {"mHandRing2Right", "mHandRing2Left", HANDS, {}, true}, {"mHandRing3Right", "mHandRing3Left", HANDS, {}, true}, - {"mHandPinky1Right", "mHandPinky1Left", HANDS, {}, true}, {"mHandPinky2Right", "mHandPinky2Left", HANDS, {}, true}, {"mHandPinky3Right", "mHandPinky3Left", HANDS, {}, true}, + { "mHandThumb1Right", "mHandThumb1Left", HANDS, {}, true }, + { "mHandThumb2Right", "mHandThumb2Left", HANDS, {}, true }, + { "mHandThumb3Right", "mHandThumb3Left", HANDS, {}, true }, + { "mHandIndex1Right", "mHandIndex1Left", HANDS, {}, true }, + { "mHandIndex2Right", "mHandIndex2Left", HANDS, {}, true }, + { "mHandIndex3Right", "mHandIndex3Left", HANDS, {}, true }, + { "mHandMiddle1Right", "mHandMiddle1Left", HANDS, {}, true }, + { "mHandMiddle2Right", "mHandMiddle2Left", HANDS, {}, true }, + { "mHandMiddle3Right", "mHandMiddle3Left", HANDS, {}, true }, + { "mHandRing1Right", "mHandRing1Left", HANDS, {}, true }, + { "mHandRing2Right", "mHandRing2Left", HANDS, {}, true }, + { "mHandRing3Right", "mHandRing3Left", HANDS, {}, true }, + { "mHandPinky1Right", "mHandPinky1Left", HANDS, {}, true }, + { "mHandPinky2Right", "mHandPinky2Left", HANDS, {}, true }, + { "mHandPinky3Right", "mHandPinky3Left", HANDS, {}, true }, // tail and hind limbs - {"mTail1", "", MISC}, {"mTail2", "", MISC}, {"mTail3", "", MISC}, {"mTail4", "", MISC}, {"mTail5", "", MISC}, {"mTail6", "", MISC}, {"mGroin", "", MISC}, - {"mHindLimbsRoot", "", MISC}, - {"mHindLimb1Left", "mHindLimb1Right", MISC}, {"mHindLimb2Left", "mHindLimb2Right", MISC}, {"mHindLimb3Left", "mHindLimb3Right", MISC}, {"mHindLimb4Left", "mHindLimb4Right", MISC}, - {"mHindLimb1Right", "mHindLimb1Left", MISC, {}, true}, {"mHindLimb2Right", "mHindLimb2Left", MISC, {}, true}, {"mHindLimb3Right", "mHindLimb3Left", MISC, {}, true}, {"mHindLimb4Right", "mHindLimb4Left", MISC, {}, true}, + { "mTail1", "", MISC }, + { "mTail2", "", MISC }, + { "mTail3", "", MISC }, + { "mTail4", "", MISC }, + { "mTail5", "", MISC }, + { "mTail6", "", MISC }, + { "mGroin", "", MISC }, + { "mHindLimbsRoot", "", MISC }, + { "mHindLimb1Left", "mHindLimb1Right", MISC }, + { "mHindLimb2Left", "mHindLimb2Right", MISC }, + { "mHindLimb3Left", "mHindLimb3Right", MISC }, + { "mHindLimb4Left", "mHindLimb4Right", MISC }, + { "mHindLimb1Right", "mHindLimb1Left", MISC, {}, true }, + { "mHindLimb2Right", "mHindLimb2Left", MISC, {}, true }, + { "mHindLimb3Right", "mHindLimb3Left", MISC, {}, true }, + { "mHindLimb4Right", "mHindLimb4Left", MISC, {}, true }, // wings - {"mWingsRoot", "", MISC}, - {"mWing1Left", "mWing1Right", MISC}, {"mWing2Left", "mWing2Right", MISC}, {"mWing3Left", "mWing3Right", MISC}, {"mWing4Left", "mWing4Right", MISC}, {"mWing4FanLeft", "mWing4FanRight", MISC}, - {"mWing1Right", "mWing1Left", MISC, {}, true}, {"mWing2Right", "mWing2Left", MISC, {}, true}, {"mWing3Right", "mWing3Left", MISC, {}, true}, {"mWing4Right", "mWing4Left", MISC, {}, true}, {"mWing4FanRight", "mWing4FanLeft", MISC, {}, true}, + { "mWingsRoot", "", MISC }, + { "mWing1Left", "mWing1Right", MISC }, + { "mWing2Left", "mWing2Right", MISC }, + { "mWing3Left", "mWing3Right", MISC }, + { "mWing4Left", "mWing4Right", MISC }, + { "mWing4FanLeft", "mWing4FanRight", MISC }, + { "mWing1Right", "mWing1Left", MISC, {}, true }, + { "mWing2Right", "mWing2Left", MISC, {}, true }, + { "mWing3Right", "mWing3Left", MISC, {}, true }, + { "mWing4Right", "mWing4Left", MISC, {}, true }, + { "mWing4FanRight", "mWing4FanLeft", MISC, {}, true }, // Collision Volumes - {"LEFT_PEC", "RIGHT_PEC", COL_VOLUMES}, {"RIGHT_PEC", "LEFT_PEC", COL_VOLUMES, {}, true}, {"BELLY", "", COL_VOLUMES}, {"BUTT", "", COL_VOLUMES}, + { "LEFT_PEC", "RIGHT_PEC", COL_VOLUMES }, + { "RIGHT_PEC", "LEFT_PEC", COL_VOLUMES, {}, true }, + { "BELLY", "", COL_VOLUMES }, + { "BUTT", "", COL_VOLUMES }, }; public: @@ -217,27 +294,27 @@ public: /// /// The name of the joint to match. /// The matching joint if found, otherwise nullptr - const FSPoserJoint* getPoserJointByName(std::string jointName); + const FSPoserJoint* getPoserJointByName(const std::string& jointName); /// /// Tries to start posing the supplied avatar. /// /// The avatar to begin posing. /// True if the avatar was able to begin posing, otherwise false. - bool tryPosingAvatar(LLVOAvatar *avatar); + bool tryPosingAvatar(LLVOAvatar* avatar); /// /// Stops posing the supplied avatar. /// /// The avatar to stop posing. - void stopPosingAvatar(LLVOAvatar *avatar); + void stopPosingAvatar(LLVOAvatar* avatar); /// /// Determines if the supplied avatar is being posed by this. /// /// The avatar to query posing status for. /// True if this is posing the supplied avatar, otherwise false. - bool isPosingAvatar(LLVOAvatar *avatar); + bool isPosingAvatar(LLVOAvatar* avatar) const; /// /// Determines whether the supplied PoserJoint for the supplied avatar is being posed. @@ -245,7 +322,7 @@ public: /// The avatar having the joint to which we refer. /// The joint being queried for. /// True if this is joint is being posed for the supplied avatar, otherwise false. - bool isPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint); + bool isPosingAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint); /// /// Sets whether the supplied PoserJoint for the supplied avatar should be posed. @@ -256,49 +333,49 @@ public: /// /// If this is not posing the joint, then it is free to be posed by other things. /// - void setPosingAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint, bool shouldPose); + void setPosingAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint, bool shouldPose); /// /// Resets the supplied PoserJoint to its position/rotation/scale it was when poser was started. /// /// The avatar having the joint to which we refer. /// The joint to be reset. - void resetAvatarJoint(LLVOAvatar *avatar, FSPoserJoint joint); + void resetAvatarJoint(LLVOAvatar* avatar, const FSPoserJoint& joint); /// /// Undoes the last applied rotation to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the rotation to undo. - void undoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void undoLastJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Undoes the last applied position to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the position to undo. - void undoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void undoLastJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Undoes the last applied scale to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the scale to undo. - void undoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void undoLastJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Resets the position of the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the position to reset. - void resetJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void resetJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Resets the scale of the supplied joint to initial values. /// /// The avatar having the joint to which we refer. /// The joint with the scale to reset. - void resetJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void resetJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Determines if a redo action is currently permitted for the supplied joint. @@ -306,28 +383,28 @@ public: /// The avatar having the joint to which we refer. /// The joint to query. /// True if a redo action is available, otherwise false. - bool canRedoJointRotation(LLVOAvatar* avatar, FSPoserJoint joint); + bool canRedoJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint); /// /// Re-does the last undone rotation to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the rotation to redo. - void redoLastJointRotation(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void redoLastJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Re-does the last undone position to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the position to redo. - void redoLastJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void redoLastJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Re-does the last undone scale to the supplied PoserJoint. /// /// The avatar having the joint to which we refer. /// The joint with the scale to redo. - void redoLastJointScale(LLVOAvatar* avatar, FSPoserJoint joint, E_BoneDeflectionStyles style); + void redoLastJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneDeflectionStyles style); /// /// Gets the position of a joint for the supplied avatar. @@ -335,7 +412,7 @@ public: /// The avatar whose joint is being queried. /// The joint to determine the position for. /// The position of the requested joint, if determinable, otherwise a default vector. - LLVector3 getJointPosition(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture = false); + LLVector3 getJointPosition(LLVOAvatar* avatar, const FSPoserJoint& joint, bool forRecapture = false) const; /// /// Sets the position of a joint for the supplied avatar. @@ -344,7 +421,7 @@ public: /// The joint to set. /// The position to set the joint to. /// Any ancilliary action to be taken with the change to be made. - void setJointPosition(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 position, E_BoneDeflectionStyles style); + void setJointPosition(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& position, E_BoneDeflectionStyles style); /// /// Gets the rotation of a joint for the supplied avatar. @@ -355,8 +432,8 @@ public: /// The style of negation to apply to the set. /// Get the current non-poser rotation, for recapture opportunity. /// The rotation of the requested joint, if determinable, otherwise a default vector. - LLVector3 getJointRotation(LLVOAvatar *avatar, FSPoserJoint joint, E_BoneAxisTranslation translation, S32 negation, - bool forRecapture = false); + LLVector3 getJointRotation(LLVOAvatar* avatar, const FSPoserJoint& joint, E_BoneAxisTranslation translation, S32 negation, + bool forRecapture = false) const; /// /// Sets the rotation of a joint for the supplied avatar. @@ -366,7 +443,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, E_BoneDeflectionStyles style, + void setJointRotation(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& rotation, E_BoneDeflectionStyles style, E_BoneAxisTranslation translation, S32 negation); /// @@ -375,7 +452,7 @@ public: /// The avatar whose joint is being queried. /// The joint to determine the scale for. /// The scale of the requested joint, if determinable, otherwise a default vector. - LLVector3 getJointScale(LLVOAvatar* avatar, FSPoserJoint joint, bool forRecapture = false); + LLVector3 getJointScale(LLVOAvatar* avatar, const FSPoserJoint& joint, bool forRecapture = false) const; /// /// Sets the scale of a joint for the supplied avatar. @@ -384,20 +461,20 @@ public: /// The joint to set. /// The scale to set the joint to. /// Any ancilliary action to be taken with the change to be made. - void setJointScale(LLVOAvatar *avatar, const FSPoserJoint *joint, LLVector3 scale, E_BoneDeflectionStyles style); + void setJointScale(LLVOAvatar* avatar, const FSPoserJoint* joint, const LLVector3& scale, E_BoneDeflectionStyles style); /// /// Reflects the joint with its opposite if it has one, or just mirror the rotation of itself. /// /// The avatar whose joint should flip left-right. /// The joint to mirror rotation for. - void reflectJoint(LLVOAvatar *avatar, const FSPoserJoint *joint); + void reflectJoint(LLVOAvatar* avatar, const FSPoserJoint* joint); /// /// Reflects every joint of the supplied avatar with its opposite if it has one, or mirrors the rotation of the joint if it does not have an opposite. /// /// The avatar whose pose should flip left-right. - void flipEntirePose(LLVOAvatar *avatar); + void flipEntirePose(LLVOAvatar* avatar); /// /// Determines whether the supplied PoserJoint for the supplied avatar is being posed. @@ -405,7 +482,7 @@ public: /// The avatar having the joint to which we refer. /// The joint being queried for. /// True if this is joint is being posed for the supplied avatar, otherwise false. - bool writePoseAsBvh(llofstream *fileStream, LLVOAvatar* avatar); + bool writePoseAsBvh(llofstream* fileStream, LLVOAvatar* avatar); private: /// @@ -423,7 +500,7 @@ public: /// The axis translation to perform. /// The rotation to transform to matrix. /// The rotation vector. - LLVector3 translateRotationFromQuaternion(E_BoneAxisTranslation translation, S32 negation, LLQuaternion rotation); + LLVector3 translateRotationFromQuaternion(E_BoneAxisTranslation translation, S32 negation, const LLQuaternion& rotation) const; /// /// Creates a posing motion for the supplied avatar. @@ -441,14 +518,14 @@ public: /// /// The avatar to get the posing motion for. /// The posing motion if found, otherwise nullptr. - FSPosingMotion* getPosingMotion(LLVOAvatar* avatar); + FSPosingMotion* getPosingMotion(LLVOAvatar* avatar) const; /// /// Determines if the avatar can be used. /// /// The avatar to test if it is safe to animate. /// True if the avatar is safe to manipulate, otherwise false. - bool isAvatarSafeToUse(LLVOAvatar* avatar); + bool isAvatarSafeToUse(LLVOAvatar* avatar) const; /// /// Recursively writes a fragment of a BVH file format representation of the supplied joint, then that joints BVH child(ren). @@ -458,7 +535,7 @@ public: /// The joint whose fragment should be written, and whose child(ren) will also be written. /// The number of tab-stops to include for formatting purpose. /// True if the fragment wrote successfully, otherwise false. - bool writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint, int tabStops); + bool writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint, S32 tabStops); /// /// Writes a fragment of the 'single line' representing an animation frame within the BVH file respresenting the positions and/or rotations. @@ -469,26 +546,21 @@ public: /// bool writeBvhMotion(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint); - /// - /// Converts an F32 to a nice string. - /// - std::string static f32ToString(F32 val); - /// /// Generates a string with the supplied number of tab-chars. /// - std::string static getTabs(int numOfTabstops); + std::string static getTabs(S32 numOfTabstops); /// /// Transforms a rotation such that llbvhloader.cpp can resolve it to something vaguely approximating the supplied angle. /// When I say vague, I mean, it's numbers, buuuuut. /// - std::string static rotationToYZXString(LLVector3 val); + std::string static rotationToYZXString(const LLVector3& val); /// /// Transforms the supplied vector into a string of three numbers, format suiting to writing into a BVH file. /// - std::string static vec3ToXYZString(LLVector3 val); + std::string static vec3ToXYZString(const LLVector3& val); /// /// Maps the avatar's ID to the animation registered to them. @@ -497,7 +569,7 @@ public: /// An avatar's animation exists so long as their session does, and there is consideration for renewal (like if they relog/crash and their character is renewed). /// Is static, so the animationId is not lost between sessions (such as when the UI floater is closed and reopened). /// - static std::map _avatarIdToRegisteredAnimationId; + static std::map sAvatarIdToRegisteredAnimationId; }; #endif // LL_FSPoserAnimator_H diff --git a/indra/newview/fsposingmotion.cpp b/indra/newview/fsposingmotion.cpp index 2feed65bb9..657dc662f3 100644 --- a/indra/newview/fsposingmotion.cpp +++ b/indra/newview/fsposingmotion.cpp @@ -32,7 +32,7 @@ FSPosingMotion::FSPosingMotion(const LLUUID &id) : LLMotion(id) { mName = "fs_poser_pose"; - _motionID = id; + mMotionID = id; } LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character) @@ -40,7 +40,7 @@ LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character if (!character) return STATUS_FAILURE; - _jointPoses.clear(); + mJointPoses.clear(); LLJoint* targetJoint; for (S32 i = 0; (targetJoint = character->getCharacterJoint(i)); ++i) @@ -49,7 +49,7 @@ LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character continue; FSJointPose jointPose = FSJointPose(targetJoint); - _jointPoses.push_back(jointPose); + mJointPoses.push_back(jointPose); addJointState(jointPose.getJointState()); } @@ -60,7 +60,7 @@ LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character continue; FSJointPose jointPose = FSJointPose(targetJoint, true); - _jointPoses.push_back(jointPose); + mJointPoses.push_back(jointPose); addJointState(jointPose.getJointState()); } @@ -68,7 +68,10 @@ LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character return STATUS_SUCCESS; } -bool FSPosingMotion::onActivate() { return true; } +bool FSPosingMotion::onActivate() +{ + return true; +} bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask) { @@ -79,7 +82,7 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask) LLVector3 currentScale; LLVector3 targetScale; - for (FSJointPose jointPose : _jointPoses) + for (FSJointPose jointPose : mJointPoses) { LLJoint* joint = jointPose.getJointState()->getJoint(); if (!joint) @@ -94,19 +97,19 @@ bool FSPosingMotion::onUpdate(F32 time, U8* joint_mask) if (currentPosition != targetPosition) { - currentPosition = lerp(currentPosition, targetPosition, _interpolationTime); + currentPosition = lerp(currentPosition, targetPosition, mInterpolationTime); jointPose.getJointState()->setPosition(currentPosition); } if (currentRotation != targetRotation) { - currentRotation = slerp(_interpolationTime, currentRotation, targetRotation); + currentRotation = slerp(mInterpolationTime, currentRotation, targetRotation); jointPose.getJointState()->setRotation(currentRotation); } if (currentScale != targetScale) { - currentScale = lerp(currentScale, targetScale, _interpolationTime); + currentScale = lerp(currentScale, targetScale, mInterpolationTime); jointPose.getJointState()->setScale(currentScale); } } @@ -118,7 +121,7 @@ void FSPosingMotion::onDeactivate() { revertChangesToPositionsScalesAndCollision void FSPosingMotion::revertChangesToPositionsScalesAndCollisionVolumes() { - for (FSJointPose jointPose : _jointPoses) + for (FSJointPose jointPose : mJointPoses) { jointPose.revertJointScale(); jointPose.revertJointPosition(); @@ -176,13 +179,19 @@ void FSPosingMotion::removeJointFromState(FSJointPose* joint) setJointState(avJoint, 0); } -void FSPosingMotion::addJointToState(LLJoint* joint) { setJointState(joint, POSER_JOINT_STATE); } - -void FSPosingMotion::removeJointFromState(LLJoint *joint) { setJointState(joint, 0); } - -void FSPosingMotion::setJointState(LLJoint *joint, U32 state) +void FSPosingMotion::addJointToState(LLJoint* joint) { - if (_jointPoses.size() < 1) + setJointState(joint, POSER_JOINT_STATE); +} + +void FSPosingMotion::removeJointFromState(LLJoint* joint) +{ + setJointState(joint, 0); +} + +void FSPosingMotion::setJointState(LLJoint* joint, U32 state) +{ + if (mJointPoses.size() < 1) return; if (!joint) return; @@ -204,13 +213,12 @@ void FSPosingMotion::setJointState(LLJoint *joint, U32 state) addJointState(jointPose->getJointState()); } -FSPosingMotion::FSJointPose* FSPosingMotion::getJointPoseByJointName(std::string name) +FSPosingMotion::FSJointPose* FSPosingMotion::getJointPoseByJointName(const std::string& name) { - if (_jointPoses.size() < 1) + if (mJointPoses.size() < 1) return nullptr; - std::vector::iterator poserJoint_iter; - for (poserJoint_iter = _jointPoses.begin(); poserJoint_iter != _jointPoses.end(); ++poserJoint_iter) + for (auto poserJoint_iter = mJointPoses.begin(); poserJoint_iter != mJointPoses.end(); ++poserJoint_iter) { if (!boost::iequals(poserJoint_iter->jointName(), name)) continue; @@ -223,7 +231,7 @@ FSPosingMotion::FSJointPose* FSPosingMotion::getJointPoseByJointName(std::string bool FSPosingMotion::currentlyPosingJoint(LLJoint* joint) { - if (_jointPoses.size() < 1) + if (mJointPoses.size() < 1) return false; if (!joint) @@ -240,3 +248,257 @@ bool FSPosingMotion::currentlyPosingJoint(LLJoint* joint) U32 state = jointState->getUsage(); return (state & POSER_JOINT_STATE); } + + +constexpr size_t MaximumUndoQueueLength = 20; + +/// +/// The constant time interval, in seconds, +/// +constexpr std::chrono::duration UndoUpdateInterval = std::chrono::duration(0.3); + + +void FSPosingMotion::FSJointPose::addLastPositionToUndo() +{ + if (mUndonePositionIndex > 0) + { + for (int i = 0; i < mUndonePositionIndex; i++) + mLastSetPositions.pop_front(); + + mUndonePositionIndex = 0; + } + + mLastSetPositions.push_front(mTargetPosition); + + while (mLastSetPositions.size() > MaximumUndoQueueLength) + mLastSetPositions.pop_back(); +} + +void FSPosingMotion::FSJointPose::addLastRotationToUndo() +{ + if (mUndoneRotationIndex > 0) + { + for (int i = 0; i < mUndoneRotationIndex; i++) + mLastSetRotations.pop_front(); + + mUndoneRotationIndex = 0; + } + + mLastSetRotations.push_front(mTargetRotation); + + while (mLastSetRotations.size() > MaximumUndoQueueLength) + mLastSetRotations.pop_back(); +} + +void FSPosingMotion::FSJointPose::addLastScaleToUndo() +{ + if (mUndoneScaleIndex > 0) + { + for (int i = 0; i < mUndoneScaleIndex; i++) + mLastSetScales.pop_front(); + + mUndoneScaleIndex = 0; + } + + mLastSetScales.push_front(mTargetScale); + + while (mLastSetScales.size() > MaximumUndoQueueLength) + mLastSetScales.pop_back(); +} + +LLVector3 FSPosingMotion::FSJointPose::getCurrentPosition() +{ + LLVector3 vec3; + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return vec3; + + vec3 = joint->getPosition(); + return vec3; +} + +void FSPosingMotion::FSJointPose::setTargetPosition(const LLVector3& pos) +{ + auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - mTimeLastUpdatedPosition; + if (timeIntervalSinceLastRotationChange > UndoUpdateInterval) + addLastPositionToUndo(); + + mTimeLastUpdatedPosition = std::chrono::system_clock::now(); + mTargetPosition.set(pos); +} + +LLQuaternion FSPosingMotion::FSJointPose::getCurrentRotation() +{ + LLQuaternion quat; + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return quat; + + quat = joint->getRotation(); + return quat; +} + +void FSPosingMotion::FSJointPose::setTargetRotation(const LLQuaternion& rot) +{ + auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - mTimeLastUpdatedRotation; + if (timeIntervalSinceLastRotationChange > UndoUpdateInterval) + addLastRotationToUndo(); + + mTimeLastUpdatedRotation = std::chrono::system_clock::now(); + mTargetRotation.set(rot); +} + +void FSPosingMotion::FSJointPose::applyDeltaRotation(const LLQuaternion& rot) +{ + auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - mTimeLastUpdatedRotation; + if (timeIntervalSinceLastRotationChange > UndoUpdateInterval) + addLastRotationToUndo(); + + mTimeLastUpdatedRotation = std::chrono::system_clock::now(); + mTargetRotation = mTargetRotation * rot; +} + +LLVector3 FSPosingMotion::FSJointPose::getCurrentScale() +{ + LLVector3 vec3; + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return vec3; + + vec3 = joint->getScale(); + return vec3; +} + +void FSPosingMotion::FSJointPose::setTargetScale(LLVector3 scale) +{ + auto timeIntervalSinceLastScaleChange = std::chrono::system_clock::now() - mTimeLastUpdatedScale; + if (timeIntervalSinceLastScaleChange > UndoUpdateInterval) + addLastScaleToUndo(); + + mTimeLastUpdatedScale = std::chrono::system_clock::now(); + mTargetScale.set(scale); +} + +void FSPosingMotion::FSJointPose::undoLastPositionSet() +{ + if (mLastSetPositions.empty()) + return; + + if (mUndonePositionIndex == 0) // at the top of the queue add the current + addLastPositionToUndo(); + + mUndonePositionIndex++; + mUndonePositionIndex = llclamp(mUndonePositionIndex, 0, mLastSetPositions.size() - 1); + mTargetPosition.set(mLastSetPositions[mUndonePositionIndex]); +} + +void FSPosingMotion::FSJointPose::redoLastPositionSet() +{ + if (mLastSetPositions.empty()) + return; + + mUndonePositionIndex--; + mUndonePositionIndex = llclamp(mUndonePositionIndex, 0, mLastSetPositions.size() - 1); + + mTargetPosition.set(mLastSetPositions[mUndonePositionIndex]); + if (mUndonePositionIndex == 0) + mLastSetPositions.pop_front(); +} + +void FSPosingMotion::FSJointPose::undoLastRotationSet() +{ + if (mLastSetRotations.empty()) + return; + + if (mUndoneRotationIndex == 0) // at the top of the queue add the current + addLastRotationToUndo(); + + mUndoneRotationIndex++; + mUndoneRotationIndex = llclamp(mUndoneRotationIndex, 0, mLastSetRotations.size() - 1); + mTargetRotation.set(mLastSetRotations[mUndoneRotationIndex]); +} + +void FSPosingMotion::FSJointPose::redoLastRotationSet() +{ + if (mLastSetRotations.empty()) + return; + + mUndoneRotationIndex--; + mUndoneRotationIndex = llclamp(mUndoneRotationIndex, 0, mLastSetRotations.size() - 1); + + mTargetRotation.set(mLastSetRotations[mUndoneRotationIndex]); + if (mUndoneRotationIndex == 0) + mLastSetRotations.pop_front(); +} + +void FSPosingMotion::FSJointPose::undoLastScaleSet() +{ + if (mLastSetScales.empty()) + return; + + if (mUndoneScaleIndex == 0) + addLastScaleToUndo(); + + mUndoneScaleIndex++; + mUndoneScaleIndex = llclamp(mUndoneScaleIndex, 0, mLastSetScales.size() - 1); + mTargetScale.set(mLastSetScales[mUndoneScaleIndex]); +} + +void FSPosingMotion::FSJointPose::redoLastScaleSet() +{ + if (mLastSetScales.empty()) + return; + + mUndoneScaleIndex--; + mUndoneScaleIndex = llclamp(mUndoneScaleIndex, 0, mLastSetScales.size() - 1); + + mTargetScale.set(mLastSetScales[mUndoneScaleIndex]); + if (mUndoneScaleIndex == 0) + mLastSetScales.pop_front(); +} + +void FSPosingMotion::FSJointPose::revertJointScale() +{ + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return; + + joint->setScale(mBeginningScale); +} + +void FSPosingMotion::FSJointPose::revertJointPosition() +{ + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return; + + joint->setPosition(mBeginningPosition); +} + +void FSPosingMotion::FSJointPose::revertCollisionVolume() +{ + if (!mIsCollisionVolume) + return; + + LLJoint* joint = mJointState->getJoint(); + if (!joint) + return; + + joint->setRotation(mBeginningRotation); + joint->setPosition(mBeginningPosition); + joint->setScale(mBeginningScale); +} + +FSPosingMotion::FSJointPose::FSJointPose(LLJoint* joint, bool isCollisionVolume) +{ + mJointState = new LLJointState; + mJointState->setJoint(joint); + mJointState->setUsage(POSER_JOINT_STATE); + + mJointName = joint->getName(); + mIsCollisionVolume = isCollisionVolume; + + mBeginningRotation = mTargetRotation = joint->getRotation(); + mBeginningPosition = mTargetPosition = joint->getPosition(); + mBeginningScale = mTargetScale = joint->getScale(); +} diff --git a/indra/newview/fsposingmotion.h b/indra/newview/fsposingmotion.h index ed0df058fc..f5215b2b0b 100644 --- a/indra/newview/fsposingmotion.h +++ b/indra/newview/fsposingmotion.h @@ -52,398 +52,186 @@ public: /// class FSJointPose { - const size_t MaximumUndoQueueLength = 20; - - /// - /// The constant time interval, in seconds, - /// - std::chrono::duration const _undoUpdateInterval = std::chrono::duration(0.3); - - std::string _jointName = ""; // expected to be a match to LLJoint.getName() for a joint implementation. - LLPointer _jointState; + std::string mJointName = ""; // expected to be a match to LLJoint.getName() for a joint implementation. + LLPointer mJointState{ nullptr }; /// /// Collision Volumes require special treatment when we stop animating an avatar, as they do not revert to their original state natively. /// - bool _isCollisionVolume = false; + bool mIsCollisionVolume{ false }; - LLQuaternion _targetRotation; - LLQuaternion _beginningRotation; - std::deque _lastSetRotations; - size_t _undoneRotationIndex = 0; - std::chrono::system_clock::time_point _timeLastUpdatedRotation = std::chrono::system_clock::now(); + LLQuaternion mTargetRotation; + LLQuaternion mBeginningRotation; + std::deque mLastSetRotations; + size_t mUndoneRotationIndex = 0; + std::chrono::system_clock::time_point mTimeLastUpdatedRotation = std::chrono::system_clock::now(); - LLVector3 _targetPosition; - LLVector3 _beginningPosition; - std::deque _lastSetPositions; - size_t _undonePositionIndex = 0; - std::chrono::system_clock::time_point _timeLastUpdatedPosition = std::chrono::system_clock::now(); + LLVector3 mTargetPosition; + LLVector3 mBeginningPosition; + std::deque mLastSetPositions; + size_t mUndonePositionIndex = 0; + std::chrono::system_clock::time_point mTimeLastUpdatedPosition = std::chrono::system_clock::now(); /// /// Joint scales require special treatment, as they do not revert when we stop animating an avatar. /// - LLVector3 _targetScale; - LLVector3 _beginningScale; - std::deque _lastSetScales; - size_t _undoneScaleIndex = 0; - std::chrono::system_clock::time_point _timeLastUpdatedScale = std::chrono::system_clock::now(); + LLVector3 mTargetScale; + LLVector3 mBeginningScale; + std::deque mLastSetScales; + size_t mUndoneScaleIndex = 0; + std::chrono::system_clock::time_point mTimeLastUpdatedScale = std::chrono::system_clock::now(); /// /// Adds a last position to the deque. /// - void addLastPositionToUndo() - { - if (_undonePositionIndex > 0) - { - for (int i = 0; i < _undonePositionIndex; i++) - _lastSetPositions.pop_front(); - - _undonePositionIndex = 0; - } - - _lastSetPositions.push_front(_targetPosition); - - while (_lastSetPositions.size() > MaximumUndoQueueLength) - _lastSetPositions.pop_back(); - } + void addLastPositionToUndo(); /// /// Adds a last rotation to the deque. /// - void addLastRotationToUndo() - { - if (_undoneRotationIndex > 0) - { - for (int i = 0; i < _undoneRotationIndex; i++) - _lastSetRotations.pop_front(); - - _undoneRotationIndex = 0; - } - - _lastSetRotations.push_front(_targetRotation); - - while (_lastSetRotations.size() > MaximumUndoQueueLength) - _lastSetRotations.pop_back(); - } + void addLastRotationToUndo(); /// /// Adds a last rotation to the deque. /// - void addLastScaleToUndo() - { - if (_undoneScaleIndex > 0) - { - for (int i = 0; i < _undoneScaleIndex; i++) - _lastSetScales.pop_front(); - - _undoneScaleIndex = 0; - } - - _lastSetScales.push_front(_targetScale); - - while (_lastSetScales.size() > MaximumUndoQueueLength) - _lastSetScales.pop_back(); - } + void addLastScaleToUndo(); public: /// /// Gets the name of the joint. /// - std::string jointName() const { return _jointName; } + std::string jointName() const { return mJointName; } /// /// Gets whether this represents a collision volume. /// /// - bool isCollisionVolume() const { return _isCollisionVolume; } + bool isCollisionVolume() const { return mIsCollisionVolume; } /// /// Gets whether a redo of this joints rotation may be performed. /// /// - bool canRedoRotation() const { return _undoneRotationIndex > 0; } + bool canRedoRotation() const { return mUndoneRotationIndex > 0; } /// /// Gets the position the joint was in when the animation was initialized. /// - LLVector3 getBeginningPosition() const { return _beginningPosition; } + LLVector3 getBeginningPosition() const { return mBeginningPosition; } /// /// Gets the position the animator wishes the joint to be in. /// - LLVector3 getTargetPosition() const { return _targetPosition; } + LLVector3 getTargetPosition() const { return mTargetPosition; } /// /// Gets the position the animator wishes the joint to be in. /// - LLVector3 getCurrentPosition() - { - LLVector3 vec3; - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return vec3; - - vec3 = joint->getPosition(); - return vec3; - } + LLVector3 getCurrentPosition(); /// /// Sets the position the animator wishes the joint to be in. /// - void setTargetPosition(const LLVector3& pos) - { - auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - _timeLastUpdatedPosition; - if (timeIntervalSinceLastRotationChange > _undoUpdateInterval) - addLastPositionToUndo(); - - _timeLastUpdatedPosition = std::chrono::system_clock::now(); - _targetPosition.set(pos); - } + void setTargetPosition(const LLVector3& pos); /// /// Gets the rotation the joint was in when the animation was initialized. /// - LLQuaternion getBeginningRotation() const { return _beginningRotation; } + LLQuaternion getBeginningRotation() const { return mBeginningRotation; } /// /// Gets the rotation the animator wishes the joint to be in. /// - LLQuaternion getTargetRotation() const { return _targetRotation; } + LLQuaternion getTargetRotation() const { return mTargetRotation; } /// /// Gets the rotation of the joint. /// - LLQuaternion getCurrentRotation() - { - LLQuaternion quat; - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return quat; - - quat = joint->getRotation(); - return quat; - } + LLQuaternion getCurrentRotation(); /// /// Sets the rotation the animator wishes the joint to be in. /// - void setTargetRotation(const LLQuaternion& rot) - { - auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - _timeLastUpdatedRotation; - if (timeIntervalSinceLastRotationChange > _undoUpdateInterval) - addLastRotationToUndo(); - - _timeLastUpdatedRotation = std::chrono::system_clock::now(); - _targetRotation.set(rot); - } + void setTargetRotation(const LLQuaternion& rot); /// /// Applies a delta to the rotation the joint currently targets. /// - void applyDeltaRotation(const LLQuaternion& rot) - { - auto timeIntervalSinceLastRotationChange = std::chrono::system_clock::now() - _timeLastUpdatedRotation; - if (timeIntervalSinceLastRotationChange > _undoUpdateInterval) - addLastRotationToUndo(); - - _timeLastUpdatedRotation = std::chrono::system_clock::now(); - _targetRotation = _targetRotation * rot; - } + void applyDeltaRotation(const LLQuaternion& rot); /// /// Gets the scale the animator wishes the joint to have. /// - LLVector3 getTargetScale() const { return _targetScale; } + LLVector3 getTargetScale() const { return mTargetScale; } /// /// Gets the scale the joint has. /// - LLVector3 getCurrentScale() - { - LLVector3 vec3; - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return vec3; - - vec3 = joint->getScale(); - return vec3; - } + LLVector3 getCurrentScale(); /// /// Gets the scale the joint had when the animation was initialized. /// - LLVector3 getBeginningScale() const { return _beginningScale; } + LLVector3 getBeginningScale() const { return mBeginningScale; } /// /// Sets the scale the animator wishes the joint to have. /// - void setTargetScale(LLVector3 scale) - { - auto timeIntervalSinceLastScaleChange = std::chrono::system_clock::now() - _timeLastUpdatedScale; - if (timeIntervalSinceLastScaleChange > _undoUpdateInterval) - addLastScaleToUndo(); - - _timeLastUpdatedScale = std::chrono::system_clock::now(); - _targetScale.set(scale); - } + void setTargetScale(LLVector3 scale); /// /// Undoes the last position set, if any. /// - void undoLastPositionSet() - { - if (_lastSetPositions.empty()) - return; - - if (_undonePositionIndex == 0) // at the top of the queue add the current - addLastPositionToUndo(); - - _undonePositionIndex++; - _undonePositionIndex = llclamp(_undonePositionIndex, 0, _lastSetPositions.size() - 1); - _targetPosition.set(_lastSetPositions[_undonePositionIndex]); - } + void undoLastPositionSet(); /// /// Undoes the last position set, if any. /// - void redoLastPositionSet() - { - if (_lastSetPositions.empty()) - return; - - _undonePositionIndex--; - _undonePositionIndex = llclamp(_undonePositionIndex, 0, _lastSetPositions.size() - 1); - - _targetPosition.set(_lastSetPositions[_undonePositionIndex]); - if (_undonePositionIndex == 0) - _lastSetPositions.pop_front(); - } + void redoLastPositionSet(); /// /// Undoes the last rotation set, if any. /// Ordinarily the queue does not contain the current rotation, because we rely on time to add, and not button-up. /// When we undo, if we are at the top of the queue, we need to add the current rotation so we can redo back to it. - /// Thus when we start undoing, _undoneRotationIndex points at the current rotation. + /// Thus when we start undoing, mUndoneRotationIndex points at the current rotation. /// - void undoLastRotationSet() - { - if (_lastSetRotations.empty()) - return; - - if (_undoneRotationIndex == 0) // at the top of the queue add the current - addLastRotationToUndo(); - - _undoneRotationIndex++; - _undoneRotationIndex = llclamp(_undoneRotationIndex, 0, _lastSetRotations.size() - 1); - _targetRotation.set(_lastSetRotations[_undoneRotationIndex]); - } + void undoLastRotationSet(); /// /// Undoes the last rotation set, if any. /// - void redoLastRotationSet() - { - if (_lastSetRotations.empty()) - return; + void redoLastRotationSet(); - _undoneRotationIndex--; - _undoneRotationIndex = llclamp(_undoneRotationIndex, 0, _lastSetRotations.size() - 1); + void undoLastScaleSet(); - _targetRotation.set(_lastSetRotations[_undoneRotationIndex]); - if (_undoneRotationIndex == 0) - _lastSetRotations.pop_front(); - } - - void undoLastScaleSet() - { - if (_lastSetScales.empty()) - return; - - if (_undoneScaleIndex == 0) - addLastScaleToUndo(); - - _undoneScaleIndex++; - _undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1); - _targetScale.set(_lastSetScales[_undoneScaleIndex]); - } - - void redoLastScaleSet() - { - if (_lastSetScales.empty()) - return; - - _undoneScaleIndex--; - _undoneScaleIndex = llclamp(_undoneScaleIndex, 0, _lastSetScales.size() - 1); - - _targetScale.set(_lastSetScales[_undoneScaleIndex]); - if (_undoneScaleIndex == 0) - _lastSetScales.pop_front(); - } + void redoLastScaleSet(); /// /// Restores the joint represented by this to the scale it had when this motion started. /// - void revertJointScale() - { - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return; - - joint->setScale(_beginningScale); - } + void revertJointScale(); /// /// Restores the joint represented by this to the position it had when this motion started. /// - void revertJointPosition() - { - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return; - - joint->setPosition(_beginningPosition); - } + 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() - { - if (!_isCollisionVolume) - return; - - LLJoint* joint = _jointState->getJoint(); - if (!joint) - return; - - joint->setRotation(_beginningRotation); - joint->setPosition(_beginningPosition); - joint->setScale(_beginningScale); - } + void revertCollisionVolume(); /// /// Gets the pointer to the jointstate for the joint this represents. /// - LLPointer getJointState() const { return _jointState; } + LLPointer getJointState() const { return mJointState; } - FSJointPose(LLJoint* joint, bool isCollisionVolume = false) - { - _jointState = new LLJointState; - _jointState->setJoint(joint); - _jointState->setUsage(POSER_JOINT_STATE); - - _jointName = joint->getName(); - _isCollisionVolume = isCollisionVolume; - - _beginningRotation = _targetRotation = joint->getRotation(); - _beginningPosition = _targetPosition = joint->getPosition(); - _beginningScale = _targetScale = joint->getScale(); - } + FSJointPose(LLJoint* joint, bool isCollisionVolume = false); }; public: - virtual bool getLoop() { return TRUE; } + virtual bool getLoop() { return true; } virtual F32 getDuration() { return 0.0; } @@ -499,13 +287,13 @@ public: /// /// The name of the joint to get the pose for. /// The matching joint pose, if found, otherwise null. - FSJointPose* getJointPoseByJointName(std::string name); + FSJointPose* getJointPoseByJointName(const std::string& name); /// /// Gets the motion identity for this animation. /// /// The unique, per-session, per-character motion identity. - LLAssetID motionId() const { return _motionID; } + LLAssetID motionId() const { return mMotionID; } private: /// @@ -516,7 +304,7 @@ private: /// /// The unique identity of this motion. /// - LLAssetID _motionID; + LLAssetID mMotionID; /// /// The amount of time, in seconds, we use for transitioning between one animation-state to another; this affects the 'fluidity' @@ -524,12 +312,12 @@ private: /// Use caution making this larger than the subjective amount of time between adjusting a joint and then choosing to use 'undo' it. /// Undo-function waits a similar amount of time after the last user-incited joint change to add a 'restore point'. /// - const F32 _interpolationTime = 0.25f; + const F32 mInterpolationTime = 0.25f; /// /// The collection of joint poses this motion uses to pose the joints of the character this is animating. /// - std::vector _jointPoses; + std::vector mJointPoses; /// /// Removes the current joint state for the supplied joint, and adds a new one. diff --git a/indra/newview/fsvirtualtrackpad.cpp b/indra/newview/fsvirtualtrackpad.cpp index f58f46c388..772c2dc4c6 100644 --- a/indra/newview/fsvirtualtrackpad.cpp +++ b/indra/newview/fsvirtualtrackpad.cpp @@ -54,18 +54,18 @@ FSVirtualTrackpad::FSVirtualTrackpad(const FSVirtualTrackpad::Params &p) mImgSunBack(p.image_sun_back), mImgSunFront(p.image_sun_front), mImgSphere(p.image_sphere), - _allowPinchMode(p.pinch_mode), - _infiniteScrollMode(p.infinite_scroll_mode) + mAllowPinchMode(p.pinch_mode), + mInfiniteScrollMode(p.infinite_scroll_mode) { LLRect border_rect = getLocalRect(); - _cursorValueX = _pinchCursorValueX = border_rect.getCenterX(); - _cursorValueY = _pinchCursorValueY = border_rect.getCenterY(); - _cursorValueZ = _pinchCursorValueZ = 0; + mCursorValueX = mPinchCursorValueX = border_rect.getCenterX(); + mCursorValueY = mPinchCursorValueY = border_rect.getCenterY(); + mCursorValueZ = mPinchCursorValueZ = 0; - _thumbClickOffsetX = _thumbClickOffsetY = _pinchThumbClickOffsetX = _pinchThumbClickOffsetY = 0; - _posXwhenCtrlDown = _posYwhenCtrlDown = 0; - _pinchValueDeltaX = _pinchValueDeltaY = _pinchValueDeltaZ = 0; - _valueDeltaX = _valueDeltaY = _valueDeltaZ = 0; + mThumbClickOffsetX = mThumbClickOffsetY = mPinchThumbClickOffsetX = mPinchThumbClickOffsetY = 0; + mPosXwhenCtrlDown = mPosYwhenCtrlDown = 0; + mPinchValueDeltaX = mPinchValueDeltaY = mPinchValueDeltaZ = 0; + mValueDeltaX = mValueDeltaY = mValueDeltaZ = 0; LLViewBorder::Params border = p.border; border.rect(border_rect); @@ -93,8 +93,8 @@ void FSVirtualTrackpad::drawThumb(bool isPinchThumb) else thumb = isPinchThumb ? mImgSunBack : mImgMoonBack; - S32 x = isPinchThumb ? _pinchCursorValueX : _cursorValueX; - S32 y = isPinchThumb ? _pinchCursorValueY : _cursorValueY; + S32 x = isPinchThumb ? mPinchCursorValueX : mCursorValueX; + S32 y = isPinchThumb ? mPinchCursorValueY : mCursorValueY; wrapOrClipCursorPosition(&x, &y); @@ -122,11 +122,11 @@ void FSVirtualTrackpad::determineThumbClickError(S32 x, S32 y) if (!mImgSunFront) return; - _thumbClickOffsetX = 0; - _thumbClickOffsetY = 0; + mThumbClickOffsetX = 0; + mThumbClickOffsetY = 0; - S32 errorX = _cursorValueX; - S32 errorY = _cursorValueY; + S32 errorX = mCursorValueX; + S32 errorY = mCursorValueY; wrapOrClipCursorPosition(&errorX, &errorY); errorX -= x; errorY -= y; @@ -136,37 +136,37 @@ void FSVirtualTrackpad::determineThumbClickError(S32 x, S32 y) if (fabs(errorY) > mImgSunFront->getHeight() / 2.0) return; - _thumbClickOffsetX = errorX; - _thumbClickOffsetY = errorY; + mThumbClickOffsetX = errorX; + mThumbClickOffsetY = errorY; } void FSVirtualTrackpad::updateClickErrorIfInfiniteScrolling() { - if (!_infiniteScrollMode) + if (!mInfiniteScrollMode) return; - S32 errorX = _cursorValueX; - S32 errorY = _cursorValueY; + S32 errorX = mCursorValueX; + S32 errorY = mCursorValueY; LLRect rect = mTouchArea->getRect(); while (errorX > rect.mRight) { errorX -= rect.getWidth(); - _thumbClickOffsetX += rect.getWidth(); + mThumbClickOffsetX += rect.getWidth(); } while (errorX < rect.mLeft) { errorX += rect.getWidth(); - _thumbClickOffsetX -= rect.getWidth(); + mThumbClickOffsetX -= rect.getWidth(); } while (errorY > rect.mTop) { errorY -= rect.getHeight(); - _thumbClickOffsetY += rect.getHeight(); + mThumbClickOffsetY += rect.getHeight(); } while (errorY < rect.mBottom) { errorY += rect.getHeight(); - _thumbClickOffsetY -= rect.getHeight(); + mThumbClickOffsetY -= rect.getHeight(); } } @@ -177,11 +177,11 @@ void FSVirtualTrackpad::determineThumbClickErrorForPinch(S32 x, S32 y) if (!mImgMoonFront) return; - _pinchThumbClickOffsetX = 0; - _pinchThumbClickOffsetY = 0; + mPinchThumbClickOffsetX = 0; + mPinchThumbClickOffsetY = 0; - S32 errorX = _pinchCursorValueX; - S32 errorY = _pinchCursorValueY; + S32 errorX = mPinchCursorValueX; + S32 errorY = mPinchCursorValueY; wrapOrClipCursorPosition(&errorX, &errorY); errorX -= x; errorY -= y; @@ -191,37 +191,37 @@ void FSVirtualTrackpad::determineThumbClickErrorForPinch(S32 x, S32 y) if (fabs(errorY) > mImgMoonFront->getHeight() / 2.0) return; - _pinchThumbClickOffsetX = errorX; - _pinchThumbClickOffsetY = errorY; + mPinchThumbClickOffsetX = errorX; + mPinchThumbClickOffsetY = errorY; } void FSVirtualTrackpad::updateClickErrorIfInfiniteScrollingForPinch() { - if (!_infiniteScrollMode) + if (!mInfiniteScrollMode) return; - S32 errorX = _cursorValueX; - S32 errorY = _cursorValueY; + S32 errorX = mCursorValueX; + S32 errorY = mCursorValueY; LLRect rect = mTouchArea->getRect(); while (errorX > rect.mRight) { errorX -= rect.getWidth(); - _pinchThumbClickOffsetX += rect.getWidth(); + mPinchThumbClickOffsetX += rect.getWidth(); } while (errorX < rect.mLeft) { errorX += rect.getWidth(); - _pinchThumbClickOffsetX -= rect.getWidth(); + mPinchThumbClickOffsetX -= rect.getWidth(); } while (errorY > rect.mTop) { errorY -= rect.getHeight(); - _pinchThumbClickOffsetY += rect.getHeight(); + mPinchThumbClickOffsetY += rect.getHeight(); } while (errorY < rect.mBottom) { errorY += rect.getHeight(); - _pinchThumbClickOffsetY -= rect.getHeight(); + mPinchThumbClickOffsetY -= rect.getHeight(); } } @@ -229,7 +229,7 @@ void FSVirtualTrackpad::draw() { mImgSphere->draw(mTouchArea->getRect(), mTouchArea->isInEnabledChain() ? UI_VERTEX_COLOR : UI_VERTEX_COLOR % 0.5f); - if (_allowPinchMode) + if (mAllowPinchMode) drawThumb(true); drawThumb(false); @@ -258,25 +258,25 @@ void FSVirtualTrackpad::setValue(const LLSD& value) void FSVirtualTrackpad::setValue(F32 x, F32 y, F32 z) { - convertNormalizedToPixelPos(x, y, z, &_cursorValueX, &_cursorValueY, &_cursorValueZ); - _valueX = _cursorValueX; - _valueY = _cursorValueY; - _valueZ = _cursorValueZ; + convertNormalizedToPixelPos(x, y, z, &mCursorValueX, &mCursorValueY, &mCursorValueZ); + mValueX = mCursorValueX; + mValueY = mCursorValueY; + mValueZ = mCursorValueZ; } void FSVirtualTrackpad::setPinchValue(F32 x, F32 y, F32 z) { - convertNormalizedToPixelPos(x, y, z, &_pinchCursorValueX, &_pinchCursorValueY, &_pinchCursorValueZ); - _pinchValueX = _pinchCursorValueX; - _pinchValueY = _pinchCursorValueY; - _pinchValueZ = _pinchCursorValueZ; + convertNormalizedToPixelPos(x, y, z, &mPinchCursorValueX, &mPinchCursorValueY, &mPinchCursorValueZ); + mPinchValueX = mPinchCursorValueX; + mPinchValueY = mPinchCursorValueY; + mPinchValueZ = mPinchCursorValueZ; } -LLSD FSVirtualTrackpad::getValue() const { return normalizePixelPos(_valueX, _valueY, _valueZ).getValue(); } -LLSD FSVirtualTrackpad::getValueDelta() { return normalizeDelta(_valueDeltaX, _valueDeltaY, _valueDeltaZ).getValue(); } +LLSD FSVirtualTrackpad::getValue() const { return normalizePixelPos(mValueX, mValueY, mValueZ).getValue(); } +LLSD FSVirtualTrackpad::getValueDelta() { return normalizeDelta(mValueDeltaX, mValueDeltaY, mValueDeltaZ).getValue(); } -LLSD FSVirtualTrackpad::getPinchValue() { return normalizePixelPos(_pinchValueX, _pinchValueY, _pinchValueZ).getValue(); } -LLSD FSVirtualTrackpad::getPinchValueDelta() { return normalizeDelta(_pinchValueDeltaX, _pinchValueDeltaY, _pinchValueDeltaZ).getValue(); } +LLSD FSVirtualTrackpad::getPinchValue() { return normalizePixelPos(mPinchValueX, mPinchValueY, mPinchValueZ).getValue(); } +LLSD FSVirtualTrackpad::getPinchValueDelta() { return normalizeDelta(mPinchValueDeltaX, mPinchValueDeltaY, mPinchValueDeltaZ).getValue(); } void FSVirtualTrackpad::wrapOrClipCursorPosition(S32* x, S32* y) const { @@ -284,7 +284,7 @@ void FSVirtualTrackpad::wrapOrClipCursorPosition(S32* x, S32* y) const return; LLRect rect = mTouchArea->getRect(); - if (_infiniteScrollMode) + if (mInfiniteScrollMode) { while (*x > rect.mRight) *x -= rect.getWidth(); @@ -323,152 +323,152 @@ void FSVirtualTrackpad::getHoverMovementDeltas(S32 x, S32 y, MASK mask, S32* del return; S32 fromX, fromY; - fromX = _doingPinchMode ? _pinchCursorValueX : _cursorValueX; - fromY = _doingPinchMode ? _pinchCursorValueY : _cursorValueY; + fromX = mDoingPinchMode ? mPinchCursorValueX : mCursorValueX; + fromY = mDoingPinchMode ? mPinchCursorValueY : mCursorValueY; if (mask & MASK_CONTROL) { - if (!_heldDownControlBefore) + if (!mHeldDownControlBefore) { - _posXwhenCtrlDown = x; - _posYwhenCtrlDown = y; - _heldDownControlBefore = true; + mPosXwhenCtrlDown = x; + mPosYwhenCtrlDown = y; + mHeldDownControlBefore = true; } - if (_doingPinchMode) + if (mDoingPinchMode) { - *deltaX = _posXwhenCtrlDown - (_posXwhenCtrlDown - x) / 8 + _pinchThumbClickOffsetX - fromX; - *deltaY = _posYwhenCtrlDown - (_posYwhenCtrlDown - y) / 8 + _pinchThumbClickOffsetY - fromY; + *deltaX = mPosXwhenCtrlDown - (mPosXwhenCtrlDown - x) / 8 + mPinchThumbClickOffsetX - fromX; + *deltaY = mPosYwhenCtrlDown - (mPosYwhenCtrlDown - y) / 8 + mPinchThumbClickOffsetY - fromY; } else { - *deltaX = _posXwhenCtrlDown - (_posXwhenCtrlDown - x) / 8 + _thumbClickOffsetX - fromX; - *deltaY = _posYwhenCtrlDown - (_posYwhenCtrlDown - y) / 8 + _thumbClickOffsetY - fromY; + *deltaX = mPosXwhenCtrlDown - (mPosXwhenCtrlDown - x) / 8 + mThumbClickOffsetX - fromX; + *deltaY = mPosYwhenCtrlDown - (mPosYwhenCtrlDown - y) / 8 + mThumbClickOffsetY - fromY; } } else { - if (_heldDownControlBefore) + if (mHeldDownControlBefore) { - _thumbClickOffsetX = fromX - x; - _thumbClickOffsetY = fromY - y; - _heldDownControlBefore = false; + mThumbClickOffsetX = fromX - x; + mThumbClickOffsetY = fromY - y; + mHeldDownControlBefore = false; } - if (_doingPinchMode) + if (mDoingPinchMode) { - *deltaX = x + _pinchThumbClickOffsetX - fromX; - *deltaY = y + _pinchThumbClickOffsetY - fromY; + *deltaX = x + mPinchThumbClickOffsetX - fromX; + *deltaY = y + mPinchThumbClickOffsetY - fromY; } else { - *deltaX = x + _thumbClickOffsetX - fromX; - *deltaY = y + _thumbClickOffsetY - fromY; + *deltaX = x + mThumbClickOffsetX - fromX; + *deltaY = y + mThumbClickOffsetY - fromY; } } } void FSVirtualTrackpad::applyHoverMovementDeltas(S32 deltaX, S32 deltaY, MASK mask) { - if (_doingPinchMode) + if (mDoingPinchMode) { - _pinchCursorValueX += deltaX; - _pinchCursorValueY += deltaY; - if (!_infiniteScrollMode) // then constrain the cursor within control area - wrapOrClipCursorPosition(&_pinchCursorValueX, &_pinchCursorValueY); + mPinchCursorValueX += deltaX; + mPinchCursorValueY += deltaY; + if (!mInfiniteScrollMode) // then constrain the cursor within control area + wrapOrClipCursorPosition(&mPinchCursorValueX, &mPinchCursorValueY); } else { - _cursorValueX += deltaX; - _cursorValueY += deltaY; + mCursorValueX += deltaX; + mCursorValueY += deltaY; - if (!_infiniteScrollMode) // then constrain the cursor within control area - wrapOrClipCursorPosition(&_cursorValueX, &_cursorValueY); + if (!mInfiniteScrollMode) // then constrain the cursor within control area + wrapOrClipCursorPosition(&mCursorValueX, &mCursorValueY); } } void FSVirtualTrackpad::applyDeltasToValues(S32 deltaX, S32 deltaY, MASK mask) { - if (_doingPinchMode) + if (mDoingPinchMode) { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) { - _pinchValueY += deltaY; - _pinchValueZ += deltaX; + mPinchValueY += deltaY; + mPinchValueZ += deltaX; } else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) { - _pinchValueX += deltaX; - _pinchValueZ += deltaY; + mPinchValueX += deltaX; + mPinchValueZ += deltaY; } else { - _pinchValueX += deltaX; - _pinchValueY += deltaY; + mPinchValueX += deltaX; + mPinchValueY += deltaY; } } else { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) { - _valueY += deltaY; - _valueZ += deltaX; + mValueY += deltaY; + mValueZ += deltaX; } else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) { - _valueX += deltaX; - _valueZ += deltaY; + mValueX += deltaX; + mValueZ += deltaY; } else { - _valueX += deltaX; - _valueY += deltaY; + mValueX += deltaX; + mValueY += deltaY; } } } void FSVirtualTrackpad::applyDeltasToDeltaValues(S32 deltaX, S32 deltaY, MASK mask) { - if (_doingPinchMode) + if (mDoingPinchMode) { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) { - _pinchValueDeltaX = 0; - _pinchValueDeltaY = deltaY; - _pinchValueDeltaZ = deltaX; + mPinchValueDeltaX = 0; + mPinchValueDeltaY = deltaY; + mPinchValueDeltaZ = deltaX; } else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) { - _pinchValueDeltaX = deltaX; - _pinchValueDeltaY = 0; - _pinchValueDeltaZ = deltaY; + mPinchValueDeltaX = deltaX; + mPinchValueDeltaY = 0; + mPinchValueDeltaZ = deltaY; } else { - _pinchValueDeltaX = deltaX; - _pinchValueDeltaY = deltaY; - _pinchValueDeltaZ = 0; + mPinchValueDeltaX = deltaX; + mPinchValueDeltaY = deltaY; + mPinchValueDeltaZ = 0; } } else { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) { - _valueDeltaX = 0; - _valueDeltaY = deltaY; - _valueDeltaZ = deltaX; + mValueDeltaX = 0; + mValueDeltaY = deltaY; + mValueDeltaZ = deltaX; } else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) { - _valueDeltaX = deltaX; - _valueDeltaY = 0; - _valueDeltaZ = deltaY; + mValueDeltaX = deltaX; + mValueDeltaY = 0; + mValueDeltaZ = deltaY; } else { - _valueDeltaX = deltaX; - _valueDeltaY = deltaY; - _valueDeltaZ = 0; + mValueDeltaX = deltaX; + mValueDeltaY = deltaY; + mValueDeltaZ = 0; } } } @@ -520,7 +520,7 @@ void FSVirtualTrackpad::convertNormalizedToPixelPos(F32 x, F32 y, F32 z, S32 *va S32 width = rect.getWidth(); S32 height = rect.getHeight(); - if (_infiniteScrollMode) + if (mInfiniteScrollMode) { *valX = centerX + ll_round(x * width / 2); *valY = centerY + ll_round(y * height / 2); @@ -539,7 +539,7 @@ bool FSVirtualTrackpad::handleMouseUp(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { gFocusMgr.setMouseCapture(NULL); - _heldDownControlBefore = false; + mHeldDownControlBefore = false; make_ui_sound("UISndClickRelease"); } @@ -563,7 +563,7 @@ bool FSVirtualTrackpad::handleRightMouseUp(S32 x, S32 y, MASK mask) { if (hasMouseCapture()) { - _doingPinchMode = false; + mDoingPinchMode = false; gFocusMgr.setMouseCapture(NULL); make_ui_sound("UISndClickRelease"); @@ -575,14 +575,14 @@ bool FSVirtualTrackpad::handleRightMouseUp(S32 x, S32 y, MASK mask) // move pinch cursor bool FSVirtualTrackpad::handleRightMouseDown(S32 x, S32 y, MASK mask) { - if (!_allowPinchMode) + if (!mAllowPinchMode) return LLView::handleRightMouseDown(x, y, mask); if (isPointInTouchArea(x, y)) { determineThumbClickErrorForPinch(x, y); updateClickErrorIfInfiniteScrollingForPinch(); - _doingPinchMode = true; + mDoingPinchMode = true; gFocusMgr.setMouseCapture(this); make_ui_sound("UISndClick"); @@ -602,23 +602,23 @@ bool FSVirtualTrackpad::handleScrollWheel(S32 x, S32 y, S32 clicks) if (mask & MASK_CONTROL) changeAmount /= 5; - if (_doingPinchMode) + if (mDoingPinchMode) { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) - _pinchValueX -= clicks * changeAmount; + mPinchValueX -= clicks * changeAmount; else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) - _pinchValueY -= clicks * changeAmount; + mPinchValueY -= clicks * changeAmount; else - _pinchValueZ -= clicks * changeAmount; + mPinchValueZ -= clicks * changeAmount; } else { if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_ALT) - _valueX -= clicks * changeAmount; + mValueX -= clicks * changeAmount; else if ((mask & (MASK_SHIFT | MASK_ALT)) == MASK_SHIFT) - _valueY -= clicks * changeAmount; + mValueY -= clicks * changeAmount; else - _valueZ -= clicks * changeAmount; + mValueZ -= clicks * changeAmount; } if (!hasMouseCapture()) diff --git a/indra/newview/fsvirtualtrackpad.h b/indra/newview/fsvirtualtrackpad.h index fc4611a082..79703a14db 100644 --- a/indra/newview/fsvirtualtrackpad.h +++ b/indra/newview/fsvirtualtrackpad.h @@ -100,8 +100,8 @@ protected: FSVirtualTrackpad(const Params&); protected: - LLPanel* mTouchArea; - LLViewBorder* mBorder; + LLPanel* mTouchArea{ nullptr }; + LLViewBorder* mBorder{ nullptr }; private: const F32 ThirdAxisQuantization = 0.001f; // To avoid quantizing the third axis as we add integer wheel clicks, use this to preserve some precision as int. @@ -124,21 +124,21 @@ private: void applyDeltasToValues(S32 deltaX, S32 deltaY, MASK mask); void applyDeltasToDeltaValues(S32 deltaX, S32 deltaY, MASK mask); - LLUIImage* mImgMoonBack; - LLUIImage* mImgMoonFront; - LLUIImage* mImgSunBack; - LLUIImage* mImgSunFront; - LLUIImage* mImgSphere; + LLUIImage* mImgMoonBack{ nullptr }; + LLUIImage* mImgMoonFront{ nullptr }; + LLUIImage* mImgSunBack{ nullptr }; + LLUIImage* mImgSunFront{ nullptr }; + LLUIImage* mImgSphere{ nullptr }; /// /// Whether we allow the second cursor to appear. /// - bool _allowPinchMode = false; + bool mAllowPinchMode{ false }; /// /// Whether we should be moving the pinch cursor now /// - bool _doingPinchMode = false; + bool mDoingPinchMode{ false }; /// /// Whether to allow the cursor(s) to 'wrap'. @@ -148,48 +148,48 @@ private: /// When true, the cursor 'disappears' out the top, and starts from the bottom, /// effectively allowing infinite scrolling. /// - bool _infiniteScrollMode = false; + bool mInfiniteScrollMode{ false }; - bool _heldDownControlBefore = false; + bool mHeldDownControlBefore{ false }; /// /// The values the owner will get and set. /// - S32 _valueX; - S32 _valueY; - S32 _valueZ; - S32 _pinchValueX; - S32 _pinchValueY; - S32 _pinchValueZ; + S32 mValueX{ 0 }; + S32 mValueY{ 0 }; + S32 mValueZ{ 0 }; + S32 mPinchValueX{ 0 }; + S32 mPinchValueY{ 0 }; + S32 mPinchValueZ{ 0 }; /// /// The delta values the owner will get and set. /// - S32 _valueDeltaX; - S32 _valueDeltaY; - S32 _valueDeltaZ; - S32 _pinchValueDeltaX; - S32 _pinchValueDeltaY; - S32 _pinchValueDeltaZ; + S32 mValueDeltaX{ 0 }; + S32 mValueDeltaY{ 0 }; + S32 mValueDeltaZ{ 0 }; + S32 mPinchValueDeltaX{ 0 }; + S32 mPinchValueDeltaY{ 0 }; + S32 mPinchValueDeltaZ{ 0 }; /// /// The various values placing the cursors and documenting behaviours. /// Where relevant, all are scaled in pixels. /// - S32 _cursorValueX; - S32 _cursorValueY; - S32 _cursorValueZ; - S32 _pinchCursorValueX; - S32 _pinchCursorValueY; - S32 _pinchCursorValueZ; + S32 mCursorValueX{ 0 }; + S32 mCursorValueY{ 0 }; + S32 mCursorValueZ{ 0 }; + S32 mPinchCursorValueX{ 0 }; + S32 mPinchCursorValueY{ 0 }; + S32 mPinchCursorValueZ{ 0 }; // if one clicks on or about the thumb, we don't move it, instead we calculate the click-position error and factor it out - S32 _thumbClickOffsetX; - S32 _thumbClickOffsetY; - S32 _pinchThumbClickOffsetX; - S32 _pinchThumbClickOffsetY; - S32 _posXwhenCtrlDown; - S32 _posYwhenCtrlDown; + S32 mThumbClickOffsetX{ 0 }; + S32 mThumbClickOffsetY{ 0 }; + S32 mPinchThumbClickOffsetX{ 0 }; + S32 mPinchThumbClickOffsetY{ 0 }; + S32 mPosXwhenCtrlDown{ 0 }; + S32 mPosYwhenCtrlDown{ 0 }; }; #endif From db7de433d811dc33db3550b84e70dbc4faa37919 Mon Sep 17 00:00:00 2001 From: Beq Date: Sun, 27 Oct 2024 12:39:42 +0000 Subject: [PATCH 02/16] Make the password placeholder less confusing --- indra/newview/fspanellogin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/fspanellogin.cpp b/indra/newview/fspanellogin.cpp index 4ccc60194f..1c6d7ddf98 100644 --- a/indra/newview/fspanellogin.cpp +++ b/indra/newview/fspanellogin.cpp @@ -567,7 +567,7 @@ void FSPanelLogin::setFields(LLPointer credential, bool from_start // We don't actually use the password input field, // fill it with MAX_PASSWORD_SL characters so we get a // nice row of asterisks. - const std::string filler("123456789!123456"); + const std::string filler("Enter a password"); sInstance->getChild("password_edit")->setText(filler); sInstance->mPasswordLength = filler.length(); sInstance->updateLoginButtons(); From 09c4fdc5195ea7e88fc686b1214eb96c9a0c61c0 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 19 Sep 2024 19:30:05 +0200 Subject: [PATCH 03/16] [FIRE-34734 maybe] #1519 ObjectGrab message includes invalid SurfaceInfo data when in mouselook mode --- indra/newview/lltoolselect.cpp | 9 ++++----- indra/newview/llviewerwindow.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index e402c7d2ef..03f35c668e 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -63,17 +63,17 @@ LLToolSelect::LLToolSelect( LLToolComposite* composite ) : LLTool( std::string("Select"), composite ), mIgnoreGroup( false ) { - } +} // True if you selected an object. bool LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { // do immediate pick query bool pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - bool pick_transparent = gSavedSettings.getBOOL("SelectInvisibleObjects"); - bool pick_reflection_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); + static LLCachedControl select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); + static LLCachedControl select_reflection_probes(gSavedSettings, "SelectReflectionProbes"); - mPick = gViewerWindow->pickImmediate(x, y, pick_transparent, pick_rigged, false, true, pick_reflection_probe); + mPick = gViewerWindow->pickImmediate(x, y, select_invisible_objects, pick_rigged, false, true, select_reflection_probes); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); @@ -81,7 +81,6 @@ bool LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) return mPick.getObject().notNull(); } - // static LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pick, bool ignore_group, bool temp_select, bool select_root) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 7222645336..f4b2765632 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5347,15 +5347,15 @@ void LLViewerWindow::pickAsync( S32 x, bool pick_unselectable, bool pick_reflection_probes) { + static LLCachedControl select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); // "Show Debug Alpha" means no object actually transparent bool in_build_mode = LLFloaterReg::instanceVisible("build"); - if (LLDrawPoolAlpha::sShowDebugAlpha - || (in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects"))) + if (LLDrawPoolAlpha::sShowDebugAlpha || (in_build_mode && select_invisible_objects)) { pick_transparent = true; } - LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, false, pick_reflection_probes, pick_unselectable, true, callback); + LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, false, pick_reflection_probes, true, pick_unselectable, callback); schedulePick(pick_info); } @@ -5379,7 +5379,6 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) mWindow->delayInputProcessing(); } - void LLViewerWindow::performPick() { if (!mPicks.empty()) @@ -5413,8 +5412,9 @@ void LLViewerWindow::returnEmptyPicks() // Performs the GL object/land pick. LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, bool pick_transparent, bool pick_rigged, bool pick_particle, bool pick_unselectable, bool pick_reflection_probe) { + static LLCachedControl select_invisible_objects(gSavedSettings, "SelectInvisibleObjects"); bool in_build_mode = LLFloaterReg::instanceVisible("build"); - if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) + if ((in_build_mode && select_invisible_objects) || LLDrawPoolAlpha::sShowDebugAlpha) { // build mode allows interaction with all transparent objects // "Show Debug Alpha" means no object actually transparent @@ -5422,7 +5422,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, bool pick_transp } // shortcut queueing in mPicks and just update mLastPick in place - MASK key_mask = gKeyboard->currentMask(true); + MASK key_mask = gKeyboard->currentMask(true); mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, pick_rigged, pick_particle, pick_reflection_probe, true, false, NULL); mLastPick.fetchResults(); @@ -7370,14 +7370,14 @@ LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos, bool pick_rigged, bool pick_particle, bool pick_reflection_probe, - bool pick_uv_coords, + bool pick_surface_info, bool pick_unselectable, void (*pick_callback)(const LLPickInfo& pick_info)) : mMousePt(mouse_pos), mKeyMask(keyboard_mask), mPickCallback(pick_callback), mPickType(PICK_INVALID), - mWantSurfaceInfo(pick_uv_coords), + mWantSurfaceInfo(pick_surface_info), mObjectFace(-1), mUVCoords(-1.f, -1.f), mSTCoords(-1.f, -1.f), From 119a4792ab1c9aef2f6381e4e17e96ff35c39bbb Mon Sep 17 00:00:00 2001 From: Beq Date: Sun, 27 Oct 2024 18:41:33 +0000 Subject: [PATCH 04/16] FIRE-34754 - Fix the help link on Region Restart Schedule floater --- .../skins/default/xui/en/floater_region_restart_schedule.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/floater_region_restart_schedule.xml b/indra/newview/skins/default/xui/en/floater_region_restart_schedule.xml index b6d77dddeb..885cf8f415 100644 --- a/indra/newview/skins/default/xui/en/floater_region_restart_schedule.xml +++ b/indra/newview/skins/default/xui/en/floater_region_restart_schedule.xml @@ -3,7 +3,7 @@ height="180" layout="topleft" name="floater_region_restart_schedule" - help_topic="Preferences_Graphics_Advanced" + help_topic="region_restart_schedule" single_instance="true" save_rect="true" title="Region Restart Schedule" From dccdea65266e648b706093dbd4b00bf33b9a5d07 Mon Sep 17 00:00:00 2001 From: PanteraPolnocy Date: Sun, 27 Oct 2024 23:41:33 +0100 Subject: [PATCH 05/16] FIRE-34733 Russian (by Romka Swallowtail) and Polish translation updates (poser) --- .../skins/default/xui/pl/floater_fs_poser.xml | 279 ++++++++++++++++++ .../xui/pl/menu_fs_poser_poses_btn.xml | 10 + .../skins/default/xui/pl/menu_viewer.xml | 1 + .../newview/skins/default/xui/pl/strings.xml | 6 + .../skins/default/xui/ru/floater_fs_poser.xml | 270 +++++++++++++++++ 5 files changed, 566 insertions(+) create mode 100644 indra/newview/skins/default/xui/pl/floater_fs_poser.xml create mode 100644 indra/newview/skins/default/xui/pl/menu_fs_poser_poses_btn.xml create mode 100644 indra/newview/skins/default/xui/ru/floater_fs_poser.xml diff --git a/indra/newview/skins/default/xui/pl/floater_fs_poser.xml b/indra/newview/skins/default/xui/pl/floater_fs_poser.xml new file mode 100644 index 0000000000..5992da735f --- /dev/null +++ b/indra/newview/skins/default/xui/pl/floater_fs_poser.xml @@ -0,0 +1,279 @@ + + + Ciało + Czoło/Brwi + Oczy/Powieki + Policzki/Usta + Lewa ręka + Lewe ramię + Prawa ręka + Prawe ramię + Nogi + Ogon + Kończyny tylne + Skrzydła + Cały awatar + Tułów + Klatka piersiowa + Szyja + Głowa + Prawe oko + Lewe oko + Czoło, lewa strona + Czoło, prawa strona + Brwi zewnętrzne lewe + Brwi środkowe lewe + Brwi wewnętrzne lewe + Brwi zewnętrzne prawe + Brwi środkowe prawe + Brwi wewnętrzne prawe + Powieka górna lewa + Powieka dolna lewa + Powieka górna prawa + Powieka dolna prawa + Ucho górne lewe + Ucho dolne lewe + Ucho górne prawe + Ucho dolne prawe + Nos lewy + Nos środkowy + Nos prawy + Policzek dolny lewy + Policzek górny lewy + Policzek dolny prawy + Policzek górny prawy + Szczęka + Zęby dolne + Warga dolna lewa + Warga dolna prawa + Warga dolna środkowa + Podstawa języka + Czubek języka + Kształt szczęki + Środek czoła + Podstawa nosa + Teeth Upper + Warga górna lewa + Warga górna prawa + Lewy kącik ust + Prawy kącik ust + Warga górna środkowa + Wewn. lewy kącik oka + Wewn. prawy kącik oka + Grzbiet nosa + Kołnierz + Całe ramię + Przedramię + Nadgarstek + Podstawa palca środkowego + Środek palca środkowego + Czubek palca środkowego + Podstawa palca wskazującego + Środek palca wskazującego + Czubek palca wskazującego + Podstawa palca serdecznego + Środek palca serdecznego + Czubek palca serdecznego + Podstawa palca małego + Środek palca małego + Czubek palca małego + Podstawa kciuka + Środek kciuka + Czubek kciuka + Kołnierz + Całe ramię + Przedramię + Nadgarstek + Podstawa palca środkowego + Środek palca środkowego + Czubek palca środkowego + Podstawa palca wskazującego + Środek palca wskazującego + Czubek palca wskazującego + Podstawa palca serdecznego + Środek palca serdecznego + Czubek palca serdecznego + Podstawa palca małego + Środek palca małego + Czubek palca małego + Podstawa kciuka + Środek kciuka + Czubek kciuka + Skrzydła + Lewo 1 + Lewo 2 + Lewo 3 + Lewo 4 + Lewy wachlarz + Prawo 1 + Prawo 2 + Prawo 3 + Prawo 4 + Prawy wachlarz + Prawe biodro + Prawe kolano + Prawa kostka + Prawa stopa + Prawy paluch + Lewe biodro + Lewe kolano + Lewa kostka + Lewa stopa + Lewy paluch + Podstawa ogona + Ogon 2 + Ogon 3 + Ogon 4 + Ogon 5 + Czubek ogona + Krocze + Kończyny tylne + Lewa podstawa + Lewo 2 + Lewo 3 + Lewo 4 + Prawa podstawa + Prawo 2 + Prawo 3 + Prawo 4 + Pośladki + Brzuch + Lewa pierś + Prawa pierś + + + + + + + + + + + + + Góra/Dół: + + + + Lewo/Prawo: + + + + Przód/Tył: + + + + + + + + + + + + + + + + + + + + + + +