changeset 1372:5572e7b02f45

m
author Ritor1
date Mon, 15 Jul 2013 17:09:22 +0600
parents d1c8121cf0ad
children 87155494292c
files Indoor.cpp mm7_4.cpp mm7_data.h
diffstat 3 files changed, 68 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Mon Jul 15 15:03:56 2013 +0600
+++ b/Indoor.cpp	Mon Jul 15 17:09:22 2013 +0600
@@ -771,7 +771,7 @@
             v7 = GetPortalScreenCoord(v1);
             if ( v7 )
             {
-              if ( sub_424829(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
+              if ( PortalFrustrum(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
               {
                 if ( v2->uPolygonType == 1 )
                 {
@@ -1379,7 +1379,7 @@
       face_min_screenspace_x <= nodes[node_id].uViewportZ &&
       face_max_screenspace_y >= nodes[node_id].uViewportY &&
       face_min_screenspace_y <= nodes[node_id].uViewportW &&
-      sub_424829(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID))
+      PortalFrustrum(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID))
   {
     pTransitionSector = pFace->uSectorID;
     if (nodes[node_id].uSectorID == pTransitionSector )
@@ -1532,7 +1532,7 @@
           && v23 <= *((short *)v20 + 2007)
           && v12 >= *((short *)v20 + 2006)
           && v22 <= *((short *)v20 + 2008)
-          && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) )
+          && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) )
         {
           v16 = v21->uSectorID;
           if ( *((short *)v20 + 2004) == v16 )
@@ -1591,7 +1591,7 @@
         v3 = GetPortalScreenCoord(v2);
         if ( v3 )
         {
-          if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
+          if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
           {
             v4 = stru_F8A590._viewport_space_y;
             v5 = pBLVRenderParams->pRenderTarget;
@@ -6831,12 +6831,12 @@
   check_event_triggers();
 }
 //----- (00424829) --------------------------------------------------------
-bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
+bool PortalFrustrum(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
 {
-  int v6; // eax@3
+  //int v6; // eax@3
   int min_y; // esi@5
   int max_y; // edx@5
-  int v10; // eax@12
+  int current_ID; // eax@12
   int v13; // eax@22
   int v15; // ecx@29
   int v18; // eax@39
@@ -6858,14 +6858,14 @@
   int v49; // esi@93
   int v53; // [sp+Ch] [bp-34h]@44
   int v54; // [sp+10h] [bp-30h]@0
-  int v55; // [sp+14h] [bp-2Ch]@12
+  int min_y_ID2; // [sp+14h] [bp-2Ch]@12
   int v59; // [sp+14h] [bp-2Ch]@87
   int v61; // [sp+1Ch] [bp-24h]@29
   int v62; // [sp+20h] [bp-20h]@0
-  signed int v63; // [sp+24h] [bp-1Ch]@3
-  signed int v64; // [sp+28h] [bp-18h]@3
-  int v65; // [sp+2Ch] [bp-14h]@5
-  int v68; // [sp+34h] [bp-Ch]@12
+  signed int direction1; // [sp+24h] [bp-1Ch]@3
+  signed int direction2; // [sp+28h] [bp-18h]@3
+  int min_y_ID; // [sp+2Ch] [bp-14h]@5
+  //int v68; // [sp+34h] [bp-Ch]@12
   int v69; // [sp+34h] [bp-Ch]@29
   int v70; // [sp+34h] [bp-Ch]@46
   int v71; // [sp+34h] [bp-Ch]@75
@@ -6874,59 +6874,63 @@
   if ( pNumVertices <= 1 )
     return false;
   min_y = PortalFace._screen_space_y[0];
-  v65 = 0;
+  min_y_ID = 0;
   max_y = PortalFace._screen_space_y[0];
+  //face direction(направление фейса)
   if ( !PortalFace.direction )
   {
-    v63 = 1;
-    v64 = -1;
+    direction1 = 1;
+    direction2 = -1;
   }
   else 
   {
-    v63 = -1;
-    v64 = 1;
-  }
-
-  for ( v6 = 1; v6 < pNumVertices; ++v6 )
-  {
-    if ( PortalFace._screen_space_y[v6] >= min_y )
+    direction1 = -1;
+    direction2 = 1;
+  }
+
+  //get min and max y for portal(дать минимальное и максимальное значение y для портала)
+  for ( uint i = 1; i < pNumVertices; ++i )
+  {
+    if ( PortalFace._screen_space_y[i] >= min_y )
     {
-      if ( PortalFace._screen_space_y[v6] > max_y )
-        max_y = PortalFace._screen_space_y[v6];
+      if ( PortalFace._screen_space_y[i] > max_y )
+        max_y = PortalFace._screen_space_y[i];
     }
-    if ( PortalFace._screen_space_y[v6] < min_y )
+    else
     {
-      v65 = v6;
-      min_y = PortalFace._screen_space_y[v6];
+      min_y_ID = i;
+      min_y = PortalFace._screen_space_y[i];
     }
   }
   if ( max_y == min_y )
     return false;
 
-  v10 = v65;
+  //*****************************************************************************************************************************
   a2->_viewport_space_y = min_y;
   a2->_viewport_space_w = max_y;
-  v55 = v65;
-
-  for ( v68 = 0; v68 < pNumVertices; ++v68 )
-  {
-    v10 += v64;
-    if ( v10 < pNumVertices )
+  current_ID = min_y_ID;
+  min_y_ID2 = min_y_ID;
+
+  for ( uint i = 0; i < pNumVertices; ++i )
+  {
+    current_ID += direction2;
+    if ( current_ID < pNumVertices )
     {
-      if ( v10 < 0 )
-        v10 += pNumVertices;
+      if ( current_ID < 0 )
+        current_ID += pNumVertices;
     }
     else
-      v10 -= pNumVertices;
-    if ( PortalFace._screen_space_y[v10] <= PortalFace._screen_space_y[v65] )
+      current_ID -= pNumVertices;
+    if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )//определение минимальной у
     {
-      v55 = v10;
-      v65 = v10;
+      min_y_ID2 = current_ID;
+      min_y_ID = current_ID;
     }
-    if ( PortalFace._screen_space_y[v10] == max_y )
+    if ( PortalFace._screen_space_y[current_ID] == max_y )
       break;
   }
-  v13 = v55 + v64;
+
+  v13 = min_y_ID2 + direction2;
   if ( v13 < pNumVertices )
   {
     if ( v13 < 0 )
@@ -6934,18 +6938,19 @@
   }
   else
     v13 -= pNumVertices;
-  if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[v55] )
-  {
-    v62 = PortalFace._screen_space_x[v55] << 16;
-    v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[v55]) << 16) / (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[v55]);
-    a2->viewport_left_side[min_y] = LOWORD(PortalFace._screen_space_x[v55]);
-  }
-  v15 = v65;
-  v61 = v65;
-
+  if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] )
+  {
+    v62 = PortalFace._screen_space_x[min_y_ID2] << 16;
+    v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]);
+    a2->viewport_left_side[min_y] = PortalFace._screen_space_x[min_y_ID2];
+  }
+  //****************************************************************************************************************************************
+  //
+  v15 = min_y_ID;
+  v61 = min_y_ID;
   for ( v69 = 0; v69 < pNumVertices; ++v69 )
   {
-    v15 += v63;
+    v15 += direction1;
     if ( v15 < pNumVertices )
     {
       if ( v15 < 0 )
@@ -6953,15 +6958,15 @@
     }
     else
       v15 -= pNumVertices;
-    if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[v65] )
+    if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] )
     {
       v61 = v15;
-      v65 = v15;
+      min_y_ID = v15;
     }
     if ( PortalFace._screen_space_y[v15] == max_y )
       break;
   }
