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