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