changeset 2149:d4f00d622889

SortByScreenSpaceX and SortByScreenSpaceY for Vis fix
author Ritor1
date Wed, 08 Jan 2014 15:01:58 +0600
parents af349bd395ff
children 701dc2f4956b
files Vis.cpp Vis.h
diffstat 2 files changed, 69 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/Vis.cpp	Tue Jan 07 22:15:45 2014 +0600
+++ b/Vis.cpp	Wed Jan 08 15:01:58 2014 +0600
@@ -979,8 +979,8 @@
 }
 
 //----- (004C264A) --------------------------------------------------------
-void Vis::sort_object_pointers( Vis_ObjectInfo **pPointers, int start, int end )
-    {
+void Vis::sort_object_pointers( Vis_ObjectInfo **pPointers, int start, int end )//сортировка
+{
   int sort_start; // edx@1
   int forward_sort_index; // esi@2
   signed int backward_sort_index; // ecx@2
@@ -1000,11 +1000,11 @@
       backward_sort_index = end;
       do
       {
-        last_z_val = pPointers[end]->sZValue&0xFFFF0000;
+        last_z_val = pPointers[end]->sZValue & 0xFFFF0000;
         do
         {
           ++forward_sort_index;
-          more_lz_val = pPointers[forward_sort_index]->sZValue&0xFFFF0000;
+          more_lz_val = pPointers[forward_sort_index]->sZValue & 0xFFFF0000;
         }
         while ( more_lz_val < last_z_val );
 
@@ -1013,7 +1013,7 @@
           if ( backward_sort_index < 1 )
             break;
           --backward_sort_index;
-          less_lz_val = pPointers[backward_sort_index]->sZValue&0xFFFF0000;
+          less_lz_val = pPointers[backward_sort_index]->sZValue & 0xFFFF0000;
         }
         while ( less_lz_val > last_z_val );
 
@@ -1163,121 +1163,83 @@
 }
 
 //----- (004C288E) --------------------------------------------------------
-bool Vis::SortByScreenSpaceX(RenderVertexSoft *pArray, int sLeft, int sRight)
+void Vis::SortByScreenSpaceX(RenderVertexSoft *pArray, int start, int end)//сортировка по возрастанию экранных координат х
 {
-  bool result; // eax@1
-  RenderVertexSoft *v5; // edx@2
-  int v6; // ebx@2
-  int i; // ecx@2
-  int v8; // esi@3
-  int v9; // esi@5
-  //RenderVertexSoft *v10; // eax@8
-  const void *v10;
-  RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8
-  RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
-  //float v13; // [sp+4Ch] [bp-24h]@4
-  int v14; // [sp+64h] [bp-Ch]@7
-  //Vis *thisa; // [sp+68h] [bp-8h]@1
-  //void *thisa;
-  //RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
-  const void *v16;
+  int left_sort_index; // ebx@2
+  int right_sort_index; // ecx@2
+  RenderVertexSoft temp_array; // [sp+4h] [bp-6Ch]@8
+  RenderVertexSoft max_array; // [sp+34h] [bp-3Ch]@2
+  int v12; // [sp+64h] [bp-Ch]@7
 
-  //thisa = this;
-  if (sRight <= sLeft)
-    return true;
-  v5 = pArray;
-  v16 = &pArray[sRight];
-  v6 = sLeft - 1;
-  memcpy(&v12, &pArray[sRight], sizeof(v12));
-  for ( i = sRight; ; i = v14 )
+  if ( end > start )
   {
-    v8 = (int)&v5[v6].vWorldViewProjX;
-    do
+    left_sort_index = start - 1;
+    memcpy(&max_array, &pArray[end], sizeof(max_array));
+    for ( right_sort_index = end; ; right_sort_index = v12 )
     {
-      v8 += 48;
-      ++v6;
-    }
-    while ( *(float *)v8 < v12.vWorldViewProjX);
-    v9 = (int)&v5[i].vWorldViewProjX;
-    do
-    {
-      v9 -= 48;
-      --i;
+      do
+      {
+        ++left_sort_index;
+      }
+      while ( pArray[left_sort_index].vWorldViewProjX < (double)max_array.vWorldViewProjX );
+      do
+      {
+        --right_sort_index;
+      }
+      while ( pArray[right_sort_index].vWorldViewProjX > (double)max_array.vWorldViewProjX );
+      v12 = right_sort_index;
+      if ( left_sort_index >= right_sort_index )
+        break;
+      memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array));
+      memcpy(&pArray[left_sort_index], &pArray[right_sort_index], sizeof(pArray[left_sort_index]));
+      memcpy(&pArray[right_sort_index], &temp_array, sizeof(pArray[right_sort_index]));
     }
-    while ( *(float *)v9 > v12.vWorldViewProjX);
-    v14 = i;
-    if ( v6 >= i )
-      break;
-    v10 = &v5[i];
-    memcpy(&v11, &pArray[v6], sizeof(v11));
-    v5 = pArray;
-    memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
-    memcpy((void *)v10, &v11, sizeof(0x30u));
+    memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array));
+    memcpy(&pArray[left_sort_index], &pArray[end], sizeof(pArray[left_sort_index]));
+    memcpy(&pArray[end], &temp_array, sizeof(pArray[end]));
+    Vis::SortByScreenSpaceX(pArray, start, left_sort_index - 1);
+    Vis::SortByScreenSpaceX(pArray, left_sort_index + 1, end);
   }
