diff Indoor.cpp @ 2205:db94443ea4e7

_44100D_should_alter_right_panel()
author Ritor1
date Wed, 05 Feb 2014 17:24:38 +0600
parents 23e7c7299ea8
children 15a327be07e2
line wrap: on
line diff
--- a/Indoor.cpp	Wed Feb 05 00:59:33 2014 +0600
+++ b/Indoor.cpp	Wed Feb 05 17:24:38 2014 +0600
@@ -4428,7 +4428,7 @@
   int v35; // eax@39
   int v36; // ebx@39
   int v37; // edx@41
-  char *v38; // edi@51
+  //char *v38; // edi@51
   ODMFace *odm_face; // esi@54
   int v40; // ebx@60
   int v41; // eax@61
@@ -4493,8 +4493,8 @@
   int v101; // [sp-8h] [bp-84h]@126
   int v102; // [sp-4h] [bp-80h]@88
   int v103; // [sp-4h] [bp-80h]@126
-  int v104; // [sp+Ch] [bp-70h]@13
-  int v105; // [sp+Ch] [bp-70h]@48
+  //int v104; // [sp+Ch] [bp-70h]@13
+  //int v105; // [sp+Ch] [bp-70h]@48
   int v106; // [sp+10h] [bp-6Ch]@18
   int v107; // [sp+10h] [bp-6Ch]@98
   int v108; // [sp+10h] [bp-6Ch]@104
@@ -4546,11 +4546,11 @@
   int sDeptha; // [sp+58h] [bp-24h]@52
   int sDepthb; // [sp+58h] [bp-24h]@90
   char *a5; // [sp+5Ch] [bp-20h]@16
-  char *a5a; // [sp+5Ch] [bp-20h]@51
+  //char *a5a; // [sp+5Ch] [bp-20h]@51
   signed int a5b; // [sp+5Ch] [bp-20h]@83
   signed int a5c; // [sp+5Ch] [bp-20h]@121
-  signed int v160; // [sp+60h] [bp-1Ch]@12
-  signed int v161; // [sp+60h] [bp-1Ch]@47
+  //signed int v160; // [sp+60h] [bp-1Ch]@12
+  //signed int v161; // [sp+60h] [bp-1Ch]@47
   int v162; // [sp+60h] [bp-1Ch]@128
   int v163; // [sp+64h] [bp-18h]@2
   int outx; // [sp+68h] [bp-14h]@2
@@ -4579,7 +4579,7 @@
   v97.x = x;
   v97.y = z;
   v113 = 0;
-  a4_8 = v4;
+  a4_8 = stru_5C6E00->Atan2(v.x - x, v.y - z);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
     Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
@@ -4931,95 +4931,68 @@
       v133 = v163;
       v129 = outz;
     }
