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