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