From 35ad36ec8dda392b9b13c3cdc86f2c745d5a07bb Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 26 Nov 2025 00:42:33 +0100 Subject: [PATCH] Refactor a lot of stuff... --- indra/newview/fsfloatercontacts.cpp | 25 +++---- indra/newview/fsfloatercontacts.h | 6 +- indra/newview/fsfloaterposer.cpp | 108 +++++++++++++-------------- indra/newview/fsfloaterposer.h | 10 +-- indra/newview/fsjointpose.cpp | 42 +++++------ indra/newview/fsjointpose.h | 16 ++-- indra/newview/fsmaniprotatejoint.cpp | 8 +- indra/newview/fsposeranimator.cpp | 28 +++---- indra/newview/fsposeranimator.h | 12 +-- indra/newview/fsposestate.cpp | 20 ++--- indra/newview/fsposestate.h | 16 ++-- indra/newview/fsposingmotion.cpp | 24 +++--- indra/newview/fsposingmotion.h | 14 ++-- indra/newview/llavatarlist.cpp | 31 ++++---- 14 files changed, 175 insertions(+), 185 deletions(-) diff --git a/indra/newview/fsfloatercontacts.cpp b/indra/newview/fsfloatercontacts.cpp index 03c3cd8e95..f976f0218b 100644 --- a/indra/newview/fsfloatercontacts.cpp +++ b/indra/newview/fsfloatercontacts.cpp @@ -271,7 +271,7 @@ void FSFloaterContacts::onOpen(const LLSD& key) LLFloater::onOpen(key); } -void FSFloaterContacts::openTab(const std::string& name) +void FSFloaterContacts::openTab(std::string_view name) { if (name == "friends") { @@ -291,8 +291,7 @@ void FSFloaterContacts::openTab(const std::string& name) return; } - FSFloaterIMContainer* floater_container = dynamic_cast(getHost()); - if (floater_container) + if (auto floater_container = dynamic_cast(getHost())) { floater_container->setVisible(true); floater_container->showFloater(this); @@ -391,7 +390,7 @@ void FSFloaterContacts::onAvatarPicked(const uuid_vec_t& ids, const std::vector< { if (!names.empty() && !ids.empty()) { - LLAvatarActions::requestFriendshipDialog(ids[0], names[0].getCompleteName()); + LLAvatarActions::requestFriendshipDialog(ids.front(), names.front().getCompleteName()); } } @@ -405,8 +404,7 @@ void FSFloaterContacts::onAddFriendWizButtonClicked(LLUICtrl* ctrl) picker->setOkBtnEnableCb(boost::bind(&FSFloaterContacts::isItemsFreeOfFriends, this, _1)); } - LLFloater* root_floater = gFloaterView->getParentFloater(this); - if (root_floater) + if (auto root_floater = gFloaterView->getParentFloater(this)) { root_floater->addDependentFloater(picker); } @@ -474,7 +472,7 @@ std::string FSFloaterContacts::getActiveTabName() const return mTabContainer->getCurrentPanel()->getName(); } -LLPanel* FSFloaterContacts::getPanelByName(const std::string& panel_name) +LLPanel* FSFloaterContacts::getPanelByName(std::string_view panel_name) { return mTabContainer->getPanelByName(panel_name); } @@ -518,10 +516,9 @@ void FSFloaterContacts::getCurrentItemIDs(uuid_vec_t& selected_uuids) const void FSFloaterContacts::getCurrentFriendItemIDs(uuid_vec_t& selected_uuids) const { - listitem_vec_t selected = mFriendsList->getAllSelected(); - for (listitem_vec_t::iterator itr = selected.begin(); itr != selected.end(); ++itr) + for (auto list_item : mFriendsList->getAllSelected()) { - selected_uuids.push_back((*itr)->getUUID()); + selected_uuids.push_back(list_item->getUUID()); } } @@ -786,7 +783,7 @@ void FSFloaterContacts::refreshRightsChangeList() bool can_offer_teleport = num_selected >= 1; bool selected_friends_online = true; - const LLRelationship* friend_status = NULL; + const LLRelationship* friend_status = nullptr; for (const auto& id : friends) { friend_status = LLAvatarTracker::instance().getBuddyInfo(id); @@ -1064,8 +1061,8 @@ void FSFloaterContacts::sendRightsGrant(rights_map_t& ids) // setup message header msg->newMessageFast(_PREHASH_GrantUserRights); msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUID(_PREHASH_AgentID, gAgent.getID()); - msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID()); + msg->addUUID(_PREHASH_AgentID, gAgentID); + msg->addUUID(_PREHASH_SessionID, gAgentSessionID); for (const auto& [id, rights] : ids) { @@ -1078,7 +1075,7 @@ void FSFloaterContacts::sendRightsGrant(rights_map_t& ids) gAgent.sendReliableMessage(); } -void FSFloaterContacts::childShowTab(const std::string& id, const std::string& tabname) +void FSFloaterContacts::childShowTab(std::string_view id, std::string_view tabname) { if (LLTabContainer* child = findChild(id)) { diff --git a/indra/newview/fsfloatercontacts.h b/indra/newview/fsfloatercontacts.h index 5c3061eff3..949769d0e2 100644 --- a/indra/newview/fsfloatercontacts.h +++ b/indra/newview/fsfloatercontacts.h @@ -63,8 +63,8 @@ public: static FSFloaterContacts* getInstance(); static FSFloaterContacts* findInstance(); - void openTab(const std::string& name); - LLPanel* getPanelByName(const std::string& panel_name); + void openTab(std::string_view name); + LLPanel* getPanelByName(std::string_view panel_name); void sortFriendList(); void onDisplayNameChanged(); @@ -189,7 +189,7 @@ private: std::string mFriendFilterSubString{ LLStringUtil::null }; std::string mFriendFilterSubStringOrig{ LLStringUtil::null }; - void childShowTab(const std::string& id, const std::string& tabname); + void childShowTab(std::string_view id, std::string_view tabname); void updateRlvRestrictions(ERlvBehaviour behavior); boost::signals2::connection mRlvBehaviorCallbackConnection{}; diff --git a/indra/newview/fsfloaterposer.cpp b/indra/newview/fsfloaterposer.cpp index 23809f09e9..a09faa3ed6 100644 --- a/indra/newview/fsfloaterposer.cpp +++ b/indra/newview/fsfloaterposer.cpp @@ -300,7 +300,7 @@ void FSFloaterPoser::markSelectedJointsToHighlight() return; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; std::string jointName = selectedJoints[0]->jointName(); @@ -682,7 +682,7 @@ bool FSFloaterPoser::savePoseToXml(LLVOAvatar* avatar, const std::string& poseFi void FSFloaterPoser::onClickToggleSelectedBoneEnabled() { auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -706,7 +706,7 @@ void FSFloaterPoser::onClickToggleSelectedBoneEnabled() void FSFloaterPoser::onClickFlipSelectedJoints() { auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -765,7 +765,7 @@ void FSFloaterPoser::onClickFlipPose() void FSFloaterPoser::onClickRecaptureSelectedBones() { auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -795,9 +795,9 @@ void FSFloaterPoser::onClickRecaptureSelectedBones() enableOrDisableRedoAndUndoButton(); } -void FSFloaterPoser::updatePosedBones(const std::string& jointName, const LLQuaternion rotation, const LLVector3 position, const LLVector3 scale) +void FSFloaterPoser::updatePosedBones(const std::string& jointName, const LLQuaternion& rotation, const LLVector3& position, const LLVector3& scale) { - LLVOAvatar *avatar = getUiSelectedAvatar(); + LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return; @@ -828,7 +828,7 @@ void FSFloaterPoser::updatePosedBones(const std::string& jointName, const LLQuat LLQuaternion FSFloaterPoser::getManipGimbalRotation(const std::string& jointName) { - LLVOAvatar *avatar = getUiSelectedAvatar(); + LLVOAvatar* avatar = getUiSelectedAvatar(); if (!avatar) return LLQuaternion(); @@ -1431,7 +1431,7 @@ void FSFloaterPoser::onPoseStartStop() onAvatarSelect(); } -bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar *avatar) const +bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar* avatar) const { if (!avatar || avatar->isDead()) return false; @@ -1441,7 +1441,7 @@ bool FSFloaterPoser::couldAnimateAvatar(LLVOAvatar *avatar) const return true; } -bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar *avatar) const +bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar* avatar) const { if (!avatar || avatar->isDead()) return false; @@ -1462,7 +1462,7 @@ bool FSFloaterPoser::havePermissionToAnimateAvatar(LLVOAvatar *avatar) const return false; } -bool FSFloaterPoser::havePermissionToAnimateOtherAvatar(LLVOAvatar *avatar) const +bool FSFloaterPoser::havePermissionToAnimateOtherAvatar(LLVOAvatar* avatar) const { if (!avatar || avatar->isDead()) return false; @@ -1566,13 +1566,13 @@ void FSFloaterPoser::addHeaderRowToScrollList(const std::string& jointName, LLSc return; LLScrollListItem *hdrRow = bodyJointsScrollList->addElement(headerRow); - hdrRow->setEnabled(FALSE); + hdrRow->setEnabled(false); } LLSD FSFloaterPoser::createRowForJoint(const std::string& jointName, bool isHeaderRow) { if (jointName.empty()) - return NULL; + return {}; std::string headerValue = ""; if (isHeaderRow) @@ -1583,7 +1583,7 @@ LLSD FSFloaterPoser::createRowForJoint(const std::string& jointName, bool isHead if (hasString(parameterName)) jointValue = getString(parameterName); else - return NULL; + return {}; LLSD row; row["columns"][COL_ICON]["column"] = "icon"; @@ -1649,8 +1649,7 @@ void FSFloaterPoser::onToggleRotationFrameButton(const LLUICtrl* toggleButton) if (!toggleButton) return; - bool buttonDown = toggleButton->getValue().asBoolean(); - if (buttonDown) + if (bool buttonDown = toggleButton->getValue().asBoolean()) { mBtnAvatarFrame->setValue(toggleButton == mBtnAvatarFrame); mBtnScreenFrame->setValue(toggleButton == mBtnScreenFrame); @@ -1671,7 +1670,7 @@ void FSFloaterPoser::onUndoLastChange() return; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; for (auto item : selectedJoints) @@ -1702,7 +1701,7 @@ void FSFloaterPoser::onSetAvatarToTpose() enableOrDisableRedoAndUndoButton(); } -void FSFloaterPoser::onResetJoint(const LLSD data) +void FSFloaterPoser::onResetJoint(const LLSD& data) { int resetType = data.asInteger(); @@ -1714,7 +1713,7 @@ void FSFloaterPoser::onResetJoint(const LLSD data) return; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; for (auto item : selectedJoints) @@ -1744,7 +1743,7 @@ void FSFloaterPoser::onRedoLastChange() return; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; for (auto item : selectedJoints) @@ -1776,7 +1775,7 @@ void FSFloaterPoser::enableOrDisableRedoAndUndoButton() return; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; bool shouldEnableRedoButton = false; @@ -1867,7 +1866,7 @@ void FSFloaterPoser::selectJointByName(const std::string& jointName) LL_WARNS() << "Joint not found: " << jointName << LL_ENDL; } -LLScrollListCtrl* FSFloaterPoser::getScrollListForTab(LLPanel * tabPanel) const +LLScrollListCtrl* FSFloaterPoser::getScrollListForTab(LLPanel* tabPanel) const { if (tabPanel == mPositionRotationPnl) { @@ -1929,8 +1928,7 @@ std::vector FSFloaterPoser::getUiSelectedPoserJo for (auto item : scrollList->getAllSelected()) { - auto* userData = static_cast(item->getUserdata()); - if (userData) + if (auto* userData = static_cast(item->getUserdata())) { joints.push_back(userData); } @@ -1941,7 +1939,7 @@ std::vector FSFloaterPoser::getUiSelectedPoserJo return joints; } -void FSFloaterPoser::updateManipWithFirstSelectedJoint(std::vector joints) const +void FSFloaterPoser::updateManipWithFirstSelectedJoint(const std::vector& joints) const { auto avatarp = getUiSelectedAvatar(); if (!avatarp) @@ -2320,7 +2318,7 @@ LLVector3 FSFloaterPoser::getRotationOfFirstSelectedJoint() const { LLVector3 rotation; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return rotation; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -2342,7 +2340,7 @@ LLVector3 FSFloaterPoser::getPositionOfFirstSelectedJoint() const { LLVector3 position; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return position; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -2360,7 +2358,7 @@ LLVector3 FSFloaterPoser::getScaleOfFirstSelectedJoint() const { LLVector3 scale; auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return scale; LLVOAvatar *avatar = getUiSelectedAvatar(); @@ -2586,13 +2584,13 @@ void FSFloaterPoser::onAvatarsRefresh() iconObjectName = getString("icon_object"); // Add non-Animesh avatars - for (LLCharacter *character : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { LLUUID uuid = character->getID(); if (std::find(avatarsToAddToList.begin(), avatarsToAddToList.end(), uuid) == avatarsToAddToList.end()) continue; - LLVOAvatar *avatar = dynamic_cast(character); + LLVOAvatar* avatar = dynamic_cast(character); if (!couldAnimateAvatar(avatar)) continue; @@ -2603,8 +2601,7 @@ void FSFloaterPoser::onAvatarsRefresh() if (!LLAvatarNameCache::get(uuid, &av_name)) continue; - bool isMuted = LLMuteList::getInstance()->isMuted(uuid); - if (isMuted) + if (LLMuteList::getInstance()->isMuted(uuid)) continue; if (!avatar->isSelf()) @@ -2630,7 +2627,7 @@ void FSFloaterPoser::onAvatarsRefresh() if (std::find(avatarsToAddToList.begin(), avatarsToAddToList.end(), uuid) == avatarsToAddToList.end()) continue; - LLControlAvatar *avatar = dynamic_cast(character); + LLControlAvatar* avatar = dynamic_cast(character); if (!couldAnimateAvatar(avatar)) continue; @@ -2674,15 +2671,15 @@ std::string FSFloaterPoser::getIconNameForAvatar(LLVOAvatar* avatar) std::string FSFloaterPoser::getControlAvatarName(const LLControlAvatar* avatar) { if (!avatar) - return ""; + return {}; - const LLVOVolume* rootVolume = avatar->mRootVolp; - const LLViewerObject* rootEditObject = (rootVolume) ? rootVolume->getRootEdit() : NULL; + const LLVOVolume* rootVolume = avatar->mRootVolp; + const LLViewerObject* rootEditObject = rootVolume ? rootVolume->getRootEdit() : nullptr; if (!rootEditObject) - return ""; + return {}; const LLViewerInventoryItem* attachedItem = - (rootEditObject->isAttachment()) ? gInventory.getItem(rootEditObject->getAttachmentItemID()) : NULL; + (rootEditObject->isAttachment()) ? gInventory.getItem(rootEditObject->getAttachmentItemID()) : nullptr; if (attachedItem) return attachedItem->getName(); @@ -2690,7 +2687,7 @@ std::string FSFloaterPoser::getControlAvatarName(const LLControlAvatar* avatar) if (rootEditObject->permYouOwner()) return avatar->getFullname(); - return ""; + return {}; } void FSFloaterPoser::refreshTextHighlightingOnAvatarScrollList() @@ -2707,9 +2704,9 @@ void FSFloaterPoser::refreshTextHighlightingOnAvatarScrollList() ((LLScrollListText*)listItem->getColumn(COL_ICON))->setValue(getIconNameForAvatar(listAvatar)); if (mPoserAnimator.isPosingAvatar(listAvatar)) - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); + ((LLScrollListText*)listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); else - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); + ((LLScrollListText*)listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); } } @@ -2737,34 +2734,34 @@ void FSFloaterPoser::addBoldToScrollList(LLScrollListCtrl* list, LLVOAvatar* ava if (!list) return; - std::string iconValue = ""; + std::string iconValue = ""; bool considerExternalFormatSaving = getSavingToBvh(); for (auto listItem : list->getAllData()) { - FSPoserAnimator::FSPoserJoint *poserJoint = static_cast(listItem->getUserdata()); + FSPoserAnimator::FSPoserJoint* poserJoint = static_cast(listItem->getUserdata()); if (!poserJoint) continue; ((LLScrollListText*)listItem->getColumn(COL_ICON))->setValue(getScrollListIconForJoint(avatar, *poserJoint)); if (mPoserAnimator.isPosingAvatarJoint(avatar, *poserJoint)) - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); + ((LLScrollListText*)listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::BOLD); else - ((LLScrollListText *) listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); + ((LLScrollListText*)listItem->getColumn(COL_NAME))->setFontStyle(LLFontGL::NORMAL); } } std::string FSFloaterPoser::getScrollListIconForJoint(LLVOAvatar* avatar, FSPoserAnimator::FSPoserJoint joint) { if (!avatar) - return ""; + return {}; if (mPoserAnimator.getRotationIsWorldLocked(avatar, joint)) return tryGetString("icon_rotation_is_world_locked"); if (!getSavingToBvh()) - return ""; + return {}; if (joint.boneType() == COL_VOLUMES) return tryGetString("icon_rotation_does_not_export"); @@ -2783,7 +2780,7 @@ std::string FSFloaterPoser::getScrollListIconForJoint(LLVOAvatar* avatar, FSPose std::string FSFloaterPoser::tryGetString(std::string_view name) { if (name.empty()) - return ""; + return {}; return hasString(name) ? getString(name) : ""; } @@ -2810,8 +2807,7 @@ bool FSFloaterPoser::savePoseToBvh(LLVOAvatar* avatar, const std::string& poseFi 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()); + llofstream file(fullSavePath.c_str()); if (!file.is_open()) { LL_WARNS("Poser") << "Unable to save pose!" << LL_ENDL; @@ -2908,7 +2904,7 @@ void FSFloaterPoser::writeBvhFragment(llofstream* fileStream, LLVOAvatar* avatar { for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren().at(index)); writeBvhFragment(fileStream, avatar, nextJoint, tabStops + 1); } } @@ -2943,7 +2939,7 @@ void FSFloaterPoser::writeFirstFrameOfBvhMotion(llofstream* fileStream, const FS size_t numberOfBvhChildNodes = joint->bvhChildren().size(); for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren().at(index)); writeFirstFrameOfBvhMotion(fileStream, nextJoint); } } @@ -2972,15 +2968,15 @@ void FSFloaterPoser::writeBvhMotion(llofstream* fileStream, LLVOAvatar* avatar, size_t numberOfBvhChildNodes = joint->bvhChildren().size(); for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = mPoserAnimator.getPoserJointByName(joint->bvhChildren().at(index)); writeBvhMotion(fileStream, avatar, nextJoint); } } std::string FSFloaterPoser::positionToString(const LLVector3& val) { - const float metresToInches = 39.37008f; - return std::to_string(metresToInches * val[VY]) + " " + std::to_string(metresToInches * val[VZ]) + " " + std::to_string(metresToInches * val[VX]); + constexpr F32 metersToInches = 39.37008f; + return std::to_string(metersToInches * val[VY]) + " " + std::to_string(metersToInches * val[VZ]) + " " + std::to_string(metersToInches * val[VX]); } std::string FSFloaterPoser::rotationToString(const LLVector3& val) @@ -3047,7 +3043,7 @@ S32 FSFloaterPoser::getBvhJointNegation(const std::string& jointName) const return result; } -bool FSFloaterPoser::getSavingToBvh() +bool FSFloaterPoser::getSavingToBvh() const { return gSavedSettings.getBOOL(POSER_SAVEEXTERNALFORMAT_SAVE_KEY); } @@ -3061,7 +3057,7 @@ void FSFloaterPoser::onClickSavingToBvh() void FSFloaterPoser::onClickLockWorldRotBtn() { auto selectedJoints = getUiSelectedPoserJoints(); - if (selectedJoints.size() < 1) + if (selectedJoints.empty()) return; LLVOAvatar* avatar = getUiSelectedAvatar(); diff --git a/indra/newview/fsfloaterposer.h b/indra/newview/fsfloaterposer.h index 645bc9de3f..d6af0c882e 100644 --- a/indra/newview/fsfloaterposer.h +++ b/indra/newview/fsfloaterposer.h @@ -81,7 +81,7 @@ class FSFloaterPoser : public LLFloater, public LLEditMenuHandler friend class LLFloaterReg; FSFloaterPoser(const LLSD &key); public: - void updatePosedBones(const std::string& jointName, const LLQuaternion rotation, const LLVector3 position, const LLVector3 scale); + void updatePosedBones(const std::string& jointName, const LLQuaternion& rotation, const LLVector3& position, const LLVector3& scale); LLQuaternion getManipGimbalRotation(const std::string& jointName); void selectJointByName(const std::string& jointName); void undo() override { onUndoLastChange(); }; @@ -143,7 +143,7 @@ public: /// Updates the visual with the first selected joint from the supplied collection, if any. /// /// The collection of selected joints. - void updateManipWithFirstSelectedJoint(std::vector joints) const; + void updateManipWithFirstSelectedJoint(const std::vector& joints) const; /// /// Gets a detectable avatar by its UUID. @@ -229,7 +229,7 @@ public: LLVector3 getPositionOfFirstSelectedJoint() const; LLVector3 getScaleOfFirstSelectedJoint() const; - LLScrollListCtrl* getScrollListForTab(LLPanel * tabPanel) const; + LLScrollListCtrl* getScrollListForTab(LLPanel* tabPanel) const; // Pose load/save void createUserPoseDirectoryIfNeeded(); void onToggleLoadSavePanel(); @@ -268,7 +268,7 @@ public: void setRotationChangeButtons(bool mirror, bool sympathetic); void onUndoLastChange(); void onRedoLastChange(); - void onResetJoint(const LLSD data); + void onResetJoint(const LLSD& data); void onSetAvatarToTpose(); void onPoseStartStop(); void onTrackballChanged(); @@ -422,7 +422,7 @@ public: /// Gets whether the pose should also write a BVH file when saved. /// /// True if the user wants to additionally save a BVH file, otherwise false. - bool getSavingToBvh(); + bool getSavingToBvh() const; /// /// Writes the current pose in BVH-format to the supplied stream. diff --git a/indra/newview/fsjointpose.cpp b/indra/newview/fsjointpose.cpp index e48500eef0..2d8f634c45 100644 --- a/indra/newview/fsjointpose.cpp +++ b/indra/newview/fsjointpose.cpp @@ -25,7 +25,6 @@ */ #include -#include #include "fsposingmotion.h" #include "llcharacter.h" @@ -49,19 +48,19 @@ FSJointPose::FSJointPose(LLJoint* joint, U32 usage, bool isCollisionVolume) mIsCollisionVolume = isCollisionVolume; mJointNumber = joint->getJointNum(); - mCurrentState = FSJointState(joint); + mCurrentState = FSJointState(joint); } void FSJointPose::setPublicPosition(const LLVector3& pos) { - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); mCurrentState.mPosition.set(pos); mCurrentState.mLastChangeWasRotational = false; } void FSJointPose::setPublicRotation(bool zeroBase, const LLQuaternion& rot) { - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); if (zeroBase) zeroBaseRotation(true); @@ -74,7 +73,7 @@ void FSJointPose::setPublicRotation(bool zeroBase, const LLQuaternion& rot) void FSJointPose::setPublicScale(const LLVector3& scale) { - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); mCurrentState.mScale.set(scale); mCurrentState.mLastChangeWasRotational = false; } @@ -82,29 +81,30 @@ void FSJointPose::setPublicScale(const LLVector3& scale) bool FSJointPose::undoLastChange() { bool changeType = mCurrentState.mLastChangeWasRotational; - mCurrentState = undoLastStateChange(FSJointState(mCurrentState)); + mCurrentState = undoLastStateChange(mCurrentState); return changeType; } void FSJointPose::redoLastChange() { - mCurrentState = redoLastStateChange(FSJointState(mCurrentState)); + mCurrentState = redoLastStateChange(mCurrentState); } void FSJointPose::resetJoint() { - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); mCurrentState.resetJoint(); mCurrentState.mLastChangeWasRotational = true; } -void FSJointPose::addStateToUndo(FSJointState stateToAddToUndo) +void FSJointPose::addStateToUndo(const FSJointState& stateToAddToUndo) { mModifiedThisSession = true; - auto timeIntervalSinceLastChange = std::chrono::system_clock::now() - mTimeLastUpdatedCurrentState; - mTimeLastUpdatedCurrentState = std::chrono::system_clock::now(); + auto now = std::chrono::system_clock::now(); + auto timeIntervalSinceLastChange = now - mTimeLastUpdatedCurrentState; + mTimeLastUpdatedCurrentState = now; if (timeIntervalSinceLastChange < UndoUpdateInterval) return; @@ -124,7 +124,7 @@ void FSJointPose::addStateToUndo(FSJointState stateToAddToUndo) mLastSetJointStates.pop_back(); } -FSJointPose::FSJointState FSJointPose::undoLastStateChange(FSJointState thingToSet) +FSJointPose::FSJointState FSJointPose::undoLastStateChange(const FSJointState& thingToSet) { if (mLastSetJointStates.empty()) return thingToSet; @@ -138,7 +138,7 @@ FSJointPose::FSJointState FSJointPose::undoLastStateChange(FSJointState thingToS return mLastSetJointStates.at(mUndoneJointStatesIndex); } -FSJointPose::FSJointState FSJointPose::redoLastStateChange(FSJointState thingToSet) +FSJointPose::FSJointState FSJointPose::redoLastStateChange(const FSJointState& thingToSet) { if (mLastSetJointStates.empty()) return thingToSet; @@ -160,37 +160,37 @@ void FSJointPose::recaptureJoint() if (!joint) return; - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); if (mIsCollisionVolume) { - mCurrentState.mPosition.set(LLVector3::zero); - mCurrentState.mScale.set(LLVector3::zero); + mCurrentState.mPosition.clear(); + mCurrentState.mScale.clear(); } mCurrentState = FSJointState(joint); mCurrentState.mLastChangeWasRotational = true; } -LLQuaternion FSJointPose::updateJointAsDelta(bool zeroBase, const LLQuaternion rotation, const LLVector3 position, const LLVector3 scale) +LLQuaternion FSJointPose::updateJointAsDelta(bool zeroBase, const LLQuaternion& rotation, const LLVector3& position, const LLVector3& scale) { - addStateToUndo(FSJointState(mCurrentState)); + addStateToUndo(mCurrentState); mCurrentState.mLastChangeWasRotational = true; return mCurrentState.updateFromJointProperties(zeroBase, rotation, position, scale); } -void FSJointPose::setBaseRotation(LLQuaternion rotation, LLJoint::JointPriority priority) +void FSJointPose::setBaseRotation(const LLQuaternion& rotation, LLJoint::JointPriority priority) { mCurrentState.resetBaseRotation(rotation, priority); } -void FSJointPose::setBasePosition(LLVector3 position, LLJoint::JointPriority priority) +void FSJointPose::setBasePosition(const LLVector3& position, LLJoint::JointPriority priority) { mCurrentState.resetBasePosition(position, priority); } -void FSJointPose::setBaseScale(LLVector3 scale, LLJoint::JointPriority priority) +void FSJointPose::setBaseScale(const LLVector3& scale, LLJoint::JointPriority priority) { mCurrentState.resetBaseScale(scale, priority); } diff --git a/indra/newview/fsjointpose.h b/indra/newview/fsjointpose.h index 003aa28d36..bc551afbdf 100644 --- a/indra/newview/fsjointpose.h +++ b/indra/newview/fsjointpose.h @@ -179,28 +179,28 @@ class FSJointPose /// The position of the supplied joint. /// The scale of the supplied joint. /// The rotation of the public difference between before and after recapture. - LLQuaternion updateJointAsDelta(bool zeroBase, const LLQuaternion rotation, const LLVector3 position, const LLVector3 scale); + LLQuaternion updateJointAsDelta(bool zeroBase, const LLQuaternion& rotation, const LLVector3& position, const LLVector3& scale); /// /// Sets the base rotation to the supplied rotation if the supplied priority is appropriate. /// /// The base rotation to set; zero is ignored. /// The priority of the base rotation; only priority equal or higher than any prior sets have any effect. - void setBaseRotation(LLQuaternion rotation, LLJoint::JointPriority priority); + void setBaseRotation(const LLQuaternion& rotation, LLJoint::JointPriority priority); /// /// Sets the base position to the supplied position if the supplied priority is appropriate. /// /// The base position to set; zero is ignored. /// The priority of the base rotation; only priority equal or higher than any prior sets have any effect. - void setBasePosition(LLVector3 position, LLJoint::JointPriority priority); + void setBasePosition(const LLVector3& position, LLJoint::JointPriority priority); /// /// Sets the base scale to the supplied scale if the supplied priority is appropriate. /// /// The base scale to set; zero is ignored. /// The priority of the base rotation; only priority equal or higher than any prior sets have any effect. - void setBaseScale(LLVector3 scale, LLJoint::JointPriority priority); + void setBaseScale(const LLVector3& scale, LLJoint::JointPriority priority); /// /// Sets the priority of the bone to the supplied value. @@ -455,7 +455,7 @@ class FSJointPose }; private: - std::string mJointName = ""; // expected to be a match to LLJoint.getName() for a joint implementation. + std::string mJointName = ""; // expected to be a match to LLJoint.getName() for a joint implementation. LLPointer mJointState{ nullptr }; /// @@ -477,9 +477,9 @@ class FSJointPose FSJointState mCurrentState; - void addStateToUndo(FSJointState stateToAddToUndo); - FSJointState undoLastStateChange(FSJointState currentState); - FSJointState redoLastStateChange(FSJointState currentState); + void addStateToUndo(const FSJointState& stateToAddToUndo); + FSJointState undoLastStateChange(const FSJointState& currentState); + FSJointState redoLastStateChange(const FSJointState& currentState); }; #endif // FS_JOINTPPOSE_H diff --git a/indra/newview/fsmaniprotatejoint.cpp b/indra/newview/fsmaniprotatejoint.cpp index 41ca92a1ca..da01a29f0a 100644 --- a/indra/newview/fsmaniprotatejoint.cpp +++ b/indra/newview/fsmaniprotatejoint.cpp @@ -505,7 +505,7 @@ void FSManipRotateJoint::renderRingPass(const RingRenderParams& params, float ra // If an extra rotation is specified, apply it. if (params.extraRotateAngle != 0.f) { - gGL.rotatef(params.extraRotateAngle, params.extraRotateAxis.mV[0], params.extraRotateAxis.mV[1], params.extraRotateAxis.mV[2]); + gGL.rotatef(params.extraRotateAngle, params.extraRotateAxis.mV[VX], params.extraRotateAxis.mV[VY], params.extraRotateAxis.mV[VZ]); } // Get the appropriate scale value from mManipulatorScales. float scaleVal = 1.f; @@ -878,7 +878,7 @@ void FSManipRotateJoint::renderNameXYZ(const LLQuaternion& rot) S32 vertical_offset = window_center_y - VERTICAL_OFFSET; LLVector3 euler_angles; - rot.getEulerAngles(&euler_angles.mV[0], &euler_angles.mV[1], &euler_angles.mV[2]); + rot.getEulerAngles(&euler_angles.mV[VX], &euler_angles.mV[VY], &euler_angles.mV[VZ]); euler_angles *= RAD_TO_DEG; for (S32 i = 0; i < 3; ++i) { @@ -1011,7 +1011,7 @@ bool FSManipRotateJoint::handleMouseDownOnPart(S32 x, S32 y, MASK mask) if (!isAvatarJointSafeToUse()) return false; - auto* poser = dynamic_cast(LLFloaterReg::findInstance("fs_poser")); + auto* poser = LLFloaterReg::findTypedInstance("fs_poser"); if (!poser) return false; @@ -1463,7 +1463,7 @@ void FSManipRotateJoint::drag(S32 x, S32 y) break; } - auto* poser = dynamic_cast(LLFloaterReg::findInstance("fs_poser")); + auto* poser = LLFloaterReg::findTypedInstance("fs_poser"); if (poser && mJoint) poser->updatePosedBones(mJoint->getName(), delta_send, LLVector3::zero, LLVector3::zero); } diff --git a/indra/newview/fsposeranimator.cpp b/indra/newview/fsposeranimator.cpp index fe7a1b67dc..31b35fa8f1 100644 --- a/indra/newview/fsposeranimator.cpp +++ b/indra/newview/fsposeranimator.cpp @@ -463,8 +463,8 @@ void FSPoserAnimator::recaptureJoint(LLVOAvatar* avatar, const FSPoserJoint& joi } void FSPoserAnimator::updateJointFromManip(LLVOAvatar* avatar, const FSPoserJoint* joint, bool resetBaseRotationToZero, - E_BoneDeflectionStyles style, E_PoserReferenceFrame frame, const LLQuaternion rotation, - const LLVector3 position, const LLVector3 scale) + E_BoneDeflectionStyles style, E_PoserReferenceFrame frame, const LLQuaternion& rotation, + const LLVector3& position, const LLVector3& scale) { if (!isAvatarSafeToUse(avatar)) return; @@ -848,7 +848,7 @@ LLQuaternion FSPoserAnimator::translateRotationToQuaternion(LLVOAvatar* avatar, return rot_quat; } -LLQuaternion FSPoserAnimator::changeToRotationFrame(LLVOAvatar* avatar, LLQuaternion rotation, E_PoserReferenceFrame frame, FSJointPose* joint) +LLQuaternion FSPoserAnimator::changeToRotationFrame(LLVOAvatar* avatar, const LLQuaternion& rotation, E_PoserReferenceFrame frame, FSJointPose* joint) { if (!joint || !avatar) return rotation; @@ -1187,7 +1187,7 @@ const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByName(const return nullptr; } -const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByNumber(LLVOAvatar* avatar, const int jointNumber) const +const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByNumber(LLVOAvatar* avatar, const S32 jointNumber) const { if (!avatar) return nullptr; @@ -1203,7 +1203,7 @@ const FSPoserAnimator::FSPoserJoint* FSPoserAnimator::getPoserJointByNumber(LLVO return getPoserJointByName(parentJoint->jointName()); } -bool FSPoserAnimator::tryGetJointNumber(LLVOAvatar* avatar, const FSPoserJoint &poserJoint, int &jointNumber) +bool FSPoserAnimator::tryGetJointNumber(LLVOAvatar* avatar, const FSPoserJoint &poserJoint, S32& jointNumber) { if (!avatar) return false; @@ -1244,7 +1244,7 @@ bool FSPoserAnimator::tryPosingAvatar(LLVOAvatar* avatar) return false; } -void FSPoserAnimator::updatePosingState(LLVOAvatar* avatar, std::vector jointsRecaptured) +void FSPoserAnimator::updatePosingState(LLVOAvatar* avatar, const std::vector& jointsRecaptured) { if (!avatar) return; @@ -1253,7 +1253,7 @@ void FSPoserAnimator::updatePosingState(LLVOAvatar* avatar, std::vector jointNumbersRecaptured; + std::vector jointNumbersRecaptured; for (auto item : jointsRecaptured) { auto poserJoint = posingMotion->getJointPoseByJointName(item->jointName()); @@ -1266,7 +1266,7 @@ void FSPoserAnimator::updatePosingState(LLVOAvatar* avatar, std::vectorisDead()) return; @@ -1330,7 +1330,7 @@ bool FSPoserAnimator::isAvatarSafeToUse(LLVOAvatar* avatar) const return true; } -int FSPoserAnimator::getChildJointDepth(const FSPoserJoint* joint, int depth) const +int FSPoserAnimator::getChildJointDepth(const FSPoserJoint* joint, S32 depth) const { size_t numberOfBvhChildNodes = joint->bvhChildren().size(); if (numberOfBvhChildNodes < 1) @@ -1340,7 +1340,7 @@ int FSPoserAnimator::getChildJointDepth(const FSPoserJoint* joint, int depth) co for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = getPoserJointByName(joint->bvhChildren().at(index)); if (!nextJoint) continue; @@ -1364,7 +1364,7 @@ void FSPoserAnimator::deRotateWorldLockedDescendants(const FSPoserJoint* joint, for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = getPoserJointByName(joint->bvhChildren().at(index)); if (!nextJoint) continue; @@ -1395,7 +1395,7 @@ void FSPoserAnimator::deRotateJointOrFirstLockedChild(const FSPoserJoint* joint, for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = getPoserJointByName(joint->bvhChildren()[index]); + auto nextJoint = getPoserJointByName(joint->bvhChildren().at(index)); if (!nextJoint) continue; @@ -1411,7 +1411,7 @@ void FSPoserAnimator::undoOrRedoWorldLockedDescendants(const FSPoserJoint& joint for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = getPoserJointByName(joint.bvhChildren()[index]); + auto nextJoint = getPoserJointByName(joint.bvhChildren().at(index)); if (!nextJoint) continue; @@ -1444,7 +1444,7 @@ void FSPoserAnimator::undoOrRedoJointOrFirstLockedChild(const FSPoserJoint& join for (size_t index = 0; index != numberOfBvhChildNodes; ++index) { - auto nextJoint = getPoserJointByName(joint.bvhChildren()[index]); + auto nextJoint = getPoserJointByName(joint.bvhChildren().at(index)); if (!nextJoint) continue; diff --git a/indra/newview/fsposeranimator.h b/indra/newview/fsposeranimator.h index 8852edacfd..2f7cb32948 100644 --- a/indra/newview/fsposeranimator.h +++ b/indra/newview/fsposeranimator.h @@ -401,14 +401,14 @@ public: /// /// The name of the joint to match. /// The matching joint if found, otherwise nullptr - const FSPoserJoint* getPoserJointByNumber(LLVOAvatar* avatar, const int jointNumber) const; + const FSPoserJoint* getPoserJointByNumber(LLVOAvatar* avatar, const S32 jointNumber) const; /// /// Get a PoserJoint by its LLJoint number. /// /// The name of the joint to match. /// The matching joint if found, otherwise nullptr - bool tryGetJointNumber(LLVOAvatar* avatar, const FSPoserJoint &poserJoint, int &jointNumber); + bool tryGetJointNumber(LLVOAvatar* avatar, const FSPoserJoint &poserJoint, S32& jointNumber); /// /// Tries to start posing the supplied avatar. @@ -614,7 +614,7 @@ public: /// The position of the supplied joint. /// The scale of the supplied joint. void updateJointFromManip(LLVOAvatar* avatar, const FSPoserJoint* joint, bool resetBaseRotationToZero, E_BoneDeflectionStyles style, - E_PoserReferenceFrame frame, const LLQuaternion rotation, const LLVector3 position, const LLVector3 scale); + E_PoserReferenceFrame frame, const LLQuaternion& rotation, const LLVector3& position, const LLVector3& scale); /// /// Sets all of the joint rotations of the supplied avatar to zero. @@ -780,7 +780,7 @@ public: /// /// The avatar whose pose state is to be recapture. /// The joints which were recaptured. - void updatePosingState(LLVOAvatar* avatar, std::vector jointsRecaptured); + void updatePosingState(LLVOAvatar* avatar, const std::vector& jointsRecaptured); /// /// Traverses the joints and applies reversals to the base rotations if needed. @@ -845,7 +845,7 @@ public: /// The joint to determine the depth for. /// The depth of the supplied joint. /// The number of generations of descendents the joint has, if none, then zero. - int getChildJointDepth(const FSPoserJoint* joint, int depth) const; + int getChildJointDepth(const FSPoserJoint* joint, S32 depth) const; /// /// Derotates the first world-locked child joint to the supplied joint. @@ -898,7 +898,7 @@ public: /// This method imposes a framing upon the supplied rotation, meaning user input is considered as relative to something like /// 'the world', 'avatar pelvis' or the position of the camera relative to the joint. /// - LLQuaternion changeToRotationFrame(LLVOAvatar* avatar, LLQuaternion rotation, E_PoserReferenceFrame frame, FSJointPose* joint); + LLQuaternion changeToRotationFrame(LLVOAvatar* avatar, const LLQuaternion& rotation, E_PoserReferenceFrame frame, FSJointPose* joint); /// /// Maps the avatar's ID to the animation registered to them. diff --git a/indra/newview/fsposestate.cpp b/indra/newview/fsposestate.cpp index 804a327220..416f60b811 100644 --- a/indra/newview/fsposestate.cpp +++ b/indra/newview/fsposestate.cpp @@ -30,13 +30,13 @@ void FSPoseState::captureMotionStates(LLVOAvatar* avatar) } } -void FSPoseState::updateMotionStates(LLVOAvatar* avatar, FSPosingMotion* posingMotion, std::vector jointNumbersRecaptured) +void FSPoseState::updateMotionStates(LLVOAvatar* avatar, FSPosingMotion* posingMotion, const std::vector& jointNumbersRecaptured) { if (!avatar || !posingMotion) return; sCaptureOrder[avatar->getID()]++; - int animNumber = 0; + S32 animNumber = 0; // if an animation for avatar is a subset of jointNumbersRecaptured, delete it // this happens on second/subsequent recaptures; the first recapture is no longer needed @@ -96,7 +96,7 @@ void FSPoseState::writeMotionStates(LLVOAvatar* avatar, bool ignoreOwnership, LL if (!avatar) return; - int animNumber = 0; + S32 animNumber = 0; for (auto it = sMotionStates[avatar->getID()].begin(); it != sMotionStates[avatar->getID()].end(); ++it) { if (!ignoreOwnership && !it->gAgentOwnsPose) @@ -178,7 +178,7 @@ bool FSPoseState::applyMotionStatesToPosingMotion(LLVOAvatar* avatar, FSPosingMo std::sort(sMotionStates[avatar->getID()].begin(), sMotionStates[avatar->getID()].end(), compareByCaptureOrder()); - int lastCaptureOrder = 0; + S32 lastCaptureOrder = 0; bool needPriorityReset = false; for (auto it = sMotionStates[avatar->getID()].begin(); it != sMotionStates[avatar->getID()].end(); it++) { @@ -211,7 +211,7 @@ bool FSPoseState::applyMotionStatesToPosingMotion(LLVOAvatar* avatar, FSPosingMo return allMotionsApplied; } -void FSPoseState::resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, int captureOrder) +void FSPoseState::resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, S32 captureOrder) { for (auto it = sMotionStates[avatar->getID()].begin(); it != sMotionStates[avatar->getID()].end(); it++) { @@ -319,9 +319,9 @@ bool FSPoseState::motionIdIsFromPrimAgentOwnsAgentIsSittingOn(LLVOAvatar* avatar bool FSPoseState::vector2IsSubsetOfVector1(std::vector newRecapture, std::vector oldRecapture) { - if (newRecapture.size() < 1) + if (newRecapture.empty()) return false; - if (oldRecapture.size() < 1) + if (oldRecapture.empty()) return false; if (newRecapture.size() < oldRecapture.size()) @@ -334,10 +334,10 @@ bool FSPoseState::vector2IsSubsetOfVector1(std::vector newRecapture, std::v return true; } -std::string FSPoseState::encodeVectorToString(std::vector vector) +std::string FSPoseState::encodeVectorToString(const std::vector& vector) { std::string encoded = ""; - if (vector.size() < 1) + if (vector.empty()) return encoded; for (S32 numberToEncode : vector) @@ -371,7 +371,7 @@ std::string FSPoseState::encodeVectorToString(std::vector vector) return encoded; } -std::vector FSPoseState::decodeStringToVector(std::string vector) +std::vector FSPoseState::decodeStringToVector(std::string_view vector) { std::vector decoded; if (vector.empty()) diff --git a/indra/newview/fsposestate.h b/indra/newview/fsposestate.h index 0f68459aee..df53bd396b 100644 --- a/indra/newview/fsposestate.h +++ b/indra/newview/fsposestate.h @@ -49,7 +49,7 @@ public: /// The avatar whose animations are to be captured. /// The posing motion. /// The names of the joints being recaptured. - void updateMotionStates(LLVOAvatar* avatar, FSPosingMotion* posingMotion, std::vector jointNamesRecaptured); + void updateMotionStates(LLVOAvatar* avatar, FSPosingMotion* posingMotion, const std::vector& jointNamesRecaptured); /// /// Removes all current animation states for the supplied avatar. @@ -125,12 +125,12 @@ private: /// /// Represents 'capture layers: how the user layers animations 'on top of' others. /// - int captureOrder = 0; + S32 captureOrder = 0; /// /// Represents in-layer order of capture. /// - int inLayerOrder = 0; + S32 inLayerOrder = 0; /// /// When reloading, and if not-empty, the bone-numbers this motionId should affect. @@ -144,7 +144,7 @@ private: /// The avatar being posed by the motion. /// The posing motion. /// The order of the capture. - void resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, int captureOrder); + void resetPriorityForCaptureOrder(LLVOAvatar* avatar, FSPosingMotion* posingMotion, S32 captureOrder); /// /// Gets whether gAgentID owns, and thus can save information about the supplied motionId. @@ -197,8 +197,8 @@ private: /// /// Collab-safe means ASCII-printable chars, and delimiter usage does not conflict with Collab's delimiter. /// - std::string encodeVectorToString(std::vector vector); - std::vector decodeStringToVector(std::string vector); + std::string encodeVectorToString(const std::vector& vector); + std::vector decodeStringToVector(std::string_view vector); struct compareByCaptureOrder { @@ -213,8 +213,8 @@ private: } }; - static std::map > sMotionStates; - static std::map sCaptureOrder; + static std::map> sMotionStates; + static std::map sCaptureOrder; static std::map sMotionStatesOwnedByMe; }; diff --git a/indra/newview/fsposingmotion.cpp b/indra/newview/fsposingmotion.cpp index e34af7943a..91f018061d 100644 --- a/indra/newview/fsposingmotion.cpp +++ b/indra/newview/fsposingmotion.cpp @@ -36,7 +36,7 @@ FSPosingMotion::FSPosingMotion(const LLUUID& id) : LLKeyframeMotion(id) mJointMotionList = &dummyMotionList; } -LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter *character) +LLMotion::LLMotionInitStatus FSPosingMotion::onInitialize(LLCharacter* character) { if (!character) return STATUS_FAILURE; @@ -184,7 +184,7 @@ void FSPosingMotion::removeJointFromState(LLJoint* joint) void FSPosingMotion::setJointState(LLJoint* joint, U32 state) { - if (mJointPoses.size() < 1) + if (mJointPoses.empty()) return; if (!joint) return; @@ -208,7 +208,7 @@ void FSPosingMotion::setJointState(LLJoint* joint, U32 state) FSJointPose* FSPosingMotion::getJointPoseByJointName(const std::string& name) { - if (name.empty() || mJointPoses.size() < 1) + if (name.empty() || mJointPoses.empty()) return nullptr; for (auto poserJoint_iter = mJointPoses.begin(); poserJoint_iter != mJointPoses.end(); ++poserJoint_iter) @@ -222,9 +222,9 @@ FSJointPose* FSPosingMotion::getJointPoseByJointName(const std::string& name) return nullptr; } -FSJointPose* FSPosingMotion::getJointPoseByJointNumber(const S32& number) +FSJointPose* FSPosingMotion::getJointPoseByJointNumber(const S32 number) { - if (mJointPoses.size() < 1) + if (mJointPoses.empty()) return nullptr; if (number < 0) return nullptr; @@ -242,13 +242,13 @@ FSJointPose* FSPosingMotion::getJointPoseByJointNumber(const S32& number) bool FSPosingMotion::currentlyPosingJoint(LLJoint* joint) { - if (mJointPoses.size() < 1) + if (mJointPoses.empty()) return false; if (!joint) return false; - LLPose* pose = this->getPose(); + LLPose* pose = getPose(); if (!pose) return false; @@ -288,7 +288,7 @@ void FSPosingMotion::setJointBvhLock(FSJointPose* joint, bool lockInBvh) joint->zeroBaseRotation(lockInBvh); } -bool FSPosingMotion::loadOtherMotionToBaseOfThisMotion(LLKeyframeMotion* motionToLoad, F32 timeToLoadAt, std::vector selectedJointNumbers) +bool FSPosingMotion::loadOtherMotionToBaseOfThisMotion(LLKeyframeMotion* motionToLoad, F32 timeToLoadAt, const std::vector& selectedJointNumbers) { FSPosingMotion* motionToLoadAsFsPosingMotion = static_cast(motionToLoad); if (!motionToLoadAsFsPosingMotion) @@ -357,7 +357,7 @@ void FSPosingMotion::getJointStateAtTime(std::string jointPoseName, F32 timeToLo } } -bool FSPosingMotion::otherMotionAnimatesJoints(LLKeyframeMotion* motionToQuery, std::vector recapturedJointNumbers) +bool FSPosingMotion::otherMotionAnimatesJoints(LLKeyframeMotion* motionToQuery, const std::vector& recapturedJointNumbers) { FSPosingMotion* motionToLoadAsFsPosingMotion = static_cast(motionToQuery); if (!motionToLoadAsFsPosingMotion) @@ -367,7 +367,7 @@ bool FSPosingMotion::otherMotionAnimatesJoints(LLKeyframeMotion* motionToQuery, } // Do not try to access FSPosingMotion state; you are a LLKeyframeMotion cast as a FSPosingMotion, NOT an FSPosingMotion. -bool FSPosingMotion::motionAnimatesJoints(std::vector recapturedJointNumbers) +bool FSPosingMotion::motionAnimatesJoints(const std::vector& recapturedJointNumbers) { if (mJointMotionList == nullptr) return false; @@ -387,7 +387,7 @@ bool FSPosingMotion::motionAnimatesJoints(std::vector recapturedJointNumber return false; } -void FSPosingMotion::resetBonePriority(std::vector boneNumbersToReset) +void FSPosingMotion::resetBonePriority(const std::vector& boneNumbersToReset) { for (S32 boneNumber : boneNumbersToReset) { @@ -399,7 +399,7 @@ void FSPosingMotion::resetBonePriority(std::vector boneNumbersToReset) } } -bool FSPosingMotion::vectorsNotQuiteEqual(LLVector3 v1, LLVector3 v2) const +bool FSPosingMotion::vectorsNotQuiteEqual(const LLVector3& v1, const LLVector3& v2) const { if (vectorAxesAlmostEqual(v1.mV[VX], v2.mV[VX]) && vectorAxesAlmostEqual(v1.mV[VY], v2.mV[VY]) && diff --git a/indra/newview/fsposingmotion.h b/indra/newview/fsposingmotion.h index 1db88e8f86..2193973cff 100644 --- a/indra/newview/fsposingmotion.h +++ b/indra/newview/fsposingmotion.h @@ -68,7 +68,7 @@ public: // run-time (post constructor) initialization, // called after parameters have been set // must return true to indicate success and be available for activation - virtual LLMotionInitStatus onInitialize(LLCharacter *character); + virtual LLMotionInitStatus onInitialize(LLCharacter* character); // called when a motion is activated // must return TRUE to indicate success, or else @@ -113,7 +113,7 @@ public: /// /// The number of the joint to get the pose for. /// The matching joint pose, if found, otherwise null. - FSJointPose* getJointPoseByJointNumber(const S32& number); + FSJointPose* getJointPoseByJointNumber(const S32 number); /// /// Gets the motion identity for this animation. @@ -148,7 +148,7 @@ public: /// The play-time the animation should be advanced to derive the correct joint state. /// If only some of the joints should be animated by this motion, number them here. /// - bool loadOtherMotionToBaseOfThisMotion(LLKeyframeMotion* motionToLoad, F32 timeToLoadAt, std::vector selectedJointNumbers); + bool loadOtherMotionToBaseOfThisMotion(LLKeyframeMotion* motionToLoad, F32 timeToLoadAt, const std::vector& selectedJointNumbers); /// /// Tries to get the rotation, position and scale for the supplied joint name at the supplied time. @@ -172,7 +172,7 @@ public: /// Resets the bone priority to zero for the joints named in the supplied string. /// /// The vector containing bone numbers. - void resetBonePriority(std::vector boneNumbersToReset); + void resetBonePriority(const std::vector& boneNumbersToReset); /// /// Queries whether the supplied motion animates any of the joints named in the supplied string. @@ -180,7 +180,7 @@ public: /// The motion to query. /// A string containing all of the joint numbers. /// True if the motion animates any of the bones named, otherwise false. - bool otherMotionAnimatesJoints(LLKeyframeMotion* motionToQuery, std::vector recapturedJointNumbers); + bool otherMotionAnimatesJoints(LLKeyframeMotion* motionToQuery, const std::vector& recapturedJointNumbers); /// /// Queries whether the this motion animates any of the joints named in the supplied string. @@ -191,7 +191,7 @@ public: /// The most significant thing this method does is provide access to protected properties of an LLPosingMotion. /// Thus its most common usage would be to access those properties for an arbitrary animation. /// - bool motionAnimatesJoints(std::vector recapturedJointNumbers); + bool motionAnimatesJoints(const std::vector& recapturedJointNumbers); private: /// @@ -274,7 +274,7 @@ private: /// The first vector to compare. /// The sceond vector to compare. /// true if the vectors are "close enough", otherwise false. - bool vectorsNotQuiteEqual(LLVector3 v1, LLVector3 v2) const; + bool vectorsNotQuiteEqual(const LLVector3& v1, const LLVector3& v2) const; /// /// Determines if two quaternions are near enough to equal. diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index c692a24009..23cb507ec1 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -191,8 +191,8 @@ LLAvatarList::LLAvatarList(const Params& p) , mRlvCheckShowNames(false) // [/RLVa:KB] , mShowVoiceVolume(p.show_voice_volume) -, mShowUsername((bool)gSavedSettings.getBOOL("NameTagShowUsernames")) -, mShowDisplayName((bool)gSavedSettings.getBOOL("UseDisplayNames")) +, mShowUsername(gSavedSettings.getBOOL("NameTagShowUsernames")) +, mShowDisplayName(gSavedSettings.getBOOL("UseDisplayNames")) { setCommitOnSelectionChange(true); @@ -219,13 +219,13 @@ LLAvatarList::LLAvatarList(const Params& p) void LLAvatarList::handleDisplayNamesOptionChanged() { // FIRE-1089: Set the proper name options for the AvatarListItem before we update the list. - mShowUsername = (bool)gSavedSettings.getBOOL("NameTagShowUsernames"); - mShowDisplayName = (bool)gSavedSettings.getBOOL("UseDisplayNames"); + mShowUsername = gSavedSettings.getBOOL("NameTagShowUsernames"); + mShowDisplayName = gSavedSettings.getBOOL("UseDisplayNames"); std::vector items; getItems(items); - for( std::vector::const_iterator it = items.begin(); it != items.end(); it++) + for (auto panel : items) { - LLAvatarListItem* item = static_cast(*it); + LLAvatarListItem* item = static_cast(panel); item->showUsername(mShowUsername, false); item->showDisplayName(mShowDisplayName, false); } @@ -265,9 +265,9 @@ void LLAvatarList::updateRlvRestrictions(ERlvBehaviour behavior, ERlvParamType t { std::vector items; getItems(items); - for (std::vector::const_iterator it = items.begin(); it != items.end(); it++) + for (auto panel : items) { - LLAvatarListItem* item = static_cast(*it); + LLAvatarListItem* item = static_cast(panel); item->updateRlvRestrictions(); } } @@ -559,11 +559,11 @@ S32 LLAvatarList::notifyParent(const LLSD& info) return 1; } // [SL:KB] - Patch: UI-AvatarListDndShare | Checked: 2011-06-19 (Catznip-2.6.0c) | Added: Catznip-2.6.0c - else if ( (info.has("select")) && (info["select"].isUUID()) ) + else if (info.has("select") && info["select"].isUUID()) { const LLSD& sdValue = getSelectedValue(); const LLUUID idItem = info["select"].asUUID(); - if ( (!sdValue.isDefined()) || ((sdValue.isUUID()) && (sdValue.asUUID() != idItem)) ) + if (!sdValue.isDefined() || (sdValue.isUUID() && sdValue.asUUID() != idItem)) { resetSelection(); selectItemByUUID(info["select"].asUUID()); @@ -731,21 +731,18 @@ void LLAvatarList::onItemClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask) // static std::string LLAvatarList::getNameForDisplay(const LLUUID& avatar_id, const LLAvatarName& av_name, bool show_displayname, bool show_username, bool force_use_complete_name, bool rlv_check_shownames) { - bool fRlvCanShowName = (!rlv_check_shownames) || (RlvActions::canShowName(RlvActions::SNC_DEFAULT, avatar_id)); + const bool fRlvCanShowName = (!rlv_check_shownames) || (RlvActions::canShowName(RlvActions::SNC_DEFAULT, avatar_id)); if (show_displayname && !show_username) { - return ( (fRlvCanShowName) ? av_name.getDisplayName() : RlvStrings::getAnonym(av_name) ); + return (fRlvCanShowName ? av_name.getDisplayName() : RlvStrings::getAnonym(av_name)); } else if (!show_displayname && show_username) { - return ( (fRlvCanShowName) ? av_name.getUserName() : RlvStrings::getAnonym(av_name) ); + return (fRlvCanShowName ? av_name.getUserName() : RlvStrings::getAnonym(av_name)); } else { - // fix People / Friends showing [ user.name ] instead of (user.name) - // return ( (fRlvCanShowName) ? av_name.getCompleteName(false, force_use_complete_name) : RlvStrings::getAnonym(av_name) ); - return ( (fRlvCanShowName) ? av_name.getCompleteName(true, force_use_complete_name) : RlvStrings::getAnonym(av_name) ); - // + return (fRlvCanShowName ? av_name.getCompleteName(true, force_use_complete_name) : RlvStrings::getAnonym(av_name)); } } //