comparison mm7_4.cpp @ 741:cd9ae9a2c99c

Слияние
author Ritor1
date Fri, 22 Mar 2013 19:59:03 +0600
parents 14cf77af15de 2f4e33c1ed24
children 4b06e19fcdbc
comparison
equal deleted inserted replaced
740:14cf77af15de 741:cd9ae9a2c99c
266 bool v50; // [sp+2Ch] [bp-14h]@12 266 bool v50; // [sp+2Ch] [bp-14h]@12
267 signed int v53; // [sp+30h] [bp-10h]@10 267 signed int v53; // [sp+30h] [bp-10h]@10
268 signed int v54; // [sp+30h] [bp-10h]@41 268 signed int v54; // [sp+30h] [bp-10h]@41
269 signed int v55; // [sp+34h] [bp-Ch]@1 269 signed int v55; // [sp+34h] [bp-Ch]@1
270 270
271 LOG_DECOMPILATION_WARNING(); 271 //LOG_DECOMPILATION_WARNING();
272
273 static int blv_floor_id[50]; // 00721200
274 static int blv_floor_level[50]; // 007212C8
275
276 static __int16 word_721390_ys[104]; // idb
277 static __int16 word_721460_xs[104]; // idb
272 278
273 auto pSector = &pIndoor->pSectors[uSectorID]; 279 auto pSector = &pIndoor->pSectors[uSectorID];
274 v55 = 1; 280 v55 = 1;
275 for (uint i = 0; i < pSector->uNumFloors; ++i) 281 for (uint i = 0; i < pSector->uNumFloors; ++i)
276 { 282 {
281 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && 287 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 &&
282 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) 288 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1)
283 { 289 {
284 for (uint j = 0; j < pFloor->uNumVertices; ++j) 290 for (uint j = 0; j < pFloor->uNumVertices; ++j)
285 { 291 {
286 word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; 292 word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x;
287 word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; 293 word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x;
288 word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; 294 word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y;
289 word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; 295 word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y;
290 } 296 }
291 v44 = 2 * pFloor->uNumVertices; 297 v44 = 2 * pFloor->uNumVertices;
292 word_721460[2 * pFloor->uNumVertices] = word_721460[0]; 298 word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0];
293 word_721390[2 * pFloor->uNumVertices] = word_721390[0]; 299 word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0];
294 300
295 v48 = word_721390[0] >= y; 301 v48 = word_721390_ys[0] >= y;
296 v53 = 0; 302 v53 = 0;
297 if ( pFloor->uNumVertices > 0 ) 303 if ( pFloor->uNumVertices > 0 )
298 { 304 {
299 for ( int i = 0; i < v44; i++ ) 305 for ( int i = 0; i < v44; i++ )
300 { 306 {
301 if ( v53 >= 2 ) 307 if ( v53 >= 2 )
302 break; 308 break;
303 v50 = word_721390[i + 1] >= y; 309 v50 = word_721390_ys[i + 1] >= y;
304 if ( v48 == v50 ) 310
311 v13 = i;
312 if ( v48 != v50 )
305 { 313 {
306 v13 = i; 314 v14 = word_721460_xs[i + 1] >= x ? 0 : 2;
307 } 315 v15 = v14 | word_721460_xs[i] < x;
308 else
309 {
310 v13 = i;
311 v14 = word_721460[i + 1] >= x ? 0 : 2;
312 v15 = v14 | word_721460[i] < x;
313 316
314 if ( !v15) 317 if ( !v15)
315 ++v53; 318 ++v53;
316 else 319 else
317 { 320 {
318 //v16 = word_721390[i]; 321 //v16 = word_721390_ys[i];
319 v17 = word_721390[i + 1] - word_721390[i]; 322 v17 = word_721390_ys[i + 1] - word_721390_ys[i];
320 v18 = y - word_721390[i]; 323 v18 = y - word_721390_ys[i];
321 LODWORD(v19) = v18 << 16; 324 LODWORD(v19) = v18 << 16;
322 HIDWORD(v19) = v18 >> 16; 325 HIDWORD(v19) = v18 >> 16;
323 if ((signed int)(((unsigned __int64)(((signed int)word_721460[i + 1] - (signed int)word_721460[i]) * v19 / v17) >> 16) + word_721460[i]) >= x) 326 if ((signed int)(((unsigned __int64)(((signed int)word_721460_xs[i + 1] - (signed int)word_721460_xs[i]) * v19 / v17) >> 16) + word_721460_xs[i]) >= x)
324 ++v53; 327 ++v53;
325 } 328 }
326 /*if ( v15 != 3 ) 329 /*if ( v15 != 3 )
327 { 330 {
328 if ( !v15 ) 331 if ( !v15 )
329 { 332 {
330 LODWORD(v19) = (y - word_721390[i]) << 16; 333 LODWORD(v19) = (y - word_721390_ys[i]) << 16;
331 HIDWORD(v19) = (y - word_721390[i]) >> 16; 334 HIDWORD(v19) = (y - word_721390_ys[i]) >> 16;
332 v16 = ((((word_721460[i + 1] - word_721460[i]) * v19 / (word_721390[i + 1] - word_721390[i])) >> 16) + word_721460[i]); 335 v16 = ((((word_721460_xs[i + 1] - word_721460_xs[i]) * v19 / (word_721390_ys[i + 1] - word_721390_ys[i])) >> 16) + word_721460_xs[i]);
333 if ( v16 >= x) 336 if ( v16 >= x)
334 ++v53; 337 ++v53;
335 } 338 }
336 }*/ 339 }*/
337 } 340 }
350 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16) 353 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16)
351 + HIWORD(pFloor->zCalc3); 354 + HIWORD(pFloor->zCalc3);
352 } 355 }
353 v22 = v55++; 356 v22 = v55++;
354 blv_floor_level[v22] = v21; 357 blv_floor_level[v22] = v21;
355 dword_721200[v22] = pSector->pFloors[i]; 358 blv_floor_id[v22] = pSector->pFloors[i];
356 } 359 }
357 } 360 }
358 } 361 }
359 } 362 }
360 363
369 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && 372 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 &&
370 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) 373 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 )
371 { 374 {
372 for (uint j = 0; j < portal->uNumVertices; ++j) 375 for (uint j = 0; j < portal->uNumVertices; ++j)
373 { 376 {
374 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; 377 word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x;
375 word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; 378 word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x;
376 word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; 379 word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y;
377 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; 380 word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y;
378 } 381 }
379 word_721460[2 * portal->uNumVertices] = word_721460[0]; 382 word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0];
380 word_721390[2 * portal->uNumVertices] = word_721390[0]; 383 word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0];
381 v54 = 0; 384 v54 = 0;
382 v49 = word_721390[0] >= y; 385 v49 = word_721390_ys[0] >= y;
383 if ( portal->uNumVertices > 0 ) 386 if ( portal->uNumVertices > 0 )
384 { 387 {
385 for ( int i = 0; i < 2 * portal->uNumVertices; ++i ) 388 for ( int i = 0; i < 2 * portal->uNumVertices; ++i )
386 { 389 {
387 if ( v54 >= 2 ) 390 if ( v54 >= 2 )
388 break; 391 break;
389 v47 = word_721390[i + 1] >= y; 392 v47 = word_721390_ys[i + 1] >= y;
390 if ( v49 != v47 ) 393 if ( v49 != v47 )
391 { 394 {
392 v28 = word_721460[i + 1] >= x ? 0 : 2; 395 v28 = word_721460_xs[i + 1] >= x ? 0 : 2;
393 v29 = v28 | word_721460[i] < x; 396 v29 = v28 | word_721460_xs[i] < x;
394 if ( v29 != 3 ) 397 if ( v29 != 3 )
395 { 398 {
396 if ( !v29 ) 399 if ( !v29 )
397 ++v54; 400 ++v54;
398 else 401 else
399 { 402 {
400 //v30 = word_721390[v27]; 403 //v30 = word_721390_ys[v27];
401 v31 = word_721390[i + 1] - word_721390[i]; 404 v31 = word_721390_ys[i + 1] - word_721390_ys[i];
402 v32 = y - word_721390[i]; 405 v32 = y - word_721390_ys[i];
403 LODWORD(v33) = v32 << 16; 406 LODWORD(v33) = v32 << 16;
404 HIDWORD(v33) = v32 >> 16; 407 HIDWORD(v33) = v32 >> 16;
405 if ((signed int)(((unsigned __int64)(((signed int)word_721460[i + 1] - (signed int)word_721460[i]) * v33 / v31) >> 16) + word_721460[i]) >= x) 408 if ((signed int)(((unsigned __int64)(((signed int)word_721460_xs[i + 1] - (signed int)word_721460_xs[i]) * v33 / v31) >> 16) + word_721460_xs[i]) >= x)
406 ++v54; 409 ++v54;
407 } 410 }
408 } 411 }
409 } 412 }
410 v49 = v47; 413 v49 = v47;
413 { 416 {
414 if ( v55 >= 50 ) 417 if ( v55 >= 50 )
415 break; 418 break;
416 v34 = v55++; 419 v34 = v55++;
417 blv_floor_level[v34] = -29000; 420 blv_floor_level[v34] = -29000;
418 dword_721200[v34] = pSector->pPortals[i]; 421 blv_floor_id[v34] = pSector->pPortals[i];
419 } 422 }
420 } 423 }
421 } 424 }
422 } 425 }
423 } 426 }
424 if ( v55 == 1 ) 427 if ( v55 == 1 )
425 { 428 {
426 *pFaceID = dword_721200[0]; 429 *pFaceID = blv_floor_id[0];
427 return blv_floor_level[0]; 430 return blv_floor_level[0];
428 } 431 }
429 if ( !v55 ) 432 if ( !v55 )
430 return -30000; 433 return -30000;
431 *pFaceID = dword_721200[0]; 434 *pFaceID = blv_floor_id[0];
432 //result = blv_floor_level[0]; 435 //result = blv_floor_level[0];
433 if ( v55 > 1 ) 436 if ( v55 > 1 )
434 { 437 {
435 for ( v35 = 1; v35 < v55; ++v35 ) 438 for ( v35 = 1; v35 < v55; ++v35 )
436 { 439 {
437 if ( blv_floor_level[0] <= z + 5 ) 440 if ( blv_floor_level[0] <= z + 5 )
438 { 441 {
439 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 ) 442 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 )
440 continue; 443 continue;
441 blv_floor_level[0] = blv_floor_level[v35]; 444 blv_floor_level[0] = blv_floor_level[v35];
442 *pFaceID = dword_721200[v35]; 445 *pFaceID = blv_floor_id[v35];
443 continue; 446 continue;
444 } 447 }
445 if ( blv_floor_level[v35] < blv_floor_level[0] ) 448 if ( blv_floor_level[v35] < blv_floor_level[0] )
446 { 449 {
447 blv_floor_level[0] = blv_floor_level[v35]; 450 blv_floor_level[0] = blv_floor_level[v35];
448 *pFaceID = dword_721200[v35]; 451 *pFaceID = blv_floor_id[v35];
449 } 452 }
450 } 453 }
451 } 454 }
452 return blv_floor_level[0]; 455 return blv_floor_level[0];
453 } 456 }
2572 char *v24; // [sp+48h] [bp-10h]@2 2575 char *v24; // [sp+48h] [bp-10h]@2
2573 int v25; // [sp+4Ch] [bp-Ch]@2 2576 int v25; // [sp+4Ch] [bp-Ch]@2
2574 float v26; // [sp+50h] [bp-8h]@3 2577 float v26; // [sp+50h] [bp-8h]@3
2575 float v27; // [sp+54h] [bp-4h]@3 2578 float v27; // [sp+54h] [bp-4h]@3
2576 2579
2580 __debugbreak();
2577 v22 = 0; 2581 v22 = 0;
2578 v1 = this->pMemBlocks[1]->pAlignedBlock; 2582 v1 = this->pMemBlocks[1]->pAlignedBlock;
2579 v2 = this->pMemBlocks[6]->pAlignedBlock; 2583 v2 = this->pMemBlocks[6]->pAlignedBlock;
2580 if ( this->field_8C > 0 ) 2584 if ( this->field_8C > 0 )
2581 { 2585 {
4766 4770
4767 4771
4768 4772
4769 4773
4770 //----- (0049B04D) -------------------------------------------------------- 4774 //----- (0049B04D) --------------------------------------------------------
4771 int stru154::_49B04D(ODMFace *a2, BSPVertexBuffer *a3) 4775 void stru154::GetFacePlaneAndClassify(ODMFace *a2, BSPVertexBuffer *a3)
4772 { 4776 {
4773 stru154 *v3; // edi@1 4777 //stru154 *v3; // edi@1
4774 signed int v4; // eax@1 4778 //signed int v4; // eax@1
4775 signed int result; // eax@9 4779 //signed int result; // eax@9
4776 signed int v6; // [sp-8h] [bp-18h]@8 4780 //signed int v6; // [sp-8h] [bp-18h]@8
4777 Vec3_float_ v; // [sp+4h] [bp-Ch]@1 4781 Vec3_float_ v; // [sp+4h] [bp-Ch]@1
4782 float v7;
4778 4783
4779 v.x = 0.0; 4784 v.x = 0.0;
4780 v3 = this;
4781 v.y = 0.0; 4785 v.y = 0.0;
4782 v.z = 0.0; 4786 v.z = 0.0;
4783 _49B13D(a2, a3, &v, (float *)&a3); 4787 GetFacePlane(a2, a3, &v, &v7);
4784 v4 = 2; 4788
4785 if ( a2->pFacePlane.vNormal.z ) 4789 if (fabsf(a2->pFacePlane.vNormal.z) < 1e-6f)
4786 { 4790 polygonType = POLYGON_VerticalWall;
4787 if ( !a2->pFacePlane.vNormal.x && !a2->pFacePlane.vNormal.y ) 4791 else if (fabsf(a2->pFacePlane.vNormal.x) < 1e-6f &&
4788 v4 = 1; 4792 fabsf(a2->pFacePlane.vNormal.y) < 1e-6f)
4789 } 4793 polygonType = POLYGON_Floor;
4790 else 4794 else
4791 { 4795 polygonType = POLYGON_InBetweenFloorAndWall;
4792 v4 = 0; 4796
4793 } 4797 face_plane.vNormal.x = v.x;
4794 if ( v4 ) 4798 face_plane.vNormal.y = v.y;
4795 { 4799 face_plane.vNormal.z = v.z;
4796 if ( v4 == 1 ) 4800 face_plane.dist = v7;
4797 v6 = 3; 4801 }
4798 else 4802
4799 v6 = 4; 4803 //----- (0049B0C9) --------------------------------------------------------
4800 result = v6; 4804 void stru154::ClassifyPolygon(Vec3_float_ *pNormal, float dist)
4801 } 4805 {
4806 if (fabsf(pNormal->z) < 1e-6f)
4807 polygonType = POLYGON_VerticalWall;
4808 else if (fabsf(pNormal->x) < 1e-6f &&
4809 fabsf(pNormal->y) < 1e-6f)
4810 polygonType = POLYGON_Floor;
4802 else 4811 else
4803 { 4812 polygonType = POLYGON_InBetweenFloorAndWall;
4804 result = 1; 4813
4805 } 4814 face_plane.vNormal.x = pNormal->x;
4806 v3->face_plane.vNormal.x = v.x; 4815 face_plane.dist = dist;
4807 v3->face_plane.vNormal.y = v.y; 4816 face_plane.vNormal.y = pNormal->y;
4808 v3->face_plane.vNormal.z = v.z; 4817 face_plane.vNormal.z = pNormal->z;
4809 v3->face_plane.dist = *(float *)&a3;
4810 v3->polygonType = (PolygonType)result;
4811 return result;
4812 } 4818 }
4813 4819
4814 //----- (0049B0C9) --------------------------------------------------------
4815 int stru154::_49B0C9(Vec3_float_ *pNormal, float dist)
4816 {
4817 signed int v3; // esi@1
4818 signed int result; // eax@9
4819 double v5; // st7@12
4820 double v6; // st6@12
4821 double v7; // st5@12
4822 signed int v8; // [sp+0h] [bp-4h]@8
4823
4824 v3 = 2;
4825 if ( pNormal->z == 0.0 )
4826 {
4827 v3 = 0;
4828 }
4829 else
4830 {
4831 if ( pNormal->x == 0.0 && pNormal->y == 0.0 )
4832 v3 = 1;
4833 }
4834 if ( v3 )
4835 {
4836 if ( v3 == 1 )
4837 v8 = 3;
4838 else
4839 v8 = 4;
4840 result = v8;
4841 }
4842 else
4843 {
4844 result = 1;
4845 }
4846 v5 = pNormal->z;
4847 v6 = pNormal->y;
4848 v7 = pNormal->x;
4849 this->polygonType = (PolygonType)result;
4850 this->face_plane.vNormal.x = v7;
4851 this->face_plane.dist = dist;
4852 this->face_plane.vNormal.y = v6;
4853 this->face_plane.vNormal.z = v5;
4854 return result;
4855 }
4856
4857 //----- (0049B13D) -------------------------------------------------------- 4820 //----- (0049B13D) --------------------------------------------------------
4858 int stru154::_49B13D(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *a3, float *a4) 4821 void stru154::GetFacePlane(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *pOutNormal, float *pOutDist)
4859 { 4822 {
4860 ODMFace *v5; // ebx@1 4823 ODMFace *v5; // ebx@1
4861 int v6; // eax@1 4824 //int v6; // eax@1
4862 unsigned __int16 *v7; // ebx@2 4825 //unsigned __int16 *v7; // ebx@2
4863 Vec3_int_ *v8; // eax@3 4826 //Vec3_int_ *v8; // eax@3
4864 Vec3_int_ *v9; // ecx@3 4827 Vec3_int_ *v9; // ecx@3
4865 double v10; // st7@3 4828 //double v10; // st7@3
4866 int v11; // ecx@3 4829 //int v11; // ecx@3
4867 Vec3_int_ *v12; // ecx@3 4830 Vec3_int_ *v12; // ecx@3
4868 double v13; // st7@3 4831 //double v13; // st7@3
4869 double v14; // st6@3 4832 //double v14; // st6@3
4870 double v15; // st5@3 4833 //double v15; // st5@3
4871 int v16; // ecx@3 4834 //int v16; // ecx@3
4872 Vec3_int_ *v17; // eax@3 4835 Vec3_int_ *v17; // eax@3
4873 double v18; // st5@3 4836 //double v18; // st5@3
4874 Vec3_float_ *v19; // eax@3 4837 Vec3_float_ *v19; // eax@3
4875 int result; // eax@8 4838 //int result; // eax@8
4876 float v21; // ecx@10 4839 //float v21; // ecx@10
4877 double v22; // st7@10 4840 //double v22; // st7@10
4878 double v23; // st6@10 4841 //double v23; // st6@10
4879 Vec3_float_ v2; // [sp+4h] [bp-64h]@3 4842 Vec3_float_ v2; // [sp+4h] [bp-64h]@3
4880 float v25; // [sp+18h] [bp-50h]@3 4843 //float v25; // [sp+18h] [bp-50h]@3
4881 float v26; // [sp+1Ch] [bp-4Ch]@3 4844 float v26; // [sp+1Ch] [bp-4Ch]@3
4882 float v27; // [sp+20h] [bp-48h]@3 4845 float v27; // [sp+20h] [bp-48h]@3
4883 float v28; // [sp+24h] [bp-44h]@3 4846 float v28; // [sp+24h] [bp-44h]@3
4884 float v29; // [sp+2Ch] [bp-3Ch]@3 4847 //float v29; // [sp+2Ch] [bp-3Ch]@3
4885 float v30; // [sp+30h] [bp-38h]@3 4848 //float v30; // [sp+30h] [bp-38h]@3
4886 float v31; // [sp+34h] [bp-34h]@3 4849 //float v31; // [sp+34h] [bp-34h]@3
4887 float v32; // [sp+38h] [bp-30h]@3 4850 //float v32; // [sp+38h] [bp-30h]@3
4888 float v33; // [sp+3Ch] [bp-2Ch]@3 4851 //float v33; // [sp+3Ch] [bp-2Ch]@3
4889 Vec3_float_ v1; // [sp+40h] [bp-28h]@1 4852 Vec3_float_ v1; // [sp+40h] [bp-28h]@1
4890 float v35; // [sp+4Ch] [bp-1Ch]@3 4853 //float v35; // [sp+4Ch] [bp-1Ch]@3
4891 float v36; // [sp+50h] [bp-18h]@3 4854 //float v36; // [sp+50h] [bp-18h]@3
4892 float v37; // [sp+54h] [bp-14h]@3 4855 //float v37; // [sp+54h] [bp-14h]@3
4893 Vec3_float_ v38; // [sp+58h] [bp-10h]@3 4856 Vec3_float_ v38; // [sp+58h] [bp-10h]@3
4894 int v39; // [sp+64h] [bp-4h]@1 4857 //int v39; // [sp+64h] [bp-4h]@1
4895 4858
4896 v39 = 0; 4859 //v39 = 0;
4897 v1.x = 0.0; 4860 v1.x = 0.0;
4898 v5 = pFace; 4861 v5 = pFace;
4899 v6 = pFace->uNumVertices; 4862 //v6 = pFace->uNumVertices;
4900 v1.y = 0.0; 4863 v1.y = 0.0;
4901 v1.z = 0.0; 4864 v1.z = 0.0;
4902 if ( v6 - 1 <= 0 ) 4865
4903 { 4866 if (pFace->uNumVertices >= 2)
4904 LABEL_8: 4867 {
4905 a3->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.x >> 16); 4868 int i = 0;
4906 a3->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.y >> 16); 4869 while ( i < pFace->uNumVertices - 2 )
4907 a3->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.vNormal.z >> 16); 4870 {
4908 result = (int)a4; 4871 v9 = &pVertices->pVertices[pFace->pVertexIDs[i]];
4909 *a4 = (double)(v5->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(v5->pFacePlane.dist >> 16); 4872 v12 = &pVertices->pVertices[pFace->pVertexIDs[i + 1]];
4910 } 4873 v17 = &pVertices->pVertices[pFace->pVertexIDs[i + 2]];
4911 else 4874
4912 { 4875 v1.x = v12->x - v9->x;
4913 v7 = &pFace->pVertexIDs[1]; 4876 v26 = v17->x - v12->x;
4914 while ( 1 ) 4877 v1.y = v12->y - v9->y;
4915 { 4878 v27 = v17->y - v12->y;
4916 v8 = pVertices->pVertices; 4879 v1.z = v12->z - v9->z;
4917 v9 = &v8[*(v7 - 1)]; 4880 v28 = v17->z - v12->z;
4918 v35 = (double)v9->x;
4919 v36 = (double)v9->y;
4920 v10 = (double)v9->z;
4921 v11 = *v7;
4922 v37 = v10;
4923 v12 = &v8[v11];
4924 v13 = (double)v12->x;
4925 v14 = (double)v12->y;
4926 v15 = (double)v12->z;
4927 v16 = v7[1];
4928 v25 = v15;
4929 v17 = &v8[v16];
4930 v18 = (double)v17->x;
4931 v29 = (double)v17->y;
4932 v30 = (double)v17->z;
4933 v31 = v13 - v35;
4934 v32 = v14 - v36;
4935 v33 = v25 - v37;
4936 v1.x = v31;
4937 v26 = v18 - v13;
4938 v1.y = v32;
4939 v27 = v29 - v14;
4940 v1.z = v33;
4941 v28 = v30 - v25;
4942 v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28); 4881 v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28);
4943 v38.x = v19->x; 4882 v38.x = v19->x;
4944 v38.y = v19->y; 4883 v38.y = v19->y;
4945 v38.z = v19->z; 4884 v38.z = v19->z;
4946 if ( v38.x != 0.0 ) 4885 if ( v38.x != 0.0 || v38.y != 0.0 || v38.z != 0.0)
4947 break; 4886 {
4948 if ( v38.y != 0.0 || v38.z != 0.0 ) 4887 v38.Normalize();
4949 break; 4888
4950 ++v39; 4889 pOutNormal->x = v38.x;
4951 ++v7; 4890 pOutNormal->y = v38.y;
4952 if ( v39 >= pFace->uNumVertices - 1 ) 4891 pOutNormal->z = v38.z;
4953 { 4892
4954 v5 = pFace; 4893 *pOutDist = -(v9->x * v38.x + v9->y * v38.y + v9->z * v38.z);
4955 goto LABEL_8; 4894 return;
4956 } 4895 }
4957 } 4896 }
4958 v38.Normalize(); 4897 }
4959 v21 = v38.y; 4898
4960 a3->x = v38.x; 4899 pOutNormal->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.x >> 16);
4961 v22 = v37 * v38.z; 4900 pOutNormal->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.y >> 16);
4962 v23 = v36 * v38.y; 4901 pOutNormal->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.z >> 16);
4963 a3->y = v21; 4902 *pOutDist = (double)(v5->pFacePlane.dist & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.dist >> 16);
4964 a3->z = v38.z;
4965 result = (int)a4;
4966 *a4 = -(v22 + v23 + v35 * v38.x);
4967 }
4968 return result;
4969 } 4903 }
4970 4904
4971 4905
4972 4906
4973 4907
5452 5386
5453 5387
5454 5388
5455 5389
5456 5390
5457 //----- (004AC1C9) --------------------------------------------------------
5458 int __thiscall sub_4AC1C9(unsigned int _this, Vec4_int_ *a2)
5459 {
5460 unsigned int v2; // esi@1
5461 __int16 v3; // di@1
5462 signed int v4; // ebx@1
5463 int v5; // ecx@3
5464 Vec4_int_ *v6; // eax@10
5465 Vec4_int_ *v7; // esi@14
5466 int result; // eax@16
5467 char *v9; // esi@16
5468 Vec4_int_ a1; // [sp+Ch] [bp-34h]@10
5469 Vec4_int_ v11; // [sp+1Ch] [bp-24h]@14
5470 Vec4_int_ Dst; // [sp+2Ch] [bp-14h]@1
5471 int v13; // [sp+3Ch] [bp-4h]@1
5472
5473 v2 = _this;
5474 v3 = sub_4382BC(_this);
5475 v13 = sub_4383ED();
5476 v4 = 0;
5477 memset(&Dst, 0, 0x10u);
5478 if ( v3 < 0 )
5479 goto LABEL_19;
5480 if ( (signed int)v2 > 0 )
5481 {
5482 if ( (signed int)v2 > 150 )
5483 {
5484 v5 = (int)a2;
5485 }
5486 else
5487 {
5488 v5 = 4000 * v2;
5489 v4 = 1;
5490 }
5491 }
5492 else
5493 {
5494 v5 = 4000 * dword_4F031C[(unsigned __int16)v3];
5495 }
5496 if ( v13 & 0x10 && !v4 )
5497 {
5498 if ( v2 )
5499 v6 = sub_4AC4FD_get_cpu_clocks_rdtsc(v5, &a1);
5500 else
5501 v6 = sub_4AC33A_get_cpu_clocks_QPC(v5, &a1);
5502 goto LABEL_14;
5503 }
5504 if ( (unsigned __int16)v3 < 3u )
5505 {
5506 LABEL_19:
5507 v7 = &Dst;
5508 goto LABEL_16;
5509 }
5510 v6 = sub_4AC277(v5, &a1);
5511 LABEL_14:
5512 v11.x = v6->x;
5513 v11.y = v6->y;
5514 v11.z = v6->z;
5515 v11.w = v6->w;
5516 v7 = &v11;
5517 LABEL_16:
5518 result = (int)a2;
5519 a2->x = v7->x;
5520 v9 = (char *)&v7->y;
5521 a2->y = *(int *)v9;
5522 v9 += 4;
5523 a2->z = *(int *)v9;
5524 a2->w = *((int *)v9 + 1);
5525 return result;
5526 }
5527 // 4F031C: using guessed type int dword_4F031C[];
5528
5529 //----- (004AC277) --------------------------------------------------------
5530 Vec4_int_ *__thiscall sub_4AC277(unsigned int _this, Vec4_int_ *a2)
5531 {
5532 __debugbreak();
5533 return 0;
5534 /*signed int v2; // esi@1
5535 signed __int16 v4; // bx@3
5536 int v10; // esi@8
5537 int v11; // eax@10
5538 Vec4_int_ *result; // eax@13
5539 Vec4_int_ Dst; // [sp+8h] [bp-30h]@1
5540 LARGE_INTEGER Frequency; // [sp+18h] [bp-20h]@1
5541 LARGE_INTEGER PerformanceCount; // [sp+20h] [bp-18h]@3
5542 LARGE_INTEGER v16; // [sp+28h] [bp-10h]@5
5543 int v17; // [sp+30h] [bp-8h]@1
5544 int v18; // [sp+34h] [bp-4h]@2
5545
5546 v17 = _this;
5547 v2 = -1;
5548 memset(&Dst, 0, 0x10u);
5549 if ( QueryPerformanceFrequency(&Frequency) )
5550 {
5551 v18 = 10;
5552 do
5553 {
5554 QueryPerformanceCounter(&PerformanceCount);
5555 _EAX = -2147483648;
5556 v4 = 4000;
5557 do
5558 {
5559 __asm { bsf ecx, eax }
5560 --v4;
5561 }
5562 while ( v4 );
5563 QueryPerformanceCounter(&v16);
5564 if ( (signed int)v16.s.LowPart - (signed int)PerformanceCount.s.LowPart < (unsigned int)v2 )
5565 v2 = v16.s.LowPart - PerformanceCount.s.LowPart;
5566 --v18;
5567 }
5568 while ( v18 );
5569 v10 = 100000 * v2 / (Frequency.s.LowPart / 0xA);
5570 if ( v10 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
5571 ++v10;
5572 v11 = v17 / (unsigned int)v10;
5573 Dst.z = v17 / (unsigned int)v10;
5574 if ( v17 % (unsigned int)v10 > (unsigned int)v10 >> 1 )
5575 ++v11;
5576 Dst.x = v17;
5577 Dst.y = v10;
5578 Dst.w = v11;
5579 }
5580 result = a2;
5581 a2->x = Dst.x;
5582 a2->y = Dst.y;
5583 a2->z = Dst.z;
5584 a2->w = Dst.w;
5585 return result;*/
5586 }
5587
5588 //----- (004AC33A) --------------------------------------------------------
5589 Vec4_int_ *__thiscall sub_4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1)
5590 {
5591 __debugbreak();
5592 return 0;
5593 /*int v2; // esi@1
5594 int v3; // ebx@1
5595 unsigned __int64 v4; // qax@4
5596 unsigned __int64 v5; // qax@7
5597 DWORD v6; // edi@7
5598 DWORD v7; // eax@7
5599 unsigned int v8; // ecx@10
5600 unsigned __int64 v9; // qax@10
5601 unsigned int v10; // edi@10
5602 int v11; // eax@14
5603 unsigned int v12; // ecx@19
5604 Vec4_int_ *result; // eax@24
5605 int Dst; // [sp+Ch] [bp-4Ch]@1
5606 int v15; // [sp+10h] [bp-48h]@23
5607 int v16; // [sp+14h] [bp-44h]@21
5608 int v17; // [sp+18h] [bp-40h]@21
5609 LARGE_INTEGER Frequency; // [sp+1Ch] [bp-3Ch]@1
5610 LARGE_INTEGER PerformanceCount; // [sp+24h] [bp-34h]@2
5611 LARGE_INTEGER v20; // [sp+2Ch] [bp-2Ch]@2
5612 int v21; // [sp+34h] [bp-24h]@2
5613 int v22; // [sp+38h] [bp-20h]@2
5614 int v23; // [sp+3Ch] [bp-1Ch]@4
5615 int v24; // [sp+40h] [bp-18h]@7
5616 int nPriority; // [sp+44h] [bp-14h]@2
5617 unsigned int v26; // [sp+48h] [bp-10h]@1
5618 unsigned int v27; // [sp+4Ch] [bp-Ch]@1
5619 HANDLE hThread; // [sp+50h] [bp-8h]@1
5620 int v29; // [sp+54h] [bp-4h]@1
5621
5622 v2 = 0;
5623 v3 = 0;
5624 v29 = 0;
5625 v27 = 0;
5626 v26 = 0;
5627 hThread = GetCurrentThread();
5628 memset(&Dst, 0, 0x10u);
5629 if ( QueryPerformanceFrequency(&Frequency) )
5630 {
5631 do
5632 {
5633 ++v29;
5634 v22 = v2;
5635 v21 = v3;
5636 QueryPerformanceCounter(&PerformanceCount);
5637 v20 = PerformanceCount;
5638 nPriority = GetThreadPriority(hThread);
5639 if ( nPriority != 2147483647 )
5640 SetThreadPriority(hThread, 15);
5641 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x32 )
5642 {
5643 QueryPerformanceCounter(&v20);
5644 v4 = __rdtsc();
5645 v23 = v4;
5646 }
5647 PerformanceCount = v20;
5648 do
5649 {
5650 QueryPerformanceCounter(&v20);
5651 v5 = __rdtsc();
5652 v24 = v5;
5653 v6 = v20.s.LowPart;
5654 v7 = PerformanceCount.s.LowPart;
5655 }
5656 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x3E8 );
5657 if ( nPriority != 2147483647 )
5658 {
5659 SetThreadPriority(hThread, nPriority);
5660 v7 = PerformanceCount.s.LowPart;
5661 v6 = v20.s.LowPart;
5662 }
5663 v8 = v24 - v23;
5664 v27 += v24 - v23;
5665 v9 = (100000 * v6 - 100000 * v7) / (Frequency.s.LowPart / 0xA);
5666 v10 = v9;
5667 v26 += v9;
5668 if ( v9 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 )
5669 v10 = v9 + 1;
5670 v3 = v8 / v10;
5671 if ( v8 % v10 > v10 >> 1 )
5672 v3 = v8 / v10 + 1;
5673 v2 = v21;
5674 v11 = v3 + v22 + v21;
5675 }
5676 while ( v29 < 3
5677 || v29 < 20
5678 && ((unsigned int)(3 * v3 - v11) > 3 || (unsigned int)(3 * v21 - v11) > 3 || (unsigned int)(3 * v22 - v11) > 3) );
5679 v12 = 10 * v27 / v26;
5680 if ( 100 * v27 / v26 - 10 * v12 >= 6 )
5681 ++v12;
5682 v16 = v27 / v26;
5683 v17 = v27 / v26;
5684 if ( v12 - 10 * v27 / v26 >= 6 )
5685 v17 = v27 / v26 + 1;
5686 v15 = v26;
5687 Dst = v27;
5688 }
5689 result = a1;
5690 a1->x = Dst;
5691 a1->y = v15;
5692 a1->z = v16;
5693 a1->w = v17;
5694 return result;*/
5695 }
5696
5697 //----- (004AC4FD) --------------------------------------------------------
5698 Vec4_int_ *__thiscall sub_4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1)
5699 {
5700 __debugbreak();
5701 return 0;
5702 /*int v2; // eax@1
5703 int v3; // eax@4
5704 bool v4; // eax@5
5705 unsigned __int64 v5; // kr00_8@8
5706 int v6; // edi@9
5707 int v7; // eax@9
5708 bool v8; // eax@10
5709 unsigned __int64 v9; // kr08_8@13
5710 unsigned int v10; // eax@15
5711 Vec4_int_ *result; // eax@17
5712 int Dst; // [sp+Ch] [bp-2Ch]@1
5713 int v13; // [sp+10h] [bp-28h]@17
5714 int v14; // [sp+14h] [bp-24h]@15
5715 int v15; // [sp+18h] [bp-20h]@17
5716 unsigned int v16; // [sp+1Ch] [bp-1Ch]@8
5717 unsigned int v17; // [sp+20h] [bp-18h]@8
5718 unsigned int v18; // [sp+24h] [bp-14h]@13
5719 int nPriority; // [sp+28h] [bp-10h]@1
5720 __int64 v20; // [sp+2Ch] [bp-Ch]@1
5721 int v21; // [sp+34h] [bp-4h]@3
5722
5723 HIDWORD(v20) = GetCurrentThread();
5724 memset(&Dst, 0, 0x10u);
5725 v2 = GetThreadPriority(HIDWORD(v20));
5726 nPriority = v2;
5727 if ( v2 != 0x7FFFFFFF )
5728 SetThreadPriority(HIDWORD(v20), v2 + 1);
5729 __outbyte(0x70u, 0);
5730 v21 = __inbyte(0x71u);
5731 do
5732 {
5733 __outbyte(0x70u, 0);
5734 LODWORD(v20) = __inbyte(0x71u);
5735 v3 = v20 - v21;
5736 if ( (signed int)v20 >= v21 )
5737 v4 = v3 > 0;
5738 else
5739 v4 = v3 + 10;
5740 }
5741 while ( !v4 );
5742 v5 = __rdtsc();
5743 v16 = HIDWORD(v5);
5744 v17 = v5;
5745 do
5746 {
5747 __outbyte(0x70u, 0);
5748 v21 = __inbyte(0x71u);
5749 v6 = v21;
5750 v7 = v21 - v20;
5751 if ( v21 >= (signed int)v20 )
5752 v8 = v7 > 0;
5753 else
5754 v8 = v7 + 10;
5755 }
5756 while ( !v8 );
5757 v9 = __rdtsc();
5758 v18 = HIDWORD(v9);
5759 v21 = v9;
5760 if ( nPriority != 0x7FFFFFFF )
5761 SetThreadPriority(HIDWORD(v20), nPriority);
5762 nPriority = v21;
5763 *(__int64 *)((char *)&v20 + 4) = __PAIR__(v18, v21) - __PAIR__(v16, v17);
5764 Dst = HIDWORD(v20);
5765 v10 = HIDWORD(v20) / 0xF4240;
5766 v14 = HIDWORD(v20) / 0xF4240;
5767 if ( HIDWORD(v20) / 0x186A0 - 10 * HIDWORD(v20) / 0xF4240 >= 6 )
5768 ++v10;
5769 v15 = v10;
5770 result = a1;
5771 v13 = 1000000 * v6 - 1000000 * v20;
5772 a1->x = Dst;
5773 a1->y = v13;
5774 a1->z = v14;
5775 a1->w = v15;
5776 return result;*/
5777 }
5778 5391
5779 5392
5780 5393
5781 //----- (004AD504) -------------------------------------------------------- 5394 //----- (004AD504) --------------------------------------------------------
5782 int __fastcall sub_4AD504(signed int sFaceID) 5395 int __fastcall sub_4AD504(signed int sFaceID)