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