-  v18 = v63 + v61;
+  v18 = direction1 + v61;
   if ( v18 < pNumVertices )
   {
     if ( v18 < 0 )
@@ -6975,8 +6980,9 @@
   {
     v61 = PortalFace._screen_space_x[v20] << 16;
     v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20];
-    a2->viewport_right_side[max_y] = LOWORD(PortalFace._screen_space_x[v20]);
-  }
+    a2->viewport_right_side[max_y] = PortalFace._screen_space_x[v20];
+  }
+  //****************************************************************************************************************************************
   v22 = min_y;
   if ( min_y <= max_y )
   {
@@ -6987,7 +6993,7 @@
       v24 = v13;
       if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y )
       {
-        v13 = v64 + v13;
+        v13 = direction2 + v13;
         if ( v13 < pNumVertices )
         {
           if ( v13 < 0 )
@@ -7006,7 +7012,7 @@
       v29 = v18;
       if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y )
       {
-        v18 += v63;
+        v18 += direction1;
         if ( v18 < pNumVertices )
         {
           if ( v18 < 0 )
--- a/mm7_4.cpp	Mon Jul 15 15:03:56 2013 +0600
+++ b/mm7_4.cpp	Mon Jul 15 17:09:22 2013 +0600
@@ -3497,7 +3497,7 @@
         result = GetPortalScreenCoord(sFaceID);
         if ( result )
         {
-          result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
+          result = PortalFrustrum(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
           if ( result )
           {
             result = (int)v3->GetTexture();
@@ -3962,7 +3962,7 @@
       v59 = GetPortalScreenCoord(uFaceID);
       v3 = v59;
     }
-    if ( v3 && (pRenderer->pRenderD3D || sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1)) )
+    if ( v3 && (pRenderer->pRenderD3D || PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1)) )
     {
       v4 = v2->GetTexture();
       v5 = 0;
--- a/mm7_data.h	Mon Jul 15 15:03:56 2013 +0600
+++ b/mm7_data.h	Mon Jul 15 17:09:22 2013 +0600
@@ -1151,7 +1151,7 @@
 void __cdecl sub_423B4A();
 int __fastcall GetPortalScreenCoord(unsigned int uFaceID);
 signed int __fastcall sub_424579(int uFaceID, struct stru320 *a2);
-bool sub_424829(int pNumVertices, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int uFaceID);
+bool PortalFrustrum(int pNumVertices, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int uFaceID);
 signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb
 signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb
 signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb