Dimitri_UA

prj_sum: gta_sa.exe | CShadows::CastShadowEntity

Jun 4th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 32.38 KB | None | 0 0
  1. CColModel *__cdecl CShadows::CastShadowEntity(CEntity *entity, int a2, int a3, int a4, int a5, RwV3D *a6, float a7, float a8, float a9, float a10, __int16 a11, char a12, char a13, char a14, float a15, float a16, int a17, char *cBuf, int a19)
  2. {
  3.   int v19; // eax@1
  4.   CColModel *result; // eax@7
  5.   ColDataHeader *_pColData; // ebp@7
  6.   CMatrix *m1; // edi@11
  7.   CMatrix *m2; // eax@13
  8.   int v24; // edi@15
  9.   int v25; // eax@17
  10.   int v26; // edi@19
  11.   int v27; // eax@21
  12.   CMatrix *v28; // edi@23
  13.   CMatrix *v29; // eax@25
  14.   RwV3D *v30; // ecx@25
  15.   RwV3D *v31; // ecx@27
  16.   long double v32; // fst7@27
  17.   CMatrix *v33; // edi@31
  18.   CMatrix *v34; // eax@33
  19.   CMatrix *v35; // edi@35
  20.   CMatrix *v36; // eax@37
  21.   long double v37; // fst7@37
  22.   long double v38; // fst6@37
  23.   long double v39; // t0@37
  24.   long double v40; // fst6@37
  25.   RwV3D *v41; // eax@38
  26.   long double v42; // fst7@44
  27.   long double v43; // fst7@53
  28.   long double v44; // fst7@62
  29.   long double v45; // fst7@71
  30.   int v46; // ecx@83
  31.   int numFaces; // eax@87
  32.   float v48; // edx@87
  33.   int v49; // edx@90
  34.   int v50; // esi@91
  35.   int v51; // ecx@91
  36.   int v52; // esi@91
  37.   int v53; // edx@109
  38.   signed int v54; // ecx@109
  39.   signed __int16 v55; // bx@109
  40.   int v56; // ebp@109
  41.   int *v57; // edi@109
  42.   int v58; // esi@109
  43.   long double v59; // fst6@109
  44.   long double v60; // fst7@109
  45.   long double v61; // fst5@110
  46.   long double v62; // fst5@114
  47.   long double v63; // fst5@114
  48.   long double v64; // fst5@118
  49.   long double v65; // fst5@118
  50.   long double v66; // fst5@121
  51.   int v67; // eax@125
  52.   long double v68; // fst5@125
  53.   long double v69; // fst5@125
  54.   int v70; // eax@126
  55.   signed __int16 v71; // bx@126
  56.   int v72; // ebp@126
  57.   int v73; // edx@127
  58.   int v74; // ecx@127
  59.   int v75; // esi@127
  60.   long double v76; // fst5@128
  61.   long double v77; // fst5@132
  62.   long double v78; // fst5@132
  63.   long double v79; // fst5@136
  64.   long double v80; // fst5@136
  65.   long double v81; // fst5@139
  66.   int v82; // eax@143
  67.   int v83; // ecx@143
  68.   long double v84; // fst5@143
  69.   long double v85; // fst5@143
  70.   int v86; // ecx@144
  71.   signed __int16 v87; // bx@144
  72.   signed int v88; // ebp@144
  73.   int v89; // edx@145
  74.   int v90; // ecx@145
  75.   int v91; // esi@145
  76.   long double v92; // fst5@146
  77.   long double v93; // fst5@150
  78.   long double v94; // fst5@150
  79.   long double v95; // fst5@154
  80.   long double v96; // fst5@154
  81.   long double v97; // fst5@158
  82.   int v98; // eax@162
  83.   long double v99; // fst5@162
  84.   int v100; // ecx@162
  85.   long double v101; // fst7@162
  86.   long double v102; // fst7@162
  87.   signed int v103; // ecx@164
  88.   long double v104; // fst7@164
  89.   int v105; // eax@164
  90.   int v106; // edx@164
  91.   int v107; // eax@164
  92.   int v108; // ecx@164
  93.   signed int v109; // edx@164
  94.   long double v110; // fst7@164
  95.   long double v111; // fst7@164
  96.   int v112; // eax@165
  97.   signed int v113; // edx@165
  98.   long double v114; // fst6@165
  99.   long double v115; // fst5@166
  100.   float *v116; // eax@168
  101.   int v117; // edx@168
  102.   long double v118; // fst7@168
  103.   int v119; // esi@171
  104.   int v120; // ebx@174
  105.   int v121; // eax@176
  106.   int v122; // ecx@176
  107.   int v123; // ebx@180
  108.   int v124; // eax@182
  109.   int v125; // ecx@182
  110.   int v126; // eax@184
  111.   int v127; // eax@185
  112.   long double v128; // fst7@187
  113.   char v129; // zf@187
  114.   int v130; // ebx@189
  115.   int v131; // edi@191
  116.   int v132; // esi@191
  117.   unsigned __int64 v133; // qax@192
  118.   signed int v134; // eax@194
  119.   int v135; // ecx@194
  120.   int v136; // edi@194
  121.   int v137; // ebx@204
  122.   int v138; // ebx@204
  123.   signed int v139; // esi@204
  124.   char v140; // al@204
  125.   int pVertices; // eax@205
  126.   int v142; // edx@205
  127.   int v143; // ecx@205
  128.   signed int v144; // edi@205
  129.   long double v145; // fst7@206
  130.   long double v146; // fst7@206
  131.   long double v147; // fst7@206
  132.   long double v148; // fst7@206
  133.   int v149; // ebx@206
  134.   long double v150; // fst7@206
  135.   long double v151; // fst7@206
  136.   int v152; // eax@209
  137.   int v153; // edx@209
  138.   int v154; // ecx@209
  139.   int v155; // ebp@209
  140.   long double v156; // fst7@210
  141.   int v157; // esi@210
  142.   long double v158; // fst7@210
  143.   int i; // ecx@212
  144.   unsigned int v160; // ecx@212
  145.   int v161; // edi@212
  146.   __int16 *v162; // esi@212
  147.   int v163; // edi@212
  148.   unsigned __int8 v164; // cf@212
  149.   char v165[7]; // [sp+11h] [bp-73h]@110
  150.   float v166; // [sp+18h] [bp-6Ch]@47
  151.   float v167; // [sp+1Ch] [bp-68h]@27
  152.   float v168; // [sp+20h] [bp-64h]@25
  153.   float v169; // [sp+24h] [bp-60h]@21
  154.   ColDataHeader *pColData; // [sp+28h] [bp-5Ch]@7
  155.   float v171; // [sp+2Ch] [bp-58h]@17
  156.   int v172; // [sp+30h] [bp-54h]@13
  157.   float v173; // [sp+34h] [bp-50h]@33
  158.   float v174; // [sp+38h] [bp-4Ch]@29
  159.   int v175; // [sp+3Ch] [bp-48h]@90
  160.   int v176; // [sp+40h] [bp-44h]@89
  161.   CColModel *v177; // [sp+44h] [bp-40h]@79
  162.   int v178; // [sp+48h] [bp-3Ch]@90
  163.   float v179; // [sp+4Ch] [bp-38h]@172
  164.   int v180; // [sp+50h] [bp-34h]@91
  165.   float v181; // [sp+54h] [bp-30h]@91
  166.   float v182; // [sp+58h] [bp-2Ch]@97
  167.   float v183; // [sp+5Ch] [bp-28h]@103
  168.   float v184; // [sp+60h] [bp-24h]@91
  169.   float v185; // [sp+64h] [bp-20h]@98
  170.   float v186; // [sp+68h] [bp-1Ch]@104
  171.   float v187; // [sp+6Ch] [bp-18h]@91
  172.   float v188; // [sp+70h] [bp-14h]@99
  173.   float v189; // [sp+74h] [bp-10h]@105
  174.   float v190; // [sp+78h] [bp-Ch]@164
  175.   float v191; // [sp+7Ch] [bp-8h]@164
  176.  
  177.   v19 = dword_C4B8C8;
  178.   if ( !(dword_C4B8C8 & 1) )
  179.   {
  180.     v19 = dword_C4B8C8 | 1;
  181.     dword_C4B8C8 |= 1u;
  182.   }
  183.   if ( !(v19 & 2) )
  184.   {
  185.     v19 |= 2u;
  186.     dword_C4B8C8 = v19;
  187.   }
  188.   if ( !(v19 & 4) )
  189.     dword_C4B8C8 = v19 | 4;
  190.   result = modelPtrs[entity->m_wModelIndex]->m_pColModel;
  191.   pColData = result->m_pColData;
  192.   _pColData = pColData;
  193.   if ( pColData && pColData->numberOfFaces )
  194.   {
  195.     sub_418580(result);
  196.     if ( !entity->__parent.m_pCoords )
  197.     {
  198.       CPlaceable__allocateL1XYZ(entity);
  199.       Placement__toMatrix(entity->__parent.m_pCoords);
  200.     }
  201.     m1 = entity->__parent.m_pCoords;
  202.     if ( !m1 )
  203.     {
  204.       CPlaceable__allocateL1XYZ(entity);
  205.       Placement__toMatrix(entity->__parent.m_pCoords);
  206.     }
  207.     m2 = entity->__parent.m_pCoords;
  208.     *&v172 = a8 * m2->matrix.right.y + a7 * m1->matrix.right.x;
  209.     if ( !m2 )
  210.     {
  211.       CPlaceable__allocateL1XYZ(entity);
  212.       Placement__toMatrix(entity->__parent.m_pCoords);
  213.     }
  214.     v24 = entity->__parent.m_pCoords;
  215.     if ( !entity->__parent.m_pCoords )
  216.     {
  217.       CPlaceable__allocateL1XYZ(entity);
  218.       Placement__toMatrix(entity->__parent.m_pCoords);
  219.     }
  220.     v25 = entity->__parent.m_pCoords;
  221.     v171 = a7 * *(v24 + 16) + a8 * *(v25 + 20);
  222.     if ( !v25 )
  223.     {
  224.       CPlaceable__allocateL1XYZ(entity);
  225.       Placement__toMatrix(entity->__parent.m_pCoords);
  226.     }
  227.     v26 = entity->__parent.m_pCoords;
  228.     if ( !entity->__parent.m_pCoords )
  229.     {
  230.       CPlaceable__allocateL1XYZ(entity);
  231.       Placement__toMatrix(entity->__parent.m_pCoords);
  232.     }
  233.     v27 = entity->__parent.m_pCoords;
  234.     v169 = a10 * *(v27 + 4) + a9 * *v26;
  235.     if ( !v27 )
  236.     {
  237.       CPlaceable__allocateL1XYZ(entity);
  238.       Placement__toMatrix(entity->__parent.m_pCoords);
  239.     }
  240.     v28 = entity->__parent.m_pCoords;
  241.     if ( !entity->__parent.m_pCoords )
  242.     {
  243.       CPlaceable__allocateL1XYZ(entity);
  244.       Placement__toMatrix(entity->__parent.m_pCoords);
  245.     }
  246.     v29 = entity->__parent.m_pCoords;
  247.     v30 = &v29->matrix.pos;
  248.     v168 = a9 * v28->matrix.top.x + a10 * v29->matrix.top.y;
  249.     if ( !v29 )
  250.       v30 = &entity->__parent.placement.pos;
  251.     v32 = a6->x - v30->x;
  252.     v31 = &v29->matrix.pos;
  253.     v167 = v32;
  254.     if ( !v29 )
  255.       v31 = &entity->__parent.placement.pos;
  256.     v174 = a6->y - v31->y;
  257.     if ( !v29 )
  258.     {
  259.       CPlaceable__allocateL1XYZ(entity);
  260.       Placement__toMatrix(entity->__parent.m_pCoords);
  261.     }
  262.     v33 = entity->__parent.m_pCoords;
  263.     if ( !entity->__parent.m_pCoords )
  264.     {
  265.       CPlaceable__allocateL1XYZ(entity);
  266.       Placement__toMatrix(entity->__parent.m_pCoords);
  267.     }
  268.     v34 = entity->__parent.m_pCoords;
  269.     v173 = v174 * v34->matrix.right.y + v167 * v33->matrix.right.x;
  270.     if ( !v34 )
  271.     {
  272.       CPlaceable__allocateL1XYZ(entity);
  273.       Placement__toMatrix(entity->__parent.m_pCoords);
  274.     }
  275.     v35 = entity->__parent.m_pCoords;
  276.     if ( !v35 )
  277.     {
  278.       CPlaceable__allocateL1XYZ(entity);
  279.       Placement__toMatrix(entity->__parent.m_pCoords);
  280.     }
  281.     v37 = v174 * *(entity->__parent.m_pCoords + 20) + v167 * v35->matrix.top.x;
  282.     flt_C4B898 = v173 + *&v172 - v169;
  283.     flt_C4B89C = v171 + v37 - v168;
  284.     flt_C4B8A4 = v173 + v169 + *&v172;
  285.     flt_C4B8A8 = v168 + v37 + v171;
  286.     v38 = v173 - *&v172;
  287.     flt_C4B8B0 = v169 + v38;
  288.     v39 = v38;
  289.     v40 = v37 - v171;
  290.     v174 = v40;
  291.     flt_C4B8B4 = v40 + v168;
  292.     flt_C4B8BC = v39 - v169;
  293.     flt_C4B8C0 = v174 - v168;
  294.     v36 = entity->__parent.m_pCoords;
  295.     v41 = v36 ? &v36->matrix.pos : &entity->__parent.placement;
  296.     v171 = a6->z - v41->z;
  297.     v173 = flt_C4B8B0 >= flt_C4B8BC ? flt_C4B8BC : flt_C4B8B0;
  298.     v42 = flt_C4B898 >= flt_C4B8A4 ? flt_C4B8A4 : flt_C4B898;
  299.     v166 = v42 >= v173 ? v173 : v42;
  300.     v173 = flt_C4B8B0 <= flt_C4B8BC ? flt_C4B8BC : flt_C4B8B0;
  301.     v43 = flt_C4B898 <= flt_C4B8A4 ? flt_C4B8A4 : flt_C4B898;
  302.     v167 = v43 <= v173 ? v173 : v43;
  303.     v173 = flt_C4B8B4 >= flt_C4B8C0 ? flt_C4B8C0 : flt_C4B8B4;
  304.     v44 = flt_C4B89C >= flt_C4B8A8 ? flt_C4B8A8 : flt_C4B89C;
  305.     v168 = v44 >= v173 ? v173 : v44;
  306.     v173 = flt_C4B8B4 <= flt_C4B8C0 ? flt_C4B8C0 : flt_C4B8B4;
  307.     v45 = flt_C4B89C <= flt_C4B8A8 ? flt_C4B8A8 : flt_C4B89C;
  308.     v169 = v45 <= v173 ? v173 : v45;
  309.     result = (pColData->flags & 2 ? *(pColData->meshFaces - 4) : 1);
  310.     v177 = result;
  311.     v174 = 0.0;
  312.     if ( result > 0 )
  313.     {
  314.       while ( 1 )
  315.       {
  316.         if ( _pColData->flags & 2 )
  317.         {
  318.           v46 = _pColData->meshFaces - 28 * LODWORD(v174) - 32;
  319.           if ( v167 <= *v46 || v166 >= *(v46 + 12) || v169 <= *(v46 + 4) || v168 >= *(v46 + 16) )
  320.             goto LABEL_217;
  321.           LODWORD(v48) = *(v46 + 24);
  322.           numFaces = *(v46 + 26) + 1;
  323.         }
  324.         else
  325.         {
  326.           numFaces = _pColData->numberOfFaces;
  327.           LODWORD(v48) = 0;
  328.         }
  329.         v176 = numFaces;
  330.         v173 = v48;
  331.         if ( SLODWORD(v48) < numFaces )
  332.         {
  333. LABEL_90:
  334.           v49 = pColData->pMeshFaces;
  335.           v178 = 10 * LODWORD(v173);
  336.           v175 = *(v49 + 10 * LODWORD(v173) + 4);
  337.           if ( fabs(v175 * 0.00024414062) <= 0.1
  338.             || (v50 = pColData->meshFaces,
  339.                 v51 = *(v50 + 8 * LODWORD(v173)),
  340.                 v52 = 8 * LODWORD(v173) + v50,
  341.                 v180 = 8 * LODWORD(v173),
  342.                 sub_40F5E0(&v181, v51),
  343.                 sub_40F5E0(&v184, *(v52 + 2)),
  344.                 sub_40F5E0(&v187, *(v52 + 4)),
  345.                 v181 <= v166)
  346.             && v184 <= v166
  347.             && v187 <= v166
  348.             || v181 >= v167 && v184 >= v167 && v187 >= v167
  349.             || v182 <= v168 && v185 <= v168 && v188 <= v168
  350.             || v182 >= v169 && v185 >= v169 && v188 >= v169
  351.             || v183 >= v171 && v186 >= v171 && v189 >= v171
  352.             || (*&v172 = v171 - a15, v183 <= *&v172) && v186 <= *&v172 && v189 <= *&v172 )
  353.             goto LABEL_216;
  354.           v60 = v184 - v181;
  355.           v59 = v185 - v182;
  356.           dword_C4B7A8[0] = LODWORD(flt_C4B898);
  357.           dword_C4B7AC[0] = LODWORD(flt_C4B89C);
  358.           dword_C4B7B8 = LODWORD(flt_C4B8A8);
  359.           dword_C4B7C0 = LODWORD(flt_C4B8B0);
  360.           dword_C4B7B4 = LODWORD(flt_C4B8A4);
  361.           dword_C4B7CC = LODWORD(flt_C4B8BC);
  362.           dword_C4B7D0 = LODWORD(flt_C4B8C0);
  363.           v56 = 0;
  364.           v55 = 0;
  365.           v54 = 0;
  366.           dword_C4B7C4 = LODWORD(flt_C4B8B4);
  367.           dword_C4B6B8[0] = 0;
  368.           dword_C4B6BC[0] = 0;
  369.           dword_C4B6C4 = 0x3F800000u;
  370.           dword_C4B6C8 = 0;
  371.           dword_C4B6D0 = 0x3F800000u;
  372.           dword_C4B6D4 = 0x3F800000u;
  373.           dword_C4B6DC = 0;
  374.           dword_C4B6E0 = 0x3F800000u;
  375.           v58 = dword_C4B820;
  376.           v53 = dword_C4B730;
  377.           v57 = &dword_C4B7A8[-2];
  378.           while ( 1 )
  379.           {
  380.             v61 = (*&dword_C4B7A8[v54] - v181) * v59 - (*&dword_C4B7AC[v54] - v182) * v60;
  381.             *&v165[3] = v61;
  382.             if ( v61 <= 0.0 )
  383.             {
  384.               if ( v55 == 1 )
  385.               {
  386.                 ++v56;
  387.                 v53 += 12;
  388.                 v58 += 12;
  389.                 v64 = fabs((*&v57[v54 - 1] - v181) * v59 - (*&v57[v54] - v182) * v60);
  390.                 v65 = v64 / (fabs(*&v165[3]) + v64);
  391.                 *(v53 - 12) = v65 * *&dword_C4B6B8[v54] + (1.0 - v65) * flt_C4B6AC[v54];
  392.                 *(v53 - 8) = (1.0 - v65) * flt_C4B6B0[v54] + v65 * *&dword_C4B6BC[v54];
  393.                 *(v58 - 12) = v65 * *&dword_C4B7A8[v54] + (1.0 - v65) * *&v57[v54 - 1];
  394.                 *(v58 - 8) = v65 * *&dword_C4B7AC[v54] + (1.0 - v65) * *&v57[v54];
  395.               }
  396.               v55 = 2;
  397.               goto LABEL_120;
  398.             }
  399.             if ( !v55 || v55 == 1 )
  400.               goto LABEL_115;
  401.             if ( v55 == 2 )
  402.               break;
  403. LABEL_116:
  404.             v55 = 1;
  405. LABEL_120:
  406.             v54 += 3;
  407.             if ( v54 >= 12 )
  408.             {
  409.               v66 = (*dword_C4B7A8 - v181) * v59 - (*dword_C4B7AC - v182) * v60;
  410.               *&v165[3] = v66;
  411.               if ( v66 > 0.0 && v55 == 2 || *&v165[3] <= 0.0 && v55 == 1 )
  412.               {
  413.                 v67 = 3 * v56++;
  414.                 v68 = fabs((*&dword_C4B7CC - v181) * v59 - (*&dword_C4B7D0 - v182) * v60);
  415.                 v69 = v68 / (fabs(*&v165[3]) + v68);
  416.                 *&dword_C4B730[v67] = *&dword_C4B6DC * (1.0 - v69) + v69 * *dword_C4B6B8;
  417.                 *&dword_C4B734[v67] = *&dword_C4B6E0 * (1.0 - v69) + v69 * *dword_C4B6BC;
  418.                 *&dword_C4B820[v67] = *&dword_C4B7CC * (1.0 - v69) + v69 * *dword_C4B7A8;
  419.                 *&dword_C4B824[v67] = (1.0 - v69) * *&dword_C4B7D0 + v69 * *dword_C4B7AC;
  420.               }
  421.               v70 = v56;
  422.               v72 = 0;
  423.               v71 = 0;
  424.               v172 = v70;
  425.               if ( v70 > 0 )
  426.               {
  427.                 v75 = dword_C4B7A8;
  428.                 v73 = dword_C4B6B8;
  429.                 v74 = 0;
  430.                 v60 = v187 - v184;
  431.                 v175 = v70;
  432.                 v59 = v188 - v185;
  433.                 while ( 1 )
  434.                 {
  435.                   v76 = (*&dword_C4B820[v74] - v184) * v59 - (*&dword_C4B824[v74] - v185) * v60;
  436.                   *&v165[3] = v76;
  437.                   if ( v76 <= 0.0 )
  438.                   {
  439.                     if ( v71 == 1 )
  440.                     {
  441.                       ++v72;
  442.                       v73 += 12;
  443.                       v75 += 12;
  444.                       v79 = fabs((flt_C4B814[v74] - v184) * v59 - (flt_C4B818[v74] - v185) * v60);
  445.                       v80 = v79 / (fabs(*&v165[3]) + v79);
  446.                       *(v73 - 12) = v80 * *&dword_C4B730[v74] + (1.0 - v80) * flt_C4B724[v74];
  447.                       *(v73 - 8) = (1.0 - v80) * flt_C4B728[v74] + v80 * *&dword_C4B734[v74];
  448.                       *(v75 - 12) = v80 * *&dword_C4B820[v74] + (1.0 - v80) * flt_C4B814[v74];
  449.                       *(v75 - 8) = v80 * *&dword_C4B824[v74] + (1.0 - v80) * flt_C4B818[v74];
  450.                     }
  451.                     v71 = 2;
  452.                     goto LABEL_138;
  453.                   }
  454.                   if ( !v71 || v71 == 1 )
  455.                     goto LABEL_133;
  456.                   if ( v71 == 2 )
  457.                     break;
  458. LABEL_134:
  459.                   v71 = 1;
  460. LABEL_138:
  461.                   v74 += 3;
  462.                   --v175;
  463.                   if ( !v175 )
  464.                     goto LABEL_139;
  465.                 }
  466.                 ++v72;
  467.                 v73 += 12;
  468.                 v75 += 12;
  469.                 v77 = fabs((flt_C4B814[v74] - v184) * v59 - (flt_C4B818[v74] - v185) * v60);
  470.                 v78 = v77 / (fabs(*&v165[3]) + v77);
  471.                 *(v73 - 12) = (1.0 - v78) * flt_C4B724[v74] + v78 * *&dword_C4B730[v74];
  472.                 *(v73 - 8) = (1.0 - v78) * flt_C4B728[v74] + v78 * *&dword_C4B734[v74];
  473.                 *(v75 - 12) = v78 * *&dword_C4B820[v74] + (1.0 - v78) * flt_C4B814[v74];
  474.                 *(v75 - 8) = v78 * *&dword_C4B824[v74] + (1.0 - v78) * flt_C4B818[v74];
  475. LABEL_133:
  476.                 *v73 = dword_C4B730[v74];
  477.                 *(v73 + 4) = dword_C4B734[v74];
  478.                 *v75 = dword_C4B820[v74];
  479.                 v73 += 12;
  480.                 *(v75 + 4) = dword_C4B824[v74];
  481.                 ++v72;
  482.                 v75 += 12;
  483.                 goto LABEL_134;
  484.               }
  485. LABEL_139:
  486.               v81 = (*dword_C4B820 - v184) * v59 - (*dword_C4B824 - v185) * v60;
  487.               *&v165[3] = v81;
  488.               if ( v81 > 0.0 && v71 == 2 || *&v165[3] <= 0.0 && v71 == 1 )
  489.               {
  490.                 v82 = 3 * v172;
  491.                 v83 = 3 * v72++;
  492.                 v84 = fabs((flt_C4B814[3 * v172] - v184) * v59 - (flt_C4B818[3 * v172] - v185) * v60);
  493.                 v85 = v84 / (fabs(*&v165[3]) + v84);
  494.                 *&dword_C4B6B8[v83] = (1.0 - v85) * flt_C4B724[3 * v172] + *dword_C4B730 * v85;
  495.                 *&dword_C4B6BC[v83] = (1.0 - v85) * flt_C4B728[v82] + *dword_C4B734 * v85;
  496.                 *&dword_C4B7A8[v83] = *dword_C4B820 * v85 + (1.0 - v85) * flt_C4B814[v82];
  497.                 *&dword_C4B7AC[v83] = (1.0 - v85) * flt_C4B818[v82] + *dword_C4B824 * v85;
  498.               }
  499.               v86 = v72;
  500.               v88 = 0;
  501.               v87 = 0;
  502.               v172 = v86;
  503.               if ( v86 > 0 )
  504.               {
  505.                 v91 = dword_C4B820;
  506.                 v89 = dword_C4B730;
  507.                 v60 = v181 - v187;
  508.                 v90 = 0;
  509.                 v175 = v172;
  510.                 v59 = v182 - v188;
  511.                 while ( 1 )
  512.                 {
  513.                   v92 = (*&dword_C4B7A8[v90] - v187) * v59 - (*&dword_C4B7AC[v90] - v188) * v60;
  514.                   *&v165[3] = v92;
  515.                   if ( v92 <= 0.0 )
  516.                   {
  517.                     if ( v87 == 1 )
  518.                     {
  519.                       ++v88;
  520.                       v89 += 12;
  521.                       v91 += 12;
  522.                       v95 = fabs((*&v57[v90 - 1] - v187) * v59 - (*&v57[v90] - v188) * v60);
  523.                       v96 = v95 / (fabs(*&v165[3]) + v95);
  524.                       *(v89 - 12) = v96 * *&dword_C4B6B8[v90] + (1.0 - v96) * flt_C4B6AC[v90];
  525.                       *(v89 - 8) = v96 * *&dword_C4B6BC[v90] + (1.0 - v96) * flt_C4B6B0[v90];
  526.                       *(v91 - 12) = v96 * *&dword_C4B7A8[v90] + (1.0 - v96) * *&v57[v90 - 1];
  527.                       *(v91 - 8) = v96 * *&dword_C4B7AC[v90] + (1.0 - v96) * *&v57[v90];
  528.                     }
  529.                     v87 = 2;
  530.                     goto LABEL_156;
  531.                   }
  532.                   if ( !v87 || v87 == 1 )
  533.                     goto LABEL_151;
  534.                   if ( v87 == 2 )
  535.                     break;
  536. LABEL_152:
  537.                   v87 = 1;
  538. LABEL_156:
  539.                   v90 += 3;
  540.                   --v175;
  541.                   if ( !v175 )
  542.                   {
  543.                     v86 = v172;
  544.                     goto LABEL_158;
  545.                   }
  546.                 }
  547.                 ++v88;
  548.                 v89 += 12;
  549.                 v91 += 12;
  550.                 v93 = fabs((*&v57[v90 - 1] - v187) * v59 - (*&v57[v90] - v188) * v60);
  551.                 v94 = v93 / (fabs(*&v165[3]) + v93);
  552.                 *(v89 - 12) = (1.0 - v94) * flt_C4B6AC[v90] + v94 * *&dword_C4B6B8[v90];
  553.                 *(v89 - 8) = v94 * *&dword_C4B6BC[v90] + (1.0 - v94) * flt_C4B6B0[v90];
  554.                 *(v91 - 12) = v94 * *&dword_C4B7A8[v90] + (1.0 - v94) * *&v57[v90 - 1];
  555.                 *(v91 - 8) = v94 * *&dword_C4B7AC[v90] + (1.0 - v94) * *&v57[v90];
  556. LABEL_151:
  557.                 *v89 = dword_C4B6B8[v90];
  558.                 *(v89 + 4) = dword_C4B6BC[v90];
  559.                 *v91 = dword_C4B7A8[v90];
  560.                 v89 += 12;
  561.                 *(v91 + 4) = dword_C4B7AC[v90];
  562.                 ++v88;
  563.                 v91 += 12;
  564.                 goto LABEL_152;
  565.               }
  566. LABEL_158:
  567.               v97 = (*dword_C4B7A8 - v187) * v59 - (*dword_C4B7AC - v188) * v60;
  568.               *&v165[3] = v97;
  569.               if ( v97 > 0.0 && v87 == 2 || *&v165[3] <= 0.0 && v87 == 1 )
  570.               {
  571.                 v98 = 3 * v86;
  572.                 v99 = flt_C4B79C[3 * v86];
  573.                 v100 = 3 * v88++;
  574.                 v101 = fabs((v99 - v187) * v59 - (flt_C4B7A0[v98] - v188) * v60);
  575.                 v102 = v101 / (fabs(*&v165[3]) + v101);
  576.                 *&dword_C4B730[v100] = (1.0 - v102) * flt_C4B6AC[v98] + v102 * *dword_C4B6B8;
  577.                 *&dword_C4B734[v100] = (1.0 - v102) * flt_C4B6B0[v98] + v102 * *dword_C4B6BC;
  578.                 *&dword_C4B820[v100] = v102 * *dword_C4B7A8 + (1.0 - v102) * flt_C4B79C[v98];
  579.                 *&dword_C4B824[v100] = (1.0 - v102) * flt_C4B7A0[v98] + v102 * *dword_C4B7AC;
  580.               }
  581.               if ( v88 >= 3 )
  582.               {
  583.                 v105 = pColData->pMeshFaces;
  584.                 v106 = *(v105 + v178);
  585.                 v107 = v178 + v105;
  586.                 v108 = *(v107 + 2);
  587.                 v178 = v106;
  588.                 v109 = *(v107 + 4);
  589.                 v110 = v178;
  590.                 v178 = v108;
  591.                 v103 = 0;
  592.                 v190 = v110 * 0.00024414062;
  593.                 v111 = v178;
  594.                 v178 = v109;
  595.                 v191 = v111 * 0.00024414062;
  596.                 v104 = v109 * 0.00024414062;
  597.                 *&v165[3] = v183 * v104 + v191 * v182 + v190 * v181;
  598.                 if ( v88 >= 4 )
  599.                 {
  600.                   v113 = 3;
  601.                   v114 = -1.0 / v104;
  602.                   v112 = flt_C4B828;
  603.                   do
  604.                   {
  605.                     v113 += 4;
  606.                     v115 = v191 * *(v112 - 4);
  607.                     v103 += 4;
  608.                     v112 += 48;
  609.                     *(v112 - 48) = (v115 + v190 * *(v112 - 56) - *&v165[3]) * v114;
  610.                     *(v112 - 36) = (v191 * *(v112 - 40) + v190 * *(v112 - 44) - *&v165[3]) * v114;
  611.                     *(v112 - 24) = (v191 * *(v112 - 28) + v190 * *(v112 - 32) - *&v165[3]) * v114;
  612.                     *(v112 - 12) = (v191 * *(v112 - 16) + v190 * *(v112 - 20) - *&v165[3]) * v114;
  613.                   }
  614.                   while ( v113 < v88 );
  615.                 }
  616.                 if ( v103 < v88 )
  617.                 {
  618.                   v118 = -1.0 / v104;
  619.                   v116 = &flt_C4B828[3 * v103];
  620.                   v117 = v88 - v103;
  621.                   do
  622.                   {
  623.                     v116 += 3;
  624.                     --v117;
  625.                     *(v116 - 3) = (v191 * *(v116 - 4) + v190 * *(v116 - 5) - *&v165[3]) * v118;
  626.                   }
  627.                   while ( v117 );
  628.                 }
  629.                 if ( v88 > 0 )
  630.                 {
  631.                   v119 = dword_C4B824;
  632.                   v175 = v88;
  633.                   do
  634.                   {
  635.                     LODWORD(v179) = *(v119 - 4);
  636.                     if ( !entity->__parent.m_pCoords )
  637.                     {
  638.                       CPlaceable__allocateL1XYZ(entity);
  639.                       Placement__toMatrix(entity->__parent.m_pCoords);
  640.                     }
  641.                     v120 = entity->__parent.m_pCoords;
  642.                     if ( !entity->__parent.m_pCoords )
  643.                     {
  644.                       CPlaceable__allocateL1XYZ(entity);
  645.                       Placement__toMatrix(entity->__parent.m_pCoords);
  646.                     }
  647.                     v121 = entity->__parent.m_pCoords;
  648.                     v122 = v121 + 48;
  649.                     if ( !v121 )
  650.                       v122 = &entity->__parent.placement;
  651.                     *(v119 - 4) = *(v121 + 16) * *v119 + *v120 * *(v119 - 4) + *v122;
  652.                     if ( !entity->__parent.m_pCoords )
  653.                     {
  654.                       CPlaceable__allocateL1XYZ(entity);
  655.                       Placement__toMatrix(entity->__parent.m_pCoords);
  656.                     }
  657.                     v123 = entity->__parent.m_pCoords;
  658.                     if ( !entity->__parent.m_pCoords )
  659.                     {
  660.                       CPlaceable__allocateL1XYZ(entity);
  661.                       Placement__toMatrix(entity->__parent.m_pCoords);
  662.                     }
  663.                     v124 = entity->__parent.m_pCoords;
  664.                     v125 = v124 + 48;
  665.                     if ( !v124 )
  666.                       v125 = &entity->__parent.placement;
  667.                     *v119 = *(v124 + 20) * *v119 + v179 * *(v123 + 4) + *(v125 + 4);
  668.                     v126 = entity->__parent.m_pCoords;
  669.                     if ( v126 )
  670.                       v127 = v126 + 48;
  671.                     else
  672.                       v127 = &entity->__parent.placement;
  673.                     v128 = *(v127 + 8) + *(v119 + 4);
  674.                     v119 += 12;
  675.                     v129 = v175-- == 1;
  676.                     *(v119 - 8) = v128;
  677.                   }
  678.                   while ( !v129 );
  679.                 }
  680.                 *cBuf = *(v180 + pColData->meshFaces + 7);
  681.                 if ( a17 )
  682.                 {
  683.                   v130 = dword_C403D8;
  684.                   if ( dword_C403D8 )
  685.                   {
  686.                     dword_C403D8 = *(dword_C403D8 + 84);
  687.                     *(v130 + 0x54) = *a17;
  688.                     *a17 = v130;
  689.                     *(v130 + 0x58) = v88;
  690.                     if ( v88 > 0 )
  691.                     {
  692.                       v131 = v130 + 97;
  693.                       v132 = 0;
  694.                       do
  695.                       {
  696.                         *(v132 * 4 + v130) = dword_C4B820[v132];
  697.                         *(v132 * 4 + v130 + 4) = dword_C4B820[v132 + 1];
  698.                         *(v132 * 4 + v130 + 8) = dword_C4B820[v132 + 2];
  699.                         *(v131 - 7) = (*&dword_C4B730[v132] * 200.0);
  700.                         v133 = (*&dword_C4B734[v132] * 200.0);
  701.                         v132 += 3;
  702.                         *v131++ = v133;
  703.                         --v88;
  704.                       }
  705.                       while ( v88 );
  706.                     }
  707.                   }
  708.                 }
  709.                 else
  710.                 {
  711.                   v135 = numIndices;
  712.                   v134 = numVerts;
  713.                   v136 = 3 * v88 - 6;
  714.                   v180 = 3 * v88 - 6;
  715.                   if ( numIndices + v136 >= 4096 )
  716.                   {
  717.                     if ( numVerts && RwIm3DTransform(&pVerts, numVerts, 0, 1u) )
  718.                     {
  719.                       RwIm3DRenderIndexedPrimitive(3, indices, numIndices);
  720.                       RwIm3DEnd();
  721.                     }
  722.                     v135 = 0;
  723.                     v134 = 0;
  724.                     numIndices = 0;
  725.                     numVerts = 0;
  726.                   }
  727.                   if ( v134 + v88 >= 2048 )
  728.                   {
  729.                     if ( v134 && RwIm3DTransform(&pVerts, v134, 0, 1u) )
  730.                     {
  731.                       RwIm3DRenderIndexedPrimitive(3, indices, numIndices);
  732.                       RwIm3DEnd();
  733.                     }
  734.                     v135 = 0;
  735.                     v134 = 0;
  736.                     numIndices = 0;
  737.                     numVerts = 0;
  738.                   }
  739.                   v138 = 9 * v134;
  740.                   v175 = 2 * v135 + 0xC4B958;
  741.                   dword_C40410 = 3 * v88 - 6;
  742.                   dword_C40414 = v88;
  743.                   v140 = *cBuf;
  744.                   v137 = 4 * v138 + 12900696;
  745.                   v178 = v137;
  746.                   sub_707850(a19, v140, a12, a13, a14, v165, &v165[1], &v165[2]);
  747.                   v139 = 0;
  748.                   if ( v88 >= 4 )
  749.                   {
  750.                     v142 = v165[2] | ((v165[1] | ((v165[0] | (a11 << 8)) << 8)) << 8);
  751.                     v144 = 3;
  752.                     pVertices = v137 + 0x1C;
  753.                     v143 = 0;
  754.                     do
  755.                     {
  756.                       v145 = a16 * *&dword_C4B730[v143];
  757.                       *(pVertices - 28) = dword_C4B820[v143];
  758.                       *(pVertices - 24) = dword_C4B824[v143];
  759.                       *pVertices = v145;
  760.                       v146 = a16 * *&dword_C4B734[v143];
  761.                       *(pVertices + 8) = dword_C4B82C[v143];
  762.                       *(pVertices + 12) = dword_C4B830[v143];
  763.                       *(pVertices + 4) = v146;
  764.                       v147 = flt_C4B828[v143] + 0.059999999;
  765.                       *(pVertices + 44) = dword_C4B838[v143];
  766.                       *(pVertices + 48) = dword_C4B83C[v143];
  767.                       *(pVertices - 20) = v147;
  768.                       *(pVertices + 80) = dword_C4B844[v143];
  769.                       v148 = a16 * flt_C4B73C[v143];
  770.                       v149 = dword_C4B848[v143];
  771.                       *(pVertices - 4) = v142;
  772.                       *(pVertices + 32) = v142;
  773.                       *(pVertices + 36) = v148;
  774.                       *(pVertices + 68) = v142;
  775.                       v150 = a16 * flt_C4B740[v143];
  776.                       *(pVertices + 104) = v142;
  777.                       *(pVertices + 84) = v149;
  778.                       v144 += 4;
  779.                       *(pVertices + 40) = v150;
  780.                       v139 += 4;
  781.                       v151 = flt_C4B834[v143] + 0.059999999;
  782.                       v143 += 12;
  783.                       pVertices += 144;
  784.                       *(pVertices - 128) = v151;
  785.                       *(pVertices - 72) = a16 * flt_C4B718[v143];
  786.                       *(pVertices - 68) = a16 * flt_C4B71C[v143];
  787.                       *(pVertices - 92) = flt_C4B810[v143] + 0.059999999;
  788.                       *(pVertices - 36) = a16 * flt_C4B724[v143];
  789.                       *(pVertices - 32) = a16 * flt_C4B728[v143];
  790.                       *(pVertices - 56) = flt_C4B81C[v143] + 0.059999999;
  791.                     }
  792.                     while ( v144 < v88 );
  793.                     v136 = v180;
  794.                     v137 = v178;
  795.                   }
  796.                   if ( v139 < v88 )
  797.                   {
  798.                     v154 = v165[2] | ((v165[1] | ((v165[0] | (a11 << 8)) << 8)) << 8);
  799.                     v153 = v137 + 36 * v139 + 28;
  800.                     v152 = 3 * v139;
  801.                     v155 = v88 - v139;
  802.                     do
  803.                     {
  804.                       v156 = a16 * *&dword_C4B730[v152];
  805.                       *(v153 - 28) = dword_C4B820[v152];
  806.                       v157 = dword_C4B824[v152];
  807.                       *(v153 - 4) = v154;
  808.                       *v153 = v156;
  809.                       *(v153 - 24) = v157;
  810.                       v158 = a16 * *&dword_C4B734[v152];
  811.                       v152 += 3;
  812.                       v153 += 36;
  813.                       --v155;
  814.                       *(v153 - 32) = v158;
  815.                       *(v153 - 56) = flt_C4B81C[v152] + 0.059999999;
  816.                     }
  817.                     while ( v155 );
  818.                   }
  819.                   if ( v136 > 0 )
  820.                   {
  821.                     v160 = v136;
  822.                     v163 = v175;
  823.                     v164 = v160 & 1;
  824.                     v160 >>= 1;
  825.                     memcpy(v175, word_C403A8, 4 * v160);
  826.                     v162 = &word_C403A8[2 * v160];
  827.                     v161 = v163 + 4 * v160;
  828.                     for ( i = v164; i; --i )
  829.                     {
  830.                       *v161 = *v162;
  831.                       ++v162;
  832.                       v161 += 2;
  833.                     }
  834.                   }
  835.                   sub_7077A0();
  836.                 }
  837.               }
  838. LABEL_216:
  839.               ++LODWORD(v173);
  840.               if ( SLODWORD(v173) >= v176 )
  841.                 goto LABEL_217;
  842.               goto LABEL_90;
  843.             }
  844.           }
  845.           ++v56;
  846.           v53 += 12;
  847.           v58 += 12;
  848.           v62 = fabs((*&v57[v54 - 1] - v181) * v59 - (*&v57[v54] - v182) * v60);
  849.           v63 = v62 / (fabs(*&v165[3]) + v62);
  850.           *(v53 - 12) = (1.0 - v63) * flt_C4B6AC[v54] + v63 * *&dword_C4B6B8[v54];
  851.           *(v53 - 8) = (1.0 - v63) * flt_C4B6B0[v54] + v63 * *&dword_C4B6BC[v54];
  852.           *(v58 - 12) = v63 * *&dword_C4B7A8[v54] + (1.0 - v63) * *&v57[v54 - 1];
  853.           *(v58 - 8) = v63 * *&dword_C4B7AC[v54] + (1.0 - v63) * *&v57[v54];
  854. LABEL_115:
  855.           *v53 = dword_C4B6B8[v54];
  856.           *(v53 + 4) = dword_C4B6BC[v54];
  857.           *v58 = dword_C4B7A8[v54];
  858.           v53 += 12;
  859.           *(v58 + 4) = dword_C4B7AC[v54];
  860.           ++v56;
  861.           v58 += 12;
  862.           goto LABEL_116;
  863.         }
  864. LABEL_217:
  865.         result = (LODWORD(v174)++ + 1);
  866.         if ( SLODWORD(v174) >= v177 )
  867.           return result;
  868.         _pColData = pColData;
  869.       }
  870.     }
  871.   }
  872.   return result;
  873. }
Advertisement
Add Comment
Please, Sign In to add comment