comparison DecalBuilder.cpp @ 87:c0cf9393af64

Слияние
author Ritor1
date Mon, 29 Oct 2012 09:28:08 +0600
parents fdacbc653945
children
comparison
equal deleted inserted replaced
86:c83d06692295 87:c0cf9393af64
1 #include "DecalBuilder.h" 1 #include "DecalBuilder.h"
2 #include "Game.h" 2 #include "Game.h"
3 #include "Time.h" 3 #include "Time.h"
4 #include "stru314.h" 4 #include "stru314.h"
5 #include "Outdoor.h" 5 #include "Outdoor.h"
6 #include "Log.h"
6 7
7 #include "mm7_data.h" 8 #include "mm7_data.h"
8 //#include "MM7.h"
9 9
10 10
11 11
12 12
13 13
14 struct DecalBuilder *pDecalBuilder = new DecalBuilder; 14 struct DecalBuilder *pDecalBuilder = new DecalBuilder;
15 struct BloodsplatContainer *pBloodsplatContainer = new BloodsplatContainer; 15 struct BloodsplatContainer *pBloodsplatContainer = new BloodsplatContainer;
16 16
17 17
18 //----- (0043B570) -------------------------------------------------------- 18 //----- (0043B570) --------------------------------------------------------
19 double DecalBuilder_stru0::_43B570() 19 double DecalBuilder_stru0::_43B570_get_color_mult_by_time()
20 { 20 {
21 DecalBuilder_stru0 *v1; // esi@1
22 double result; // st7@3 21 double result; // st7@3
23 22
24 v1 = this; 23 if (field_1C_flags & 1)
25 if ( this->field_1C_flags & 1 ) 24 {
26 { 25 if ((field_20_time - pEventTimer->Time() + 384) / 384.0 >= 0.0)
27 if ( (double)(signed __int64)(this->field_20_time - pEventTimer->Time() + 384) * 0.0026041667 >= 0.0 ) 26 result = (field_20_time - pEventTimer->Time() + 384) / 384.0;
28 result = (double)(signed __int64)(v1->field_20_time - pEventTimer->Time() + 384) * 0.0026041667;
29 else 27 else
30 result = 0.0; 28 result = 0.0;
31 } 29 }
32 else 30 else
33 { 31 {
107 } 105 }
108 std__vector_pDecals_size = 0; 106 std__vector_pDecals_size = 0;
109 } 107 }
110 108
111 //----- (0049B540) -------------------------------------------------------- 109 //----- (0049B540) --------------------------------------------------------
112 char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, int a7, char a8, int a9) 110 char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID)
113 { 111 {
114 char *v9; // eax@3 112 char *v9; // eax@3
115 signed int v10; // ecx@3 113 signed int v10; // ecx@3
116 RenderVertexSoft *v11; // eax@10 114 RenderVertexSoft *v11; // eax@10
117 unsigned int v12; // edx@10 115 unsigned int v12; // edx@10
146 int v42; // [sp+38h] [bp-10h]@21 144 int v42; // [sp+38h] [bp-10h]@21
147 int v43; // [sp+3Ch] [bp-Ch]@21 145 int v43; // [sp+3Ch] [bp-Ch]@21
148 DecalBuilder *thisa; // [sp+40h] [bp-8h]@1 146 DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
149 RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8 147 RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
150 148
149 __debugbreak();
150
151 auto a9 = uSectorID;
152
151 thisa = this; 153 thisa = this;
152 if ( !a5 ) 154 if ( !a5 )
153 return 0; 155 return 0;
154 156
155 static RenderVertexSoft static_AE4F90[64]; 157 static RenderVertexSoft static_AE4F90[64];
200 } 202 }
201 else 203 else
202 { 204 {
203 v16 = a4; 205 v16 = a4;
204 } 206 }
205 v18 = v16->vNormal.z; 207 v18 = v16->face_plane.vNormal.z;
206 v19 = v16->vNormal.y; 208 v19 = v16->face_plane.vNormal.y;
207 v20 = v16->vNormal.x; 209 v20 = v16->face_plane.vNormal.x;
208 v37 = (int)&stru_AE4F7C; 210 v37 = (int)&static_AE4F60.field_1C;
209 stru_AE4F64.y = v19; 211 static_AE4F60.field_4.y = v19;
210 stru_AE4F64.x = v20; 212 static_AE4F60.field_4.x = v20;
211 LODWORD(v36) = (DWORD)&stru_AE4F70; 213 LODWORD(v36) = (DWORD)&static_AE4F60.field_10;
212 stru_AE4F64.z = v18; 214 static_AE4F60.field_4.z = v18;
213 dword_AE4F88 = LODWORD(v16->field_10); 215 static_AE4F60.dist = v16->face_plane.dist;
214 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation( 216 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
215 v16->field_14, 217 v16->polygonType,
216 &stru_AE4F64, 218 &static_AE4F60.field_4,
217 &stru_AE4F70, 219 &static_AE4F60.field_10,
218 &stru_AE4F7C) ) 220 &static_AE4F60.field_1C) )
219 { 221 {
220 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0); 222 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
221 } 223 }
222 a7 = 0; 224 int _a7 = 0;
223 if ( thisa->uNumDecals > 0 ) 225 if ( thisa->uNumDecals > 0 )
224 { 226 {
225 a6 = (RenderVertexSoft *)thisa->std__vector_30B00C; 227 a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
226 do 228 do
227 { 229 {
228 v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)]; 230 v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)];
229 *(float *)&v37 = v21->z; 231 *(float *)&v37 = v21->z;
230 v36 = v21->y; 232 v36 = v21->y;
231 v35 = v21->x; 233 v35 = v21->x;
232 v22 = sub_43F5C8(a2, a9, v35, v36, *(float *)&v37); 234 v22 = _43F5C8_get_point_light_level_with_respect_to_lights(a2, a9, v35, v36, *(float *)&v37);
233 v23 = v21->b; 235 v23 = v21->b;
234 v24 = v21->x; 236 v24 = v21->x;
235 v42 = v22; 237 v42 = v22;
236 BYTE3(v22) = 0; 238 BYTE3(v22) = 0;
237 *(short *)((char *)&v22 + 1) = v21->r; 239 *(short *)((char *)&v22 + 1) = v21->r;
240 v25 = (signed __int64)v24; 242 v25 = (signed __int64)v24;
241 v26 = v21->z; 243 v26 = v21->z;
242 v27 = (signed __int64)v21->y; 244 v27 = (signed __int64)v21->y;
243 v37 = a8; 245 v37 = a8;
244 v40 = (signed __int64)v26; 246 v40 = (signed __int64)v26;
245 v28 = *(float *)&v21->field_14; 247 v28 = v21->dot_dist;
246 LODWORD(v36) = (uint32)a11; 248 LODWORD(v36) = (uint32)a11;
247 a5a = v25; 249 a5a = v25;
248 v39 = v27; 250 v39 = v27;
249 LODWORD(v35) = a5; 251 LODWORD(v35) = a5;
250 v34 = &static_AE4F60; 252 v34 = &static_AE4F60;
266 a11, 268 a11,
267 a8) ) 269 a8) )
268 { 270 {
269 MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0); 271 MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
270 } 272 }
271 ++a7; 273 ++_a7;
272 a6 = (RenderVertexSoft *)((char *)a6 + 4); 274 a6 = (RenderVertexSoft *)((char *)a6 + 4);
273 } 275 }
274 while ( a7 < v31->uNumDecals ); 276 while ( _a7 < v31->uNumDecals );
275 } 277 }
276 return 1; 278 return 1;
277 } 279 }
278 // AE4F88: using guessed type int dword_AE4F88;
279 // AE5B90: using guessed type char static_init_flag__AE4F90_bit1__AE4F60_bit2;
280 280
281 //----- (0049B790) -------------------------------------------------------- 281 //----- (0049B790) --------------------------------------------------------
282 char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, int a7, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags) 282 char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
283 { 283 {
284 DecalBuilder *v12; // esi@1 284 DecalBuilder *v12; // esi@1
285 Decal *v13; // edi@2 285 Decal *v13; // edi@2
286 char *v14; // eax@2 286 char *v14; // eax@2
287 double v15; // st7@4 287 double v15; // st7@4
374 do 374 do
375 { 375 {
376 v28 = v18->field_4.y * *(float *)v25 376 v28 = v18->field_4.y * *(float *)v25
377 + *((float *)v25 - 1) * v18->field_4.x 377 + *((float *)v25 - 1) * v18->field_4.x
378 + *((float *)v25 + 1) * v18->field_4.z 378 + *((float *)v25 + 1) * v18->field_4.z
379 + *(float *)&v18->field_28; 379 + v18->dist;
380 *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x; 380 *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
381 *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y; 381 *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
382 v25 += 48; 382 v25 += 48;
383 --v26; 383 --v26;
384 *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z; 384 *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
385 } 385 }
386 while ( v26 ); 386 while ( v26 );
387 v13->field_C10 = a7; 387 v13->uColorMultiplier = uColorMultiplier;
388 v40 = (unsigned int *)&v13->uNumVertices; 388 v40 = (unsigned int *)&v13->uNumVertices;
389 v39 = v13->pVertices; 389 v39 = v13->pVertices;
390 v13->uNumVertices = 4; 390 v13->uNumVertices = 4;
391 v13->field_C14 = a2; 391 v13->field_C14 = a2;
392 v29 = v18->field_4.z; 392 v29 = v18->field_4.z;
401 v32 = a8; 401 v32 = a8;
402 v40 = *(unsigned int **)a6; 402 v40 = *(unsigned int **)a6;
403 v39 = a8; 403 v39 = a8;
404 pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40); 404 pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
405 v40 = 0; 405 v40 = 0;
406 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0); 406 pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
407 if ( !(uClipFlags & 1) ) 407 if ( !(uClipFlags & 1) )
408 { 408 {
409 LABEL_19: 409 LABEL_19:
410 ++v12->field_308008; 410 ++v12->field_308008;
411 v34 = 1024; 411 v34 = 1024;
420 { 420 {
421 if ( uClipFlags & 2 ) 421 if ( uClipFlags & 2 )
422 { 422 {
423 v40 = (unsigned int *)&a8; 423 v40 = (unsigned int *)&a8;
424 v39 = v12->pVertices; 424 v39 = v12->pVertices;
425 pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8); 425 pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
426 LABEL_14: 426 LABEL_14:
427 v40 = v31; 427 v40 = v31;
428 v39 = v12->pVertices; 428 v39 = v12->pVertices;
429 pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31); 429 pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
430 goto LABEL_18; 430 goto LABEL_18;
431 } 431 }
432 if ( uClipFlags & 4 ) 432 if ( uClipFlags & 4 )
433 { 433 {
434 v40 = (unsigned int *)&a8; 434 v40 = (unsigned int *)&a8;
435 v39 = v12->pVertices; 435 v39 = v12->pVertices;
436 pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8); 436 pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
437 goto LABEL_14; 437 goto LABEL_14;
438 } 438 }
439 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258"; 439 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
440 v35 = "Undefined clip flag specified"; 440 v35 = "Undefined clip flag specified";
441 } 441 }
453 } 453 }
454 return result; 454 return result;
455 } 455 }
456 456
457 //----- (0049BBBD) -------------------------------------------------------- 457 //----- (0049BBBD) --------------------------------------------------------
458 char DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID) 458 bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
459 { 459 {
460 int v2; // edi@1
461 unsigned int v3; // ebx@1
462 BLVFace *v4; // esi@2
463 unsigned int v5; // eax@2
464 char *v6; // edx@5
465 double v7; // st7@12 460 double v7; // st7@12
466 461
467 v2 = 0; 462 if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
468 this->uNumDecals = 0; 463 return true;
469 v3 = pBloodsplatContainer->std__vector_pBloodsplats_size; 464
470 if ( pBloodsplatContainer->std__vector_pBloodsplats_size ) 465 auto pFace = &pIndoor->pFaces[uFaceID];
471 { 466
472 v4 = &pIndoor->pFaces[uFaceID]; 467 if (pFace->uAttributes & 0x400000)
473 v5 = v4->uAttributes; 468 return true;
474 if ( !(v5 & 0x400000) ) 469 if (pFace->Animated())
475 { 470 return true;
476 if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 ) 471
472 for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
473 {
474 auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
475 if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x &&
476 pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x &&
477 pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y &&
478 pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y &&
479 pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z &&
480 pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z)
481 {
482 v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z +
483 pFace->pFacePlane.vNormal.y * pBloodsplat->y +
484 pFace->pFacePlane.vNormal.x * pBloodsplat->x +
485 pFace->pFacePlane.dist;
486 if (v7 <= pBloodsplat->radius)
477 { 487 {
478 v6 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y; 488 pBloodsplat->dot_dist = v7;
479 do 489 std__vector_30B00C[uNumDecals++] = i;
480 {
481 if ( (double)v4->pBounding.x1 - *((float *)v6 + 2) < *((float *)v6 - 1) )
482 {
483 if ( (double)v4->pBounding.x2 + *((float *)v6 + 2) > *((float *)v6 - 1) )
484 {
485 if ( (double)v4->pBounding.y1 - *((float *)v6 + 2) < *(float *)v6 )
486 {
487 if ( (double)v4->pBounding.y2 + *((float *)v6 + 2) > *(float *)v6 )
488 {
489 if ( (double)v4->pBounding.z1 - *((float *)v6 + 2) < *((float *)v6 + 1) )
490 {
491 if ( (double)v4->pBounding.z2 + *((float *)v6 + 2) > *((float *)v6 + 1) )
492 {
493 v7 = v4->pFacePlane.vNormal.z * *((float *)v6 + 1)
494 + v4->pFacePlane.vNormal.y * *(float *)v6
495 + v4->pFacePlane.vNormal.x * *((float *)v6 - 1)
496 + v4->pFacePlane.dist;
497 if ( v7 <= *((float *)v6 + 2) )
498 {
499 *((float *)v6 + 3) = v7;
500 this->std__vector_30B00C[this->uNumDecals++] = v2;
501 }
502 }
503 }
504 }
505 }
506 }
507 }
508 ++v2;
509 v6 += 40;
510 }
511 while ( v2 < (signed int)v3 );
512 } 490 }
513 } 491 }
514 } 492 }
515 return 1; 493
494 return true;
516 } 495 }
517 496
518 //----- (0049BCEB) -------------------------------------------------------- 497 //----- (0049BCEB) --------------------------------------------------------
519 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace) 498 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace)
520 { 499 {
530 v2 = 0; 509 v2 = 0;
531 this->uNumDecals = 0; 510 this->uNumDecals = 0;
532 v10 = pBloodsplatContainer->std__vector_pBloodsplats_size; 511 v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
533 if ( pBloodsplatContainer->std__vector_pBloodsplats_size ) 512 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
534 { 513 {
535 v3 = pFace->uFaceAttributes; 514 v3 = pFace->uAttributes;
536 if ( !(v3 & 0x400000) ) 515 if ( !(v3 & 0x400000) )
537 { 516 {
538 if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 ) 517 if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
539 { 518 {
540 v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y; 519 v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
712 LOBYTE(result) = 1; 691 LOBYTE(result) = 1;
713 return result; 692 return result;
714 } 693 }
715 694
716 //----- (0049C095) -------------------------------------------------------- 695 //----- (0049C095) --------------------------------------------------------
717 void DecalBuilder::DrawDecal(Decal *pDecal, float a2) 696 void DecalBuilder::DrawDecal(Decal *pDecal, float z_bias)
718 { 697 {
719 Decal *v3; // edi@1
720 double v4; // st7@3
721 double v5; // st7@5
722 int v6; // eax@5
723 unsigned __int8 v7; // zf@5
724 unsigned __int8 v8; // sf@5
725 char *v9; // esi@6
726 int v10; // ebx@6
727 int v11; // eax@8
728 int v12; // edx@8
729 int v13; // eax@8
730 int v14; // ecx@8
731 double v15; // st7@9
732 int v16; // eax@12
733 double v17; // st7@12
734 int v18; // eax@12
735 unsigned __int8 v19; // of@12
736 HRESULT v20; // eax@17
737 signed int v21; // [sp+Ch] [bp-864h]@15 698 signed int v21; // [sp+Ch] [bp-864h]@15
738 const char *v22; // [sp+10h] [bp-860h]@15 699 RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
739 int v23; // [sp+14h] [bp-85Ch]@15 700
740 unsigned int v24; // [sp+18h] [bp-858h]@14 701 if (pDecal->uNumVertices < 3)
741 RenderVertexD3D3 hr[64]; // [sp+20h] [bp-850h]@6 702 {
742 double v26; // [sp+820h] [bp-50h]@8 703 Log::Warning(L"Decal has < 3 vertices");
743 double v27; // [sp+828h] [bp-48h]@8 704 return;
744 double v28; // [sp+830h] [bp-40h]@8 705 }
745 int v29; // [sp+838h] [bp-38h]@8 706
746 int v30; // [sp+83Ch] [bp-34h]@8 707 float color_mult;
747 __int64 v31; // [sp+840h] [bp-30h]@8 708 if ( pDecal->field_C1C & 1 )
748 __int64 v32; // [sp+848h] [bp-28h]@8 709 color_mult = 1.0;
749 __int64 v33; // [sp+850h] [bp-20h]@8 710 else
750 int v34; // [sp+858h] [bp-18h]@8 711 color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
751 unsigned __int64 v35; // [sp+85Ch] [bp-14h]@8 712
752 float v36; // [sp+864h] [bp-Ch]@6 713 for (uint i = 0; i < pDecal->uNumVertices; ++i)
753 int v37; // [sp+868h] [bp-8h]@5 714 {
754 float v38; // [sp+86Ch] [bp-4h]@8 715 uint uTint = pRenderer->GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
755 float thisa; // [sp+878h] [bp+8h]@5 716
756 717 uint uTintR = (uTint >> 16) & 0xFF,
757 v3 = pDecal; 718 uTintG = (uTint >> 8) & 0xFF,
758 if ( pDecal->uNumVertices >= 3 ) 719 uTintB = uTint & 0xFF;
759 { 720
760 if ( pDecal->field_C1C & 1 ) 721 uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
761 v4 = 1.0; 722 uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
762 else 723 uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
763 v4 = pDecal->field_C18->_43B570(); 724
764 thisa = v4; 725 uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
765 v5 = get_shading_dist_mist(); 726 uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
766 v6 = 0; 727 uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
767 v7 = v3->uNumVertices == 0; 728
768 v8 = v3->uNumVertices < 0; 729
769 v37 = 0; 730 float v15;
770 if ( !(v8 | v7) ) 731 if (fabs(z_bias) < 1e-5)
771 { 732 v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
772 v9 = (char *)&hr[0].pos.y; 733 else
773 v10 = (int)&v3->pVertices[0].vWorldViewPosition; 734 {
774 v36 = 1.0 / v5; 735 v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
775 while ( 1 ) 736 if (v15 < 0.000099999997)
776 { 737 v15 = 0.000099999997;
777 v11 = pRenderer->GetActorTintColor(*(float *)v10, v3->field_C14, v6, v6, (RenderBillboard *)v6); 738 }
778 LOBYTE(v12) = v11; 739
779 v33 = ((unsigned int)v11 >> 16) & 0xFFi64; 740 pVerticesD3D[i].pos.z = v15;
780 LOBYTE(v38) = BYTE2(v3->field_C10); 741
781 v38 = (double)v33 * 0.0039215689 * thisa * (double)LOBYTE(v38); 742 pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
782 v28 = v38 + 6.7553994e15; 743 pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
783 v31 = (unsigned __int16)v11 >> 8; 744 pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
784 LODWORD(v38) = BYTE1(v3->field_C10); 745 pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
785 v38 = (double)v31 * 0.0039215689 * thisa * (double)SLODWORD(v38); 746 pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
786 v26 = v38 + 6.7553994e15; 747 pVerticesD3D[i].specular = 0;
787 v35 = __PAIR__(LODWORD(v28), LODWORD(v26)); 748 pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
788 v13 = v3->field_C10; 749 }
789 v32 = v12 & 0xFFi64; 750
790 v29 = (unsigned __int8)v13; 751 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
791 v30 = 0; 752 v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
792 v38 = (double)v32 * 0.0039215689 * thisa * (double)(unsigned __int8)v13; 753 else
793 v27 = v38 + 6.7553994e15; 754 v21 = D3DDP_DONOTLIGHT;
794 v34 = LODWORD(v27); 755
795 v14 = LODWORD(v27) | ((LODWORD(v26) | (LODWORD(v28) << 8)) << 8); 756 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
796 if ( a2 == 0.0 ) 757 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
797 { 758 pVerticesD3D,
798 v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0); 759 pDecal->uNumVertices,
799 }
800 else
801 {
802 v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0) - a2;
803 if ( v15 < 0.000099999997 )
804 v15 = 0.000099999997;
805 }
806 *((float *)v9 + 1) = v15;
807 v16 = *(int *)(v10 + 12);
808 ++v37;
809 v17 = 1.0 / *(float *)v10;
810 *((int *)v9 - 1) = v16;
811 *(int *)v9 = *(int *)(v10 + 16);
812 *((int *)v9 + 5) = *(int *)(v10 + 24);
813 *((int *)v9 + 6) = *(int *)(v10 + 28);
814 v18 = v37;
815 *((int *)v9 + 3) = v14;
816 *((int *)v9 + 4) = 0;
817 v10 += 48;
818 v9 += 32;
819 v19 = __OFSUB__(v18, v3->uNumVertices);
820 v8 = v18 - v3->uNumVertices < 0;
821 *((float *)v9 - 6) = v17;
822 if ( !(v8 ^ v19) )
823 break;
824 v6 = 0;
825 }
826 v6 = 0;
827 }
828 v24 = v6;
829 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
830 {
831 v21 = 28;
832 }
833 else
834 {
835 v21 = 16;
836 }
837 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
838 D3DPT_TRIANGLEFAN,
839 452,
840 hr,
841 v3->uNumVertices,
842 v21)); 760 v21));
843 }
844 } 761 }
845 762
846 //----- (0049C2CD) -------------------------------------------------------- 763 //----- (0049C2CD) --------------------------------------------------------
847 void DecalBuilder::DrawDecals(float a2) 764 void DecalBuilder::DrawDecals(float z_bias)
848 { 765 {
849 DecalBuilder *v2; // esi@1 766 for (uint i = 0; i < std__vector_pDecals_size; ++i)
850 signed int v3; // edi@1 767 DrawDecal(std__vector_pDecals + i, z_bias);
851 Decal *v4; // ebx@2
852
853 v2 = this;
854 v3 = 0;
855 if ( (signed int)this->std__vector_pDecals_size > 0 )
856 {
857 v4 = this->std__vector_pDecals;
858 do
859 {
860 DrawDecal(v4, a2);
861 ++v3;
862 ++v4;
863 }
864 while ( v3 < (signed int)v2->std__vector_pDecals_size );
865 }
866 } 768 }
867 769
868 //----- (0049C304) -------------------------------------------------------- 770 //----- (0049C304) --------------------------------------------------------
869 void DecalBuilder::DrawBloodsplats() 771 void DecalBuilder::DrawBloodsplats()
870 { 772 {
871 unsigned int v1; // ebx@0 773 if (!std__vector_pDecals_size)
872 int v2; // esi@0 774 return;
873 char v3; // zf@1 775
874 HRESULT v4; // eax@4 776 if (pRenderer->bUsingSpecular)
875 HRESULT v5; // eax@4 777 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
876 HRESULT v6; // eax@4 778 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
877 HRESULT v7; // eax@4 779
878 HRESULT v8; // eax@4 780 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
879 HRESULT v9; // eax@4 781 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
880 HRESULT v10; // eax@4 782 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
881 char *v11; // eax@4 783 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
882 //IDirect3DDevice3Vtbl *v12; // ebx@6 784 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
883 int v13; // ST6C_4@6 785 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
884 HRESULT v14; // eax@6 786
885 HRESULT v15; // eax@6 787 auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04");
886 HRESULT v16; // eax@6 788 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
887 HRESULT v17; // eax@6 789
888 HRESULT v18; // eax@6 790 DrawDecals(0.00039999999);
889 HRESULT v19; // eax@6 791 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
890 char thisa; // [sp+80h] [bp-8h]@4 792 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
891 DecalBuilder *v21; // [sp+84h] [bp-4h]@1 793 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
892 794 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
893 v3 = this->std__vector_pDecals_size == 0; 795 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
894 v21 = this; 796
895 if ( !v3 ) 797 if (pRenderer->bUsingSpecular)
896 { 798 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
897 if ( pRenderer->bUsingSpecular )
898 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
899 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
900
901 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
902 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
903 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
904 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
905 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
906 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
907
908 v11 = (char *)std__string_AE5B94.c_str();
909 if ( !std__string_AE5B94.size() )
910 v11 = (char *)&dword_4D86F0;
911 //v12 = pRenderer->pRenderD3D->pDevice->lpVtbl;
912 v13 = (int)pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v11);
913 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, (IDirect3DTexture2 *)v13));
914
915 v21->DrawDecals(0.00039999999);
916 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
917 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
918 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
919 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
920 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
921
922 if ( pRenderer->bUsingSpecular )
923 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
924 }
925 } 799 }
926 800
927 //----- (0049C550) -------------------------------------------------------- 801 //----- (0049C550) --------------------------------------------------------
928 void DecalBuilder::DrawDecalDebugOutlines() 802 void DecalBuilder::DrawDecalDebugOutlines()
929 { 803 {