comparison LightmapBuilder.cpp @ 1669:bd28d08e2c75

Merge
author Ritor1
date Tue, 17 Sep 2013 22:55:48 +0600
parents 2c71fa8913d2
children c1c74df0a33e
comparison
equal deleted inserted replaced
1668:d17247968bd6 1669:bd28d08e2c75
4 #include "Outdoor.h" 4 #include "Outdoor.h"
5 #include "Outdoor_stuff.h" 5 #include "Outdoor_stuff.h"
6 #include "Log.h" 6 #include "Log.h"
7 #include "ErrorHandling.h" 7 #include "ErrorHandling.h"
8 8
9 #include "OutdoorCamera.h"
10 #include "Lights.h" 9 #include "Lights.h"
11 10
12 #include "mm7_data.h" 11 #include "mm7_data.h"
13 12
14 13
1310 } 1309 }
1311 } 1310 }
1312 ++*v53; 1311 ++*v53;
1313 return 1; 1312 return 1;
1314 } 1313 }
1315 // 4E94D2: using guessed type char _4E94D2_light_type;
1316
1317 //----- (0045D3C7) --------------------------------------------------------
1318 bool LightmapBuilder::_45D3C7(struct Polygon *a1)
1319 {
1320 LightmapBuilder *v2; // ebx@1
1321 struct Polygon *result; // eax@1
1322 float v4; // ecx@2
1323 Span *i; // edi@5
1324
1325 v2 = this;
1326 result = (struct Polygon *)a1->prolly_head;
1327 if ( result && (v4 = result->field_4, *(int *)&v4) != 0 && *(unsigned int *)(LODWORD(v4) + 60) )
1328 {
1329 for ( i = a1->prolly_head; ; i = i->pNext )
1330 {
1331 result = i->pParent;
1332 if ( result->field_108 )
1333 result = (struct Polygon *)_45D426(
1334 i,
1335 a1->pEdgeList1,
1336 a1->uEdgeList1Size,
1337 (Edge *)a1->pEdgeList2,
1338 a1->uEdgeList2Size);
1339 if ( a1->prolly_tail == i )
1340 break;
1341 }
1342 LOBYTE(result) = 1;
1343 }
1344 else
1345 {
1346 LOBYTE(result) = 0;
1347 }
1348 return (bool)result;
1349 }
1350
1351 //----- (0045D426) --------------------------------------------------------
1352 int LightmapBuilder::_45D426(Span *a1, Edge **a2, unsigned int a3, Edge *a4, int a5)
1353 {
1354 int v6; // edi@1
1355 signed int v7; // ebx@3
1356 signed int v8; // ecx@3
1357 Span *v9; // esi@3
1358 double v10; // st7@4
1359 Edge *v11; // edx@5
1360 double v12; // st7@11
1361 int v13; // edx@12
1362 int v14; // ebx@17
1363 Edge *v15; // edi@17
1364 float v16; // ST04_4@17
1365 float v17; // ST04_4@17
1366 double v18; // st7@17
1367 int result; // eax@19
1368 //double v20; // ST14_8@20
1369 //double v21; // ST14_8@20
1370 double v22; // st7@20
1371 int v23; // ecx@20
1372 double v24; // st6@20
1373 double v25; // st7@23
1374 double v26; // st7@28
1375 __int16 v27; // fps@28
1376 char v28; // c0@28
1377 char v29; // c2@28
1378 char v30; // c3@28
1379 double v31; // st7@29
1380 double v32; // st7@30
1381 __int16 v33; // fps@30
1382 char v34; // c0@30
1383 char v35; // c2@30
1384 char v36; // c3@30
1385 LightmapBuilder *this_4; // [sp+14h] [bp-8h]@1
1386 signed int v38; // [sp+18h] [bp-4h]@3
1387 float a1a; // [sp+24h] [bp+8h]@20
1388 float a2a; // [sp+28h] [bp+Ch]@17
1389 float a3a; // [sp+2Ch] [bp+10h]@17
1390 float a5a; // [sp+34h] [bp+18h]@20
1391 float a5b; // [sp+34h] [bp+18h]@20
1392
1393 v6 = 0;
1394 this_4 = this;
1395 if ( a5 && a3 )
1396 {
1397 v7 = -1;
1398 v8 = 0;
1399 v9 = a1;
1400 v38 = -1;
1401 if ( (signed int)a3 > 0 )
1402 {
1403 v10 = (double)a1->field_A;
1404 while ( 1 )
1405 {
1406 v11 = a2[v8];
1407 if ( v10 >= v11->field_2C )
1408 {
1409 if ( v10 <= v11->field_30 )
1410 break;
1411 }
1412 ++v8;
1413 if ( v8 >= (signed int)a3 )
1414 goto LABEL_10;
1415 }
1416 v38 = v8;
1417 }
1418 LABEL_10:
1419 if ( a5 > 0 )
1420 {
1421 v12 = (double)a1->field_A;
1422 while ( 1 )
1423 {
1424 v13 = *((unsigned int *)&a4->field_0 + v6);
1425 if ( v12 >= *(float *)(v13 + 44) )
1426 {
1427 if ( v12 <= *(float *)(v13 + 48) )
1428 break;
1429 }
1430 ++v6;
1431 if ( v6 >= a5 )
1432 goto LABEL_17;
1433 }
1434 v7 = v6;
1435 }
1436 LABEL_17:
1437 v14 = *((unsigned int *)&a4->field_0 + v7);
1438 v15 = a2[v38];
1439 v16 = (double)a1->field_A;
1440 a3a = _45D643(a2[v38], v16);
1441 v17 = (double)a1->field_A;
1442 v18 = _45D643((Edge *)v14, v17);
1443 a2a = v18;
1444 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x80 )
1445 {
1446 HIWORD(result) = HIWORD(a3a);
1447 a1->field_14 = v18;
1448 a1->field_10 = a3a;
1449 }
1450 else
1451 {
1452 a5a = ((double)a1->field_A - v15->field_2C) * v15->field_4 + v15->field_24 - 0.5;
1453 //v20 = a5a + 6.7553994e15;
1454 //a5b = (double)SLODWORD(v20);
1455 a5b = (double)floorf(a5a + 0.5f);
1456 a1a = ((double)a1->field_A - *(float *)(v14 + 44)) * *(float *)(v14 + 4) + *(float *)(v14 + 36) + 0.5;
1457 //v21 = a1a + 6.7553994e15;
1458 //v22 = (double)SLODWORD(v21);
1459 v22 = (double)floorf(a1a + 0.5f);
1460 result = v9->field_8;
1461 v23 = v9->field_C;
1462 v24 = -((a3a - a2a) / (v22 - a5b));
1463 v9->field_10 = ((double)result - a5b) * v24 + a3a;
1464 v9->field_14 = a2a - (v22 - (double)(result + v23)) * v24;
1465 }
1466 if ( v9->field_10 < 0.0 || v9->field_10 <= 1.0 )
1467 {
1468 if ( v9->field_10 >= 0.0 )
1469 v25 = v9->field_10;
1470 else
1471 v25 = 0.0;
1472 }
1473 else
1474 {
1475 v25 = 1.0;
1476 }
1477 v9->field_10 = v25;
1478 __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
1479 if ( v9->field_14 < 0.0
1480 || (v26 = v9->field_14,
1481 //UNDEF(v27),
1482 v28 = 1.0 < v26,
1483 v29 = 0,
1484 v30 = 1.0 == v26,
1485 BYTE1(result) = HIBYTE(v27),
1486 v26 <= 1.0) )
1487 {
1488 v32 = v9->field_14;
1489 //UNDEF(v33);
1490 v34 = 0.0 < v32;
1491 v35 = 0;
1492 v36 = 0.0 == v32;
1493 __debugbreak(); // warning C4700: uninitialized local variable 'v33' used
1494 BYTE1(result) = HIBYTE(v33);
1495 if ( v32 >= 0.0 )
1496 v31 = v9->field_14;
1497 else
1498 v31 = 0.0;
1499 }
1500 else
1501 {
1502 v31 = 1.0;
1503 }
1504 v9->field_14 = v31;
1505 LOBYTE(result) = 1;
1506 }
1507 else
1508 {
1509 LOBYTE(result) = 0;
1510 }
1511 return result;
1512 }
1513 // 4D864C: using guessed type char byte_4D864C;
1514
1515 //----- (0045D643) --------------------------------------------------------
1516 double LightmapBuilder::_45D643(Edge *a1, float a2)
1517 {
1518 double result; // st7@1
1519
1520 result = (a1->field_1C - a1->field_20) * -1.0 / (a1->field_30 - a1->field_2C) * (a2 - a1->field_2C) + a1->field_1C;
1521 if ( result < 0.0 || result <= 1.0 )
1522 {
1523 if ( result < 0.0 )
1524 result = 0.0;
1525 }
1526 else
1527 {
1528 result = 1.0;
1529 }
1530 return result;
1531 }
1532 1314
1533 //----- (0045D698) -------------------------------------------------------- 1315 //----- (0045D698) --------------------------------------------------------
1534 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) 1316 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2)
1535 { 1317 {
1536 bool result; // eax@1 1318 bool result; // eax@1
1739 uint uLightmapColorB = floorf(uLightmapColorMaskB * pLightmap->fBrightness * pColorMult->z + 0.5f); 1521 uint uLightmapColorB = floorf(uLightmapColorMaskB * pLightmap->fBrightness * pColorMult->z + 0.5f);
1740 1522
1741 uint uLightmapColor = uLightmapColorB | (uLightmapColorMaskG << 8) | (uLightmapColorMaskR << 16); 1523 uint uLightmapColor = uLightmapColorB | (uLightmapColorMaskG << 8) | (uLightmapColorMaskR << 16);
1742 1524
1743 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) 1525 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
1744 v10 = (double)pOutdoorCamera->shading_dist_mist; 1526 v10 = (double)pODMRenderParams->shading_dist_mist;
1745 else 1527 else
1746 v10 = 16192.0; 1528 v10 = 16192.0;
1747 v14 = 1.0 / v10; 1529 v14 = 1.0 / v10;
1748 1530
1749 for (uint i = 0; i < pLightmap->uNumVertices; ++i) 1531 for (uint i = 0; i < pLightmap->uNumVertices; ++i)