Mercurial > mm7
annotate DecalBuilder.cpp @ 2159:67a83bc1a7de
uDefaultPartyHeight = 192
author | Ritor1 |
---|---|
date | Mon, 13 Jan 2014 14:31:25 +0600 |
parents | 0a1438c16c2b |
children | 70b63fe6587c |
rev | line source |
---|---|
0 | 1 #include "DecalBuilder.h" |
2 #include "Game.h" | |
2044 | 3 #include "Timer.h" |
0 | 4 #include "stru314.h" |
5 #include "Outdoor.h" | |
6 #include "Log.h" | |
7 | |
8 #include "mm7_data.h" | |
2152 | 9 #include "mm7_unsorted_subs.h" |
0 | 10 |
1016 | 11 #include "stru9.h" |
0 | 12 |
1277 | 13 #include "Outdoor_stuff.h" |
0 | 14 |
15 | |
16 struct DecalBuilder *pDecalBuilder = new DecalBuilder; | |
17 struct BloodsplatContainer *pBloodsplatContainer = new BloodsplatContainer; | |
18 | |
19 | |
20 //----- (0043B570) -------------------------------------------------------- | |
21 double DecalBuilder_stru0::_43B570_get_color_mult_by_time() | |
22 { | |
23 double result; // st7@3 | |
24 | |
25 if (field_1C_flags & 1) | |
26 { | |
27 if ((field_20_time - pEventTimer->Time() + 384) / 384.0 >= 0.0) | |
28 result = (field_20_time - pEventTimer->Time() + 384) / 384.0; | |
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, | |
94 //SLOBYTE(v13), a7a, v11); | |
95 r * 255.0f, | |
96 g * 255.0f, | |
97 b * 255.0f); | |
98 } | |
99 | |
100 //----- (0049B525) -------------------------------------------------------- | |
101 void DecalBuilder::Reset(unsigned int bPreserveBloodsplats) | |
102 { | |
103 if ( !bPreserveBloodsplats ) | |
104 { | |
105 pBloodsplatContainer->std__vector_pBloodsplats_size = 0; | |
106 pBloodsplatContainer->uNumBloodsplats = 0; | |
107 } | |
108 std__vector_pDecals_size = 0; | |
109 } | |
110 | |
111 //----- (0049B540) -------------------------------------------------------- | |
638 | 112 char DecalBuilder::ApplyDecals(int light_level, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID) |
0 | 113 { |
114 char *v9; // eax@3 | |
115 signed int v10; // ecx@3 | |
116 RenderVertexSoft *v11; // eax@10 | |
117 unsigned int v12; // edx@10 | |
118 RenderVertexSoft *v13; // esi@11 | |
119 RenderVertexSoft *v14; // edi@11 | |
120 char v15; // zf@11 | |
121 stru154 *v16; // esi@12 | |
122 double v18; // st7@17 | |
123 double v19; // st6@17 | |
124 float v20; // eax@17 | |
125 Bloodsplat *v21; // esi@21 | |
126 int v22; // eax@21 | |
127 int v23; // ecx@21 | |
128 double v24; // st7@21 | |
129 int v25; // ebx@21 | |
130 double v26; // st7@21 | |
131 int v27; // edi@21 | |
132 double v28; // st7@21 | |
1077 | 133 float v29; // ST10_4@21 |
0 | 134 int v30; // ST08_4@21 |
920 | 135 //DecalBuilder *v31; // esi@21 |
0 | 136 int v32; // [sp+4h] [bp-44h]@18 |
1077 | 137 float v33; // [sp+8h] [bp-40h]@21 |
0 | 138 stru314 *v34; // [sp+Ch] [bp-3Ch]@21 |
139 float v35; // [sp+10h] [bp-38h]@21 | |
140 float v36; // [sp+14h] [bp-34h]@17 | |
141 int v37; // [sp+18h] [bp-30h]@17 | |
142 int a5a; // [sp+28h] [bp-20h]@21 | |
143 int v39; // [sp+2Ch] [bp-1Ch]@21 | |
144 int v40; // [sp+30h] [bp-18h]@21 | |
145 int v41; // [sp+34h] [bp-14h]@22 | |
146 int v42; // [sp+38h] [bp-10h]@21 | |
147 int v43; // [sp+3Ch] [bp-Ch]@21 | |
920 | 148 //DecalBuilder *thisa; // [sp+40h] [bp-8h]@1 |
149 //RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8 | |
1076 | 150 int a6a; |
151 int *a6b; | |
152 | |
0 | 153 |
920 | 154 // __debugbreak(); |
0 | 155 |
920 | 156 //auto a2 = light_level; |
157 //auto a9 = uSectorID; | |
0 | 158 |
920 | 159 //thisa = this; |
0 | 160 if ( !a5 ) |
161 return 0; | |
162 | |
163 static RenderVertexSoft static_AE4F90[64]; | |
164 static bool __init_flag1 = false; | |
165 if (!__init_flag1) | |
166 { | |
167 __init_flag1 = true; | |
168 | |
169 for (uint i = 0; i < 64; ++i) | |
170 static_AE4F90[i].flt_2C = 0.0f; | |
171 } | |
172 | |
173 static stru314 static_AE4F60; // idb | |
174 /*static bool __init_flag2 = false; | |
175 if (!__init_flag2) | |
176 { | |
177 __init_flag2 = true; | |
178 | |
179 stru314::stru314(&static_AE4F60); | |
180 }*/ | |
181 | |
920 | 182 //a11 = a6; |
0 | 183 if ( a7 ) |
184 { | |
1076 | 185 for(int i=0; i < a5;i++) |
0 | 186 { |
1076 | 187 memcpy(&static_AE4F90[i], a6, 0x30u); |
188 ++a6; | |
0 | 189 } |
190 v16 = a4; | |
191 if ( pGame->pIndoorCameraD3D->_437376(a4, static_AE4F90, (unsigned int *)&a5) == 1 ) | |
192 { | |
193 if ( !a5 ) | |
194 return 0; | |
920 | 195 a6 = static_AE4F90; |
0 | 196 } |
197 } | |
198 else | |
199 { | |
200 v16 = a4; | |
201 } | |
202 v18 = v16->face_plane.vNormal.z; | |
203 v19 = v16->face_plane.vNormal.y; | |
204 v20 = v16->face_plane.vNormal.x; | |
205 v37 = (int)&static_AE4F60.field_1C; | |
206 static_AE4F60.field_4.y = v19; | |
207 static_AE4F60.field_4.x = v20; | |
208 LODWORD(v36) = (DWORD)&static_AE4F60.field_10; | |
209 static_AE4F60.field_4.z = v18; | |
210 static_AE4F60.dist = v16->face_plane.dist; | |
920 | 211 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(v16->polygonType, &static_AE4F60.field_4, &static_AE4F60.field_10, &static_AE4F60.field_1C) ) |
0 | 212 { |
213 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0); | |
214 } | |
215 int _a7 = 0; | |
920 | 216 if ( this->uNumDecals > 0 ) |
0 | 217 { |
1076 | 218 a6b = this->std__vector_30B00C; |
0 | 219 do |
220 { | |
1076 | 221 v21 = &pBloodsplatContainer->std__vector_pBloodsplats[*a6b]; |
222 v22 = _43F5C8_get_point_light_level_with_respect_to_lights(light_level, uSectorID, v21->x, v21->y, v21->z); | |
0 | 223 v23 = v21->b; |
224 v24 = v21->x; | |
225 v42 = v22; | |
226 BYTE3(v22) = 0; | |
227 *(short *)((char *)&v22 + 1) = v21->r; | |
228 LOBYTE(v22) = v21->g; | |
229 v43 = v23 | (v22 << 8); | |
230 v25 = (signed __int64)v24; | |
231 v26 = v21->z; | |
232 v27 = (signed __int64)v21->y; | |
233 v37 = a8; | |
234 v40 = (signed __int64)v26; | |
235 v28 = v21->dot_dist; | |
1076 | 236 //LODWORD(v36) = (uint32)a6; |
0 | 237 a5a = v25; |
238 v39 = v27; | |
239 LODWORD(v35) = a5; | |
240 v34 = &static_AE4F60; | |
1077 | 241 v33 = v28; |
0 | 242 v32 = v23 | (v22 << 8); |
1077 | 243 v29 = v21->radius; |
244 //v30 = (int)v21; | |
920 | 245 //v31 = thisa; |
1077 | 246 if ( !this->_49B790_build_decal_geometry(v42, a3, (DecalBuilder_stru0 *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) ) |
0 | 247 { |
248 MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0); | |
249 } | |
250 ++_a7; | |
1076 | 251 ++a6b; |
0 | 252 } |
920 | 253 while ( _a7 < this->uNumDecals ); |
0 | 254 } |
255 return 1; | |
256 } | |
257 | |
258 //----- (0049B790) -------------------------------------------------------- | |
1077 | 259 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 | 260 { |
261 DecalBuilder *v12; // esi@1 | |
262 Decal *v13; // edi@2 | |
1077 | 263 int *v14; // eax@2 |
0 | 264 double v15; // st7@4 |
265 double v16; // st7@4 | |
266 int v17; // eax@4 | |
267 stru314 *v18; // ebx@4 | |
268 double v19; // st7@4 | |
269 double v20; // st7@4 | |
270 double v21; // st7@4 | |
271 double v22; // st6@4 | |
272 double v23; // st6@4 | |
273 double v24; // st5@4 | |
274 char *v25; // eax@4 | |
275 signed int v26; // ecx@4 | |
276 double v27; // st5@4 | |
277 double v28; // st7@5 | |
278 double v29; // st7@6 | |
279 char result; // al@6 | |
280 unsigned int *v31; // edi@7 | |
281 RenderVertexSoft *v32; // ebx@8 | |
282 std::string *v33; // ecx@15 | |
283 int v34; // eax@19 | |
284 const char *v35; // [sp-Ch] [bp-2Ch]@15 | |
285 int v36; // [sp-8h] [bp-28h]@15 | |
286 std::string v37; // [sp-4h] [bp-24h]@15 | |
287 float v38; // [sp+8h] [bp-18h]@6 | |
288 RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6 | |
1077 | 289 unsigned int v40; // [sp+10h] [bp-10h]@6 |
290 | |
291 int a6a; | |
292 RenderVertexSoft *a8a; | |
293 unsigned int a8b = 0; | |
0 | 294 |
295 v12 = this; | |
1077 | 296 if ( a6 == 0.0 ) |
297 return 1; | |
0 | 298 v13 = &this->std__vector_pDecals[this->field_308008]; |
1077 | 299 v14 = &this->std__vector_pDecals[this->field_308008].field_C1C; |
300 this->std__vector_pDecals[this->field_308008].field_C18 = a4; | |
301 *v14 = 0; | |
0 | 302 if ( a3 & 2 ) |
1077 | 303 *v14 = 1; |
304 v15 = a6 - a8; | |
305 this->field_30C028 = v15; | |
306 v16 = sqrt((a6 + a6 - v15) * v15); | |
307 v12->field_30C02C = v16; | |
0 | 308 v17 = a5; |
309 v18 = a9; | |
1077 | 310 v12->flt_30C030 = 1.0 - (a6 - v16) / a6; |
311 v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - a8 * v18->field_4.x); | |
312 v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * v18->field_4.y); | |
313 v19 = a6; | |
314 v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * v18->field_4.z); | |
0 | 315 v20 = v19 * v12->flt_30C030; |
1077 | 316 a8a = v13->pVertices; |
0 | 317 v12->field_30C034 = v20; |
318 v12->field_30C010 = v20 * v18->field_10.x; | |
319 v12->field_30C014 = v20 * v18->field_10.y; | |
320 v12->field_30C018 = v20 * v18->field_10.z; | |
321 v12->field_30C01C = v20 * v18->field_1C.x; | |
322 v12->field_30C020 = v20 * v18->field_1C.y; | |
323 v12->field_30C024 = v20 * v18->field_1C.z; | |
1077 | 324 a6a = v13->field_C08; |
325 v21 = (double)a6a; | |
0 | 326 v22 = v21 - v12->field_30C01C; |
1077 | 327 a6a = v13->field_C0A; |
0 | 328 v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010; |
1077 | 329 v23 = (double)a6a; |
0 | 330 v24 = v23 - v12->field_30C020 + v12->field_30C014; |
331 v25 = (char *)&v13->pVertices[0].vWorldPosition.y; | |
332 a6 = v13->field_C0C; | |
333 v26 = 4; | |
334 v13->pVertices[0].vWorldPosition.y = v24; | |
1077 | 335 v27 = (double)a6a; |
336 a6 = v27; | |
0 | 337 v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018; |
338 v13->pVertices[0].u = 0.0; | |
339 v13->pVertices[0].v = 0.0; | |
340 v13->pVertices[1].vWorldPosition.x = v21 - v12->field_30C01C - v12->field_30C010; | |
341 v13->pVertices[1].vWorldPosition.y = v23 - v12->field_30C020 - v12->field_30C014; | |
342 v13->pVertices[1].vWorldPosition.z = v27 - v12->field_30C024 - v12->field_30C018; | |
343 v13->pVertices[1].u = 0.0; | |
344 v13->pVertices[1].v = 1.0; | |
345 v13->pVertices[2].vWorldPosition.x = v21 + v12->field_30C01C - v12->field_30C010; | |
346 v13->pVertices[2].vWorldPosition.y = v23 + v12->field_30C020 - v12->field_30C014; | |
347 v13->pVertices[2].vWorldPosition.z = v27 + v12->field_30C024 - v12->field_30C018; | |
348 v13->pVertices[2].u = 1.0; | |
349 v13->pVertices[2].v = 1.0; | |
350 v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010; | |
351 v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014; | |
1077 | 352 v13->pVertices[3].vWorldPosition.z = a6 + v12->field_30C024 + v12->field_30C018; |
0 | 353 v13->pVertices[3].u = 1.0; |
354 v13->pVertices[3].v = 0.0; | |
355 do | |
356 { | |
357 v28 = v18->field_4.y * *(float *)v25 | |
358 + *((float *)v25 - 1) * v18->field_4.x | |
359 + *((float *)v25 + 1) * v18->field_4.z | |
360 + v18->dist; | |
361 *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x; | |
362 *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y; | |
363 v25 += 48; | |
364 --v26; | |
365 *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z; | |
366 } | |
367 while ( v26 ); | |
368 v13->uColorMultiplier = uColorMultiplier; | |
1077 | 369 //v40 = (unsigned int *)&v13->uNumVertices; |
0 | 370 v39 = v13->pVertices; |
371 v13->uNumVertices = 4; | |
372 v13->field_C14 = a2; | |
373 v29 = v18->field_4.z; | |
1077 | 374 //a6a = (unsigned int *)&v13->uNumVertices; |
0 | 375 v38 = v29; |
1077 | 376 result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, (unsigned int*)&v13->uNumVertices); |
0 | 377 if ( result ) |
378 { | |
1077 | 379 //v31 = a6a; |
380 if ( !v13->uNumVertices ) | |
381 return 1; | |
382 v32 = a8a; | |
383 //v40 = *a6a; | |
384 v39 = a8a; | |
385 pGame->pIndoorCameraD3D->ViewTransform(a8a, (unsigned int)v13->uNumVertices); | |
0 | 386 v40 = 0; |
1086 | 387 pGame->pIndoorCameraD3D->Project(v32, v13->uNumVertices, 0); |
0 | 388 if ( !(uClipFlags & 1) ) |
389 { | |
390 ++v12->field_308008; | |
391 v34 = 1024; | |
392 if ( v12->field_308008 == 1024 ) | |
393 v12->field_308008 = 0; | |
394 if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 ) | |
395 v34 = v12->std__vector_pDecals_size + 1; | |
396 v12->std__vector_pDecals_size = v34; | |
1077 | 397 return 1; |
0 | 398 } |
399 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
400 { | |
401 if ( uClipFlags & 2 ) | |
402 { | |
1077 | 403 v40 = (int)&a8; |
0 | 404 v39 = v12->pVertices; |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1391
diff
changeset
|
405 __debugbreak(); // warning C4700: uninitialized local variable 'v31' used |
1077 | 406 pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b); |
407 v40 = (int)v31; | |
0 | 408 v39 = v12->pVertices; |
1077 | 409 pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31); |
0 | 410 } |
1077 | 411 else if ( uClipFlags & 4 ) |
0 | 412 { |
1077 | 413 v40 = (int)&a8; |
414 v39 = v12->pVertices; | |
415 pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, &a8b); | |
416 v40 = (int)v31; | |
0 | 417 v39 = v12->pVertices; |
1077 | 418 pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31); |
0 | 419 } |
1077 | 420 else |
421 { | |
422 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258"; | |
423 v35 = "Undefined clip flag specified"; | |
424 MessageBoxA(nullptr, v35, (const char *)v39, 0); | |
425 } | |
0 | 426 } |
427 else | |
428 { | |
429 v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263"; | |
430 v35 = "Lightpoly builder native indoor clipping not implemented"; | |
1077 | 431 MessageBoxA(nullptr, v35, (const char *)v39, 0); |
0 | 432 } |
1077 | 433 if ( a8b != 0 ) |
434 { | |
435 ++v12->field_308008; | |
436 v34 = 1024; | |
437 if ( v12->field_308008 == 1024 ) | |
438 v12->field_308008 = 0; | |
439 if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 ) | |
440 v34 = v12->std__vector_pDecals_size + 1; | |
441 v12->std__vector_pDecals_size = v34; | |
442 return 1; | |
443 } | |
0 | 444 result = 1; |
445 } | |
446 return result; | |
447 } | |
448 | |
449 //----- (0049BBBD) -------------------------------------------------------- | |
450 bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID) | |
451 { | |
452 double v7; // st7@12 | |
453 | |
1079 | 454 uNumDecals = 0; |
0 | 455 if (!pBloodsplatContainer->std__vector_pBloodsplats_size) |
456 return true; | |
457 | |
1980 | 458 BLVFace* pFace = &pIndoor->pFaces[uFaceID]; |
0 | 459 |
2092 | 460 if ( pFace->Indoor_sky() || pFace->Fluid() ) |
0 | 461 return true; |
462 for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i) | |
463 { | |
1980 | 464 Bloodsplat* pBloodsplat = &pBloodsplatContainer->std__vector_pBloodsplats[i]; |
0 | 465 if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x && |
466 pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x && | |
467 pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y && | |
468 pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y && | |
469 pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z && | |
470 pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z) | |
471 { | |
472 v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z + | |
473 pFace->pFacePlane.vNormal.y * pBloodsplat->y + | |
474 pFace->pFacePlane.vNormal.x * pBloodsplat->x + | |
475 pFace->pFacePlane.dist; | |
476 if (v7 <= pBloodsplat->radius) | |
477 { | |
478 pBloodsplat->dot_dist = v7; | |
479 std__vector_30B00C[uNumDecals++] = i; | |
480 } | |
481 } | |
482 } | |
483 | |
484 return true; | |
485 } | |
486 | |
487 //----- (0049BCEB) -------------------------------------------------------- | |
488 char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace) | |
489 { | |
1119 | 490 double v8; // st7@12 |
491 unsigned int v10; // [sp+20h] [bp-1Ch]@1 | |
492 | |
493 Bloodsplat *pBloodsplat; | |
0 | 494 |
1119 | 495 this->uNumDecals = 0; |
496 v10 = pBloodsplatContainer->std__vector_pBloodsplats_size; | |
2092 | 497 if ( !pFace->Indoor_sky() && !pFace->Fluid() ) |
1119 | 498 { |
499 for(int i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; i++ ) | |
500 { | |
501 pBloodsplat = &pBloodsplatContainer->std__vector_pBloodsplats[i]; | |
502 if ( (double)pFace->pBoundingBox.x1 - pBloodsplat->radius < pBloodsplat->x && | |
503 (double)pFace->pBoundingBox.x2 + pBloodsplat->radius > pBloodsplat->x && | |
504 (double)pFace->pBoundingBox.y1 - pBloodsplat->radius < pBloodsplat->y && | |
505 (double)pFace->pBoundingBox.y2 + pBloodsplat->radius > pBloodsplat->y && | |
506 (double)pFace->pBoundingBox.z1 - pBloodsplat->radius < pBloodsplat->z && | |
507 (double)pFace->pBoundingBox.z2 + pBloodsplat->radius > pBloodsplat->z ) | |
508 { | |
509 v8 = (double)((pFace->pFacePlane.dist | |
2125 | 510 + round_to_int(pBloodsplat->x) * pFace->pFacePlane.vNormal.x |
511 + round_to_int(pBloodsplat->y) * pFace->pFacePlane.vNormal.y | |
512 + round_to_int(pBloodsplat->z) * pFace->pFacePlane.vNormal.z) >> 16); | |
1119 | 513 if ( v8 <= pBloodsplat->radius ) |
514 { | |
515 pBloodsplat->dot_dist = v8; | |
516 this->std__vector_30B00C[this->uNumDecals++] = i; | |
517 } | |
518 } | |
519 } | |
520 } | |
521 return 1; | |
0 | 522 } |
523 | |
524 //----- (0049BE8A) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
525 bool DecalBuilder::_49BE8A(struct Polygon *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7) |
0 | 526 { |
527 bool result; // eax@1 | |
528 RenderVertexSoft *v8; // edi@3 | |
1075 | 529 Vec3_float_ *v9; // ebx@3 |
530 Bloodsplat *v10; // esi@3 | |
0 | 531 float v11; // eax@5 |
532 float v12; // eax@6 | |
533 double v13; // st7@13 | |
534 double v14; // st7@19 | |
1075 | 535 short v15; // eax@20 |
0 | 536 int v16; // eax@22 |
537 int v17; // edx@24 | |
538 DecalBuilder *v18; // eax@24 | |
539 std::string v19; // [sp-18h] [bp-54h]@12 | |
540 const char *v20; // [sp-8h] [bp-44h]@12 | |
541 int v21; // [sp-4h] [bp-40h]@12 | |
542 double v22; // [sp+Ch] [bp-30h]@19 | |
543 unsigned int v23; // [sp+14h] [bp-28h]@1 | |
544 DecalBuilder *v24; // [sp+18h] [bp-24h]@1 | |
545 int v25; // [sp+1Ch] [bp-20h]@19 | |
546 float v26; // [sp+20h] [bp-1Ch]@12 | |
547 int v27; // [sp+24h] [bp-18h]@12 | |
548 float v28; // [sp+28h] [bp-14h]@13 | |
549 float v29; // [sp+2Ch] [bp-10h]@7 | |
550 float v30; // [sp+30h] [bp-Ch]@6 | |
551 float v31; // [sp+34h] [bp-8h]@6 | |
552 bool v32; // [sp+38h] [bp-4h]@2 | |
1075 | 553 float a3; |
0 | 554 |
555 this->uNumDecals = 0; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1086
diff
changeset
|
556 result = pBloodsplatContainer->std__vector_pBloodsplats_size != 0; |
0 | 557 v24 = this; |
558 v23 = pBloodsplatContainer->std__vector_pBloodsplats_size; | |
559 if ( pBloodsplatContainer->std__vector_pBloodsplats_size ) | |
560 { | |
561 v32 = 0; | |
562 if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 ) | |
563 { | |
564 v8 = a5; | |
1075 | 565 v9 = _a3; |
566 v10 = pBloodsplatContainer->std__vector_pBloodsplats; | |
567 while ( v32 < (signed int)v23) | |
0 | 568 { |
1075 | 569 if ( uStripType == 4 ) |
570 { | |
571 a3 = v8->vWorldPosition.x; | |
572 v11 = v8[3].vWorldPosition.x; | |
573 v31 = v11; | |
574 v30 = v8[1].vWorldPosition.y; | |
575 v12 = v8->vWorldPosition.y; | |
576 v29 = v12; | |
577 } | |
578 else if ( uStripType == 3 ) | |
0 | 579 { |
580 if ( a7 ) | |
581 { | |
582 a3 = v8->vWorldPosition.x; | |
583 v31 = v8[2].vWorldPosition.x; | |
584 v30 = v8[1].vWorldPosition.y; | |
585 v12 = v8[2].vWorldPosition.y; | |
1075 | 586 v29 = v12; |
0 | 587 } |
1075 | 588 else |
589 { | |
590 a3 = v8[1].vWorldPosition.x; | |
591 v11 = v8[2].vWorldPosition.x; | |
592 v31 = v11; | |
593 v30 = v8[1].vWorldPosition.y; | |
594 v12 = v8->vWorldPosition.y; | |
595 v29 = v12; | |
596 } | |
0 | 597 } |
1075 | 598 else |
599 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0); | |
0 | 600 v21 = uStripType; |
601 v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType); | |
602 v21 = uStripType; | |
603 v28 = v13; | |
604 v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType); | |
1075 | 605 if ( a3 - v10->radius < v10->x && |
606 v31 + v10->radius > v10->x && | |
607 v30 - v10->radius < v10->y && | |
608 v29 + v10->radius > v10->y && | |
609 v28 - v10->radius < v10->z && | |
610 v26 + v10->radius > v10->z ) | |
0 | 611 { |
1075 | 612 Vec3_float_::NegDot(&v8->vWorldPosition, v9, a4); |
613 v26 = v9->y * v10->y | |
614 + v9->z * v10->z | |
615 + v9->x * v10->x | |
616 + *a4; | |
617 v22 = v26 + 6.7553994e15; | |
618 v25 = LODWORD(v22); | |
619 v14 = (double)SLODWORD(v22); | |
620 v28 = v14; | |
621 if ( v14 <= v10->radius ) | |
622 { | |
623 v15 = a2->flags; | |
624 if ( v15 & 2 || BYTE1(v15) & 1 ) | |
625 { | |
626 v16 = v10->field_1C; | |
627 if ( !(v16 & 1) ) | |
628 { | |
629 LOBYTE(v16) = v16 | 1; | |
630 v10->field_1C = v16; | |
631 v10->field_20 = pEventTimer->Time(); | |
632 } | |
633 } | |
634 v17 = v32; | |
635 v10->dot_dist = LODWORD(v28); | |
636 v18 = v24; | |
637 v24->std__vector_30B00C[v24->uNumDecals] = v17; | |
638 ++v18->uNumDecals; | |
639 } | |
0 | 640 } |
641 ++v32; | |
1075 | 642 ++v10; |
0 | 643 result = v32; |
644 } | |
645 } | |
646 } | |
647 LOBYTE(result) = 1; | |
648 return result; | |
649 } | |
650 | |
651 | |
652 //----- (0049C2CD) -------------------------------------------------------- | |
653 void DecalBuilder::DrawDecals(float z_bias) | |
654 { | |
655 for (uint i = 0; i < std__vector_pDecals_size; ++i) | |
2155 | 656 pRenderer->DrawDecal(std__vector_pDecals + i, z_bias); |
0 | 657 } |
658 | |
659 //----- (0049C304) -------------------------------------------------------- | |
660 void DecalBuilder::DrawBloodsplats() | |
661 { | |
662 if (!std__vector_pDecals_size) | |
663 return; | |
664 | |
2155 | 665 pRenderer->BeginDecals(); |
0 | 666 |
667 DrawDecals(0.00039999999); | |
668 | |
2155 | 669 pRenderer->EndDecals(); |
0 | 670 } |
671 | |
672 //----- (0049C550) -------------------------------------------------------- | |
673 void DecalBuilder::DrawDecalDebugOutlines() | |
674 { | |
1075 | 675 for(int i = 0; i < std__vector_pDecals_size; i++) |
676 pGame->pIndoorCameraD3D->debug_outline_sw(std__vector_pDecals[i].pVertices, std__vector_pDecals[i].uNumVertices, 0xC86400u, 0.0); | |
0 | 677 } |
678 | |
679 //----- (0040E4C2) -------------------------------------------------------- | |
680 void Decal::Decal_base_ctor() | |
681 { | |
682 uNumVertices = -1; | |
683 for (uint i = 0; i < 64; ++i) | |
684 pVertices[i].flt_2C = 0.0f; | |
685 } |