changeset 1320:2e3deb510de3

Слияние
author Ritor1
date Fri, 28 Jun 2013 11:34:15 +0600
parents 2ddb0af0f437 (diff) ae6c8e1ddef4 (current diff)
children cc8d58f2bf0c
files
diffstat 5 files changed, 203 insertions(+), 218 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Jun 26 21:33:42 2013 +0400
+++ b/Indoor.cpp	Fri Jun 28 11:34:15 2013 +0600
@@ -1262,7 +1262,7 @@
   //stru170 *v4; // ebx@1
   //BLVFace *v5; // eax@1
   //int v6; // ecx@2
-  unsigned __int16 v7; // ax@11
+  unsigned __int16 pTransitionSector; // ax@11
   Vec3_short_ *v8; // esi@15
   int v9; // edx@15
   //signed int v10; // eax@18
@@ -1273,7 +1273,7 @@
   int v15; // edx@24
   //int v16; // esi@29
   //BLVFace *v17; // edi@34
-  unsigned __int16 v18; // ax@34
+  //unsigned __int16 v18; // ax@34
   char *v19; // eax@38
   signed int v20; // ecx@38
   char *v21; // eax@42
@@ -1303,7 +1303,6 @@
   //v39 = &pIndoor->pFaces[uFaceID];
 
   auto pFace = &pIndoor->pFaces[uFaceID];
-  auto p = &nodes[node_id];
 
   if (!pFace->Portal())
   {
@@ -1315,127 +1314,115 @@
     return;
   }
 
-    if (p->uFaceID == uFaceID)
-      return;
-    if (!node_id &&
-        pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 &&  // we are probably standing at the portal plane
-        pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 &&
-        pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 &&
-        pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 &&
-        pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 &&
-        pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 )
+  if (nodes[node_id].uFaceID == uFaceID)
+    return;
+  if (!node_id &&
+      pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 &&  // we are probably standing at the portal plane
+      pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 &&
+      pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 &&
+      pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 &&
+      pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 &&
+      pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 )
+  {
+    if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
+                                        + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
+                                        + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
     {
-      if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
-                                          + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
-                                          + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
-      {
-        v7 = pFace->uSectorID;
-        if ( nodes[0].uSectorID == v7 )  // draw back sector
-          v7 = pFace->uBackSectorID;
-        nodes[num_nodes].uSectorID = v7;
-        nodes[num_nodes].uFaceID = uFaceID;
-        nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
-        nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
-        nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
-        nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
-        nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
-                                         pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
-        AddBspNodeToRenderList(++num_nodes - 1);
-        return;
-      }
-      //v5 = v39;
-      //v6 = a0;
+      pTransitionSector = pFace->uSectorID;
+      if ( nodes[0].uSectorID == pTransitionSector )  // draw back sector
+        pTransitionSector = pFace->uBackSectorID;
+      nodes[num_nodes].uSectorID = pTransitionSector;
+      nodes[num_nodes].uFaceID = uFaceID;
+      nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
+      nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
+      nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
+      nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
+      nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
+                                       pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
+      AddBspNodeToRenderList(++num_nodes - 1);
+      return;
     }
-
-    v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
-    v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x)
-       + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y)
-       + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
-    if (p->uSectorID != pFace->uSectorID)
-      v9 = -v9;
-    if (v9 >= 0)
-      return;
-
-    auto num_vertices = sub_423B5D(uFaceID);
-    if (num_vertices < 2)
-      return;
-
-    auto face_min_screenspace_x = stru_50B700._screen_space_x[0],
-         face_max_screenspace_x = stru_50B700._screen_space_x[0];
-    auto face_min_screenspace_y = stru_50B700._screen_space_y[0],
-         face_max_screenspace_y = stru_50B700._screen_space_y[0];
-    for (uint i = 1; i < num_vertices; ++i)
-    {
-      if (face_min_screenspace_x > stru_50B700._screen_space_x[i])
-        face_min_screenspace_x = stru_50B700._screen_space_x[i];
-      if (face_max_screenspace_x < stru_50B700._screen_space_x[i])
-        face_max_screenspace_x = stru_50B700._screen_space_x[i];
-
-      if (face_min_screenspace_y > stru_50B700._screen_space_y[i])
-        face_min_screenspace_y = stru_50B700._screen_space_y[i];
-      if (face_max_screenspace_y < stru_50B700._screen_space_y[i])
-        face_max_screenspace_y = stru_50B700._screen_space_y[i];
-    }
+  }
+
+  v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)
+     + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
+     + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z);
+  if (nodes[node_id].uSectorID != pFace->uSectorID)
+    v9 = -v9;
+  if (v9 >= 0)
+    return;
+
+  auto num_vertices = sub_423B5D(uFaceID);
+  if (num_vertices < 2)
+    return;
+
+  auto face_min_screenspace_x = stru_50B700._screen_space_x[0],
+       face_max_screenspace_x = stru_50B700._screen_space_x[0];
+  auto face_min_screenspace_y = stru_50B700._screen_space_y[0],
+       face_max_screenspace_y = stru_50B700._screen_space_y[0];
+  for (uint i = 1; i < num_vertices; ++i)
+  {
+    if (face_min_screenspace_x > stru_50B700._screen_space_x[i])
+      face_min_screenspace_x = stru_50B700._screen_space_x[i];
+    if (face_max_screenspace_x < stru_50B700._screen_space_x[i])
+      face_max_screenspace_x = stru_50B700._screen_space_x[i];
+
+    if (face_min_screenspace_y > stru_50B700._screen_space_y[i])
+      face_min_screenspace_y = stru_50B700._screen_space_y[i];
+    if (face_max_screenspace_y < stru_50B700._screen_space_y[i])
+      face_max_screenspace_y = stru_50B700._screen_space_y[i];
+  }
 	  //_screen_space_x = 719, 568, 493
 	  //savegame: qw , 0Bh and 0x1D4h
 	  //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ
