From 7d1a2e1cce46481e14a43281bf622dc13936690a Mon Sep 17 00:00:00 2001 From: Angeldark Raymaker Date: Mon, 28 Oct 2024 21:49:09 +0000 Subject: [PATCH] FIRE-34771: Remove BVH save option from poser --- indra/newview/app_settings/settings.xml | 11 -- indra/newview/fsfloaterposer.cpp | 57 --------- indra/newview/fsfloaterposer.h | 1 - indra/newview/fsposeranimator.cpp | 110 ------------------ indra/newview/fsposeranimator.h | 43 ------- .../skins/default/xui/en/floater_fs_poser.xml | 9 -- 6 files changed, 231 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 28d24477fd..d489801f48 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8056,17 +8056,6 @@ Value 0 - FSPoserSaveBvhFileAlso - - Comment - Whether to save a BVH file as well when saving a pose. - Persist - 1 - Type - Boolean - Value - 0 - FSPoserTrackpadSensitivity Comment diff --git a/indra/newview/fsfloaterposer.cpp b/indra/newview/fsfloaterposer.cpp index 902a7ee7e3..7b315f733d 100644 --- a/indra/newview/fsfloaterposer.cpp +++ b/indra/newview/fsfloaterposer.cpp @@ -45,14 +45,12 @@ namespace { 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 @@ -160,12 +158,6 @@ bool FSFloaterPoser::postBuild() mToggleAdvancedPanelBtn->setValue(true); } - mAlsoSaveBvhCbx = getChild("also_save_bvh_checkbox"); - if (gSavedSettings.getBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY)) - { - mAlsoSaveBvhCbx->set(true); - } - mTrackpadSensitivitySlider = getChild("trackpad_sensitivity_slider"); mTrackpadSensitivitySlider->setValue(gSavedSettings.getF32(POSER_TRACKPAD_SENSITIVITY_SAVE_KEY)); @@ -232,7 +224,6 @@ void FSFloaterPoser::onOpen(const LLSD& key) void FSFloaterPoser::onClose(bool app_quitting) { gSavedSettings.setBOOL(POSER_ADVANCEDWINDOWSTATE_SAVE_KEY, mToggleAdvancedPanelBtn->getValue().asBoolean()); - gSavedSettings.setBOOL(POSER_ALSOSAVEBVHFILE_SAVE_KEY, mAlsoSaveBvhCbx->getValue()); LLFloater::onClose(app_quitting); } @@ -317,57 +308,9 @@ void FSFloaterPoser::onClickPoseSave() refreshPoseScroll(mPosesScrollList); setUiSelectedAvatarSaveFileName(filename); // TODO: provide feedback for save - - bool alsoSaveAsBvh = mAlsoSaveBvhCbx->getValue().asBoolean(); - if (alsoSaveAsBvh) - savePoseToBvh(avatar, filename); } } -bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, const std::string& poseFileName) -{ - if (poseFileName.empty()) - return false; - - if (!mPoserAnimator.isPosingAvatar(avatar)) - return false; - - bool writeSuccess = false; - - try - { - 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; - LLFile::mkdir(pathname); - } - - std::string fullSavePath = - gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, POSE_SAVE_SUBDIRECTORY, poseFileName + POSE_EXTERNAL_FORMAT_FILE_EXT); - - llofstream file; - file.open(fullSavePath.c_str()); - if (!file.is_open()) - { - LL_WARNS("Poser") << "Unable to save pose!" << LL_ENDL; - return false; - } - - writeSuccess = mPoserAnimator.writePoseAsBvh(&file, avatar); - - file.close(); - } - catch (const std::exception& e) - { - LL_WARNS("Posing") << "Exception caught in SaveToBVH: " << e.what() << LL_ENDL; - return false; - } - - - return true; -} - bool FSFloaterPoser::savePoseToXml(LLVOAvatar* avatar, const std::string& poseFileName) { if (poseFileName.empty()) diff --git a/indra/newview/fsfloaterposer.h b/indra/newview/fsfloaterposer.h index be3481e9e5..a2362ba6bc 100644 --- a/indra/newview/fsfloaterposer.h +++ b/indra/newview/fsfloaterposer.h @@ -192,7 +192,6 @@ class FSFloaterPoser : public LLFloater void onClickPoseSave(); void onPoseFileSelect(); 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, const std::string& poseFileName, E_LoadPoseMethods loadMethod); diff --git a/indra/newview/fsposeranimator.cpp b/indra/newview/fsposeranimator.cpp index 8bfb3a313a..c7b7da8d65 100644 --- a/indra/newview/fsposeranimator.cpp +++ b/indra/newview/fsposeranimator.cpp @@ -808,113 +808,3 @@ bool FSPoserAnimator::isAvatarSafeToUse(LLVOAvatar* avatar) const return true; } - -bool FSPoserAnimator::writePoseAsBvh(llofstream* fileStream, LLVOAvatar* avatar) -{ - if (!fileStream || !avatar) - return false; - - *fileStream << "HIERARCHY" << std::endl; - auto startingJoint = getPoserJointByName("mPelvis"); - writeBvhFragment(fileStream, avatar, startingJoint, 0); - *fileStream << "MOTION" << std::endl; - *fileStream << "Frames: 1" << std::endl; - *fileStream << "Frame Time: 1" << std::endl; - writeBvhMotion(fileStream, avatar, startingJoint); - *fileStream << std::endl; - - return true; -} - -bool FSPoserAnimator::writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint, S32 tabStops) -{ - if (!joint) - return false; - - auto position = getJointPosition(avatar, *joint); - - switch (joint->boneType()) - { - case WHOLEAVATAR: - *fileStream << "ROOT " + joint->jointName() << std::endl; - *fileStream << "{" << std::endl; - *fileStream << getTabs(tabStops + 1) + "OFFSET " + vec3ToXYZString(position) << std::endl; - *fileStream << getTabs(tabStops + 1) + "CHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation" << std::endl; - break; - - default: - *fileStream << getTabs(tabStops) + "JOINT " + joint->jointName() << std::endl; - *fileStream << getTabs(tabStops) + "{" << std::endl; - *fileStream << getTabs(tabStops + 1) + "OFFSET " + vec3ToXYZString(position) << std::endl; - *fileStream << getTabs(tabStops + 1) + "CHANNELS 3 Xrotation Yrotation Zrotation" << std::endl; - break; - } - - size_t numberOfBvhChildNodes = joint->bvhChildren().size(); - if (numberOfBvhChildNodes > 0) - { - for (size_t index = 0; index != numberOfBvhChildNodes; ++index) - { - auto nextJoint = getPoserJointByName(joint->bvhChildren()[index]); - writeBvhFragment(fileStream, avatar, nextJoint, tabStops + 1); - } - } - else - { - *fileStream << getTabs(tabStops + 1) + "End Site" << std::endl; - *fileStream << getTabs(tabStops + 1) + "{" << std::endl; - *fileStream << getTabs(tabStops + 2) + "OFFSET " + vec3ToXYZString(position) << std::endl; // I don't understand this node - *fileStream << getTabs(tabStops + 1) + "}" << std::endl; - } - - *fileStream << getTabs(tabStops) + "}" << std::endl; - return true; -} - -bool FSPoserAnimator::writeBvhMotion(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint) -{ - if (!joint) - return false; - - auto rotation = getJointRotation(avatar, *joint, SWAP_NOTHING, NEGATE_NOTHING, true); - auto position = getJointPosition(avatar, *joint, true); - - switch (joint->boneType()) - { - case WHOLEAVATAR: - *fileStream << vec3ToXYZString(position) + " " + rotationToYZXString(rotation); - break; - - default: - *fileStream << " " + rotationToYZXString(rotation); - break; - } - - size_t numberOfBvhChildNodes = joint->bvhChildren().size(); - for (size_t index = 0; index != numberOfBvhChildNodes; ++index) - { - auto nextJoint = getPoserJointByName(joint->bvhChildren()[index]); - writeBvhMotion(fileStream, avatar, nextJoint); - } - - return true; -} - -std::string FSPoserAnimator::vec3ToXYZString(const LLVector3& val) -{ - return std::to_string(val[VX]) + " " + std::to_string(val[VY]) + " " + std::to_string(val[VZ]); -} - -std::string FSPoserAnimator::rotationToYZXString(const LLVector3& val) -{ - 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(S32 numOfTabstops) -{ - std::string tabSpaces; - for (S32 i = 0; i < numOfTabstops; i++) - tabSpaces += "\t"; - - return tabSpaces; -} diff --git a/indra/newview/fsposeranimator.h b/indra/newview/fsposeranimator.h index 21296cfdfb..39e56eac7c 100644 --- a/indra/newview/fsposeranimator.h +++ b/indra/newview/fsposeranimator.h @@ -476,14 +476,6 @@ public: /// The avatar whose pose should flip left-right. void flipEntirePose(LLVOAvatar* avatar); - /// - /// Determines whether the supplied PoserJoint for the supplied avatar is being posed. - /// - /// 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); - private: /// /// Translates a rotation vector from the UI to a Quaternion for the bone. @@ -527,41 +519,6 @@ public: /// True if the avatar is safe to manipulate, otherwise false. 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). - /// - /// The stream to write the fragment to. - /// The avatar owning the supplied joint. - /// 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, S32 tabStops); - - /// - /// Writes a fragment of the 'single line' representing an animation frame within the BVH file respresenting the positions and/or rotations. - /// - /// The stream to write the position and/or rotation to. - /// The avatar owning the supplied joint. - /// The joint whose position and/or rotation should be written. - /// - bool writeBvhMotion(llofstream* fileStream, LLVOAvatar* avatar, const FSPoserJoint* joint); - - /// - /// Generates a string with the supplied number of tab-chars. - /// - 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(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(const LLVector3& val); - /// /// Maps the avatar's ID to the animation registered to them. /// Thus we start/stop the same animation, and get/set the same rotations etc. diff --git a/indra/newview/skins/default/xui/en/floater_fs_poser.xml b/indra/newview/skins/default/xui/en/floater_fs_poser.xml index f9e197a781..057fd20ff2 100644 --- a/indra/newview/skins/default/xui/en/floater_fs_poser.xml +++ b/indra/newview/skins/default/xui/en/floater_fs_poser.xml @@ -1463,15 +1463,6 @@ width="565"> name="save_file_options" left_pad="2" width="235"> -