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