comparison DecalBuilder.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 2ca04ccb612a
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "DecalBuilder.h"
2 #include "Game.h"
3 #include "Time.h"
4 #include "stru314.h"
5 #include "Outdoor.h"
6
7 #include "mm7_data.h"
8 //#include "MM7.h"
9
10
11
12
13
14 struct DecalBuilder *pDecalBuilder;
15 struct BloodsplatContainer *pBloodsplatContainer; // idb
16
17
18 //----- (0043B570) --------------------------------------------------------
19 double DecalBuilder_stru0::_43B570()
20 {
21 DecalBuilder_stru0 *v1; // esi@1
22 double result; // st7@3
23
24 v1 = this;
25 if ( this->field_1C_flags & 1 )
26 {
27 if ( (double)(signed __int64)(this->field_20_time - pEventTimer->Time() + 384) * 0.0026041667 >= 0.0 )
28 result = (double)(signed __int64)(v1->field_20_time - pEventTimer->Time() + 384) * 0.0026041667;
29 else
30 result = 0.0;
31 }
32 else
33 {
34 result = 1.0;
35 }
36 return result;
37 }
38
39
40
41
42
43 //----- (0043B6EF) --------------------------------------------------------
44 bool BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b)
45 {
46 int *v8; // esi@1
47 int v9; // eax@3
48 Bloodsplat *v10; // eax@3
49 int *result; // eax@3
50 int v12; // ecx@3
51
52 v8 = &this->uNumBloodsplats;
53 if ( this->uNumBloodsplats == 64 )
54 *v8 = 0;
55 v9 = 5 * (*v8)++;
56 v10 = &this->std__vector_pBloodsplats[8 * v9 / 0x28u];
57 v10->x = x;
58 v10->y = y;
59 v10->z = z;
60 v10->radius = radius;
61 v10->r = r;
62 v10->g = g;
63 v10->b = b;
64 result = (int *)&this->std__vector_pBloodsplats_size;
65 v12 = this->std__vector_pBloodsplats_size + 1;
66 if ( v12 > 64 )
67 v12 = 64;
68 *result = v12;
69 LOBYTE(result) = 1;
70 return (bool)result;
71 }
72
73 //----- (0049B490) --------------------------------------------------------
74 bool DecalBuilder::AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9)
75 {
76 double v10; // ST1C_8@1
77 char v11; // ST24_1@1
78 double v12; // ST1C_8@1
79 double v13; // ST1C_8@1
80 int a7a; // [sp+40h] [bp+18h]@1
81 float arg14a; // [sp+44h] [bp+1Ch]@1
82 float arg14b; // [sp+44h] [bp+1Ch]@1
83 float arg14c; // [sp+44h] [bp+1Ch]@1
84
85 arg14a = b * 255.0;
86 v10 = arg14a + 6.7553994e15;
87 v11 = LOBYTE(v10);
88 arg14b = g * 255.0;
89 v12 = arg14b + 6.7553994e15;
90 a7a = LODWORD(v12);
91 arg14c = r * 255.0;
92 v13 = arg14c + 6.7553994e15;
93 return pBloodsplatContainer->AddBloodsplat(x, y, z, radius, SLOBYTE(v13), a7a, v11);
94 }
95
96 //----- (0049B525) --------------------------------------------------------
97 void DecalBuilder::Reset(unsigned int bPreserveBloodsplats)
98 {
99 if ( !bPreserveBloodsplats )
100 {
101 pBloodsplatContainer->std__vector_pBloodsplats_size = 0;
102 pBloodsplatContainer->uNumBloodsplats = 0;
103 }
104 this->std__vector_pDecals_size = 0;
105 }
106
107 //----- (0049B540) --------------------------------------------------------
108 char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, int a7, char a8, int a9)
109 {
110 char *v9; // eax@3
111 signed int v10; // ecx@3
112 RenderVertexSoft *v11; // eax@10
113 unsigned int v12; // edx@10
114 RenderVertexSoft *v13; // esi@11
115 RenderVertexSoft *v14; // edi@11
116 char v15; // zf@11
117 stru154 *v16; // esi@12
118 double v18; // st7@17
119 double v19; // st6@17
120 float v20; // eax@17
121 Bloodsplat *v21; // esi@21
122 int v22; // eax@21
123 int v23; // ecx@21
124 double v24; // st7@21
125 int v25; // ebx@21
126 double v26; // st7@21
127 int v27; // edi@21
128 double v28; // st7@21
129 int v29; // ST10_4@21
130 int v30; // ST08_4@21
131 DecalBuilder *v31; // esi@21
132 int v32; // [sp+4h] [bp-44h]@18
133 RenderVertexSoft *v33; // [sp+8h] [bp-40h]@21
134 stru314 *v34; // [sp+Ch] [bp-3Ch]@21
135 float v35; // [sp+10h] [bp-38h]@21
136 float v36; // [sp+14h] [bp-34h]@17
137 int v37; // [sp+18h] [bp-30h]@17
138 int a5a; // [sp+28h] [bp-20h]@21
139 int v39; // [sp+2Ch] [bp-1Ch]@21
140 int v40; // [sp+30h] [bp-18h]@21
141 int v41; // [sp+34h] [bp-14h]@22
142 int v42; // [sp+38h] [bp-10h]@21
143 int v43; // [sp+3Ch] [bp-Ch]@21
144 DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
145 RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
146
147 thisa = this;
148 if ( !a5 )
149 return 0;
150
151 static RenderVertexSoft static_AE4F90[64];
152 static bool __init_flag1 = false;
153 if (!__init_flag1)
154 {
155 __init_flag1 = true;
156
157 for (uint i = 0; i < 64; ++i)
158 static_AE4F90[i].flt_2C = 0.0f;
159 }
160
161 static stru314 static_AE4F60; // idb
162 /*static bool __init_flag2 = false;
163 if (!__init_flag2)
164 {
165 __init_flag2 = true;
166
167 stru314::stru314(&static_AE4F60);
168 }*/
169
170 a11 = a6;
171 if ( a7 )
172 {
173 if ( a5 > 0 )
174 {
175 v11 = static_AE4F90;
176 v12 = (char *)a6 - (char *)static_AE4F90;
177 a6 = (RenderVertexSoft *)a5;
178 do
179 {
180 v13 = (RenderVertexSoft *)((char *)v11 + v12);
181 v14 = v11;
182 ++v11;
183 v15 = a6 == (RenderVertexSoft *)1;
184 a6 = (RenderVertexSoft *)((char *)a6 - 1);
185 memcpy(v14, v13, 0x30u);
186 }
187 while ( !v15 );
188 }
189 v16 = a4;
190 if ( pGame->pIndoorCameraD3D->_437376(a4, static_AE4F90, (unsigned int *)&a5) == 1 )
191 {
192 if ( !a5 )
193 return 0;
194 a11 = static_AE4F90;
195 }
196 }
197 else
198 {
199 v16 = a4;
200 }
201 v18 = v16->vNormal.z;
202 v19 = v16->vNormal.y;
203 v20 = v16->vNormal.x;
204 v37 = (int)&stru_AE4F7C;
205 stru_AE4F64.y = v19;
206 stru_AE4F64.x = v20;
207 LODWORD(v36) = (DWORD)&stru_AE4F70;
208 stru_AE4F64.z = v18;
209 dword_AE4F88 = LODWORD(v16->field_10);
210 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
211 v16->field_14,
212 &stru_AE4F64,
213 &stru_AE4F70,
214 &stru_AE4F7C) )
215 {
216 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
217 }
218 a7 = 0;
219 if ( thisa->uNumDecals > 0 )
220 {
221 a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
222 do
223 {
224 v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)];
225 *(float *)&v37 = v21->z;
226 v36 = v21->y;
227 v35 = v21->x;
228 v22 = sub_43F5C8(a2, a9, v35, v36, *(float *)&v37);
229 v23 = v21->b;
230 v24 = v21->x;
231 v42 = v22;
232 BYTE3(v22) = 0;
233 *(short *)((char *)&v22 + 1) = v21->r;
234 LOBYTE(v22) = v21->g;
235 v43 = v23 | (v22 << 8);
236 v25 = (signed __int64)v24;
237 v26 = v21->z;
238 v27 = (signed __int64)v21->y;
239 v37 = a8;
240 v40 = (signed __int64)v26;
241 v28 = *(float *)&v21->field_14;
242 LODWORD(v36) = (uint32)a11;
243 a5a = v25;
244 v39 = v27;
245 LODWORD(v35) = a5;
246 v34 = &static_AE4F60;
247 *(float *)&v33 = v28;
248 v32 = v23 | (v22 << 8);
249 *(float *)&v29 = v21->radius;
250 v30 = (int)v21;
251 v31 = thisa;
252 if ( !thisa->_49B790_build_decal_geometry(
253 v42,
254 a3,
255 v30,
256 (int)&a5a,
257 v29,
258 v43,
259 v33,
260 &static_AE4F60,
261 a5,
262 a11,
263 a8) )
264 {
265 MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
266 }
267 ++a7;
268 a6 = (RenderVertexSoft *)((char *)a6 + 4);
269 }
270 while ( a7 < v31->uNumDecals );
271 }
272 return 1;
273 }
274 // AE4F88: using guessed type int dword_AE4F88;
275 // AE5B90: using guessed type char static_init_flag__AE4F90_bit1__AE4F60_bit2;
276
277 //----- (0049B790) --------------------------------------------------------
278 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)
279 {
280 DecalBuilder *v12; // esi@1
281 Decal *v13; // edi@2
282 char *v14; // eax@2
283 double v15; // st7@4
284 double v16; // st7@4
285 int v17; // eax@4
286 stru314 *v18; // ebx@4
287 double v19; // st7@4
288 double v20; // st7@4
289 double v21; // st7@4
290 double v22; // st6@4
291 double v23; // st6@4
292 double v24; // st5@4
293 char *v25; // eax@4
294 signed int v26; // ecx@4
295 double v27; // st5@4
296 double v28; // st7@5
297 double v29; // st7@6
298 char result; // al@6
299 unsigned int *v31; // edi@7
300 RenderVertexSoft *v32; // ebx@8
301 std::string *v33; // ecx@15
302 int v34; // eax@19
303 const char *v35; // [sp-Ch] [bp-2Ch]@15
304 int v36; // [sp-8h] [bp-28h]@15
305 std::string v37; // [sp-4h] [bp-24h]@15
306 float v38; // [sp+8h] [bp-18h]@6
307 RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
308 unsigned int *v40; // [sp+10h] [bp-10h]@6
309
310 v12 = this;
311 if ( *(float *)&a6 == 0.0 )
312 goto LABEL_24;
313 v13 = &this->std__vector_pDecals[this->field_308008];
314 v14 = (char *)&this->std__vector_pDecals[this->field_308008].field_C1C;
315 this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
316 *(int *)v14 = 0;
317 if ( a3 & 2 )
318 *(int *)v14 = 1;
319 v15 = *(float *)&a6 - *(float *)&a8;
320 *(float *)&this->field_30C028 = v15;
321 v16 = sqrt((*(float *)&a6 + *(float *)&a6 - v15) * v15);
322 *(float *)&v12->field_30C02C = v16;
323 v17 = a5;
324 v18 = a9;
325 v12->flt_30C030 = 1.0 - (*(float *)&a6 - v16) / *(float *)&a6;
326 v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - *(float *)&a8 * v18->field_4.x);
327 v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - *(float *)&a8 * v18->field_4.y);
328 v19 = *(float *)&a6;
329 v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - *(float *)&a8 * v18->field_4.z);
330 v20 = v19 * v12->flt_30C030;
331 a8 = v13->pVertices;
332 v12->field_30C034 = v20;
333 v12->field_30C010 = v20 * v18->field_10.x;
334 v12->field_30C014 = v20 * v18->field_10.y;
335 v12->field_30C018 = v20 * v18->field_10.z;
336 v12->field_30C01C = v20 * v18->field_1C.x;
337 v12->field_30C020 = v20 * v18->field_1C.y;
338 v12->field_30C024 = v20 * v18->field_1C.z;
339 a6 = v13->field_C08;
340 v21 = (double)a6;
341 v22 = v21 - v12->field_30C01C;
342 a6 = v13->field_C0A;
343 v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
344 v23 = (double)a6;
345 v24 = v23 - v12->field_30C020 + v12->field_30C014;
346 v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
347 a6 = v13->field_C0C;
348 v26 = 4;
349 v13->pVertices[0].vWorldPosition.y = v24;
350 v27 = (double)a6;
351 *(float *)&a6 = v27;
352 v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
353 v13->pVertices[0].u = 0.0;
354 v13->pVertices[0].v = 0.0;
355 v13->pVertices[1].vWorldPosition.x = v21 - v12->field_30C01C - v12->field_30C010;
356 v13->pVertices[1].vWorldPosition.y = v23 - v12->field_30C020 - v12->field_30C014;
357 v13->pVertices[1].vWorldPosition.z = v27 - v12->field_30C024 - v12->field_30C018;
358 v13->pVertices[1].u = 0.0;
359 v13->pVertices[1].v = 1.0;
360 v13->pVertices[2].vWorldPosition.x = v21 + v12->field_30C01C - v12->field_30C010;
361 v13->pVertices[2].vWorldPosition.y = v23 + v12->field_30C020 - v12->field_30C014;
362 v13->pVertices[2].vWorldPosition.z = v27 + v12->field_30C024 - v12->field_30C018;
363 v13->pVertices[2].u = 1.0;
364 v13->pVertices[2].v = 1.0;
365 v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
366 v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
367 v13->pVertices[3].vWorldPosition.z = *(float *)&a6 + v12->field_30C024 + v12->field_30C018;
368 v13->pVertices[3].u = 1.0;
369 v13->pVertices[3].v = 0.0;
370 do
371 {
372 v28 = v18->field_4.y * *(float *)v25
373 + *((float *)v25 - 1) * v18->field_4.x
374 + *((float *)v25 + 1) * v18->field_4.z
375 + *(float *)&v18->field_28;
376 *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
377 *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
378 v25 += 48;
379 --v26;
380 *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
381 }
382 while ( v26 );
383 v13->field_C10 = a7;
384 v40 = (unsigned int *)&v13->uNumVertices;
385 v39 = v13->pVertices;
386 v13->uNumVertices = 4;
387 v13->field_C14 = a2;
388 v29 = v18->field_4.z;
389 a6 = (int)&v13->uNumVertices;
390 v38 = v29;
391 result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, v40);
392 if ( result )
393 {
394 v31 = (unsigned int *)a6;
395 if ( !*(int *)a6 )
396 goto LABEL_24;
397 v32 = a8;
398 v40 = *(unsigned int **)a6;
399 v39 = a8;
400 pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
401 v40 = 0;
402 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0);
403 if ( !(uClipFlags & 1) )
404 {
405 LABEL_19:
406 ++v12->field_308008;
407 v34 = 1024;
408 if ( v12->field_308008 == 1024 )
409 v12->field_308008 = 0;
410 if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
411 v34 = v12->std__vector_pDecals_size + 1;
412 v12->std__vector_pDecals_size = v34;
413 goto LABEL_24;
414 }
415 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
416 {
417 if ( uClipFlags & 2 )
418 {
419 v40 = (unsigned int *)&a8;
420 v39 = v12->pVertices;
421 pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8);
422 LABEL_14:
423 v40 = v31;
424 v39 = v12->pVertices;
425 pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
426 goto LABEL_18;
427 }
428 if ( uClipFlags & 4 )
429 {
430 v40 = (unsigned int *)&a8;
431 v39 = v12->pVertices;
432 pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8);
433 goto LABEL_14;
434 }
435 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
436 v35 = "Undefined clip flag specified";
437 }
438 else
439 {
440 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
441 v35 = "Lightpoly builder native indoor clipping not implemented";
442 }
443 MessageBoxA(nullptr, v35, (const char *)v39, 0);
444 LABEL_18:
445 if ( *(float *)&a8 != 0.0 )
446 goto LABEL_19;
447 LABEL_24:
448 result = 1;
449 }
450 return result;
451 }
452
453 //----- (0049BBBD) --------------------------------------------------------
454 char DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
455 {
456 int v2; // edi@1
457 unsigned int v3; // ebx@1
458 BLVFace *v4; // esi@2
459 unsigned int v5; // eax@2
460 char *v6; // edx@5
461 double v7; // st7@12
462
463 v2 = 0;
464 this->uNumDecals = 0;
465 v3 = pBloodsplatContainer->std__vector_pBloodsplats_size;
466 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
467 {
468 v4 = &pIndoor->pFaces[uFaceID];
469 v5 = v4->uAttributes;
470 if ( !(v5 & 0x400000) )
471 {
472 if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
473 {
474 v6 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
475 do
476 {
477 if ( (double)v4->pBounding.x1 - *((float *)v6 + 2) < *((float *)v6 - 1) )
478 {
479 if ( (double)v4->pBounding.x2 + *((float *)v6 + 2) > *((float *)v6 - 1) )
480 {
481 if ( (double)v4->pBounding.y1 - *((float *)v6 + 2) < *(float *)v6 )
482 {
483 if ( (double)v4->pBounding.y2 + *((float *)v6 + 2) > *(float *)v6 )
484 {
485 if ( (double)v4->pBounding.z1 - *((float *)v6 + 2) < *((float *)v6 + 1) )
486 {
487 if ( (double)v4->pBounding.z2 + *((float *)v6 + 2) > *((float *)v6 + 1) )
488 {
489 v7 = v4->pFacePlane.vNormal.z * *((float *)v6 + 1)
490 + v4->pFacePlane.vNormal.y * *(float *)v6
491 + v4->pFacePlane.vNormal.x * *((float *)v6 - 1)
492 + v4->pFacePlane.dist;
493 if ( v7 <= *((float *)v6 + 2) )
494 {
495 *((float *)v6 + 3) = v7;
496 this->std__vector_30B00C[this->uNumDecals++] = v2;
497 }
498 }
499 }
500 }
501 }
502 }
503 }
504 ++v2;
505 v6 += 40;
506 }
507 while ( v2 < (signed int)v3 );
508 }
509 }
510 }
511 return 1;
512 }
513
514 //----- (0049BCEB) --------------------------------------------------------
515 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace)
516 {
517 int v2; // edi@1
518 unsigned int v3; // eax@2
519 char *v4; // edx@5
520 double v5; // ST1C_8@12
521 double v6; // ST14_8@12
522 double v7; // ST0C_8@12
523 double v8; // st7@12
524 unsigned int v10; // [sp+20h] [bp-1Ch]@1
525
526 v2 = 0;
527 this->uNumDecals = 0;
528 v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
529 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
530 {
531 v3 = pFace->uFaceAttributes;
532 if ( !(v3 & 0x400000) )
533 {
534 if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
535 {
536 v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
537 do
538 {
539 if ( (double)pFace->pBoundingBox.x1 - *((float *)v4 + 2) < *((float *)v4 - 1) )
540 {
541 if ( (double)pFace->pBoundingBox.x2 + *((float *)v4 + 2) > *((float *)v4 - 1) )
542 {
543 if ( (double)pFace->pBoundingBox.y1 - *((float *)v4 + 2) < *(float *)v4 )
544 {
545 if ( (double)pFace->pBoundingBox.y2 + *((float *)v4 + 2) > *(float *)v4 )
546 {
547 if ( (double)pFace->pBoundingBox.z1 - *((float *)v4 + 2) < *((float *)v4 + 1) )
548 {
549 if ( (double)pFace->pBoundingBox.z2 + *((float *)v4 + 2) > *((float *)v4 + 1) )
550 {
551 v5 = *((float *)v4 - 1) + 6.7553994e15;
552 v6 = *(float *)v4 + 6.7553994e15;
553 v7 = *((float *)v4 + 1) + 6.7553994e15;
554 v8 = (double)((pFace->pFacePlane.dist
555 + LODWORD(v5) * pFace->pFacePlane.vNormal.x
556 + LODWORD(v6) * pFace->pFacePlane.vNormal.y
557 + LODWORD(v7) * pFace->pFacePlane.vNormal.z) >> 16);
558 if ( v8 <= *((float *)v4 + 2) )
559 {
560 *((float *)v4 + 3) = v8;
561 this->std__vector_30B00C[this->uNumDecals++] = v2;
562 }
563 }
564 }
565 }
566 }
567 }
568 }
569 ++v2;
570 v4 += 40;
571 }
572 while ( v2 < (signed int)v10 );
573 }
574 }
575 }
576 return 1;
577 }
578
579 //----- (0049BE8A) --------------------------------------------------------
580 bool DecalBuilder::_49BE8A(struct stru148 *a2, float a3, int a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
581 {
582 bool result; // eax@1
583 RenderVertexSoft *v8; // edi@3
584 float v9; // ebx@3
585 char *v10; // esi@3
586 float v11; // eax@5
587 float v12; // eax@6
588 double v13; // st7@13
589 double v14; // st7@19
590 int v15; // eax@20
591 int v16; // eax@22
592 int v17; // edx@24
593 DecalBuilder *v18; // eax@24
594 std::string v19; // [sp-18h] [bp-54h]@12
595 const char *v20; // [sp-8h] [bp-44h]@12
596 int v21; // [sp-4h] [bp-40h]@12
597 double v22; // [sp+Ch] [bp-30h]@19
598 unsigned int v23; // [sp+14h] [bp-28h]@1
599 DecalBuilder *v24; // [sp+18h] [bp-24h]@1
600 int v25; // [sp+1Ch] [bp-20h]@19
601 float v26; // [sp+20h] [bp-1Ch]@12
602 int v27; // [sp+24h] [bp-18h]@12
603 float v28; // [sp+28h] [bp-14h]@13
604 float v29; // [sp+2Ch] [bp-10h]@7
605 float v30; // [sp+30h] [bp-Ch]@6
606 float v31; // [sp+34h] [bp-8h]@6
607 bool v32; // [sp+38h] [bp-4h]@2
608
609 this->uNumDecals = 0;
610 result = pBloodsplatContainer->std__vector_pBloodsplats_size;
611 v24 = this;
612 v23 = pBloodsplatContainer->std__vector_pBloodsplats_size;
613 if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
614 {
615 v32 = 0;
616 if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
617 {
618 v8 = a5;
619 v9 = a3;
620 v10 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
621 while ( uStripType != 4 )
622 {
623 if ( uStripType == 3 )
624 {
625 if ( a7 )
626 {
627 a3 = v8->vWorldPosition.x;
628 v31 = v8[2].vWorldPosition.x;
629 v30 = v8[1].vWorldPosition.y;
630 v12 = v8[2].vWorldPosition.y;
631 goto LABEL_7;
632 }
633 a3 = v8[1].vWorldPosition.x;
634 v11 = v8[2].vWorldPosition.x;
635 LABEL_6:
636 v31 = v11;
637 v30 = v8[1].vWorldPosition.y;
638 v12 = v8->vWorldPosition.y;
639 LABEL_7:
640 v29 = v12;
641 goto LABEL_13;
642 }
643 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
644 LABEL_13:
645 v21 = uStripType;
646 v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType);
647 v21 = uStripType;
648 v28 = v13;
649 v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType);
650 if ( a3 - *((float *)v10 + 2) < *((float *)v10 - 1) )
651 {
652 if ( v31 + *((float *)v10 + 2) > *((float *)v10 - 1) )
653 {
654 if ( v30 - *((float *)v10 + 2) < *(float *)v10 )
655 {
656 if ( v29 + *((float *)v10 + 2) > *(float *)v10 )
657 {
658 if ( v28 - *((float *)v10 + 2) < *((float *)v10 + 1) )
659 {
660 if ( v26 + *((float *)v10 + 2) > *((float *)v10 + 1) )
661 {
662 Vec3_float_::NegDot(&v8->vWorldPosition, (Vec3_float_ *)LODWORD(v9), (float *)a4);
663 v26 = *(float *)(LODWORD(v9) + 4) * *(float *)v10
664 + *(float *)(LODWORD(v9) + 8) * *((float *)v10 + 1)
665 + *(unsigned int *)LODWORD(v9) * *((float *)v10 - 1)
666 + *(float *)a4;
667 v22 = v26 + 6.7553994e15;
668 v25 = LODWORD(v22);
669 v14 = (double)SLODWORD(v22);
670 v28 = v14;
671 if ( v14 <= *((float *)v10 + 2) )
672 {
673 v15 = *(int *)&a2->flags;
674 if ( v15 & 2 || BYTE1(v15) & 1 )
675 {
676 v16 = *((int *)v10 + 5);
677 if ( !(v16 & 1) )
678 {
679 LOBYTE(v16) = v16 | 1;
680 *((int *)v10 + 5) = v16;
681 *((_QWORD *)v10 + 3) = pEventTimer->Time();
682 }
683 }
684 v17 = v32;
685 *((int *)v10 + 3) = LODWORD(v28);
686 v18 = v24;
687 v24->std__vector_30B00C[v24->uNumDecals] = v17;
688 ++v18->uNumDecals;
689 }
690 }
691 }
692 }
693 }
694 }
695 }
696 ++v32;
697 v10 += 40;
698 result = v32;
699 if ( v32 >= (signed int)v23 )
700 goto LABEL_26;
701 }
702 a3 = v8->vWorldPosition.x;
703 v11 = v8[3].vWorldPosition.x;
704 goto LABEL_6;
705 }
706 }
707 LABEL_26:
708 LOBYTE(result) = 1;
709 return result;
710 }
711
712 //----- (0049C095) --------------------------------------------------------
713 void DecalBuilder::DrawDecal(Decal *pDecal, float a2)
714 {
715 Decal *v3; // edi@1
716 double v4; // st7@3
717 double v5; // st7@5
718 int v6; // eax@5
719 unsigned __int8 v7; // zf@5
720 unsigned __int8 v8; // sf@5
721 char *v9; // esi@6
722 int v10; // ebx@6
723 int v11; // eax@8
724 int v12; // edx@8
725 int v13; // eax@8
726 int v14; // ecx@8
727 double v15; // st7@9
728 int v16; // eax@12
729 double v17; // st7@12
730 int v18; // eax@12
731 unsigned __int8 v19; // of@12
732 HRESULT v20; // eax@17
733 signed int v21; // [sp+Ch] [bp-864h]@15
734 const char *v22; // [sp+10h] [bp-860h]@15
735 int v23; // [sp+14h] [bp-85Ch]@15
736 unsigned int v24; // [sp+18h] [bp-858h]@14
737 RenderVertexD3D3 hr[64]; // [sp+20h] [bp-850h]@6
738 double v26; // [sp+820h] [bp-50h]@8
739 double v27; // [sp+828h] [bp-48h]@8
740 double v28; // [sp+830h] [bp-40h]@8
741 int v29; // [sp+838h] [bp-38h]@8
742 int v30; // [sp+83Ch] [bp-34h]@8
743 __int64 v31; // [sp+840h] [bp-30h]@8
744 __int64 v32; // [sp+848h] [bp-28h]@8
745 __int64 v33; // [sp+850h] [bp-20h]@8
746 int v34; // [sp+858h] [bp-18h]@8
747 unsigned __int64 v35; // [sp+85Ch] [bp-14h]@8
748 float v36; // [sp+864h] [bp-Ch]@6
749 int v37; // [sp+868h] [bp-8h]@5
750 float v38; // [sp+86Ch] [bp-4h]@8
751 float thisa; // [sp+878h] [bp+8h]@5
752
753 v3 = pDecal;
754 if ( pDecal->uNumVertices >= 3 )
755 {
756 if ( pDecal->field_C1C & 1 )
757 v4 = 1.0;
758 else
759 v4 = pDecal->field_C18->_43B570();
760 thisa = v4;
761 v5 = get_shading_dist_mist();
762 v6 = 0;
763 v7 = v3->uNumVertices == 0;
764 v8 = v3->uNumVertices < 0;
765 v37 = 0;
766 if ( !(v8 | v7) )
767 {
768 v9 = (char *)&hr[0].pos.y;
769 v10 = (int)&v3->pVertices[0].vWorldViewPosition;
770 v36 = 1.0 / v5;
771 while ( 1 )
772 {
773 v11 = pRenderer->GetActorTintColor(*(float *)v10, v3->field_C14, v6, v6, (RenderBillboard *)v6);
774 LOBYTE(v12) = v11;
775 v33 = ((unsigned int)v11 >> 16) & 0xFFi64;
776 LOBYTE(v38) = BYTE2(v3->field_C10);
777 v38 = (double)v33 * 0.0039215689 * thisa * (double)LOBYTE(v38);
778 v28 = v38 + 6.7553994e15;
779 v31 = (unsigned __int16)v11 >> 8;
780 LODWORD(v38) = BYTE1(v3->field_C10);
781 v38 = (double)v31 * 0.0039215689 * thisa * (double)SLODWORD(v38);
782 v26 = v38 + 6.7553994e15;
783 v35 = __PAIR__(LODWORD(v28), LODWORD(v26));
784 v13 = v3->field_C10;
785 v32 = v12 & 0xFFi64;
786 v29 = (unsigned __int8)v13;
787 v30 = 0;
788 v38 = (double)v32 * 0.0039215689 * thisa * (double)(unsigned __int8)v13;
789 v27 = v38 + 6.7553994e15;
790 v34 = LODWORD(v27);
791 v14 = LODWORD(v27) | ((LODWORD(v26) | (LODWORD(v28) << 8)) << 8);
792 if ( a2 == 0.0 )
793 {
794 v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0);
795 }
796 else
797 {
798 v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0) - a2;
799 if ( v15 < 0.000099999997 )
800 v15 = 0.000099999997;
801 }
802 *((float *)v9 + 1) = v15;
803 v16 = *(int *)(v10 + 12);
804 ++v37;
805 v17 = 1.0 / *(float *)v10;
806 *((int *)v9 - 1) = v16;
807 *(int *)v9 = *(int *)(v10 + 16);
808 *((int *)v9 + 5) = *(int *)(v10 + 24);
809 *((int *)v9 + 6) = *(int *)(v10 + 28);
810 v18 = v37;
811 *((int *)v9 + 3) = v14;
812 *((int *)v9 + 4) = 0;
813 v10 += 48;
814 v9 += 32;
815 v19 = __OFSUB__(v18, v3->uNumVertices);
816 v8 = v18 - v3->uNumVertices < 0;
817 *((float *)v9 - 6) = v17;
818 if ( !(v8 ^ v19) )
819 break;
820 v6 = 0;
821 }
822 v6 = 0;
823 }
824 v24 = v6;
825 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
826 {
827 v21 = 28;
828 }
829 else
830 {
831 v21 = 16;
832 }
833 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
834 D3DPT_TRIANGLEFAN,
835 452,
836 hr,
837 v3->uNumVertices,
838 v21));
839 }
840 }
841
842 //----- (0049C2CD) --------------------------------------------------------
843 void DecalBuilder::DrawDecals(float a2)
844 {
845 DecalBuilder *v2; // esi@1
846 signed int v3; // edi@1
847 Decal *v4; // ebx@2
848
849 v2 = this;
850 v3 = 0;
851 if ( (signed int)this->std__vector_pDecals_size > 0 )
852 {
853 v4 = this->std__vector_pDecals;
854 do
855 {
856 DrawDecal(v4, a2);
857 ++v3;
858 ++v4;
859 }
860 while ( v3 < (signed int)v2->std__vector_pDecals_size );
861 }
862 }
863
864 //----- (0049C304) --------------------------------------------------------
865 void DecalBuilder::DrawBloodsplats()
866 {
867 unsigned int v1; // ebx@0
868 int v2; // esi@0
869 char v3; // zf@1
870 HRESULT v4; // eax@4
871 HRESULT v5; // eax@4
872 HRESULT v6; // eax@4
873 HRESULT v7; // eax@4
874 HRESULT v8; // eax@4
875 HRESULT v9; // eax@4
876 HRESULT v10; // eax@4
877 char *v11; // eax@4
878 //IDirect3DDevice3Vtbl *v12; // ebx@6
879 int v13; // ST6C_4@6
880 HRESULT v14; // eax@6
881 HRESULT v15; // eax@6
882 HRESULT v16; // eax@6
883 HRESULT v17; // eax@6
884 HRESULT v18; // eax@6
885 HRESULT v19; // eax@6
886 char thisa; // [sp+80h] [bp-8h]@4
887 DecalBuilder *v21; // [sp+84h] [bp-4h]@1
888
889 v3 = this->std__vector_pDecals_size == 0;
890 v21 = this;
891 if ( !v3 )
892 {
893 if ( pRenderer->bUsingSpecular )
894 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
895 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
896
897 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
898 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
899 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
900 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
901 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
902 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
903
904 v11 = (char *)std__string_AE5B94.c_str();
905 if ( !std__string_AE5B94.size() )
906 v11 = (char *)&dword_4D86F0;
907 //v12 = pRenderer->pRenderD3D->pDevice->lpVtbl;
908 v13 = (int)pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v11);
909 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, (IDirect3DTexture2 *)v13));
910
911 v21->DrawDecals(0.00039999999);
912 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
913 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
914 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
915 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
916 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
917
918 if ( pRenderer->bUsingSpecular )
919 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
920 }
921 }
922
923 //----- (0049C550) --------------------------------------------------------
924 void DecalBuilder::DrawDecalDebugOutlines()
925 {
926 DecalBuilder *v1; // esi@1
927 signed int v2; // ebx@1
928 RenderVertexSoft *v3; // edi@2
929
930 v1 = this;
931 v2 = 0;
932 if ( (signed int)this->std__vector_pDecals_size > 0 )
933 {
934 v3 = this->std__vector_pDecals[0].pVertices;
935 do
936 {
937 pGame->pIndoorCameraD3D->debug_outline_sw(v3, *((int *)v3 - 1), 0xC86400u, 0.0);
938 ++v2;
939 v3 = (RenderVertexSoft *)((char *)v3 + 3104);
940 }
941 while ( v2 < (signed int)v1->std__vector_pDecals_size );
942 }
943 }
944
945 //----- (0040E4C2) --------------------------------------------------------
946 void Decal::Decal_base_ctor()
947 {
948 uNumVertices = -1;
949 for (uint i = 0; i < 64; ++i)
950 pVertices[i].flt_2C = 0.0f;
951 }