From e2c76ec70d643727d510f2aafac1e918655dfa44 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Jun 2025 18:52:41 +0300 Subject: #4147 Move mAlternateBindMatrices For reduced log spam and calculutions and to make further modifications easier. --- indra/newview/gltf/llgltfloader.cpp | 38 ++++++++++++++++++------------------- indra/newview/gltf/llgltfloader.h | 1 + 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp index ffe574f4b1..40b9334e63 100644 --- a/indra/newview/gltf/llgltfloader.cpp +++ b/indra/newview/gltf/llgltfloader.cpp @@ -903,25 +903,7 @@ bool LLGLTFLoader::populateModelFromMesh(LLModel* pModel, const LL::GLTF::Mesh& // In scope of same skin multiple meshes reuse same bind matrices skin_info.mInvBindMatrix.push_back(mInverseBindMatrices[skinIdx][i]); - // For alternate bind matrix, use the ORIGINAL joint transform (before rotation) - // Get the original joint node and use its matrix directly - // Todo: this seems blatantly wrong, it should have been rotated - glm::mat4 joint_mat = jointNode.mMatrix; - S32 root_joint = findValidRootJointNode(joint, gltf_skin); // skeleton can have multiple real roots - if (root_joint == joint) - { - // This is very likely incomplete in some way. - // Root shouldn't be the only one to need full coordinate fix - joint_mat = coord_system_rotation; - if (mApplyXYRotation) - { - joint_mat = coord_system_rotationxy * joint_mat; - } - } - LLMatrix4 original_joint_transform(glm::value_ptr(joint_mat)); - - LL_INFOS("GLTF_DEBUG") << "mAlternateBindMatrix name: " << legal_name << " val: " << original_joint_transform << LL_ENDL; - skin_info.mAlternateBindMatrix.push_back(LLMatrix4a(original_joint_transform)); + skin_info.mAlternateBindMatrix.push_back(mAlternateBindMatrices[skinIdx][i]); } } @@ -992,7 +974,23 @@ void LLGLTFLoader::populateJointFromSkin(S32 skin_idx) LL_INFOS("GLTF_DEBUG") << "mInvBindMatrix name: " << legal_name << " val: " << gltf_transform << LL_ENDL; mInverseBindMatrices[skin_idx].push_back(LLMatrix4a(gltf_transform)); } - // todo: prepare mAlternateBindMatrix here + + // Todo: this seems blatantly wrong + glm::mat4 joint_mat = jointNode.mMatrix; + S32 root_joint = findValidRootJointNode(joint, skin); // skeleton can have multiple real roots and one gltf root to group them + if (root_joint == joint) + { + // This is very likely incomplete in some way. + joint_mat = coord_system_rotation; + if (mApplyXYRotation) + { + joint_mat = coord_system_rotationxy * joint_mat; + } + } + LLMatrix4 original_joint_transform(glm::value_ptr(joint_mat)); + + LL_INFOS("GLTF_DEBUG") << "mAlternateBindMatrix name: " << legal_name << " val: " << original_joint_transform << LL_ENDL; + mAlternateBindMatrices[skin_idx].push_back(LLMatrix4a(original_joint_transform)); if (!legal_joint) { diff --git a/indra/newview/gltf/llgltfloader.h b/indra/newview/gltf/llgltfloader.h index 50a63c1cd8..6009a8e0c7 100644 --- a/indra/newview/gltf/llgltfloader.h +++ b/indra/newview/gltf/llgltfloader.h @@ -174,6 +174,7 @@ protected: // vector of vectors because of a posibility of having more than one skin typedef std::vector bind_matrices_t; bind_matrices_t mInverseBindMatrices; + bind_matrices_t mAlternateBindMatrices; private: bool parseMeshes(); -- cgit v1.2.3