-  memcpy(&v11, &v5[v6], sizeof(v11));
-  memcpy(&v5[v6], v16, sizeof(v5[v6]));
-  memcpy((void *)v16, &v11, sizeof(0x30u));
-  SortByScreenSpaceX(v5, sLeft, v6 - 1);
-  SortByScreenSpaceX(pArray, v6 + 1, sRight);
-  return true;
 }
 
 //----- (004C297E) --------------------------------------------------------
-bool Vis::SortByScreenSpaceY(RenderVertexSoft *pArray, int sLeft, int sRight)
+void Vis::SortByScreenSpaceY(RenderVertexSoft *pArray, int start, int end)
 {
-  //bool result; // eax@1
-  RenderVertexSoft *v5; // edx@2
-  int v6; // ebx@2
-  int i; // ecx@2
-  int v8; // esi@3
-  int v9; // esi@5
-  //RenderVertexSoft *v10; // eax@8
-  const void *v10;
-  //char v11; // [sp+4h] [bp-6Ch]@8
-  RenderVertexSoft v11;
-  RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
-  //float v13; // [sp+50h] [bp-20h]@4
-  int v14; // [sp+64h] [bp-Ch]@7
-  //Vis *thisa; // [sp+68h] [bp-8h]@1
-  RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
+  int left_sort_index; // ebx@2
+  int right_sort_index; // ecx@2
+  RenderVertexSoft temp_array; // [sp+4h] [bp-6Ch]@8
+  RenderVertexSoft max_array; // [sp+34h] [bp-3Ch]@2
+  int v12; // [sp+64h] [bp-Ch]@7
 
-  if (sRight <= sLeft)
-   return true;
-  v5 = pArray;
-  v16 = &pArray[sRight];
-  v6 = sLeft - 1;
-  memcpy(&v12, &pArray[sRight], sizeof(v12));
-  for ( i = sRight; ; i = v14 )
+  if ( end > start )
   {
-    v8 = (int)&v5[v6].vWorldViewProjY;
-    do
+    left_sort_index = start - 1;
+    memcpy(&max_array, &pArray[end], sizeof(max_array));
+    for ( right_sort_index = end; ; right_sort_index = v12 )
     {
-      v8 += 48;
-      ++v6;
-    }
-    while ( *(float *)v8 < v12.vWorldViewProjY);
-    v9 = (int)&v5[v6].vWorldViewProjY;
-    do
-    {
-      v9 -= 48;
-      --i;
+      do
+      {
+        ++left_sort_index;
+      }
+      while ( pArray[left_sort_index].vWorldViewProjY < (double)max_array.vWorldViewProjY );
+      do
+      {
+        --right_sort_index;
+      }
+      while ( pArray[right_sort_index].vWorldViewProjY > (double)max_array.vWorldViewProjY );
+      v12 = right_sort_index;
+      if ( left_sort_index >= right_sort_index )
+        break;
+      memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array));
+      memcpy(&pArray[left_sort_index], &pArray[right_sort_index], sizeof(pArray[left_sort_index]));
+      memcpy(&pArray[right_sort_index], &temp_array, sizeof(pArray[right_sort_index]));
     }
-    while ( *(float *)v9 > v12.vWorldViewProjY);
-    v14 = i;
-    if ( v6 >= i )
-      break;
-    v10 = &v5[i];
-    memcpy(&v11, &pArray[v6], sizeof(0x30));
-    v5 = pArray;
-    memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
-    memcpy((void *)v10, &v11, sizeof(0x30));
+    memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array));
+    memcpy(&pArray[left_sort_index], &pArray[end], sizeof(pArray[left_sort_index]));
+    memcpy(&pArray[end], &temp_array, sizeof(pArray[end]));
+    Vis::SortByScreenSpaceY(pArray, start, left_sort_index - 1);
+    Vis::SortByScreenSpaceY(pArray, left_sort_index + 1, end);
   }
-  memcpy(&v11, &v5[v6], sizeof(0x30));
-  memcpy(&v5[v6], v16, sizeof(v5[v6]));
-  memcpy((void *)v16, &v11, sizeof(0x30));
-  SortByScreenSpaceY(v5, sLeft, v6 - 1);
-  SortByScreenSpaceY(pArray, v6 + 1, sRight);
-  return true;
 }
 
 //----- (004C04AF) --------------------------------------------------------
--- a/Vis.h	Tue Jan 07 22:15:45 2014 +0600
+++ b/Vis.h	Wed Jan 08 15:01:58 2014 +0600
@@ -119,8 +119,8 @@
   void sort_object_pointers(Vis_ObjectInfo **pPointers, int start, int end);
   bool SortVerticesByX(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd);
   bool SortVerticesByY(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd);
-  bool SortByScreenSpaceX(struct RenderVertexSoft *pArray, int sLeft, int sRight);
-  bool SortByScreenSpaceY(struct RenderVertexSoft *pArray, int sLeft, int sRight);
+  void SortByScreenSpaceX(struct RenderVertexSoft *pArray, int start, int end);
+  void SortByScreenSpaceY(struct RenderVertexSoft *pArray, int start, int end);
 
   //void ( ***vdestructor_ptr)(Vis *, bool);
   Vis_SelectionList default_list;