Mercurial > might-and-magic-trilogy
comparison LightmapBuilder.cpp @ 0:8b8875f5b359
Initial commit
author | Nomad |
---|---|
date | Fri, 05 Oct 2012 16:07:14 +0200 |
parents | |
children | 2ca04ccb612a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b8875f5b359 |
---|---|
1 #include "LightmapBuilder.h" | |
2 #include "Game.h" | |
3 #include "stru314.h" | |
4 #include "Outdoor.h" | |
5 | |
6 #include "mm7_data.h" | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 LightsStack_StationaryLight_ *pStationaryLightsStack; | |
15 StationaryLight pStationaryLights[400]; | |
16 int uNumStationaryLightsApplied; // weak | |
17 LightsStack_MobileLight_ *pMobileLightsStack; | |
18 MobileLight pMobileLights[400]; | |
19 int uNumMobileLightsApplied; | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 //----- (0045DF13) -------------------------------------------------------- | |
26 Lightmap::Lightmap() | |
27 { | |
28 field_C18 = 0; | |
29 } | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 //----- (0045BB06) -------------------------------------------------------- | |
36 LightmapBuilder::LightmapBuilder() | |
37 { | |
38 //std__vector_000004.reserve(512); | |
39 //std__vector_183808.reserve(768); | |
40 | |
41 for (uint i = 0; i < 256; ++i) | |
42 field_3C8C34[i].flt_2C = 0.0f; | |
43 } | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 //----- (0045BC07) -------------------------------------------------------- | |
50 char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char a7) | |
51 { | |
52 char *v7; // eax@3 | |
53 signed int v8; // ecx@3 | |
54 RenderVertexSoft *v9; // eax@10 | |
55 unsigned int v10; // edx@10 | |
56 const void *v11; // esi@11 | |
57 void *v12; // edi@11 | |
58 char v13; // zf@11 | |
59 stru154 *v14; // esi@12 | |
60 double v16; // st7@17 | |
61 double v17; // st6@17 | |
62 float v18; // eax@17 | |
63 int *v19; // esi@20 | |
64 double v20; // st7@21 | |
65 int v21; // eax@21 | |
66 unsigned int v22; // eax@21 | |
67 int v23; // ecx@23 | |
68 float v24; // ST04_4@23 | |
69 float v25; // [sp+8h] [bp-64h]@18 | |
70 Vec3_float_ *v26; // [sp+18h] [bp-54h]@17 | |
71 int v27; // [sp+1Ch] [bp-50h]@17 | |
72 int arg0; // [sp+2Ch] [bp-40h]@21 | |
73 int v29; // [sp+30h] [bp-3Ch]@21 | |
74 int v30; // [sp+34h] [bp-38h]@21 | |
75 double v31; // [sp+38h] [bp-34h]@21 | |
76 double v32; // [sp+40h] [bp-2Ch]@21 | |
77 double v33; // [sp+48h] [bp-24h]@21 | |
78 int v34; // [sp+50h] [bp-1Ch]@24 | |
79 LightmapBuilder *thisa; // [sp+54h] [bp-18h]@1 | |
80 int v36; // [sp+58h] [bp-14h]@21 | |
81 int v37; // [sp+5Ch] [bp-10h]@21 | |
82 unsigned __int64 v38; // [sp+60h] [bp-Ch]@21 | |
83 int a9; // [sp+68h] [bp-4h]@8 | |
84 | |
85 thisa = this; | |
86 if ( !uNumVertices ) | |
87 return 0; | |
88 | |
89 static bool _static_initialized = false; | |
90 static RenderVertexSoft LightmapBuilder_static_sub_45BC07_stru_69B140[64]; | |
91 if (!_static_initialized) | |
92 { | |
93 for (uint i = 0; i < 64; ++i) | |
94 LightmapBuilder_static_sub_45BC07_stru_69B140[i].flt_2C = 0.0f; | |
95 _static_initialized = true; | |
96 } | |
97 | |
98 a9 = (int)a5; | |
99 if ( a6 == 0.0 ) | |
100 { | |
101 v14 = a3; | |
102 } | |
103 else | |
104 { | |
105 if ( (signed int)uNumVertices > 0 ) | |
106 { | |
107 v9 = LightmapBuilder_static_sub_45BC07_stru_69B140; | |
108 v10 = (char *)a5 - (char *)LightmapBuilder_static_sub_45BC07_stru_69B140; | |
109 a5 = (RenderVertexSoft *)uNumVertices; | |
110 do | |
111 { | |
112 v11 = (char *)v9 + v10; | |
113 v12 = v9; | |
114 ++v9; | |
115 v13 = a5 == (RenderVertexSoft *)1; | |
116 a5 = (RenderVertexSoft *)((char *)a5 - 1); | |
117 memcpy(v12, v11, 0x30u); | |
118 } | |
119 while ( !v13 ); | |
120 } | |
121 v14 = a3; | |
122 if ( pGame->pIndoorCameraD3D->_437376( | |
123 a3, | |
124 LightmapBuilder_static_sub_45BC07_stru_69B140, | |
125 &uNumVertices) == 1 ) | |
126 { | |
127 if ( !uNumVertices ) | |
128 return 0; | |
129 a9 = (int)LightmapBuilder_static_sub_45BC07_stru_69B140; | |
130 } | |
131 } | |
132 v16 = v14->vNormal.z; | |
133 v17 = v14->vNormal.y; | |
134 v18 = v14->vNormal.x; | |
135 | |
136 static stru314 LightmapBuilder_static_sub_45BC07_stru_69B110; | |
137 v27 = (int)&LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C; | |
138 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.y = v17; | |
139 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.x = v18; | |
140 v26 = &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10; | |
141 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.z = v16; | |
142 dword_69B138 = LODWORD(v14->field_10); | |
143 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation( | |
144 v14->field_14, | |
145 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_4, | |
146 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10, | |
147 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C) ) | |
148 { | |
149 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); | |
150 ExitProcess(0); | |
151 } | |
152 a5 = 0; | |
153 if ( a2->field_AC > 0 ) | |
154 { | |
155 v19 = a2->_blv_lights_ys; | |
156 do | |
157 { | |
158 v20 = *((float *)v19 + 80) * 255.0; | |
159 arg0 = *(v19 - 20); | |
160 v29 = *v19; | |
161 v30 = v19[60]; | |
162 v21 = *(v19 - 60); | |
163 a6 = v20; | |
164 v36 = v21; | |
165 v37 = v19[20]; | |
166 v33 = a6 + 6.7553994e15; | |
167 a6 = *((float *)v19 + 100) * 255.0; | |
168 v32 = a6 + 6.7553994e15; | |
169 a6 = *((float *)v19 + 120) * 255.0; | |
170 v31 = a6 + 6.7553994e15; | |
171 v38 = __PAIR__(LODWORD(v32), LODWORD(v31)); | |
172 v22 = LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8); | |
173 if ( !(LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8)) ) | |
174 v22 = 0xFFFFFFu; | |
175 v27 = a7; | |
176 v23 = (int)a5; | |
177 v26 = (Vec3_float_ *)a9; | |
178 LOBYTE(v23) = *((unsigned char *)&a5[20].vWorldViewPosition.y + (unsigned int)a2); | |
179 v25 = (double)v37; | |
180 v24 = (double)v36; | |
181 if ( !_45BE86_build_light_polygon( | |
182 (int)&arg0, | |
183 v24, | |
184 v22, | |
185 v25, | |
186 v23, | |
187 &LightmapBuilder_static_sub_45BC07_stru_69B110, | |
188 uNumVertices, | |
189 (RenderVertexSoft *)a9, | |
190 a7) ) | |
191 { | |
192 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); | |
193 v34 = 5080748; | |
194 } | |
195 a5 = (RenderVertexSoft *)((char *)a5 + 1); | |
196 ++v19; | |
197 } | |
198 while ( (signed int)a5 < a2->field_AC ); | |
199 } | |
200 return 1; | |
201 } | |
202 | |
203 //----- (0045BE86) -------------------------------------------------------- | |
204 char LightmapBuilder::_45BE86_build_light_polygon(int arg0, float a4, int arg8, float a5, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag) | |
205 { | |
206 LightmapBuilder *v10; // esi@1 | |
207 Lightmap *v11; // edi@3 | |
208 double v12; // st7@5 | |
209 double v13; // st7@5 | |
210 stru314 *v14; // ebx@5 | |
211 double v15; // st7@5 | |
212 RenderVertexSoft *pLightmapVertices; // edx@5 | |
213 double v17; // st7@5 | |
214 double v18; // st7@5 | |
215 char *v19; // eax@5 | |
216 double v20; // st6@5 | |
217 double v21; // st5@5 | |
218 signed int v22; // ecx@5 | |
219 double v23; // st5@5 | |
220 double v24; // st7@6 | |
221 int v25; // ebx@8 | |
222 double v26; // st7@8 | |
223 int v27; // eax@8 | |
224 double v28; // st6@8 | |
225 double v29; // st6@8 | |
226 double v30; // st5@8 | |
227 int v31; // eax@8 | |
228 int v32; // ebx@8 | |
229 unsigned int v33; // ecx@8 | |
230 int v34; // edx@9 | |
231 int v35; // edx@11 | |
232 unsigned int v36; // edx@13 | |
233 int v37; // ecx@14 | |
234 double v38; // st7@14 | |
235 double v39; // st7@16 | |
236 double v40; // st7@16 | |
237 double v41; // st7@22 | |
238 stru9 *v42; // ecx@22 | |
239 char result; // al@22 | |
240 unsigned int *v44; // ebx@23 | |
241 int v45; // eax@24 | |
242 RenderVertexSoft *v46; // edi@27 | |
243 std::string *v47; // ecx@34 | |
244 char *v48; // esi@39 | |
245 int v49; // eax@39 | |
246 unsigned __int8 v50; // sf@39 | |
247 unsigned __int8 v51; // of@39 | |
248 const char *v52; // [sp-Ch] [bp-58h]@34 | |
249 int v53; // [sp-8h] [bp-54h]@34 | |
250 std::string v54; // [sp-4h] [bp-50h]@19 | |
251 float v55; // [sp+0h] [bp-4Ch]@22 | |
252 float v56; // [sp+4h] [bp-48h]@22 | |
253 int v57; // [sp+8h] [bp-44h]@22 | |
254 unsigned int v58; // [sp+Ch] [bp-40h]@16 | |
255 void *v59; // [sp+10h] [bp-3Ch]@16 | |
256 float v60; // [sp+20h] [bp-2Ch]@8 | |
257 float v61; // [sp+24h] [bp-28h]@8 | |
258 float v62; // [sp+28h] [bp-24h]@8 | |
259 Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8 | |
260 double v64; // [sp+38h] [bp-14h]@8 | |
261 int pLightmapVertices_; // [sp+40h] [bp-Ch]@5 | |
262 float v66; // [sp+44h] [bp-8h]@5 | |
263 char v67; // [sp+4Bh] [bp-1h]@2 | |
264 float arg0b; // [sp+54h] [bp+8h]@8 | |
265 int arg0c; // [sp+54h] [bp+8h]@8 | |
266 int arg0a; // [sp+54h] [bp+8h]@8 | |
267 | |
268 v10 = this; | |
269 if ( a4 == 0.0 ) | |
270 return 1; | |
271 v67 = uLightType & 1; | |
272 v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] : | |
273 &std__vector_183808[std__vector_183808_size]; | |
274 v12 = a4 - a5; | |
275 this->flt_3C8C24 = v12; | |
276 v13 = sqrt((a4 + a4 - v12) * v12); | |
277 v10->flt_3C8C28 = v13; | |
278 v14 = a7; | |
279 v66 = 1.0 / a4; | |
280 v10->flt_3C8C2C = 1.0 - (a4 - v13) * v66; | |
281 v11->field_C08 = (signed __int64)((double)*(signed int *)arg0 - a5 * v14->field_4.x); | |
282 v11->field_C0A = (signed __int64)((double)*(signed int *)(arg0 + 4) - a5 * v14->field_4.y); | |
283 v15 = a4; | |
284 v11->field_C0C = (signed __int64)((double)*(signed int *)(arg0 + 8) - a5 * v14->field_4.z); | |
285 pLightmapVertices = v11->pVertices; | |
286 v17 = v15 * v10->flt_3C8C2C; | |
287 pLightmapVertices_ = (int)v11->pVertices; | |
288 v10->flt_3C8C30 = v17; | |
289 v10->flt_3C8C0C = v17 * v14->field_10.x; | |
290 v10->flt_3C8C10 = v17 * v14->field_10.y; | |
291 v10->flt_3C8C14 = v17 * v14->field_10.z; | |
292 v10->flt_3C8C18 = v17 * v14->field_1C.x; | |
293 v10->flt_3C8C1C = v17 * v14->field_1C.y; | |
294 v10->flt_3C8C20 = v17 * v14->field_1C.z; | |
295 LODWORD(a5) = v11->field_C08; | |
296 v18 = (double)SLODWORD(a5); | |
297 v11->pVertices[0].vWorldPosition.x = v18 - v10->flt_3C8C18 + v10->flt_3C8C0C; | |
298 LODWORD(a5) = v11->field_C0A; | |
299 v19 = (char *)&v11->pVertices[0].vWorldPosition.y; | |
300 v20 = (double)SLODWORD(a5); | |
301 v21 = v20 - v10->flt_3C8C1C; | |
302 LODWORD(a5) = v11->field_C0C; | |
303 v22 = 4; | |
304 v11->pVertices[0].vWorldPosition.y = v21 + v10->flt_3C8C10; | |
305 v23 = (double)SLODWORD(a5); | |
306 a5 = v23; | |
307 v11->pVertices[0].vWorldPosition.z = v23 - v10->flt_3C8C20 + v10->flt_3C8C14; | |
308 v11->pVertices[0].u = 0.0; | |
309 v11->pVertices[0].v = 0.0; | |
310 v11->pVertices[1].vWorldPosition.x = v18 - v10->flt_3C8C18 - v10->flt_3C8C0C; | |
311 v11->pVertices[1].vWorldPosition.y = v20 - v10->flt_3C8C1C - v10->flt_3C8C10; | |
312 v11->pVertices[1].vWorldPosition.z = v23 - v10->flt_3C8C20 - v10->flt_3C8C14; | |
313 v11->pVertices[1].u = 0.0; | |
314 v11->pVertices[1].v = 1.0; | |
315 v11->pVertices[2].vWorldPosition.x = v18 + v10->flt_3C8C18 - v10->flt_3C8C0C; | |
316 v11->pVertices[2].vWorldPosition.y = v20 + v10->flt_3C8C1C - v10->flt_3C8C10; | |
317 v11->pVertices[2].vWorldPosition.z = v23 + v10->flt_3C8C20 - v10->flt_3C8C14; | |
318 v11->pVertices[2].u = 1.0; | |
319 v11->pVertices[2].v = 1.0; | |
320 v11->pVertices[3].vWorldPosition.x = v18 + v10->flt_3C8C18 + v10->flt_3C8C0C; | |
321 v11->pVertices[3].vWorldPosition.y = v20 + v10->flt_3C8C1C + v10->flt_3C8C10; | |
322 v11->pVertices[3].vWorldPosition.z = a5 + v10->flt_3C8C20 + v10->flt_3C8C14; | |
323 v11->pVertices[3].u = 1.0; | |
324 v11->pVertices[3].v = 0.0; | |
325 do | |
326 { | |
327 v24 = v14->field_4.y * *(float *)v19 | |
328 + *((float *)v19 + 1) * v14->field_4.z | |
329 + v14->field_4.x * *((float *)v19 - 1) | |
330 + *(float *)&v14->field_28; | |
331 *((float *)v19 - 1) = *((float *)v19 - 1) - v24 * v14->field_4.x; | |
332 *(float *)v19 = *(float *)v19 - v24 * v14->field_4.y; | |
333 v19 += 48; | |
334 --v22; | |
335 *((float *)v19 - 11) = *((float *)v19 - 11) - v24 * v14->field_4.z; | |
336 } | |
337 while ( v22 ); | |
338 v11->field_C10 = arg8; | |
339 v11->uNumVertices = 4; | |
340 if ( pGame->uFlags2 & 4 ) | |
341 { | |
342 LODWORD(a5) = v11->field_C0C; | |
343 v25 = arg0; | |
344 v26 = (double)SLODWORD(a5); | |
345 LODWORD(a5) = v11->field_C0A; | |
346 v27 = v11->field_C08; | |
347 a5 = (double)SLODWORD(a5); | |
348 arg8 = v27; | |
349 v28 = (double)v27; | |
350 v61 = a5; | |
351 v60 = v28; | |
352 v62 = v26; | |
353 *(float *)&arg8 = (double)*(signed int *)(arg0 + 8); | |
354 arg0b = (double)*(signed int *)(arg0 + 4); | |
355 v29 = (double)*(signed int *)v25 - v28; | |
356 v30 = arg0b - a5; | |
357 a5 = *(float *)&arg8 - v26; | |
358 a1.x = v29; | |
359 a1.z = a5; | |
360 a1.y = v30; | |
361 a1.Normalize(); | |
362 v64 = v62 + 6.7553994e15; | |
363 LODWORD(a5) = LODWORD(v64); | |
364 v64 = v61 + 6.7553994e15; | |
365 arg0c = LODWORD(v64); | |
366 v64 = v60 + 6.7553994e15; | |
367 arg8 = LODWORD(v64); | |
368 HIDWORD(v64) = abs(*(int *)(v25 + 8) - (signed)LODWORD(a5)); | |
369 arg0a = abs(*(int *)(v25 + 4) - arg0c); | |
370 v31 = abs(*(int *)v25 - arg8); | |
371 LODWORD(a5) = v31; | |
372 v32 = arg0a; | |
373 v33 = HIDWORD(v64); | |
374 if ( v31 < arg0a ) | |
375 { | |
376 v34 = v31; | |
377 v31 = arg0a; | |
378 v32 = v34; | |
379 } | |
380 if ( v31 < SHIDWORD(v64) ) | |
381 { | |
382 v35 = v31; | |
383 v31 = HIDWORD(v64); | |
384 v33 = v35; | |
385 } | |
386 if ( v32 < (signed int)v33 ) | |
387 { | |
388 v36 = v33; | |
389 v33 = v32; | |
390 v32 = v36; | |
391 } | |
392 v37 = v33 >> 2; | |
393 LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31; | |
394 v38 = (double)SLODWORD(a5); | |
395 if ( v38 > a4 ) | |
396 return 1; | |
397 a4 = v66 * v38; | |
398 if ( uLightType & 4 ) | |
399 { | |
400 v59 = (void *)v37; | |
401 uLightType = dword_4D86CC; | |
402 v58 = v37; | |
403 v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y); | |
404 v40 = v39 * 1.0 * *(float *)&uLightType; | |
405 } | |
406 else | |
407 { | |
408 if ( uLightType & 8 ) | |
409 { | |
410 v40 = 1.0 * 1.0; | |
411 } | |
412 else | |
413 { | |
414 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0); | |
415 v40 = *(float *)&uLightType; | |
416 } | |
417 } | |
418 v14 = a7; | |
419 pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_; | |
420 v11->flt_C14 = v40 - a4 * v40; | |
421 } | |
422 else | |
423 { | |
424 v11->flt_C14 = v10->flt_3C8C2C; | |
425 } | |
426 v41 = v14->field_4.z; | |
427 v42 = pGame->pStru9Instance; | |
428 v59 = &v11->uNumVertices; | |
429 v58 = (unsigned int)pLightmapVertices; | |
430 *(float *)&v57 = v41; | |
431 v56 = v14->field_4.y; | |
432 v55 = v14->field_4.x; | |
433 result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices); | |
434 if ( !result ) | |
435 return result; | |
436 v44 = &v11->uNumVertices; | |
437 if ( !v11->uNumVertices ) | |
438 return 1; | |
439 v45 = v10->_45C6D6(a2, a9, v11); | |
440 if ( v45 != a2 && v45 > 0 ) | |
441 v10->_45C4B9(a2, a9, v11); | |
442 v59 = (void *)*v44; | |
443 v46 = (RenderVertexSoft *)pLightmapVertices_; | |
444 pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)pLightmapVertices_, (unsigned int)v59); | |
445 v59 = 0; | |
446 v58 = *v44; | |
447 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v46, v58, 0); | |
448 if ( !(uClipFlag & 1) ) | |
449 goto LABEL_38; | |
450 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
451 { | |
452 if ( uClipFlag & 2 ) | |
453 { | |
454 v59 = &a4; | |
455 v58 = (unsigned int)v10->field_3C8C34; | |
456 v57 = *v44; | |
457 pGame->pIndoorCameraD3D->_436CDC(v46, v57, v10->field_3C8C34, (unsigned int *)&a4); | |
458 LABEL_33: | |
459 v59 = v44; | |
460 v58 = (unsigned int)v10->field_3C8C34; | |
461 v57 = (int)v46; | |
462 v56 = a4; | |
463 pGame->pIndoorCameraD3D->_437143(LODWORD(a4), v46, v10->field_3C8C34, v44); | |
464 goto LABEL_37; | |
465 } | |
466 if ( uClipFlag & 4 ) | |
467 { | |
468 v59 = &a4; | |
469 v58 = (unsigned int)v10->field_3C8C34; | |
470 v57 = *v44; | |
471 pGame->pIndoorCameraD3D->_436F09(v46, v57, v10->field_3C8C34, (unsigned int *)&a4); | |
472 goto LABEL_33; | |
473 } | |
474 v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330"; | |
475 v52 = "Undefined clip flag specified"; | |
476 } | |
477 else | |
478 { | |
479 v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335"; | |
480 v52 = "Lightpoly builder native indoor clipping not implemented"; | |
481 } | |
482 MessageBoxA(nullptr, v52, (const char *)v58, 0); | |
483 LABEL_37: | |
484 if ( a4 != 0.0 ) | |
485 { | |
486 LABEL_38: | |
487 if ( v67 ) | |
488 { | |
489 v48 = (char *)&v10->std__vector_000004_size; | |
490 v49 = *(unsigned int *)v48; | |
491 v51 = __OFSUB__(*(unsigned int *)v48, 511); | |
492 v50 = *(unsigned int *)v48 - 511 < 0; | |
493 } | |
494 else | |
495 { | |
496 v48 = (char *)&v10->std__vector_183808_size; | |
497 v49 = *(unsigned int *)v48; | |
498 v51 = __OFSUB__(*(unsigned int *)v48, 767); | |
499 v50 = *(unsigned int *)v48 - 767 < 0; | |
500 } | |
501 if ( v50 ^ v51 ) | |
502 *(unsigned int *)v48 = v49 + 1; | |
503 } | |
504 return 1; | |
505 } | |
506 | |
507 //----- (0045C4B9) -------------------------------------------------------- | |
508 int LightmapBuilder::_45C4B9(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) | |
509 { | |
510 Lightmap *v4; // edi@1 | |
511 int v5; // eax@1 | |
512 signed int v6; // ecx@1 | |
513 RenderVertexSoft *v7; // ebx@2 | |
514 int v8; // edx@3 | |
515 RenderVertexSoft *v9; // esi@3 | |
516 int v10; // eax@6 | |
517 char *v11; // edi@7 | |
518 RenderVertexSoft *v12; // ecx@8 | |
519 char v13; // bl@17 | |
520 signed int v14; // edx@17 | |
521 double v15; // st6@18 | |
522 double v16; // st6@21 | |
523 double v17; // st6@24 | |
524 signed int v18; // edx@33 | |
525 int v20; // [sp+4h] [bp-1Ch]@3 | |
526 int v21; // [sp+8h] [bp-18h]@8 | |
527 float v22; // [sp+Ch] [bp-14h]@23 | |
528 float v23; // [sp+10h] [bp-10h]@20 | |
529 int v24; // [sp+14h] [bp-Ch]@1 | |
530 RenderVertexSoft *v25; // [sp+18h] [bp-8h]@2 | |
531 char v26; // [sp+1Eh] [bp-2h]@17 | |
532 char v27; // [sp+1Fh] [bp-1h]@17 | |
533 | |
534 v4 = pLightmap; | |
535 v5 = 0; | |
536 v6 = pLightmap->uNumVertices; | |
537 v24 = 0; | |
538 if ( v6 > 0 ) | |
539 { | |
540 v7 = pLightmap->pVertices; | |
541 v25 = pLightmap->pVertices; | |
542 do | |
543 { | |
544 v20 = v5 + 1; | |
545 v8 = (v5 + 1) % v6; | |
546 v9 = &v4->pVertices[v8]; | |
547 if ( v7->vWorldPosition.x != v9->vWorldPosition.x | |
548 || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y | |
549 || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z ) | |
550 { | |
551 v10 = 0; | |
552 if ( a2 > 0 ) | |
553 { | |
554 v11 = (char *)&a3->vWorldPosition.z; | |
555 do | |
556 { | |
557 v21 = v10 + 1; | |
558 v12 = &a3[(v10 + 1) % a2]; | |
559 if ( (*((float *)v11 - 2) != v12->vWorldPosition.x | |
560 || *((float *)v11 - 1) != v12->vWorldPosition.y | |
561 || *(float *)v11 != v12->vWorldPosition.z) | |
562 && v7->vWorldPosition.x == *((float *)v11 - 2) | |
563 && v7->vWorldPosition.y == *((float *)v11 - 1) | |
564 && v7->vWorldPosition.z == *(float *)v11 | |
565 && (v9->vWorldPosition.x != v12->vWorldPosition.x | |
566 || v9->vWorldPosition.y != v12->vWorldPosition.y | |
567 || v9->vWorldPosition.z != v12->vWorldPosition.z) ) | |
568 { | |
569 v13 = 0; | |
570 v14 = 0; | |
571 v27 = 0; | |
572 v26 = 0; | |
573 if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x ) | |
574 v15 = v12->vWorldPosition.x - v9->vWorldPosition.x; | |
575 else | |
576 v15 = v9->vWorldPosition.x - v12->vWorldPosition.x; | |
577 v23 = v15; | |
578 if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y ) | |
579 v16 = v12->vWorldPosition.y - v9->vWorldPosition.y; | |
580 else | |
581 v16 = v9->vWorldPosition.y - v12->vWorldPosition.y; | |
582 v22 = v16; | |
583 if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z ) | |
584 v17 = v12->vWorldPosition.z - v9->vWorldPosition.z; | |
585 else | |
586 v17 = v9->vWorldPosition.z - v12->vWorldPosition.z; | |
587 if ( v23 < 1.0 ) | |
588 { | |
589 v13 = 1; | |
590 v14 = 1; | |
591 } | |
592 if ( v22 < 1.0 ) | |
593 { | |
594 v27 = 1; | |
595 ++v14; | |
596 } | |
597 if ( v17 < 1.0 ) | |
598 { | |
599 v26 = 1; | |
600 ++v14; | |
601 } | |
602 if ( v14 > 1 ) | |
603 { | |
604 v18 = 0; | |
605 if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x ) | |
606 { | |
607 v18 = 1; | |
608 v9->vWorldPosition.x = v12->vWorldPosition.x; | |
609 } | |
610 if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y ) | |
611 { | |
612 ++v18; | |
613 v9->vWorldPosition.y = v12->vWorldPosition.y; | |
614 } | |
615 if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z ) | |
616 { | |
617 ++v18; | |
618 v9->vWorldPosition.z = v12->vWorldPosition.z; | |
619 } | |
620 if ( v18 > 0 ) | |
621 ++v24; | |
622 } | |
623 v7 = v25; | |
624 } | |
625 ++v10; | |
626 v11 += 48; | |
627 } | |
628 while ( v21 < a2 ); | |
629 v4 = pLightmap; | |
630 } | |
631 } | |
632 v5 = v20; | |
633 v6 = v4->uNumVertices; | |
634 ++v7; | |
635 v25 = v7; | |
636 } | |
637 while ( v20 < v6 ); | |
638 } | |
639 return v24; | |
640 } | |
641 | |
642 //----- (0045C6D6) -------------------------------------------------------- | |
643 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) | |
644 { | |
645 Lightmap *v4; // edi@1 | |
646 signed int v5; // ebx@1 | |
647 signed int v6; // esi@1 | |
648 RenderVertexSoft *v7; // ecx@2 | |
649 char *v8; // edx@4 | |
650 double v9; // st7@6 | |
651 double v10; // st6@10 | |
652 double v11; // st5@14 | |
653 double v12; // st7@17 | |
654 RenderVertexSoft *v13; // eax@21 | |
655 int v15; // [sp+Ch] [bp-8h]@1 | |
656 float v16; // [sp+10h] [bp-4h]@1 | |
657 int pLightmapa; // [sp+24h] [bp+10h]@3 | |
658 | |
659 v4 = pLightmap; | |
660 v5 = 0; | |
661 v6 = -1; | |
662 v16 = 3.4028235e38; | |
663 v15 = 0; | |
664 if ( (signed int)pLightmap->uNumVertices > 0 ) | |
665 { | |
666 v7 = pLightmap->pVertices; | |
667 do | |
668 { | |
669 pLightmapa = 0; | |
670 if ( a2 > 0 ) | |
671 { | |
672 v8 = (char *)&a3->vWorldPosition.z; | |
673 do | |
674 { | |
675 if ( v7->vWorldPosition.x <= (double)*((float *)v8 - 2) ) | |
676 v9 = *((float *)v8 - 2) - v7->vWorldPosition.x; | |
677 else | |
678 v9 = v7->vWorldPosition.x - *((float *)v8 - 2); | |
679 if ( v9 < 2.0 ) | |
680 { | |
681 v10 = v7->vWorldPosition.y <= (double)*((float *)v8 - 1) ? *((float *)v8 - 1) - v7->vWorldPosition.y : v7->vWorldPosition.y - *((float *)v8 - 1); | |
682 if ( v10 < 2.0 ) | |
683 { | |
684 v11 = v7->vWorldPosition.z <= (double)*(float *)v8 ? *(float *)v8 - v7->vWorldPosition.z : v7->vWorldPosition.z - *(float *)v8; | |
685 if ( v11 < 2.0 ) | |
686 { | |
687 v12 = v9 + v11 + v10; | |
688 if ( v12 < v16 ) | |
689 { | |
690 v16 = v12; | |
691 v6 = pLightmapa; | |
692 } | |
693 } | |
694 } | |
695 } | |
696 ++pLightmapa; | |
697 v8 += 48; | |
698 } | |
699 while ( pLightmapa < a2 ); | |
700 if ( v6 != -1 ) | |
701 { | |
702 v13 = &a3[v6]; | |
703 ++v15; | |
704 v7->vWorldPosition.x = v13->vWorldPosition.x; | |
705 v7->vWorldPosition.y = v13->vWorldPosition.y; | |
706 v7->vWorldPosition.z = v13->vWorldPosition.z; | |
707 } | |
708 } | |
709 v6 = -1; | |
710 ++v5; | |
711 ++v7; | |
712 v16 = 3.4028235e38; | |
713 } | |
714 while ( v5 < (signed int)v4->uNumVertices ); | |
715 } | |
716 return v15; | |
717 } | |
718 | |
719 //----- (0045C7F6) -------------------------------------------------------- | |
720 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID) | |
721 { | |
722 BLVFace *pFace; // esi@1 | |
723 int v3; // ebx@1 | |
724 int uSectorID; // edi@1 | |
725 int v5; // ecx@5 | |
726 BLVLightMM7 *v6; // eax@7 | |
727 int v7; // edi@10 | |
728 bool result; // eax@14 | |
729 LightmapBuilder *thisa; // [sp+Ch] [bp-Ch]@1 | |
730 MobileLight *pMobileLight; // [sp+10h] [bp-8h]@2 | |
731 int uSectLights; // [sp+10h] [bp-8h]@5 | |
732 StationaryLight *pStationaryLight; // [sp+10h] [bp-8h]@11 | |
733 int v13; // [sp+14h] [bp-4h]@1 | |
734 int i; // [sp+14h] [bp-4h]@5 | |
735 | |
736 pFace = &pIndoor->pFaces[uFaceID]; | |
737 v3 = uNumMobileLightsApplied; | |
738 v13 = 0; | |
739 thisa = this; | |
740 uSectorID = pFace->uSectorID; | |
741 uFaceID = 0; | |
742 stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + pIndoor->pSectors[uSectorID].uMinAmbientLightLevel) << 16; | |
743 if ( uNumMobileLightsApplied > 0 ) | |
744 { | |
745 pMobileLight = pMobileLights; | |
746 do | |
747 { | |
748 if ( (signed int)uFaceID >= 20 ) | |
749 break; | |
750 ApplyLight_BLV((StationaryLight *)pMobileLight, pFace, &uFaceID, 1, 0); | |
751 ++v13; | |
752 ++pMobileLight; | |
753 } | |
754 while ( v13 < v3 ); | |
755 } | |
756 v5 = 0; | |
757 i = 0; | |
758 for ( uSectLights = pIndoor->pSectors[uSectorID].uNumLights; i < uSectLights; v5 = i++ + 1 ) | |
759 { | |
760 if ( (signed int)uFaceID >= 20 ) | |
761 break; | |
762 v6 = &pIndoor->pLights[*(&pIndoor->pSectors[uSectorID].pLights->vPosition.x + v5)]; | |
763 if ( !(v6->uAtributes & 8) ) | |
764 ApplyLight_BLV((StationaryLight *)v6, pFace, &uFaceID, 0, (int)&byte_4E94D0); | |
765 } | |
766 v7 = 0; | |
767 if ( uNumStationaryLightsApplied > 0 ) | |
768 { | |
769 pStationaryLight = pStationaryLights; | |
770 do | |
771 { | |
772 if ( (signed int)uFaceID >= 20 ) | |
773 break; | |
774 ApplyLight_BLV(pStationaryLight, pFace, &uFaceID, 0, (int)&byte_4E94D0); | |
775 ++pStationaryLight; | |
776 ++v7; | |
777 } | |
778 while ( v7 < uNumStationaryLightsApplied ); | |
779 } | |
780 result = uFaceID; | |
781 stru_F8AD28.field_AC = uFaceID; | |
782 LOBYTE(result) = 1; | |
783 return result; | |
784 } | |
785 // 4E94D0: using guessed type char byte_4E94D0; | |
786 // 519AB4: using guessed type int uNumStationaryLightsApplied; | |
787 | |
788 //----- (0045C911) -------------------------------------------------------- | |
789 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, char X, int a5) | |
790 { | |
791 BLVFace *result; // eax@0 | |
792 StationaryLight *v7; // edi@1 | |
793 signed int v8; // ecx@1 | |
794 int v9; // edx@2 | |
795 int v10; // edx@4 | |
796 int v11; // esi@4 | |
797 int v12; // edx@6 | |
798 double v13; // st7@8 | |
799 __int16 v14; // fps@8 | |
800 char v15; // c0@9 | |
801 char v16; // c2@9 | |
802 char v17; // c3@9 | |
803 double v18; // st6@12 | |
804 __int16 v19; // fps@12 | |
805 char v20; // c0@12 | |
806 char v21; // c2@12 | |
807 char v22; // c3@12 | |
808 signed int v23; // [sp+10h] [bp-4h]@2 | |
809 float pLighta; // [sp+1Ch] [bp+8h]@13 | |
810 signed int a2a; // [sp+20h] [bp+Ch]@4 | |
811 | |
812 v7 = pLight; | |
813 v8 = pLight->uRadius; | |
814 if ( v8 > 0 | |
815 && (result = a2, v9 = pLight->vPosition.x, v23 = v9, v9 > a2->pBounding.x1 - v8) | |
816 && v9 < v8 + a2->pBounding.x2 | |
817 && (v10 = pLight->vPosition.y, v11 = a2->pBounding.y1 - v8, a2a = v10, v10 > v11) | |
818 && v10 < v8 + result->pBounding.y2 | |
819 && (v12 = pLight->vPosition.z, v12 > result->pBounding.z1 - v8) | |
820 && v12 < v8 + result->pBounding.z2 | |
821 && ((v13 = (double)v12 * result->pFacePlane.vNormal.z | |
822 + (double)a2a * result->pFacePlane.vNormal.y | |
823 + (double)v23 * result->pFacePlane.vNormal.x | |
824 + result->pFacePlane.dist, | |
825 //UNDEF(v14), | |
826 X) | |
827 || (v15 = v13 < 0.0, v16 = 0, v17 = v13 == 0.0, BYTE1(result) = HIBYTE(v14), v13 >= 0.0)) | |
828 && (v18 = (double)pLight->uRadius, | |
829 //UNDEF(v19), | |
830 v20 = v13 < v18, | |
831 v21 = 0, | |
832 v22 = v13 == v18, | |
833 BYTE1(result) = HIBYTE(v19), | |
834 v13 <= v18) ) | |
835 { | |
836 stru_F8AD28._blv_lights_radii[*pSlot] = v8; | |
837 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v8; | |
838 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; | |
839 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; | |
840 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; | |
841 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; | |
842 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; | |
843 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; | |
844 pLighta = v13; | |
845 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15)); | |
846 result = (BLVFace *)*pSlot; | |
847 stru_F8AD28._blv_lights_smthngs[(*pSlot)++] = v7->field_B; | |
848 LOBYTE(result) = 1; | |
849 } | |
850 else | |
851 { | |
852 LOBYTE(result) = 0; | |
853 } | |
854 return (bool)result; | |
855 } | |
856 | |
857 //----- (0045CA88) -------------------------------------------------------- | |
858 int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal) | |
859 { | |
860 int result; // eax@1 | |
861 stru320 *v6; // ecx@2 | |
862 RenderVertexSoft *v7; // ebx@2 | |
863 double v8; // st7@2 | |
864 double v9; // st6@2 | |
865 char *v10; // eax@3 | |
866 double v11; // st7@5 | |
867 __int64 v12; // ST2C_8@5 | |
868 float v13; // edx@5 | |
869 int v14; // eax@5 | |
870 float v15; // ST10_4@5 | |
871 Vec3_float_ v16; // ST00_12@5 | |
872 double v17; // st7@5 | |
873 int a5; // [sp+2Ch] [bp-1Ch]@1 | |
874 float v19; // [sp+30h] [bp-18h]@1 | |
875 float v20; // [sp+34h] [bp-14h]@1 | |
876 LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1 | |
877 int v22; // [sp+3Ch] [bp-Ch]@1 | |
878 int *j; // [sp+40h] [bp-8h]@3 | |
879 int i; // [sp+44h] [bp-4h]@1 | |
880 int a3a; // [sp+58h] [bp+10h]@2 | |
881 | |
882 *(float *)&a5 = 0.0; | |
883 v19 = 0.0; | |
884 thisa = this; | |
885 v20 = 0.0; | |
886 result = _45CBD4(a3, a4, dword_69B010, &v22); | |
887 for ( i = 0; i < v22; result = i ) | |
888 { | |
889 v6 = a2; | |
890 a3a = 0; | |
891 v7 = &a3[dword_69B010[i]]; | |
892 v8 = v7->vWorldPosition.z; | |
893 v9 = v7->vWorldPosition.y; | |
894 *(float *)&a5 = v7->vWorldPosition.x; | |
895 v19 = v9; | |
896 v20 = v8; | |
897 v7->flt_2C = 0.0; | |
898 if ( a2->field_AC > 0 ) | |
899 { | |
900 v10 = (char *)a2->_blv_lights_ys; | |
901 for ( j = a2->_blv_lights_ys; ; v10 = (char *)j ) | |
902 { | |
903 v11 = (double)*((signed int *)v10 - 60); | |
904 LODWORD(v12) = *((unsigned int *)v10 - 20); | |
905 HIDWORD(v12) = *(unsigned int *)v10; | |
906 LODWORD(v13) = *((unsigned int *)v10 + 60); | |
907 v14 = a3a; | |
908 LOBYTE(v14) = v6->_blv_lights_smthngs[a3a]; | |
909 v15 = v11; | |
910 *(_QWORD *)&v16.x = v12; | |
911 v16.z = v13; | |
912 v17 = _45CC0C_light(v16/*COERCE_VEC3_FLOAT_(v16.x)*/, 1.0, v15, pNormal, *(float *)&a5/*COERCE_FLOAT(&a5)*/, v14) | |
913 + v7->flt_2C; | |
914 ++a3a; | |
915 ++j; | |
916 v7->flt_2C = v17; | |
917 if ( a3a >= a2->field_AC ) | |
918 break; | |
919 v6 = a2; | |
920 } | |
921 } | |
922 ++i; | |
923 } | |
924 return result; | |
925 } | |
926 | |
927 //----- (0045CB89) -------------------------------------------------------- | |
928 int LightmapBuilder::_45CB89(RenderVertexSoft *a1, int a2) | |
929 { | |
930 int v3; // edx@1 | |
931 int result; // eax@2 | |
932 char *v5; // ecx@2 | |
933 double v6; // st7@4 | |
934 __int16 v7; // fps@4 | |
935 char v8; // c0@4 | |
936 char v9; // c2@4 | |
937 char v10; // c3@4 | |
938 double v11; // st7@5 | |
939 double v12; // st7@6 | |
940 __int16 v13; // fps@6 | |
941 char v14; // c0@6 | |
942 char v15; // c2@6 | |
943 char v16; // c3@6 | |
944 | |
945 v3 = a2; | |
946 if ( a2 > 0 ) | |
947 { | |
948 HIWORD(result) = HIWORD(a1); | |
949 v5 = (char *)&a1->flt_2C; | |
950 do | |
951 { | |
952 if ( *(float *)v5 < 0.0 | |
953 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) ) | |
954 { | |
955 v12 = *(float *)v5; | |
956 //UNDEF(v13); | |
957 v14 = 0.0 < v12; | |
958 v15 = 0; | |
959 v16 = 0.0 == v12; | |
960 LOWORD(result) = v13; | |
961 if ( v12 >= 0.0 ) | |
962 v11 = *(float *)v5; | |
963 else | |
964 v11 = 0.0; | |
965 } | |
966 else | |
967 { | |
968 v11 = 1.0; | |
969 } | |
970 *(float *)v5 = v11; | |
971 v5 += 48; | |
972 --v3; | |
973 } | |
974 while ( v3 ); | |
975 } | |
976 return result; | |
977 } | |
978 | |
979 //----- (0045CBD4) -------------------------------------------------------- | |
980 int LightmapBuilder::_45CBD4(RenderVertexSoft *a2, int a3, int *a4, int *a5) | |
981 { | |
982 int result; // eax@1 | |
983 int v6; // edx@1 | |
984 int v7; // ecx@2 | |
985 int v8; // esi@2 | |
986 | |
987 result = (int)a5; | |
988 v6 = 0; | |
989 for ( *a5 = 0; v6 < a3; ++v6 ) | |
990 { | |
991 v7 = *a5; | |
992 v8 = 0; | |
993 if ( *a5 <= 0 ) | |
994 { | |
995 LABEL_5: | |
996 a4[v7] = v6; | |
997 ++*a5; | |
998 } | |
999 else | |
1000 { | |
1001 while ( a4[v8] != v6 ) | |
1002 { | |
1003 ++v8; | |
1004 if ( v8 >= v7 ) | |
1005 goto LABEL_5; | |
1006 } | |
1007 } | |
1008 } | |
1009 return result; | |
1010 } | |
1011 | |
1012 //----- (0045CC0C) -------------------------------------------------------- | |
1013 double LightmapBuilder::_45CC0C_light(Vec3_float_ a1, float a2, float a3, Vec3_float_ *pNormal, float a5, int uLightType) | |
1014 { | |
1015 float v7; // esi@1 | |
1016 int v8; // eax@1 | |
1017 int v9; // ebx@1 | |
1018 unsigned int v10; // ecx@1 | |
1019 int v11; // edx@2 | |
1020 int v12; // edx@4 | |
1021 unsigned int v13; // edx@6 | |
1022 double v14; // st7@7 | |
1023 double result; // st7@8 | |
1024 double v16; // st7@9 | |
1025 int v17; // esi@9 | |
1026 const char *v18; // ecx@9 | |
1027 double v19; // st7@10 | |
1028 double v20; // st7@10 | |
1029 std::string v21; // [sp-10h] [bp-40h]@13 | |
1030 const char *v22[6]; // [sp+0h] [bp-30h]@10 | |
1031 double v23; // [sp+18h] [bp-18h]@1 | |
1032 double v24; // [sp+20h] [bp-10h]@1 | |
1033 int v25; // [sp+28h] [bp-8h]@1 | |
1034 int v26; // [sp+2Ch] [bp-4h]@1 | |
1035 | |
1036 v7 = a5; | |
1037 LODWORD(a5) = *(unsigned int *)(LODWORD(a5) + 8); | |
1038 v24 = a5 + 6.7553994e15; | |
1039 v26 = LODWORD(v24); | |
1040 LODWORD(a5) = *(unsigned int *)(LODWORD(v7) + 4); | |
1041 v24 = a5 + 6.7553994e15; | |
1042 LODWORD(a5) = *(unsigned int *)LODWORD(v7); | |
1043 v23 = a5 + 6.7553994e15; | |
1044 *(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23)); | |
1045 v26 = abs((signed)LODWORD(a1.z) - v26); | |
1046 v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24)); | |
1047 v8 = abs((int)a1.x - (signed)LODWORD(v23)); | |
1048 LODWORD(a5) = v8; | |
1049 v9 = v25; | |
1050 v10 = v26; | |
1051 if ( v8 < v25 ) | |
1052 { | |
1053 v11 = v8; | |
1054 v8 = v25; | |
1055 v9 = v11; | |
1056 } | |
1057 if ( v8 < v26 ) | |
1058 { | |
1059 v12 = v8; | |
1060 v8 = v26; | |
1061 v10 = v12; | |
1062 } | |
1063 if ( v9 < (signed int)v10 ) | |
1064 { | |
1065 v13 = v10; | |
1066 v10 = v9; | |
1067 v9 = v13; | |
1068 } | |
1069 v14 = (double)(signed int)(((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8); | |
1070 if ( v14 <= a3 ) | |
1071 { | |
1072 a5 = v14 / a3; | |
1073 v16 = (double)(signed int)a1.x; | |
1074 *(float *)&v23 = (double)SLODWORD(a1.y); | |
1075 LODWORD(a1.x) = *(unsigned int *)LODWORD(v7); | |
1076 v17 = LODWORD(v7) + 4; | |
1077 *((float *)&v23 + 1) = (double)SLODWORD(a1.z); | |
1078 LODWORD(a1.y) = *(unsigned int *)v17; | |
1079 LODWORD(a1.z) = *(unsigned int *)(v17 + 4); | |
1080 a3 = *((float *)&v23 + 1) - a1.z; | |
1081 a1.z = a3; | |
1082 a1.x = v16 - a1.x; | |
1083 a1.y = (float)v23 - a1.y; | |
1084 a1.Normalize(); | |
1085 if ( uLightType & 4 ) | |
1086 { | |
1087 v22[1] = v18; | |
1088 uLightType = dword_4D86D8; | |
1089 v22[0] = v18; | |
1090 v19 = fabs(a1.z * pNormal->z + a1.y * pNormal->y + a1.x * pNormal->x); | |
1091 v20 = v19 * *(float *)&uLightType * a2; | |
1092 } | |
1093 else | |
1094 { | |
1095 if ( uLightType & 8 ) | |
1096 { | |
1097 v20 = 1.3 * a2; | |
1098 } | |
1099 else | |
1100 { | |
1101 MessageBoxW(nullptr, L"Invalid light type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:783", 0); | |
1102 v20 = *(float *)&uLightType; | |
1103 } | |
1104 } | |
1105 result = v20 - a5 * v20; | |
1106 } | |
1107 else | |
1108 { | |
1109 result = 0.0; | |
1110 } | |
1111 return result; | |
1112 } | |
1113 // 4D86D8: using guessed type int dword_4D86D8; | |
1114 | |
1115 //----- (0045CDB7) -------------------------------------------------------- | |
1116 bool LightmapBuilder::ApplyLights_OutdoorFace(ODMFace *pFace) | |
1117 { | |
1118 int v2; // esi@1 | |
1119 int v3; // eax@1 | |
1120 MobileLight *pMobileLight; // ebx@2 | |
1121 int v5; // esi@5 | |
1122 StationaryLight *pStationaryLight; // ebx@6 | |
1123 bool result; // eax@9 | |
1124 LightmapBuilder *thisa; // [sp+Ch] [bp-8h]@1 | |
1125 int pSlot; // [sp+10h] [bp-4h]@1 | |
1126 | |
1127 v2 = 0; | |
1128 thisa = this; | |
1129 v3 = stru_F8AD28.field_3F8 + pFace->uShadeType; | |
1130 pSlot = 0; | |
1131 stru_F8AD28.field_2C = v3 << 16; | |
1132 if ( uNumMobileLightsApplied > 0 ) | |
1133 { | |
1134 pMobileLight = pMobileLights; | |
1135 do | |
1136 { | |
1137 if ( pSlot >= 20 ) | |
1138 break; | |
1139 ApplyLight_ODM((StationaryLight *)pMobileLight, pFace, (unsigned int *)&pSlot, 1); | |
1140 ++v2; | |
1141 ++pMobileLight; | |
1142 } | |
1143 while ( v2 < uNumMobileLightsApplied ); | |
1144 } | |
1145 v5 = 0; | |
1146 if ( uNumStationaryLightsApplied > 0 ) | |
1147 { | |
1148 pStationaryLight = pStationaryLights; | |
1149 do | |
1150 { | |
1151 if ( pSlot >= 20 ) | |
1152 break; | |
1153 ApplyLight_ODM(pStationaryLight, pFace, (unsigned int *)&pSlot, 0); | |
1154 ++v5; | |
1155 ++pStationaryLight; | |
1156 } | |
1157 while ( v5 < uNumStationaryLightsApplied ); | |
1158 } | |
1159 result = pSlot; | |
1160 stru_F8AD28.field_AC = pSlot; | |
1161 LOBYTE(result) = 1; | |
1162 return result; | |
1163 } | |
1164 // 519AB4: using guessed type int uNumStationaryLightsApplied; | |
1165 | |
1166 //----- (0045CE50) -------------------------------------------------------- | |
1167 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4) | |
1168 { | |
1169 int result; // eax@0 | |
1170 signed int v6; // ebx@1 | |
1171 int v7; // ecx@2 | |
1172 int v8; // esi@4 | |
1173 int v9; // edx@6 | |
1174 int v10; // ecx@8 | |
1175 int v11; // eax@11 | |
1176 unsigned int v12; // ebx@11 | |
1177 RenderD3D *v13; // ecx@11 | |
1178 char v14; // dl@11 | |
1179 | |
1180 v6 = pLight->uRadius; | |
1181 if ( v6 > 0 | |
1182 && (result = (int)pFace, v7 = pLight->vPosition.x, v7 > pFace->pBoundingBox.x1 - v6) | |
1183 && v7 < v6 + pFace->pBoundingBox.x2 | |
1184 && (v8 = pLight->vPosition.y, v8 > pFace->pBoundingBox.y1 - v6) | |
1185 && v8 < v6 + pFace->pBoundingBox.y2 | |
1186 && (v9 = pLight->vPosition.z, v9 > pFace->pBoundingBox.z1 - v6) | |
1187 && v9 < v6 + pFace->pBoundingBox.z2 | |
1188 && ((v10 = (pFace->pFacePlane.dist | |
1189 + pLight->vPosition.x * pFace->pFacePlane.vNormal.x | |
1190 + v8 * pFace->pFacePlane.vNormal.y | |
1191 + v9 * pFace->pFacePlane.vNormal.z) >> 16, | |
1192 a4) | |
1193 || v10 >= 0) | |
1194 && v10 <= v6 ) | |
1195 { | |
1196 stru_F8AD28._blv_lights_radii[*pSlot] = v6; | |
1197 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v6; | |
1198 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; | |
1199 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; | |
1200 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; | |
1201 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; | |
1202 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; | |
1203 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; | |
1204 v11 = abs(v10); | |
1205 v12 = pRenderer->bUsingSpecular; | |
1206 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11; | |
1207 stru_F8AD28._blv_lights_smthngs[*pSlot] = pLight->field_B; | |
1208 v13 = pRenderer->pRenderD3D; | |
1209 v14 = stru_F8AD28._blv_lights_smthngs[*pSlot]; | |
1210 if ( pRenderer->pRenderD3D && v12 && v14 & 4 ) | |
1211 v14 = byte_4E94D2; | |
1212 stru_F8AD28._blv_lights_smthngs[*pSlot] = v14; | |
1213 result = 4 * *pSlot; | |
1214 if ( v13 && v12 ) | |
1215 { | |
1216 if ( stru_F8AD28._blv_lights_smthngs[*pSlot] & 4 ) | |
1217 { | |
1218 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) | |
1219 * 0.33000001; | |
1220 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) | |
1221 * 0.33000001; | |
1222 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) | |
1223 * 0.33000001; | |
1224 } | |
1225 } | |
1226 ++*pSlot; | |
1227 LOBYTE(result) = 1; | |
1228 } | |
1229 else | |
1230 { | |
1231 LOBYTE(result) = 0; | |
1232 } | |
1233 return result; | |
1234 } | |
1235 // 4E94D2: using guessed type char byte_4E94D2; | |
1236 | |
1237 //----- (0045D036) -------------------------------------------------------- | |
1238 bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X) | |
1239 { | |
1240 int v6; // esi@1 | |
1241 LightmapBuilder *v7; // edi@1 | |
1242 MobileLight *v8; // ebx@2 | |
1243 int v9; // esi@5 | |
1244 StationaryLight *v10; // ebx@6 | |
1245 bool result; // eax@9 | |
1246 unsigned int a7; // [sp+Ch] [bp-4h]@1 | |
1247 | |
1248 v6 = 0; | |
1249 v7 = this; | |
1250 a7 = 0; | |
1251 stru_F8AD28.field_2C = pOutdoor->field_CBC_terrain_triangles_shade_type; | |
1252 if ( uNumMobileLightsApplied > 0 ) | |
1253 { | |
1254 v8 = pMobileLights; | |
1255 do | |
1256 { | |
1257 if ( (signed int)a7 >= 20 ) | |
1258 break; | |
1259 StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, X, &a7); | |
1260 ++v6; | |
1261 ++v8; | |
1262 } | |
1263 while ( v6 < uNumMobileLightsApplied ); | |
1264 } | |
1265 v9 = 0; | |
1266 if ( uNumStationaryLightsApplied > 0 ) | |
1267 { | |
1268 v10 = pStationaryLights; | |
1269 do | |
1270 { | |
1271 if ( (signed int)a7 >= 20 ) | |
1272 break; | |
1273 StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, X, &a7); | |
1274 ++v9; | |
1275 ++v10; | |
1276 } | |
1277 while ( v9 < uNumStationaryLightsApplied ); | |
1278 } | |
1279 result = a7; | |
1280 stru_F8AD28.field_AC = a7; | |
1281 LOBYTE(result) = 1; | |
1282 return result; | |
1283 } | |
1284 // 519AB4: using guessed type int uNumStationaryLightsApplied; | |
1285 | |
1286 //----- (0045D0D5) -------------------------------------------------------- | |
1287 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot) | |
1288 { | |
1289 StationaryLight *v8; // edi@1 | |
1290 bool result; // eax@1 | |
1291 unsigned int v10; // esi@2 | |
1292 RenderVertexSoft *v11; // ebx@2 | |
1293 float v12; // eax@3 | |
1294 float v13; // eax@4 | |
1295 double v14; // st7@11 | |
1296 double maxz; // st7@11 | |
1297 double v16; // st7@11 | |
1298 double v17; // st6@11 | |
1299 __int16 v18; // fps@11 | |
1300 char v19; // c0@11 | |
1301 char v20; // c2@11 | |
1302 char v21; // c3@11 | |
1303 double v22; // st6@12 | |
1304 __int16 v23; // fps@12 | |
1305 char v24; // c0@12 | |
1306 char v25; // c2@12 | |
1307 char v26; // c3@12 | |
1308 double v27; // st7@13 | |
1309 double v28; // st6@13 | |
1310 __int16 v29; // fps@13 | |
1311 char v30; // c0@13 | |
1312 char v31; // c2@13 | |
1313 char v32; // c3@13 | |
1314 double v33; // st6@14 | |
1315 __int16 v34; // fps@14 | |
1316 char v35; // c0@14 | |
1317 char v36; // c2@14 | |
1318 char v37; // c3@14 | |
1319 double v38; // st7@15 | |
1320 double v39; // st6@15 | |
1321 __int16 v40; // fps@15 | |
1322 char v41; // c0@15 | |
1323 char v42; // c2@15 | |
1324 char v43; // c3@15 | |
1325 double v44; // st6@16 | |
1326 __int16 v45; // fps@16 | |
1327 char v46; // c0@16 | |
1328 char v47; // c2@16 | |
1329 char v48; // c3@16 | |
1330 Vec3_float_ *v49; // esi@17 | |
1331 double v50; // st7@17 | |
1332 double v51; // st6@17 | |
1333 signed int v52; // ecx@17 | |
1334 unsigned int *v53; // esi@18 | |
1335 int v54; // eax@18 | |
1336 unsigned int v55; // ebx@18 | |
1337 RenderD3D *v56; // ecx@18 | |
1338 char v57; // dl@18 | |
1339 std::string v58; // [sp-18h] [bp-38h]@10 | |
1340 const char *v59; // [sp-8h] [bp-28h]@10 | |
1341 signed int v60; // [sp-4h] [bp-24h]@10 | |
1342 double v61; // [sp+Ch] [bp-14h]@11 | |
1343 float minz; // [sp+14h] [bp-Ch]@11 | |
1344 int v63; // [sp+18h] [bp-8h]@1 | |
1345 float v64; // [sp+1Ch] [bp-4h]@5 | |
1346 | |
1347 v8 = pLight; | |
1348 result = pLight->uRadius; | |
1349 v63 = pLight->uRadius; | |
1350 if ( result <= 0 ) | |
1351 goto LABEL_27; | |
1352 v10 = uStripType; | |
1353 v11 = a1; | |
1354 if ( uStripType == 4 ) | |
1355 { | |
1356 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); | |
1357 v12 = a1[3].vWorldPosition.x; | |
1358 } | |
1359 else | |
1360 { | |
1361 if ( uStripType != 3 ) | |
1362 { | |
1363 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0); | |
1364 goto LABEL_11; | |
1365 } | |
1366 if ( (unsigned char)X ) | |
1367 { | |
1368 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); | |
1369 uStripType = LODWORD(a1[2].vWorldPosition.x); | |
1370 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); | |
1371 v13 = v11[2].vWorldPosition.y; | |
1372 goto LABEL_5; | |
1373 } | |
1374 pLight = (StationaryLight *)LODWORD(a1[1].vWorldPosition.x); | |
1375 v12 = a1[2].vWorldPosition.x; | |
1376 } | |
1377 uStripType = LODWORD(v12); | |
1378 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); | |
1379 v13 = v11->vWorldPosition.y; | |
1380 LABEL_5: | |
1381 v64 = v13; | |
1382 LABEL_11: | |
1383 v60 = v10; | |
1384 v59 = (const char *)v11; | |
1385 v14 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, v10); | |
1386 v60 = v10; | |
1387 minz = v14; | |
1388 maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, v10); | |
1389 result = v8->vPosition.x; | |
1390 *((float *)&v61 + 1) = maxz; | |
1391 v16 = (double)result; | |
1392 *(float *)&X = (double)v63; | |
1393 v17 = *(float *)&pLight - *(float *)&X; | |
1394 //UNDEF(v18); | |
1395 v19 = v16 < v17; | |
1396 v20 = 0; | |
1397 v21 = v16 == v17; | |
1398 BYTE1(result) = HIBYTE(v18); | |
1399 if ( v16 <= v17 | |
1400 || (v22 = *(float *)&X + *(float *)&uStripType, | |
1401 //UNDEF(v23), | |
1402 v24 = v16 < v22, | |
1403 v25 = 0, | |
1404 v26 = v16 == v22, | |
1405 BYTE1(result) = HIBYTE(v23), | |
1406 v16 >= v22) | |
1407 || (result = v8->vPosition.y, | |
1408 pLight = (StationaryLight *)v8->vPosition.y, | |
1409 v27 = (double)(signed int)pLight, | |
1410 v28 = *(float *)&a1 - *(float *)&X, | |
1411 //UNDEF(v29), | |
1412 v30 = v27 < v28, | |
1413 v31 = 0, | |
1414 v32 = v27 == v28, | |
1415 BYTE1(result) = HIBYTE(v29), | |
1416 v27 <= v28) | |
1417 || (v33 = *(float *)&X + v64, | |
1418 //UNDEF(v34), | |
1419 v35 = v27 < v33, | |
1420 v36 = 0, | |
1421 v37 = v27 == v33, | |
1422 BYTE1(result) = HIBYTE(v34), | |
1423 v27 >= v33) | |
1424 || (result = v8->vPosition.z, | |
1425 pLight = (StationaryLight *)v8->vPosition.z, | |
1426 v38 = (double)(signed int)pLight, | |
1427 v39 = minz - *(float *)&X, | |
1428 //UNDEF(v40), | |
1429 v41 = v38 < v39, | |
1430 v42 = 0, | |
1431 v43 = v38 == v39, | |
1432 BYTE1(result) = HIBYTE(v40), | |
1433 v38 <= v39) | |
1434 || (v44 = *(float *)&X + *((float *)&v61 + 1), | |
1435 //UNDEF(v45), | |
1436 v46 = v38 < v44, | |
1437 v47 = 0, | |
1438 v48 = v38 == v44, | |
1439 BYTE1(result) = HIBYTE(v45), | |
1440 v38 >= v44) | |
1441 || (v49 = pNormal, | |
1442 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3), | |
1443 X = v8->vPosition.y, | |
1444 v50 = (double)X * v49->y, | |
1445 X = v8->vPosition.z, | |
1446 v51 = (double)X * v49->z, | |
1447 X = v8->vPosition.x, | |
1448 *(float *)&a3 = v50 + v51 + (double)X * v49->x + *a3, | |
1449 v61 = *(float *)&a3 + 6.7553994e15, | |
1450 result = LODWORD(v61), | |
1451 X = LODWORD(v61), | |
1452 v52 = v63, | |
1453 SLODWORD(v61) > v63) ) | |
1454 { | |
1455 LABEL_27: | |
1456 LOBYTE(result) = 0; | |
1457 return result; | |
1458 } | |
1459 v53 = pSlot; | |
1460 v60 = X; | |
1461 stru_F8AD28._blv_lights_radii[*pSlot] = v63; | |
1462 stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v52; | |
1463 stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x; | |
1464 stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y; | |
1465 stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z; | |
1466 a3 = (float *)v8->uLightColorR; | |
1467 stru_F8AD28._blv_lights_rs[*v53] = (double)(signed int)a3 * 0.0039215689; | |
1468 a3 = (float *)v8->uLightColorG; | |
1469 stru_F8AD28._blv_lights_gs[*v53] = (double)(signed int)a3 * 0.0039215689; | |
1470 a3 = (float *)v8->uLightColorB; | |
1471 stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.0039215689; | |
1472 v54 = abs(v60); | |
1473 v55 = pRenderer->bUsingSpecular; | |
1474 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; | |
1475 stru_F8AD28._blv_lights_smthngs[*v53] = v8->field_B; | |
1476 v56 = pRenderer->pRenderD3D; | |
1477 v57 = stru_F8AD28._blv_lights_smthngs[*v53]; | |
1478 if ( pRenderer->pRenderD3D && v55 && v57 & 4 ) | |
1479 v57 = byte_4E94D2; | |
1480 stru_F8AD28._blv_lights_smthngs[*v53] = v57; | |
1481 result = 4 * *v53; | |
1482 if ( v56 && v55 ) | |
1483 { | |
1484 if ( stru_F8AD28._blv_lights_smthngs[*v53] & 4 ) | |
1485 { | |
1486 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) | |
1487 * 0.33000001; | |
1488 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) | |
1489 * 0.33000001; | |
1490 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) | |
1491 * 0.33000001; | |
1492 } | |
1493 } | |
1494 ++*v53; | |
1495 LOBYTE(result) = 1; | |
1496 return result; | |
1497 } | |
1498 // 4E94D2: using guessed type char byte_4E94D2; | |
1499 | |
1500 //----- (0045D3C7) -------------------------------------------------------- | |
1501 bool LightmapBuilder::_45D3C7(stru148 *a1) | |
1502 { | |
1503 LightmapBuilder *v2; // ebx@1 | |
1504 stru148 *result; // eax@1 | |
1505 float v4; // ecx@2 | |
1506 Span *i; // edi@5 | |
1507 | |
1508 v2 = this; | |
1509 result = (stru148 *)a1->prolly_head; | |
1510 if ( result && (v4 = result->field_4, *(int *)&v4) != 0 && *(unsigned int *)(LODWORD(v4) + 60) ) | |
1511 { | |
1512 for ( i = a1->prolly_head; ; i = i->pNext ) | |
1513 { | |
1514 result = i->pParent; | |
1515 if ( result->field_108 ) | |
1516 result = (stru148 *)_45D426( | |
1517 i, | |
1518 a1->pEdgeList1, | |
1519 a1->uEdgeList1Size, | |
1520 (Edge *)a1->pEdgeList2, | |
1521 a1->uEdgeList2Size); | |
1522 if ( a1->prolly_tail == i ) | |
1523 break; | |
1524 } | |
1525 LOBYTE(result) = 1; | |
1526 } | |
1527 else | |
1528 { | |
1529 LOBYTE(result) = 0; | |
1530 } | |
1531 return (bool)result; | |
1532 } | |
1533 | |
1534 //----- (0045D426) -------------------------------------------------------- | |
1535 int LightmapBuilder::_45D426(Span *a1, Edge **a2, unsigned int a3, Edge *a4, int a5) | |
1536 { | |
1537 int v6; // edi@1 | |
1538 signed int v7; // ebx@3 | |
1539 signed int v8; // ecx@3 | |
1540 Span *v9; // esi@3 | |
1541 double v10; // st7@4 | |
1542 Edge *v11; // edx@5 | |
1543 double v12; // st7@11 | |
1544 int v13; // edx@12 | |
1545 int v14; // ebx@17 | |
1546 Edge *v15; // edi@17 | |
1547 float v16; // ST04_4@17 | |
1548 float v17; // ST04_4@17 | |
1549 double v18; // st7@17 | |
1550 int result; // eax@19 | |
1551 double v20; // ST14_8@20 | |
1552 double v21; // ST14_8@20 | |
1553 double v22; // st7@20 | |
1554 int v23; // ecx@20 | |
1555 double v24; // st6@20 | |
1556 double v25; // st7@23 | |
1557 double v26; // st7@28 | |
1558 __int16 v27; // fps@28 | |
1559 char v28; // c0@28 | |
1560 char v29; // c2@28 | |
1561 char v30; // c3@28 | |
1562 double v31; // st7@29 | |
1563 double v32; // st7@30 | |
1564 __int16 v33; // fps@30 | |
1565 char v34; // c0@30 | |
1566 char v35; // c2@30 | |
1567 char v36; // c3@30 | |
1568 LightmapBuilder *this_4; // [sp+14h] [bp-8h]@1 | |
1569 signed int v38; // [sp+18h] [bp-4h]@3 | |
1570 float a1a; // [sp+24h] [bp+8h]@20 | |
1571 float a2a; // [sp+28h] [bp+Ch]@17 | |
1572 float a3a; // [sp+2Ch] [bp+10h]@17 | |
1573 float a5a; // [sp+34h] [bp+18h]@20 | |
1574 float a5b; // [sp+34h] [bp+18h]@20 | |
1575 | |
1576 v6 = 0; | |
1577 this_4 = this; | |
1578 if ( a5 && a3 ) | |
1579 { | |
1580 v7 = -1; | |
1581 v8 = 0; | |
1582 v9 = a1; | |
1583 v38 = -1; | |
1584 if ( (signed int)a3 > 0 ) | |
1585 { | |
1586 v10 = (double)a1->field_A; | |
1587 while ( 1 ) | |
1588 { | |
1589 v11 = a2[v8]; | |
1590 if ( v10 >= v11->field_2C ) | |
1591 { | |
1592 if ( v10 <= v11->field_30 ) | |
1593 break; | |
1594 } | |
1595 ++v8; | |
1596 if ( v8 >= (signed int)a3 ) | |
1597 goto LABEL_10; | |
1598 } | |
1599 v38 = v8; | |
1600 } | |
1601 LABEL_10: | |
1602 if ( a5 > 0 ) | |
1603 { | |
1604 v12 = (double)a1->field_A; | |
1605 while ( 1 ) | |
1606 { | |
1607 v13 = *((unsigned int *)&a4->field_0 + v6); | |
1608 if ( v12 >= *(float *)(v13 + 44) ) | |
1609 { | |
1610 if ( v12 <= *(float *)(v13 + 48) ) | |
1611 break; | |
1612 } | |
1613 ++v6; | |
1614 if ( v6 >= a5 ) | |
1615 goto LABEL_17; | |
1616 } | |
1617 v7 = v6; | |
1618 } | |
1619 LABEL_17: | |
1620 v14 = *((unsigned int *)&a4->field_0 + v7); | |
1621 v15 = a2[v38]; | |
1622 v16 = (double)a1->field_A; | |
1623 a3a = _45D643(a2[v38], v16); | |
1624 v17 = (double)a1->field_A; | |
1625 v18 = _45D643((Edge *)v14, v17); | |
1626 a2a = v18; | |
1627 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x80 ) | |
1628 { | |
1629 HIWORD(result) = HIWORD(a3a); | |
1630 a1->field_14 = v18; | |
1631 a1->field_10 = a3a; | |
1632 } | |
1633 else | |
1634 { | |
1635 a5a = ((double)a1->field_A - v15->field_2C) * v15->field_4 + v15->field_24 - 0.5; | |
1636 v20 = a5a + 6.7553994e15; | |
1637 a5b = (double)SLODWORD(v20); | |
1638 a1a = ((double)a1->field_A - *(float *)(v14 + 44)) * *(float *)(v14 + 4) + *(float *)(v14 + 36) + 0.5; | |
1639 v21 = a1a + 6.7553994e15; | |
1640 v22 = (double)SLODWORD(v21); | |
1641 result = v9->field_8; | |
1642 v23 = v9->field_C; | |
1643 v24 = -((a3a - a2a) / (v22 - a5b)); | |
1644 v9->field_10 = ((double)result - a5b) * v24 + a3a; | |
1645 v9->field_14 = a2a - (v22 - (double)(result + v23)) * v24; | |
1646 } | |
1647 if ( v9->field_10 < 0.0 || v9->field_10 <= 1.0 ) | |
1648 { | |
1649 if ( v9->field_10 >= 0.0 ) | |
1650 v25 = v9->field_10; | |
1651 else | |
1652 v25 = 0.0; | |
1653 } | |
1654 else | |
1655 { | |
1656 v25 = 1.0; | |
1657 } | |
1658 v9->field_10 = v25; | |
1659 if ( v9->field_14 < 0.0 | |
1660 || (v26 = v9->field_14, | |
1661 //UNDEF(v27), | |
1662 v28 = 1.0 < v26, | |
1663 v29 = 0, | |
1664 v30 = 1.0 == v26, | |
1665 BYTE1(result) = HIBYTE(v27), | |
1666 v26 <= 1.0) ) | |
1667 { | |
1668 v32 = v9->field_14; | |
1669 //UNDEF(v33); | |
1670 v34 = 0.0 < v32; | |
1671 v35 = 0; | |
1672 v36 = 0.0 == v32; | |
1673 BYTE1(result) = HIBYTE(v33); | |
1674 if ( v32 >= 0.0 ) | |
1675 v31 = v9->field_14; | |
1676 else | |
1677 v31 = 0.0; | |
1678 } | |
1679 else | |
1680 { | |
1681 v31 = 1.0; | |
1682 } | |
1683 v9->field_14 = v31; | |
1684 LOBYTE(result) = 1; | |
1685 } | |
1686 else | |
1687 { | |
1688 LOBYTE(result) = 0; | |
1689 } | |
1690 return result; | |
1691 } | |
1692 // 4D864C: using guessed type char byte_4D864C; | |
1693 | |
1694 //----- (0045D643) -------------------------------------------------------- | |
1695 double LightmapBuilder::_45D643(Edge *a1, float a2) | |
1696 { | |
1697 double result; // st7@1 | |
1698 | |
1699 result = (a1->field_1C - a1->field_20) * -1.0 / (a1->field_30 - a1->field_2C) * (a2 - a1->field_2C) + a1->field_1C; | |
1700 if ( result < 0.0 || result <= 1.0 ) | |
1701 { | |
1702 if ( result < 0.0 ) | |
1703 result = 0.0; | |
1704 } | |
1705 else | |
1706 { | |
1707 result = 1.0; | |
1708 } | |
1709 return result; | |
1710 } | |
1711 | |
1712 //----- (0045D698) -------------------------------------------------------- | |
1713 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) | |
1714 { | |
1715 bool result; // eax@1 | |
1716 LightmapBuilder *v3; // esi@1 | |
1717 RenderVertexSoft *v4; // edi@3 | |
1718 RenderVertexSoft *v5; // edi@7 | |
1719 IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1 | |
1720 bool v7; // [sp+14h] [bp-4h]@2 | |
1721 bool a2a; // [sp+20h] [bp+8h]@6 | |
1722 | |
1723 result = (bool)pGame->pIndoorCameraD3D; | |
1724 v3 = this; | |
1725 thisa = pGame->pIndoorCameraD3D; | |
1726 if ( bit_one_for_list1__bit_two_for_list2 & 1 ) | |
1727 { | |
1728 v7 = 0; | |
1729 if ( (signed int)this->std__vector_000004_size > 0 ) | |
1730 { | |
1731 v4 = this->std__vector_000004[0].pVertices; | |
1732 do | |
1733 { | |
1734 pGame->pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0); | |
1735 ++v7; | |
1736 v4 = (RenderVertexSoft *)((char *)v4 + 3100); | |
1737 result = v7; | |
1738 } | |
1739 while ( v7 < (signed int)v3->std__vector_000004_size ); | |
1740 } | |
1741 } | |
1742 if ( bit_one_for_list1__bit_two_for_list2 & 2 ) | |
1743 { | |
1744 a2a = 0; | |
1745 if ( (signed int)v3->std__vector_183808_size > 0 ) | |
1746 { | |
1747 v5 = v3->std__vector_183808[0].pVertices; | |
1748 do | |
1749 { | |
1750 pGame->pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999); | |
1751 ++a2a; | |
1752 v5 = (RenderVertexSoft *)((char *)v5 + 3100); | |
1753 result = a2a; | |
1754 } | |
1755 while ( a2a < (signed int)v3->std__vector_183808_size ); | |
1756 } | |
1757 } | |
1758 LOBYTE(result) = 1; | |
1759 return result; | |
1760 } | |
1761 | |
1762 //----- (0045D73F) -------------------------------------------------------- | |
1763 void LightmapBuilder::DrawLightmaps(int a2) | |
1764 { | |
1765 if ( a2 == 2 ) | |
1766 DoDrawLightmaps(); | |
1767 } | |
1768 | |
1769 //----- (0045D74F) -------------------------------------------------------- | |
1770 char LightmapBuilder::_45D74F_MessWithLight(int a2, int *a3) | |
1771 { | |
1772 char v3; // zf@1 | |
1773 IDirect3DDevice3 *v4; // eax@2 | |
1774 HRESULT v5; // eax@2 | |
1775 char *v6; // eax@2 | |
1776 struct IDirect3DTexture2 *v7; // edi@4 | |
1777 HRESULT v8; // eax@8 | |
1778 HRESULT v9; // eax@8 | |
1779 HRESULT v10; // eax@8 | |
1780 HRESULT v11; // eax@8 | |
1781 HRESULT v12; // eax@8 | |
1782 int *v13; // eax@8 | |
1783 float v14; // ecx@15 | |
1784 IDirect3DDevice3 *v15; // eax@21 | |
1785 HRESULT v16; // eax@21 | |
1786 IDirect3DDevice3 *v17; // eax@21 | |
1787 HRESULT v18; // eax@21 | |
1788 IDirect3DDevice3 *v19; // eax@21 | |
1789 HRESULT v20; // eax@21 | |
1790 IDirect3DDevice3 *v21; // eax@21 | |
1791 HRESULT v22; // eax@21 | |
1792 IDirect3DDevice3 *v23; // eax@23 | |
1793 std::string v25; // [sp+44h] [bp-44h]@12 | |
1794 signed int v26; // [sp+48h] [bp-40h]@21 | |
1795 signed int v27; // [sp+4Ch] [bp-3Ch]@21 | |
1796 Lightmap *v28; // [sp+50h] [bp-38h]@2 | |
1797 int v29; // [sp+54h] [bp-34h]@2 | |
1798 float v30; // [sp+58h] [bp-30h]@2 | |
1799 int arg4; // [sp+68h] [bp-20h]@8 | |
1800 float v32; // [sp+6Ch] [bp-1Ch]@8 | |
1801 float v33; // [sp+70h] [bp-18h]@8 | |
1802 int v34; // [sp+74h] [bp-14h]@19 | |
1803 int v35; // [sp+78h] [bp-10h]@2 | |
1804 int *v36; // [sp+7Ch] [bp-Ch]@10 | |
1805 int a1; // [sp+80h] [bp-8h]@12 | |
1806 float v38; // [sp+84h] [bp-4h]@1 | |
1807 | |
1808 v3 = this->std__vector_000004_size == 0; | |
1809 LODWORD(v38) = (int)this; | |
1810 if ( !v3 ) | |
1811 { | |
1812 v30 = 0.0; | |
1813 //v4 = pRenderer->pRenderD3D->pDevice; | |
1814 ErrD3D(v4->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); | |
1815 v6 = (char *)stru_69BD44.c_str(); | |
1816 if ( !stru_69BD44.c_str() ) | |
1817 v6 = (char *)&dword_4D86F0; | |
1818 v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v6); | |
1819 if ( pRenderer->bUsingSpecular ) | |
1820 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); | |
1821 if ( !byte_4D864C || !(pGame->uFlags & 1) ) | |
1822 { | |
1823 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
1824 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | |
1825 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7)); | |
1826 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
1827 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u)); | |
1828 v13 = a3; | |
1829 v33 = 1.0; | |
1830 v32 = 1.0; | |
1831 *(float *)&arg4 = 1.0; | |
1832 if ( a3 ) | |
1833 { | |
1834 if ( *a3 != -1 ) | |
1835 { | |
1836 v36 = a3; | |
1837 do | |
1838 { | |
1839 v28 = (Lightmap *)(3100 * *v13 + LODWORD(v38) + 4); | |
1840 if ( !DrawLightmap(v28, (Vec3_float_ *)&arg4, 0.0) ) | |
1841 { | |
1842 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1230", 0); | |
1843 a1 = 5080812; | |
1844 } | |
1845 v13 = v36 + 1; | |
1846 v36 = v13; | |
1847 } | |
1848 while ( *v13 != -1 ); | |
1849 } | |
1850 } | |
1851 else | |
1852 { | |
1853 v14 = v38; | |
1854 v36 = 0; | |
1855 if ( *(unsigned int *)(LODWORD(v38) + 1587204) > 0 ) | |
1856 { | |
1857 a1 = LODWORD(v38) + 4; | |
1858 while ( 1 ) | |
1859 { | |
1860 if ( !DrawLightmap((Lightmap *)a1, (Vec3_float_ *)&arg4, 0.0) ) | |
1861 { | |
1862 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0); | |
1863 v35 = 5080812; | |
1864 } | |
1865 v36 = (int *)((char *)v36 + 1); | |
1866 a1 += 3100; | |
1867 if ( (signed int)v36 >= *(unsigned int *)(LODWORD(v38) + 1587204) ) | |
1868 break; | |
1869 v14 = v38; | |
1870 } | |
1871 } | |
1872 } | |
1873 v15 = pRenderer->pRenderD3D->pDevice; | |
1874 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
1875 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
1876 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
1877 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); | |
1878 } | |
1879 if ( pRenderer->bUsingSpecular ) | |
1880 { | |
1881 //LODWORD(v30) = 1; | |
1882 //v29 = 28; | |
1883 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; | |
1884 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1); | |
1885 v30 = pRenderer->uFogColor; | |
1886 v23 = pRenderer->pRenderD3D->pDevice; | |
1887 //v29 = 34; | |
1888 //v28 = (Lightmap *)v23; | |
1889 v23->SetRenderState(D3DRENDERSTATE_FOGCOLOR, LODWORD(pRenderer->uFogColor)); | |
1890 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; | |
1891 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, false); | |
1892 } | |
1893 } | |
1894 return 1; | |
1895 } | |
1896 // 4D864C: using guessed type char byte_4D864C; | |
1897 // 4D86F0: using guessed type int dword_4D86F0; | |
1898 | |
1899 //----- (0045DA56) -------------------------------------------------------- | |
1900 bool LightmapBuilder::DrawLightmaps2(float a2) | |
1901 { | |
1902 LightmapBuilder *v2; // esi@1 | |
1903 bool result; // eax@1 | |
1904 signed int v4; // edi@2 | |
1905 std::string v5; // [sp-14h] [bp-3Ch]@5 | |
1906 const char *v6; // [sp-4h] [bp-2Ch]@5 | |
1907 int v7; // [sp+0h] [bp-28h]@5 | |
1908 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2 | |
1909 std::string *v9; // [sp+18h] [bp-10h]@5 | |
1910 unsigned int v10; // [sp+1Ch] [bp-Ch]@5 | |
1911 Lightmap *a1; // [sp+20h] [bp-8h]@3 | |
1912 int a3; // [sp+27h] [bp-1h]@5 | |
1913 | |
1914 v2 = this; | |
1915 result = this->std__vector_183808_size; | |
1916 if ( result ) | |
1917 { | |
1918 v4 = 0; | |
1919 v.z = 1.0; | |
1920 v.y = 1.0; | |
1921 v.x = 1.0; | |
1922 if ( result > 0 ) | |
1923 { | |
1924 a1 = this->std__vector_183808; | |
1925 do | |
1926 { | |
1927 result = DrawLightmap(a1, &v, a2); | |
1928 if ( !result ) | |
1929 { | |
1930 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0); | |
1931 v10 = 0x4D86ECu; | |
1932 } | |
1933 ++a1; | |
1934 ++v4; | |
1935 } | |
1936 while ( v4 < (signed int)v2->std__vector_183808_size); | |
1937 } | |
1938 } | |
1939 LOBYTE(result) = 1; | |
1940 return result; | |
1941 } | |
1942 | |
1943 //----- (0045DAE8) -------------------------------------------------------- | |
1944 bool LightmapBuilder::DrawLightmap(Lightmap *a1, Vec3_float_ *arg4, float thisa) | |
1945 { | |
1946 Lightmap *v4; // edx@1 | |
1947 bool result; // eax@2 | |
1948 double v6; // st7@3 | |
1949 Vec3_float_ *v7; // ecx@3 | |
1950 LEVEL_TYPE v8; // edi@3 | |
1951 int v9; // esi@3 | |
1952 double v10; // st7@4 | |
1953 unsigned int v11; // ebx@6 | |
1954 char *v12; // ecx@7 | |
1955 int v13; // edx@7 | |
1956 double v14; // st7@7 | |
1957 __int16 v15; // fps@8 | |
1958 unsigned __int8 v16; // c2@8 | |
1959 unsigned __int8 v17; // c3@8 | |
1960 double v18; // st3@8 | |
1961 int v19; // eax@11 | |
1962 double v20; // st3@11 | |
1963 int v21; // eax@11 | |
1964 char v22; // zf@11 | |
1965 HRESULT v23; // eax@15 | |
1966 signed int v24; // [sp-1Ch] [bp-670h]@13 | |
1967 const char *v25; // [sp-18h] [bp-66Ch]@13 | |
1968 int v26; // [sp-14h] [bp-668h]@13 | |
1969 HRESULT a2; // [sp+0h] [bp-654h]@15 | |
1970 char v28; // [sp+4h] [bp-650h]@7 | |
1971 double v29; // [sp+640h] [bp-14h]@3 | |
1972 __int64 v30; // [sp+648h] [bp-Ch]@3 | |
1973 float v31; // [sp+650h] [bp-4h]@3 | |
1974 signed int a1b; // [sp+65Ch] [bp+8h]@3 | |
1975 float a1c; // [sp+65Ch] [bp+8h]@3 | |
1976 float a1d; // [sp+65Ch] [bp+8h]@3 | |
1977 float a1e; // [sp+65Ch] [bp+8h]@3 | |
1978 unsigned int a1a; // [sp+65Ch] [bp+8h]@7 | |
1979 int arg4a; // [sp+660h] [bp+Ch]@3 | |
1980 | |
1981 v4 = a1; | |
1982 if ( (signed int)a1->uNumVertices >= 3 ) | |
1983 { | |
1984 v6 = (double)BYTE1(a1->field_C10) * a1->flt_C14; | |
1985 v30 = a1->field_C10 & 0xFFi64; | |
1986 a1b = BYTE2(a1->field_C10); | |
1987 v7 = arg4; | |
1988 v31 = v6; | |
1989 *((float *)&v30 + 1) = (double)v30 * v4->flt_C14; | |
1990 a1c = (double)a1b * v4->flt_C14 * arg4->x; | |
1991 v29 = a1c + 6.7553994e15; | |
1992 arg4a = LODWORD(v29); | |
1993 a1d = v31 * v7->y; | |
1994 v29 = a1d + 6.7553994e15; | |
1995 LODWORD(v31) = LODWORD(v29); | |
1996 a1e = *((float *)&v30 + 1) * v7->z; | |
1997 v29 = a1e + 6.7553994e15; | |
1998 HIDWORD(v30) = LODWORD(v29); | |
1999 v8 = uCurrentlyLoadedLevelType; | |
2000 v9 = LODWORD(v29) | ((LODWORD(v31) | (arg4a << 8)) << 8); | |
2001 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2002 v10 = (double)pOutdoorCamera->shading_dist_mist; | |
2003 else | |
2004 v10 = 16192.0; | |
2005 v11 = v4->uNumVertices; | |
2006 if ( (signed int)v11 > 0 ) | |
2007 { | |
2008 v12 = &v28; | |
2009 v13 = (int)&v4->pVertices[0].vWorldViewPosition; | |
2010 v14 = 1.0 / v10; | |
2011 a1a = v11; | |
2012 do | |
2013 { | |
2014 //UNDEF(v15); | |
2015 v18 = 1.0 - 1.0 / (v14 * *(float *)v13 * 1000.0); | |
2016 if ( !(v17 | v16) ) | |
2017 { | |
2018 v18 = v18 - thisa; | |
2019 if ( v18 < 0.000099999997 ) | |
2020 v18 = 0.000099999997; | |
2021 } | |
2022 *((float *)v12 + 1) = v18; | |
2023 v19 = *(unsigned int *)(v13 + 12); | |
2024 *((unsigned int *)v12 + 4) = 0; | |
2025 v20 = 1.0 / *(float *)v13; | |
2026 *((unsigned int *)v12 - 1) = v19; | |
2027 *(unsigned int *)v12 = *(unsigned int *)(v13 + 16); | |
2028 *((unsigned int *)v12 + 5) = *(unsigned int *)(v13 + 24); | |
2029 v21 = *(unsigned int *)(v13 + 28); | |
2030 *((unsigned int *)v12 + 3) = v9; | |
2031 *((unsigned int *)v12 + 6) = v21; | |
2032 v13 += 48; | |
2033 v12 += 32; | |
2034 v22 = a1a-- == 1; | |
2035 *((float *)v12 - 6) = v20; | |
2036 } | |
2037 while ( !v22 ); | |
2038 } | |
2039 if ( v8 == 1 ) | |
2040 { | |
2041 v26 = 1346; | |
2042 v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp"; | |
2043 v24 = 28; | |
2044 } | |
2045 else | |
2046 { | |
2047 v26 = 1354; | |
2048 v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp"; | |
2049 v24 = 16; | |
2050 } | |
2051 v23 = pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
2052 D3DPT_TRIANGLEFAN, | |
2053 452, | |
2054 &a2, | |
2055 v11, | |
2056 v24); | |
2057 //CheckHRESULT((CheckHRESULT_stru0 *)&thisa, v23, v25, v26, 0); | |
2058 LOBYTE(result) = 1; | |
2059 } | |
2060 else | |
2061 { | |
2062 LOBYTE(result) = 0; | |
2063 } | |
2064 return result; | |
2065 } | |
2066 | |
2067 //----- (0045DCA9) -------------------------------------------------------- | |
2068 void LightmapBuilder::DoDrawLightmaps() | |
2069 { | |
2070 const char *v1; // ebx@0 | |
2071 int v2; // ebp@0 | |
2072 int v3; // edi@0 | |
2073 int v4; // esi@0 | |
2074 HRESULT v5; // eax@4 | |
2075 HRESULT v6; // eax@4 | |
2076 HRESULT v7; // eax@4 | |
2077 char *v8; // eax@4 | |
2078 //IDirect3DDevice3Vtbl *v9; // ebp@6 | |
2079 struct IDirect3DTexture2 *v10; // ST90_4@6 | |
2080 //IDirect3DDevice3 *v11; // ST88_4@6 | |
2081 HRESULT v12; // eax@6 | |
2082 HRESULT v13; // eax@6 | |
2083 HRESULT v14; // eax@6 | |
2084 HRESULT v15; // eax@6 | |
2085 HRESULT v16; // eax@6 | |
2086 HRESULT v17; // eax@6 | |
2087 HRESULT v18; // eax@6 | |
2088 HRESULT v19; // eax@6 | |
2089 LightmapBuilder *v20; // [sp+98h] [bp-8h]@1 | |
2090 LightmapBuilder *v21; // [sp+9Ch] [bp-4h]@1 | |
2091 LightmapBuilder *thisa; // [sp+A4h] [bp+4h]@0 | |
2092 //CheckHRESULT_stru0 a8; // [sp+A8h] [bp+8h]@0 | |
2093 //CheckHRESULT_stru0 thisaa; // [sp+B4h] [bp+14h]@0 | |
2094 | |
2095 v21 = this; | |
2096 v20 = this; | |
2097 if ( this->std__vector_183808_size ) | |
2098 { | |
2099 if ( pRenderer->bUsingSpecular ) | |
2100 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | |
2101 | |
2102 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | |
2103 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); | |
2104 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | |
2105 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | |
2106 | |
2107 v8 = (char *)stru_69BD44.c_str(); | |
2108 if ( !stru_69BD44.size() ) | |
2109 v8 = (char *)&dword_4D86F0; | |
2110 //v9 = pRenderer->pRenderD3D->pDevice->lpVtbl; | |
2111 v10 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v8); | |
2112 //v11 = pRenderer->pRenderD3D->pDevice; | |
2113 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v10)); | |
2114 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
2115 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u)); | |
2116 | |
2117 DrawLightmaps2(0.00050000002); | |
2118 | |
2119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | |
2120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | |
2121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | |
2122 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); | |
2123 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); | |
2124 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2)); | |
2125 if ( pRenderer->bUsingSpecular ) | |
2126 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u)); | |
2127 } | |
2128 } |