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