diff Indoor.cpp @ 2383:342b73a61a60

sub_407A1C - refactoring min-max
author zipi
date Sun, 22 Jun 2014 14:39:50 +0100
parents 8c00bd4573a8
children f784ffc9a758
line wrap: on
line diff
--- a/Indoor.cpp	Sun Jun 22 13:58:46 2014 +0100
+++ b/Indoor.cpp	Sun Jun 22 14:39:50 2014 +0100
@@ -4143,15 +4143,15 @@
 {
   unsigned int v4; // esi@1
   //Vec3_int_ v5; // ST08_12@2
-  int v6; // edi@2
-  int v7; // ebx@2
-  int v8; // esi@2
+  int dist_y; // edi@2
+  int dist_z; // ebx@2
+  int dist_x; // esi@2
   signed int v9; // ecx@2
   int v10; // eax@2
-  int v11; // ecx@4
+//  int v11; // ecx@4
   int v12; // eax@4
-  int v13; // ebx@4
-  int v14; // edx@6
+//  int v13; // ebx@4
+//  int v14; // edx@6
 //  char *v15; // edi@16
 //  ODMFace *v16; // esi@19
   int v17; // ST34_4@25
@@ -4174,7 +4174,7 @@
   int v34; // ecx@39
   int v35; // eax@39
   int v36; // ebx@39
-  int v37; // edx@41
+  //int v37; // edx@41
   //char *v38; // edi@51
   ODMFace *odm_face; // esi@54
   int v40; // ebx@60
@@ -4191,11 +4191,11 @@
   int v51; // edx@75
   int v52; // ecx@75
   int v53; // eax@75
-  int v54; // ebx@75
-  int v55; // edi@77
-  int v56; // ecx@77
-  int v57; // eax@81
-  int v58; // esi@81
+  //int v54; // ebx@75
+  //int v55; // edi@77
+  //int v56; // ecx@77
+  //int v57; // eax@81
+  //int v58; // esi@81
   int v59; // eax@90
   //BLVSector *v60; // edx@90
 //  int v61; // ecx@90
@@ -4219,11 +4219,11 @@
   int v79; // edx@113
   int v80; // ecx@113
   int v81; // eax@113
-  int v82; // ebx@113
-  int v83; // edi@115
-  int v84; // ecx@115
-  int v85; // eax@119
-  int v86; // esi@119
+  //int v82; // ebx@113
+  //int v83; // edi@115
+  //int v84; // ecx@115
+  //int v85; // eax@119
+  //int v86; // esi@119
   int v87; // ecx@128
 //  BLVSector *v88; // eax@128
 //  int v89; // ecx@128
@@ -4253,7 +4253,7 @@
   signed int v114; // [sp+24h] [bp-58h]@1
   //unsigned __int64 a4; // [sp+28h] [bp-54h]@1
   unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
-  int v117; // [sp+34h] [bp-48h]@4
+//  int v117; // [sp+34h] [bp-48h]@4
   int v118; // [sp+34h] [bp-48h]@39
   int v119; // [sp+34h] [bp-48h]@75
   int v120; // [sp+34h] [bp-48h]@113
@@ -4348,9 +4348,11 @@
     v143 = v48 * v50;
     v52 = v46 * v50;
     v53 = v47 * v50;
-    v54 = sX;
+    //v54 = sX;
     v147 = v52;
     v151 = v53;
+
+	/*
     v119 = sX;
     if ( sX < outx )
       v123 = outx;
@@ -4359,9 +4361,10 @@
       v119 = outx;
       v123 = sX;
     }
-    v55 = sY;
-    v56 = outy;
-    v127 = sY;
+    //v55 = sY;
+    //v56 = outy;
+    
+	v127 = sY;
     if ( sY < outy )
       v131 = outy;
     else
@@ -4369,9 +4372,11 @@
       v127 = outy;
       v131 = sY;
     }
-    v57 = outz;
-    v58 = sZ;
-    v135 = sZ;
+    
+	//v57 = outz;
+    //v58 = sZ;
+    
+	v135 = sZ;
     if ( sZ < outz )
       v139 = outz;
     else
@@ -4379,7 +4384,17 @@
       v135 = outz;
       v139 = sZ;
     }
-    
+    */
+
+	v123 = max(outx, sX);
+	v119 = min(outx, sX);
+
+	v131 = max(outy, sY);
+	v127 = min(outy, sY);
+
+	v139 = max(outz, sZ);
+	v135 = min(outz, sZ);
+
     //while ( !v114 )
     for ( a5b = 0; a5b < 2; a5b++ )
     {
@@ -4457,7 +4472,8 @@
         }
       }
     }
-    v72.z = y;
+    
+	v72.z = y;
     v72.x = x;
     v72.y = z;
     Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &sX, &sY, &sZ);
@@ -4476,9 +4492,11 @@
     v144 = v76 * v78;
     v80 = v74 * v78;
     v81 = v75 * v78;
-    v82 = sX;
+    //v82 = sX;
     v148 = v80;
     v152 = v81;
