From 55179387c7481d3b4ae34f3a53e0256d2705733b Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Mon, 25 Apr 2022 15:27:39 -0500
Subject: [PATCH] SL-17236 For real this time, maintain legacy draw order of
 alpha rigged meshes, batching be damned.

---
 indra/newview/llvovolume.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 35c415f9dbf..126a25115d6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5943,7 +5943,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
         // for rigged set, add weights and disable alpha sorting (rigged items use depth buffer)
         extra_mask |= LLVertexBuffer::MAP_WEIGHT4;
-        alpha_sort = FALSE;
         rigged = TRUE;
     }
 
@@ -6198,8 +6197,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
         
         if (rigged)
         {
-            //sort faces by things that break batches, including avatar and mesh id
-            std::sort(faces, faces + face_count, CompareBatchBreakerRigged());
+            if (!distance_sort) // <--- alpha "sort" rigged faces by maintaining original draw order
+            {
+                //sort faces by things that break batches, including avatar and mesh id
+                std::sort(faces, faces + face_count, CompareBatchBreakerRigged());
+            }
         }
         else if (!distance_sort)
         {
@@ -6234,11 +6236,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
 		texture_index_channels = gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels;
 	}
     
-    if (rigged)
-    { //don't attempt distance sorting on rigged meshes, not likely to succeed and breaks batches
-        distance_sort = FALSE;
-    }
-
     if (distance_sort)
     {
         buffer_index = -1;
-- 
GitLab