Mercurial > mm7
comparison LightmapBuilder.cpp @ 2247:529bf95fb0d7
Merge
author | Grumpy7 |
---|---|
date | Wed, 26 Feb 2014 01:15:58 +0100 |
parents | 8817c398b792 |
children | 47bcb700b74b aff7a7b072b7 |
comparison
equal
deleted
inserted
replaced
2246:0be4f17b7986 | 2247:529bf95fb0d7 |
---|---|
63 { | 63 { |
64 for (uint i = 0; i < uNumVertices; ++i) | 64 for (uint i = 0; i < uNumVertices; ++i) |
65 memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft)); | 65 memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft)); |
66 | 66 |
67 //__debugbreak(); | 67 //__debugbreak(); |
68 if (pGame->pIndoorCameraD3D->_437376( | 68 if (pGame->pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1) |
69 a3, | |
70 static_69B140, | |
71 &uNumVertices) == 1) | |
72 { | 69 { |
73 if ( !uNumVertices ) | 70 if ( !uNumVertices ) |
74 return false; | 71 return false; |
75 a9 = static_69B140; | 72 a9 = static_69B140; |
76 } | 73 } |
79 static stru314 static_69B110; | 76 static stru314 static_69B110; |
80 static_69B110.field_4.x = a3->face_plane.vNormal.x; | 77 static_69B110.field_4.x = a3->face_plane.vNormal.x; |
81 static_69B110.field_4.y = a3->face_plane.vNormal.y; | 78 static_69B110.field_4.y = a3->face_plane.vNormal.y; |
82 static_69B110.field_4.z = a3->face_plane.vNormal.z; | 79 static_69B110.field_4.z = a3->face_plane.vNormal.z; |
83 static_69B110.dist = a3->face_plane.dist; | 80 static_69B110.dist = a3->face_plane.dist; |
84 if (!pGame->pIndoorCameraD3D->GetFacetOrientation( | 81 if (!pGame->pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.field_4, |
85 a3->polygonType, | 82 &static_69B110.field_10, &static_69B110.field_1C)) |
86 &static_69B110.field_4, | |
87 &static_69B110.field_10, | |
88 &static_69B110.field_1C)) | |
89 { | 83 { |
90 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); | 84 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); |
91 ExitProcess(0); | 85 ExitProcess(0); |
92 } | 86 } |
93 | 87 |
102 uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; | 96 uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; |
103 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB; | 97 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB; |
104 if (!uColor) | 98 if (!uColor) |
105 uColor = 0x00FFFFF; | 99 uColor = 0x00FFFFF; |
106 | 100 |
107 if (!_45BE86_build_light_polygon( | 101 if (!_45BE86_build_light_polygon(&pos, a2->_blv_lights_radii[i], uColor, a2->_blv_lights_light_dot_faces[i], |
108 &pos, | 102 a2->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) ) |
109 a2->_blv_lights_radii[i], | |
110 uColor, | |
111 a2->_blv_lights_light_dot_faces[i], | |
112 a2->_blv_lights_types[i], | |
113 &static_69B110, | |
114 uNumVertices, | |
115 a9, | |
116 uClipFlag) ) | |
117 { | 103 { |
118 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); | 104 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); |
119 } | 105 } |
120 } | 106 } |
121 return true; | 107 return true; |
464 } | 450 } |
465 | 451 |
466 //----- (0045C6D6) -------------------------------------------------------- | 452 //----- (0045C6D6) -------------------------------------------------------- |
467 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) | 453 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) |
468 { | 454 { |
469 Lightmap *v4; // edi@1 | |
470 signed int v5; // ebx@1 | |
471 signed int v6; // esi@1 | 455 signed int v6; // esi@1 |
472 RenderVertexSoft *v7; // ecx@2 | |
473 char *v8; // edx@4 | |
474 double v9; // st7@6 | 456 double v9; // st7@6 |
475 double v10; // st6@10 | 457 double v10; // st6@10 |
476 double v11; // st5@14 | 458 double v11; // st5@14 |
477 double v12; // st7@17 | 459 double v12; // st7@17 |
478 RenderVertexSoft *v13; // eax@21 | |
479 int v15; // [sp+Ch] [bp-8h]@1 | 460 int v15; // [sp+Ch] [bp-8h]@1 |
480 float v16; // [sp+10h] [bp-4h]@1 | 461 float v16; // [sp+10h] [bp-4h]@1 |
481 int pLightmapa; // [sp+24h] [bp+10h]@3 | 462 |
482 | |
483 v4 = pLightmap; | |
484 v5 = 0; | |
485 v6 = -1; | 463 v6 = -1; |
486 v16 = 3.4028235e38; | 464 v16 = 3.4028235e38; |
487 v15 = 0; | 465 v15 = 0; |
488 if ( (signed int)pLightmap->uNumVertices > 0 ) | 466 if ( (signed int)pLightmap->uNumVertices > 0 ) |
489 { | 467 { |
490 v7 = pLightmap->pVertices; | 468 for ( uint i = 0; i < (signed int)pLightmap->uNumVertices; ++i ) |
491 do | 469 { |
492 { | |
493 pLightmapa = 0; | |
494 if ( a2 > 0 ) | 470 if ( a2 > 0 ) |
495 { | 471 { |
496 v8 = (char *)&a3->vWorldPosition.z; | 472 for ( uint j = 0; j < a2; ++j ) |
497 do | |
498 { | 473 { |
499 if ( v7->vWorldPosition.x <= (double)*((float *)v8 - 2) ) | 474 if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x ) |
500 v9 = *((float *)v8 - 2) - v7->vWorldPosition.x; | 475 v9 = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x; |
501 else | 476 else |
502 v9 = v7->vWorldPosition.x - *((float *)v8 - 2); | 477 v9 = pLightmap->pVertices[i].vWorldPosition.x - a3[j].vWorldPosition.x; |
503 if ( v9 < 2.0 ) | 478 if ( v9 < 2.0 ) |
504 { | 479 { |
505 v10 = v7->vWorldPosition.y <= (double)*((float *)v8 - 1) ? *((float *)v8 - 1) - v7->vWorldPosition.y : v7->vWorldPosition.y - *((float *)v8 - 1); | 480 v10 = pLightmap->pVertices[i].vWorldPosition.y <= (double)a3[j].vWorldPosition.y |
481 ? a3[j].vWorldPosition.y - pLightmap->pVertices[i].vWorldPosition.y | |
482 : pLightmap->pVertices[i].vWorldPosition.y - a3[j].vWorldPosition.y; | |
506 if ( v10 < 2.0 ) | 483 if ( v10 < 2.0 ) |
507 { | 484 { |
508 v11 = v7->vWorldPosition.z <= (double)*(float *)v8 ? *(float *)v8 - v7->vWorldPosition.z : v7->vWorldPosition.z - *(float *)v8; | 485 v11 = pLightmap->pVertices[i].vWorldPosition.z <= (double)a3[j].vWorldPosition.z |
486 ? a3[j].vWorldPosition.z - pLightmap->pVertices[i].vWorldPosition.z | |
487 : pLightmap->pVertices[i].vWorldPosition.z - a3[j].vWorldPosition.z; | |
509 if ( v11 < 2.0 ) | 488 if ( v11 < 2.0 ) |
510 { | 489 { |
511 v12 = v9 + v11 + v10; | 490 v12 = v9 + v11 + v10; |
512 if ( v12 < v16 ) | 491 if ( v12 < v16 ) |
513 { | 492 { |
514 v16 = v12; | 493 v16 = v12; |
515 v6 = pLightmapa; | 494 v6 = j; |
516 } | 495 } |
517 } | 496 } |
518 } | 497 } |
519 } | 498 } |
520 ++pLightmapa; | |
521 v8 += 48; | |
522 } | 499 } |
523 while ( pLightmapa < a2 ); | |
524 if ( v6 != -1 ) | 500 if ( v6 != -1 ) |
525 { | 501 { |
526 v13 = &a3[v6]; | |
527 ++v15; | 502 ++v15; |
528 v7->vWorldPosition.x = v13->vWorldPosition.x; | 503 pLightmap->pVertices[i].vWorldPosition.x = a3[v6].vWorldPosition.x; |
529 v7->vWorldPosition.y = v13->vWorldPosition.y; | 504 pLightmap->pVertices[i].vWorldPosition.y = a3[v6].vWorldPosition.y; |
530 v7->vWorldPosition.z = v13->vWorldPosition.z; | 505 pLightmap->pVertices[i].vWorldPosition.z = a3[v6].vWorldPosition.z; |
531 } | 506 } |
532 } | 507 } |
533 v6 = -1; | 508 v6 = -1; |
534 ++v5; | |
535 ++v7; | |
536 v16 = 3.4028235e38; | 509 v16 = 3.4028235e38; |
537 } | 510 } |
538 while ( v5 < (signed int)v4->uNumVertices ); | |
539 } | 511 } |
540 return v15; | 512 return v15; |
541 } | 513 } |
542 | 514 |
543 //----- (0045C7F6) -------------------------------------------------------- | 515 //----- (0045C7F6) -------------------------------------------------------- |