diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2025-06-13 18:33:49 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-06-13 21:49:02 +0300 |
| commit | 54660c8931593ceb465605acf872d5227e1d2d63 (patch) | |
| tree | 6460f98d9e12a5640d93516a39ccc78aabdcf76b /indra/llappearance | |
| parent | 8322a9a61e951275278fbf80b0a46880f5318107 (diff) | |
#4147 Joint Overrides #3
Remande skeleton translation from default skeleton to overriden skeleton
Diffstat (limited to 'indra/llappearance')
| -rw-r--r-- | indra/llappearance/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | indra/llappearance/llavatarappearance.cpp | 36 | ||||
| -rw-r--r-- | indra/llappearance/llavatarappearance.h | 3 | ||||
| -rw-r--r-- | indra/llappearance/lljointdata.h | 44 |
4 files changed, 66 insertions, 18 deletions
diff --git a/indra/llappearance/CMakeLists.txt b/indra/llappearance/CMakeLists.txt index c3be8bc78e..6744c8d8a4 100644 --- a/indra/llappearance/CMakeLists.txt +++ b/indra/llappearance/CMakeLists.txt @@ -14,6 +14,7 @@ set(llappearance_SOURCE_FILES llavatarjoint.cpp llavatarjointmesh.cpp lldriverparam.cpp + lljointdata.h lllocaltextureobject.cpp llpolyskeletaldistortion.cpp llpolymesh.cpp diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp index f3e474dba7..13bea1e5ea 100644 --- a/indra/llappearance/llavatarappearance.cpp +++ b/indra/llappearance/llavatarappearance.cpp @@ -29,6 +29,7 @@ #include "llavatarappearance.h" #include "llavatarappearancedefines.h" #include "llavatarjointmesh.h" +#include "lljointdata.h" #include "llstl.h" #include "lldir.h" #include "llpolymorph.h" @@ -108,11 +109,9 @@ public: private: typedef std::vector<LLAvatarBoneInfo*> bone_info_list_t; - static void getJointRestMatrices( - const bone_info_list_t& bone_list, - const std::string &parent_name, - LLAvatarAppearance::joint_rest_map_t& rest, - LLAvatarAppearance::joint_parent_map_t& parent_map, + static void getJointMatricesAndHierarhy( + LLAvatarBoneInfo* bone_info, + LLJointData& data, const glm::mat4& parent_mat); private: @@ -1677,19 +1676,18 @@ bool LLAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node) return true; } -void LLAvatarSkeletonInfo::getJointRestMatrices( - const bone_info_list_t& bone_list, - const std::string& parent_name, - LLAvatarAppearance::joint_rest_map_t& rest, - LLAvatarAppearance::joint_parent_map_t& parent_map, +void LLAvatarSkeletonInfo::getJointMatricesAndHierarhy( + LLAvatarBoneInfo* bone_info, + LLJointData& data, const glm::mat4& parent_mat) { - for (LLAvatarBoneInfo* bone_info : bone_list) + data.mName = bone_info->mName; + data.mJointMatrix = bone_info->getJointMatrix(); + data.mRestMatrix = parent_mat * data.mJointMatrix; + for (LLAvatarBoneInfo* child_info : bone_info->mChildren) { - glm::mat4 rest_mat = parent_mat * bone_info->getJointMatrix(); - rest[bone_info->mName] = rest_mat; - parent_map[bone_info->mName] = parent_name; - getJointRestMatrices(bone_info->mChildren, bone_info->mName, rest, parent_map, rest_mat); + LLJointData& child_data = data.mChildren.emplace_back(); + getJointMatricesAndHierarhy(child_info, child_data, data.mRestMatrix); } } @@ -1754,10 +1752,14 @@ const LLAvatarAppearance::joint_alias_map_t& LLAvatarAppearance::getJointAliases return mJointAliasMap; } -void LLAvatarAppearance:: getJointRestMatrices(LLAvatarAppearance::joint_rest_map_t& rest_map, LLAvatarAppearance::joint_parent_map_t& parent_map) const +void LLAvatarAppearance::getJointMatricesAndHierarhy(std::vector<LLJointData> &data) const { glm::mat4 identity(1.f); - LLAvatarSkeletonInfo::getJointRestMatrices(sAvatarSkeletonInfo->mBoneInfoList, std::string(), rest_map, parent_map, identity); + for (LLAvatarBoneInfo* bone_info : sAvatarSkeletonInfo->mBoneInfoList) + { + LLJointData& child_data = data.emplace_back(); + LLAvatarSkeletonInfo::getJointMatricesAndHierarhy(bone_info, child_data, identity); + } } diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h index e48d80b8ce..2748da9a1d 100644 --- a/indra/llappearance/llavatarappearance.h +++ b/indra/llappearance/llavatarappearance.h @@ -42,6 +42,7 @@ class LLTexGlobalColorInfo; class LLWearableData; class LLAvatarBoneInfo; class LLAvatarSkeletonInfo; +class LLJointData; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // LLAvatarAppearance @@ -156,7 +157,7 @@ public: const joint_alias_map_t& getJointAliases(); typedef std::map<std::string, std::string> joint_parent_map_t; // matrix plus parent typedef std::map<std::string, glm::mat4> joint_rest_map_t; - void getJointRestMatrices(joint_rest_map_t& rest_map, joint_parent_map_t& parent_map) const; + void getJointMatricesAndHierarhy(std::vector<LLJointData> &data) const; protected: static bool parseSkeletonFile(const std::string& filename, LLXmlTree& skeleton_xml_tree); diff --git a/indra/llappearance/lljointdata.h b/indra/llappearance/lljointdata.h new file mode 100644 index 0000000000..549f4af041 --- /dev/null +++ b/indra/llappearance/lljointdata.h @@ -0,0 +1,44 @@ +/** + * @file lljointdata.h + * @brief LLJointData class for holding individual joint data and skeleton + * + * $LicenseInfo:firstyear=2025&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2025, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLJOINTDATA_H +#define LL_LLJOINTDATA_H + +#include "v4math.h" + +// may be just move LLAvatarBoneInfo +class LLJointData +{ +public: + std::string mName; + glm::mat4 mJointMatrix; + glm::mat4 mRestMatrix; + + typedef std::vector<LLJointData> bones_t; + bones_t mChildren; +}; + +#endif //LL_LLJOINTDATA_H |