-    v160 = 0;
-    if ( (signed int)pOutdoor->uNumBModels > 0 )
+    for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++)
     {
-      v104 = 0;
-      while ( 1 )
+      if ( sub_4088E9(pOut.x, pOut.y, outx, outy, pOutdoor->pBModels[model_id].vPosition.x, pOutdoor->pBModels[model_id].vPosition.y)
+           <= pOutdoor->pBModels[model_id].sBoundingRadius + 128 )
       {
-        v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
-        a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
-        if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
+        for ( uint face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; ++face_id )
         {
-          sDepth = 0;
-          if ( *((int *)v15 + 2) > 0 )
-            break;
-        }
-LABEL_36:
-        ++v160;
-        ++v104;
-        if ( v160 >= (signed int)pOutdoor->uNumBModels )
-          goto LABEL_37;
-        v14 = outy;
-        v13 = pOut.x;
-      }
-      v106 = 0;
-      while ( 1 )
-     {
-       odm_face = (ODMFace *)(v106 + *((int *)a5 + 4));
-       if ( v149 > odm_face->pBoundingBox.x2
-         || v145 < odm_face->pBoundingBox.x1
-         || v141 > odm_face->pBoundingBox.y2
-         || v137 < odm_face->pBoundingBox.y1
-         || v133 > odm_face->pBoundingBox.z2
-         || v129 < odm_face->pBoundingBox.z1
-         || (v17 = fixpoint_mul(v125, odm_face->pFacePlane.vNormal.x),
-             v18 = fixpoint_mul(v121, odm_face->pFacePlane.vNormal.y),
-             v19 = fixpoint_mul(v117, odm_face->pFacePlane.vNormal.z),
-             v20 = v17 + v18 + v19 == 0,
-             v21 = v17 + v18 + v19,
-             v109 = v17 + v18 + v19,
-             v20) )
-         goto LABEL_33;
-        //v22 = pOut.y * odm_face->pFacePlane.vNormal.y;
-        v23 = -(odm_face->pFacePlane.dist + pOut.y * odm_face->pFacePlane.vNormal.y
-                                          + outz * odm_face->pFacePlane.vNormal.z
-                                          + pOut.x * odm_face->pFacePlane.vNormal.x);
-        if ( v21 <= 0 )
-        {
-          if ( odm_face->pFacePlane.dist + pOut.y * odm_face->pFacePlane.vNormal.y 
-                                         + outz * odm_face->pFacePlane.vNormal.z 
-                                         + pOut.x * odm_face->pFacePlane.vNormal.x < 0 )
-            goto LABEL_33;
-        }
-        else
-        {
-          if ( odm_face->pFacePlane.dist + pOut.y * odm_face->pFacePlane.vNormal.y
-                                         + outz * odm_face->pFacePlane.vNormal.z 
-                                         + pOut.x * odm_face->pFacePlane.vNormal.x > 0 )
-            goto LABEL_33;
-        }
-        v24 = abs(-(odm_face->pFacePlane.dist + pOut.y * odm_face->pFacePlane.vNormal.y 
-                                              + outz * odm_face->pFacePlane.vNormal.z 
-                                              + pOut.x * odm_face->pFacePlane.vNormal.x)) >> 14;
-        if ( v24 <= abs(v21) )
-        {
-          //LODWORD(v25) = v23 << 16;
-          //HIDWORD(v25) = v23 >> 16;
-          //v26 = v25 / v109;
-          //v110 = v25 / v109;
-          v110 = fixpoint_div(v23, v109);
-          if ( v110 >= 0 )
+          odm_face = &pOutdoor->pBModels[model_id].pFaces[face_id];
+          v17 = fixpoint_mul(v125, odm_face->pFacePlane.vNormal.x);
+          v18 = fixpoint_mul(v121, odm_face->pFacePlane.vNormal.y);
+          v19 = fixpoint_mul(v117, odm_face->pFacePlane.vNormal.z);
+          v20 = v17 + v18 + v19;
+          v21 = v17 + v18 + v19;
+          v109 = v17 + v18 + v19;
+          if ( v149 > odm_face->pBoundingBox.x2 || v145 < odm_face->pBoundingBox.x1
+            || v141 > odm_face->pBoundingBox.y2 || v137 < odm_face->pBoundingBox.y1
+            || v133 > odm_face->pBoundingBox.z2 || v129 < odm_face->pBoundingBox.z1
+            || !v20 )
+            continue;
+          v23 = -(odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                            + pOut.y * odm_face->pFacePlane.vNormal.y
+                                            + outz * odm_face->pFacePlane.vNormal.z);
+          if ( v21 <= 0 )
+          {
+            if ( odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                           + pOut.y * odm_face->pFacePlane.vNormal.y 
+                                           + outz * odm_face->pFacePlane.vNormal.z < 0 )
+              continue;
+          }
+          else
           {
-            if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(v110, v125) + 32768) >> 16),
-                            pOut.y + ((signed int)(fixpoint_mul(v110, v121) + 32768) >> 16),
-                              outz + ((signed int)(fixpoint_mul(v110, v117) + 32768) >> 16),
-                   odm_face,
-                   (BSPVertexBuffer *)a5) )
+            if ( odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                           + pOut.y * odm_face->pFacePlane.vNormal.y
+                                           + outz * odm_face->pFacePlane.vNormal.z > 0 )
+              continue;
+          }
+          v24 = abs(-(odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                                + pOut.y * odm_face->pFacePlane.vNormal.y 
+                                                + outz * odm_face->pFacePlane.vNormal.z)) >> 14;
+          if ( v24 <= abs(v21) )
+          {
+            //LODWORD(v25) = v23 << 16;
+            //HIDWORD(v25) = v23 >> 16;
+            //v26 = v25 / v109;
+            //v110 = v25 / v109;
+            v110 = fixpoint_div(v23, v109);
+            if ( v110 >= 0 )
             {
-              v114 = 1;
-              goto LABEL_36;
+              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(v110, v125) + 32768) >> 16),
+                              pOut.y + ((signed int)(fixpoint_mul(v110, v121) + 32768) >> 16),
+                                outz + ((signed int)(fixpoint_mul(v110, v117) + 32768) >> 16),
+                              odm_face,
+                              &pOutdoor->pBModels[model_id].pVertices) )
+              {
+                v114 = 1;
+                break;
+              }
             }
           }
         }
