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