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