+
+	/*
     v120 = sX;
     if ( sX < outx )
       v124 = outx;
@@ -4487,9 +4505,11 @@
       v120 = outx;
       v124 = sX;
     }
-    v83 = sY;
-    v84 = outy;
-    v128 = sY;
+
+    //v83 = sY;
+    //v84 = outy;
+    
+	v128 = sY;
     if ( sY < outy )
       v132 = outy;
     else
@@ -4497,9 +4517,11 @@
       v128 = outy;
       v132 = sY;
     }
-    v85 = outz;
-    v86 = sZ;
-    v136 = sZ;
+    
+	//v85 = outz;
+    //v86 = sZ;
+    
+	v136 = sZ;
     if ( sZ < outz )
       v140 = outz;
     else
@@ -4507,7 +4529,18 @@
       v136 = outz;
       v140 = sZ;
     }
-    //while ( 1 )
+    */
+
+	v120 = max(outx, sX);
+	v124 = min(outx, sX);
+
+	v132 = max(outy, sY);
+	v128 = min(outy, sY);
+
+	v140 = max(outz, sZ);
+	v136 = min(outz, sZ);
+
+	//while ( 1 )
     for ( a5c = 0; a5c < 2; a5c++ )
     {
       if ( v113 )
@@ -4598,20 +4631,22 @@
     //v5.x = v.x;
     //v5.y = v.y;
     Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v, &outx, &outy, &outz);
-    v6 = outy - sY;
-    v7 = outz - sZ;
-    v8 = outx - sX;
-    v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7);
+    dist_y = outy - sY;
+    dist_z = outz - sZ;
+    dist_x = outx - sX;
+    v9 = integer_sqrt(dist_x* dist_x+ dist_y* dist_y+ dist_z* dist_z);
     v10 = 65536;
     if ( v9 )
       v10 = 65536 / v9;
-    v125 = v8 * v10;
-    v11 = v10;
-    v12 = v7 * v10;
-    v13 = sX;
-    v117 = v12;
-    v121 = v6 * v11;
-    v149 = sX;
+    v125 = dist_x* v10;
+    //v11 = v10;
+    v12 = dist_z* v10;
+	//v13 = sX;
+    //v117 = v12;
+    v121 = dist_y* v10;
+
+	/*
+	v149 = sX;
     if ( sX < outx )
       v145 = outx;
     else
@@ -4619,24 +4654,37 @@
       v149 = outx;
       v145 = sX;
     }
-    v14 = outy;
-    v141 = sY;
-    if ( sY < outy )
-      v137 = outy;
-    else
-    {
-      v141 = outy;
-      v137 = sY;
-    }
-    v133 = sZ;
-    if ( sZ < outz )
-      v129 = outz;
-    else
-    {
-      v133 = outz;
-      v129 = sZ;
-    }
-    for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++)
+
+	//v14 = outy;
+	v141 = sY;
+	if (sY < outy)
+		v137 = outy;
+	else
+	{
+		v141 = outy;
+		v137 = sY;
+	}
+
+	v133 = sZ;
+	if (sZ < outz)
+		v129 = outz;
+	else
+	{
+		v133 = outz;
+		v129 = sZ;
+	}
+	*/
+
+	v145 = max(outx, sX);
+	v149 = min(outx, sX);
+
+	v137 = max(outy, sY);
+	v141 = min(outy, sY);
+
+	v129 = max(outz, sZ);
+	v133 = min(outz, sZ);
+
+	for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++)
     {
       if ( sub_4088E9(sX, sY, outx, outy, pOutdoor->pBModels[model_id].vPosition.x, pOutdoor->pBModels[model_id].vPosition.y)
            <= pOutdoor->pBModels[model_id].sBoundingRadius + 128 )
@@ -4646,7 +4694,7 @@
           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);
+          v19 = fixpoint_mul(v12, odm_face->pFacePlane.vNormal.z);
           v20 = v17 + v18 + v19;
           v21 = v17 + v18 + v19;
           v109 = v17 + v18 + v19;
@@ -4686,7 +4734,7 @@
             {
               if ( sub_4077F1(sX + ((signed int)(fixpoint_mul(v110, v125) + 0x8000) >> 16),
                               sY + ((signed int)(fixpoint_mul(v110, v121) + 0x8000) >> 16),
-                                sZ + ((signed int)(fixpoint_mul(v110, v117) + 0x8000) >> 16),
+                                sZ + ((signed int)(fixpoint_mul(v110, v12) + 0x8000) >> 16),
                               odm_face,
                               &pOutdoor->pBModels[model_id].pVertices) )
               {
@@ -4698,7 +4746,8 @@
         }
       }
     }
-    v27.z = y;
+    
+	v27.z = y;
     v27.x = x;
     v27.y = z;
     Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &sX, &sY, &sZ);
@@ -4719,7 +4768,9 @@
     v36 = sX;
     v118 = v35;
     v122 = v29 * v34;
-    v150 = sX;
+    
+	/*
+	v150 = sX;
     if ( sX < outx )
       v146 = outx;
     else
@@ -4727,8 +4778,10 @@
       v150 = outx;
       v146 = sX;
     }
-    v37 = outy;
-    v142 = sY;
+    	
+	//v37 = outy;
+    
+	v142 = sY;
     if ( sY < outy )
       v138 = outy;
     else
@@ -4736,7 +4789,8 @@
       v142 = outy;
       v138 = sY;
     }
-    v134 = sZ;
+    
+	v134 = sZ;
     if ( sZ < outz )
       v130 = outz;
     else
@@ -4744,6 +4798,16 @@
       v134 = outz;
       v130 = sZ;
     }
+	*/
+
+	v146 = max(outx, sX);
+	v150 = min(outx, sX);
+
+	v138 = max(outy, sY);
+	v142 = min(outy, sY);
+
+	v130 = max(outz, sZ);
+	v134 = min(outz, sZ);
 
     for ( uint model_id = 0; model_id < (signed int)pOutdoor->uNumBModels; ++model_id )
     {