-      if (face_max_screenspace_x >= p->uViewportX &&
-          face_min_screenspace_x <= p->uViewportZ &&
-          face_max_screenspace_y >= p->uViewportY &&
-          face_min_screenspace_y <= p->uViewportW &&
-          sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID))
-        {
-          //v17 = v39;
-          v18 = pFace->uSectorID;
-          if (p->uSectorID == v18 )
-            v18 = pFace->uBackSectorID;
-          nodes[num_nodes].uSectorID = v18;
-          nodes[num_nodes].uFaceID = uFaceID;
-          nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
-          nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
-          nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
-          nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
-          //v38 = pGame->pStru10Instance;
-          //a0a = pGame->pIndoorCameraD3D;
-          v29 = false;
-          if (p->viewing_portal_id == -1)
-          {
-            v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding);
-          }
-          else
-          {
-            static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64];
-            static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64];
-
-            for (uint k = 0; k < pFace->uNumVertices; ++k)
-            {
-              static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x;
-              static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y;
-              static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z;
-            }
-
-
-            unsigned int a2 = pFace->uNumVertices;
-            pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08,
-                                                     &a2,
-                                                     static_subAddFaceToRenderList_d3d_stru_F79E08,
-                                                     p->std__vector_0007AC, 4, 0, 0);
-
-            v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2,
-                                                  nodes[num_nodes].std__vector_0007AC,
-                                                  nodes[num_nodes].pPortalBounding);
-          }
-          if ( 1 )
-          {
-            assert(num_nodes < 150);
-
-            nodes[num_nodes].viewing_portal_id = uFaceID;
-            AddBspNodeToRenderList(++num_nodes - 1);
-          }
-          if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES)
-            pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF);
-            //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace);
-        }
+  if (face_max_screenspace_x >= nodes[node_id].uViewportX &&
+      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))
+  {
+    pTransitionSector = pFace->uSectorID;
+    if (nodes[node_id].uSectorID == pTransitionSector )
+      pTransitionSector = pFace->uBackSectorID;
+    nodes[num_nodes].uSectorID = pTransitionSector;
+    nodes[num_nodes].uFaceID = uFaceID;
+    nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
+    nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
+    nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
+    nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
+    v29 = false;
+    if (nodes[node_id].viewing_portal_id == -1)//     
+      v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding);
+    else//   
+    {
+      static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64];
+      static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64];
+
+      for (uint k = 0; k < pFace->uNumVertices; ++k)
+      {
+        static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x;
+        static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y;
+        static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z;
+      }
+
+      unsigned int pNewNumVertices = pFace->uNumVertices;
+      pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices,
+                                               static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0);
+
+      v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices,
+                                            nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding);
+    }
+    if ( 1 )
+    {
+      assert(num_nodes < 150);
+
+      nodes[num_nodes].viewing_portal_id = uFaceID;
+      AddBspNodeToRenderList(++num_nodes - 1);
+    }
+    if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES)
+      pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF);
+    //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace);
+  }
 }
 
 
--- a/IndoorCameraD3D.cpp	Wed Jun 26 21:33:42 2013 +0400
+++ b/IndoorCameraD3D.cpp	Fri Jun 28 11:34:15 2013 +0600
@@ -1373,13 +1373,13 @@
   RenderVertexSoft *v14; // eax@8
   RenderVertexSoft *v15; // edx@8
   Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12
