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