-LABEL_33:
-        ++sDepth;
-        v106 += 308;
-        if ( sDepth >= *((int *)a5 + 2) )
-          goto LABEL_36;
       }
     }
-LABEL_37:
     v27.z = y;
     v27.x = x;
     v27.y = z;
@@ -5066,84 +5039,66 @@
       v134 = v163;
       v130 = outz;
     }
-    //v161 = 0;
-    if ( (signed int)pOutdoor->uNumBModels > 0 )
+
+    for ( uint model_id = 0; model_id < (signed int)pOutdoor->uNumBModels; ++model_id )
     {
-      v105 = 0;
-      //while ( 1 )
-      for ( v161 = 0; v161 < (signed int)pOutdoor->uNumBModels; ++v161 )
+      if ( sub_4088E9(pOut.x, pOut.y, outx, outy, pOutdoor->pBModels[model_id].vPosition.x, pOutdoor->pBModels[model_id].vPosition.y)
+           <= pOutdoor->pBModels[model_id].sBoundingRadius + 128 )
       {
-        v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
-        a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
-        if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
+        for ( uint face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; ++face_id )
         {
-         
-          if ( *((int *)v38 + 2) > 0 )
-		  {
-            //v_8 = 0;
-            //while ( 1 )
-			for ( sDeptha = 0; sDeptha < *((int *)a5a + 2); ++sDeptha )
+          odm_face = &pOutdoor->pBModels[model_id].pFaces[face_id];
+          ya = fixpoint_mul(v126, odm_face->pFacePlane.vNormal.x);
+          ve = fixpoint_mul(v122, odm_face->pFacePlane.vNormal.y);
+          v_4 = fixpoint_mul(v118, odm_face->pFacePlane.vNormal.z);
+          v20 = ya + ve + v_4;
+          v40 = ya + ve + v_4;
+          va = ya + ve + v_4;
+          if ( v150 > odm_face->pBoundingBox.x2 || v146 < odm_face->pBoundingBox.x1
+            || v142 > odm_face->pBoundingBox.y2 || v138 < odm_face->pBoundingBox.y1
+            || v134 > odm_face->pBoundingBox.z2 || v130 < odm_face->pBoundingBox.z1
+            || !v20 )
+            continue;
+          v42 = -(odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                            + pOut.y * odm_face->pFacePlane.vNormal.y
+                                            + outz * odm_face->pFacePlane.vNormal.z);
+          if ( v40 <= 0 )
+          {
+            if ( odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                           + pOut.y * odm_face->pFacePlane.vNormal.y 
+                                           + outz * odm_face->pFacePlane.vNormal.z  < 0 )
+              continue;
+          }
+          else
+          {
+            if ( odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                           + pOut.y * odm_face->pFacePlane.vNormal.y 
+                                           + outz * odm_face->pFacePlane.vNormal.z  > 0 )
+              continue;
+          }
+          v_4a = abs(-(odm_face->pFacePlane.dist + pOut.x * odm_face->pFacePlane.vNormal.x
+                                                 + pOut.y * odm_face->pFacePlane.vNormal.y 
+                                                 + outz * odm_face->pFacePlane.vNormal.z )) >> 14;
+          if ( v_4a <= abs(v40) )
+          {
+            //LODWORD(v43) = v42 << 16;
+            //HIDWORD(v43) = v42 >> 16;
+            //vb = v43 / va;
+            vb = fixpoint_div(v42, va);
+            if ( vb >= 0 )
             {
-              odm_face = &pOutdoor->pBModels[v105].pFaces[sDeptha];
-              if ( v150 > odm_face->pBoundingBox.x2
-                || v146 < odm_face->pBoundingBox.x1
-                || v142 > odm_face->pBoundingBox.y2
-                || v138 < odm_face->pBoundingBox.y1
-                || v134 > odm_face->pBoundingBox.z2
-                || v130 < odm_face->pBoundingBox.z1
-                || (ya = fixpoint_mul(v126, odm_face->pFacePlane.vNormal.x),
-                    ve = fixpoint_mul(v122, odm_face->pFacePlane.vNormal.y),
-                    v_4 = fixpoint_mul(v118, odm_face->pFacePlane.vNormal.z),
-                    v20 = ya + ve + v_4 == 0,
-                    v40 = ya + ve + v_4,
-                    va = ya + ve + v_4,
-                    v20) )
-                goto LABEL_68;
-              v41 = pOut.y * odm_face->pFacePlane.vNormal.y;
-              v42 = -(odm_face->pFacePlane.dist + v41 + outz * odm_face->pFacePlane.vNormal.z + pOut.x * odm_face->pFacePlane.vNormal.x);
-              if ( v40 <= 0 )
+              if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(vb, v126) + 32768) >> 16),
+                              pOut.y + ((signed int)(fixpoint_mul(vb, v122) + 32768) >> 16),
+                                outz + ((signed int)(fixpoint_mul(vb, v118) + 32768) >> 16),
+                              odm_face,
+                              &pOutdoor->pBModels[model_id].pVertices) )
               {
-                if ( odm_face->pFacePlane.dist + v41 + outz * odm_face->pFacePlane.vNormal.z + pOut.x * odm_face->pFacePlane.vNormal.x < 0 )
-                  goto LABEL_68;
-              }
-              else
-              {
-                if ( odm_face->pFacePlane.dist + v41 + outz * odm_face->pFacePlane.vNormal.z + pOut.x * odm_face->pFacePlane.vNormal.x > 0 )
-                  goto LABEL_68;
-              }
-              v_4a = abs(-(odm_face->pFacePlane.dist + v41 + outz * odm_face->pFacePlane.vNormal.z + pOut.x * odm_face->pFacePlane.vNormal.x)) >> 14;
-              if ( v_4a <= abs(v40) )
-              {
-                //LODWORD(v43) = v42 << 16;
-                //HIDWORD(v43) = v42 >> 16;
-                //vb = v43 / va;
-                vb = fixpoint_div(v42, va);
-                if ( vb >= 0 )
-                {
-                  if ( sub_4077F1(pOut.x + ((signed int)(fixpoint_mul(vb, v126) + 32768) >> 16),
-                                  pOut.y + ((signed int)(fixpoint_mul(vb, v122) + 32768) >> 16),
-                                    outz + ((signed int)(fixpoint_mul(vb, v118) + 32768) >> 16),
-                                  odm_face,
-                                  (BSPVertexBuffer *)a5a) )
-                  {
-                    v113 = 1;
-                    goto LABEL_71;
-                  }
-                }
-              }
-LABEL_68:
-			  ;
-              //++sDeptha;
-              //v_8 += 308;
-              //if ( sDeptha >= *((int *)a5a + 2) )
-                //goto LABEL_71;
+                v113 = 1;
+                break;
+               }
             }
-		  }
+          }
         }
-LABEL_71:
-        ++v105;
-        v37 = outy;
-        v36 = pOut.x;
       }
     }