-  float v17; // [sp+44h] [bp-10h]@1
-  int v18; // [sp+48h] [bp-Ch]@5
+  //float v17; // [sp+44h] [bp-10h]@1
+  //int v18; // [sp+48h] [bp-Ch]@5
   //stru9 *thisa; // [sp+4Ch] [bp-8h]@1
   int a7a; // [sp+53h] [bp-1h]@5
   //bool a6a; // [sp+70h] [bp+1Ch]@5
 
-  v17 = 0.0;
+  //v17 = 0.0;
   //thisa = pGame->pStru9Instance;
   
   static RenderVertexSoft sr_vertices_50D9D8[64];
@@ -1388,41 +1388,44 @@
   a7a = 0;
   v11 = 2 * (a6 == 0) + 1;
   //a6a = 0;
-  v18 = v11;
+  //v18 = v11;
   if (uNumVertices <= 0)
     return false;
 
     //v12 = *pOutNumVertices;
     //v13 = (char *)&a4->y;
-  uint i = 0;
-    while ( 1 )
+  
+  //while ( 1 )
+  for ( uint i = 0; i < uNumVertices; ++i )
+  {
+    if (i % 2)
+    {
+      v14 = a1;
+      v15 = sr_vertices_50D9D8;
+    }
+    else
     {
-      if (i % 2)
-      {
-        v14 = a1;
-        v15 = sr_vertices_50D9D8;
-      }
-      else
-      {
-        v15 = a1;
-        v14 = sr_vertices_50D9D8;
-      }
-      if (i == uNumVertices - 1)
-        v14 = pVertices;
-      a5.x = a4[i].x;
-      a5.y = a4[i].y;
-      a5.z = a4[i].z;
-      pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused);
-      //v12 = *pOutNumVertices;
-      if (*pOutNumVertices < v18)
-        break;
-      //result = a6a;
-      //v13 += 24;
-      if (++i >= uNumVertices)
-        return a7a;
+      v15 = a1;
+      v14 = sr_vertices_50D9D8;
     }
-    *pOutNumVertices = 0;
-  return true;
+    if (i == uNumVertices - 1)
+      v14 = pVertices;
+    a5.x = a4[i].x;
+    a5.y = a4[i].y;
+    a5.z = a4[i].z;
+    pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused);
+    //v12 = *pOutNumVertices;
+    if (*pOutNumVertices < v11)
+    {
+      *pOutNumVertices = 0;
+      return true;
+    }
+    //result = a6a;
+    //v13 += 24;
+    //if (++i >= uNumVertices)
+      //
+  }
+  return a7a;
 }
 
 //----- (004371C3) --------------------------------------------------------
--- a/mm7_2.cpp	Wed Jun 26 21:33:42 2013 +0400
+++ b/mm7_2.cpp	Fri Jun 28 11:34:15 2013 +0600
@@ -7583,7 +7583,7 @@
             v127 = v9;
             v126 = v124;
 LABEL_268:
-            v116 = word_4EE088_sound_ids[v2->spell_id];
+            v116 = word_4EE088_sound_ids[v2->spell_id - 1];
 LABEL_269:
             v125 = v116 + 1;
             goto LABEL_29;
--- a/stru10.cpp	Wed Jun 26 21:33:42 2013 +0400
+++ b/stru10.cpp	Fri Jun 28 11:34:15 2013 +0600
@@ -184,35 +184,29 @@
     }
   }
 
-
+  RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
+  v1.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].x;
+  v1.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].y;
+  v1.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].z;
+  memcpy(&pOutVertices[0], &v1, sizeof(RenderVertexSoft));
 
-  auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]];
-  RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
-  v1.vWorldPosition.x = (float)p1->x;
-  v1.vWorldPosition.y = (float)p1->y;
-  v1.vWorldPosition.z = (float)p1->z;
-  memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft));
-
-  auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]];
   RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24
-  v2.vWorldPosition.x = (float)p2->x;
-  v2.vWorldPosition.y = (float)p2->y;
-  v2.vWorldPosition.z = (float)p2->z;
-  memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft));
+  v2.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].x;
+  v2.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].y;
+  v2.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].z;
+  memcpy(&pOutVertices[1], &v2, sizeof(RenderVertexSoft));
 
-  auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]];
   RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24
-  v3.vWorldPosition.x = (float)p3->x;
-  v3.vWorldPosition.y = (float)p3->y;
-  v3.vWorldPosition.z = (float)p3->z;
-  memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft));
+  v3.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].x;
+  v3.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].y;
+  v3.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].z;
+  memcpy(&pOutVertices[2], &v3, sizeof(RenderVertexSoft));
 
