From 08971cd9ac4a865ccc312f8ebe381e620062339c Mon Sep 17 00:00:00 2001 From: Henri Beauchamp <8734940+vldevel@users.noreply.github.com> Date: Tue, 22 Jul 2025 18:22:55 +0200 Subject: Fix a crash bug and bogus calculations in LLMeshRepoThread::lodReceived() (#4398, #4408) When trying to update the rigging info for a newly received mesh LOD, a wrong usage of LLVolume::getNumFaces() is done to get the number of volume faces, causing the code to iterate over the number of faces in the underlying LLProfile instead. LLVolume::getNumVolumeFaces() must be used here. This fixes a crash bug seen with low LODs in some meshes (when the number of mesh faces is smaller than the number of faces in the LLProfile), and also properly updates the rigging info for all mesh faces, as it should, when the mesh got more faces than the LLProfile. --- indra/newview/llmeshrepository.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index e7e95034b2..f25cb25517 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2362,7 +2362,13 @@ EMeshProcessingResult LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_p LLPointer volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod)); if (volume->unpackVolumeFaces(data, data_size)) { - if (volume->getNumFaces() > 0) + // Use LLVolume::getNumVolumeFaces() here and not LLVolume::getNumFaces(), + // because setMeshAssetLoaded() has not yet been called for this volume + // (it is set later in LLMeshRepository::notifyMeshLoaded()), and + // getNumFaces() would return the number of faces in the LLProfile + // instead. HB + S32 num_faces = volume->getNumVolumeFaces(); + if (num_faces > 0) { // if we have a valid SkinInfo, cache per-joint bounding boxes for this LOD LLPointer skin_info = nullptr; @@ -2376,7 +2382,7 @@ EMeshProcessingResult LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_p } if (skin_info.notNull() && isAgentAvatarValid()) { - for (S32 i = 0; i < volume->getNumFaces(); ++i) + for (S32 i = 0; i < num_faces; ++i) { // NOTE: no need to lock gAgentAvatarp as the state being checked is not changed after initialization LLVolumeFace& face = volume->getVolumeFace(i); -- cgit v1.2.3