From 439aa79414edfe48f3bfa5d154987d741308bdbb Mon Sep 17 00:00:00 2001
From: Andrey Lihatskiy <alihatskiy@productengine.com>
Date: Mon, 24 Oct 2022 22:14:20 +0300
Subject: SL-18432 Fix for alpha sorting

---
 indra/newview/llspatialpartition.h |  2 +-
 indra/newview/llvovolume.cpp       | 51 ++++++--------------------------------
 2 files changed, 8 insertions(+), 45 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index f7bc9fb644..6d3ef33801 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -264,7 +264,7 @@ public:
                 return lhs->mAvatarp < rhs->mAvatarp;
             }
 
-            return lhs->mRenderOrder < rhs->mRenderOrder;
+            return lhs->mRenderOrder > rhs->mRenderOrder;
         }
     };
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e923115c43..a4e0d367c8 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5515,7 +5515,7 @@ static inline void add_face(T*** list, U32* count, T* face)
     {
         if (count[1] < MAX_FACE_COUNT)
         {
-            //face->setDrawOrderIndex(count[1]);
+            face->setDrawOrderIndex(count[1]);
             list[1][count[1]++] = face;
         }
     }
@@ -5523,36 +5523,12 @@ static inline void add_face(T*** list, U32* count, T* face)
     {
         if (count[0] < MAX_FACE_COUNT)
         {
-            //face->setDrawOrderIndex(count[0]);
+            face->setDrawOrderIndex(count[0]);
             list[0][count[0]++] = face;
         }
     }
 }
 
-// return index into linkset for given object (0 for root prim)
-U32 get_linkset_index(LLVOVolume* vobj)
-{
-    LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE;
-    if (vobj->isRootEdit())
-    {
-        return 0;
-    }
-
-    LLViewerObject* root = vobj->getRootEdit();
-    U32 idx = 1;
-    for (const auto& child : root->getChildren())
-    {
-        if (child == vobj)
-        {
-            return idx;
-        }
-        ++idx;
-    }
-
-    llassert(false);
-    return idx; //should never get here
-}
-
 void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
@@ -5714,8 +5690,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
             {
                 avatar->addAttachmentOverridesForObject(vobj, NULL, false);
             }
-            
-            U32 linkset_index = get_linkset_index(vobj);
 
             // Standard rigged mesh attachments: 
 			bool rigged = !vobj->isAnimatedObject() && skinInfo && vobj->isAttachment();
@@ -5736,9 +5710,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 					continue;
 				}
 
-                // order by linkset index first and face index second
-                facep->setDrawOrderIndex(linkset_index * 100 + i);
-
 				//ALWAYS null out vertex buffer on rebuild -- if the face lands in a render
 				// batch, it will recover its vertex buffer reference from the spatial group
 				facep->setVertexBuffer(NULL);
@@ -5763,6 +5734,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
                     if (facep->isState(LLFace::RIGGED))
                     { 
                         //face is not rigged but used to be, remove from rigged face pool
+                        LLDrawPoolAvatar* pool = (LLDrawPoolAvatar*)facep->getPool();
+                        if (pool)
+                        {
+                            pool->removeFace(facep);
+                        }
                         facep->clearState(LLFace::RIGGED);
                         facep->mAvatar = NULL;
                         facep->mSkinInfo = NULL;
@@ -6216,14 +6192,6 @@ struct CompareBatchBreakerRigged
     }
 };
 
-struct CompareDrawOrder
-{
-    bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
-    {
-        return lhs->getDrawOrderIndex() < rhs->getDrawOrderIndex();
-    }
-};
-
 U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures, BOOL rigged)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
@@ -6267,11 +6235,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
                 //sort faces by things that break batches, including avatar and mesh id
                 std::sort(faces, faces + face_count, CompareBatchBreakerRigged());
             }
-            else
-            {
-                // preserve legacy draw order for rigged faces
-                std::sort(faces, faces + face_count, CompareDrawOrder());
-            }
         }
         else if (!distance_sort)
         {
-- 
cgit v1.2.3


From a022452ff56c31cb028d5a17d827c82f1a74e624 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Wed, 26 Oct 2022 14:35:44 -0400
Subject: Increment viewer version to 6.6.7 following promotion of DRTVWR-574

---
 indra/newview/VIEWER_VERSION.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt
index 10abd6ae5b..5db1411e12 100644
--- a/indra/newview/VIEWER_VERSION.txt
+++ b/indra/newview/VIEWER_VERSION.txt
@@ -1 +1 @@
-6.6.6
+6.6.7
-- 
cgit v1.2.3