-  auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]];
   RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24
-  v4.vWorldPosition.x = (double)p4->x;
-  v4.vWorldPosition.y = (double)p4->y;
-  v4.vWorldPosition.z = (double)p4->z;
-  memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft));
+  v4.vWorldPosition.x = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].x;
+  v4.vWorldPosition.y = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].y;
+  v4.vWorldPosition.z = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].z;
+  memcpy(&pOutVertices[3], &v4, sizeof(RenderVertexSoft));
 }
 
 
@@ -259,7 +253,7 @@
   switch (pFace->uPolygonType)
   {
     case POLYGON_VerticalWall:
-      a1.x = -pFace->pFacePlane.vNormal.y;
+      a1.x = -pFace->pFacePlane.vNormal.y;//  
       a1.y = pFace->pFacePlane.vNormal.x;
       a1.z = 0.0f;
       a1.Normalize();
@@ -300,12 +294,12 @@
   }
   if (pFace->uAttributes & 0x0200)
   {
-    face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;
+    face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;//  
     face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2;
     face_center_z = (pFaceLimits[1].vWorldPosition.z + pFaceLimits[3].vWorldPosition.z) / 2;
 
-    a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;
-    var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;
+    a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;//    
+    var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;//   
 
     if (pFace->uPolygonType == POLYGON_VerticalWall)
       a3 /= a1.x;
@@ -680,9 +674,9 @@
               (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z;
   if (fabs(_dp) < 1e-6f)
   {
-    memcpy(&v25, pOutBounding + 1, sizeof(RenderVertexSoft));
-    memcpy(pOutBounding + 1, pOutBounding + 3, sizeof(RenderVertexSoft));
-    memcpy(pOutBounding + 3, &v25, sizeof(RenderVertexSoft));
+    memcpy(&v25, &pOutBounding[1], sizeof(RenderVertexSoft));
+    memcpy(&pOutBounding[1], &pOutBounding[3], sizeof(RenderVertexSoft));
+    memcpy(&pOutBounding[3], &v25, sizeof(RenderVertexSoft));
   }
 
     //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
@@ -694,10 +688,10 @@
         v26.vWorldPosition.y = pParty->vPosition.y;
         v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel;             // frustum
 
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, pOutBounding, 0xFF0000u, 0, 0);
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, pOutBounding + 1, 0xFF00u, 0, 0);
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, pOutBounding + 2, 0xFFu, 0, 0);
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, pOutBounding + 3, 0xFFFFFFu, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0);
         bDoNotDrawPortalFrustum = true;
       }
       pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999);    // bounding
@@ -767,61 +761,62 @@
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (0049C681) --------------------------------------------------------
-bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding)
+bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *pPortalDataFrustum, RenderVertexSoft *pOutBounding)
 {
   RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
 
-  CalcPolygonLimits(pFace, pLimits);
+  CalcPolygonLimits(pFace, pLimits);//  
   //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
  //   pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997);
   if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
-    return _49C720(pOutBounding, a3) != 0;
+    return _49C720(pOutBounding, pPortalDataFrustum) != 0;
   return false;
 }
+
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (0049C720) --------------------------------------------------------
-char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *a4)
+char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
 {
-  Vec3_float_ a3; // [sp+4h] [bp-34h]@1
-  a3.x = (double)pBLVRenderParams->vPartyPos.x;
-  a3.y = (double)pBLVRenderParams->vPartyPos.y;
-  a3.z = (double)pBLVRenderParams->vPartyPos.z;
+  Vec3_float_ pRayStart; // [sp+4h] [bp-34h]@1
+  pRayStart.x = (double)pBLVRenderParams->vPartyPos.x;
+  pRayStart.y = (double)pBLVRenderParams->vPartyPos.y;
+  pRayStart.z = (double)pBLVRenderParams->vPartyPos.z;
 
-  if (FindFaceNormal(pFaceBounding,     pFaceBounding + 1, &a3, a4) &&
-      FindFaceNormal(pFaceBounding + 1, pFaceBounding + 2, &a3, a4 + 1) &&
-      FindFaceNormal(pFaceBounding + 2, pFaceBounding + 3, &a3, a4 + 2) &&
-      FindFaceNormal(pFaceBounding + 3, pFaceBounding,     &a3, a4 + 3))
+  if (FindFaceNormal(&pFaceBounding[0], &pFaceBounding[1], &pRayStart, &pPortalDataFrustum[0]) &&
+      FindFaceNormal(&pFaceBounding[1], &pFaceBounding[2], &pRayStart, &pPortalDataFrustum[1]) &&
+      FindFaceNormal(&pFaceBounding[2], &pFaceBounding[3], &pRayStart, &pPortalDataFrustum[2]) &&
+      FindFaceNormal(&pFaceBounding[3], &pFaceBounding[0], &pRayStart, &pPortalDataFrustum[3]))
     return true;
   return false;
 }
 
 //----- (0049C7C5) --------------------------------------------------------
-bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4)
+bool stru10::FindFaceNormal(RenderVertexSoft *pFaceBounding1, RenderVertexSoft *pFaceBounding2, Vec3_float_ *pRayStart, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
 {
-  Vec3_float_ v1; // [sp+4h] [bp-48h]@1
-  Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1
+  Vec3_float_ ray_dir; // [sp+4h] [bp-48h]@1
+  Vec3_float_ pRay2; // [sp+10h] [bp-3Ch]@1
 
-  v1.x = a1->vWorldPosition.x - a3->x;
-  v1.y = a1->vWorldPosition.y - a3->y;
-  v1.z = a1->vWorldPosition.z - a3->z;
-  Vec3_float_::Cross(&v1, &v2, a2->vWorldPosition.x - a1->vWorldPosition.x,
-                               a2->vWorldPosition.y - a1->vWorldPosition.y,
-                               a2->vWorldPosition.z - a1->vWorldPosition.z);
+  ray_dir.x = pFaceBounding1->vWorldPosition.x - pRayStart->x;//get ray for cmera to bounding1
+  ray_dir.y = pFaceBounding1->vWorldPosition.y - pRayStart->y;
+  ray_dir.z = pFaceBounding1->vWorldPosition.z - pRayStart->z;
+  Vec3_float_::Cross(&ray_dir, &pRay2, pFaceBounding2->vWorldPosition.x - pFaceBounding1->vWorldPosition.x,
+                               pFaceBounding2->vWorldPosition.y - pFaceBounding1->vWorldPosition.y,
+                               pFaceBounding2->vWorldPosition.z - pFaceBounding1->vWorldPosition.z);
 
-  float sqr_mag = v2.x * v2.x + v2.y * v2.y + v2.z * v2.z;
+  float sqr_mag = pRay2.x * pRay2.x + pRay2.y * pRay2.y + pRay2.z * pRay2.z;
   if (fabsf(sqr_mag) > 1e-6f)
   {
     float inv_mag = 1.0f / sqrtf(sqr_mag);
-    v2.x *= inv_mag;
-    v2.y *= inv_mag;
-    v2.z *= inv_mag;
-    //v2.Normalize();
+    pRay2.x *= inv_mag;
+    pRay2.y *= inv_mag;
+    pRay2.z *= inv_mag;
+    pRay2.Normalize();
 
-    a4->x = v2.x;
-    a4->y = v2.y;
-    a4->z = v2.z;
-    a4->dot = a3->z * v2.z + a3->y * v2.y + a3->x * v2.x;
+    pPortalDataFrustum->x = pRay2.x;
+    pPortalDataFrustum->y = pRay2.y;
+    pPortalDataFrustum->z = pRay2.z;
+    pPortalDataFrustum->dot = pRayStart->z * pRay2.z + pRayStart->y * pRay2.y + pRayStart->x * pRay2.x;
     return true;
   }
   return false;
--- a/stru10.h	Wed Jun 26 21:33:42 2013 +0400
+++ b/stru10.h	Fri Jun 28 11:34:15 2013 +0600
@@ -8,9 +8,9 @@
   stru10();
   virtual ~stru10();
   char _49C5DA(struct BLVFace *pFace, struct RenderVertexSoft *pVertices, unsigned int *pNumVertices, struct IndoorCameraD3D_Vec4 *a5, struct RenderVertexSoft *pOutBounding);
-  bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pOutBounding);
-  char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *a4);
-  bool FindFaceNormal(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct Vec3_float_ *a3, struct IndoorCameraD3D_Vec4 *a4);
+  bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum, struct RenderVertexSoft *pOutBounding);
+  char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum);
+  bool FindFaceNormal(struct RenderVertexSoft *pFaceBounding1, struct RenderVertexSoft *pFaceBounding2, struct Vec3_float_ *pRayStart, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum);
   bool FindFacePlane(struct RenderVertexSoft *face, struct Vec3_float_ *out_normal, float *out_distance);
   bool CalcFaceBounding(struct BLVFace *pFace, struct RenderVertexSoft *pFaceLimits, unsigned int uNumVertices, struct RenderVertexSoft *pOutBounding);
   void CalcPolygonLimits(struct BLVFace *pFace, struct RenderVertexSoft pOutVertices[4]);